diff --git a/.gitignore b/.gitignore index d6dc0d7a3e..b03f74fc5d 100644 --- a/.gitignore +++ b/.gitignore @@ -9,19 +9,24 @@ #idea /.idea +/*/out /classes *.iml #gradle /build /.gradle -/mdk/.gradle -/mdk/build +/*/build +/*/.gradle -#occupational hazards +# Projects repo, either ignore it, or ignore patches. /projects/mcp/ /projects/clean/ /projects/forge/ +/projects/fmlonly/ +#/patches/ + +#occupational hazards /projects/**/build/ /projects/**/out/ /projects/**/run/ @@ -31,16 +36,11 @@ src/generated/resources/.cache/ #Patch rejects /patches-/ -*.patch.rej +#*.patch.rej +/projects/*/rejects/ # FML changelog changelog.txt *.py *.7z /logs/ - -/projects/forge/rejects/ - -# Srg2Source causes import bugs on these patches. If you intentionnally change these, remove the ignore. -/patches/minecraft/net/minecraft/client/renderer/ViewFrustum.java.patch -/patches/minecraft/net/minecraft/data/BlockModelDefinition.java.patch diff --git a/Jenkinsfile b/Jenkinsfile index b9ba1c1648..a04f76131a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,7 +6,7 @@ pipeline { } agent { docker { - image 'gradle:jdk8' + image 'gradle:7-jdk16' args '-v forgegc:/home/gradle/.gradle/' } } @@ -69,7 +69,7 @@ pipeline { steps { withCredentials([usernamePassword(credentialsId: 'maven-forge-user', usernameVariable: 'MAVEN_USER', passwordVariable: 'MAVEN_PASSWORD')]) { withGradle { - sh './gradlew ${GRADLE_ARGS} :forge:publish -PkeystoreKeyPass=${KEYSTORE_KEYPASS} -PkeystoreStorePass=${KEYSTORE_STOREPASS} -Pkeystore=${KEYSTORE} -PcrowdinKey=${CROWDIN}' + sh './gradlew ${GRADLE_ARGS} publish -PkeystoreKeyPass=${KEYSTORE_KEYPASS} -PkeystoreStorePass=${KEYSTORE_STOREPASS} -Pkeystore=${KEYSTORE} -PcrowdinKey=${CROWDIN}' } } } @@ -88,7 +88,7 @@ pipeline { } steps { withGradle { - sh './gradlew ${GRADLE_ARGS} :forge:publish -PcrowdinKey=${CROWDIN}' + sh './gradlew ${GRADLE_ARGS} publish -PcrowdinKey=${CROWDIN}' } } } diff --git a/build.gradle b/build.gradle index 653a19ab46..8f203194b3 100644 --- a/build.gradle +++ b/build.gradle @@ -16,10 +16,11 @@ import java.util.Date import java.util.LinkedHashMap import net.minecraftforge.forge.tasks.* import static net.minecraftforge.forge.tasks.Util.* +import net.minecraftforge.gradle.common.tasks.ApplyBinPatches import net.minecraftforge.gradle.common.tasks.DownloadMavenArtifact import net.minecraftforge.gradle.common.tasks.ExtractInheritance import net.minecraftforge.gradle.common.tasks.SignJar -import net.minecraftforge.gradle.patcher.tasks.ReobfuscateJar +import net.minecraftforge.gradle.userdev.tasks.RenameJar import org.apache.tools.ant.filters.ReplaceTokens import org.gradle.plugins.ide.eclipse.model.SourceFolder @@ -30,9 +31,7 @@ plugins { id 'eclipse' } -Util.init() //Init all our extension methods - -println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch')) +Util.init() //Init all our extension methods! ext { JAR_SIGNER = null @@ -44,17 +43,128 @@ ext { ] } MAPPING_CHANNEL = 'official' - MAPPING_VERSION = '1.16.5' - MC_VERSION = '1.16.5' - MCP_VERSION = '20210115.111550' - SPI_VERSION = '3.2.0' + MAPPING_VERSION = '1.17.1' + MC_VERSION = '1.17.1' + MCP_VERSION = '20210706.113038' + SPI_VERSION = '4.0.9' + ACCESSTRANSFORMERS_VERSION = '8.0.4' + COREMODS_VERSION = '5.0.1' + EVENTBUS_VERSION = '5.0.3' + MODLAUNCHER_VERSION = '9.0.7' + SECUREJARHANDLER_VERSION = '0.9.44' + BOOTSTRAPLAUNCHER_VERSION = '0.1.15' + ASM_VERSION = '9.1' + INSTALLER_VERSION = '2.1.4' + + GIT_INFO = gradleutils.gitInfo + VERSION = gradleutils.getFilteredMCTagOffsetBranchVersion(true, '[0-9]', MC_VERSION) + // FML_VERSION = gradleutils.getFilteredMCTagOffsetBranchVersion(true, 'FML', MC_VERSION) + FORGE_VERSION = VERSION.substring(MC_VERSION.length() + 1) + + SPECIAL_SOURCE = 'net.md-5:SpecialSource:1.10.0' + VIGNETTE = 'net.minecraftforge.lex:vignette:0.2.0.16' + BINPATCH_TOOL = 'net.minecraftforge:binarypatcher:1.0.12:fatjar' + INSTALLER_TOOLS = 'net.minecraftforge:installertools:1.2.7' + JAR_SPLITTER = 'net.minecraftforge:jarsplitter:1.1.4' +} + +println('Version: ' + VERSION + + ' Java: ' + System.getProperty('java.version') + + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ')' + + ' Arch: ' + System.getProperty('os.arch')) + +def extraTxts = [ + rootProject.file('CREDITS.txt'), + rootProject.file('LICENSE.txt') +] + +def changelog = rootProject.file('build/changelog.txt') +if (changelog.exists()) + extraTxts += changelog + +subprojects { + apply plugin: 'maven-publish' + apply plugin: 'eclipse' + apply plugin: 'java' + + group = 'net.minecraftforge' + version = VERSION + //println(name + ' Version: ' + version) + + ext { + isNonStable = { String version -> + def stableKeyword = ['RELEASE', 'FINAL', 'GA'].any { ver -> version.toUpperCase().contains(ver) } + def regex = /^[0-9,.v-]+(-r)?$/ + return !stableKeyword && !(version ==~ regex) + } + } + + repositories { + mavenLocal() + mavenCentral() + maven { + name = 'forge' + url = 'https://maven.minecraftforge.net/' + } + } + + java.toolchain.languageVersion = JavaLanguageVersion.of(16) + + publishing { + publications { + mavenJava(MavenPublication) { + // Normal Maven/old gradle doesn't support '2.+' version wildcards + // For now we just suppress. We *should* force the resolution to pinned versions. + suppressPomMetadataWarningsFor('apiElements') + suppressPomMetadataWarningsFor('runtimeElements') + pom { + name = project.name + description = 'Modifactions to Minecraft to enable mod developers.' + url = 'https://github.com/MinecraftForge/MinecraftForge' + + scm { + url = 'https://github.com/MinecraftForge/MinecraftForge' + connection = 'scm:git:git://github.com/MinecraftForge/MinecraftForge.git' + developerConnection = 'scm:git:git@github.com:MinecraftForge/MinecraftForge.git' + } + + issueManagement { + system = 'github' + url = 'https://github.com/MinecraftForge/MinecraftForge/issues' + } + + licenses { + license { + name = 'LGPL 2.1' + url = 'https://github.com/MinecraftForge/MinecraftForge/blob/1.13-pre/LICENSE.txt' + distribution = 'repo' + } + } + } + } + } + repositories { + maven { + if (System.env.MAVEN_USER) { + url 'https://maven.minecraftforge.net/releases/' + authentication { + basic(BasicAuthentication) + } + credentials { + username = System.env.MAVEN_USER ?: 'not' + password = System.env.MAVEN_PASSWORD ?: 'set' + } + } else { + url 'file://' + rootProject.file('repo').getAbsolutePath() + } + } + } + } } project(':mcp') { apply plugin: 'net.minecraftforge.gradle.mcp' - repositories { - mavenLocal() - } + tasks.withType(AbstractPublishToMaven.class).forEach{tsk -> tsk.enabled = false } // We don't want to publish anything mcp { config MC_VERSION + '-' + MCP_VERSION pipeline = 'joined' @@ -63,20 +173,13 @@ project(':mcp') { project(':clean') { evaluationDependsOn(':mcp') - apply plugin: 'eclipse' apply plugin: 'net.minecraftforge.gradle.patcher' - - java.toolchain.languageVersion = JavaLanguageVersion.of(8) - - repositories { - mavenLocal() - mavenCentral() - } - + tasks.withType(AbstractPublishToMaven.class).forEach{tsk -> tsk.enabled = false } // We don't want to publish anything + dependencies { implementation 'net.minecraftforge:forgespi:' + SPI_VERSION } - + patcher { parent = project(':mcp') mcVersion = MC_VERSION @@ -86,7 +189,9 @@ project(':clean') { runs { clean_client { + client true taskName 'clean_client' + ideaModule "${rootProject.name}.${project.name}.main" main 'net.minecraft.client.main.Main' workingDirectory project.file('run') @@ -99,7 +204,9 @@ project(':clean') { } clean_server { + client false taskName 'clean_server' + ideaModule "${rootProject.name}.${project.name}.main" main 'net.minecraft.server.Main' workingDirectory project.file('run') @@ -108,46 +215,578 @@ project(':clean') { } } -project(':forge') { +def sharedDeps = { + moduleonly "cpw.mods:securejarhandler:${SECUREJARHANDLER_VERSION}" + moduleonly "org.ow2.asm:asm:${ASM_VERSION}" + moduleonly "org.ow2.asm:asm-commons:${ASM_VERSION}" + moduleonly "org.ow2.asm:asm-tree:${ASM_VERSION}" + moduleonly "org.ow2.asm:asm-util:${ASM_VERSION}" + moduleonly "org.ow2.asm:asm-analysis:${ASM_VERSION}" + moduleonly "cpw.mods:bootstraplauncher:${BOOTSTRAPLAUNCHER_VERSION}" + + installer "cpw.mods:securejarhandler:${SECUREJARHANDLER_VERSION}" + installer "org.ow2.asm:asm:${ASM_VERSION}" + installer "org.ow2.asm:asm-commons:${ASM_VERSION}" + installer "org.ow2.asm:asm-tree:${ASM_VERSION}" + installer "org.ow2.asm:asm-util:${ASM_VERSION}" + installer "org.ow2.asm:asm-analysis:${ASM_VERSION}" + installer "net.minecraftforge:accesstransformers:${ACCESSTRANSFORMERS_VERSION}" + installer 'org.antlr:antlr4-runtime:4.9.1' //Dep of AccessTransformer + installer "net.minecraftforge:eventbus:${EVENTBUS_VERSION}" + installer "net.minecraftforge:forgespi:${SPI_VERSION}" + installer "net.minecraftforge:coremods:${COREMODS_VERSION}" + installer "cpw.mods:modlauncher:${MODLAUNCHER_VERSION}" + installer 'net.minecraftforge:unsafe:0.2.+' + installer 'com.electronwill.night-config:core:3.6.3' + installer 'com.electronwill.night-config:toml:3.6.3' + installer 'org.apache.maven:maven-artifact:3.6.3' + installer 'org.apache.commons:commons-lang3:3.8.1' + installer 'net.jodah:typetools:0.8.3' + installer 'org.apache.logging.log4j:log4j-api:2.14.1' + installer 'org.apache.logging.log4j:log4j-core:2.14.1' + installer 'net.minecrell:terminalconsoleappender:1.2.0' + installer 'org.jline:jline-reader:3.12.+' //Dep of TerminaalConsoleeAppender + installer 'org.jline:jline-terminal:3.12.+' //Dep of TerminaalConsoleeAppender + installer 'net.sf.jopt-simple:jopt-simple:5.0.4' + // installer 'org.spongepowered:mixin:0.8.3' + installer 'org.openjdk.nashorn:nashorn-core:15.1.1' + installer 'com.google.guava:guava:21.0' + installer 'com.google.code.gson:gson:2.8.0' + + /* + installer 'org.lwjgl:lwjgl:3.2.2' + installer 'org.lwjgl:lwjgl-glfw:3.2.2' + installer 'org.lwjgl:lwjgl-opengl:3.2.2' + installer 'org.lwjgl:lwjgl-stb:3.2.2' + */ +} + +def sharedFmlonlyForge = { Project prj -> + ['Client', 'Server', 'Joined'].each { side -> + ['slim', 'extra'].each { type -> + prj.task([type: DownloadMavenArtifact], "download${side}${type.capitalize()}") { + artifact = "net.minecraft:${side.toLowerCase()}:${MC_VERSION}-${MCP_VERSION}:${type}" + } + } + + if (side.equals('Joined')) { + prj.task([type: DownloadMavenArtifact], "createJoinedSRG") { + artifact = "net.minecraft:joined:${MC_VERSION}-${MCP_VERSION}:srg" + } + } else { + prj.task([type: RenameJar, dependsOn: prj.tasks.createMcp2Srg], "create${side}SRG") { + tool = VIGNETTE + args = [ + '--jar-in', '{input}', + '--jar-out', '{output}', + '--mapping-format', 'tsrg2', + '--mappings', '{mappings}', + // '--stable', + '--create-inits', '--fix-param-annotations', '--fernflower-meta' + ] + mappings = prj.tasks.createMcp2Srg.srg + input = prj.tasks.getByName("download${side}Slim").output + output = file("build/create${side}SRG/output.jar") + } + } + + def gen = prj.tasks.getByName("gen${side}BinPatches") + def createSRG = prj.tasks.getByName("create${side}SRG") + gen.dependsOn(createSRG) + gen.tool = BINPATCH_TOOL + gen.cleanJar = createSRG.output + + prj.task([type: ApplyBinPatches, dependsOn: gen], "apply${side}BinPatches") { + clean = gen.cleanJar + patch = gen.output + tool = BINPATCH_TOOL + } + } + + prj.task([type: DownloadMavenArtifact], 'downloadInstaller') { + artifact = "net.minecraftforge:installer:${INSTALLER_VERSION}:shrunk" + changing = true + } + + prj.afterEvaluate { + [prj.tasks.universalJar, prj.tasks.installerJar].each { t -> + def signTask = prj.task([type: SignJar, dependsOn: t], "sign${t.name.capitalize()}") { + onlyIf { + JAR_SIGNER != null && t.state.failure == null + } + def jarsigner = JAR_SIGNER == null ? [:] : JAR_SIGNER + alias = 'forge' + storePass = jarsigner.storepass + keyPass = jarsigner.keypass + keyStore = jarsigner.keystore + inputFile = t.archiveFile.get().asFile + outputFile = t.archiveFile.get().asFile + doFirst { + prj.logger.lifecycle('Signing: ' + inputFile) + } + } + t.finalizedBy(signTask) + } + } + + prj.tasks.userdevConfig { + def launchPrefix = prj.name == "forge" ? "forge" : "fml" + getArtifacts(prj, prj.configurations.installer, true).each { key, lib -> libraries.add(lib.name) } + getArtifacts(prj, prj.configurations.moduleonly, true).each { key, lib -> + libraries.add(lib.name) + modules.add(lib.name) + } + for (child in prj.ext.PACKED_DEPS) { + libraries.add(Util.getMavenDep(rootProject.tasks.findByPath(child))) + } + //libraries.add("${project.group}:${project.name}:${project.version}:launcher") + inject = '' // We don't have a userdev sourceset anymore. Empty as a gradle workaround... + runs { + client { + environment 'MOD_CLASSES', '{source_roots}' + environment 'MCP_MAPPINGS', '{mcp_mappings}' + + property 'nativesDirectory', '{natives}' + + args '--launchTarget', "${launchPrefix}clientuserdev" + args '--version', 'MOD_DEV' + args '--assetIndex', '{asset_index}' + args '--assetsDir', '{assets_root}' + } + + server { + environment 'MOD_CLASSES', '{source_roots}' + environment 'MCP_MAPPINGS', '{mcp_mappings}' + + args '--launchTarget', "${launchPrefix}serveruserdev" + } + + data { + environment 'MOD_CLASSES', '{source_roots}' + environment 'MCP_MAPPINGS', '{mcp_mappings}' + + args '--launchTarget', "${launchPrefix}datauserdev" + args '--assetIndex', '{asset_index}' + args '--assetsDir', '{assets_root}' + } + } + } + + def userdevRuns = prj.tasks.userdevConfig.runs + for (def run : prj.patcher.runs + userdevRuns) { + if (run.parents) continue // We already added this to the parent run config + //run.property 'bsl.debug', 'true' + run.main 'cpw.mods.bootstraplauncher.BootstrapLauncher' + + run.args '--gameDir', '.' + run.args '--fml.forgeVersion', FORGE_VERSION + run.args '--fml.mcVersion', MC_VERSION + run.args '--fml.forgeGroup', prj.group + run.args '--fml.mcpVersion', MCP_VERSION + + if (run.name.contains('client')) { + run.client true + } else { + run.client false + } + + // SecureJarHandler bootstrap values. + run.property 'legacyClassPath', '{runtime_classpath}' + run.property 'ignoreList', prj.configurations.moduleonly.files.collect {it.name}.join(',') + ",client-extra,fmlcore,javafmllanguage,mclanguage,${prj.name}-${prj.version},${prj.rootProject.ext.MC_VERSION}-${prj.name}${prj.version.substring(prj.rootProject.ext.MC_VERSION.length())}" + run.property 'mergeModules', 'jna-5.8.0.jar,jna-platform-58.0.jar,java-objc-bridge-1.0.0.jar' + if (userdevRuns.contains(run)) { + run.jvmArgs '-p', '{modules}' + } else { + run.jvmArgs '-p', prj.configurations.moduleonly.files.collect { it.path }.join(File.pathSeparator) + } + run.jvmArgs '--add-modules', 'ALL-MODULE-PATH' + run.jvmArgs '--add-opens', 'java.base/java.util.jar=cpw.mods.securejarhandler' + run.jvmArgs '--add-exports', 'java.base/sun.security.util=cpw.mods.securejarhandler' + run.jvmArgs '--add-exports', 'jdk.naming.dns/com.sun.jndi.dns=java.naming' + } + for (def run : prj.patcher.runs) { + if (run.parents) continue // We already added this to the parent run config + run.workingDirectory prj.file('run') + + if (run.name.contains('client') || run.name.contains('data')) { + run.property 'nativesDirectory', prj.extractNatives.output.get().asFile + run.args '--assetsDir', prj.downloadAssets.output + run.args '--assetIndex', "{asset_index}" + } + + if (run.name.contains('client')) { + run.property 'org.lwjgl.system.SharedLibraryExtractDirectory', 'lwjgl_dll' + run.args '--username', 'Dev' + run.args '--version', prj.name + run.args '--uuid', '0' + run.args '--accessToken', '0' + run.args '--userType', 'mojang' + run.args '--versionType', 'release' + } + + if (prj.name == 'forge') { + run.environment 'FORGE_SPEC', prj.SPEC_VERSION + } + } + + eclipse.project.resourceFilter { + appliesTo = 'FOLDERS' + type = 'EXCLUDE_ALL' + matcher { + id = 'org.eclipse.ui.ide.multiFilter' + arguments = '1.0-name-matches-false-false-run' + } + } + + def MODULE_PATH = Util.getArtifacts(prj, prj.configurations.moduleonly, false).values().collect{"libraries/${it.downloads.artifact.path}"} + def CLASS_PATH = Util.getArtifacts(prj, prj.configurations.installer, false).values().collect{"libraries/${it.downloads.artifact.path}"} + + [ + 'libraries/' + Util.getMavenPath(rootProject.tasks.findByPath(':fmlloader:jar')), + "libraries/net/minecraft/server/${MC_VERSION}-${MCP_VERSION}/server-${MC_VERSION}-${MCP_VERSION}-extra.jar" + ] + def tokens = [ + TASK: prj.name.equals('forge') ? 'forgeserver' : 'fmlserver', + MAVEN_PATH: prj.ext.MAVEN_PATH.toString(), + FORGE_VERSION: FORGE_VERSION, + MC_VERSION: MC_VERSION, + MCP_VERSION: MCP_VERSION, + FORGE_GROUP: prj.group, + IGNORE_LIST: Util.getArtifacts(prj, prj.configurations.moduleonly, false).values().collect{it.downloads.artifact.path.rsplit('/', 1)[1]}.join(','), + MODULES: 'ALL-MODULE-PATH' + ] + + prj.afterEvaluate { + prj.installerJar { + from(rootProject.file('server_files/')) { + exclude 'args.txt' + filter(ReplaceTokens, tokens: tokens) + into('data/') + //rename 'run.sh', "run_forge_${VERSION.replace('-', '_').sh" + //rename 'run.bat', "run_forge_${VERSION.replace('-', '_').bat" + } + + from(rootProject.file('server_files/args.txt')) { + filter(ReplaceTokens, tokens: tokens + [MODULE_PATH: MODULE_PATH.join(';'), CLASS_PATH: CLASS_PATH.join(';')]) + rename { 'data/win_args.txt' } + } + + from(rootProject.file('server_files/args.txt')) { + filter(ReplaceTokens, tokens: tokens + [MODULE_PATH: MODULE_PATH.join(':'), CLASS_PATH: CLASS_PATH.join(':')]) + rename { 'data/unix_args.txt' } + } + } + } +} + +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', ':javafmllanguage: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(':javafmllanguage') + 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'] + 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: ['-DlegacyClassPath=${classpath}', + "-DignoreList=${fmlonly_client.properties.ignoreList}", + "-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', + '--add-opens', 'java.base/java.util.jar=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) { + 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_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" + ] + ], [ + 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' + ] + ], [ + 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}' + ] + ], [ + jar: VIGNETTE, + classpath: getClasspath(project, libs, VIGNETTE), + args: [ + '--jar-in', '{MC_SLIM}', + '--jar-out', '{MC_SRG}', + '--mapping-format', 'tsrg2', + '--mappings', '{MERGED_MAPPINGS}', + // '--stable', + '--create-inits', '--fix-param-annotations', '--fernflower-meta' + ]/*, + 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(':fmlcore:jar', ':fmlloader:jar', ':javafmllanguage:jar', ':mclanguage:jar') } +} + +project(':forge') { evaluationDependsOn(':clean') apply plugin: 'java-library' - apply plugin: 'maven-publish' - apply plugin: 'eclipse' apply plugin: 'net.minecraftforge.gradle.patcher' apply plugin: 'org.cadixdev.licenser' - java.toolchain.languageVersion = JavaLanguageVersion.of(8) - group = 'net.minecraftforge' - sourceSets { - fmllauncher { - java { - srcDirs = ["$rootDir/src/fmllauncher/java"] - } - resources { - srcDirs = ["$rootDir/src/fmllauncher/resources"] - } - } main { - compileClasspath += sourceSets.fmllauncher.runtimeClasspath - runtimeClasspath += sourceSets.fmllauncher.runtimeClasspath java { - srcDirs = ["$rootDir/src/main/java"] + srcDirs = [ + "$rootDir/src/main/java", + "$rootDir/src/fmlcommon/java" + ] } resources { srcDirs = [ "$rootDir/src/main/resources", - "$rootDir/src/generated/resources" + "$rootDir/src/generated/resources", + "$rootDir/src/fmlcommon/resources" ] } } test { - compileClasspath += sourceSets.fmllauncher.runtimeClasspath - runtimeClasspath += sourceSets.fmllauncher.runtimeClasspath java { srcDirs = [ - "$rootDir/src/test/java", - "$rootDir/src/fmllaunchertest/java" + "$rootDir/src/test/java" ] } resources { @@ -157,47 +796,41 @@ project(':forge') { ] } } - userdev { - compileClasspath += sourceSets.main.runtimeClasspath - runtimeClasspath += sourceSets.main.runtimeClasspath - java { - srcDirs = ["$rootDir/src/userdev/java"] - } - resources { - srcDirs = ["$rootDir/src/userdev/resources"] - } - } - userdev_test { - compileClasspath += sourceSets.userdev.runtimeClasspath - runtimeClasspath += sourceSets.userdev.runtimeClasspath - compileClasspath += sourceSets.test.runtimeClasspath - runtimeClasspath += sourceSets.test.runtimeClasspath - } } //Eclipse adds the sourcesets twice, once where we tell it to, once in the projects folder. No idea why. So delete them eclipse.classpath.file.whenMerged { cls -> cls.entries.removeIf { e -> e instanceof SourceFolder && e.path.startsWith('src/') && !e.path.startsWith('src/main/') } } - repositories { - mavenLocal() - mavenCentral() - } - ext { - GIT_INFO = gradleutils.gitInfo - SPEC_VERSION = GIT_INFO.tag + SPEC_VERSION = gradleutils.gitInfo.tag // The new versioning sceme is -.. // ForgeMC is a unique identifier for every MC version we have supported. // Essentially, the same as the old, except dropping the first number, and the builds are no longer unique. MCP_ARTIFACT = project(':mcp').mcp.config.get() - SPECIAL_SOURCE = 'net.md-5:SpecialSource:1.10.0' - SPECIAL_SOURCE_MCP = 'net.md-5:SpecialSource:1.8.5' VERSION_JSON = project(':mcp').file('build/mcp/downloadJson/version.json') - BINPATCH_TOOL = 'net.minecraftforge:binarypatcher:1.0.12:fatjar' - INSTALLER_TOOLS = 'net.minecraftforge:installertools:1.2.6' + PACKED_DEPS = [':fmlcore:jar', ':fmlloader:jar', ':javafmllanguage:jar', ':mclanguage:jar'] + MAVEN_PATH = "${group.replace('.', '/')}/${project.name}/${VERSION}" } - version = gradleutils.getMCTagOffsetBranchVersion(MC_VERSION) - println('Forge Version: ' + version) + configurations { + installer { + // Don't pull all libraries, if we're missing something, add it to the installer list so the installer knows to download it. + transitive = false + } + moduleonly + api.extendsFrom(installer) + } + + dependencies { + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0' + testImplementation 'org.junit.vintage:junit-vintage-engine:5.+' + testImplementation 'org.opentest4j:opentest4j:1.2.0' // needed for junit 5 + testImplementation 'org.hamcrest:hamcrest-all:1.3' // needs advanced matching for list order + implementation project(':fmlcore') + implementation project(':fmlloader') + implementation project(':javafmllanguage') + implementation project(':mclanguage') + } + dependencies sharedDeps patcher { excs.from file("$rootDir/src/main/resources/forge.exc") @@ -210,32 +843,11 @@ project(':forge') { runs { forge_client { - taskName 'forge_client' - - main 'net.minecraftforge.userdev.LaunchTesting' - workingDirectory project.file('run') - - environment 'target', 'fmldevclient' - environment 'assetIndex', '{asset_index}' - environment 'assetDirectory', downloadAssets.output - environment 'nativesDirectory', extractNatives.output.get().asFile - - environment 'MC_VERSION', MC_VERSION - environment 'MCP_VERSION', MCP_VERSION - environment 'FORGE_GROUP', project.group - environment 'FORGE_SPEC', SPEC_VERSION - environment 'FORGE_VERSION', project.version.substring(MC_VERSION.length() + 1) - environment 'LAUNCHER_VERSION', SPEC_VERSION - property 'org.lwjgl.system.SharedLibraryExtractDirectory', 'lwjgl_dll' property 'eventbus.checkTypesOnDispatch', 'true' - - ideaModule "${rootProject.name}.${project.name}.userdev" - + args '--launchTarget', 'forgeclientdev' + ideaModule "${rootProject.name}.${project.name}.main" mods { - forge { - source sourceSets.main - source sourceSets.userdev - } + minecraft { source sourceSets.main } } } @@ -245,34 +857,19 @@ project(':forge') { environment 'MOD_CLASSES', 'dummy' // Needed to work around FG limitation, FG will replace this! - ideaModule "${rootProject.name}.${project.name}.userdev_test" + ideaModule "${rootProject.name}.${project.name}.test" mods { - forge { source sourceSets.main } tests { sources sourceSets.test } } } forge_server { - taskName 'forge_server' - - main 'net.minecraftforge.userdev.LaunchTesting' - workingDirectory project.file('run') - - environment 'target', 'fmldevserver' - - environment 'MC_VERSION', MC_VERSION - environment 'MCP_VERSION', MCP_VERSION - environment 'FORGE_GROUP', project.group - environment 'FORGE_SPEC', SPEC_VERSION - environment 'FORGE_VERSION', project.version.substring(MC_VERSION.length() + 1) - environment 'LAUNCHER_VERSION', SPEC_VERSION - property 'eventbus.checkTypesOnDispatch', 'true' - - ideaModule "${rootProject.name}.${project.name}.userdev" + args '--launchTarget', 'forgeserverdev' + ideaModule "${rootProject.name}.${project.name}.main" mods { - forge { source sourceSets.main } + minecraft { source sourceSets.main } } } @@ -282,39 +879,30 @@ project(':forge') { environment 'MOD_CLASSES', 'dummy' // Needed to work around FG limitation, FG will replace this! - ideaModule "${rootProject.name}.${project.name}.userdev_test" + ideaModule "${rootProject.name}.${project.name}.test" mods { - forge { source sourceSets.main } tests { sources sourceSets.test } } } + def forgeDataArgs = [ + '--mod', 'forge', + '--all', + '--output', rootProject.file('src/generated/resources/'), + '--validate', + '--existing', sourceSets.main.resources.srcDirs[0] + ] forge_data { taskName 'forge_data' - - main 'net.minecraftforge.userdev.LaunchTesting' - workingDirectory project.file('run') - - environment 'target', 'fmldevdata' - environment 'assetIndex', '{asset_index}' - environment 'assetDirectory', downloadAssets.output - - environment 'MC_VERSION', MC_VERSION - environment 'MCP_VERSION', MCP_VERSION - environment 'FORGE_GROUP', project.group - environment 'FORGE_SPEC', SPEC_VERSION - environment 'FORGE_VERSION', project.version.substring(MC_VERSION.length() + 1) - environment 'LAUNCHER_VERSION', SPEC_VERSION - - ideaModule "${rootProject.name}.${project.name}.userdev" + args '--launchTarget', 'forgedatadev' + ideaModule "${rootProject.name}.${project.name}.main" mods { - forge { source sourceSets.main } + minecraft { source sourceSets.main } } - - args '--mod', 'forge', '--all', '--output', rootProject.file('src/generated/resources/'), '--validate', - '--existing', sourceSets.main.resources.srcDirs[0] + + args forgeDataArgs } forge_test_data { @@ -323,32 +911,39 @@ project(':forge') { environment 'MOD_CLASSES', 'dummy' // Needed to work around FG limitation, FG will replace this! - ideaModule "${rootProject.name}.${project.name}.userdev_test" + ideaModule "${rootProject.name}.${project.name}.test" mods { - tests { sources sourceSets.test } + tests { sources sourceSets.test } + } + + afterEvaluate { + // Clear forge's main datagen args + args.removeAll { + forgeDataArgs.contains(it instanceof File ? (it as File).absolutePath : it.toString()) + } + + args '--flat', '--all', '--validate', + '--mod', 'data_gen_test', + '--mod', 'piston_event_test', + '--mod', 'global_loot_test', + '--mod', 'scaffolding_test', + '--mod', 'custom_tag_types_test', + '--mod', 'new_model_loader_test', + '--output', rootProject.file('src/generated_test/resources/'), + '--existing', sourceSets.main.resources.srcDirs[0], + '--existing', sourceSets.test.resources.srcDirs[0] } - - args '--flat', '--all', '--validate', - '--mod', 'data_gen_test', - '--mod', 'piston_event_test', - '--mod', 'global_loot_test', - '--mod', 'scaffolding_test', - '--mod', 'custom_tag_types_test', - '--mod', 'new_model_loader_test', - '--output', rootProject.file('src/generated_test/resources/'), - '--existing', sourceSets.main.resources.srcDirs[0], - '--existing', sourceSets.test.resources.srcDirs[0] } } } - + ext { MANIFESTS = [ '/': [ 'Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), - 'GitCommit': GIT_INFO.abbreviatedId, - 'Git-Branch': GIT_INFO.branch + 'GitCommit': gradleutils.gitInfo.abbreviatedId, + 'Git-Branch': gradleutils.gitInfo.branch ] as LinkedHashMap, 'net/minecraftforge/versions/forge/': [ 'Specification-Title': 'Forge', @@ -389,104 +984,22 @@ project(':forge') { 'Implementation-Title': 'FML Launcher', 'Implementation-Version': SPEC_VERSION, 'Implementation-Vendor': 'Forge' - ] as LinkedHashMap, - 'net/minecraftforge/fml/userdev/': [ - 'Specification-Title': 'Forge User Development', - 'Specification-Vendor': 'Forge Development LLC', - 'Specification-Version': SPEC_VERSION, - 'Implementation-Title': project.group, - 'Implementation-Version': project.version.substring(MC_VERSION.length() + 1), - 'Implementation-Vendor': 'Forge Development LLC' ] as LinkedHashMap ] } - - configurations { - installer { - transitive = false //Don't pull all libraries, if we're missing something, add it to the installer list so the installer knows to download it. - } - api.extendsFrom(installer) - fmllauncherImplementation.extendsFrom(installer, implementation) - } - dependencies { - installer 'org.ow2.asm:asm:9.1' - installer 'org.ow2.asm:asm-commons:9.1' - installer 'org.ow2.asm:asm-tree:9.1' - installer 'org.ow2.asm:asm-util:9.1' - installer 'org.ow2.asm:asm-analysis:9.1' - installer 'cpw.mods:modlauncher:8.0.9' - installer 'cpw.mods:grossjava9hacks:1.3.3' - installer 'net.minecraftforge:accesstransformers:3.0.1' - installer 'org.antlr:antlr4-runtime:4.9.1' //Dep of AccessTransformer - installer 'net.minecraftforge:eventbus:4.0.+' - installer 'net.minecraftforge:forgespi:' + SPI_VERSION - installer 'net.minecraftforge:coremods:4.0.+' - installer 'net.minecraftforge:unsafe:0.2.+' - installer 'com.electronwill.night-config:core:3.6.3' - installer 'com.electronwill.night-config:toml:3.6.3' - installer 'org.jline:jline:3.12.+' - installer 'org.apache.maven:maven-artifact:3.6.3' - installer 'net.jodah:typetools:0.8.3' - installer 'org.apache.logging.log4j:log4j-api:2.11.2' - installer 'org.apache.logging.log4j:log4j-core:2.11.2' - installer 'net.minecrell:terminalconsoleappender:1.2.0' - installer 'net.sf.jopt-simple:jopt-simple:5.0.4' - installer 'org.spongepowered:mixin:0.8.2' - // This is org.openjdk.nashorn:nashorn-core:15.1.1 repackaged so it doesn't crash on JREs < 15. - // See: https://github.com/LexManos/NashornLegacyPackager - installer 'net.minecraftforge:nashorn-core-compat:15.1.1.1' - fmllauncherImplementation 'com.google.guava:guava:21.0' - fmllauncherImplementation 'com.google.code.gson:gson:2.8.0' - fmllauncherImplementation 'org.lwjgl:lwjgl:3.2.2' - fmllauncherImplementation 'org.lwjgl:lwjgl-glfw:3.2.2' - fmllauncherImplementation 'org.lwjgl:lwjgl-opengl:3.2.2' - fmllauncherImplementation 'org.lwjgl:lwjgl-stb:3.2.2' - testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0' - testImplementation 'org.junit.vintage:junit-vintage-engine:5.+' - testImplementation 'org.opentest4j:opentest4j:1.2.0' // needed for junit 5 - testImplementation 'org.hamcrest:hamcrest-all:1.3' // needs advanced matching for list order - } - - def extraTxts = [ - rootProject.file('CREDITS.txt'), - rootProject.file('LICENSE.txt') - ] - - def changelog = rootProject.file('build/changelog.txt') - if (changelog.exists()) - extraTxts += changelog - + task crowdin(type: Crowdin) { key = project.hasProperty('crowdinKey') ? project.crowdinKey : null //TODO: Merge our english.json? } - - // We apply the bin patches we just created to make a jar that is JUST our changes - ['Client', 'Server', 'Joined'].each { side -> - def gen = tasks.getByName("gen${side}BinPatches") - gen.tool = BINPATCH_TOOL - task "apply${side}BinPatches"(type: net.minecraftforge.gradle.common.tasks.ApplyBinPatches, dependsOn: gen) { - clean = gen.cleanJar - patch = gen.output - tool = BINPATCH_TOOL - } - def srgTask = tasks.getByName(patcher.notchObf ? 'createMcp2Obf' : 'createMcp2Srg') - // Create SRG named Vanilla jars, using the SpecialSource we have in the installer - task "create${side}SRG"(type: net.minecraftforge.gradle.userdev.tasks.RenameJar, dependsOn: srgTask) { - tool = SPECIAL_SOURCE_MCP + ':shaded' - args = ['--stable', '--in-jar', '{input}', '--out-jar', '{output}', '--srg-in', '{mappings}'] - mappings = srgTask.output - input = gen.cleanJar - output = file("build/create${name}SRG/output.jar") - } - } - + sharedFmlonlyForge.call(project) + task downloadLibraries(type: DownloadLibraries, dependsOn: ':mcp:setupMCP') { input = VERSION_JSON output = rootProject.file('build/libraries/') } - + task extractInheritance(type: ExtractInheritance, dependsOn: [genJoinedBinPatches, downloadLibraries]) { tool = INSTALLER_TOOLS + ':fatjar' input = genJoinedBinPatches.cleanJar @@ -494,38 +1007,21 @@ project(':forge') { } task findFieldInstanceChecks(type: FieldCompareFinder, dependsOn: ['createJoinedSRG']) { - jar = tasks.getByName('createJoinedSRG').output + jar = createJoinedSRG.output output = rootProject.file('src/main/resources/coremods/field_to_instanceof.json') fields { + /* 1.17 changed most things to use Tags. So this isn't nessasary anymore so just make an empty list bows { - cls = 'net/minecraft/item/Items' - name = 'field_151031_f' - replacement = 'net/minecraft/item/BowItem' + cls = 'net/minecraft/world/item/Items' + name = 'f_42411_' + replacement = 'net/minecraft/world/item/BowItem' } crossbows { - cls = 'net/minecraft/item/Items' - name = 'field_222114_py' - replacement = 'net/minecraft/item/CrossbowItem' - } - filled_map { - cls = 'net/minecraft/item/Items' - name = 'field_151098_aY' - replacement = 'net/minecraft/item/FilledMapItem' - blacklist 'net/minecraft/client/gui/screen/inventory/CartographyTableScreen', 'func_230450_a_', '(Lcom/mojang/blaze3d/matrix/MatrixStack;FII)V' - blacklist 'net/minecraft/client/renderer/entity/ItemFrameRenderer', 'func_225623_a_', '(Lnet/minecraft/entity/item/ItemFrameEntity;FFLcom/mojang/blaze3d/matrix/MatrixStack;Lnet/minecraft/client/renderer/IRenderTypeBuffer;I)V' - blacklist 'net/minecraft/item/crafting/MapCloningRecipe' - blacklist 'net/minecraft/item/crafting/MapExtendingRecipe' - } - fishing_rod { - cls = 'net/minecraft/item/Items' - name = 'field_151112_aM' - replacement = 'net/minecraft/item/FishingRodItem' - } - shears { - cls = 'net/minecraft/item/Items' - name = 'field_151097_aZ' - replacement = 'net/minecraft/item/ShearsItem' + cls = 'net/minecraft/world/item/Items' + name = 'f_42717_' + replacement = 'net/minecraft/world/item/CrossbowItem' } + */ } } @@ -541,7 +1037,7 @@ project(':forge') { } task checkExcs(type: CheckExcs, dependsOn: jar) { - binary = jar.archiveFile + binary = jar.archiveFile.get().asFile excs.from patcher.excs } @@ -556,127 +1052,80 @@ project(':forge') { patchDir = file("$rootDir/patches") autoFix = false } + genPatches { finalizedBy checkPatches autoHeader true lineEnding = '\n' } - task launcherJson(dependsOn: ['signUniversalJar', 'signLauncherJar']) { - inputs.file universalJar.archiveFile - inputs.file { launcherJar.archiveFile } - ext { - output = file('build/version.json') - vanilla = project(':mcp').file('build/mcp/downloadJson/version.json') - timestamp = iso8601Now() - comment = [ - "Please do not automate the download and installation of Forge.", - "Our efforts are supported by ads from the download page.", - "If you MUST automate this, please consider supporting the project through https://www.patreon.com/LexManos/" - ] - def idx = project.version.indexOf('-') - id = project.version.substring(0, idx) + "-${project.name}" + project.version.substring(idx) - } - inputs.file vanilla - outputs.file output - doLast { - def json_vanilla = vanilla.json() - def json = [ + task launcherJson(type: LauncherJson) { + packedDependencies = [':fmlloader:jar'] + doFirst { + def forge_client = project(':forge').patcher.runs.forge_client + json = [ _comment_: comment, id: id, time: timestamp, releaseTime: timestamp, type: 'release', - mainClass: 'cpw.mods.modlauncher.Launcher', + mainClass: 'cpw.mods.bootstraplauncher.BootstrapLauncher', inheritsFrom: MC_VERSION, logging: {}, arguments: [ - game: ['--launchTarget', 'fmlclient', '--fml.forgeVersion', "${project.version.substring(MC_VERSION.length() + 1)}", '--fml.mcVersion', "${MC_VERSION}", '--fml.forgeGroup', "${project.group}", '--fml.mcpVersion', "${MCP_VERSION}"], - // Support running with Java 8 and up, including 16 - jvm: [ - // Allow these JVM args to not crash Java 8 - '-XX:+IgnoreUnrecognizedVMOptions', - // ModLauncher uses sun.security.util.ManifestEntryVerifier and needs access to it - '--add-exports=java.base/sun.security.util=ALL-UNNAMED', - // JDK bug, not fixed properly - https://bugs.openjdk.java.net/browse/JDK-8186019 - '--add-exports=jdk.naming.dns/com.sun.jndi.dns=java.naming', - // ModLauncher reflects field 'jv' in java.util.jar.JarVerifier - '--add-opens=java.base/java.util.jar=ALL-UNNAMED' + game: ['--launchTarget', 'forgeclient', + '--fml.forgeVersion', FORGE_VERSION, + '--fml.mcVersion', MC_VERSION, + '--fml.forgeGroup', project.group, + '--fml.mcpVersion', MCP_VERSION], + jvm: ['-DlegacyClassPath=${classpath}', + "-DignoreList=${forge_client.properties.ignoreList}", + "-DmergeModules=${forge_client.properties.mergeModules}", + '-DlibraryDirectory=${library_directory}', + '-p', Util.getArtifacts(project, configurations.moduleonly, false).values().collect{'${library_directory}/' + it.downloads.artifact.path}.join('${classpath_separator}'), + '--add-modules', 'ALL-MODULE-PATH', + '--add-opens', 'java.base/java.util.jar=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: [ - [ - //Package our launcher jar as the 'main' jar Mojang's launcher loads. It will in turn load Forge's regular jars itself. - name: "${project.group}:${project.name}:${project.version}", - downloads: [ - artifact: [ - path: "${project.group.replace('.', '/')}/${project.name}/${project.version}/${project.name}-${project.version}.jar", - url: "", //Do not include the URL so that the installer/launcher won't grab it. This is also why we don't have the universal classifier - sha1: launcherJar.archiveFile.get().asFile.sha1(), - size: launcherJar.archiveFile.get().asFile.length() - ] - ] - ] - ] + libraries: [] ] - - def artifacts = getArtifacts(project, project.configurations.installer, false) - artifacts.each { key, lib -> - json.libraries.add(lib) - } - - output.text = new JsonBuilder(json).toPrettyString() } } - task installerJson(dependsOn: [launcherJson, genClientBinPatches, applyClientBinPatches, applyServerBinPatches/*, createClientSRG, createServerSRG*/]) { + task installerJson(type: InstallerJson, dependsOn: [launcherJson, genClientBinPatches, applyClientBinPatches, applyServerBinPatches]) { ext { - output = file('build/install_profile.json') - JAR_SPLITTER = 'net.minecraftforge:jarsplitter:1.1.4' + // remove :fatjar + BIN_PATCHER = BINPATCH_TOOL.substring(0, BINPATCH_TOOL.length() - 1 - BINPATCH_TOOL.split(':')[3].length()) } + input.from applyClientBinPatches.output, applyServerBinPatches.output, genClientBinPatches.toolJar, launcherJson.output + icon = rootProject.file('icon.ico') + packedDependencies = PACKED_DEPS + doFirst { - ext.BIN_PATCHER = BINPATCH_TOOL.substring(0, BINPATCH_TOOL.length() - 1 - BINPATCH_TOOL.split(':')[3].length()) - } - inputs.file applyClientBinPatches.output - inputs.file applyServerBinPatches.output - inputs.file genClientBinPatches.toolJar - inputs.file launcherJson.output - /* - inputs.file createClientSRG.output - inputs.file createServerSRG.output - */ - outputs.file output - doLast { - def libs = [ - "${project.group}:${project.name}:${project.version}:universal": [ - name: "${project.group}:${project.name}:${project.version}:universal", - downloads: [ - artifact: [ - path: "${project.group.replace('.', '/')}/${project.name}/${project.version}/${project.name}-${project.version}-universal.jar", - url: "", //Do not include the URL so that the installer/launcher won't grab it. This is also why we don't have the universal classifier - sha1: universalJar.archiveFile.get().asFile.sha1(), - size: universalJar.archiveFile.get().asFile.length() - ] - ] - ] - ] - def json = [ + def libs = libraries + json = [ _comment_: launcherJson.comment, - spec: 0, + spec: 1, profile: project.name, version: launcherJson.id, - icon: "data:image/png;base64," + new String(Base64.getEncoder().encode(Files.readAllBytes(rootProject.file("icon.ico").toPath()))), - json: '/version.json', - path: "${project.group}:${project.name}:${project.version}", - logo: '/big_logo.png', + path: null, minecraft: MC_VERSION, - welcome: "Welcome to the simple ${project.name.capitalize()} installer.", - mirrorList: "https://files.minecraftforge.net/mirrors-2.0.json", + serverJarPath: '{LIBRARY_DIR}/net/minecraft/server/{MINECRAFT_VERSION}/server-{MINECRAFT_VERSION}.jar', 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]" + ], BINPATCH: [ client: '/data/client.lzma', server: '/data/server.lzma' @@ -686,16 +1135,16 @@ project(':forge') { server: "[net.minecraft:server:${MC_VERSION}-${MCP_VERSION}:slim]" ], MC_SLIM_SHA: [ - client: "'${tasks.getByName('downloadClientSlim').output.get().asFile.sha1()}'", - server: "'${tasks.getByName('downloadServerSlim').output.get().asFile.sha1()}'" + 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: "'${tasks.getByName('downloadClientExtra').output.get().asFile.sha1()}'", - server: "'${tasks.getByName('downloadServerExtra').output.get().asFile.sha1()}'" + client: "'${downloadClientExtra.output.get().asFile.sha1()}'", + server: "'${downloadServerExtra.output.get().asFile.sha1()}'" ], MC_SRG: [ client: "[net.minecraft:client:${MC_VERSION}-${MCP_VERSION}:srg]", @@ -720,6 +1169,36 @@ project(':forge') { ], 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_forge_${VERSION.replace('-', '_').sh", + //'--to', '{ROOT}/run_forge_${VERSION.replace('-', '_').sh', + //'--exec', '{ROOT}/run_forge_${VERSION.replace('-', '_').sh', + + '--from', 'data/run.bat', + '--to', '{ROOT}/run.bat', + //'--from', 'data/run_forge_${VERSION.replace('-', '_').bat', + //'--to', '{ROOT}/run_forge_${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" + ] + ], [ jar: INSTALLER_TOOLS, classpath: getClasspath(project, libs, INSTALLER_TOOLS), args: [ @@ -728,6 +1207,25 @@ project(':forge') { '--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' + ] ], [ jar: JAR_SPLITTER, classpath: getClasspath(project, libs, JAR_SPLITTER), @@ -735,20 +1233,22 @@ project(':forge') { '--input', '{MINECRAFT_JAR}', '--slim', '{MC_SLIM}', '--extra', '{MC_EXTRA}', - '--srg', '{MAPPINGS}' + '--srg', '{MERGED_MAPPINGS}' ], outputs: [ '{MC_SLIM}': '{MC_SLIM_SHA}', '{MC_EXTRA}': '{MC_EXTRA_SHA}' ] ], [ - jar: SPECIAL_SOURCE_MCP, - classpath: getClasspath(project, libs, SPECIAL_SOURCE_MCP), + jar: VIGNETTE, + classpath: getClasspath(project, libs, VIGNETTE), args: [ - //'--stable', Java 9 Is borked, https://bugs.openjdk.java.net/browse/JDK-8184940 TODO: find a fix. - '--in-jar', '{MC_SLIM}', - '--out-jar', '{MC_SRG}', - '--srg-in', '{MAPPINGS}' + '--jar-in', '{MC_SLIM}', + '--jar-out', '{MC_SRG}', + '--mapping-format', 'tsrg2', + '--mappings', '{MERGED_MAPPINGS}', + // '--stable', + '--create-inits', '--fix-param-annotations', '--fernflower-meta' ]/*, outputs: [ '{MC_SRG}': '{MC_SRG_SHA}' @@ -761,34 +1261,21 @@ project(':forge') { '--clean', '{MC_SRG}', '--output', '{PATCHED}', '--apply', '{BINPATCH}' - ], + ]/*, Because Vignette is unstable, it screws with the entry order of the binpatched jar, so we can't use the hash right now + // Re-enable this when https://github.com/CadixDev/Vignette/issues/1 is solved outputs: [ '{PATCHED}': '{PATCHED_SHA}' - ] + ]*/ ] ] ] getClasspath(project, libs, MCP_ARTIFACT.descriptor) //Tell it to download mcp_config - json.libraries = libs.values().sort{a,b -> a.name.compareTo(b.name)} - - output.text = new JsonBuilder(json).toPrettyString() } } - - ['client', 'server'].each { side -> - ['slim', 'extra'].each { type -> - def name = "download${side.capitalize()}${type.capitalize()}" - task "${name}"(type: DownloadMavenArtifact) { - artifact = "net.minecraft:${side}:${MC_VERSION}-${MCP_VERSION}:${type}" - } - installerJson.dependsOn(name) - installerJson.inputs.file(tasks.getByName(name).output) - } - } - + universalJar { from extraTxts - + // add crowdin locales from { crowdin.output.present && crowdin.output.get().asFile.exists() ? zipTree(crowdin.output) : null} dependsOn crowdin @@ -804,94 +1291,21 @@ project(':forge') { } } } - - task launcherJar(type: Jar) { - classifier 'launcher' - from sourceSets.fmllauncher.output - doFirst { - def classpath = new StringBuilder() - def artifacts = getArtifacts(project, project.configurations.installer, false) - artifacts.each { key, lib -> - classpath += "libraries/${lib.downloads.artifact.path} " - } - classpath += "libraries/net/minecraft/server/${MC_VERSION}-${MCP_VERSION}/server-${MC_VERSION}-${MCP_VERSION}-extra.jar" - - MANIFESTS.each{ pkg, values -> - if (pkg == '/') { - manifest.attributes(values += [ - 'Main-Class': 'net.minecraftforge.server.ServerMain', - 'Class-Path': classpath.toString(), - 'ServerLaunchArgs': [ - '--gameDir', '.', - '--launchTarget', 'fmlserver', - '--fml.forgeVersion', "${project.version.substring(MC_VERSION.length() + 1)}".toString(), - '--fml.mcpVersion', MCP_VERSION, - '--fml.mcVersion', MC_VERSION, - '--fml.forgeGroup', project.group - ].join(' ') - ]) - } else { - manifest.attributes(values, pkg) - } - } - } - } - - task downloadInstaller(type: DownloadMavenArtifact) { - artifact = 'net.minecraftforge:installer:2.1.+:shrunk' - changing = true - } - - task installerJar(type: Zip, dependsOn: [downloadInstaller, installerJson, launcherJson, genClientBinPatches, genServerBinPatches, 'signUniversalJar', 'signLauncherJar']) { - archiveClassifier = 'installer' - archiveExtension = 'jar' //Needs to be Zip task to not override Manifest, so set extension - destinationDirectory = file('build/libs') + + task installerJar(type: InstallerJar, dependsOn: [genClientBinPatches, genServerBinPatches, 'signUniversalJar', launcherJson]) { + packedDependencies = PACKED_DEPS from(extraTxts) - from(rootProject.file('/installer_logo.png')) { - rename{'big_logo.png'} + from(rootProject.file('/forge_installer_logo.png')) { + rename { 'big_logo.png' } } - from(rootProject.file('/src/main/resources/url.png')) from(genClientBinPatches.output) { - rename{'data/client.lzma'} + rename { 'data/client.lzma' } } from(genServerBinPatches.output) { - rename{'data/server.lzma'} - } - from(universalJar) { - into "/maven/${project.group.replace('.', '/')}/${project.name}/${project.version}/" - } - from(launcherJar) { - into "/maven/${project.group.replace('.', '/')}/${project.name}/${project.version}/" - rename { "${project.name}-${project.version}.jar" } - } - from(installerJson.output) - from(launcherJson.output) - if (downloadInstaller.output.present) { - from(zipTree(downloadInstaller.output)) { - duplicatesStrategy = 'exclude' - } + rename { 'data/server.lzma' } } } - - [universalJar, launcherJar, installerJar].each { t -> - task "sign${t.name.capitalize()}"(type: SignJar, dependsOn: t) { - onlyIf { - JAR_SIGNER != null && t.state.failure == null - } - def jarsigner = JAR_SIGNER == null ? [:] : JAR_SIGNER - alias = 'forge' - storePass = jarsigner.storepass - keyPass = jarsigner.keypass - keyStore = jarsigner.keystore - inputFile = t.archiveFile - outputFile = t.archiveFile - doFirst { - project.logger.lifecycle('Signing: ' + inputFile) - } - } - t.finalizedBy(tasks.getByName("sign${t.name.capitalize()}")) - } - + task makeMdk(type: Zip) { archiveBaseName = project.name archiveClassifier = 'mdk' @@ -923,78 +1337,7 @@ project(':forge') { rename 'gitattributes\\.txt', '.gitattributes' } } - - userdevConfig { - def artifacts = getArtifacts(project, project.configurations.installer, true) - artifacts.each { key, lib -> - libraries.add(lib.name) - } - libraries.add("${project.group}:${project.name}:${project.version}:launcher") - runs { - client { - main 'net.minecraftforge.userdev.LaunchTesting' - // Support mod devs running on Java 8 and up, including 16 - jvmArgs '-XX:+IgnoreUnrecognizedVMOptions' - jvmArgs '--add-exports=java.base/sun.security.util=ALL-UNNAMED' - jvmArgs '--add-exports=jdk.naming.dns/com.sun.jndi.dns=java.naming' - jvmArgs '--add-opens=java.base/java.util.jar=ALL-UNNAMED' - - environment 'target', 'fmluserdevclient' - environment 'assetIndex', '{asset_index}' - environment 'assetDirectory', '{assets_root}' - environment 'nativesDirectory', '{natives}' - - environment 'MC_VERSION', "${MC_VERSION}" - environment 'FORGE_GROUP', "${project.group}" - environment 'MCP_VERSION', "${MCP_VERSION}" - environment 'MOD_CLASSES', '{source_roots}' - environment 'MCP_MAPPINGS', '{mcp_mappings}' - environment 'FORGE_VERSION', "${project.version.substring(MC_VERSION.length() + 1)}" - } - - server { - main 'net.minecraftforge.userdev.LaunchTesting' - - // Support mod devs running on Java 8 and up, including 16 - jvmArgs '-XX:+IgnoreUnrecognizedVMOptions' - jvmArgs '--add-exports=java.base/sun.security.util=ALL-UNNAMED' - jvmArgs '--add-exports=jdk.naming.dns/com.sun.jndi.dns=java.naming' - jvmArgs '--add-opens=java.base/java.util.jar=ALL-UNNAMED' - - environment 'target', 'fmluserdevserver' - - environment 'MC_VERSION', "${MC_VERSION}" - environment 'FORGE_GROUP', "${project.group}" - environment 'MCP_VERSION', "${MCP_VERSION}" - environment 'MOD_CLASSES', '{source_roots}' - environment 'MCP_MAPPINGS', '{mcp_mappings}' - environment 'FORGE_VERSION', "${project.version.substring(MC_VERSION.length() + 1)}" - } - - data { - main 'net.minecraftforge.userdev.LaunchTesting' - - // Support mod devs running on Java 8 and up, including 16 - jvmArgs '-XX:+IgnoreUnrecognizedVMOptions' - jvmArgs '--add-exports=java.base/sun.security.util=ALL-UNNAMED' - jvmArgs '--add-exports=jdk.naming.dns/com.sun.jndi.dns=java.naming' - jvmArgs '--add-opens=java.base/java.util.jar=ALL-UNNAMED' - - environment 'target', 'fmluserdevdata' - environment 'assetIndex', '{asset_index}' - environment 'assetDirectory', '{assets_root}' - - environment 'MC_VERSION', "${MC_VERSION}" - environment 'FORGE_GROUP', "${project.group}" - environment 'MCP_VERSION', "${MCP_VERSION}" - environment 'MOD_CLASSES', '{source_roots}' - environment 'MCP_MAPPINGS', '{mcp_mappings}' - environment 'FORGE_VERSION', "${project.version.substring(MC_VERSION.length() + 1)}" - } - } - } - license { header = file("$rootDir/LICENSE-header.txt") @@ -1021,44 +1364,12 @@ project(':forge') { } } - task userdevExtras(type:Jar) { - dependsOn classes - from sourceSets.userdev.output - classifier 'userdev-temp' - } - reobfJar { tool = SPECIAL_SOURCE + ':shaded' } - task userdevExtrasReobf(type: ReobfuscateJar) { - dependsOn userdevExtras, createMcp2Srg - input = tasks.userdevExtras.archiveFile - classpath.from project.configurations.userdevCompileClasspath - srg = tasks.createMcp2Srg.output - tool = SPECIAL_SOURCE + ':shaded' - } - - userdevJar { - dependsOn tasks.userdevExtrasReobf - from (zipTree(tasks.userdevExtrasReobf.output)) { - into '/inject/' - } - from (sourceSets.userdev.output.resourcesDir) { - into '/inject/' - } - } - - extractRangeMap { - dependencies.from jar.archiveFile - sources.from sourceSets.userdev.java.srcDirs - } - applyRangeMap { - sources.from sourceSets.userdev.java.srcDirs - } - tasks.eclipse.dependsOn('genEclipseRuns') - + if (project.hasProperty('UPDATE_MAPPINGS')) { extractRangeMap { sources.from sourceSets.test.java.srcDirs @@ -1069,7 +1380,7 @@ project(':forge') { } sourceSets.test.java.srcDirs.each { extractMappedNew.addTarget it } } - + publishing { publications { mavenJava(MavenPublication) { @@ -1084,55 +1395,17 @@ project(':forge') { artifact makeMdk artifact userdevJar artifact sourcesJar - artifact launcherJar - - pom { - name = 'forge' - description = 'Modifactions to Minecraft to enable mod developers.' - url = 'https://github.com/MinecraftForge/MinecraftForge' - - scm { - url = 'https://github.com/MinecraftForge/MinecraftForge' - connection = 'scm:git:git://github.com/MinecraftForge/MinecraftForge.git' - developerConnection = 'scm:git:git@github.com:MinecraftForge/MinecraftForge.git' - } - - issueManagement { - system = 'github' - url = 'https://github.com/MinecraftForge/MinecraftForge/issues' - } - - licenses { - license { - name = 'LGPL 2.1' - url = 'https://github.com/MinecraftForge/MinecraftForge/blob/1.13-pre/LICENSE.txt' - distribution = 'repo' - } - } - } - } - } - repositories { - maven { - if (System.env.MAVEN_USER) { - url "https://maven.minecraftforge.net/releases/" - authentication { - basic(BasicAuthentication) - } - credentials { - username = System.env.MAVEN_USER ?: 'not' - password = System.env.MAVEN_PASSWORD ?: 'set' - } - } else { - url 'file://' + rootProject.file('repo').getAbsolutePath() - } } } } + // Since we need the modules in the bootstrap, we need to make sure they are compiled before we do each run + afterEvaluate { prepareRuns.dependsOn(':fmlcore:jar', ':fmlloader:jar', ':javafmllanguage:jar', ':mclanguage:jar') } } //evaluationDependsOnChildren() -task setup() { +task setup() { //These must be strings so that we can do lazy resolution. Else we need evaluationDependsOnChildren above dependsOn ':clean:extractMapped' - dependsOn ':forge:extractMapped' //These must be strings so that we can do lazy resolution. Else we need evaluationDependsOnChildren above + if (symlinkValid) + dependsOn ':fmlonly:extractMapped' + dependsOn ':forge:extractMapped' } diff --git a/buildSrc/.gitignore b/buildSrc/.gitignore index abc78ba75a..2979d33310 100644 --- a/buildSrc/.gitignore +++ b/buildSrc/.gitignore @@ -1,2 +1,3 @@ /.gradle/ /build/ +/out/ diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index b644cd621b..f2d3e1fe1a 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -1,9 +1,9 @@ repositories { - maven { url = 'https://maven.minecraftforge.net/' } + maven { url = 'https://maven.minecraftforge.net/' } mavenCentral() } dependencies { implementation 'org.ow2.asm:asm:9.1' implementation 'org.ow2.asm:asm-tree:9.1' - implementation 'net.minecraftforge:srgutils:0.4.+' + implementation 'net.minecraftforge:srgutils:0.4.+' } \ No newline at end of file diff --git a/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/CheckATs.groovy b/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/CheckATs.groovy index 74f5fc8d35..85a7ab610a 100644 --- a/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/CheckATs.groovy +++ b/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/CheckATs.groovy @@ -1,9 +1,10 @@ package net.minecraftforge.forge.tasks import net.minecraftforge.srgutils.IMappingFile -import org.gradle.api.DefaultTask import org.gradle.api.file.ConfigurableFileCollection import org.gradle.api.file.RegularFileProperty + +import org.gradle.api.DefaultTask import org.gradle.api.tasks.InputFile import org.gradle.api.tasks.InputFiles import org.gradle.api.tasks.Optional diff --git a/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/CheckExcs.groovy b/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/CheckExcs.groovy index c9b7fd4bbc..cdc65a5859 100644 --- a/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/CheckExcs.groovy +++ b/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/CheckExcs.groovy @@ -1,12 +1,18 @@ package net.minecraftforge.forge.tasks -import org.gradle.api.DefaultTask import org.gradle.api.file.ConfigurableFileCollection import org.gradle.api.file.RegularFileProperty + +import org.gradle.api.DefaultTask import org.gradle.api.tasks.InputFile import org.gradle.api.tasks.InputFiles import org.gradle.api.tasks.TaskAction -import org.objectweb.asm.* + +import org.objectweb.asm.ClassReader +import org.objectweb.asm.ClassVisitor +import org.objectweb.asm.MethodVisitor +import org.objectweb.asm.Opcodes +import org.objectweb.asm.Type import java.util.zip.ZipEntry import java.util.zip.ZipInputStream diff --git a/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/CheckPatches.groovy b/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/CheckPatches.groovy index e6633cf074..64a0407552 100644 --- a/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/CheckPatches.groovy +++ b/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/CheckPatches.groovy @@ -17,8 +17,8 @@ abstract class CheckPatches extends DefaultTask { @TaskAction protected void exec() { def hasS2SArtifact = [ - Paths.get("patches/minecraft/net/minecraft/client/renderer/ViewFrustum.java.patch"), - Paths.get("patches/minecraft/net/minecraft/data/BlockModelDefinition.java.patch") + Paths.get("patches/minecraft/net/minecraft/client/renderer/ViewArea.java.patch"), + Paths.get("patches/minecraft/net/minecraft/data/models/blockstates/Variant.java.patch") ] def verified = true; diff --git a/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/CheckSAS.groovy b/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/CheckSAS.groovy index 6dd6453e29..ab16229872 100644 --- a/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/CheckSAS.groovy +++ b/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/CheckSAS.groovy @@ -1,8 +1,9 @@ package net.minecraftforge.forge.tasks -import org.gradle.api.DefaultTask import org.gradle.api.file.ConfigurableFileCollection import org.gradle.api.file.RegularFileProperty + +import org.gradle.api.DefaultTask import org.gradle.api.tasks.InputFile import org.gradle.api.tasks.InputFiles import org.gradle.api.tasks.TaskAction diff --git a/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/DownloadLibraries.groovy b/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/DownloadLibraries.groovy index 342146a5f3..b5e233cc6f 100644 --- a/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/DownloadLibraries.groovy +++ b/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/DownloadLibraries.groovy @@ -1,12 +1,15 @@ package net.minecraftforge.forge.tasks import org.gradle.api.DefaultTask +import org.gradle.api.file.ConfigurableFileCollection import org.gradle.api.file.DirectoryProperty import org.gradle.api.file.RegularFileProperty import org.gradle.api.tasks.InputFile -import org.gradle.api.tasks.OutputDirectory +import org.gradle.api.tasks.Internal import org.gradle.api.tasks.OutputFile +import org.gradle.api.tasks.OutputFiles import org.gradle.api.tasks.TaskAction +import org.gradle.api.tasks.OutputDirectory import java.nio.file.Files diff --git a/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/FieldCompareFinder.groovy b/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/FieldCompareFinder.groovy index 9134db369d..56648b5e95 100644 --- a/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/FieldCompareFinder.groovy +++ b/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/FieldCompareFinder.groovy @@ -1,11 +1,20 @@ package net.minecraftforge.forge.tasks import groovy.transform.EqualsAndHashCode -import org.gradle.api.tasks.Input -import org.gradle.api.tasks.Internal -import org.gradle.api.tasks.Nested -import org.gradle.api.tasks.Optional + +import java.util.ArrayList +import java.util.HashMap +import java.util.TreeMap +import java.util.TreeSet +import java.util.function.BiConsumer + +import org.gradle.api.DefaultTask +import org.gradle.api.tasks.* + +import org.objectweb.asm.Opcodes +import org.objectweb.asm.Type import org.objectweb.asm.tree.ClassNode +import org.objectweb.asm.tree.FieldNode import org.objectweb.asm.tree.MethodNode import static org.objectweb.asm.Opcodes.* diff --git a/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/InstallerJar.groovy b/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/InstallerJar.groovy new file mode 100644 index 0000000000..91e196d25e --- /dev/null +++ b/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/InstallerJar.groovy @@ -0,0 +1,44 @@ +package net.minecraftforge.forge.tasks + +import org.gradle.api.tasks.bundling.Zip +import org.gradle.api.tasks.* +import org.gradle.api.provider.SetProperty + +abstract class InstallerJar extends Zip { + @Input @Optional abstract SetProperty getPackedDependencies() + + InstallerJar() { + archiveClassifier.set('installer') + archiveExtension.set('jar') // Needs to be Zip task to not override Manifest, so set extension + destinationDirectory.set(project.layout.buildDirectory.dir('libs')) + + def installerJson = project.tasks.installerJson + def launcherJson = project.tasks.launcherJson + def downloadInstaller = project.tasks.downloadInstaller + + dependsOn(installerJson, launcherJson, downloadInstaller) + from(installerJson, launcherJson) + + from(project.rootProject.file('/src/main/resources/url.png')) + project.afterEvaluate { + from(project.zipTree(downloadInstaller.output)) { + duplicatesStrategy = 'exclude' + } + + if (!System.env.MAVEN_USER) { + dependsOn(project.universalJar) + from(project.universalJar) { + into '/maven/' + project.group.replace('.', '/') + '/' + project.universalJar.archiveBaseName.get() + '/' + project.version + '/' + } + + packedDependencies.get().forEach { + def jarTask = project.rootProject.getTasks().findByPath(it) + dependsOn(jarTask) + from(jarTask) { + into '/maven/' + jarTask.project.group.replace('.', '/') + '/' + jarTask.archiveBaseName.get() + '/' + jarTask.project.version + '/' + } + } + } + } + } +} diff --git a/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/InstallerJson.groovy b/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/InstallerJson.groovy new file mode 100644 index 0000000000..4842c9f607 --- /dev/null +++ b/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/InstallerJson.groovy @@ -0,0 +1,81 @@ +package net.minecraftforge.forge.tasks + +import groovy.json.JsonBuilder +import org.gradle.api.DefaultTask +import org.gradle.api.file.ConfigurableFileCollection +import org.gradle.api.file.RegularFileProperty +import org.gradle.api.provider.Property +import org.gradle.api.provider.SetProperty +import org.gradle.api.tasks.* + +import java.nio.file.Files + +abstract class InstallerJson extends DefaultTask { + @OutputFile abstract RegularFileProperty getOutput() + @InputFiles abstract ConfigurableFileCollection getInput() + @Input @Optional abstract SetProperty getPackedDependencies() + @Input @Optional final Map libraries = new LinkedHashMap<>() + @Input Map json = new LinkedHashMap<>() + @InputFile abstract RegularFileProperty getIcon() + @Input abstract Property getLauncherJsonName() + @Input abstract Property getLogo() + @Input abstract Property getMirrors() + @Input abstract Property getWelcome() + + InstallerJson() { + getLauncherJsonName().convention('/version.json') + getLogo().convention('/big_logo.png') + getMirrors().convention('https://files.minecraftforge.net/mirrors-2.0.json') + getWelcome().convention("Welcome to the simple ${project.name.capitalize()} installer.") + + getOutput().convention(project.layout.buildDirectory.file('install_profile.json')) + + ['client', 'server'].each { side -> + ['slim', 'extra'].each { type -> + def tsk = project.tasks.getByName("download${side.capitalize()}${type.capitalize()}") + dependsOn(tsk) + input.from(tsk.output) + } + def tsk = project.tasks.getByName("create${side.capitalize()}SRG") + dependsOn(tsk) + input.from(tsk.output) + } + + + project.afterEvaluate { + (packedDependencies.get().collect{ project.rootProject.tasks.findByPath(it) } + [project.universalJar]).forEach { + dependsOn(it) + input.from it.archiveFile + } + } + } + + @TaskAction + protected void exec() { + def libs = libraries + for (def child : packedDependencies.get().collect{ project.rootProject.tasks.findByPath(it) } + [project.universalJar]) { + def dep = Util.getMavenDep(child) + def path = Util.getMavenPath(child) + libs.put(dep.toString(), [ + name: dep, + downloads: [ + artifact: [ + path: path, + url: "https://maven.minecraftforge.net/${path}", + sha1: child.archiveFile.get().asFile.sha1(), + size: child.archiveFile.get().asFile.length() + ] + ] + ]) + } + json.libraries = libs.values().sort{a,b -> a.name.compareTo(b.name)} + json.icon = "data:image/png;base64," + new String(Base64.getEncoder().encode(Files.readAllBytes(icon.get().asFile.toPath()))) + json.json = launcherJsonName.get() + json.logo = logo.get() + if (!mirrors.get().isEmpty()) + json.mirrorList = mirrors.get() + json.welcome = welcome.get() + + Files.writeString(output.get().getAsFile().toPath(), new JsonBuilder(json).toPrettyString()) + } +} diff --git a/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/LauncherJson.groovy b/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/LauncherJson.groovy new file mode 100644 index 0000000000..20e684fd8b --- /dev/null +++ b/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/LauncherJson.groovy @@ -0,0 +1,71 @@ +package net.minecraftforge.forge.tasks + +import groovy.json.JsonBuilder +import org.gradle.api.DefaultTask +import org.gradle.api.file.ConfigurableFileCollection +import org.gradle.api.file.RegularFileProperty +import org.gradle.api.provider.SetProperty +import org.gradle.api.tasks.* + +import java.nio.file.Files + +import static net.minecraftforge.forge.tasks.Util.getArtifacts +import static net.minecraftforge.forge.tasks.Util.iso8601Now + +abstract class LauncherJson extends DefaultTask { + @OutputFile abstract RegularFileProperty getOutput() + @InputFiles abstract ConfigurableFileCollection getInput() + @Input Map json = new LinkedHashMap<>() + @Input @Optional abstract SetProperty getPackedDependencies() + + @Internal final vanilla = project.project(':mcp').file('build/mcp/downloadJson/version.json') + @Internal final timestamp = iso8601Now() + @Internal final comment = [ + "Please do not automate the download and installation of Forge.", + "Our efforts are supported by ads from the download page.", + "If you MUST automate this, please consider supporting the project through https://www.patreon.com/LexManos/" + ] + @Internal final id = "${project.rootProject.ext.MC_VERSION}-${project.name}${project.version.substring(project.rootProject.ext.MC_VERSION.length())}" + + LauncherJson() { + getOutput().convention(project.layout.buildDirectory.file('version.json')) + + dependsOn(':fmlloader:jar', 'universalJar') + getInput().from(project.tasks.universalJar.archiveFile, + project.project(':fmlloader').jar.archiveFile, + vanilla) + + project.afterEvaluate { + packedDependencies.get().forEach { + def jarTask = project.rootProject.tasks.findByPath(it) + dependsOn(jarTask) + input.from jarTask.archiveFile + } + } + } + + @TaskAction + protected void exec() { + if (!json.libraries) + json.libraries = [] + getArtifacts(project, project.configurations.installer, false).each { key, lib -> json.libraries.add(lib) } + getArtifacts(project, project.configurations.moduleonly, false).each { key, lib -> json.libraries.add(lib) } + + packedDependencies.get().collect{ project.rootProject.tasks.findByPath(it) }.forEach { + def path = Util.getMavenPath(it) + + json.libraries.add([ + name: Util.getMavenDep(it), + downloads: [ + artifact: [ + path: path, + url: "https://maven.minecraftforge.net/${path}", + sha1: it.archiveFile.get().asFile.sha1(), + size: it.archiveFile.get().asFile.length() + ] + ] + ]) + } + Files.writeString(output.get().asFile.toPath(), new JsonBuilder(json).toPrettyString()) + } +} diff --git a/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/Util.groovy b/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/Util.groovy index e3bd7f0129..2a785fb2bc 100644 --- a/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/Util.groovy +++ b/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/Util.groovy @@ -2,8 +2,10 @@ package net.minecraftforge.forge.tasks import groovy.json.JsonSlurper +import java.io.File import java.security.MessageDigest import java.text.SimpleDateFormat +import java.util.Date public class Util { static void init() { @@ -90,6 +92,17 @@ public class Util { } return ret } + + public static def getMavenPath(task) { + def classifier = task.archiveClassifier.get() + def dep = "${task.project.group}:${task.project.name}:${task.project.version}" + (classifier == '' ? '' : ':' + classifier) + return "${task.project.group.replace('.', '/')}/${task.project.name}/${task.project.version}/${task.project.name}-${task.project.version}".toString() + (classifier == '' ? '' : '-' + classifier) + '.jar' + } + + public static def getMavenDep(task) { + def classifier = task.archiveClassifier.get() + return "${task.project.group}:${task.project.name}:${task.project.version}" + (classifier == '' ? '' : ':' + classifier) + } public static def iso8601Now() { new Date().iso8601() } diff --git a/fmlcore/build.gradle b/fmlcore/build.gradle new file mode 100644 index 0000000000..86b1a19290 --- /dev/null +++ b/fmlcore/build.gradle @@ -0,0 +1,64 @@ +plugins { + id 'com.github.ben-manes.versions' + id 'org.javamodularity.moduleplugin' version '1.8.3' apply false +} +apply plugin: 'java-library' +apply plugin: 'jacoco' +apply plugin: 'org.javamodularity.moduleplugin' + +dependencyUpdates.rejectVersionIf { isNonStable(it.candidate.version) } + +dependencies { + compileOnly('org.jetbrains:annotations:21.0.1') + implementation(project(':fmlloader')) + api('net.minecraftforge:eventbus:5.0.+') + implementation('commons-io:commons-io:2.5') +} + +task sourcesJar(type: Jar) { + archiveClassifier = 'sources' + from sourceSets.main.allSource +} + +ext { + MANIFESTS = [ + '': [ + 'FMLModType': 'LIBRARY', + 'Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), + 'Git-Commit': GIT_INFO.abbreviatedId, + 'Git-Branch': GIT_INFO.branch, + 'Build-Number': "${System.getenv('BUILD_NUMBER')?:0}" + ] as LinkedHashMap, + 'net/minecraftforge/fml/loading/': [ + 'Specification-Title': 'FMLLoader', + 'Specification-Vendor': 'Forge Development LLC', + 'Specification-Version': '1', + 'Implementation-Title': 'FML Loader', + 'Implementation-Version': '1.0', + 'Implementation-Vendor': 'Forge' + ] as LinkedHashMap + ] +} + +jar.doFirst { + MANIFESTS.each { pkg, values -> + if (pkg == '') + manifest.attributes(values) + else + manifest.attributes(values, pkg) + } +} + +tasks.withType(JavaCompile) { + options.compilerArgs << '-Xlint:unchecked' +} + +artifacts { + archives jar + archives sourcesJar +} + +publishing.publications.mavenJava(MavenPublication) { + from components.java + artifact sourcesJar +} \ No newline at end of file diff --git a/fmlcore/src/main/java/net/minecraftforge/fml/Bindings.java b/fmlcore/src/main/java/net/minecraftforge/fml/Bindings.java new file mode 100644 index 0000000000..c6e300657d --- /dev/null +++ b/fmlcore/src/main/java/net/minecraftforge/fml/Bindings.java @@ -0,0 +1,36 @@ +package net.minecraftforge.fml; + +import cpw.mods.modlauncher.util.ServiceLoaderUtils; +import net.minecraftforge.eventbus.api.BusBuilder; +import net.minecraftforge.eventbus.api.IEventBus; +import net.minecraftforge.fml.config.IConfigEvent; +import net.minecraftforge.fml.loading.FMLLoader; + +import java.util.ServiceLoader; +import java.util.function.Supplier; + +public class Bindings { + private static final Bindings INSTANCE = new Bindings(); + + private final IBindingsProvider provider; + + private Bindings() { + final var providers = ServiceLoaderUtils.streamServiceLoader(()->ServiceLoader.load(FMLLoader.getGameLayer(), IBindingsProvider.class), sce->{}).toList(); + if (providers.size() != 1) { + throw new IllegalStateException("Could not find bindings provider"); + } + this.provider = providers.get(0); + } + + public static Supplier getForgeBus() { + return INSTANCE.provider.getForgeBusSupplier(); + } + + public static Supplier getMessageParser() { + return INSTANCE.provider.getMessageParser(); + } + + public static Supplier getConfigConfiguration() { + return INSTANCE.provider.getConfigConfiguration(); + } +} diff --git a/fmlcore/src/main/java/net/minecraftforge/fml/CrashReportCallables.java b/fmlcore/src/main/java/net/minecraftforge/fml/CrashReportCallables.java new file mode 100644 index 0000000000..0644b2f0cc --- /dev/null +++ b/fmlcore/src/main/java/net/minecraftforge/fml/CrashReportCallables.java @@ -0,0 +1,32 @@ +package net.minecraftforge.fml; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.function.Supplier; + +public class CrashReportCallables { + private static final List crashCallables = Collections.synchronizedList(new ArrayList<>()); + + public static void registerCrashCallable(ISystemReportExtender callable) + { + crashCallables.add(callable); + } + + public static void registerCrashCallable(String headerName, Supplier reportGenerator) { + registerCrashCallable(new ISystemReportExtender() { + @Override + public String getLabel() { + return headerName; + } + @Override + public String get() { + return reportGenerator.get(); + } + }); + } + + public static List allCrashCallables() { + return List.copyOf(crashCallables); + } +} diff --git a/src/main/java/net/minecraftforge/fml/DeferredWorkQueue.java b/fmlcore/src/main/java/net/minecraftforge/fml/DeferredWorkQueue.java similarity index 65% rename from src/main/java/net/minecraftforge/fml/DeferredWorkQueue.java rename to fmlcore/src/main/java/net/minecraftforge/fml/DeferredWorkQueue.java index 3343369fef..475b52d2fa 100644 --- a/src/main/java/net/minecraftforge/fml/DeferredWorkQueue.java +++ b/fmlcore/src/main/java/net/minecraftforge/fml/DeferredWorkQueue.java @@ -21,20 +21,19 @@ package net.minecraftforge.fml; import static net.minecraftforge.fml.Logging.LOADING; -import java.util.*; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentLinkedDeque; import java.util.concurrent.Executor; import java.util.concurrent.TimeUnit; import java.util.function.Supplier; -import net.minecraftforge.fml.event.lifecycle.ParallelDispatchEvent; -import org.apache.commons.lang3.time.StopWatch; +import com.google.common.base.Stopwatch; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import com.google.common.base.Stopwatch; - import net.minecraftforge.forgespi.language.IModInfo; /** @@ -52,26 +51,28 @@ public class DeferredWorkQueue { private static final Logger LOGGER = LogManager.getLogger(); - private static Map, DeferredWorkQueue> workQueues = new HashMap<>(); + private static final Map workQueues = new HashMap<>(); - private final ModLoadingStage modLoadingStage; private final ConcurrentLinkedDeque tasks = new ConcurrentLinkedDeque<>(); + private final ModLoadingStage modLoadingStage; - public DeferredWorkQueue(final ModLoadingStage modLoadingStage, Class eventClass) { + public DeferredWorkQueue(ModLoadingStage modLoadingStage) { this.modLoadingStage = modLoadingStage; - workQueues.put(eventClass, this); + workQueues.put(modLoadingStage, this); } - public static Optional lookup(Optional> parallelClass) { + @SuppressWarnings("OptionalUsedAsFieldOrParameterType") + public static Optional lookup(Optional parallelClass) { return Optional.ofNullable(workQueues.get(parallelClass.orElse(null))); } - void runTasks() { + public void runTasks() { if (tasks.isEmpty()) return; - LOGGER.debug(LOADING, "Dispatching synchronous work after {}: {} jobs", modLoadingStage, tasks.size()); - StopWatch globalTimer = StopWatch.createStarted(); + LOGGER.debug(LOADING, "Dispatching synchronous work for work queue {}: {} jobs", modLoadingStage, tasks.size()); + Stopwatch timer = Stopwatch.createStarted(); tasks.forEach(t->makeRunnable(t, Runnable::run)); - LOGGER.debug(LOADING, "Synchronous work queue completed in {}", globalTimer); + timer.stop(); + LOGGER.debug(LOADING, "Synchronous work queue completed in {}", timer); } private static void makeRunnable(TaskInfo ti, Executor executor) { @@ -93,28 +94,5 @@ public class DeferredWorkQueue return CompletableFuture.supplyAsync(work, r->tasks.add(new TaskInfo(modInfo, r))); } - /** - * DEPRECATED FOR REMOVAL. Use {@link ParallelDispatchEvent#enqueueWork(Runnable)} or {@link ParallelDispatchEvent#enqueueWork(Supplier)} - * - * @param workToEnqueue Runnable to execute later - * @return a completable future - */ - @Deprecated - public static CompletableFuture runLater(Runnable workToEnqueue) { - return - Optional.ofNullable(ModLoadingContext.get().getActiveContainer().modLoadingStage.getDeferredWorkQueue()) - .map(wq->wq.enqueueWork(ModLoadingContext.get().getActiveContainer().modInfo, workToEnqueue)) - .orElseGet(()->CompletableFuture.completedFuture(null)); - } - - static class TaskInfo - { - public final IModInfo owner; - public final Runnable task; - - private TaskInfo(IModInfo owner, Runnable task) { - this.owner = owner; - this.task = task; - } - } + record TaskInfo(IModInfo owner, Runnable task) {} } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/fml/DistExecutor.java b/fmlcore/src/main/java/net/minecraftforge/fml/DistExecutor.java similarity index 100% rename from src/main/java/net/minecraftforge/fml/DistExecutor.java rename to fmlcore/src/main/java/net/minecraftforge/fml/DistExecutor.java diff --git a/fmlcore/src/main/java/net/minecraftforge/fml/I18NParser.java b/fmlcore/src/main/java/net/minecraftforge/fml/I18NParser.java new file mode 100644 index 0000000000..c7e3f75a0a --- /dev/null +++ b/fmlcore/src/main/java/net/minecraftforge/fml/I18NParser.java @@ -0,0 +1,6 @@ +package net.minecraftforge.fml; + +public interface I18NParser { + String parseMessage(String i18nMessage, Object... args); + String stripControlCodes(String toStrip); +} diff --git a/fmlcore/src/main/java/net/minecraftforge/fml/IBindingsProvider.java b/fmlcore/src/main/java/net/minecraftforge/fml/IBindingsProvider.java new file mode 100644 index 0000000000..5800dce590 --- /dev/null +++ b/fmlcore/src/main/java/net/minecraftforge/fml/IBindingsProvider.java @@ -0,0 +1,12 @@ +package net.minecraftforge.fml; + +import net.minecraftforge.eventbus.api.IEventBus; +import net.minecraftforge.fml.config.IConfigEvent; + +import java.util.function.Supplier; + +public interface IBindingsProvider { + Supplier getForgeBusSupplier(); + Supplier getMessageParser(); + Supplier getConfigConfiguration(); +} diff --git a/fmlcore/src/main/java/net/minecraftforge/fml/ICrashCallable.java b/fmlcore/src/main/java/net/minecraftforge/fml/ICrashCallable.java new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/main/java/net/minecraftforge/fml/ExtensionPoint.java b/fmlcore/src/main/java/net/minecraftforge/fml/IExtensionPoint.java similarity index 76% rename from src/main/java/net/minecraftforge/fml/ExtensionPoint.java rename to fmlcore/src/main/java/net/minecraftforge/fml/IExtensionPoint.java index 23e6c1e342..dbe9c95aeb 100644 --- a/src/main/java/net/minecraftforge/fml/ExtensionPoint.java +++ b/fmlcore/src/main/java/net/minecraftforge/fml/IExtensionPoint.java @@ -19,21 +19,11 @@ package net.minecraftforge.fml; -import java.util.function.BiFunction; import java.util.function.BiPredicate; import java.util.function.Supplier; -import org.apache.commons.lang3.tuple.Pair; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.resources.IResourcePack; -import net.minecraftforge.fml.packs.ModFileResourcePack; - -public class ExtensionPoint +public interface IExtensionPoint { - public static final ExtensionPoint> CONFIGGUIFACTORY = new ExtensionPoint<>(); - public static final ExtensionPoint> RESOURCEPACK = new ExtensionPoint<>(); /** * Compatibility display test for the mod. * Used for displaying compatibility with remote servers with the same mod, and on disk saves. @@ -68,11 +58,5 @@ public class ExtensionPoint *

* */ - public static final ExtensionPoint, BiPredicate>> DISPLAYTEST = new ExtensionPoint<>(); - - private Class type; - - private ExtensionPoint() { - } - + record DisplayTest(Supplier suppliedVersion, BiPredicate remoteVersionTest) implements IExtensionPoint {} } diff --git a/fmlcore/src/main/java/net/minecraftforge/fml/IModLoadingState.java b/fmlcore/src/main/java/net/minecraftforge/fml/IModLoadingState.java new file mode 100644 index 0000000000..83fea95e63 --- /dev/null +++ b/fmlcore/src/main/java/net/minecraftforge/fml/IModLoadingState.java @@ -0,0 +1,25 @@ +package net.minecraftforge.fml; + +import net.minecraftforge.eventbus.api.Event; +import net.minecraftforge.fml.event.IModBusEvent; + +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Executor; +import java.util.function.Consumer; +import java.util.function.Function; + +public interface IModLoadingState { + String name(); + String previous(); + ModLoadingPhase phase(); + Function message(); + Optional> inlineRunnable(); + + default Optional>> buildTransition(final Executor syncExecutor, final Executor parallelExecutor) { + return buildTransition(syncExecutor, parallelExecutor, e->CompletableFuture.runAsync(()->{}, e), e->CompletableFuture.runAsync(()->{}, e)); + } + + Optional>> buildTransition(Executor syncExecutor, Executor parallelExecutor, Function> preSyncTask, Function> postSyncTask); +} diff --git a/fmlcore/src/main/java/net/minecraftforge/fml/IModStateProvider.java b/fmlcore/src/main/java/net/minecraftforge/fml/IModStateProvider.java new file mode 100644 index 0000000000..4888698e15 --- /dev/null +++ b/fmlcore/src/main/java/net/minecraftforge/fml/IModStateProvider.java @@ -0,0 +1,7 @@ +package net.minecraftforge.fml; + +import java.util.List; + +public interface IModStateProvider { + List getAllStates(); +} diff --git a/fmlcore/src/main/java/net/minecraftforge/fml/IModStateTransition.java b/fmlcore/src/main/java/net/minecraftforge/fml/IModStateTransition.java new file mode 100644 index 0000000000..330008ed27 --- /dev/null +++ b/fmlcore/src/main/java/net/minecraftforge/fml/IModStateTransition.java @@ -0,0 +1,87 @@ +package net.minecraftforge.fml; + +import net.minecraftforge.eventbus.api.Event; +import net.minecraftforge.fml.event.IModBusEvent; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Executor; +import java.util.function.BiFunction; +import java.util.function.Function; +import java.util.function.Supplier; +import java.util.stream.Stream; + +@SuppressWarnings("unchecked") +public interface IModStateTransition { + static IModStateTransition buildNoopTransition() { + return new NoopTransition(); + } + + default CompletableFuture> build(Executor syncExecutor, Executor parallelExecutor, Function> preSyncTask, Function> postSyncTask) { + List>> cfs = new ArrayList<>(); + this.eventFunctionStream().get() + .map(f->(EventGenerator)f) + .reduce((head, tail)-> addCompletableFutureTaskForModDispatch(syncExecutor, parallelExecutor, cfs, head, ModLoadingStage::currentState, tail)) + .ifPresent(last-> addCompletableFutureTaskForModDispatch(syncExecutor, parallelExecutor, cfs, last, nextModLoadingStage(), null)); + final CompletableFuture preSyncTaskCF = preSyncTask.apply(syncExecutor); + final CompletableFuture> eventDispatchCF = ModList.gather(cfs).thenCompose(ModList::completableFutureFromExceptionList); + final CompletableFuture> postEventDispatchCF = preSyncTaskCF.thenComposeAsync(n -> eventDispatchCF, parallelExecutor).thenApply(r -> { + postSyncTask.apply(syncExecutor); + return r; + }); + return this.finalActivityGenerator().apply(syncExecutor, postEventDispatchCF); + } + + default BiFunction nextModLoadingStage() { + return ModLoadingStage::nextState; + } + + private EventGenerator addCompletableFutureTaskForModDispatch(final Executor syncExecutor, final Executor parallelExecutor, final List>> completeableFutures, final EventGenerator eventGenerator, BiFunction nextState, final EventGenerator nextGenerator) { + completeableFutures.add(((BiFunction, CompletableFuture>>)preDispatchHook()).apply(threadSelector().apply(syncExecutor, parallelExecutor), eventGenerator)); + completeableFutures.add(ModList.get().futureVisitor(eventGenerator, nextState).apply(threadSelector().apply(syncExecutor, parallelExecutor))); + completeableFutures.add(((BiFunction, CompletableFuture>>)postDispatchHook()).apply(threadSelector().apply(syncExecutor, parallelExecutor), eventGenerator)); + return nextGenerator; + } + + Supplier>> eventFunctionStream(); + ThreadSelector threadSelector(); + BiFunction>, CompletableFuture>> finalActivityGenerator(); + BiFunction, CompletableFuture>> preDispatchHook(); + BiFunction, CompletableFuture>> postDispatchHook(); + + interface EventGenerator extends Function { + static EventGenerator fromFunction(Function fn) { + return fn::apply; + } + } +} + +record NoopTransition() implements IModStateTransition { + + @Override + public Supplier>> eventFunctionStream() { + return Stream::of; + } + + @Override + public ThreadSelector threadSelector() { + return ThreadSelector.SYNC; + } + + @Override + public BiFunction>, CompletableFuture>> finalActivityGenerator() { + return (e, t) -> t.thenApplyAsync(Function.identity(), e); + } + + @Override + public BiFunction, CompletableFuture>> preDispatchHook() { + return (t, f)-> CompletableFuture.completedFuture(Collections.emptyList()); + } + + @Override + public BiFunction, CompletableFuture>> postDispatchHook() { + return (t, f)-> CompletableFuture.completedFuture(Collections.emptyList()); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/fml/common/ICrashCallable.java b/fmlcore/src/main/java/net/minecraftforge/fml/ISystemReportExtender.java similarity index 83% rename from src/main/java/net/minecraftforge/fml/common/ICrashCallable.java rename to fmlcore/src/main/java/net/minecraftforge/fml/ISystemReportExtender.java index f9f4064be9..fc64a9325d 100644 --- a/src/main/java/net/minecraftforge/fml/common/ICrashCallable.java +++ b/fmlcore/src/main/java/net/minecraftforge/fml/ISystemReportExtender.java @@ -17,11 +17,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.common; +package net.minecraftforge.fml; -import net.minecraft.crash.ICrashReportDetail; +import java.util.function.Supplier; -public interface ICrashCallable extends ICrashReportDetail +public interface ISystemReportExtender extends Supplier { String getLabel(); } diff --git a/src/main/java/net/minecraftforge/fml/InterModComms.java b/fmlcore/src/main/java/net/minecraftforge/fml/InterModComms.java similarity index 92% rename from src/main/java/net/minecraftforge/fml/InterModComms.java rename to fmlcore/src/main/java/net/minecraftforge/fml/InterModComms.java index 45fadae85b..1c21df0e7b 100644 --- a/src/main/java/net/minecraftforge/fml/InterModComms.java +++ b/fmlcore/src/main/java/net/minecraftforge/fml/InterModComms.java @@ -33,38 +33,32 @@ import java.util.stream.StreamSupport; public class InterModComms { - public static final class IMCMessage { - private final String modId; - private final String method; - private final String senderModId; - private final Supplier thing; - - IMCMessage(String senderModId, String modId, String method, Supplier thing) - { - this.senderModId = senderModId; - this.modId = modId; - this.method = method; - this.thing = thing; - } + public record IMCMessage(String senderModId, String modId, String method, Supplier messageSupplier) { /** + * Deprecated: use {@link #senderModId()} * @return The modid of the sender. This is supplied by the caller, or by the active mod container context. * Consider it unreliable. */ + @Deprecated public final String getSenderModId() { return this.senderModId; } /** + * Deprecated: use {@link #modId()} * @return The modid being sent to. */ + @Deprecated public final String getModId() { return this.modId; } /** + * Deprecated: use {@link #method()} * @return The method being sent to. */ + @Deprecated public final String getMethod() { return this.method; } @@ -72,10 +66,12 @@ public class InterModComms /** * @param The type of the message. * @return A {@link Supplier} of the message. + * Use {@link #messageSupplier()} */ @SuppressWarnings("unchecked") + @Deprecated public final Supplier getMessageSupplier() { - return (Supplier)this.thing; + return (Supplier) this.messageSupplier; } } diff --git a/src/main/java/net/minecraftforge/fml/LoadingFailedException.java b/fmlcore/src/main/java/net/minecraftforge/fml/LoadingFailedException.java similarity index 100% rename from src/main/java/net/minecraftforge/fml/LoadingFailedException.java rename to fmlcore/src/main/java/net/minecraftforge/fml/LoadingFailedException.java diff --git a/src/main/java/net/minecraftforge/fml/Logging.java b/fmlcore/src/main/java/net/minecraftforge/fml/Logging.java similarity index 93% rename from src/main/java/net/minecraftforge/fml/Logging.java rename to fmlcore/src/main/java/net/minecraftforge/fml/Logging.java index d29b9618b5..26efa8544d 100644 --- a/src/main/java/net/minecraftforge/fml/Logging.java +++ b/fmlcore/src/main/java/net/minecraftforge/fml/Logging.java @@ -31,6 +31,7 @@ public class Logging public static final Marker SPLASH = MarkerManager.getMarker("SPLASH"); public static final Marker CAPABILITIES = MarkerManager.getMarker("CAPABILITIES"); public static final Marker MODELLOADING = MarkerManager.getMarker("MODELLOADING"); + public static final Marker FORGEMOD = MarkerManager.getMarker("FORGEMOD").addParents(LOADING); // --log CORE:+DEBUG,SCAN:-OFF // forge log debug 5 diff --git a/src/main/java/net/minecraftforge/fml/LogicalSide.java b/fmlcore/src/main/java/net/minecraftforge/fml/LogicalSide.java similarity index 100% rename from src/main/java/net/minecraftforge/fml/LogicalSide.java rename to fmlcore/src/main/java/net/minecraftforge/fml/LogicalSide.java diff --git a/src/main/java/net/minecraftforge/fml/ModContainer.java b/fmlcore/src/main/java/net/minecraftforge/fml/ModContainer.java similarity index 86% rename from src/main/java/net/minecraftforge/fml/ModContainer.java rename to fmlcore/src/main/java/net/minecraftforge/fml/ModContainer.java index 605582405e..56a44b986a 100644 --- a/src/main/java/net/minecraftforge/fml/ModContainer.java +++ b/fmlcore/src/main/java/net/minecraftforge/fml/ModContainer.java @@ -20,10 +20,10 @@ package net.minecraftforge.fml; import net.minecraftforge.eventbus.api.Event; +import net.minecraftforge.fml.config.IConfigEvent; import net.minecraftforge.fml.config.ModConfig; -import net.minecraftforge.fml.event.lifecycle.IModBusEvent; +import net.minecraftforge.fml.event.IModBusEvent; import net.minecraftforge.forgespi.language.IModInfo; -import org.apache.commons.lang3.tuple.Pair; import java.util.EnumMap; import java.util.HashMap; @@ -58,10 +58,10 @@ public abstract class ModContainer protected ModLoadingStage modLoadingStage; protected Supplier contextExtension; protected final Map activityMap = new HashMap<>(); - protected final Map> extensionPoints = new IdentityHashMap<>(); + protected final Map>, Supplier> extensionPoints = new IdentityHashMap<>(); protected final EnumMap configs = new EnumMap<>(ModConfig.Type.class); @SuppressWarnings("OptionalUsedAsFieldOrParameterType") - protected Optional> configHandler = Optional.empty(); + protected Optional> configHandler = Optional.empty(); public ModContainer(IModInfo info) { @@ -71,7 +71,7 @@ public abstract class ModContainer this.modInfo = info; this.modLoadingStage = ModLoadingStage.CONSTRUCT; // default displaytest extension checks for version string match - registerExtensionPoint(ExtensionPoint.DISPLAYTEST, () -> Pair.of(()->this.modInfo.getVersion().toString(), + registerExtensionPoint(IExtensionPoint.DisplayTest.class, () -> new IExtensionPoint.DisplayTest(()->this.modInfo.getVersion().toString(), (incoming, isNetwork)->Objects.equals(incoming, this.modInfo.getVersion().toString()))); } @@ -111,7 +111,7 @@ public abstract class ModContainer public static CompletableFuture buildTransitionHandler( final ModContainer target, - final ModLoadingStage.EventGenerator eventGenerator, + final IModStateTransition.EventGenerator eventGenerator, final BiFunction stateChangeHandler, final Executor executor) { return CompletableFuture @@ -126,20 +126,17 @@ public abstract class ModContainer }); } - /** - * @return the modinfo used to create this mod instance - */ public IModInfo getModInfo() { return modInfo; } @SuppressWarnings("unchecked") - public Optional getCustomExtension(ExtensionPoint point) { + public Optional getCustomExtension(Class> point) { return Optional.ofNullable((T)extensionPoints.getOrDefault(point,()-> null).get()); } - public void registerExtensionPoint(ExtensionPoint point, Supplier extension) + public > void registerExtensionPoint(Class> point, Supplier extension) { extensionPoints.put(point, extension); } @@ -148,7 +145,7 @@ public abstract class ModContainer configs.put(modConfig.getType(), modConfig); } - public void dispatchConfigEvent(ModConfig.ModConfigEvent event) { + public void dispatchConfigEvent(IConfigEvent event) { configHandler.ifPresent(configHandler->configHandler.accept(event)); } diff --git a/src/main/java/net/minecraftforge/fml/ModList.java b/fmlcore/src/main/java/net/minecraftforge/fml/ModList.java similarity index 87% rename from src/main/java/net/minecraftforge/fml/ModList.java rename to fmlcore/src/main/java/net/minecraftforge/fml/ModList.java index 889bc557d3..5f685edade 100644 --- a/src/main/java/net/minecraftforge/fml/ModList.java +++ b/fmlcore/src/main/java/net/minecraftforge/fml/ModList.java @@ -20,11 +20,14 @@ package net.minecraftforge.fml; import net.minecraftforge.eventbus.api.Event; -import net.minecraftforge.fml.event.lifecycle.IModBusEvent; +import net.minecraftforge.fml.event.IModBusEvent; +import net.minecraftforge.forgespi.language.IModFileInfo; +import net.minecraftforge.forgespi.language.IModInfo; import net.minecraftforge.forgespi.language.ModFileScanData; import net.minecraftforge.fml.loading.moddiscovery.ModFile; import net.minecraftforge.fml.loading.moddiscovery.ModFileInfo; import net.minecraftforge.fml.loading.moddiscovery.ModInfo; +import net.minecraftforge.forgespi.locating.IModFile; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -58,8 +61,8 @@ public class ModList { private static Logger LOGGER = LogManager.getLogger(); private static ModList INSTANCE; - private final List modFiles; - private final List sortedList; + private final List modFiles; + private final List sortedList; private final Map fileById; private List mods; private Map indexedMods; @@ -71,17 +74,17 @@ public class ModList this.sortedList = sortedList.stream(). map(ModInfo.class::cast). collect(Collectors.toList()); - this.fileById = this.modFiles.stream().map(ModFileInfo::getMods).flatMap(Collection::stream). + this.fileById = this.modFiles.stream().map(IModFileInfo::getMods).flatMap(Collection::stream). map(ModInfo.class::cast). collect(Collectors.toMap(ModInfo::getModId, ModInfo::getOwningFile)); - CrashReportExtender.registerCrashCallable("Mod List", this::crashReport); + CrashReportCallables.registerCrashCallable("Mod List", this::crashReport); } private String getModContainerState(String modId) { return getModContainerById(modId).map(ModContainer::getCurrentState).map(Object::toString).orElse("NONE"); } - private String fileToLine(ModFile mf) { + private String fileToLine(IModFile mf) { return String.format("%-50.50s|%-30.30s|%-30.30s|%-20.20s|%-10.10s|Manifest: %s", mf.getFileName(), mf.getModInfos().get(0).getDisplayName(), mf.getModInfos().get(0).getModId(), @@ -111,18 +114,18 @@ public class ModList return thread; } - public List getModFiles() + public List getModFiles() { return modFiles; } - public ModFileInfo getModFileById(String modid) + public IModFileInfo getModFileById(String modid) { return this.fileById.get(modid); } Function>> futureVisitor( - final ModLoadingStage.EventGenerator eventGenerator, + final IModStateTransition.EventGenerator eventGenerator, final BiFunction stateChange) { return executor -> gather( this.mods.stream() @@ -185,7 +188,7 @@ public class ModList return mods.stream().filter(mc -> mc.getMod() == obj).findFirst(); } - public List getMods() + public List getMods() { return this.sortedList; } @@ -205,24 +208,24 @@ public class ModList if (modFileScanData == null) { modFileScanData = this.sortedList.stream(). - map(ModInfo::getOwningFile). + map(IModInfo::getOwningFile). filter(Objects::nonNull). - map(ModFileInfo::getFile). + map(IModFileInfo::getFile). distinct(). - map(ModFile::getScanResult). + map(IModFile::getScanResult). collect(Collectors.toList()); } return modFileScanData; } - public void forEachModFile(Consumer fileConsumer) + public void forEachModFile(Consumer fileConsumer) { - modFiles.stream().map(ModFileInfo::getFile).forEach(fileConsumer); + modFiles.stream().map(IModFileInfo::getFile).forEach(fileConsumer); } - public Stream applyForEachModFile(Function function) { - return modFiles.stream().map(ModFileInfo::getFile).map(function); + public Stream applyForEachModFile(Function function) { + return modFiles.stream().map(IModFileInfo::getFile).map(function); } public void forEachModContainer(BiConsumer modContainerConsumer) { diff --git a/src/main/java/net/minecraftforge/fml/ModLoader.java b/fmlcore/src/main/java/net/minecraftforge/fml/ModLoader.java similarity index 66% rename from src/main/java/net/minecraftforge/fml/ModLoader.java rename to fmlcore/src/main/java/net/minecraftforge/fml/ModLoader.java index 0462b28d3d..eed6990710 100644 --- a/src/main/java/net/minecraftforge/fml/ModLoader.java +++ b/fmlcore/src/main/java/net/minecraftforge/fml/ModLoader.java @@ -20,28 +20,16 @@ package net.minecraftforge.fml; import com.google.common.collect.ImmutableList; -import cpw.mods.modlauncher.TransformingClassLoader; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.common.capabilities.CapabilityManager; import net.minecraftforge.eventbus.api.Event; -import net.minecraftforge.fml.config.ConfigTracker; -import net.minecraftforge.fml.config.ModConfig; -import net.minecraftforge.fml.event.lifecycle.IModBusEvent; +import net.minecraftforge.fml.event.IModBusEvent; import net.minecraftforge.fml.loading.FMLLoader; -import net.minecraftforge.fml.loading.FMLPaths; import net.minecraftforge.fml.loading.LoadingModList; import net.minecraftforge.fml.loading.moddiscovery.InvalidModIdentifier; import net.minecraftforge.fml.loading.moddiscovery.ModFile; import net.minecraftforge.fml.loading.moddiscovery.ModFileInfo; -import net.minecraftforge.fml.loading.moddiscovery.ModInfo; import net.minecraftforge.fml.loading.progress.StartupMessageManager; -import net.minecraftforge.fml.network.FMLNetworkConstants; -import net.minecraftforge.fml.network.NetworkRegistry; import net.minecraftforge.forgespi.language.IModInfo; import net.minecraftforge.forgespi.language.IModLanguageProvider; -import net.minecraftforge.registries.GameData; -import net.minecraftforge.registries.ObjectHolderRegistry; -import net.minecraftforge.versions.forge.ForgeVersion; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -102,38 +90,37 @@ public class ModLoader { private static final Logger LOGGER = LogManager.getLogger(); private static ModLoader INSTANCE; - private final TransformingClassLoader launchClassLoader; private final LoadingModList loadingModList; private final List loadingExceptions; private final List loadingWarnings; + private final ModStateManager stateManager; private boolean loadingStateValid; @SuppressWarnings("OptionalUsedAsFieldOrParameterType") private final Optional> statusConsumer = StartupMessageManager.modLoaderConsumer(); + private ModList modList; private ModLoader() { INSTANCE = this; - this.launchClassLoader = FMLLoader.getLaunchClassLoader(); this.loadingModList = FMLLoader.getLoadingModList(); - this.loadingExceptions = FMLLoader.getLoadingModList(). - getErrors().stream().flatMap(ModLoadingException::fromEarlyException).collect(Collectors.toList()); - this.loadingWarnings = FMLLoader.getLoadingModList(). - getBrokenFiles().stream().map(file -> new ModLoadingWarning(null, ModLoadingStage.VALIDATE, - InvalidModIdentifier.identifyJarProblem(file.getFilePath()).orElse("fml.modloading.brokenfile"), file.getFileName())).collect(Collectors.toList()); - FMLLoader.getLoadingModList() - .getModFiles().stream().filter(ModFileInfo::missingLicense) //Search for files with missing licenses + this.loadingExceptions = FMLLoader.getLoadingModList().getErrors().stream() + .flatMap(ModLoadingException::fromEarlyException) + .collect(Collectors.toList()); + this.loadingWarnings = FMLLoader.getLoadingModList().getBrokenFiles().stream() + .map(file -> new ModLoadingWarning(null, ModLoadingStage.VALIDATE, InvalidModIdentifier.identifyJarProblem(file.getFilePath()).orElse("fml.modloading.brokenfile"), file.getFileName())) + .collect(Collectors.toList()); + FMLLoader.getLoadingModList().getModFiles().stream() + .filter(ModFileInfo::missingLicense) //Search for files with missing licenses .filter(modFileInfo -> modFileInfo.getMods().stream().noneMatch(thisModInfo -> this.loadingExceptions.stream().map(ModLoadingException::getModInfo).anyMatch(otherInfo -> otherInfo == thisModInfo))) //Ignore files where any other mod already encountered an error .map(modFileInfo -> new ModLoadingException(null, ModLoadingStage.VALIDATE, "fml.modloading.missinglicense", null, modFileInfo.getFile())) .forEach(this.loadingExceptions::add); - LOGGER.debug(CORE, "Loading Network data for FML net version: {}", FMLNetworkConstants.init()); - CrashReportExtender.registerCrashCallable("ModLauncher", FMLLoader::getLauncherInfo); - CrashReportExtender.registerCrashCallable("ModLauncher launch target", FMLLoader::launcherHandlerName); - CrashReportExtender.registerCrashCallable("ModLauncher naming", FMLLoader::getNaming); - CrashReportExtender.registerCrashCallable("ModLauncher services", this::computeModLauncherServiceList); - CrashReportExtender.registerCrashCallable("FML", ForgeVersion::getSpec); - CrashReportExtender.registerCrashCallable("Forge", ()->ForgeVersion.getGroup()+":"+ForgeVersion.getVersion()); - CrashReportExtender.registerCrashCallable("FML Language Providers", this::computeLanguageList); + this.stateManager = new ModStateManager(); + CrashReportCallables.registerCrashCallable("ModLauncher", FMLLoader::getLauncherInfo); + CrashReportCallables.registerCrashCallable("ModLauncher launch target", FMLLoader::launcherHandlerName); + CrashReportCallables.registerCrashCallable("ModLauncher naming", FMLLoader::getNaming); + CrashReportCallables.registerCrashCallable("ModLauncher services", this::computeModLauncherServiceList); + CrashReportCallables.registerCrashCallable("FML Language Providers", this::computeLanguageList); } private String computeLanguageList() { @@ -165,11 +152,7 @@ public class ModLoader statusConsumer.ifPresent(c->c.accept("Waiting for scan to complete")); FMLLoader.backgroundScanHandler.waitForScanToComplete(periodicTask); statusConsumer.ifPresent(c->c.accept("Loading mods")); - final ModList modList = ModList.of(loadingModList - .getModFiles() - .stream() - .map(ModFileInfo::getFile) - .collect(Collectors.toList()), + final ModList modList = ModList.of(loadingModList.getModFiles().stream().map(ModFileInfo::getFile).toList(), loadingModList.getMods()); if (!this.loadingExceptions.isEmpty()) { LOGGER.fatal(CORE, "Error during pre-loading phase", loadingExceptions.get(0)); @@ -178,11 +161,11 @@ public class ModLoader throw new LoadingFailedException(loadingExceptions); } statusConsumer.ifPresent(c->c.accept("Building Mod List")); - final List modContainers = loadingModList.getModFiles().stream(). - map(ModFileInfo::getFile). - map(mf -> buildMods(mf, launchClassLoader)). - flatMap(Collection::stream). - collect(Collectors.toList()); + final List modContainers = loadingModList.getModFiles().stream() + .map(ModFileInfo::getFile) + .map(this::buildMods) + .mapMulti(Iterable::forEach) + .toList(); if (!loadingExceptions.isEmpty()) { LOGGER.fatal(CORE, "Failed to initialize mod containers", loadingExceptions.get(0)); modList.setLoadedMods(Collections.emptyList()); @@ -190,61 +173,45 @@ public class ModLoader throw new LoadingFailedException(loadingExceptions); } modList.setLoadedMods(modContainers); - statusConsumer.ifPresent(c->c.accept(String.format("Constructing %d mods", modList.size()))); - dispatchAndHandleError(ModLoadingStage.CONSTRUCT, syncExecutor, parallelExecutor, periodicTask); - statusConsumer.ifPresent(c->c.accept("Creating registries")); - dispatchAndHandleError(ModLoadingStage.CREATE_REGISTRIES, syncExecutor, parallelExecutor, periodicTask); - ObjectHolderRegistry.findObjectHolders(); - CapabilityManager.INSTANCE.injectCapabilities(modList.getAllScanData()); - statusConsumer.ifPresent(c->c.accept("Adding custom tag types")); - GameData.setCustomTagTypesFromRegistries(); - statusConsumer.ifPresent(c->c.accept("Populating registries")); - dispatchAndHandleError(ModLoadingStage.LOAD_REGISTRIES, syncExecutor, parallelExecutor, periodicTask); - statusConsumer.ifPresent(c->c.accept("Early mod loading complete")); + this.modList = modList; + statusConsumer.ifPresent(c->c.accept("Dispatching gathering events")); + stateManager.getStates(ModLoadingPhase.GATHER).forEach(mls->dispatchAndHandleError(mls, syncExecutor, parallelExecutor, periodicTask)); + statusConsumer.ifPresent(c->c.accept("Gathering phase complete")); } - public void loadMods(final ModWorkManager.DrivenExecutor syncExecutor, final Executor parallelExecutor, final Function> beforeSidedEvent, final Function> afterSidedEvent, final Runnable periodicTask) { - statusConsumer.ifPresent(c->c.accept("Loading mod config")); - DistExecutor.unsafeRunWhenOn(Dist.CLIENT, ()->()-> ConfigTracker.INSTANCE.loadConfigs(ModConfig.Type.CLIENT, FMLPaths.CONFIGDIR.get())); - ConfigTracker.INSTANCE.loadConfigs(ModConfig.Type.COMMON, FMLPaths.CONFIGDIR.get()); - statusConsumer.ifPresent(c->c.accept("Mod setup: SETUP")); - dispatchAndHandleError(ModLoadingStage.COMMON_SETUP, syncExecutor, parallelExecutor, periodicTask); - statusConsumer.ifPresent(c->c.accept("Mod setup: SIDED SETUP")); - dispatchAndHandleError(ModLoadingStage.SIDED_SETUP, syncExecutor, parallelExecutor, periodicTask, beforeSidedEvent, afterSidedEvent); + public void loadMods(final ModWorkManager.DrivenExecutor syncExecutor, final Executor parallelExecutor, final Runnable periodicTask) { + statusConsumer.ifPresent(c->c.accept("Performing load phase")); + stateManager.getStates(ModLoadingPhase.LOAD).forEach(mls->dispatchAndHandleError(mls, syncExecutor, parallelExecutor, periodicTask)); statusConsumer.ifPresent(c->c.accept("Mod setup complete")); } - public void finishMods(final ModWorkManager.DrivenExecutor syncExecutor, final Executor parallelExecutor, final Runnable periodicTask) - { - statusConsumer.ifPresent(c->c.accept("Mod setup: ENQUEUE IMC")); - dispatchAndHandleError(ModLoadingStage.ENQUEUE_IMC, syncExecutor, parallelExecutor, periodicTask); - statusConsumer.ifPresent(c->c.accept("Mod setup: PROCESS IMC")); - dispatchAndHandleError(ModLoadingStage.PROCESS_IMC, syncExecutor, parallelExecutor, periodicTask); - statusConsumer.ifPresent(c->c.accept("Mod setup: Final completion")); - dispatchAndHandleError(ModLoadingStage.COMPLETE, syncExecutor, parallelExecutor, periodicTask); - statusConsumer.ifPresent(c->c.accept("Freezing data")); - GameData.freezeData(); - NetworkRegistry.lock(); - statusConsumer.ifPresent(c->c.accept(String.format("Mod loading complete - %d mods loaded", ModList.get().size()))); + public void finishMods(final ModWorkManager.DrivenExecutor syncExecutor, final Executor parallelExecutor, final Runnable periodicTask) { + statusConsumer.ifPresent(c->c.accept("Performing completion phase")); + stateManager.getStates(ModLoadingPhase.COMPLETE).forEach(mls->dispatchAndHandleError(mls, syncExecutor, parallelExecutor, periodicTask)); + statusConsumer.ifPresent(c->c.accept(String.format("Mod loading complete - %d mods loaded", this.modList.size()))); } - private void dispatchAndHandleError(ModLoadingStage state, ModWorkManager.DrivenExecutor syncExecutor, Executor parallelExecutor, final Runnable ticker) { + private void dispatchAndHandleError(IModLoadingState state, ModWorkManager.DrivenExecutor syncExecutor, Executor parallelExecutor, final Runnable ticker) { if (!isLoadingStateValid()) { LOGGER.error("Cowardly refusing to process mod state change request from {}", state); return; } - waitForTransition(state, syncExecutor, ticker, state.buildTransition(syncExecutor, parallelExecutor)); + statusConsumer.ifPresent(c->c.accept(state.message().apply(this.modList))); + state.inlineRunnable().ifPresent(a->a.accept(this.modList)); + state.buildTransition(syncExecutor, parallelExecutor).ifPresent(t->waitForTransition(state, syncExecutor, ticker, t)); } - private void dispatchAndHandleError(ModLoadingStage state, ModWorkManager.DrivenExecutor syncExecutor, Executor parallelExecutor, final Runnable ticker, Function> preSyncTask, Function> postSyncTask) { + private void dispatchAndHandleError(IModLoadingState state, ModWorkManager.DrivenExecutor syncExecutor, Executor parallelExecutor, final Runnable ticker, Function> preSyncTask, Function> postSyncTask) { if (!isLoadingStateValid()) { LOGGER.error("Cowardly refusing to process mod state change request from {}", state); return; } - waitForTransition(state, syncExecutor, ticker, state.buildTransition(syncExecutor, parallelExecutor, preSyncTask, postSyncTask)); + statusConsumer.ifPresent(c->c.accept(state.message().apply(this.modList))); + state.inlineRunnable().ifPresent(a->a.accept(this.modList)); + state.buildTransition(syncExecutor, parallelExecutor, preSyncTask, postSyncTask).ifPresent(t->waitForTransition(state, syncExecutor, ticker, t)); } - private void waitForTransition(final ModLoadingStage state, final ModWorkManager.DrivenExecutor syncExecutor, final Runnable ticker, final CompletableFuture> transition) { + private void waitForTransition(final IModLoadingState state, final ModWorkManager.DrivenExecutor syncExecutor, final Runnable ticker, final CompletableFuture> transition) { while (!transition.isDone()) { syncExecutor.drive(ticker); } @@ -265,12 +232,12 @@ public class ModLoader .filter(ModLoadingException.class::isInstance) .map(ModLoadingException.class::cast) .collect(Collectors.toList()); - LOGGER.fatal(LOADING,"Failed to complete lifecycle event {}, {} errors found", state, modLoadingExceptions.size()); + LOGGER.fatal(LOADING,"Failed to complete lifecycle event {}, {} errors found", state.name(), modLoadingExceptions.size()); throw new LoadingFailedException(modLoadingExceptions); } } - private List buildMods(final ModFile modFile, final TransformingClassLoader modClassLoader) + private List buildMods(final ModFile modFile) { final Map modInfoMap = modFile.getModFileInfo().getMods().stream().collect(Collectors.toMap(IModInfo::getModId, Function.identity())); @@ -278,7 +245,7 @@ public class ModLoader final List containers = modFile.getScanResult().getTargets() .entrySet() .stream() - .map(e -> buildModContainerFromTOML(modFile, modClassLoader, modInfoMap, e)) + .map(e -> buildModContainerFromTOML(modFile, modInfoMap, e)) .filter(Objects::nonNull) .collect(Collectors.toList()); if (containers.size() != modInfoMap.size()) { @@ -292,14 +259,14 @@ public class ModLoader return containers.stream().filter(mc -> mc.modLoadingStage != ModLoadingStage.ERROR).collect(Collectors.toList()); } - private ModContainer buildModContainerFromTOML(final ModFile modFile, final TransformingClassLoader modClassLoader, final Map modInfoMap, final Map.Entry idToProviderEntry) { + private ModContainer buildModContainerFromTOML(final ModFile modFile, final Map modInfoMap, final Map.Entry idToProviderEntry) { try { final String modId = idToProviderEntry.getKey(); final IModLanguageProvider.IModLanguageLoader languageLoader = idToProviderEntry.getValue(); IModInfo info = Optional.ofNullable(modInfoMap.get(modId)). // throw a missing metadata error if there is no matching modid in the modInfoMap from the mods.toml file orElseThrow(()->new ModLoadingException(null, ModLoadingStage.CONSTRUCT, "fml.modloading.missingmetadata", null, modId)); - return languageLoader.loadMod(info, modClassLoader, modFile.getScanResult()); + return languageLoader.loadMod(info, modFile.getScanResult(), FMLLoader.getGameLayer()); } catch (ModLoadingException mle) { // exceptions are caught and added to the error list for later handling loadingExceptions.add(mle); diff --git a/src/main/java/net/minecraftforge/fml/ModLoadingContext.java b/fmlcore/src/main/java/net/minecraftforge/fml/ModLoadingContext.java similarity index 80% rename from src/main/java/net/minecraftforge/fml/ModLoadingContext.java rename to fmlcore/src/main/java/net/minecraftforge/fml/ModLoadingContext.java index 2cf73ee4dc..098b065de2 100644 --- a/src/main/java/net/minecraftforge/fml/ModLoadingContext.java +++ b/fmlcore/src/main/java/net/minecraftforge/fml/ModLoadingContext.java @@ -19,14 +19,14 @@ package net.minecraftforge.fml; -import net.minecraftforge.common.ForgeConfigSpec; +import net.minecraftforge.fml.config.IConfigSpec; import net.minecraftforge.fml.config.ModConfig; import java.util.function.Supplier; public class ModLoadingContext { - private static ThreadLocal context = ThreadLocal.withInitial(ModLoadingContext::new); + private static final ThreadLocal context = ThreadLocal.withInitial(ModLoadingContext::new); private Object languageExtension; private ModLoadingStage stage; @@ -50,20 +50,20 @@ public class ModLoadingContext } /** - * Register an {@link ExtensionPoint} with the mod container. + * Register an {@link IExtensionPoint} with the mod container. * @param point The extension point to register * @param extension An extension operator * @param The type signature of the extension operator */ - public void registerExtensionPoint(ExtensionPoint point, Supplier extension) { + public > void registerExtensionPoint(Class> point, Supplier extension) { getActiveContainer().registerExtensionPoint(point, extension); } - public void registerConfig(ModConfig.Type type, ForgeConfigSpec spec) { + public void registerConfig(ModConfig.Type type, IConfigSpec spec) { getActiveContainer().addConfig(new ModConfig(type, spec, getActiveContainer())); } - public void registerConfig(ModConfig.Type type, ForgeConfigSpec spec, String fileName) { + public void registerConfig(ModConfig.Type type, IConfigSpec spec, String fileName) { getActiveContainer().addConfig(new ModConfig(type, spec, getActiveContainer(), fileName)); } diff --git a/src/main/java/net/minecraftforge/fml/ModLoadingException.java b/fmlcore/src/main/java/net/minecraftforge/fml/ModLoadingException.java similarity index 91% rename from src/main/java/net/minecraftforge/fml/ModLoadingException.java rename to fmlcore/src/main/java/net/minecraftforge/fml/ModLoadingException.java index 2aa6400328..71396d2721 100644 --- a/src/main/java/net/minecraftforge/fml/ModLoadingException.java +++ b/fmlcore/src/main/java/net/minecraftforge/fml/ModLoadingException.java @@ -73,7 +73,7 @@ public class ModLoadingException extends RuntimeException } public String formatToString() { - return ForgeI18n.parseMessage(i18nMessage, Streams.concat(Stream.of(modInfo, errorStage, getCause()), context.stream()).toArray()); + return Bindings.getMessageParser().get().parseMessage(i18nMessage, Streams.concat(Stream.of(modInfo, errorStage, getCause()), context.stream()).toArray()); } @Override @@ -85,6 +85,6 @@ public class ModLoadingException extends RuntimeException return modInfo; } public String getCleanMessage() { - return ForgeI18n.stripControlCodes(formatToString()); + return Bindings.getMessageParser().get().stripControlCodes(formatToString()); } } diff --git a/fmlcore/src/main/java/net/minecraftforge/fml/ModLoadingPhase.java b/fmlcore/src/main/java/net/minecraftforge/fml/ModLoadingPhase.java new file mode 100644 index 0000000000..05a0b7a05c --- /dev/null +++ b/fmlcore/src/main/java/net/minecraftforge/fml/ModLoadingPhase.java @@ -0,0 +1,9 @@ +package net.minecraftforge.fml; + +public enum ModLoadingPhase { + ERROR, // Special state for error handling + GATHER, + LOAD, + COMPLETE, + DONE; +} diff --git a/fmlcore/src/main/java/net/minecraftforge/fml/ModLoadingStage.java b/fmlcore/src/main/java/net/minecraftforge/fml/ModLoadingStage.java new file mode 100644 index 0000000000..d95439e708 --- /dev/null +++ b/fmlcore/src/main/java/net/minecraftforge/fml/ModLoadingStage.java @@ -0,0 +1,51 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.fml; + +public enum ModLoadingStage +{ + ERROR, + VALIDATE, + CONSTRUCT, + COMMON_SETUP, + SIDED_SETUP, + ENQUEUE_IMC, + PROCESS_IMC, + COMPLETE, + DONE; + + private final DeferredWorkQueue deferredWorkQueue; + + ModLoadingStage() { + deferredWorkQueue = new DeferredWorkQueue(this); + } + + ModLoadingStage nextState(Throwable exception) { + return exception != null ? ERROR : values()[this.ordinal()+1]; + } + + public ModLoadingStage currentState(Throwable exception) { + return exception != null ? ERROR : this; + } + + public DeferredWorkQueue getDeferredWorkQueue() { + return deferredWorkQueue; + } +} diff --git a/fmlcore/src/main/java/net/minecraftforge/fml/ModLoadingState.java b/fmlcore/src/main/java/net/minecraftforge/fml/ModLoadingState.java new file mode 100644 index 0000000000..d19068f78a --- /dev/null +++ b/fmlcore/src/main/java/net/minecraftforge/fml/ModLoadingState.java @@ -0,0 +1,33 @@ +package net.minecraftforge.fml; + +import net.minecraftforge.eventbus.api.Event; +import net.minecraftforge.fml.event.IModBusEvent; + +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Executor; +import java.util.function.Consumer; +import java.util.function.Function; + +public record ModLoadingState(String name, String previous, Function message, ModLoadingPhase phase, Optional> inlineRunnable, Optional transition) implements IModLoadingState { + @Override + public Optional>> buildTransition(final Executor syncExecutor, final Executor parallelExecutor, Function> preSyncTask, Function> postSyncTask) { + return transition.map(t->t.build(syncExecutor, parallelExecutor, preSyncTask, postSyncTask)); + } + + public static ModLoadingState empty(final String name, final String previous, final ModLoadingPhase phase) { + return new ModLoadingState(name, previous, ml->"", phase, Optional.empty(), Optional.empty()); + } + + public static ModLoadingState withTransition(final String name, final String previous, final ModLoadingPhase phase, IModStateTransition transition) { + return new ModLoadingState(name, previous, ml->"Processing transition "+name, phase, Optional.empty(), Optional.of(transition)); + } + + public static ModLoadingState withTransition(final String name, final String previous, final Function message, final ModLoadingPhase phase, IModStateTransition transition) { + return new ModLoadingState(name, previous, message, phase, Optional.empty(), Optional.of(transition)); + } + public static ModLoadingState withInline(final String name, final String previous, final ModLoadingPhase phase, Consumer inline) { + return new ModLoadingState(name, previous, ml->"Processing work "+name, phase, Optional.of(inline), Optional.empty()); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/fml/ModLoadingWarning.java b/fmlcore/src/main/java/net/minecraftforge/fml/ModLoadingWarning.java similarity index 91% rename from src/main/java/net/minecraftforge/fml/ModLoadingWarning.java rename to fmlcore/src/main/java/net/minecraftforge/fml/ModLoadingWarning.java index a87dfb7158..1a037de6fb 100644 --- a/src/main/java/net/minecraftforge/fml/ModLoadingWarning.java +++ b/fmlcore/src/main/java/net/minecraftforge/fml/ModLoadingWarning.java @@ -55,6 +55,6 @@ public class ModLoadingWarning } public String formatToString() { - return ForgeI18n.parseMessage(i18nMessage, Streams.concat(Stream.of(modInfo, warningStage), context.stream()).toArray()); + return Bindings.getMessageParser().get().parseMessage(i18nMessage, Streams.concat(Stream.of(modInfo, warningStage), context.stream()).toArray()); } } diff --git a/fmlcore/src/main/java/net/minecraftforge/fml/ModStateManager.java b/fmlcore/src/main/java/net/minecraftforge/fml/ModStateManager.java new file mode 100644 index 0000000000..471b1a3b17 --- /dev/null +++ b/fmlcore/src/main/java/net/minecraftforge/fml/ModStateManager.java @@ -0,0 +1,38 @@ +package net.minecraftforge.fml; + +import com.google.common.graph.GraphBuilder; +import com.google.common.graph.MutableGraph; +import cpw.mods.modlauncher.util.ServiceLoaderUtils; +import net.minecraftforge.fml.loading.FMLLoader; +import net.minecraftforge.fml.loading.toposort.TopologicalSort; + +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; + +@SuppressWarnings("UnstableApiUsage") +public class ModStateManager { + static ModStateManager INSTANCE; + private final EnumMap> stateMap; + + public ModStateManager() { + INSTANCE = this; + final var sp = ServiceLoader.load(FMLLoader.getGameLayer(), IModStateProvider.class); + this.stateMap = ServiceLoaderUtils.streamWithErrorHandling(sp, sce->{}) + .map(IModStateProvider::getAllStates) + .mapMulti(Iterable::forEach) + .collect(Collectors.groupingBy(IModLoadingState::phase, ()->new EnumMap<>(ModLoadingPhase.class), Collectors.toUnmodifiableList())); + } + + public List getStates(final ModLoadingPhase phase) { + var nodes = stateMap.get(phase); + var lookup = nodes.stream().collect(Collectors.toMap(IModLoadingState::name, Function.identity())); + + var graph = GraphBuilder.directed().allowsSelfLoops(false).build(); + var dummy = ModLoadingState.empty("", "", phase); + nodes.forEach(graph::addNode); + graph.addNode(dummy); + nodes.forEach(n->graph.putEdge(lookup.getOrDefault(n.previous(), dummy), n)); + return TopologicalSort.topologicalSort(graph, Comparator.comparingInt(nodes::indexOf)).stream().filter(st->st!=dummy).toList(); + } +} diff --git a/src/main/java/net/minecraftforge/fml/ModWorkManager.java b/fmlcore/src/main/java/net/minecraftforge/fml/ModWorkManager.java similarity index 100% rename from src/main/java/net/minecraftforge/fml/ModWorkManager.java rename to fmlcore/src/main/java/net/minecraftforge/fml/ModWorkManager.java diff --git a/src/main/java/net/minecraftforge/fml/OptionalMod.java b/fmlcore/src/main/java/net/minecraftforge/fml/OptionalMod.java similarity index 100% rename from src/main/java/net/minecraftforge/fml/OptionalMod.java rename to fmlcore/src/main/java/net/minecraftforge/fml/OptionalMod.java diff --git a/src/main/java/net/minecraftforge/fml/StartupMessageManager.java b/fmlcore/src/main/java/net/minecraftforge/fml/StartupMessageManager.java similarity index 70% rename from src/main/java/net/minecraftforge/fml/StartupMessageManager.java rename to fmlcore/src/main/java/net/minecraftforge/fml/StartupMessageManager.java index d3b0c6418e..12680cb535 100644 --- a/src/main/java/net/minecraftforge/fml/StartupMessageManager.java +++ b/fmlcore/src/main/java/net/minecraftforge/fml/StartupMessageManager.java @@ -19,8 +19,19 @@ package net.minecraftforge.fml; +import java.util.Optional; +import java.util.function.Consumer; + public class StartupMessageManager { public static void addModMessage(final String message) { net.minecraftforge.fml.loading.progress.StartupMessageManager.addModMessage(message); } + + public static Optional> modLoaderConsumer() { + return net.minecraftforge.fml.loading.progress.StartupMessageManager.modLoaderConsumer(); + } + + public static Optional> mcLoaderConsumer() { + return net.minecraftforge.fml.loading.progress.StartupMessageManager.mcLoaderConsumer(); + } } diff --git a/fmlcore/src/main/java/net/minecraftforge/fml/ThreadSelector.java b/fmlcore/src/main/java/net/minecraftforge/fml/ThreadSelector.java new file mode 100644 index 0000000000..e6380cc108 --- /dev/null +++ b/fmlcore/src/main/java/net/minecraftforge/fml/ThreadSelector.java @@ -0,0 +1,20 @@ +package net.minecraftforge.fml; + +import java.util.concurrent.Executor; +import java.util.function.BinaryOperator; + +public enum ThreadSelector implements BinaryOperator { + SYNC((sync, parallel) -> sync), + PARALLEL((sync, parallel) -> parallel); + + private final BinaryOperator selector; + + ThreadSelector(final BinaryOperator selector) { + this.selector = selector; + } + + @Override + public Executor apply(final Executor sync, final Executor parallel) { + return this.selector.apply(sync, parallel); + } +} diff --git a/src/main/java/net/minecraftforge/fml/VersionChecker.java b/fmlcore/src/main/java/net/minecraftforge/fml/VersionChecker.java similarity index 89% rename from src/main/java/net/minecraftforge/fml/VersionChecker.java rename to fmlcore/src/main/java/net/minecraftforge/fml/VersionChecker.java index f53bd07164..6d8cd7e6f8 100644 --- a/src/main/java/net/minecraftforge/fml/VersionChecker.java +++ b/fmlcore/src/main/java/net/minecraftforge/fml/VersionChecker.java @@ -24,15 +24,16 @@ import com.google.gson.Gson; import net.minecraftforge.fml.loading.FMLConfig; import net.minecraftforge.fml.loading.moddiscovery.ModInfo; import net.minecraftforge.forgespi.language.IModInfo; -import net.minecraftforge.versions.mcp.MCPVersion; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.maven.artifact.versioning.ComparableVersion; + import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLConnection; +import java.net.http.HttpClient; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collections; @@ -41,8 +42,6 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; import static net.minecraftforge.fml.VersionChecker.Status.*; @@ -103,25 +102,7 @@ public class VersionChecker } - public static class CheckResult - { - @Nonnull - public final Status status; - @Nullable - public final ComparableVersion target; - @Nullable - public final Map changes; - @Nullable - public final String url; - - private CheckResult(@Nonnull Status status, @Nullable ComparableVersion target, @Nullable Map changes, @Nullable String url) - { - this.status = status; - this.target = target; - this.changes = changes == null ? Collections.emptyMap() : Collections.unmodifiableMap(changes); - this.url = url; - } - } + public record CheckResult(VersionChecker.Status status, ComparableVersion target, Map changes, String url) {} public static void startVersionCheck() { @@ -175,13 +156,15 @@ public class VersionChecker private void process(IModInfo mod) { +// HttpClient.newBuilder().build(); Status status = PENDING; ComparableVersion target = null; Map changes = null; String display_url = null; try { - URL url = mod.getUpdateURL(); + if (mod.getUpdateURL().isEmpty()) return; + URL url = mod.getUpdateURL().get(); LOGGER.info("[{}] Starting version check at {}", mod.getModId(), url.toString()); InputStream con = openUrlStream(url); @@ -197,7 +180,8 @@ public class VersionChecker Map promos = (Map)json.get("promos"); display_url = (String)json.get("homepage"); - String mcVersion = MCPVersion.getMCVersion(); +// String mcVersion = MCPVersion.getMCVersion(); + var mcVersion = "1.17"; String rec = promos.get(mcVersion + "-recommended"); String lat = promos.get(mcVersion + "-latest"); ComparableVersion current = new ComparableVersion(mod.getVersion().toString()); @@ -278,9 +262,8 @@ public class VersionChecker private static List gatherMods() { List ret = new LinkedList<>(); - for (ModInfo info : ModList.get().getMods()) { - URL url = info.getUpdateURL(); - if (url != null) + for (IModInfo info : ModList.get().getMods()) { + if (info.getUpdateURL().isPresent()) ret.add(info); } return ret; diff --git a/src/main/java/net/minecraftforge/fml/config/ConfigFileTypeHandler.java b/fmlcore/src/main/java/net/minecraftforge/fml/config/ConfigFileTypeHandler.java similarity index 98% rename from src/main/java/net/minecraftforge/fml/config/ConfigFileTypeHandler.java rename to fmlcore/src/main/java/net/minecraftforge/fml/config/ConfigFileTypeHandler.java index 4e81783087..a0ff68d490 100644 --- a/src/main/java/net/minecraftforge/fml/config/ConfigFileTypeHandler.java +++ b/fmlcore/src/main/java/net/minecraftforge/fml/config/ConfigFileTypeHandler.java @@ -157,7 +157,7 @@ public class ConfigFileTypeHandler { } LOGGER.debug(CONFIG, "Config file {} changed, sending notifies", this.modConfig.getFileName()); this.modConfig.getSpec().afterReload(); - this.modConfig.fireEvent(new ModConfig.Reloading(this.modConfig)); + this.modConfig.fireEvent(IConfigEvent.reloading(this.modConfig)); } } } diff --git a/src/main/java/net/minecraftforge/fml/config/ConfigTracker.java b/fmlcore/src/main/java/net/minecraftforge/fml/config/ConfigTracker.java similarity index 69% rename from src/main/java/net/minecraftforge/fml/config/ConfigTracker.java rename to fmlcore/src/main/java/net/minecraftforge/fml/config/ConfigTracker.java index 61426d85b0..78ec0b98d5 100644 --- a/src/main/java/net/minecraftforge/fml/config/ConfigTracker.java +++ b/fmlcore/src/main/java/net/minecraftforge/fml/config/ConfigTracker.java @@ -21,33 +21,14 @@ package net.minecraftforge.fml.config; import com.electronwill.nightconfig.core.CommentedConfig; import com.electronwill.nightconfig.core.file.CommentedFileConfig; -import com.electronwill.nightconfig.toml.TomlFormat; -import it.unimi.dsi.fastutil.bytes.Byte2ByteOpenCustomHashMap; -import net.minecraft.client.Minecraft; -import net.minecraftforge.fml.network.FMLHandshakeMessages; -import net.minecraftforge.fml.network.NetworkEvent; -import org.apache.commons.lang3.tuple.Pair; 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 java.io.ByteArrayInputStream; -import java.io.IOException; -import java.nio.file.Files; import java.nio.file.Path; -import java.util.Collections; -import java.util.EnumMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; +import java.util.*; import java.util.concurrent.ConcurrentHashMap; -import java.util.function.Supplier; -import java.util.stream.Collectors; - -import static cpw.mods.modlauncher.api.LamdbaExceptionUtils.rethrowFunction; public class ConfigTracker { private static final Logger LOGGER = LogManager.getLogger(); @@ -55,7 +36,7 @@ public class ConfigTracker { public static final ConfigTracker INSTANCE = new ConfigTracker(); private final ConcurrentHashMap fileMap; private final EnumMap> configSets; - private ConcurrentHashMap> configsByMod; + private final ConcurrentHashMap> configsByMod; private ConfigTracker() { this.fileMap = new ConcurrentHashMap<>(); @@ -88,22 +69,11 @@ public class ConfigTracker { this.configSets.get(type).forEach(config -> closeConfig(config, configBasePath)); } - public List> syncConfigs(boolean isLocal) { - final Map configData = configSets.get(ModConfig.Type.SERVER).stream().collect(Collectors.toMap(ModConfig::getFileName, mc -> { //TODO: Test cpw's LambdaExceptionUtils on Oracle javac. - try { - return Files.readAllBytes(mc.getFullPath()); - } catch (IOException e) { - throw new RuntimeException(e); - } - })); - return configData.entrySet().stream().map(e->Pair.of("Config "+e.getKey(), new FMLHandshakeMessages.S2CConfigData(e.getKey(), e.getValue()))).collect(Collectors.toList()); - } - private void openConfig(final ModConfig config, final Path configBasePath) { LOGGER.trace(CONFIG, "Loading config file type {} at {} for {}", config.getType(), config.getFileName(), config.getModId()); final CommentedFileConfig configData = config.getHandler().reader(configBasePath).apply(config); config.setConfigData(configData); - config.fireEvent(new ModConfig.Loading(config)); + config.fireEvent(IConfigEvent.loading(config)); config.save(); } @@ -116,21 +86,12 @@ public class ConfigTracker { } } - public void receiveSyncedConfig(final FMLHandshakeMessages.S2CConfigData s2CConfigData, final Supplier contextSupplier) { - if (!Minecraft.getInstance().isLocalServer()) { - Optional.ofNullable(fileMap.get(s2CConfigData.getFileName())).ifPresent(mc-> { - mc.setConfigData(TomlFormat.instance().createParser().parse(new ByteArrayInputStream(s2CConfigData.getBytes()))); - mc.fireEvent(new ModConfig.Reloading(mc)); - }); - } - } - public void loadDefaultServerConfigs() { configSets.get(ModConfig.Type.SERVER).forEach(modConfig -> { final CommentedConfig commentedConfig = CommentedConfig.inMemory(); modConfig.getSpec().correct(commentedConfig); modConfig.setConfigData(commentedConfig); - modConfig.fireEvent(new ModConfig.Loading(modConfig)); + modConfig.fireEvent(IConfigEvent.loading(modConfig)); }); } @@ -138,4 +99,12 @@ public class ConfigTracker { return Optional.ofNullable(configsByMod.getOrDefault(modId, Collections.emptyMap()).getOrDefault(type, null)). map(ModConfig::getFullPath).map(Object::toString).orElse(null); } + + public Map> configSets() { + return configSets; + } + + public ConcurrentHashMap fileMap() { + return fileMap; + } } diff --git a/fmlcore/src/main/java/net/minecraftforge/fml/config/IConfigEvent.java b/fmlcore/src/main/java/net/minecraftforge/fml/config/IConfigEvent.java new file mode 100644 index 0000000000..b53d3dc5ba --- /dev/null +++ b/fmlcore/src/main/java/net/minecraftforge/fml/config/IConfigEvent.java @@ -0,0 +1,24 @@ +package net.minecraftforge.fml.config; + +import net.minecraftforge.eventbus.api.Event; +import net.minecraftforge.fml.Bindings; + +import java.util.function.Function; + +public interface IConfigEvent { + record ConfigConfig(Function loading, Function reloading) {} + ConfigConfig CONFIGCONFIG = Bindings.getConfigConfiguration().get(); + + static IConfigEvent reloading(ModConfig modConfig) { + return CONFIGCONFIG.reloading().apply(modConfig); + } + static IConfigEvent loading(ModConfig modConfig) { + return CONFIGCONFIG.loading().apply(modConfig); + } + ModConfig getConfig(); + + @SuppressWarnings("unchecked") + default T self() { + return (T) this; + } +} diff --git a/fmlcore/src/main/java/net/minecraftforge/fml/config/IConfigSpec.java b/fmlcore/src/main/java/net/minecraftforge/fml/config/IConfigSpec.java new file mode 100644 index 0000000000..0257559122 --- /dev/null +++ b/fmlcore/src/main/java/net/minecraftforge/fml/config/IConfigSpec.java @@ -0,0 +1,21 @@ +package net.minecraftforge.fml.config; + +import com.electronwill.nightconfig.core.CommentedConfig; +import com.electronwill.nightconfig.core.UnmodifiableConfig; + +public interface IConfigSpec> extends UnmodifiableConfig { + @SuppressWarnings("unchecked") + default T self() { + return (T) this; + } + + void acceptConfig(CommentedConfig data); + + boolean isCorrecting(); + + boolean isCorrect(CommentedConfig commentedFileConfig); + + int correct(CommentedConfig commentedFileConfig); + + void afterReload(); +} diff --git a/src/main/java/net/minecraftforge/fml/config/ModConfig.java b/fmlcore/src/main/java/net/minecraftforge/fml/config/ModConfig.java similarity index 77% rename from src/main/java/net/minecraftforge/fml/config/ModConfig.java rename to fmlcore/src/main/java/net/minecraftforge/fml/config/ModConfig.java index d2cbb565b5..f41543bb11 100644 --- a/src/main/java/net/minecraftforge/fml/config/ModConfig.java +++ b/fmlcore/src/main/java/net/minecraftforge/fml/config/ModConfig.java @@ -21,26 +21,25 @@ package net.minecraftforge.fml.config; import com.electronwill.nightconfig.core.CommentedConfig; import com.electronwill.nightconfig.core.file.CommentedFileConfig; -import net.minecraftforge.common.ForgeConfigSpec; -import net.minecraftforge.eventbus.api.Event; +import com.electronwill.nightconfig.toml.TomlFormat; import net.minecraftforge.fml.ModContainer; -import net.minecraftforge.fml.event.lifecycle.IModBusEvent; import net.minecraftforge.fml.loading.StringUtils; +import java.io.ByteArrayInputStream; import java.nio.file.Path; import java.util.concurrent.Callable; public class ModConfig { private final Type type; - private final ForgeConfigSpec spec; + private final IConfigSpec spec; private final String fileName; private final ModContainer container; private final ConfigFileTypeHandler configHandler; private CommentedConfig configData; private Callable saveHandler; - public ModConfig(final Type type, final ForgeConfigSpec spec, final ModContainer container, final String fileName) { + public ModConfig(final Type type, final IConfigSpec spec, final ModContainer container, final String fileName) { this.type = type; this.spec = spec; this.fileName = fileName; @@ -49,7 +48,7 @@ public class ModConfig ConfigTracker.INSTANCE.trackConfig(this); } - public ModConfig(final Type type, final ForgeConfigSpec spec, final ModContainer activeContainer) { + public ModConfig(final Type type, final IConfigSpec spec, final ModContainer activeContainer) { this(type, spec, activeContainer, defaultConfigName(type, activeContainer.getModId())); } @@ -69,8 +68,9 @@ public class ModConfig return configHandler; } - public ForgeConfigSpec getSpec() { - return spec; + @SuppressWarnings("unchecked") + public > IConfigSpec getSpec() { + return (IConfigSpec) spec; } public String getModId() { @@ -83,10 +83,10 @@ public class ModConfig void setConfigData(final CommentedConfig configData) { this.configData = configData; - this.spec.setConfig(this.configData); + this.spec.acceptConfig(this.configData); } - void fireEvent(final ModConfigEvent configEvent) { + void fireEvent(final IConfigEvent configEvent) { this.container.dispatchConfigEvent(configEvent); } @@ -98,6 +98,11 @@ public class ModConfig return ((CommentedFileConfig)this.configData).getNioPath(); } + public void acceptSyncedConfig(byte[] bytes) { + setConfigData(TomlFormat.instance().createParser().parse(new ByteArrayInputStream(bytes))); + fireEvent(IConfigEvent.reloading(this)); + } + public enum Type { /** * Common mod config for configuration that needs to be loaded on both environments. @@ -133,28 +138,4 @@ public class ModConfig return StringUtils.toLowerCase(name()); } } - - public static class ModConfigEvent extends Event implements IModBusEvent { - private final ModConfig config; - - ModConfigEvent(final ModConfig config) { - this.config = config; - } - - public ModConfig getConfig() { - return config; - } - } - - public static class Loading extends ModConfigEvent { - Loading(final ModConfig config) { - super(config); - } - } - - public static class Reloading extends ModConfigEvent { - Reloading(final ModConfig config) { - super(config); - } - } } diff --git a/src/main/java/net/minecraftforge/fml/event/lifecycle/IModBusEvent.java b/fmlcore/src/main/java/net/minecraftforge/fml/event/IModBusEvent.java similarity index 94% rename from src/main/java/net/minecraftforge/fml/event/lifecycle/IModBusEvent.java rename to fmlcore/src/main/java/net/minecraftforge/fml/event/IModBusEvent.java index 79c5ffb1d9..41e0b14d29 100644 --- a/src/main/java/net/minecraftforge/fml/event/lifecycle/IModBusEvent.java +++ b/fmlcore/src/main/java/net/minecraftforge/fml/event/IModBusEvent.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.event.lifecycle; +package net.minecraftforge.fml.event; /** * Marker interface for events dispatched on the ModLifecycle event bus instead of the primary event bus diff --git a/src/main/java/net/minecraftforge/fml/common/CertificateHelper.java b/fmlcore/src/main/java/net/minecraftforge/fml/util/CertificateHelper.java similarity index 98% rename from src/main/java/net/minecraftforge/fml/common/CertificateHelper.java rename to fmlcore/src/main/java/net/minecraftforge/fml/util/CertificateHelper.java index d61a2b0ef0..ae6e296eff 100644 --- a/src/main/java/net/minecraftforge/fml/common/CertificateHelper.java +++ b/fmlcore/src/main/java/net/minecraftforge/fml/util/CertificateHelper.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.common; +package net.minecraftforge.fml.util; import com.google.common.collect.ImmutableList; diff --git a/src/main/java/net/minecraftforge/fml/common/EnhancedRuntimeException.java b/fmlcore/src/main/java/net/minecraftforge/fml/util/EnhancedRuntimeException.java similarity index 98% rename from src/main/java/net/minecraftforge/fml/common/EnhancedRuntimeException.java rename to fmlcore/src/main/java/net/minecraftforge/fml/util/EnhancedRuntimeException.java index fde2747a03..fdee96905d 100644 --- a/src/main/java/net/minecraftforge/fml/common/EnhancedRuntimeException.java +++ b/fmlcore/src/main/java/net/minecraftforge/fml/util/EnhancedRuntimeException.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.common; +package net.minecraftforge.fml.util; import java.io.PrintStream; import java.io.PrintWriter; diff --git a/src/main/java/net/minecraftforge/fml/common/LoaderException.java b/fmlcore/src/main/java/net/minecraftforge/fml/util/LoaderException.java similarity index 91% rename from src/main/java/net/minecraftforge/fml/common/LoaderException.java rename to fmlcore/src/main/java/net/minecraftforge/fml/util/LoaderException.java index 3e31d0fc8e..373e860c64 100644 --- a/src/main/java/net/minecraftforge/fml/common/LoaderException.java +++ b/fmlcore/src/main/java/net/minecraftforge/fml/util/LoaderException.java @@ -17,8 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.common; -import net.minecraftforge.fml.common.EnhancedRuntimeException.WrappedPrintStream; +package net.minecraftforge.fml.util; public class LoaderException extends EnhancedRuntimeException diff --git a/src/main/java/net/minecraftforge/fml/common/LoaderExceptionModCrash.java b/fmlcore/src/main/java/net/minecraftforge/fml/util/LoaderExceptionModCrash.java similarity index 96% rename from src/main/java/net/minecraftforge/fml/common/LoaderExceptionModCrash.java rename to fmlcore/src/main/java/net/minecraftforge/fml/util/LoaderExceptionModCrash.java index 6e866e3024..1031d6e14d 100644 --- a/src/main/java/net/minecraftforge/fml/common/LoaderExceptionModCrash.java +++ b/fmlcore/src/main/java/net/minecraftforge/fml/util/LoaderExceptionModCrash.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.common; +package net.minecraftforge.fml.util; /** * Prevent LoaderException from adding its own stack trace to the wrapped throwable's stack trace. diff --git a/src/main/java/net/minecraftforge/fml/common/ObfuscationReflectionHelper.java b/fmlcore/src/main/java/net/minecraftforge/fml/util/ObfuscationReflectionHelper.java similarity index 93% rename from src/main/java/net/minecraftforge/fml/common/ObfuscationReflectionHelper.java rename to fmlcore/src/main/java/net/minecraftforge/fml/util/ObfuscationReflectionHelper.java index 79b670dafd..52e5dded68 100644 --- a/src/main/java/net/minecraftforge/fml/common/ObfuscationReflectionHelper.java +++ b/fmlcore/src/main/java/net/minecraftforge/fml/util/ObfuscationReflectionHelper.java @@ -17,15 +17,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.common; +package net.minecraftforge.fml.util; import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.StringJoiner; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - import cpw.mods.modlauncher.api.INameMappingService; import net.minecraftforge.fml.loading.FMLLoader; import org.apache.logging.log4j.LogManager; @@ -34,6 +31,8 @@ import org.apache.logging.log4j.Marker; import org.apache.logging.log4j.MarkerManager; import com.google.common.base.Preconditions; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Some reflection helper code. @@ -58,7 +57,7 @@ public class ObfuscationReflectionHelper * @param name The name to try and remap. * @return The remapped name, or the original name if it couldn't be remapped. */ - @Nonnull + @NotNull public static String remapName(INameMappingService.Domain domain, String name) { return FMLLoader.getNameFunction("srg").map(f->f.apply(domain, name)).orElse(name); @@ -72,7 +71,7 @@ public class ObfuscationReflectionHelper * * @param classToAccess The class to find the field on. * @param instance The instance of the {@code classToAccess}. - * @param fieldName The SRG (unmapped) name of the field to find (e.g. "field_181725_a"). + * @param fieldName The SRG (unmapped) name of the field to find (e.g. "f_46443_"). * @param The type of the value. * @param The type of the {@code classToAccess}. * @return The value of the field with the specified name in the {@code classToAccess}. @@ -113,7 +112,7 @@ public class ObfuscationReflectionHelper * @throws UnableToFindFieldException If there was a problem getting the field. * @throws UnableToAccessFieldException If there was a problem setting the value of the field. */ - public static void setPrivateValue(@Nonnull final Class classToAccess, @Nonnull final T instance, @Nullable final E value, @Nonnull final String fieldName) + public static void setPrivateValue(@NotNull final Class classToAccess, @NotNull final T instance, @Nullable final E value, @NotNull final String fieldName) { try { @@ -138,7 +137,7 @@ public class ObfuscationReflectionHelper * Throws an exception if the method is not found. * * @param clazz The class to find the method on. - * @param methodName The SRG (unmapped) name of the method to find (e.g. "func_12820_D"). + * @param methodName The SRG (unmapped) name of the method to find (e.g. "m_5776_"). * @param parameterTypes The parameter types of the method to find. * @return The method with the specified name and parameters in the given class. * @throws NullPointerException If {@code clazz} is null. @@ -147,8 +146,8 @@ public class ObfuscationReflectionHelper * @throws NullPointerException If {@code parameterTypes} is null. * @throws UnableToFindMethodException If the method could not be found. */ - @Nonnull - public static Method findMethod(@Nonnull final Class clazz, @Nonnull final String methodName, @Nonnull final Class... parameterTypes) + @NotNull + public static Method findMethod(@NotNull final Class clazz, @NotNull final String methodName, @NotNull final Class... parameterTypes) { Preconditions.checkNotNull(clazz, "Class to find method on cannot be null."); Preconditions.checkNotNull(methodName, "Name of method to find cannot be null."); @@ -181,8 +180,8 @@ public class ObfuscationReflectionHelper * @throws NullPointerException If {@code parameterTypes} is null. * @throws UnknownConstructorException If the constructor could not be found. */ - @Nonnull - public static Constructor findConstructor(@Nonnull final Class clazz, @Nonnull final Class... parameterTypes) + @NotNull + public static Constructor findConstructor(@NotNull final Class clazz, @NotNull final Class... parameterTypes) { Preconditions.checkNotNull(clazz, "Class to find constructor on cannot be null."); Preconditions.checkNotNull(parameterTypes, "Parameter types of constructor to find cannot be null."); @@ -216,7 +215,7 @@ public class ObfuscationReflectionHelper * Throws an exception if the field is not found. * * @param clazz The class to find the field on. - * @param fieldName The SRG (unmapped) name of the field to find (e.g. "field_181725_a"). + * @param fieldName The SRG (unmapped) name of the field to find (e.g. "f_46443_"). * @param The type. * @return The constructor with the specified parameters in the given class. * @throws NullPointerException If {@code clazz} is null. @@ -224,8 +223,8 @@ public class ObfuscationReflectionHelper * @throws IllegalArgumentException If {@code fieldName} is empty. * @throws UnableToFindFieldException If the field could not be found. */ - @Nonnull - public static Field findField(@Nonnull final Class clazz, @Nonnull final String fieldName) + @NotNull + public static Field findField(@NotNull final Class clazz, @NotNull final String fieldName) { Preconditions.checkNotNull(clazz, "Class to find field on cannot be null."); Preconditions.checkNotNull(fieldName, "Name of field to find cannot be null."); diff --git a/src/main/java/net/minecraftforge/fml/common/thread/EffectiveSide.java b/fmlcore/src/main/java/net/minecraftforge/fml/util/thread/EffectiveSide.java similarity index 95% rename from src/main/java/net/minecraftforge/fml/common/thread/EffectiveSide.java rename to fmlcore/src/main/java/net/minecraftforge/fml/util/thread/EffectiveSide.java index 61fd6b6c60..c4452f99dd 100644 --- a/src/main/java/net/minecraftforge/fml/common/thread/EffectiveSide.java +++ b/fmlcore/src/main/java/net/minecraftforge/fml/util/thread/EffectiveSide.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.common.thread; +package net.minecraftforge.fml.util.thread; import net.minecraftforge.fml.LogicalSide; diff --git a/src/main/java/net/minecraftforge/fml/common/thread/SidedThreadGroup.java b/fmlcore/src/main/java/net/minecraftforge/fml/util/thread/SidedThreadGroup.java similarity index 90% rename from src/main/java/net/minecraftforge/fml/common/thread/SidedThreadGroup.java rename to fmlcore/src/main/java/net/minecraftforge/fml/util/thread/SidedThreadGroup.java index 2cb7c0de2c..af10af460a 100644 --- a/src/main/java/net/minecraftforge/fml/common/thread/SidedThreadGroup.java +++ b/fmlcore/src/main/java/net/minecraftforge/fml/util/thread/SidedThreadGroup.java @@ -17,14 +17,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.common.thread; +package net.minecraftforge.fml.util.thread; import net.minecraftforge.fml.LogicalSide; +import org.jetbrains.annotations.NotNull; import java.util.concurrent.ThreadFactory; -import javax.annotation.Nonnull; - /** * A thread group and factory combination which belongs to a {@link LogicalSide}. */ @@ -49,7 +48,7 @@ public final class SidedThreadGroup extends ThreadGroup implements ThreadFactory } @Override - public Thread newThread(@Nonnull final Runnable runnable) + public Thread newThread(@NotNull final Runnable runnable) { return new Thread(this, runnable); } diff --git a/src/main/java/net/minecraftforge/fml/common/thread/SidedThreadGroups.java b/fmlcore/src/main/java/net/minecraftforge/fml/util/thread/SidedThreadGroups.java similarity index 95% rename from src/main/java/net/minecraftforge/fml/common/thread/SidedThreadGroups.java rename to fmlcore/src/main/java/net/minecraftforge/fml/util/thread/SidedThreadGroups.java index d87374f0c4..1600462238 100644 --- a/src/main/java/net/minecraftforge/fml/common/thread/SidedThreadGroups.java +++ b/fmlcore/src/main/java/net/minecraftforge/fml/util/thread/SidedThreadGroups.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.common.thread; +package net.minecraftforge.fml.util.thread; import net.minecraftforge.fml.LogicalSide; diff --git a/fmlloader/build.gradle b/fmlloader/build.gradle new file mode 100644 index 0000000000..7667c4591f --- /dev/null +++ b/fmlloader/build.gradle @@ -0,0 +1,80 @@ +plugins { + id 'com.github.ben-manes.versions' + id 'org.javamodularity.moduleplugin' version '1.8.3' apply false +} +apply plugin: 'java-library' +apply plugin: 'jacoco' +apply plugin: 'org.javamodularity.moduleplugin' + +dependencyUpdates.rejectVersionIf { isNonStable(it.candidate.version) } +configurations.forEach{ it.transitive = false } + +dependencies { + implementation('net.sf.jopt-simple:jopt-simple:5.0.4') + compileOnly('org.jetbrains:annotations:21.0.0') + api("org.ow2.asm:asm:${ASM_VERSION}") + api("org.ow2.asm:asm-tree:${ASM_VERSION}") + api("org.ow2.asm:asm-commons:${ASM_VERSION}") + api('net.minecraftforge:forgespi:4.0.+') + api('org.apache.logging.log4j:log4j-api:2.14.1') + api('com.google.guava:guava:21.0') + api('com.google.code.gson:gson:2.8.0') + api('org.apache.maven:maven-artifact:3.8.1') + api('org.apache.commons:commons-lang3:3.8.1') + api('com.electronwill.night-config:core:3.6.3') + api('com.electronwill.night-config:toml:3.6.3') + api('cpw.mods:modlauncher:9.0.+') + api('net.minecraftforge:coremods:5.0.+') + implementation("cpw.mods:securejarhandler:${SECUREJARHANDLER_VERSION}") + implementation('org.apache.logging.log4j:log4j-core:2.14.1') + annotationProcessor('org.apache.logging.log4j:log4j-core:2.14.1') + implementation('net.minecraftforge:accesstransformers:8.0.4') + implementation('net.minecrell:terminalconsoleappender:1.2.0') +// implementation('org.jline:jline:3.12.+') + testCompileOnly('org.jetbrains:annotations:21.0.0') + testRuntimeOnly("cpw.mods:bootstraplauncher:${BOOTSTRAPLAUNCHER_VERSION}") +} + +task sourcesJar(type: Jar) { + archiveClassifier = 'sources' + from sourceSets.main.allSource +} + +ext { + MANIFESTS = [ + '/': [ + 'Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), + 'Git-Commit': GIT_INFO.abbreviatedId, + 'Git-Branch': GIT_INFO.branch, + 'Build-Number': "${System.getenv('BUILD_NUMBER')?:0}", + ] as LinkedHashMap, + 'net/minecraftforge/fml/loading/': [ + 'Specification-Title': 'FMLLoader', + 'Specification-Vendor': 'Forge Development LLC', + 'Specification-Version': '1', + 'Implementation-Title': 'FML Loader', + 'Implementation-Version': '1.0', + 'Implementation-Vendor': 'Forge' + ] as LinkedHashMap + ] +} + +jar.doFirst { + MANIFESTS.each { pkg, values -> + manifest.attributes(values, pkg) + } +} + +tasks.withType(JavaCompile) { + options.compilerArgs << '-Xlint:unchecked' +} + +artifacts { + archives jar + archives sourcesJar +} + +publishing.publications.mavenJava(MavenPublication) { + from components.java + artifact sourcesJar +} \ No newline at end of file diff --git a/src/fmllauncher/java/net/minecraftforge/common/asm/CapabilityInjectDefinalize.java b/fmlloader/src/main/java/net/minecraftforge/common/asm/CapabilityInjectDefinalize.java similarity index 100% rename from src/fmllauncher/java/net/minecraftforge/common/asm/CapabilityInjectDefinalize.java rename to fmlloader/src/main/java/net/minecraftforge/common/asm/CapabilityInjectDefinalize.java diff --git a/src/fmllauncher/java/net/minecraftforge/common/asm/ObjectHolderDefinalize.java b/fmlloader/src/main/java/net/minecraftforge/common/asm/ObjectHolderDefinalize.java similarity index 100% rename from src/fmllauncher/java/net/minecraftforge/common/asm/ObjectHolderDefinalize.java rename to fmlloader/src/main/java/net/minecraftforge/common/asm/ObjectHolderDefinalize.java diff --git a/src/fmllauncher/java/net/minecraftforge/common/asm/RuntimeEnumExtender.java b/fmlloader/src/main/java/net/minecraftforge/common/asm/RuntimeEnumExtender.java similarity index 100% rename from src/fmllauncher/java/net/minecraftforge/common/asm/RuntimeEnumExtender.java rename to fmlloader/src/main/java/net/minecraftforge/common/asm/RuntimeEnumExtender.java diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/AdvancedLogMessageAdapter.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/AdvancedLogMessageAdapter.java similarity index 100% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/AdvancedLogMessageAdapter.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/AdvancedLogMessageAdapter.java diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/BackgroundWaiter.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/BackgroundWaiter.java similarity index 100% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/BackgroundWaiter.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/BackgroundWaiter.java diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/EarlyLoadingException.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/EarlyLoadingException.java similarity index 100% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/EarlyLoadingException.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/EarlyLoadingException.java diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/FMLConfig.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/FMLConfig.java similarity index 91% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/FMLConfig.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/FMLConfig.java index 5ce6746424..88cf4758df 100644 --- a/src/fmllauncher/java/net/minecraftforge/fml/loading/FMLConfig.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/FMLConfig.java @@ -21,6 +21,7 @@ package net.minecraftforge.fml.loading; import com.electronwill.nightconfig.core.ConfigSpec; import com.electronwill.nightconfig.core.file.CommentedFileConfig; +import com.electronwill.nightconfig.core.file.FileNotFoundAction; import com.electronwill.nightconfig.core.io.ParsingException; import com.electronwill.nightconfig.core.io.WritingMode; import net.minecraftforge.api.distmarker.Dist; @@ -30,6 +31,7 @@ import org.apache.logging.log4j.Logger; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Arrays; +import java.util.Objects; import java.util.stream.Collectors; import static net.minecraftforge.fml.loading.LogMarkers.CORE; @@ -50,11 +52,11 @@ public class FMLConfig private void loadFrom(final Path configFile) { - configData = CommentedFileConfig.builder(configFile).sync(). - defaultResource("/META-INF/defaultfmlconfig.toml"). - autosave().autoreload(). - writingMode(WritingMode.REPLACE). - build(); + configData = CommentedFileConfig.builder(configFile).sync() + .onFileNotFound(FileNotFoundAction.copyData(Objects.requireNonNull(getClass().getResourceAsStream("/META-INF/defaultfmlconfig.toml")))) + .autosave().autoreload() + .writingMode(WritingMode.REPLACE) + .build(); try { configData.load(); diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/FMLEnvironment.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/FMLEnvironment.java similarity index 100% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/FMLEnvironment.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/FMLEnvironment.java diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/FMLLoader.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/FMLLoader.java similarity index 71% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/FMLLoader.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/FMLLoader.java index de65ff54a4..c439493b27 100644 --- a/src/fmllauncher/java/net/minecraftforge/fml/loading/FMLLoader.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/FMLLoader.java @@ -20,42 +20,25 @@ package net.minecraftforge.fml.loading; import cpw.mods.modlauncher.Launcher; -import cpw.mods.modlauncher.ServiceLoaderStreamUtils; -import cpw.mods.modlauncher.TransformingClassLoader; -import cpw.mods.modlauncher.api.IEnvironment; -import cpw.mods.modlauncher.api.ILaunchHandlerService; -import cpw.mods.modlauncher.api.INameMappingService; -import cpw.mods.modlauncher.api.ITransformationService; -import cpw.mods.modlauncher.api.ITransformingClassLoader; -import cpw.mods.modlauncher.api.IncompatibleEnvironmentException; +import cpw.mods.modlauncher.api.*; import cpw.mods.modlauncher.serviceapi.ILaunchPluginService; +import cpw.mods.modlauncher.util.ServiceLoaderUtils; import net.minecraftforge.accesstransformer.service.AccessTransformerService; import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.fml.loading.moddiscovery.BackgroundScanHandler; -import net.minecraftforge.fml.loading.moddiscovery.ModDiscoverer; -import net.minecraftforge.fml.loading.moddiscovery.ModFile; -import net.minecraftforge.fml.loading.moddiscovery.ModFileInfo; +import net.minecraftforge.fml.loading.moddiscovery.*; import net.minecraftforge.fml.loading.progress.EarlyProgressVisualization; import net.minecraftforge.fml.loading.progress.StartupMessageManager; +import net.minecraftforge.fml.loading.targets.CommonLaunchHandler; import net.minecraftforge.forgespi.Environment; import net.minecraftforge.forgespi.coremod.ICoreModProvider; -import net.minecraftforge.forgespi.locating.IModFile; import org.apache.commons.lang3.tuple.Pair; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import java.net.URL; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; +import java.util.*; import java.util.function.BiFunction; -import java.util.function.Function; -import java.util.function.Predicate; import java.util.stream.Collectors; import static net.minecraftforge.fml.loading.LogMarkers.CORE; @@ -72,21 +55,16 @@ public class FMLLoader private static Dist dist; private static String naming; private static LoadingModList loadingModList; - private static TransformingClassLoader launchClassLoader; private static RuntimeDistCleaner runtimeDistCleaner; private static Path gamePath; - private static Path forgePath; - private static Path[] mcPaths; - static String mcVersion; - private static String mcpVersion; - static String forgeVersion; - private static String forgeGroup; - private static Predicate classLoaderExclusions; + private static VersionInfo versionInfo; private static String launchHandlerName; - private static FMLCommonLaunchHandler commonLaunchHandler; + private static CommonLaunchHandler commonLaunchHandler; public static Runnable progressWindowTick; + private static ModValidator modValidator; public static BackgroundScanHandler backgroundScanHandler; private static boolean production; + private static IModuleLayerManager moduleLayerManager; static void onInitialLoad(IEnvironment environment, Set otherServices) throws IncompatibleEnvironmentException { @@ -98,8 +76,6 @@ public class FMLLoader LOGGER.fatal(CORE,"Found incompatible ModLauncher specification : {}, version {} from {}", modLauncherPackage.getSpecificationVersion(), modLauncherPackage.getImplementationVersion(), modLauncherPackage.getImplementationVendor()); throw new IncompatibleEnvironmentException("Incompatible modlauncher found "+modLauncherPackage.getSpecificationVersion()); } - LOGGER.debug(CORE, "Initializing modjar URL handler"); - URL.setURLStreamHandlerFactory(p->p.equals("modjar") ? new ModJarURLHandler() : null); accessTransformer = (AccessTransformerService) environment.findLaunchPlugin("accesstransformer").orElseThrow(()-> { LOGGER.fatal(CORE,"Access Transformer library is missing, we need this to run"); @@ -131,8 +107,7 @@ public class FMLLoader }); LOGGER.debug(CORE, "Found Runtime Dist Cleaner"); - final ArrayList coreModProviders = new ArrayList<>(); - ServiceLoaderStreamUtils.errorHandlingServiceLoader(ICoreModProvider.class, serviceConfigurationError -> LOGGER.fatal(CORE, "Failed to load a coremod library, expect problems", serviceConfigurationError)).forEach(coreModProviders::add); + var coreModProviders = ServiceLoaderUtils.streamWithErrorHandling(ServiceLoader.load(FMLLoader.class.getModule().getLayer(), ICoreModProvider.class), sce -> LOGGER.fatal(CORE, "Failed to load a coremod library, expect problems", sce)).toList(); if (coreModProviders.isEmpty()) { LOGGER.fatal(CORE, "Found no coremod provider. Cannot run"); @@ -161,7 +136,6 @@ public class FMLLoader LOGGER.fatal(CORE, "Failed to load NightConfig"); throw new IncompatibleEnvironmentException("Missing NightConfig"); } - FixSSL.fixup(); } static void setupLaunchHandler(final IEnvironment environment, final Map arguments) @@ -169,55 +143,48 @@ public class FMLLoader final String launchTarget = environment.getProperty(IEnvironment.Keys.LAUNCHTARGET.get()).orElse("MISSING"); final Optional launchHandler = environment.findLaunchHandler(launchTarget); LOGGER.debug(CORE, "Using {} as launch service", launchTarget); - if (!launchHandler.isPresent()) { + if (launchHandler.isEmpty()) { LOGGER.fatal(CORE,"Missing LaunchHandler {}, cannot continue", launchTarget); - throw new RuntimeException("Missing launch handler"); + throw new RuntimeException("Missing launch handler: " + launchTarget); } - if (!(launchHandler.get() instanceof FMLCommonLaunchHandler)) { + if (!(launchHandler.get() instanceof CommonLaunchHandler)) { LOGGER.fatal(CORE, "Incompatible Launch handler found - type {}, cannot continue", launchHandler.get().getClass().getName()); throw new RuntimeException("Incompatible launch handler found"); } + commonLaunchHandler = (CommonLaunchHandler)launchHandler.get(); launchHandlerName = launchHandler.get().name(); gamePath = environment.getProperty(IEnvironment.Keys.GAMEDIR.get()).orElse(Paths.get(".").toAbsolutePath()); - commonLaunchHandler = (FMLCommonLaunchHandler)launchHandler.get(); naming = commonLaunchHandler.getNaming(); dist = commonLaunchHandler.getDist(); production = commonLaunchHandler.isProduction(); - mcVersion = (String) arguments.get("mcVersion"); - progressWindowTick = EarlyProgressVisualization.INSTANCE.accept(dist, commonLaunchHandler.isData(), mcVersion); + versionInfo = new VersionInfo(arguments); + StartupMessageManager.modLoaderConsumer().ifPresent(c->c.accept("Early Loading!")); accessTransformer.getExtension().accept(Pair.of(naming, "srg")); - mcpVersion = (String) arguments.get("mcpVersion"); - forgeVersion = (String) arguments.get("forgeVersion"); - forgeGroup = (String) arguments.get("forgeGroup"); - - LOGGER.debug(CORE,"Received command line version data : MC Version: '{}' MCP Version: '{}' Forge Version: '{}' Forge group: '{}'", mcVersion, mcpVersion, forgeVersion, forgeGroup); - forgePath = commonLaunchHandler.getForgePath(mcVersion, forgeVersion, forgeGroup); - mcPaths = commonLaunchHandler.getMCPaths(mcVersion, mcpVersion, forgeVersion, forgeGroup); - - commonLaunchHandler.validatePaths(forgePath, mcPaths, forgeVersion, mcVersion, mcpVersion); - commonLaunchHandler.setup(environment, arguments); - classLoaderExclusions = commonLaunchHandler.getPackagePredicate(); - - languageLoadingProvider = new LanguageLoadingProvider(); - languageLoadingProvider.addForgeLanguage(forgePath); + LOGGER.debug(CORE,"Received command line version data : {}", versionInfo); runtimeDistCleaner.getExtension().accept(dist); - progressWindowTick.run(); } - public static Map> beginModScan(final Map arguments) + public static List beginModScan(final Map arguments) { LOGGER.debug(SCAN,"Scanning for Mod Locators"); modDiscoverer = new ModDiscoverer(arguments); - backgroundScanHandler = modDiscoverer.discoverMods(); + modValidator = modDiscoverer.discoverMods(); + var pluginResources = modValidator.getPluginResources(); + return List.of(pluginResources); + } + + public static List completeScan(IModuleLayerManager layerManager) { + progressWindowTick = EarlyProgressVisualization.INSTANCE.accept(dist, commonLaunchHandler.isData(), versionInfo.mcVersion()); + moduleLayerManager = layerManager; + languageLoadingProvider = new LanguageLoadingProvider(); + backgroundScanHandler = modValidator.stage2Validation(); loadingModList = backgroundScanHandler.getLoadingModList(); - commonLaunchHandler.addLibraries(backgroundScanHandler.getModFiles().getOrDefault(IModFile.Type.LIBRARY, Collections.emptyList())); - progressWindowTick.run(); - return loadingModList.getModFiles().stream().map(ModFileInfo::getFile).collect(Collectors.groupingBy(ModFile::getType)); + return List.of(modValidator.getModResources()); } public static ICoreModProvider getCoreModProvider() { @@ -233,6 +200,10 @@ public class FMLLoader return modDiscoverer; } + public static CommonLaunchHandler getLaunchHandler() { + return commonLaunchHandler; + } + public static void addAccessTransformer(Path atPath, ModFile modName) { LOGGER.debug(SCAN, "Adding Access Transformer in {}", modName.getFilePath()); @@ -244,9 +215,8 @@ public class FMLLoader return dist; } - public static void beforeStart(ITransformingClassLoader launchClassLoader) + public static void beforeStart(ClassLoader launchClassLoader) { - FMLLoader.launchClassLoader = (TransformingClassLoader) launchClassLoader.getInstance(); StartupMessageManager.modLoaderConsumer().ifPresent(c->c.accept("Launching minecraft")); progressWindowTick.run(); } @@ -256,28 +226,11 @@ public class FMLLoader return loadingModList; } - public static TransformingClassLoader getLaunchClassLoader() - { - return launchClassLoader; - } - public static Path getGamePath() { return gamePath; } - public static Path getForgePath() { - return forgePath; - } - - public static Path[] getMCPaths() { - return mcPaths; - } - - public static Predicate getClassLoaderExclusions() { - return classLoaderExclusions; - } - public static String getNaming() { return naming; } @@ -286,10 +239,6 @@ public class FMLLoader return Launcher.INSTANCE.environment().findNameMapping(naming); } - public static String getMcpVersion() { - return mcpVersion; - } - public static String getLauncherInfo() { return Launcher.INSTANCE.environment().getProperty(IEnvironment.Keys.MLIMPL_VERSION.get()).orElse("MISSING"); } @@ -307,6 +256,14 @@ public class FMLLoader } public static boolean isSecureJarEnabled() { - return Launcher.INSTANCE.environment().getProperty(IEnvironment.Keys.SECURED_JARS_ENABLED.get()).orElse(false); + return true; + } + + public static ModuleLayer getGameLayer() { + return moduleLayerManager.getLayer(IModuleLayerManager.Layer.GAME).orElseThrow(); + } + + public static VersionInfo versionInfo() { + return versionInfo; } } diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/FMLPaths.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/FMLPaths.java similarity index 100% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/FMLPaths.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/FMLPaths.java diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/FMLServiceProvider.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/FMLServiceProvider.java similarity index 83% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/FMLServiceProvider.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/FMLServiceProvider.java index 0f260650a2..7c4dc9fb16 100644 --- a/src/fmllauncher/java/net/minecraftforge/fml/loading/FMLServiceProvider.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/FMLServiceProvider.java @@ -19,10 +19,8 @@ package net.minecraftforge.fml.loading; -import cpw.mods.modlauncher.api.IEnvironment; -import cpw.mods.modlauncher.api.ITransformationService; -import cpw.mods.modlauncher.api.ITransformer; -import cpw.mods.modlauncher.api.IncompatibleEnvironmentException; +import cpw.mods.jarhandling.SecureJar; +import cpw.mods.modlauncher.api.*; import joptsimple.ArgumentAcceptingOptionSpec; import joptsimple.OptionSpecBuilder; import net.minecraftforge.fml.loading.moddiscovery.ModFile; @@ -30,14 +28,16 @@ import net.minecraftforge.forgespi.Environment; import net.minecraftforge.forgespi.locating.IModFile; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.jetbrains.annotations.NotNull; -import javax.annotation.Nonnull; import java.nio.file.Path; import java.util.AbstractMap; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.function.BiFunction; @@ -47,7 +47,6 @@ import static net.minecraftforge.fml.loading.LogMarkers.CORE; public class FMLServiceProvider implements ITransformationService { - private static final Logger LOGGER = LogManager.getLogger(); private ArgumentAcceptingOptionSpec modsOption; private ArgumentAcceptingOptionSpec modListsOption; @@ -67,6 +66,12 @@ public class FMLServiceProvider implements ITransformationService private String targetForgeGroup; private Map arguments; + public FMLServiceProvider() + { + final String markerselection = System.getProperty("forge.logging.markers", ""); + Arrays.stream(markerselection.split(",")).forEach(marker -> System.setProperty("forge.logging.marker." + marker.toLowerCase(Locale.ROOT), "ACCEPT")); + } + @Override public String name() { @@ -97,28 +102,22 @@ public class FMLServiceProvider implements ITransformationService } @Override - public void beginScanning(final IEnvironment environment) { - throw new IllegalStateException("WHY ARE YOU HERE??????"); + public List beginScanning(final IEnvironment environment) { + LOGGER.debug(CORE,"Initiating mod scan"); + return FMLLoader.beginModScan(arguments); } @Override - public List> runScan(final IEnvironment environment) { - LOGGER.debug(CORE,"Initiating mod scan"); - final Map> foundFiles = FMLLoader.beginModScan(arguments); - return foundFiles - .values() - .stream() - .flatMap(Collection::stream) - .map(modFile -> new AbstractMap.SimpleImmutableEntry<>(modFile.getFileName(), modFile.getFilePath())) - .collect(Collectors.toList()); + public List completeScan(final IModuleLayerManager layerManager) { + return FMLLoader.completeScan(layerManager); } @Override public void onLoad(IEnvironment environment, Set otherServices) throws IncompatibleEnvironmentException { - LOGGER.debug("Injecting tracing printstreams for STDOUT/STDERR."); - System.setOut(new TracingPrintStream(LogManager.getLogger("STDOUT"), System.out)); - System.setErr(new TracingPrintStream(LogManager.getLogger("STDERR"), System.err)); +// LOGGER.debug("Injecting tracing printstreams for STDOUT/STDERR."); +// System.setOut(new TracingPrintStream(LogManager.getLogger("STDOUT"), System.out)); +// System.setErr(new TracingPrintStream(LogManager.getLogger("STDERR"), System.err)); FMLLoader.onInitialLoad(environment, otherServices); } @@ -148,9 +147,8 @@ public class FMLServiceProvider implements ITransformationService targetMcpMappings = option.value(mappingsOption); } - @Nonnull @Override - public List transformers() + public @NotNull List transformers() { LOGGER.debug(CORE, "Loading coremod transformers"); return new ArrayList<>(FMLLoader.getCoreModProvider().getCoreModTransformers()); diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/FileUtils.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/FileUtils.java similarity index 100% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/FileUtils.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/FileUtils.java diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/JarVersionLookupHandler.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/JarVersionLookupHandler.java similarity index 100% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/JarVersionLookupHandler.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/JarVersionLookupHandler.java diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/LanguageLoadingProvider.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/LanguageLoadingProvider.java similarity index 84% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/LanguageLoadingProvider.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/LanguageLoadingProvider.java index 1ea6c5c6d5..4992a0c172 100644 --- a/src/fmllauncher/java/net/minecraftforge/fml/loading/LanguageLoadingProvider.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/LanguageLoadingProvider.java @@ -19,7 +19,9 @@ package net.minecraftforge.fml.loading; -import cpw.mods.modlauncher.ServiceLoaderStreamUtils; +import cpw.mods.modlauncher.Launcher; +import cpw.mods.modlauncher.api.IModuleLayerManager; +import cpw.mods.modlauncher.util.ServiceLoaderUtils; import net.minecraftforge.fml.loading.progress.StartupMessageManager; import net.minecraftforge.forgespi.language.IModLanguageProvider; import net.minecraftforge.fml.loading.moddiscovery.ExplodedDirectoryLocator; @@ -49,13 +51,12 @@ import java.util.function.Consumer; import java.util.function.Function; import java.util.stream.Stream; -import static cpw.mods.modlauncher.api.LamdbaExceptionUtils.rethrowFunction; import static net.minecraftforge.fml.loading.LogMarkers.CORE; +import static net.minecraftforge.fml.loading.LogMarkers.LOADING; public class LanguageLoadingProvider { private static final Logger LOGGER = LogManager.getLogger(); - private final LanguageClassLoader languageClassLoader; private final List languageProviders = new ArrayList<>(); private final ServiceLoader serviceLoader; private final Map languageProviderMap = new HashMap<>(); @@ -71,7 +72,6 @@ public class LanguageLoadingProvider } private static class ModLanguageWrapper { - private final IModLanguageProvider modLanguageProvider; private final ArtifactVersion version; @@ -92,26 +92,14 @@ public class LanguageLoadingProvider } - private static class LanguageClassLoader extends URLClassLoader - { - public LanguageClassLoader() { - super(new URL[0]); - } - @Override - public void addURL(final URL url) { - LOGGER.debug(CORE, "Adding {} to languageloader classloader", url); - super.addURL(url); - } - - } LanguageLoadingProvider() { - languageClassLoader = new LanguageClassLoader(); - serviceLoader = ServiceLoader.load(IModLanguageProvider.class, languageClassLoader); + var sl = Launcher.INSTANCE.environment().findModuleLayerManager().flatMap(lm->lm.getLayer(IModuleLayerManager.Layer.PLUGIN)).orElseThrow(); + serviceLoader = ServiceLoader.load(sl, IModLanguageProvider.class); loadLanguageProviders(); } private void loadLanguageProviders() { - LOGGER.debug(CORE, "Found {} language providers", ServiceLoaderStreamUtils.toList(serviceLoader).size()); + LOGGER.debug(CORE, "Found {} language providers", ServiceLoaderUtils.streamServiceLoader(()->serviceLoader, sce->LOGGER.fatal("Problem with language loaders")).count()); serviceLoader.forEach(languageProviders::add); languageProviders.forEach(lp -> { @@ -122,7 +110,7 @@ public class LanguageLoadingProvider throw new RuntimeException("Huh?", e); } Optional implementationVersion = JarVersionLookupHandler.getImplementationVersion(lp.getClass()); - String impl = implementationVersion.orElse(Files.isDirectory(lpPath) ? FMLLoader.forgeVersion.split("\\.")[0] : null); + String impl = implementationVersion.orElse(Files.isDirectory(lpPath) ? FMLLoader.versionInfo().forgeVersion().split("\\.")[0] : null); if (impl == null) { LOGGER.fatal(CORE, "Found unversioned language provider {}", lp.name()); throw new RuntimeException("Failed to find implementation version for language provider "+ lp.name()); @@ -147,7 +135,7 @@ public class LanguageLoadingProvider private void addLanguagePaths(final Stream langPaths) { languageProviders.clear(); languageProviderMap.clear(); - langPaths.peek(languagePaths::add).map(Path::toFile).map(File::toURI).map(rethrowFunction(URI::toURL)).forEach(languageClassLoader::addURL); +// langPaths.peek(languagePaths::add).map(Path::toFile).map(File::toURI).map(rethrowFunction(URI::toURL)).forEach(languageClassLoader::addURL); } public void addAdditionalLanguages(List modFiles) @@ -167,11 +155,11 @@ public class LanguageLoadingProvider final String languageFileName = mf.getLocator() instanceof ExplodedDirectoryLocator ? "in-development" : mf.getFileName(); final ModLanguageWrapper mlw = languageProviderMap.get(modLoader); if (mlw == null) { - LOGGER.error("Missing language {} version {} wanted by {}", modLoader, modLoaderVersion, languageFileName); + LOGGER.error(LOADING,"Missing language {} version {} wanted by {}", modLoader, modLoaderVersion, languageFileName); throw new EarlyLoadingException("Missing language "+modLoader, null, Collections.singletonList(new EarlyLoadingException.ExceptionData("fml.language.missingversion", modLoader, modLoaderVersion, languageFileName, "null"))); } if (!VersionSupportMatrix.testVersionSupportMatrix(modLoaderVersion, modLoader, "languageloader", (llid, range) -> range.containsVersion(mlw.getVersion()))) { - LOGGER.error("Missing language {} version {} wanted by {}, found {}", modLoader, modLoaderVersion, languageFileName, mlw.getVersion()); + LOGGER.error(LOADING,"Missing language {} version {} wanted by {}, found {}", modLoader, modLoaderVersion, languageFileName, mlw.getVersion()); throw new EarlyLoadingException("Missing language "+ modLoader + " matching range "+modLoaderVersion + " found "+mlw.getVersion(), null, Collections.singletonList(new EarlyLoadingException.ExceptionData("fml.language.missingversion", modLoader, modLoaderVersion, languageFileName, mlw.getVersion()))); } diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/LauncherVersion.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/LauncherVersion.java similarity index 100% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/LauncherVersion.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/LauncherVersion.java diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/LibraryFinder.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/LibraryFinder.java similarity index 82% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/LibraryFinder.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/LibraryFinder.java index faa9d45665..8332ed38cf 100644 --- a/src/fmllauncher/java/net/minecraftforge/fml/loading/LibraryFinder.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/LibraryFinder.java @@ -36,11 +36,10 @@ public class LibraryFinder { private static Path libsPath; static Path findLibsPath() { if (libsPath == null) { - final Path asm = findJarPathFor("org/objectweb/asm/Opcodes.class", "asm"); - // go up SIX parents to find the libs dir - final Path libs = asm.getParent().getParent().getParent().getParent().getParent().getParent(); - LOGGER.debug(CORE, "Found probable library path {}", libs); - libsPath = libs; + libsPath = Path.of(System.getProperty("libraryDirectory","crazysnowmannonsense/cheezwhizz")); + if (!Files.isDirectory(libsPath)) { + throw new IllegalStateException("Missing libraryDirectory system property, cannot continue"); + } } return libsPath; } @@ -87,4 +86,14 @@ public class LibraryFinder { LOGGER.debug(CORE,"Forge patches at {} is {}", patchedBinariesPath.toString(), pathStatus(patchedBinariesPath)); return new Path[] { patchedBinariesPath, mcExtrasPath, srgMcPath }; } + + public static Path findPathForMaven(final String group, final String artifact, final String extension, final String classifier, final String version) { + return findLibsPath().resolve(MavenCoordinateResolver.get(group, artifact, extension, classifier, version)); + } + public static Path findPathForMaven(final String maven) { + return findLibsPath().resolve(MavenCoordinateResolver.get(maven)); + } + public static Path getFMLCorePath() { + return findLibsPath().resolve(MavenCoordinateResolver.get("net.minecraftforge:fmlcore:1.0")); + } } diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/LoadingModList.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/LoadingModList.java similarity index 98% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/LoadingModList.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/LoadingModList.java index 831d111829..7c5247cbcd 100644 --- a/src/fmllauncher/java/net/minecraftforge/fml/loading/LoadingModList.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/LoadingModList.java @@ -41,8 +41,6 @@ public class LoadingModList private final List modFiles; private final List sortedList; private final Map fileById; - @SuppressWarnings("unused") - private BackgroundScanHandler scanner; private final List preLoadErrors; private List brokenFiles; @@ -94,7 +92,6 @@ public class LoadingModList public void addForScanning(BackgroundScanHandler backgroundScanHandler) { - this.scanner = backgroundScanHandler; backgroundScanHandler.setLoadingModList(this); modFiles.stream() .map(ModFileInfo::getFile) diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/LogMarkers.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/LogMarkers.java similarity index 92% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/LogMarkers.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/LogMarkers.java index d9d8ed5f4b..00f015fbcb 100644 --- a/src/fmllauncher/java/net/minecraftforge/fml/loading/LogMarkers.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/LogMarkers.java @@ -27,5 +27,4 @@ public class LogMarkers { public static final Marker LOADING = MarkerManager.getMarker("LOADING"); public static final Marker SCAN = MarkerManager.getMarker("SCAN"); public static final Marker SPLASH = MarkerManager.getMarker("SPLASH"); - public static final Marker FORGEMOD = MarkerManager.getMarker("FORGEMOD").addParents(LOADING); } diff --git a/src/userdev/java/net/minecraftforge/userdev/MCPNamingService.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/MCPNamingService.java similarity index 71% rename from src/userdev/java/net/minecraftforge/userdev/MCPNamingService.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/MCPNamingService.java index 7f55f177f3..1279980b10 100644 --- a/src/userdev/java/net/minecraftforge/userdev/MCPNamingService.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/MCPNamingService.java @@ -1,23 +1,4 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.userdev; +package net.minecraftforge.fml.loading; import cpw.mods.modlauncher.api.INameMappingService; import org.apache.commons.lang3.tuple.Pair; @@ -47,7 +28,7 @@ public class MCPNamingService implements INameMappingService { @Override public String mappingVersion() { - return "1234"; + return "1234"; //TODO: Minecraft Version? } @Override @@ -92,19 +73,14 @@ public class MCPNamingService implements INameMappingService { return fields.getOrDefault(origin, origin); } - - private static void loadMappings(final String mappingFileName, BiConsumer mapStore) - { - URL path = ClassLoader.getSystemResource(mappingFileName); //We EXPLICITLY go throught the SystemClassLoader here because this is dev-time only. And will be on the root classpath. + private static void loadMappings(final String mappingFileName, BiConsumer mapStore) { + URL path = ClassLoader.getSystemResource(mappingFileName); //We EXPLICITLY go through the SystemClassLoader here because this is dev-time only. And will be on the root classpath. if (path == null) return; - try (BufferedReader reader = new BufferedReader(new InputStreamReader(path.openStream()))) - { + try (BufferedReader reader = new BufferedReader(new InputStreamReader(path.openStream()))) { reader.lines().skip(1).map(e -> e.split(",")).forEach(e -> mapStore.accept(e[0], e[1])); - } - catch (IOException e1) - { + } catch (IOException e1) { LOGGER.error(CORE, "Error reading mappings", e1); } } diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/MavenCoordinateResolver.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/MavenCoordinateResolver.java similarity index 100% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/MavenCoordinateResolver.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/MavenCoordinateResolver.java diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/ModDirTransformerDiscoverer.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/ModDirTransformerDiscoverer.java similarity index 76% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/ModDirTransformerDiscoverer.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/ModDirTransformerDiscoverer.java index bc6d0a7871..08a4c4241c 100644 --- a/src/fmllauncher/java/net/minecraftforge/fml/loading/ModDirTransformerDiscoverer.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/ModDirTransformerDiscoverer.java @@ -20,6 +20,7 @@ package net.minecraftforge.fml.loading; import cpw.mods.modlauncher.api.LamdbaExceptionUtils; +import cpw.mods.modlauncher.api.NamedPath; import cpw.mods.modlauncher.serviceapi.ITransformerDiscoveryService; import org.apache.logging.log4j.LogManager; @@ -29,40 +30,30 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; import java.util.List; +import java.util.stream.Stream; import java.util.zip.ZipFile; public class ModDirTransformerDiscoverer implements ITransformerDiscoveryService { @Override - public List candidates(final Path gameDirectory) { + public List candidates(final Path gameDirectory) { ModDirTransformerDiscoverer.scan(gameDirectory); - return ModDirTransformerDiscoverer.transformers; + return List.copyOf(found); } - private static List transformers = new ArrayList<>(); - private static List locators = new ArrayList<>(); + private final static List found = new ArrayList<>(); public static List allExcluded() { - ArrayList paths = new ArrayList<>(); - paths.addAll(transformers); - paths.addAll(locators); - return paths; - } - - public static List getExtraLocators() { - return locators; + return found.stream().map(np->np.paths()[0]).toList(); } private static void scan(final Path gameDirectory) { final Path modsDir = gameDirectory.resolve(FMLPaths.MODSDIR.relative()).toAbsolutePath().normalize(); - transformers = new ArrayList<>(); - locators = new ArrayList<>(); if (!Files.exists(modsDir)) { // Skip if the mods dir doesn't exist yet. return; } - try { - Files.createDirectories(modsDir); - Files.walk(modsDir, 1).forEach(ModDirTransformerDiscoverer::visitFile); + try (var walk = Files.walk(modsDir, 1)){ + walk.forEach(ModDirTransformerDiscoverer::visitFile); } catch (IOException | IllegalStateException ioe) { LogManager.getLogger().error("Error during early discovery", ioe); } @@ -74,9 +65,9 @@ public class ModDirTransformerDiscoverer implements ITransformerDiscoveryService if (LamdbaExceptionUtils.uncheck(() -> Files.size(path)) == 0) return; try (ZipFile zf = new ZipFile(new File(path.toUri()))) { if (zf.getEntry("META-INF/services/cpw.mods.modlauncher.api.ITransformationService") != null) { - transformers.add(path); + found.add(new NamedPath(zf.getName(), path)); } else if (zf.getEntry("META-INF/services/net.minecraftforge.forgespi.locating.IModLocator") != null) { - locators.add(path); + found.add(new NamedPath(zf.getName(), path)); } } catch (IOException ioe) { LogManager.getLogger().error("Zip Error when loading jar file {}", path, ioe); diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/ModJarURLHandler.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/ModJarURLHandler.java similarity index 88% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/ModJarURLHandler.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/ModJarURLHandler.java index bde21bcbce..0e96c8b24f 100644 --- a/src/fmllauncher/java/net/minecraftforge/fml/loading/ModJarURLHandler.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/ModJarURLHandler.java @@ -70,13 +70,13 @@ public class ModJarURLHandler extends URLStreamHandler @Override public void connect() { - if (resource == null) { - modid = url.getHost(); - // trim first char - modpath = url.getPath().substring(1); - resource = FMLLoader.getLoadingModList().getModFileById(modid).getFile().findResource(modpath); - manifest = FMLLoader.getLoadingModList().getModFileById(modid).getManifest(); - } +// if (resource == null) { +// modid = url.getHost(); +// // trim first char +// modpath = url.getPath().substring(1); +// resource = FMLLoader.getLoadingModList().getModFileById(modid).getFile().findResource(modpath); +// manifest = FMLLoader.getLoadingModList().getModFileById(modid).getManifest(); +// } } @Override diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/ModSorter.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/ModSorter.java similarity index 64% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/ModSorter.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/ModSorter.java index aa749dd98d..87d1856b29 100644 --- a/src/fmllauncher/java/net/minecraftforge/fml/loading/ModSorter.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/ModSorter.java @@ -42,6 +42,7 @@ import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; +import static java.util.stream.Collectors.*; import static net.minecraftforge.fml.loading.LogMarkers.LOADING; public class ModSorter @@ -57,22 +58,20 @@ public class ModSorter this.modFiles = modFiles; } - public static LoadingModList sort(List mods) + public static LoadingModList sort(List mods, final List errors) { final ModSorter ms = new ModSorter(mods); try { ms.buildUniqueList(); } catch (EarlyLoadingException e) { // We cannot build any list with duped mods. We have to abort immediately and report it - return LoadingModList.of(ms.forgeAndMC, ms.forgeAndMC.stream().map(mf->(ModInfo)mf.getModInfos().get(0)).collect(Collectors.toList()), e); + return LoadingModList.of(ms.forgeAndMC, ms.forgeAndMC.stream().map(mf->(ModInfo)mf.getModInfos().get(0)).collect(toList()), e); } - // try and locate languages and validate dependencies - List missingLangs = ms.findLanguages(); - List missingDeps = ms.verifyDependencyVersions(); - final List failedList = Stream.concat(missingLangs.stream(), missingDeps.stream()).collect(Collectors.toList()); + // try and validate dependencies + final List failedList = Stream.concat(ms.verifyDependencyVersions().stream(), errors.stream()).toList(); // if we miss one or the other, we abort now if (!failedList.isEmpty()) { - return LoadingModList.of(ms.forgeAndMC, ms.forgeAndMC.stream().map(mf->(ModInfo)mf.getModInfos().get(0)).collect(Collectors.toList()), new EarlyLoadingException("failure to validate mod list", null, failedList)); + return LoadingModList.of(ms.forgeAndMC, ms.forgeAndMC.stream().map(mf->(ModInfo)mf.getModInfos().get(0)).collect(toList()), new EarlyLoadingException("failure to validate mod list", null, failedList)); } else { // Otherwise, lets try and sort the modlist and proceed EarlyLoadingException earlyLoadingException = null; @@ -85,35 +84,21 @@ public class ModSorter } } - private List findLanguages() { - List errorData = new ArrayList<>(); - modFiles.forEach(modFile -> { - try { - modFile.identifyLanguage(); - } catch (EarlyLoadingException e) { - errorData.addAll(e.getAllData()); - } - }); - return errorData; - } - @SuppressWarnings("UnstableApiUsage") private void sort() { // lambdas are identity based, so sorting them is impossible unless you hold reference to them final MutableGraph graph = GraphBuilder.directed().build(); AtomicInteger counter = new AtomicInteger(); - Map infos = modFiles - .stream() + Map infos = modFiles.stream() .map(ModFile::getModFileInfo) - .collect(Collectors.toMap(Function.identity(), e -> counter.incrementAndGet())); + .collect(toMap(Function.identity(), e -> counter.incrementAndGet())); infos.keySet().forEach(i -> graph.addNode((ModFileInfo) i)); - modFiles - .stream() + modFiles.stream() .map(ModFile::getModInfos) - .flatMap(Collection::stream) + .mapMulti(Iterable::forEach) .map(IModInfo::getDependencies) - .flatMap(Collection::stream) + .mapMulti(Iterable::forEach) .forEach(dep -> addDependency(graph, dep)); final List sorted; @@ -124,33 +109,27 @@ public class ModSorter catch (CyclePresentException e) { Set> cycles = e.getCycles(); - LOGGER.error(LOADING, () -> ((StringBuilderFormattable) (buffer -> { - buffer.append("Mod Sorting failed.\n"); - buffer.append("Detected Cycles: "); - buffer.append(cycles); - buffer.append('\n'); - }))); - List dataList = cycles.stream() - .map(Set::stream) - .map(stream -> stream - .flatMap(modFileInfo -> modFileInfo.getMods() - .stream() - .map(IModInfo::getModId)) - .collect(Collectors.toList())) + LOGGER.error(LOADING, () -> new AdvancedLogMessageAdapter(buffer -> + buffer.append("Mod Sorting failed.\n") + .append("Detected Cycles: ") + .append(cycles) + .append('\n'))); + var dataList = cycles.stream() + .mapMulti(Iterable::forEach) + .mapMulti((mf,c)->mf.getMods().forEach(c)) + .map(IModInfo::getModId) .map(list -> new ExceptionData("fml.modloading.cycle", list)) - .collect(Collectors.toList()); + .toList(); throw new EarlyLoadingException("Sorting error", e, dataList); } - this.sortedList = sorted - .stream() + this.sortedList = sorted.stream() .map(ModFileInfo::getMods) - .flatMap(Collection::stream) + .mapMulti(Iterable::forEach) .map(ModInfo.class::cast) - .collect(Collectors.toList()); - this.modFiles = sorted - .stream() + .collect(toList()); + this.modFiles = sorted.stream() .map(ModFileInfo::getFile) - .collect(Collectors.toList()); + .collect(toList()); } @SuppressWarnings("UnstableApiUsage") @@ -164,63 +143,55 @@ public class ModSorter if (self == target) return; // in case a jar has two mods that have dependencies between switch (dep.getOrdering()) { - case BEFORE: - topoGraph.putEdge(self, target); - break; - case AFTER: - topoGraph.putEdge(target, self); - break; - case NONE: - break; + case BEFORE -> topoGraph.putEdge(self, target); + case AFTER -> topoGraph.putEdge(target, self); } } private void buildUniqueList() { // Collect mod files by first modid in the file. This will be used for deduping purposes - final Map> modFilesByFirstId = modFiles - .stream() - .collect(Collectors.groupingBy(mf -> mf.getModInfos().get(0).getModId())); + final Map> modFilesByFirstId = modFiles.stream() + .collect(groupingBy(mf -> mf.getModInfos().get(0).getModId())); // Capture forge and MC here, so we can keep them for later forgeAndMC = new ArrayList<>(); - forgeAndMC.add((ModFile)modFilesByFirstId.get("minecraft").get(0)); - forgeAndMC.add((ModFile)modFilesByFirstId.get("forge").get(0)); + var mc = modFilesByFirstId.get("minecraft"); + if (mc != null && !mc.isEmpty()) + forgeAndMC.add((ModFile) mc.get(0)); + else + throw new IllegalStateException("Failed to find minecraft somehow?"); // Select the newest by artifact version sorting of non-unique files thus identified this.modFiles = modFilesByFirstId.entrySet().stream() .map(this::selectNewestModInfo) .map(Map.Entry::getValue) .map(ModFile.class::cast) - .collect(Collectors.toList()); + .collect(toList()); // Transform to the full mod id list final Map> modIds = modFiles.stream() .map(ModFile::getModInfos) .flatMap(Collection::stream) .map(ModInfo.class::cast) - .collect(Collectors.groupingBy(IModInfo::getModId)); + .collect(groupingBy(IModInfo::getModId)); // Its theoretically possible that some mod has somehow moved an id to a secondary place, thus causing a dupe. // We can't handle this - final List>> dupedMods = modIds - .entrySet() - .stream() - .filter(e -> e.getValue().size() > 1) - .collect(Collectors.toList()); + final List dupedMods = modIds.values().stream() + .filter(modInfos -> modInfos.size() > 1) + .map(modInfos -> modInfos.get(0)) + .toList(); if (!dupedMods.isEmpty()) { - final List duplicateModErrors = dupedMods - .stream() - .map(dm -> new EarlyLoadingException.ExceptionData("fml.modloading.dupedmod", dm.getValue().get(0), Objects.toString(dm.getValue().get(0)))) - .collect(Collectors.toList()); + final List duplicateModErrors = dupedMods.stream() + .map(dm -> new EarlyLoadingException.ExceptionData("fml.modloading.dupedmod", + dm, Objects.toString(dm))).toList(); throw new EarlyLoadingException("Duplicate mods found", null, duplicateModErrors); } - modIdNameLookup = modIds - .entrySet() - .stream() - .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().get(0))); + modIdNameLookup = modIds.entrySet().stream() + .collect(toMap(Map.Entry::getKey, e -> e.getValue().get(0))); } private Map.Entry selectNewestModInfo(Map.Entry> fullList) { @@ -230,46 +201,40 @@ public class ModSorter modInfoList.sort(Comparator.comparing(mf -> mf.getModInfos().get(0).getVersion()).reversed()); LOGGER.debug("Selected file {} for modid {} with version {}", modInfoList.get(0).getFileName(), fullList.getKey(), modInfoList.get(0).getModInfos().get(0).getVersion()); } - return new AbstractMap.SimpleImmutableEntry<>(fullList.getKey(), modInfoList.get(0)); + return Map.entry(fullList.getKey(), modInfoList.get(0)); } private List verifyDependencyVersions() { - final Map modVersions = modFiles - .stream() + final var modVersions = modFiles.stream() .map(ModFile::getModInfos) - .flatMap(Collection::stream) - .collect(Collectors.toMap(IModInfo::getModId, IModInfo::getVersion)); + .mapMulti(Iterable::forEach) + .collect(toMap(IModInfo::getModId, IModInfo::getVersion)); - final Map> modVersionDependencies = modFiles - .stream() + final var modVersionDependencies = modFiles.stream() .map(ModFile::getModInfos) - .flatMap(Collection::stream) - .collect(Collectors.groupingBy(Function.identity(), Java9BackportUtils.flatMapping(e -> e.getDependencies().stream(), Collectors.toList()))); + .mapMulti(Iterable::forEach) + .collect(groupingBy(Function.identity(), flatMapping(e -> e.getDependencies().stream(), toList()))); - final Set modRequirements = modVersionDependencies - .values() - .stream() - .flatMap(Collection::stream) + final var modRequirements = modVersionDependencies.values().stream() + .mapMulti(Iterable::forEach) .filter(mv -> mv.getSide().isCorrectSide()) - .collect(Collectors.toSet()); + .collect(toSet()); final long mandatoryRequired = modRequirements.stream().filter(IModInfo.ModVersion::isMandatory).count(); LOGGER.debug(LOADING, "Found {} mod requirements ({} mandatory, {} optional)", modRequirements.size(), mandatoryRequired, modRequirements.size() - mandatoryRequired); - final Set missingVersions = modRequirements - .stream() + final var missingVersions = modRequirements.stream() .filter(mv -> (mv.isMandatory() || modVersions.containsKey(mv.getModId())) && this.modVersionNotContained(mv, modVersions)) - .collect(Collectors.toSet()); + .collect(toSet()); final long mandatoryMissing = missingVersions.stream().filter(IModInfo.ModVersion::isMandatory).count(); LOGGER.debug(LOADING, "Found {} mod requirements missing ({} mandatory, {} optional)", missingVersions.size(), mandatoryMissing, missingVersions.size() - mandatoryMissing); if (!missingVersions.isEmpty()) { - return missingVersions - .stream() + return missingVersions.stream() .map(mv -> new ExceptionData(mv.isMandatory() ? "fml.modloading.missingdependency" : "fml.modloading.missingdependency.optional", mv.getOwner(), mv.getModId(), mv.getOwner().getModId(), mv.getVersionRange(), modVersions.getOrDefault(mv.getModId(), new DefaultArtifactVersion("null")))) - .collect(Collectors.toList()); + .toList(); } return Collections.emptyList(); } diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/RuntimeDistCleaner.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/RuntimeDistCleaner.java similarity index 100% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/RuntimeDistCleaner.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/RuntimeDistCleaner.java diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/StringSubstitutor.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/StringSubstitutor.java similarity index 94% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/StringSubstitutor.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/StringSubstitutor.java index 90a8656c68..281f7bbbf0 100644 --- a/src/fmllauncher/java/net/minecraftforge/fml/loading/StringSubstitutor.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/StringSubstitutor.java @@ -30,8 +30,8 @@ import java.util.Map; public class StringSubstitutor { private static final Map globals = ImmutableMap.of( - "mcVersion", FMLLoader.mcVersion, - "forgeVersion", FMLLoader.forgeVersion + "mcVersion", FMLLoader.versionInfo().mcVersion(), + "forgeVersion", FMLLoader.versionInfo().forgeVersion() ); public static String replace(final String in, final ModFile file) { diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/StringUtils.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/StringUtils.java similarity index 98% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/StringUtils.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/StringUtils.java index 820fcdb687..e291bde1b0 100644 --- a/src/fmllauncher/java/net/minecraftforge/fml/loading/StringUtils.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/StringUtils.java @@ -26,8 +26,7 @@ import java.net.URL; import java.util.Locale; import java.util.Map; -public class StringUtils -{ +public class StringUtils { public static String toLowerCase(final String str) { return str.toLowerCase(Locale.ROOT); } diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/TracingPrintStream.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/TracingPrintStream.java similarity index 100% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/TracingPrintStream.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/TracingPrintStream.java diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/VersionInfo.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/VersionInfo.java new file mode 100644 index 0000000000..15d2cde99d --- /dev/null +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/VersionInfo.java @@ -0,0 +1,17 @@ +package net.minecraftforge.fml.loading; + +import java.util.Map; + +public record VersionInfo(String forgeVersion, String mcVersion, String mcpVersion, String forgeGroup) { + VersionInfo(Map arguments) { + this((String) arguments.get("forgeVersion"), (String) arguments.get("mcVersion"), (String) arguments.get("mcpVersion"), (String) arguments.get("forgeGroup")); + } + + public String mcAndForgeVersion() { + return mcVersion+"-"+forgeVersion; + } + + public String mcAndMCPVersion() { + return mcVersion + "-" + mcpVersion; + } +} diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/VersionSupportMatrix.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/VersionSupportMatrix.java similarity index 76% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/VersionSupportMatrix.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/VersionSupportMatrix.java index 5850c4d245..dc2f98ad3a 100644 --- a/src/fmllauncher/java/net/minecraftforge/fml/loading/VersionSupportMatrix.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/VersionSupportMatrix.java @@ -32,17 +32,17 @@ import java.util.function.BiPredicate; public class VersionSupportMatrix { private static final HashMap> overrideVersions = new HashMap<>(); static { - final ArtifactVersion version = new DefaultArtifactVersion(FMLLoader.mcVersion); - if (MavenVersionAdapter.createFromVersionSpec("[1.16.4,1.16.5]").containsVersion(version)) { - // 1.16.4 is Compatible with 1.16.3 - add("languageloader.javafml", "34"); - add("mod.minecraft", "1.16.3"); - add("mod.forge", "34.1.42"); - // 1.16.5 is Compatible with 1.16.4, and thus 1.16.3 - add("languageloader.javafml", "35"); - add("mod.minecraft", "1.16.4"); - add("mod.forge", "35.1.37"); - } + final ArtifactVersion version = new DefaultArtifactVersion(FMLLoader.versionInfo().mcVersion()); + // if (MavenVersionAdapter.createFromVersionSpec("[1.16.4,1.16.5]").containsVersion(version)) { + // // 1.16.4 is Compatible with 1.16.3 + // add("languageloader.javafml", "34"); + // add("mod.minecraft", "1.16.3"); + // add("mod.forge", "34.1.42"); + // // 1.16.5 is Compatible with 1.16.4, and thus 1.16.3 + // add("languageloader.javafml", "35"); + // add("mod.minecraft", "1.16.4"); + // add("mod.forge", "35.1.37"); + // } } private static void add(String key, String value) { overrideVersions.computeIfAbsent(key, k -> new ArrayList<>()).add(new DefaultArtifactVersion(value)); diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/log4j/ForgeHighlight.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/log4j/ForgeHighlight.java similarity index 98% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/log4j/ForgeHighlight.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/log4j/ForgeHighlight.java index 01af2cafb5..a5ef3c8263 100644 --- a/src/fmllauncher/java/net/minecraftforge/fml/loading/log4j/ForgeHighlight.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/log4j/ForgeHighlight.java @@ -29,8 +29,8 @@ import org.apache.logging.log4j.core.pattern.HighlightConverter; import org.apache.logging.log4j.core.pattern.PatternConverter; import org.apache.logging.log4j.status.StatusLogger; import org.apache.logging.log4j.util.PerformanceSensitive; +import org.jetbrains.annotations.Nullable; -import javax.annotation.Nullable; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/AbstractJarFileLocator.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/AbstractJarFileLocator.java new file mode 100644 index 0000000000..1fdfc1a3b6 --- /dev/null +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/AbstractJarFileLocator.java @@ -0,0 +1,67 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.fml.loading.moddiscovery; + +import cpw.mods.jarhandling.SecureJar; +import net.minecraftforge.forgespi.locating.IModFile; +import net.minecraftforge.forgespi.locating.IModLocator; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static net.minecraftforge.fml.loading.LogMarkers.SCAN; + +public abstract class AbstractJarFileLocator implements IModLocator { + private static final Logger LOGGER = LogManager.getLogger(); + + @Override + public void scanFile(final IModFile file, final Consumer pathConsumer) { + LOGGER.debug(SCAN,"Scan started: {}", file); + final Function status = p->file.getSecureJar().verifyPath(p); + try (Stream files = Files.find(file.getSecureJar().getRootPath(), Integer.MAX_VALUE, (p, a) -> p.getNameCount() > 0 && p.getFileName().toString().endsWith(".class"))) { + file.setSecurityStatus(files.peek(pathConsumer).map(status).reduce((s1, s2)-> SecureJar.Status.values()[Math.min(s1.ordinal(), s2.ordinal())]).orElse(SecureJar.Status.INVALID)); + } catch (IOException e) { + e.printStackTrace(); + } + LOGGER.debug(SCAN,"Scan finished: {}", file); + } + + @Override + public List scanMods() { + return scanCandidates() + .map(mc -> ModFile.newFMLInstance(this, mc)) + .collect(Collectors.toList()); + } + + public abstract Stream scanCandidates(); + + @Override + public boolean isValid(final IModFile modFile) { + return true; + } +} diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/BackgroundScanHandler.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/BackgroundScanHandler.java similarity index 85% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/BackgroundScanHandler.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/BackgroundScanHandler.java index 69ae1aac60..899e47dc81 100644 --- a/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/BackgroundScanHandler.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/BackgroundScanHandler.java @@ -21,17 +21,12 @@ package net.minecraftforge.fml.loading.moddiscovery; import net.minecraftforge.forgespi.language.ModFileScanData; import net.minecraftforge.fml.loading.LoadingModList; -import net.minecraftforge.forgespi.locating.IModFile; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.util.ArrayList; import java.util.List; -import java.util.Map; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; +import java.util.concurrent.*; import static net.minecraftforge.fml.loading.LogMarkers.SCAN; @@ -42,10 +37,11 @@ public class BackgroundScanHandler private final List pendingFiles; private final List scannedFiles; private final List allFiles; - private final Map> modFiles; + private final List modFiles; private LoadingModList loadingModList; - public BackgroundScanHandler(final Map> modFiles) { + @SuppressWarnings("UnstableApiUsage") + public BackgroundScanHandler(final List modFiles) { this.modFiles = modFiles; modContentScanner = Executors.newSingleThreadExecutor(r -> { final Thread thread = Executors.defaultThreadFactory().newThread(r); @@ -57,7 +53,7 @@ public class BackgroundScanHandler allFiles = new ArrayList<>(); } - public Map> getModFiles() { + public List getModFiles() { return modFiles; } @@ -92,14 +88,18 @@ public class BackgroundScanHandler } public void waitForScanToComplete(final Runnable ticker) { + boolean interrupted = false; + boolean succeeded = false; modContentScanner.shutdown(); do { ticker.run(); try { - modContentScanner.awaitTermination(50, TimeUnit.MILLISECONDS); + succeeded = modContentScanner.awaitTermination(50, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { - Thread.interrupted(); + interrupted = true; } } while (!modContentScanner.isShutdown()); + if (interrupted) Thread.currentThread().interrupt(); + if (!succeeded) throw new IllegalStateException("Failed to complete mod scan"); } } diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/CoreModFile.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/CoreModFile.java similarity index 100% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/CoreModFile.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/CoreModFile.java diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ExplodedDirectoryLocator.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ExplodedDirectoryLocator.java new file mode 100644 index 0000000000..72a9c6aa3c --- /dev/null +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ExplodedDirectoryLocator.java @@ -0,0 +1,90 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.fml.loading.moddiscovery; + +import net.minecraftforge.forgespi.locating.IModFile; +import net.minecraftforge.forgespi.locating.IModLocator; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.function.Consumer; +import java.util.stream.Stream; + +import static net.minecraftforge.fml.loading.LogMarkers.LOADING; +import static net.minecraftforge.fml.loading.LogMarkers.SCAN; + +public class ExplodedDirectoryLocator implements IModLocator { + private static final Logger LOGGER = LogManager.getLogger(); + + public record ExplodedMod(String modid, List paths) {} + + private final List explodedMods = new ArrayList<>(); + private final Map mods = new HashMap<>(); + + @Override + public List scanMods() { + explodedMods.forEach(explodedMod -> ModJarMetadata.buildFile(this, jar ->jar.findFile("/META-INF/mods.toml").isPresent(), explodedMod.paths().toArray(Path[]::new)) + .ifPresentOrElse(f->mods.put(explodedMod, f), () -> LOGGER.warn(LOADING, "Failed to find exploded resource mods.toml in directory {}", explodedMod.paths().get(0).toString()))); + return List.copyOf(mods.values()); + } + + @Override + public String name() { + return "exploded directory"; + } + + @Override + public void scanFile(final IModFile file, final Consumer pathConsumer) { + LOGGER.debug(SCAN,"Scanning exploded directory {}", file.getFilePath().toString()); + try (Stream files = Files.find(file.getSecureJar().getRootPath(), Integer.MAX_VALUE, (p, a) -> p.getNameCount() > 0 && p.getFileName().toString().endsWith(".class"))) { + files.forEach(pathConsumer); + } catch (IOException e) { + e.printStackTrace(); + } + LOGGER.debug(SCAN,"Exploded directory scan complete {}", file.getFilePath().toString()); + } + + @Override + public String toString() + { + return "{ExplodedDir locator}"; + } + + @SuppressWarnings("unchecked") + @Override + public void initArguments(final Map arguments) { + final var explodedTargets = ((Map>) arguments).get("explodedTargets"); + if (explodedTargets != null && !explodedTargets.isEmpty()) { + explodedMods.addAll(explodedTargets); + } + } + + @Override + public boolean isValid(final IModFile modFile) { + return true; + } +} diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/InvalidModFileException.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/InvalidModFileException.java similarity index 100% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/InvalidModFileException.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/InvalidModFileException.java diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/InvalidModIdentifier.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/InvalidModIdentifier.java similarity index 100% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/InvalidModIdentifier.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/InvalidModIdentifier.java diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/MavenDirectoryLocator.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/MavenDirectoryLocator.java similarity index 88% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/MavenDirectoryLocator.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/MavenDirectoryLocator.java index 10c651c7e9..11228124de 100644 --- a/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/MavenDirectoryLocator.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/MavenDirectoryLocator.java @@ -21,7 +21,6 @@ package net.minecraftforge.fml.loading.moddiscovery; import net.minecraftforge.fml.loading.FMLPaths; import net.minecraftforge.fml.loading.MavenCoordinateResolver; -import net.minecraftforge.forgespi.locating.IModFile; import java.nio.file.Files; import java.nio.file.Path; @@ -34,11 +33,8 @@ public class MavenDirectoryLocator extends AbstractJarFileLocator { private List modCoords; @Override - public List scanMods() { - return modCoords.stream() - .map(mc -> ModFile.newFMLInstance(mc, this)) - .peek(f->modJars.compute(f, (mf, fs)->createFileSystem(mf))) - .collect(Collectors.toList()); + public Stream scanCandidates() { + return modCoords.stream(); } @Override diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/MinecraftLocator.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/MinecraftLocator.java new file mode 100644 index 0000000000..d6532bced2 --- /dev/null +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/MinecraftLocator.java @@ -0,0 +1,118 @@ +package net.minecraftforge.fml.loading.moddiscovery; + +import com.electronwill.nightconfig.core.Config; +import com.electronwill.nightconfig.core.file.FileConfig; +import cpw.mods.jarhandling.SecureJar; +import net.minecraftforge.fml.loading.FMLLoader; +import net.minecraftforge.forgespi.language.IModFileInfo; +import net.minecraftforge.forgespi.language.MavenVersionAdapter; +import net.minecraftforge.forgespi.locating.IModFile; +import net.minecraftforge.forgespi.locating.IModLocator; +import net.minecraftforge.forgespi.locating.ModFileFactory; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.io.IOException; +import java.nio.file.*; +import java.util.*; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import static net.minecraftforge.fml.loading.LogMarkers.LOADING; +import static net.minecraftforge.fml.loading.LogMarkers.SCAN; + +public class MinecraftLocator implements IModLocator { + private static final Logger LOGGER = LogManager.getLogger(); + + @Override + public List scanMods() { + final var launchHandler = FMLLoader.getLaunchHandler(); + var baseMC = launchHandler.getMinecraftPaths(); + var mcjar = ModJarMetadata.buildFile(j->ModFileFactory.FACTORY.build(j, this, this::buildMinecraftTOML), j->true, baseMC.minecraftFilter(), baseMC.minecraftPaths().toArray(Path[]::new)).orElseThrow(); + var artifacts = baseMC.otherArtifacts().stream().map(SecureJar::from).map(sj->ModFile.newFMLInstance(this, sj)).collect(Collectors.toList()); + var othermods = baseMC.otherModPaths().stream().map(p->ModJarMetadata.buildFile(this, p.toArray(Path[]::new))).toList(); + artifacts.add(mcjar); + artifacts.addAll(othermods); + return artifacts; + } + + private IModFileInfo buildMinecraftTOML(final IModFile iModFile) { + final ModFile modFile = (ModFile) iModFile; + /* + final Path mcmodtoml = modFile.findResource("META-INF", "minecraftmod.toml"); + if (Files.notExists(mcmodtoml)) { + LOGGER.fatal(LOADING, "Mod file {} is missing minecraftmod.toml file", modFile.getFilePath()); + return null; + } + + final FileConfig mcmodstomlfile = FileConfig.builder(mcmodtoml).build(); + mcmodstomlfile.load(); + mcmodstomlfile.close(); + */ + + + // We haven't changed this in years, and I can't be asked right now to special case this one file in the path. + final var conf = Config.inMemory(); + conf.set("modLoader", "minecraft"); + conf.set("loaderVersion", "1"); + conf.set("license", "Mojang Studios, All Rights Reserved"); + final var mods = Config.inMemory(); + mods.set("modId", "minecraft"); + mods.set("version", FMLLoader.versionInfo().mcVersion()); + mods.set("displayName", "Minecraft"); + mods.set("logoFile", "mcplogo.png"); + mods.set("credits", "Mojang, deobfuscated by MCP"); + mods.set("authors", "MCP: Searge,ProfMobius,IngisKahn,Fesh0r,ZeuX,R4wk,LexManos,Bspkrs"); + mods.set("description", "Minecraft, decompiled and deobfuscated with MCP technology"); + conf.set("mods", List.of(mods)); + /* + conf.putAll(mcmodstomlfile); + + final var extralangs = Stream.builder(); + final Path forgemodtoml = modFile.findResource("META-INF", "mods.toml"); + if (Files.notExists(forgemodtoml)) { + LOGGER.info("No forge mods.toml file found, not loading forge mod"); + } else { + final FileConfig forgemodstomlfile = FileConfig.builder(forgemodtoml).build(); + forgemodstomlfile.load(); + forgemodstomlfile.close(); + conf.putAll(forgemodstomlfile); + conf.>get("mods").add(0, mcmodstomlfile.>get("mods").get(0)); // Add MC as a sub-mod + extralangs.add(new IModFileInfo.LanguageSpec(mcmodstomlfile.get("modLoader"), MavenVersionAdapter.createFromVersionSpec(mcmodstomlfile.get("loaderVersion")))); + } + */ + + + final NightConfigWrapper configWrapper = new NightConfigWrapper(conf); + //final ModFileInfo modFileInfo = new ModFileInfo(modFile, configWrapper, extralangs.build().toList()); + final ModFileInfo modFileInfo = new ModFileInfo(modFile, configWrapper, List.of()); + configWrapper.setFile(modFileInfo); + return modFileInfo; + } + + @Override + public String name() { + return "minecraft"; + } + + @Override + public void scanFile(final IModFile modFile, final Consumer pathConsumer) { + LOGGER.debug(SCAN, "Scan started: {}", modFile); + try (Stream files = Files.find(modFile.getSecureJar().getRootPath(), Integer.MAX_VALUE, (p, a) -> p.getNameCount() > 0 && p.getFileName().toString().endsWith(".class"))) { + files.forEach(pathConsumer); + } catch (IOException e) { + e.printStackTrace(); + } + LOGGER.debug(SCAN, "Scan finished: {}", modFile); + } + + @Override + public void initArguments(final Map arguments) { + // no op + } + + @Override + public boolean isValid(final IModFile modFile) { + return true; + } +} diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/ModAnnotation.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModAnnotation.java similarity index 100% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/ModAnnotation.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModAnnotation.java diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/ModAnnotationVisitor.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModAnnotationVisitor.java similarity index 100% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/ModAnnotationVisitor.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModAnnotationVisitor.java diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/ModClassVisitor.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModClassVisitor.java similarity index 100% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/ModClassVisitor.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModClassVisitor.java diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModDiscoverer.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModDiscoverer.java new file mode 100644 index 0000000000..899ece163a --- /dev/null +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModDiscoverer.java @@ -0,0 +1,78 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.fml.loading.moddiscovery; + +import cpw.mods.modlauncher.Launcher; +import cpw.mods.modlauncher.api.IModuleLayerManager; +import cpw.mods.modlauncher.util.ServiceLoaderUtils; +import net.minecraftforge.fml.loading.progress.StartupMessageManager; +import net.minecraftforge.forgespi.Environment; +import net.minecraftforge.forgespi.locating.IModFile; +import net.minecraftforge.forgespi.locating.IModLocator; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.util.Arrays; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.ServiceLoader; +import java.util.stream.Collectors; + +import static net.minecraftforge.fml.loading.LogMarkers.CORE; +import static net.minecraftforge.fml.loading.LogMarkers.SCAN; + +public class ModDiscoverer { + private static final Logger LOGGER = LogManager.getLogger(); + private final ServiceLoader locators; + private final List locatorList; + + public ModDiscoverer(Map arguments) { + Launcher.INSTANCE.environment().computePropertyIfAbsent(Environment.Keys.MODDIRECTORYFACTORY.get(), v->ModsFolderLocator::new); + Launcher.INSTANCE.environment().computePropertyIfAbsent(Environment.Keys.PROGRESSMESSAGE.get(), v->StartupMessageManager.locatorConsumer().orElseGet(()->s->{})); + final var moduleLayerManager = Launcher.INSTANCE.environment().findModuleLayerManager().orElseThrow(); + locators = ServiceLoader.load(moduleLayerManager.getLayer(IModuleLayerManager.Layer.SERVICE).orElseThrow(), IModLocator.class); + locatorList = ServiceLoaderUtils.streamServiceLoader(()->locators, sce->LOGGER.error("Failed to load locator list", sce)).collect(Collectors.toList()); + locatorList.forEach(l->l.initArguments(arguments)); + LOGGER.debug(CORE,"Found Mod Locators : {}", ()->locatorList.stream().map(iModLocator -> "("+iModLocator.name() + ":" + iModLocator.getClass().getPackage().getImplementationVersion()+")").collect(Collectors.joining(","))); + } + + ModDiscoverer(List locatorList) { + this.locatorList = locatorList; + this.locators = null; + } + + public ModValidator discoverMods() { + LOGGER.debug(SCAN,"Scanning for mods and other resources to load. We know {} ways to find mods", locatorList.size()); + final var modFiles = locatorList.stream() + .peek(loc -> LOGGER.debug(SCAN,"Trying locator {}", loc)) + .map(IModLocator::scanMods) + .mapMulti(Iterable::forEach) + .peek(mf -> LOGGER.info(SCAN,"Found mod file {} of type {} with locator {}", mf.getFileName(), mf.getType(), mf.getLocator())) + .peek(mf -> StartupMessageManager.modLoaderConsumer().ifPresent(c->c.accept("Found mod file "+mf.getFileName()+" of type "+mf.getType()))) + .map(ModFile.class::cast) + .collect(Collectors.groupingBy(IModFile::getType)); + + var validator = new ModValidator(modFiles); + validator.stage1Validation(); + return validator; + } + +} diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/ModFieldVisitor.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFieldVisitor.java similarity index 100% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/ModFieldVisitor.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFieldVisitor.java diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/ModFile.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFile.java similarity index 75% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/ModFile.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFile.java index 61dc9a64ae..ad7e1a5627 100644 --- a/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/ModFile.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFile.java @@ -20,6 +20,7 @@ package net.minecraftforge.fml.loading.moddiscovery; import com.google.common.collect.ImmutableMap; +import cpw.mods.jarhandling.SecureJar; import net.minecraftforge.fml.loading.progress.StartupMessageManager; import net.minecraftforge.fml.loading.FMLLoader; import net.minecraftforge.forgespi.language.IModFileInfo; @@ -46,10 +47,9 @@ import java.util.jar.Attributes; import java.util.jar.Manifest; import static net.minecraftforge.fml.loading.LogMarkers.LOADING; -import static net.minecraftforge.fml.loading.LogMarkers.SCAN; public class ModFile implements IModFile { - private static final Manifest DEFAULTMANIFEST; + public static final Manifest DEFAULTMANIFEST; private static final Logger LOGGER = LogManager.getLogger(); static { @@ -60,9 +60,9 @@ public class ModFile implements IModFile { private final String jarVersion; private final ModFileFactory.ModFileInfoParser parser; private Map fileProperties; - private IModLanguageProvider loader; + private List loaders; private Throwable scanError; - private final Path filePath; + private final SecureJar jar; private final Type modFileType; private final Manifest manifest; private final IModLocator locator; @@ -73,17 +73,17 @@ public class ModFile implements IModFile { private Path accessTransformer; public static final Attributes.Name TYPE = new Attributes.Name("FMLModType"); + private SecureJar.Status securityStatus; - public ModFile(final Path file, final IModLocator locator, final ModFileFactory.ModFileInfoParser parser) { + public ModFile(final SecureJar jar, final IModLocator locator, final ModFileFactory.ModFileInfoParser parser) { this.locator = locator; - this.filePath = file; + this.jar = jar; this.parser = parser; - manifest = Optional.ofNullable(locator).flatMap(l->l.findManifest(file)).orElse(DEFAULTMANIFEST); - if (manifest != DEFAULTMANIFEST) LOGGER.debug(SCAN,"Mod file {} has a manifest", file); - else LOGGER.debug(SCAN,"Mod file {} is missing a manifest", file); + + manifest = this.jar.getManifest(); final Optional value = Optional.ofNullable(manifest.getMainAttributes().getValue(TYPE)); modFileType = Type.valueOf(value.orElse("MOD")); - jarVersion = Optional.ofNullable(manifest.getMainAttributes().getValue(Attributes.Name.IMPLEMENTATION_VERSION)).orElse("NONE"); + jarVersion = Optional.ofNullable(manifest.getMainAttributes().getValue(Attributes.Name.IMPLEMENTATION_VERSION)).orElse("0.0NONE"); } @Override @@ -97,7 +97,12 @@ public class ModFile implements IModFile { @Override public Path getFilePath() { - return filePath; + return jar.getPrimaryPath(); + } + + @Override + public SecureJar getSecureJar() { + return this.jar; } @Override @@ -112,10 +117,10 @@ public class ModFile implements IModFile { public boolean identifyMods() { this.modFileInfo = ModFileParser.readModList(this, this.parser); if (this.modFileInfo == null) return false; - LOGGER.debug(LOADING,"Loading mod file {} with language {}", this.getFilePath(), this.modFileInfo.getModLoader()); + LOGGER.debug(LOADING,"Loading mod file {} with languages {}", this.getFilePath(), this.modFileInfo.requiredLanguageLoaders()); this.coreMods = ModFileParser.getCoreMods(this); this.coreMods.forEach(mi-> LOGGER.debug(LOADING,"Found coremod {}", mi.getPath())); - this.accessTransformer = locator.findPath(this, "META-INF", "accesstransformer.cfg"); + this.accessTransformer = findResource("META-INF", "accesstransformer.cfg"); return true; } @@ -145,7 +150,7 @@ public class ModFile implements IModFile { try { this.futureScanResult.get(); } catch (InterruptedException | ExecutionException e) { - e.printStackTrace(); + LOGGER.error("Caught unexpected exception processing scan results", e); } } if (this.scanError != null) { @@ -169,24 +174,29 @@ public class ModFile implements IModFile { } @Override - public IModLanguageProvider getLoader() + public List getLoaders() { - return loader; + return loaders; } @Override - public Path findResource(String className) + public Path findResource(String... path) { - return locator.findPath(this, className); + if (path.length < 1) { + throw new IllegalArgumentException("Missing path"); + } + return getSecureJar().getPath(String.join("/", path)); } public void identifyLanguage() { - this.loader = FMLLoader.getLanguageLoadingProvider().findLanguage(this, this.modFileInfo.getModLoader(), this.modFileInfo.getModLoaderVersion()); + this.loaders = this.modFileInfo.requiredLanguageLoaders().stream() + .map(spec->FMLLoader.getLanguageLoadingProvider().findLanguage(this, spec.languageName(), spec.acceptedVersions())) + .toList(); } @Override public String toString() { - return "Mod File: " + Objects.toString(this.filePath); + return "Mod File: " + Objects.toString(this.jar.getPrimaryPath()); } @Override @@ -208,7 +218,15 @@ public class ModFile implements IModFile { return ModFile::new; } - public static ModFile newFMLInstance(final Path path, final IModLocator locator) { - return (ModFile) ModFileFactory.FACTORY.build(path, locator, ModFileParser::modsTomlParser); + public static ModFile newFMLInstance(final IModLocator locator, final SecureJar jar) { + return (ModFile) ModFileFactory.FACTORY.build(jar, locator, ModFileParser::modsTomlParser); + } + + public static ModFile newFMLInstance(final IModLocator locator, final Path... paths) { + return (ModFile) ModJarMetadata.buildFile(locator, paths); + } + @Override + public void setSecurityStatus(final SecureJar.Status status) { + this.securityStatus = status; } } diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/ModFileInfo.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFileInfo.java similarity index 76% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/ModFileInfo.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFileInfo.java index c19c4a0b2f..f4227b52fe 100644 --- a/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/ModFileInfo.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFileInfo.java @@ -21,7 +21,7 @@ package net.minecraftforge.fml.loading.moddiscovery; import com.google.common.base.Strings; import cpw.mods.modlauncher.api.LamdbaExceptionUtils; -import net.minecraftforge.fml.loading.Java9BackportUtils; +import cpw.mods.util.LambdaExceptionUtils; import net.minecraftforge.fml.loading.StringUtils; import net.minecraftforge.forgespi.language.IConfigurable; import net.minecraftforge.forgespi.language.IModFileInfo; @@ -43,13 +43,10 @@ import java.security.SignatureException; import java.security.cert.Certificate; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; +import java.util.*; import java.util.jar.Manifest; import java.util.stream.Collectors; +import java.util.stream.Stream; import static net.minecraftforge.fml.loading.LogMarkers.LOADING; @@ -59,29 +56,27 @@ public class ModFileInfo implements IModFileInfo, IConfigurable private final IConfigurable config; private final ModFile modFile; private final URL issueURL; - private final String modLoader; - private final VersionRange modLoaderVersion; + private final List languageSpecs; private final boolean showAsResourcePack; private final List mods; private final Map properties; private final String license; - // Caches the manifest of the mod jar as parsing the manifest can be expensive for - // signed jars. - private final Optional manifest; - private final Optional signers; + private final List usesServices; ModFileInfo(final ModFile modFile, final IConfigurable config) { this.modFile = modFile; this.config = config; - this.modLoader = config.getConfigElement("modLoader") + var modLoader = config.getConfigElement("modLoader") .orElseThrow(()->new InvalidModFileException("Missing ModLoader in file", this)); - this.modLoaderVersion = config.getConfigElement("loaderVersion") + var modLoaderVersion = config.getConfigElement("loaderVersion") .map(MavenVersionAdapter::createFromVersionSpec) .orElseThrow(()->new InvalidModFileException("Missing ModLoader version in file", this)); + this.languageSpecs = new ArrayList<>(List.of(new LanguageSpec(modLoader, modLoaderVersion))); this.license = config.getConfigElement("license") .orElse(""); this.showAsResourcePack = config.getConfigElement("showAsResourcePack").orElse(false); + this.usesServices = config.>getConfigElement("services").orElse(List.of()); this.properties = config.>getConfigElement("properties").orElse(Collections.emptyMap()); this.modFile.setFileProperties(this.properties); this.issueURL = config.getConfigElement("issueTrackerURL").map(StringUtils::toURL).orElse(null); @@ -97,9 +92,11 @@ public class ModFileInfo implements IModFileInfo, IConfigurable this.modFile::getFileName, () -> this.mods.stream().map(IModInfo::getModId).collect(Collectors.joining(",", "{", "}")), () -> this.mods.stream().map(IModInfo::getVersion).map(Objects::toString).collect(Collectors.joining(",", "{", "}"))); - final Pair, Optional> manifestAndSigners = modFile.getLocator().findManifestAndSigners(modFile.getFilePath()); - this.manifest = manifestAndSigners.getKey(); - this.signers = manifestAndSigners.getValue(); + } + + public ModFileInfo(final ModFile file, final IConfigurable config, final List languageSpecs) { + this(file, config); + this.languageSpecs.addAll(languageSpecs); } @Override @@ -114,15 +111,8 @@ public class ModFileInfo implements IModFileInfo, IConfigurable } @Override - public String getModLoader() - { - return modLoader; - } - - @Override - public VersionRange getModLoaderVersion() - { - return modLoaderVersion; + public List requiredLanguageLoaders() { + return this.languageSpecs; } @Override @@ -131,11 +121,6 @@ public class ModFileInfo implements IModFileInfo, IConfigurable return this.properties; } - public Optional getManifest() - { - return manifest; - } - @Override public boolean showAsResourcePack() { @@ -160,6 +145,11 @@ public class ModFileInfo implements IModFileInfo, IConfigurable return license; } + @Override + public IConfigurable getConfig() { + return this; + } + public URL getIssueURL() { return issueURL; @@ -170,15 +160,10 @@ public class ModFileInfo implements IModFileInfo, IConfigurable return Strings.isNullOrEmpty(license); } - /* This data can only be trusted for the manifest and signature file itself. We do not validate each entry in the jar. Coremods exists, it would be useless */ - public Optional getCodeSigners() { - return this.signers; - } - - /* This data can only be trusted for the manifest and signature file itself. We do not validate each entry in the jar. Coremods exists, it would be useless */ public Optional getCodeSigningFingerprint() { - return Java9BackportUtils.toStream(this.signers) - .flatMap(csa->csa[0].getSignerCertPath().getCertificates().stream()) + var signers = this.modFile.getSecureJar().getManifestSigners(); + return (signers == null ? Stream.of() : Arrays.stream(signers)) + .flatMap(csa->csa.getSignerCertPath().getCertificates().stream()) .findFirst() .map(LamdbaExceptionUtils.rethrowFunction(Certificate::getEncoded)) .map(bytes->LamdbaExceptionUtils.uncheck(()->MessageDigest.getInstance("SHA-256")).digest(bytes)) @@ -186,10 +171,9 @@ public class ModFileInfo implements IModFileInfo, IConfigurable .map(str-> String.join(":", str.split("(?<=\\G.{2})"))); } - /* This data can only be trusted for the manifest and signature file itself. We do not validate each entry in the jar. Coremods exists, it would be useless */ public Optional getTrustData() { - return Java9BackportUtils.toStream(this.signers) - .flatMap(csa->csa[0].getSignerCertPath().getCertificates().stream()) + return Arrays.stream(this.modFile.getSecureJar().getManifestSigners()) + .flatMap(csa->csa.getSignerCertPath().getCertificates().stream()) .findFirst() .map(X509Certificate.class::cast) .map(c->{ @@ -210,4 +194,19 @@ public class ModFileInfo implements IModFileInfo, IConfigurable return sb.toString(); }); } + + @Override + public String moduleName() { + return getMods().get(0).getModId(); + } + + @Override + public String versionString() { + return getMods().get(0).getVersion().toString(); + } + + @Override + public List usesServices() { + return usesServices; + } } diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/ModFileParser.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFileParser.java similarity index 84% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/ModFileParser.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFileParser.java index 5b4f03e89a..1d27e64854 100644 --- a/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/ModFileParser.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFileParser.java @@ -49,9 +49,9 @@ public class ModFileParser { public static IModFileInfo modsTomlParser(final IModFile imodFile) { ModFile modFile = (ModFile) imodFile; LOGGER.debug(LOADING,"Considering mod file candidate {}", modFile.getFilePath()); - final Path modsjson = modFile.getLocator().findPath(modFile, "META-INF", "mods.toml"); + final Path modsjson = modFile.findResource("META-INF", "mods.toml"); if (!Files.exists(modsjson)) { - LOGGER.warn(LOADING, "Mod file {} is missing mods.toml file", modFile); + LOGGER.warn(LOADING, "Mod file {} is missing mods.toml file", modFile.getFilePath()); return null; } @@ -67,7 +67,7 @@ public class ModFileParser { protected static List getCoreMods(final ModFile modFile) { Map coreModPaths; try { - final Path coremodsjson = modFile.getLocator().findPath(modFile, "META-INF", "coremods.json"); + final Path coremodsjson = modFile.findResource("META-INF", "coremods.json"); if (!Files.exists(coremodsjson)) { return Collections.emptyList(); } @@ -79,9 +79,9 @@ public class ModFileParser { return Collections.emptyList(); } - return coreModPaths.entrySet().stream(). - peek(e-> LOGGER.debug(LOADING,"Found coremod {} with Javascript path {}", e.getKey(), e.getValue())). - map(e -> new CoreModFile(e.getKey(), modFile.getLocator().findPath(modFile, e.getValue()),modFile)). - collect(Collectors.toList()); + return coreModPaths.entrySet().stream() + .peek(e-> LOGGER.debug(LOADING,"Found coremod {} with Javascript path {}", e.getKey(), e.getValue())) + .map(e -> new CoreModFile(e.getKey(), modFile.findResource(e.getValue()),modFile)) + .collect(Collectors.toList()); } } diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/ModInfo.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModInfo.java similarity index 95% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/ModInfo.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModInfo.java index 93980ddc96..ebafdb9036 100644 --- a/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/ModInfo.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModInfo.java @@ -52,7 +52,7 @@ public class ModInfo implements IModInfo, IConfigurable private final String description; private final Optional logoFile; private final boolean logoBlur; - private final URL updateJSONURL; + private final Optional updateJSONURL; private final List dependencies; private final Map properties; private final IConfigurable config; @@ -86,8 +86,7 @@ public class ModInfo implements IModInfo, IConfigurable .orElse(true)); this.updateJSONURL = config.getConfigElement("updateJSONURL") - .map(StringUtils::toURL) - .orElse(null); + .map(StringUtils::toURL); this.dependencies = ownFile.map(mfi -> mfi.getConfigList("dependencies", this.modId) .stream() @@ -143,27 +142,25 @@ public class ModInfo implements IModInfo, IConfigurable } @Override - public URL getUpdateURL() { + public Optional getUpdateURL() { return this.updateJSONURL; } + @Override public Optional getLogoFile() { return this.logoFile; } + @Override public boolean getLogoBlur() { return this.logoBlur; } - /** - * This is no longer used. The Mods List GUI currently directly checks whether there is an EntryPoint registered. - */ - @Deprecated - public boolean hasConfigUI() - { - return false; + @Override + public IConfigurable getConfig() { + return this; } @Override diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModJarMetadata.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModJarMetadata.java new file mode 100644 index 0000000000..5cd2005110 --- /dev/null +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModJarMetadata.java @@ -0,0 +1,96 @@ +package net.minecraftforge.fml.loading.moddiscovery; + +import cpw.mods.jarhandling.JarMetadata; +import cpw.mods.jarhandling.SecureJar; +import net.minecraftforge.forgespi.locating.IModFile; +import net.minecraftforge.forgespi.locating.IModLocator; + +import java.lang.module.ModuleDescriptor; +import java.nio.file.Path; +import java.util.Objects; +import java.util.Optional; +import java.util.function.BiPredicate; +import java.util.function.Function; +import java.util.function.Predicate; + +public final class ModJarMetadata implements JarMetadata { + private IModFile modFile; + private ModuleDescriptor descriptor; + + static Optional buildFile(IModLocator locator, Predicate jarTest, Path... files) { + return buildFile(locator, jarTest, (a,b) -> true, files); + } + + static Optional buildFile(IModLocator locator, Predicate jarTest, BiPredicate filter, Path... files) { + return buildFile(j->ModFile.newFMLInstance(locator, j), jarTest, filter, files); + } + + static IModFile buildFile(IModLocator locator, Path... files) { + return buildFile(locator, j->true, files).orElseThrow(()->new IllegalArgumentException("Failed to find valid JAR file")); + } + + static Optional buildFile(Function mfConstructor, Predicate jarTest, BiPredicate filter, Path... files) { + var mjm = new ModJarMetadata(); + var sj = SecureJar.from(()->ModFile.DEFAULTMANIFEST, j->mjm, filter, files); + if (jarTest.test(sj)) { + var mf = mfConstructor.apply(sj); + mjm.setModFile(mf); + return Optional.of(mf); + } else { + return Optional.empty(); + } + } + + private ModJarMetadata() { + } + + public void setModFile(IModFile file) { + this.modFile = file; + } + + @Override + public String name() { + return modFile.getModFileInfo().moduleName(); + } + + @Override + public String version() { + return modFile.getModFileInfo().versionString(); + } + + @Override + public ModuleDescriptor descriptor() { + if (descriptor != null) return descriptor; + var bld = ModuleDescriptor.newAutomaticModule(name()) + .version(version()) + .packages(modFile.getSecureJar().getPackages()); + modFile.getSecureJar().getProviders().stream() + .filter(p -> !p.providers().isEmpty()) + .forEach(p -> bld.provides(p.serviceName(), p.providers())); + modFile.getModFileInfo().usesServices().forEach(bld::uses); + descriptor = bld.build(); + return descriptor; + } + + public IModFile modFile() { + return modFile; + } + + @Override + public boolean equals(Object obj) { + if (obj == this) return true; + if (obj == null || obj.getClass() != this.getClass()) return false; + var that = (ModJarMetadata) obj; + return Objects.equals(this.modFile, that.modFile); + } + + @Override + public int hashCode() { + return Objects.hash(modFile); + } + + @Override + public String toString() { + return "ModJarMetadata[" +"modFile=" + modFile + ']'; + } +} diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/ModListHandler.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModListHandler.java similarity index 100% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/ModListHandler.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModListHandler.java diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/ModMethodVisitor.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModMethodVisitor.java similarity index 100% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/ModMethodVisitor.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModMethodVisitor.java diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModValidator.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModValidator.java new file mode 100644 index 0000000000..a1c0f4ea21 --- /dev/null +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModValidator.java @@ -0,0 +1,88 @@ +package net.minecraftforge.fml.loading.moddiscovery; + +import cpw.mods.jarhandling.SecureJar; +import cpw.mods.modlauncher.api.IModuleLayerManager; +import cpw.mods.modlauncher.api.ITransformationService; +import net.minecraftforge.fml.loading.*; +import net.minecraftforge.fml.loading.progress.StartupMessageManager; +import net.minecraftforge.forgespi.locating.IModFile; +import net.minecraftforge.forgespi.locating.ModFileFactory; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.jetbrains.annotations.NotNull; + +import java.util.*; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static net.minecraftforge.fml.loading.LogMarkers.SCAN; + +public class ModValidator { + private static final Logger LOGGER = LogManager.getLogger(); + private final Map> modFiles; + private final List candidatePlugins; + private final List candidateMods; + private LoadingModList loadingModList; + private List brokenFiles; + + public ModValidator(final Map> modFiles) { + this.modFiles = modFiles; + this.candidateMods = new ArrayList<>(modFiles.getOrDefault(IModFile.Type.MOD, List.of())); + this.candidatePlugins = new ArrayList<>(modFiles.getOrDefault(IModFile.Type.LANGPROVIDER, List.of())); + this.candidatePlugins.addAll(modFiles.getOrDefault(IModFile.Type.LIBRARY, List.of())); + } + + public void stage1Validation() { + brokenFiles = validateFiles(candidateMods); + LOGGER.debug(SCAN,"Found {} mod files with {} mods", candidateMods::size, ()-> candidateMods.stream().mapToInt(mf -> mf.getModInfos().size()).sum()); + StartupMessageManager.modLoaderConsumer().ifPresent(c->c.accept("Found "+ candidateMods.size()+" modfiles to load")); + } + + @NotNull + private List validateFiles(final List mods) { + final List brokenFiles = new ArrayList<>(); + for (Iterator iterator = mods.iterator(); iterator.hasNext(); ) + { + ModFile mod = iterator.next(); + if (!mod.getLocator().isValid(mod) || !mod.identifyMods()) { + LOGGER.warn(SCAN, "File {} has been ignored - it is invalid", mod.getFilePath()); + iterator.remove(); + brokenFiles.add(mod); + } + } + return brokenFiles; + } + + public ITransformationService.Resource getPluginResources() { + return new ITransformationService.Resource(IModuleLayerManager.Layer.PLUGIN, this.candidatePlugins.stream().map(ModFile::getSecureJar).toList()); + } + + public ITransformationService.Resource getModResources() { + return new ITransformationService.Resource(IModuleLayerManager.Layer.GAME, this.candidateMods.stream().map(ModFile::getSecureJar).toList()); + } + + private List validateLanguages() { + List errorData = new ArrayList<>(); + for (Iterator iterator = this.candidateMods.iterator(); iterator.hasNext(); ) { + final ModFile modFile = iterator.next(); + try { + modFile.identifyLanguage(); + } catch (EarlyLoadingException e) { + errorData.addAll(e.getAllData()); + iterator.remove(); + } + } + return errorData; + } + + public BackgroundScanHandler stage2Validation() { + var errors = validateLanguages(); + loadingModList = ModSorter.sort(candidateMods, errors); + loadingModList.addCoreMods(); + loadingModList.addAccessTransformers(); + loadingModList.setBrokenFiles(brokenFiles); + BackgroundScanHandler backgroundScanHandler = new BackgroundScanHandler(candidateMods); + loadingModList.addForScanning(backgroundScanHandler); + return backgroundScanHandler; + } +} diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/ModsFolderLocator.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModsFolderLocator.java similarity index 83% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/ModsFolderLocator.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModsFolderLocator.java index ef52fa6ae8..8cb724e58a 100644 --- a/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/ModsFolderLocator.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModsFolderLocator.java @@ -32,6 +32,7 @@ import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.stream.Collectors; +import java.util.stream.Stream; import static cpw.mods.modlauncher.api.LamdbaExceptionUtils.uncheck; import static net.minecraftforge.fml.loading.LogMarkers.SCAN; @@ -57,17 +58,15 @@ public class ModsFolderLocator extends AbstractJarFileLocator { this.modFolder = modFolder; this.customName = name; } + @Override - public List scanMods() { + public Stream scanCandidates() { LOGGER.debug(SCAN,"Scanning mods dir {} for mods", this.modFolder); - List excluded = ModDirTransformerDiscoverer.allExcluded(); + var excluded = ModDirTransformerDiscoverer.allExcluded(); + return uncheck(()-> Files.list(this.modFolder)) - .filter(p->!excluded.contains(p)) - .sorted(Comparator.comparing(path-> StringUtils.toLowerCase(path.getFileName().toString()))) - .filter(p->StringUtils.toLowerCase(p.getFileName().toString()).endsWith(SUFFIX)) - .map(p->ModFile.newFMLInstance(p, this)) - .peek(f->modJars.compute(f, (mf, fs)->createFileSystem(mf))) - .collect(Collectors.toList()); + .filter(p-> !excluded.contains(p) && StringUtils.toLowerCase(p.getFileName().toString()).endsWith(SUFFIX)) + .sorted(Comparator.comparing(path-> StringUtils.toLowerCase(path.getFileName().toString()))); } @Override diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/NightConfigWrapper.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/NightConfigWrapper.java similarity index 95% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/NightConfigWrapper.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/NightConfigWrapper.java index 6ef978bdb5..0414bc9349 100644 --- a/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/NightConfigWrapper.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/NightConfigWrapper.java @@ -61,7 +61,7 @@ public class NightConfigWrapper implements IConfigurable { if (this.config.contains(path) && !(this.config.get(path) instanceof Collection)) { throw new InvalidModFileException("The configuration path "+path+" is invalid. Expecting a collection!", file); } - final ArrayList nestedConfigs = this.config.getOrElse(path, ArrayList::new); + final Collection nestedConfigs = this.config.getOrElse(path, ArrayList::new); return nestedConfigs.stream() .map(NightConfigWrapper::new) .map(cw->cw.setFile(file)) diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/Scanner.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/Scanner.java similarity index 86% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/Scanner.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/Scanner.java index d3622d471f..9c6989d5f0 100644 --- a/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/Scanner.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/Scanner.java @@ -29,6 +29,7 @@ import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Path; +import java.util.List; import static net.minecraftforge.fml.loading.LogMarkers.SCAN; @@ -44,10 +45,12 @@ public class Scanner { ModFileScanData result = new ModFileScanData(); result.addModFileInfo(fileToScan.getModFileInfo()); fileToScan.scanFile(p -> fileVisitor(p, result)); - final IModLanguageProvider loader = fileToScan.getLoader(); - if (loader != null) { - LOGGER.debug(SCAN, "Scanning {} with language loader {}", fileToScan.getFilePath(), loader.name()); - loader.getFileVisitor().accept(result); + final List loaders = fileToScan.getLoaders(); + if (loaders != null) { + loaders.forEach(loader -> { + LOGGER.debug(SCAN, "Scanning {} with language loader {}", fileToScan.getFilePath(), loader.name()); + loader.getFileVisitor().accept(result); + }); } return result; } diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/progress/ClientVisualization.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/progress/ClientVisualization.java similarity index 95% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/progress/ClientVisualization.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/progress/ClientVisualization.java index 6909767eec..a72f005372 100644 --- a/src/fmllauncher/java/net/minecraftforge/fml/loading/progress/ClientVisualization.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/progress/ClientVisualization.java @@ -15,7 +15,8 @@ * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ + *//* + package net.minecraftforge.fml.loading.progress; @@ -83,9 +84,9 @@ class ClientVisualization implements EarlyProgressVisualization.Visualization { glfwDefaultWindowHints(); glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API); glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_NATIVE_CONTEXT_API); - glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); - glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); - glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_ANY_PROFILE); + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); + glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE); @@ -161,18 +162,18 @@ class ClientVisualization implements EarlyProgressVisualization.Visualization { } private void renderProgress() { - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(0.0D, screenWidth, screenHeight, 0.0D, -1000.0D, 1000.0D); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - glEnableClientState(GL11.GL_VERTEX_ARRAY); - glEnable(GL_BLEND); - renderBackground(); - renderMessages(); - glfwSwapBuffers(window); + // glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + // glMatrixMode(GL_PROJECTION); + // glLoadIdentity(); + // glOrtho(0.0D, screenWidth, screenHeight, 0.0D, -1000.0D, 1000.0D); + // glMatrixMode(GL_MODELVIEW); + // glLoadIdentity(); + // + // glEnableClientState(GL11.GL_VERTEX_ARRAY); + // glEnable(GL_BLEND); + // renderBackground(); + // renderMessages(); + // glfwSwapBuffers(window); } private static float clamp(float num, float min, float max) { @@ -368,3 +369,4 @@ class ClientVisualization implements EarlyProgressVisualization.Visualization { return window; } } +*/ diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/progress/EarlyProgressVisualization.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/progress/EarlyProgressVisualization.java similarity index 69% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/progress/EarlyProgressVisualization.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/progress/EarlyProgressVisualization.java index 026b4b32fd..d091b4de6e 100644 --- a/src/fmllauncher/java/net/minecraftforge/fml/loading/progress/EarlyProgressVisualization.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/progress/EarlyProgressVisualization.java @@ -19,15 +19,16 @@ package net.minecraftforge.fml.loading.progress; +import cpw.mods.modlauncher.api.LamdbaExceptionUtils; import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.fml.loading.FMLLoader; +import org.jetbrains.annotations.Nullable; import java.util.function.IntConsumer; import java.util.function.IntSupplier; import java.util.function.LongSupplier; import java.util.function.Supplier; -import javax.annotation.Nullable; - public enum EarlyProgressVisualization { INSTANCE; @@ -39,7 +40,8 @@ public enum EarlyProgressVisualization { } public Runnable accept(final Dist dist, final boolean isData, @Nullable String mcVersion) { - visualization = !isData && dist.isClient() && Boolean.parseBoolean(System.getProperty("fml.earlyprogresswindow", "true")) ? new ClientVisualization() : new NoVisualization(); +// visualization = !isData && dist.isClient() && Boolean.parseBoolean(System.getProperty("fml.earlyprogresswindow", "true")) ? new ClientVisualization() : new NoVisualization(); + visualization = new NoVisualization(); return visualization.start(mcVersion); } @@ -55,12 +57,12 @@ public enum EarlyProgressVisualization { Runnable start(@Nullable String mcVersion); default long handOffWindow(final IntSupplier width, final IntSupplier height, final Supplier title, LongSupplier monitorSupplier) { - return new LongSupplier() { - @Override - public long getAsLong() { - return org.lwjgl.glfw.GLFW.glfwCreateWindow(width.getAsInt(), height.getAsInt(), title.get(), monitorSupplier.getAsLong(), 0L); - } - }.getAsLong(); + return FMLLoader.getGameLayer().findModule("forge") + .map(l->Class.forName(l, "net.minecraftforge.fmllegacy.NoVizFallback")) + .map(LamdbaExceptionUtils.rethrowFunction(c->c.getMethod("fallback", IntSupplier.class, IntSupplier.class, Supplier.class, LongSupplier.class))) + .map(LamdbaExceptionUtils.rethrowFunction(m->(LongSupplier)m.invoke(null, width, height, title, monitorSupplier))) + .map(LongSupplier::getAsLong) + .orElseThrow(()->new IllegalStateException("Why are you here?")); } default void updateFBSize(IntConsumer width, IntConsumer height) { diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/progress/StartupMessageManager.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/progress/StartupMessageManager.java similarity index 100% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/progress/StartupMessageManager.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/progress/StartupMessageManager.java diff --git a/src/userdev/java/net/minecraftforge/userdev/ArgumentList.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/ArgumentList.java similarity index 99% rename from src/userdev/java/net/minecraftforge/userdev/ArgumentList.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/ArgumentList.java index e4312e44d7..bc2651b584 100644 --- a/src/userdev/java/net/minecraftforge/userdev/ArgumentList.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/ArgumentList.java @@ -17,7 +17,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.userdev; +package net.minecraftforge.fml.loading.targets; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import java.util.ArrayList; import java.util.Arrays; @@ -26,9 +29,6 @@ import java.util.List; import java.util.Map; import java.util.function.Supplier; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - /* * A class that attempts to parse command line arguments into key value pairs to allow addition and editing. * Can not use JOptSimple as that doesn't parse out the values for keys unless the spec says it has a value. diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/CommonClientLaunchHandler.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/CommonClientLaunchHandler.java new file mode 100644 index 0000000000..bfaf257798 --- /dev/null +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/CommonClientLaunchHandler.java @@ -0,0 +1,68 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.fml.loading.targets; + +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.fml.loading.FMLLoader; +import net.minecraftforge.fml.loading.LibraryFinder; +import net.minecraftforge.fml.loading.VersionInfo; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.nio.file.Path; +import java.util.List; +import java.util.concurrent.Callable; +import java.util.stream.Stream; + +public abstract class CommonClientLaunchHandler extends CommonLaunchHandler { + private static final Logger LOGGER = LogManager.getLogger(); + + @Override public Dist getDist() { return Dist.CLIENT; } + @Override public String getNaming() { return "srg"; } + @Override public boolean isProduction() { return true; } + + @Override + public Callable launchService(String[] arguments, ModuleLayer layer) { + return () -> { + Class.forName(layer.findModule("minecraft").orElseThrow(),"net.minecraft.client.main.Main").getMethod("main", String[].class).invoke(null, (Object)arguments); + return null; + }; + } + + @Override + public LocatedPaths getMinecraftPaths() { + final var vers = FMLLoader.versionInfo(); + var mc = LibraryFinder.findPathForMaven("net.minecraft", "client", "", "srg", vers.mcAndMCPVersion()); + var mcextra = LibraryFinder.findPathForMaven("net.minecraft", "client", "", "extra", vers.mcAndMCPVersion()); + var mcstream = Stream.builder().add(mc).add(mcextra); + var modstream = Stream.>builder(); + + processMCStream(vers, mcstream, modstream); + + var fmlcore = LibraryFinder.findPathForMaven(vers.forgeGroup(), "fmlcore", "", "", vers.mcAndForgeVersion()); + var javafmllang = LibraryFinder.findPathForMaven(vers.forgeGroup(), "javafmllanguage", "", "", vers.mcAndForgeVersion()); + var mclang = LibraryFinder.findPathForMaven(vers.forgeGroup(), "mclanguage", "", "", vers.mcAndForgeVersion()); + + return new LocatedPaths(mcstream.build().toList(), (a,b) -> true, modstream.build().toList(), List.of(fmlcore, javafmllang, mclang)); + } + + protected abstract void processMCStream(VersionInfo versionInfo, Stream.Builder mc, Stream.Builder> mods); +} diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/CommonDevLaunchHandler.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/CommonDevLaunchHandler.java new file mode 100644 index 0000000000..fa61473015 --- /dev/null +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/CommonDevLaunchHandler.java @@ -0,0 +1,150 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.fml.loading.targets; + +import com.google.common.base.Strings; +import cpw.mods.jarhandling.SecureJar; + +import java.io.File; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; +import java.util.function.BiPredicate; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Stream; + +public abstract class CommonDevLaunchHandler extends CommonLaunchHandler { + @Override public String getNaming() { return "mcp"; } + @Override public boolean isProduction() { return false; } + + @Override + public LocatedPaths getMinecraftPaths() { + // Minecraft is extra jar {resources} + our exploded directories in dev + final var mcstream = Stream.builder(); + + // The extra jar is on the classpath, so try and pull it out of the legacy classpath + var legacyCP = Objects.requireNonNull(System.getProperty("legacyClassPath"), "Missing legacyClassPath, cannot find client-extra").split(File.pathSeparator); + var extra = Paths.get(Arrays.stream(legacyCP).filter(e -> e.contains("client-extra")).findFirst().orElseThrow(() -> new IllegalStateException("Could not find client-extra in legacy classpath"))); + mcstream.add(extra); + + // The MC code/Patcher edits are in exploded directories + final var modstream = Stream.>builder(); + final var mods = getModClasses(); + final var minecraft = mods.remove("minecraft"); + if (minecraft == null) + throw new IllegalStateException("Could not find 'minecraft' mod paths."); + minecraft.stream().distinct().forEach(mcstream::add); + mods.values().forEach(modstream::add); + + var mcFilter = getMcFilter(extra, minecraft, modstream); + return new LocatedPaths(mcstream.build().toList(), mcFilter, modstream.build().toList(), getFmlStuff(legacyCP)); + } + + protected String[] preLaunch(String[] arguments, ModuleLayer layer) { + if (getDist().isDedicatedServer()) + return arguments; + + fixNatives(); + + if (isData()) + return arguments; + + var args = ArgumentList.from(arguments); + + String username = args.get("username"); + if (username != null) { // Replace '#' placeholders with random numbers + Matcher m = Pattern.compile("#+").matcher(username); + StringBuffer replaced = new StringBuffer(); + while (m.find()) { + m.appendReplacement(replaced, getRandomNumbers(m.group().length())); + } + m.appendTail(replaced); + args.put("username", replaced.toString()); + } else { + args.putLazy("username", "Dev"); + } + + if (!args.hasValue("accessToken")) { + args.put("accessToken", "0"); + } + + return args.getArguments(); + } + + protected List getFmlStuff(String[] classpath) { + // We also want the FML things, fmlcore, javafmllanguage, mclanguage, I don't like hard coding these, but hey whatever works for now. + return Arrays.stream(classpath) + .filter(e -> e.contains("fmlcore") || e.contains("javafmllanguage") || e.contains("mclanguage")) + .map(Paths::get) + .toList(); + } + + protected BiPredicate getMcFilter(Path extra, List minecraft, Stream.Builder> mods) { + final var packages = getPackages(); + final var extraPath = extra.toString().replace('\\', '/'); + + // We serve everything, except for things in the forge packages. + BiPredicate mcFilter = (path, base) -> { + if (base.equals(extraPath) || + path.endsWith("/")) return true; + for (var pkg : packages) + if (path.startsWith(pkg)) return false; + return true; + }; + + // We need to separate out our resources/code so that we can show up as a different data pack. + var modJar = SecureJar.from((path, base) -> { + if (!path.endsWith(".class")) return true; + for (var pkg : packages) + if (path.startsWith(pkg)) return true; + return false; + }, minecraft.stream().distinct().toArray(Path[]::new)); + //modJar.getPackages().stream().sorted().forEach(System.out::println); + mods.add(List.of(modJar.getRootPath())); + + return mcFilter; + } + + protected String[] getPackages() { + return new String[]{ "net/minecraftforge/", "META-INF/services/", "META-INF/coremods.json", "META-INF/mods.toml" }; + } + + private static String getRandomNumbers(int length) { + // Generate a time-based random number, to mimic how n.m.client.Main works + return Long.toString(System.nanoTime() % (int) Math.pow(10, length)); + } + + private static void fixNatives() { + String paths = System.getProperty("java.library.path"); + String nativesDir = System.getProperty("nativesDirectory"); + if (nativesDir == null) + return; + + if (Strings.isNullOrEmpty(paths)) + paths = nativesDir; + else + paths += File.pathSeparator + nativesDir; + + System.setProperty("java.library.path", paths); + } +} diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/CommonLaunchHandler.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/CommonLaunchHandler.java new file mode 100644 index 0000000000..b33af88f19 --- /dev/null +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/CommonLaunchHandler.java @@ -0,0 +1,81 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.fml.loading.targets; + +import cpw.mods.modlauncher.api.ILaunchHandlerService; +import cpw.mods.modlauncher.api.ITransformingClassLoaderBuilder; +import net.minecraftforge.api.distmarker.Dist; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.io.File; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.function.BiPredicate; +import java.util.stream.Collectors; + +import static net.minecraftforge.fml.loading.LogMarkers.CORE; + +public abstract class CommonLaunchHandler implements ILaunchHandlerService { + public record LocatedPaths(List minecraftPaths, BiPredicate minecraftFilter, List> otherModPaths, List otherArtifacts) {} + + protected static final Logger LOGGER = LogManager.getLogger(); + + public abstract Dist getDist(); + + public abstract String getNaming(); + + public boolean isProduction() { + return false; + } + + public boolean isData() { + return false; + } + + public abstract LocatedPaths getMinecraftPaths(); + + @Override + public void configureTransformationClassLoader(final ITransformingClassLoaderBuilder builder) { + + } + + protected final Map> getModClasses() { + final String modClasses = Optional.ofNullable(System.getenv("MOD_CLASSES")).orElse(""); + LOGGER.debug(CORE, "Got mod coordinates {} from env", modClasses); + + record ExplodedModPath(String modid, Path path) {} + // "a/b/;c/d/;" -> "modid%%c:\fish\pepper;modid%%c:\fish2\pepper2\;modid2%%c:\fishy\bums;modid2%%c:\hmm" + final var modClassPaths = Arrays.stream(modClasses.split(File.pathSeparator)) + .map(inp -> inp.split("%%", 2)) + .map(splitString -> new ExplodedModPath(splitString.length == 1 ? "defaultmodid" : splitString[0], Paths.get(splitString[splitString.length - 1]))) + .collect(Collectors.groupingBy(ExplodedModPath::modid, Collectors.mapping(ExplodedModPath::path, Collectors.toList()))); + + LOGGER.debug(CORE, "Found supplied mod coordinates [{}]", modClassPaths); + + //final var explodedTargets = ((Map>)arguments).computeIfAbsent("explodedTargets", a -> new ArrayList<>()); + //modClassPaths.forEach((modlabel,paths) -> explodedTargets.add(new ExplodedDirectoryLocator.ExplodedMod(modlabel, paths))); + return modClassPaths; + } +} diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/CommonServerLaunchHandler.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/CommonServerLaunchHandler.java new file mode 100644 index 0000000000..c79f5abe45 --- /dev/null +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/CommonServerLaunchHandler.java @@ -0,0 +1,78 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.fml.loading.targets; + +import cpw.mods.jarhandling.SecureJar; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.fml.loading.FMLLoader; +import net.minecraftforge.fml.loading.LibraryFinder; +import net.minecraftforge.fml.loading.VersionInfo; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.nio.file.Path; +import java.util.List; +import java.util.concurrent.Callable; +import java.util.function.BiPredicate; +import java.util.stream.Stream; + +public abstract class CommonServerLaunchHandler extends CommonLaunchHandler { + protected static final Logger LOGGER = LogManager.getLogger(); + + @Override public Dist getDist() { return Dist.DEDICATED_SERVER; } + @Override public String getNaming() { return "srg"; } + @Override public boolean isProduction() { return true; } + + @Override + public Callable launchService(String[] arguments, ModuleLayer layer) { + return () -> { + Class.forName(layer.findModule("minecraft").orElseThrow(),"net.minecraft.server.Main").getMethod("main", String[].class).invoke(null, (Object)arguments); + return null; + }; + } + + @Override + public LocatedPaths getMinecraftPaths() { + final var vers = FMLLoader.versionInfo(); + var mc = LibraryFinder.findPathForMaven("net.minecraft", "server", "", "srg", vers.mcAndMCPVersion()); + var mcextra = LibraryFinder.findPathForMaven("net.minecraft", "server", "", "extra", vers.mcAndMCPVersion()); + var mcextra_filtered = SecureJar.from( // We only want it for it's resources. So filter everything else out. + (path, base) -> { + return path.equals("META-INF/versions/") || // This is required because it bypasses our filter for the manifest, and it's a multi-release jar. + (!path.endsWith(".class") && + !path.startsWith("META-INF/")); + }, mcextra + ); + BiPredicate filter = (path, base) -> true; + + var mcstream = Stream.builder().add(mc).add(mcextra_filtered.getRootPath()); + var modstream = Stream.>builder(); + + filter = processMCStream(vers, mcstream, filter, modstream); + + var fmlcore = LibraryFinder.findPathForMaven(vers.forgeGroup(), "fmlcore", "", "", vers.mcAndForgeVersion()); + var javafmllang = LibraryFinder.findPathForMaven(vers.forgeGroup(), "javafmllanguage", "", "", vers.mcAndForgeVersion()); + var mclang = LibraryFinder.findPathForMaven(vers.forgeGroup(), "mclanguage", "", "", vers.mcAndForgeVersion()); + + return new LocatedPaths(mcstream.build().toList(), filter, modstream.build().toList(), List.of(fmlcore, javafmllang, mclang)); + } + + protected abstract BiPredicate processMCStream(VersionInfo versionInfo, Stream.Builder mc, BiPredicate filter, Stream.Builder> mods); +} diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/CommonUserdevLaunchHandler.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/CommonUserdevLaunchHandler.java new file mode 100644 index 0000000000..4197fea252 --- /dev/null +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/CommonUserdevLaunchHandler.java @@ -0,0 +1,62 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.fml.loading.targets; + +import net.minecraftforge.fml.loading.FMLLoader; +import net.minecraftforge.fml.loading.VersionInfo; + +import java.io.File; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public abstract class CommonUserdevLaunchHandler extends CommonDevLaunchHandler { + @Override + public LocatedPaths getMinecraftPaths() { + final var vers = FMLLoader.versionInfo(); + + // Minecraft is extra jar {resources} + forge jar {patches} + final var mcstream = Stream.builder(); + // Mod code is in exploded directories + final var modstream = Stream.>builder(); + + // The MC extra and forge jars are on the classpath, so try and pull them out + var legacyCP = Objects.requireNonNull(System.getProperty("legacyClassPath"), "Missing legacyClassPath, cannot find userdev jars").split(File.pathSeparator); + var extra = findJarOnClasspath(legacyCP, "client-extra"); + + processStreams(legacyCP, vers, mcstream, modstream); + getModClasses().forEach((modid, paths) -> modstream.add(paths)); + + var minecraft = mcstream.build().collect(Collectors.toList()); + var mcFilter = getMcFilter(extra, minecraft, modstream); + minecraft.add(extra); // Add extra late so the filter is made correctly + return new LocatedPaths(minecraft, mcFilter, modstream.build().toList(), getFmlStuff(legacyCP)); + } + + protected abstract void processStreams(String[] classpath, VersionInfo versionInfo, Stream.Builder mc, Stream.Builder> mods); + + protected static Path findJarOnClasspath(String[] classpath, String match) { + return Paths.get(Arrays.stream(classpath).filter(e -> e.contains(match)).findFirst().orElseThrow(() -> new IllegalStateException("Could not find " + match + " in classpath"))); + } +} diff --git a/src/main/java/net/minecraftforge/client/IRenderHandler.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/FMLClientDevLaunchHandler.java similarity index 54% rename from src/main/java/net/minecraftforge/client/IRenderHandler.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/FMLClientDevLaunchHandler.java index 9df734d48f..52410fcc03 100644 --- a/src/main/java/net/minecraftforge/client/IRenderHandler.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/FMLClientDevLaunchHandler.java @@ -17,22 +17,22 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.client; +package net.minecraftforge.fml.loading.targets; import net.minecraftforge.api.distmarker.Dist; -import net.minecraft.client.Minecraft; -import net.minecraft.client.world.ClientWorld; -import net.minecraftforge.api.distmarker.OnlyIn; +import java.util.concurrent.Callable; -/** -* Use one of {@link IWeatherRenderHandler}, {@link ICloudRenderHandler} or {@link ISkyRenderHandler} instead. -* -* todo: remove in 1.17 -*/ -@Deprecated -@FunctionalInterface -public interface IRenderHandler -{ - @OnlyIn(Dist.CLIENT) - void render(int ticks, float partialTicks, ClientWorld world, Minecraft mc); -} \ No newline at end of file +public class FMLClientDevLaunchHandler extends CommonDevLaunchHandler { + @Override public String name() { return "fmlclientdev"; } + @Override public Dist getDist() { return Dist.CLIENT; } + + @Override + public Callable launchService(String[] arguments, ModuleLayer layer) { + return () -> { + var args = preLaunch(arguments, layer); + + Class.forName(layer.findModule("minecraft").orElseThrow(), "net.minecraft.client.main.Main").getMethod("main", String[].class).invoke(null, (Object) args); + return null; + }; + } +} 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 new file mode 100644 index 0000000000..5a8edd81c8 --- /dev/null +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/FMLClientLaunchHandler.java @@ -0,0 +1,37 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.fml.loading.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 new file mode 100644 index 0000000000..320e954191 --- /dev/null +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/FMLClientUserdevLaunchHandler.java @@ -0,0 +1,42 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.fml.loading.targets; + +import net.minecraftforge.api.distmarker.Dist; + +import java.util.concurrent.Callable; + +public class FMLClientUserdevLaunchHandler extends FMLUserdevLaunchHandler { + @Override + public String name() { return "fmlclientuserdev"; } + + @Override + public Dist getDist() { return Dist.CLIENT; } + + @Override + public Callable launchService(String[] arguments, ModuleLayer layer) { + return () -> { + var args = preLaunch(arguments, layer); + + Class.forName(layer.findModule("minecraft").orElseThrow(), "net.minecraft.client.main.Main").getMethod("main", String[].class).invoke(null, (Object) args); + return null; + }; + } +} 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 new file mode 100644 index 0000000000..a5e9fb2efa --- /dev/null +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/FMLDataUserdevLaunchHandler.java @@ -0,0 +1,45 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.fml.loading.targets; + +import net.minecraftforge.api.distmarker.Dist; + +import java.util.concurrent.Callable; + +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 Callable launchService(String[] arguments, ModuleLayer layer) { + return () -> { + var args = preLaunch(arguments, layer); + + Class.forName(layer.findModule("minecraft").orElseThrow(), "net.minecraft.data.Main").getMethod("main", String[].class).invoke(null, (Object) args); + return null; + }; + } +} 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 new file mode 100644 index 0000000000..92abf9fa48 --- /dev/null +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/FMLServerDevLaunchHandler.java @@ -0,0 +1,19 @@ +package net.minecraftforge.fml.loading.targets; + +import net.minecraftforge.api.distmarker.Dist; +import java.util.concurrent.Callable; + +public class FMLServerDevLaunchHandler extends CommonDevLaunchHandler { + @Override public String name() { return "fmlserverdev"; } + @Override public Dist getDist() { return Dist.DEDICATED_SERVER; } + + @Override + public Callable launchService(String[] arguments, ModuleLayer layer) { + return () -> { + var args = preLaunch(arguments, layer); + + Class.forName(layer.findModule("minecraft").orElseThrow(),"net.minecraft.server.Main").getMethod("main", String[].class).invoke(null, (Object)args); + return null; + }; + } +} \ 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 new file mode 100644 index 0000000000..66b643288b --- /dev/null +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/FMLServerLaunchHandler.java @@ -0,0 +1,40 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.fml.loading.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 new file mode 100644 index 0000000000..7a70770793 --- /dev/null +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/FMLServerUserdevLaunchHandler.java @@ -0,0 +1,20 @@ +package net.minecraftforge.fml.loading.targets; + +import net.minecraftforge.api.distmarker.Dist; + +import java.util.concurrent.Callable; + +public class FMLServerUserdevLaunchHandler extends FMLUserdevLaunchHandler { + @Override public String name() { return "fmlserveruserdev"; } + @Override public Dist getDist() { return Dist.DEDICATED_SERVER; } + + @Override + public Callable launchService(String[] arguments, ModuleLayer layer) { + return () -> { + var args = preLaunch(arguments, layer); + + Class.forName(layer.findModule("minecraft").orElseThrow(),"net.minecraft.server.Main").getMethod("main", String[].class).invoke(null, (Object)args); + return null; + }; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/common/util/DummyWorldSaveData.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/FMLUserdevLaunchHandler.java similarity index 58% rename from src/main/java/net/minecraftforge/common/util/DummyWorldSaveData.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/FMLUserdevLaunchHandler.java index 8eb13d991b..707c0dbf9f 100644 --- a/src/main/java/net/minecraftforge/common/util/DummyWorldSaveData.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/FMLUserdevLaunchHandler.java @@ -17,25 +17,18 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.common.util; +package net.minecraftforge.fml.loading.targets; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.world.storage.WorldSavedData; +import net.minecraftforge.fml.loading.VersionInfo; -public class DummyWorldSaveData extends WorldSavedData { - public static final DummyWorldSaveData DUMMY = new DummyWorldSaveData(); - private DummyWorldSaveData() { - super("DUMMYDUMMY \uD83D\uDC4C\uD83D\uDC4C\uD83D\uDC4C"); - } +import java.nio.file.Path; +import java.util.List; +import java.util.stream.Stream; +public abstract class FMLUserdevLaunchHandler extends CommonUserdevLaunchHandler { @Override - public void load(final CompoundNBT nbt) { - // NOOP - } - - @Override - public CompoundNBT save(final CompoundNBT compound) { - // NOOP - return null; + 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/java/net/minecraftforge/fml/loading/targets/ForgeClientDevLaunchHandler.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/ForgeClientDevLaunchHandler.java new file mode 100644 index 0000000000..9b5b6a70c6 --- /dev/null +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/ForgeClientDevLaunchHandler.java @@ -0,0 +1,38 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.fml.loading.targets; + +import net.minecraftforge.api.distmarker.Dist; +import java.util.concurrent.Callable; + +public class ForgeClientDevLaunchHandler extends CommonDevLaunchHandler { + @Override public String name() { return "forgeclientdev"; } + @Override public Dist getDist() { return Dist.CLIENT; } + + @Override + public Callable launchService(String[] arguments, ModuleLayer layer) { + return () -> { + var args = preLaunch(arguments, layer); + + Class.forName(layer.findModule("minecraft").orElseThrow(), "net.minecraft.client.main.Main").getMethod("main", String[].class).invoke(null, (Object) args); + return null; + }; + } +} diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/ForgeClientLaunchHandler.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/ForgeClientLaunchHandler.java new file mode 100644 index 0000000000..c4560baa33 --- /dev/null +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/ForgeClientLaunchHandler.java @@ -0,0 +1,39 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.fml.loading.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 ForgeClientLaunchHandler extends CommonClientLaunchHandler { + @Override public String name() { return "forgeclient"; } + + @Override + protected void processMCStream(VersionInfo versionInfo, Stream.Builder mc, Stream.Builder> mods) { + var forgepatches = LibraryFinder.findPathForMaven(versionInfo.forgeGroup(), "forge", "", "client", versionInfo.mcAndForgeVersion()); + var forgejar = LibraryFinder.findPathForMaven(versionInfo.forgeGroup(), "forge", "", "universal", versionInfo.mcAndForgeVersion()); + mc.add(forgepatches); + mods.add(List.of(forgejar)); + } +} diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/ForgeClientUserdevLaunchHandler.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/ForgeClientUserdevLaunchHandler.java new file mode 100644 index 0000000000..af3cccb412 --- /dev/null +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/ForgeClientUserdevLaunchHandler.java @@ -0,0 +1,42 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.fml.loading.targets; + +import net.minecraftforge.api.distmarker.Dist; + +import java.util.concurrent.Callable; + +public class ForgeClientUserdevLaunchHandler extends ForgeUserdevLaunchHandler { + @Override + public String name() { return "forgeclientuserdev"; } + + @Override + public Dist getDist() { return Dist.CLIENT; } + + @Override + public Callable launchService(String[] arguments, ModuleLayer layer) { + return () -> { + var args = preLaunch(arguments, layer); + + Class.forName(layer.findModule("minecraft").orElseThrow(), "net.minecraft.client.main.Main").getMethod("main", String[].class).invoke(null, (Object) args); + return null; + }; + } +} diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/ForgeDataDevLaunchHandler.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/ForgeDataDevLaunchHandler.java new file mode 100644 index 0000000000..6433beef23 --- /dev/null +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/ForgeDataDevLaunchHandler.java @@ -0,0 +1,40 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.fml.loading.targets; + +import net.minecraftforge.api.distmarker.Dist; + +import java.util.concurrent.Callable; + +public class ForgeDataDevLaunchHandler extends CommonDevLaunchHandler { + @Override public String name() { return "forgedatadev"; } + @Override public Dist getDist() { return Dist.CLIENT; } + @Override public boolean isData() { return true; } + + @Override + public Callable launchService(String[] arguments, ModuleLayer layer) { + return () -> { + var args = preLaunch(arguments, layer); + + Class.forName(layer.findModule("minecraft").orElseThrow(), "net.minecraft.data.Main").getMethod("main", String[].class).invoke(null, (Object) args); + return null; + }; + } +} diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/ForgeDataUserdevLaunchHandler.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/ForgeDataUserdevLaunchHandler.java new file mode 100644 index 0000000000..fe79f5f2f4 --- /dev/null +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/ForgeDataUserdevLaunchHandler.java @@ -0,0 +1,45 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.fml.loading.targets; + +import net.minecraftforge.api.distmarker.Dist; + +import java.util.concurrent.Callable; + +public class ForgeDataUserdevLaunchHandler extends ForgeUserdevLaunchHandler { + @Override + public String name() { return "forgedatauserdev"; } + + @Override + public Dist getDist() { return Dist.CLIENT; } + + @Override + public boolean isData() { return true; } + + @Override + public Callable launchService(String[] arguments, ModuleLayer layer) { + return () -> { + var args = preLaunch(arguments, layer); + + Class.forName(layer.findModule("minecraft").orElseThrow(), "net.minecraft.data.Main").getMethod("main", String[].class).invoke(null, (Object) args); + return null; + }; + } +} diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/ForgeServerDevLaunchHandler.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/ForgeServerDevLaunchHandler.java new file mode 100644 index 0000000000..7c4bb15b25 --- /dev/null +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/ForgeServerDevLaunchHandler.java @@ -0,0 +1,19 @@ +package net.minecraftforge.fml.loading.targets; + +import net.minecraftforge.api.distmarker.Dist; +import java.util.concurrent.Callable; + +public class ForgeServerDevLaunchHandler extends CommonDevLaunchHandler { + @Override public String name() { return "forgeserverdev"; } + @Override public Dist getDist() { return Dist.DEDICATED_SERVER; } + + @Override + public Callable launchService(String[] arguments, ModuleLayer layer) { + return () -> { + var args = preLaunch(arguments, layer); + + Class.forName(layer.findModule("minecraft").orElseThrow(),"net.minecraft.server.Main").getMethod("main", String[].class).invoke(null, (Object)args); + return null; + }; + } +} \ No newline at end of file diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/ForgeServerLaunchHandler.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/ForgeServerLaunchHandler.java new file mode 100644 index 0000000000..9aee476720 --- /dev/null +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/ForgeServerLaunchHandler.java @@ -0,0 +1,42 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.fml.loading.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 ForgeServerLaunchHandler extends CommonServerLaunchHandler implements ILaunchHandlerService { + @Override public String name() { return "forgeserver"; } + + @Override + protected BiPredicate processMCStream(VersionInfo versionInfo, Stream.Builder mc, BiPredicate filter, Stream.Builder> mods) { + var forgepatches = LibraryFinder.findPathForMaven(versionInfo.forgeGroup(), "forge", "", "server", versionInfo.mcAndForgeVersion()); + var forgejar = LibraryFinder.findPathForMaven(versionInfo.forgeGroup(), "forge", "", "universal", versionInfo.mcAndForgeVersion()); + mc.add(forgepatches); + mods.add(List.of(forgejar)); + return filter; + } +} diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/ForgeServerUserdevLaunchHandler.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/ForgeServerUserdevLaunchHandler.java new file mode 100644 index 0000000000..ff4b7db93b --- /dev/null +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/ForgeServerUserdevLaunchHandler.java @@ -0,0 +1,20 @@ +package net.minecraftforge.fml.loading.targets; + +import net.minecraftforge.api.distmarker.Dist; + +import java.util.concurrent.Callable; + +public class ForgeServerUserdevLaunchHandler extends ForgeUserdevLaunchHandler { + @Override public String name() { return "forgeserveruserdev"; } + @Override public Dist getDist() { return Dist.DEDICATED_SERVER; } + + @Override + public Callable launchService(String[] arguments, ModuleLayer layer) { + return () -> { + var args = preLaunch(arguments, layer); + + Class.forName(layer.findModule("minecraft").orElseThrow(),"net.minecraft.server.Main").getMethod("main", String[].class).invoke(null, (Object)args); + return null; + }; + } +} \ No newline at end of file diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/ForgeUserdevLaunchHandler.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/ForgeUserdevLaunchHandler.java new file mode 100644 index 0000000000..fb20908cfc --- /dev/null +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/ForgeUserdevLaunchHandler.java @@ -0,0 +1,34 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.fml.loading.targets; + +import net.minecraftforge.fml.loading.VersionInfo; + +import java.nio.file.Path; +import java.util.List; +import java.util.stream.Stream; + +public abstract class ForgeUserdevLaunchHandler extends CommonUserdevLaunchHandler { + @Override + protected void processStreams(String[] classpath, VersionInfo versionInfo, Stream.Builder mc, Stream.Builder> mods) { + var forge = findJarOnClasspath(classpath, "forge-" + versionInfo.mcAndForgeVersion()); + mc.add(forge); + } +} diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/toposort/CyclePresentException.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/toposort/CyclePresentException.java similarity index 100% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/toposort/CyclePresentException.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/toposort/CyclePresentException.java diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/toposort/StronglyConnectedComponentDetector.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/toposort/StronglyConnectedComponentDetector.java similarity index 100% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/toposort/StronglyConnectedComponentDetector.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/toposort/StronglyConnectedComponentDetector.java diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/toposort/TopologicalSort.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/toposort/TopologicalSort.java similarity index 99% rename from src/fmllauncher/java/net/minecraftforge/fml/loading/toposort/TopologicalSort.java rename to fmlloader/src/main/java/net/minecraftforge/fml/loading/toposort/TopologicalSort.java index efbc43a1e5..a77152d85d 100644 --- a/src/fmllauncher/java/net/minecraftforge/fml/loading/toposort/TopologicalSort.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/toposort/TopologicalSort.java @@ -21,6 +21,7 @@ package net.minecraftforge.fml.loading.toposort; import com.google.common.base.Preconditions; import com.google.common.graph.Graph; +import org.jetbrains.annotations.Nullable; import java.util.ArrayDeque; import java.util.ArrayList; @@ -33,8 +34,6 @@ import java.util.PriorityQueue; import java.util.Queue; import java.util.Set; -import javax.annotation.Nullable; - /** * Provides a topological sort algorithm. * diff --git a/src/fmllauncher/java/net/minecraftforge/server/ServerMain.java b/fmlloader/src/main/java/net/minecraftforge/server/ServerMain.java similarity index 100% rename from src/fmllauncher/java/net/minecraftforge/server/ServerMain.java rename to fmlloader/src/main/java/net/minecraftforge/server/ServerMain.java diff --git a/src/fmllauncher/resources/META-INF/defaultfmlconfig.toml b/fmlloader/src/main/resources/META-INF/defaultfmlconfig.toml similarity index 100% rename from src/fmllauncher/resources/META-INF/defaultfmlconfig.toml rename to fmlloader/src/main/resources/META-INF/defaultfmlconfig.toml diff --git a/fmlloader/src/main/resources/META-INF/services/cpw.mods.cl.ModularURLHandler.IURLProvider b/fmlloader/src/main/resources/META-INF/services/cpw.mods.cl.ModularURLHandler.IURLProvider new file mode 100644 index 0000000000..e69de29bb2 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 new file mode 100644 index 0000000000..0552d8e423 --- /dev/null +++ b/fmlloader/src/main/resources/META-INF/services/cpw.mods.modlauncher.api.ILaunchHandlerService @@ -0,0 +1,16 @@ +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 +net.minecraftforge.fml.loading.targets.ForgeServerLaunchHandler +net.minecraftforge.fml.loading.targets.ForgeServerDevLaunchHandler +net.minecraftforge.fml.loading.targets.ForgeServerUserdevLaunchHandler +net.minecraftforge.fml.loading.targets.ForgeDataDevLaunchHandler +net.minecraftforge.fml.loading.targets.ForgeDataUserdevLaunchHandler diff --git a/fmlloader/src/main/resources/META-INF/services/cpw.mods.modlauncher.api.INameMappingService b/fmlloader/src/main/resources/META-INF/services/cpw.mods.modlauncher.api.INameMappingService new file mode 100644 index 0000000000..8ed3e2a8ac --- /dev/null +++ b/fmlloader/src/main/resources/META-INF/services/cpw.mods.modlauncher.api.INameMappingService @@ -0,0 +1 @@ +net.minecraftforge.fml.loading.MCPNamingService diff --git a/src/fmllauncher/resources/META-INF/services/cpw.mods.modlauncher.api.ITransformationService b/fmlloader/src/main/resources/META-INF/services/cpw.mods.modlauncher.api.ITransformationService similarity index 100% rename from src/fmllauncher/resources/META-INF/services/cpw.mods.modlauncher.api.ITransformationService rename to fmlloader/src/main/resources/META-INF/services/cpw.mods.modlauncher.api.ITransformationService diff --git a/src/fmllauncher/resources/META-INF/services/cpw.mods.modlauncher.serviceapi.ILaunchPluginService b/fmlloader/src/main/resources/META-INF/services/cpw.mods.modlauncher.serviceapi.ILaunchPluginService similarity index 100% rename from src/fmllauncher/resources/META-INF/services/cpw.mods.modlauncher.serviceapi.ILaunchPluginService rename to fmlloader/src/main/resources/META-INF/services/cpw.mods.modlauncher.serviceapi.ILaunchPluginService diff --git a/src/fmllauncher/resources/META-INF/services/cpw.mods.modlauncher.serviceapi.ITransformerDiscoveryService b/fmlloader/src/main/resources/META-INF/services/cpw.mods.modlauncher.serviceapi.ITransformerDiscoveryService similarity index 100% rename from src/fmllauncher/resources/META-INF/services/cpw.mods.modlauncher.serviceapi.ITransformerDiscoveryService rename to fmlloader/src/main/resources/META-INF/services/cpw.mods.modlauncher.serviceapi.ITransformerDiscoveryService diff --git a/src/fmllauncher/resources/META-INF/services/net.minecraftforge.forgespi.locating.IModLocator b/fmlloader/src/main/resources/META-INF/services/net.minecraftforge.forgespi.locating.IModLocator similarity index 74% rename from src/fmllauncher/resources/META-INF/services/net.minecraftforge.forgespi.locating.IModLocator rename to fmlloader/src/main/resources/META-INF/services/net.minecraftforge.forgespi.locating.IModLocator index 31898b8b87..7165f94525 100644 --- a/src/fmllauncher/resources/META-INF/services/net.minecraftforge.forgespi.locating.IModLocator +++ b/fmlloader/src/main/resources/META-INF/services/net.minecraftforge.forgespi.locating.IModLocator @@ -1,3 +1,4 @@ net.minecraftforge.fml.loading.moddiscovery.ModsFolderLocator net.minecraftforge.fml.loading.moddiscovery.MavenDirectoryLocator -net.minecraftforge.fml.loading.moddiscovery.ExplodedDirectoryLocator \ No newline at end of file +net.minecraftforge.fml.loading.moddiscovery.ExplodedDirectoryLocator +net.minecraftforge.fml.loading.moddiscovery.MinecraftLocator diff --git a/fmlloader/src/main/resources/log4j2.xml b/fmlloader/src/main/resources/log4j2.xml new file mode 100644 index 0000000000..cc980b8647 --- /dev/null +++ b/fmlloader/src/main/resources/log4j2.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fmlonly/src/fmlcommon b/fmlonly/src/fmlcommon new file mode 120000 index 0000000000..ce217f86dd --- /dev/null +++ b/fmlonly/src/fmlcommon @@ -0,0 +1 @@ +../../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 new file mode 100644 index 0000000000..6cf1421968 --- /dev/null +++ b/fmlonly/src/main/java/net/minecraftforge/fmlonly/FMLOnlyBindings.java @@ -0,0 +1,42 @@ +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); + } +} diff --git a/fmlonly/src/main/java/net/minecraftforge/fmlonlyclient/ClientModLoader.java b/fmlonly/src/main/java/net/minecraftforge/fmlonlyclient/ClientModLoader.java new file mode 100644 index 0000000000..d9c985948c --- /dev/null +++ b/fmlonly/src/main/java/net/minecraftforge/fmlonlyclient/ClientModLoader.java @@ -0,0 +1,205 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.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 net.minecraftforge.fml.VersionChecker; +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; + +import static net.minecraftforge.fml.loading.LogMarkers.LOADING; + +@OnlyIn(Dist.CLIENT) +public class ClientModLoader +{ + private static final Logger LOGGER = LogManager.getLogger(); + private static boolean loading; + private static Minecraft mc; + private static boolean loadingComplete; + private static LoadingFailedException error; +// private static EarlyLoaderGUI earlyLoaderGUI; + + private static class SpacedRunnable implements Runnable { + static final long NANO_SLEEP_TIME = TimeUnit.MILLISECONDS.toNanos(50); + private final Runnable wrapped; + private long lastRun; + + private SpacedRunnable(final Runnable wrapped) { + this.wrapped = wrapped; + this.lastRun = System.nanoTime() - NANO_SLEEP_TIME; + } + + @Override + public void run() { + if (System.nanoTime() - this.lastRun > NANO_SLEEP_TIME) { + wrapped.run(); + this.lastRun = System.nanoTime(); + } + } + } + public static void begin(final Minecraft minecraft, final PackRepository defaultResourcePacks, final ReloadableResourceManager mcResourceManager, ClientPackSource metadataSerializer) + { + // 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; +// LogicalSidedProvider.setClient(()->minecraft); +// LanguageHook.loadForgeAndMCLangs(); +// earlyLoaderGUI = new EarlyLoaderGUI(minecraft.getWindow()); + createRunnableWithCatch(()->ModLoader.get().gatherAndInitializeMods(ModWorkManager.syncExecutor(), ModWorkManager.parallelExecutor(), ()->{})).run(); + mcResourceManager.registerReloadListener(ClientModLoader::onResourceReload); +// if (error == null) { +//// ResourcePackLoader.loadResourcePacks(defaultResourcePacks, ClientModLoader::buildPackFinder); +//// DatapackCodec.DEFAULT.addModPacks(ResourcePackLoader.getPackNames()); +//// mcResourceManager.registerReloadListener(BrandingControl.resourceManagerReloadListener()); +//// ModelLoaderRegistry.init(); +// } + } + + 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; +// earlyLoaderGUI.handleElsewhere(); + createRunnableWithCatch(() -> ModLoader.get().loadMods(syncExecutor, parallelExecutor, ()->{})).run(); + } + + private static void postSidedRunnable() { +// LOGGER.debug(LOADING, "Running post client event work"); +// RenderingRegistry.loadEntityRenderers(mc.getEntityRenderDispatcher()); + } + + 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 completeModLoading() + { +// RenderSystem.disableTexture(); +// RenderSystem.enableTexture(); +// List warnings = ModLoader.get().getWarnings(); +// boolean showWarnings = true; +// try { +// showWarnings = ForgeConfig.CLIENT.showLoadWarnings.get(); +// } catch (NullPointerException e) { +// // We're in an early error state, config is not available. Assume true. +// } +// if (!showWarnings) { +// //User disabled warning screen, as least log them +// if (!warnings.isEmpty()) { +// LOGGER.warn(LOADING, "Mods loaded with {} warning(s)", warnings.size()); +// warnings.forEach(warning -> LOGGER.warn(LOADING, warning.formatToString())); +// } +// warnings = Collections.emptyList(); //Clear warnings, as the user does not want to see them +// } +// File dumpedLocation = null; +// if (error == null) { +// // We can finally start the forge eventbus up +// MinecraftForge.EVENT_BUS.start(); +// } else { +// // Double check we have the langs loaded for forge +// LanguageHook.loadForgeAndMCLangs(); +// dumpedLocation = CrashReportExtender.dumpModLoadingCrashReport(LOGGER, error, mc.gameDirectory); +// } +// if (error != null || !warnings.isEmpty()) { +// mc.setScreen(new LoadingErrorScreen(error, warnings, dumpedLocation)); +// return true; +// } else { +// ClientHooks.logMissingTextureErrors(); +// return false; +// } + return true; + } + + public static void renderProgressText() { +// earlyLoaderGUI.renderFromGUI(); + } + public static boolean isLoading() + { + return loading; + } + +// private static ResourcePackLoader.IPackInfoFinder buildPackFinder(Map modResourcePacks, BiConsumer packSetter) { +// return (packList, factory) -> clientPackFinder(modResourcePacks, packSetter, packList, factory); +// } +// +// private static void clientPackFinder(Map modResourcePacks, BiConsumer packSetter, Consumer consumer, ResourcePackInfo.IFactory factory) { +// List hiddenPacks = new ArrayList<>(); +// for (Entry e : modResourcePacks.entrySet()) +// { +// 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 ResourcePackInfo packInfo = ResourcePackInfo.create(name, false, e::getValue, factory, ResourcePackInfo.Priority.BOTTOM, IPackNameDecorator.DEFAULT); +// if (packInfo == 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())); +// continue; +// } +// packSetter.accept(e.getValue(), packInfo); +// LOGGER.debug(CORE, "Generating PackInfo named {} for mod file {}", name, e.getKey().getFilePath()); +// if (mod.getOwningFile().showAsResourcePack()) { +// consumer.accept(packInfo); +// } else { +// hiddenPacks.add(e.getValue()); +// } +// } +// final ResourcePackInfo packInfo = ResourcePackInfo.create("mod_resources", true, () -> new DelegatingResourcePack("mod_resources", "Mod Resources", +// new PackMetadataSection(new TranslationTextComponent("fml.resources.modresources", hiddenPacks.size()), 6), +// hiddenPacks), factory, ResourcePackInfo.Priority.BOTTOM, IPackNameDecorator.DEFAULT); +// consumer.accept(packInfo); +// } +} diff --git a/fmlonly/src/main/resources/META-INF/coremods.json b/fmlonly/src/main/resources/META-INF/coremods.json new file mode 100644 index 0000000000..e0343aa992 --- /dev/null +++ b/fmlonly/src/main/resources/META-INF/coremods.json @@ -0,0 +1,3 @@ +{ + "load_fml_client": "coremods/load_fml_client.js" +} \ No newline at end of file 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 new file mode 100644 index 0000000000..e442ddc508 --- /dev/null +++ b/fmlonly/src/main/resources/META-INF/services/net.minecraftforge.fml.IBindingsProvider @@ -0,0 +1 @@ +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 new file mode 100644 index 0000000000..16864dc762 --- /dev/null +++ b/fmlonly/src/main/resources/META-INF/services/net.minecraftforge.fml.IModStateProvider @@ -0,0 +1 @@ +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 new file mode 100644 index 0000000000..4f807a39b1 --- /dev/null +++ b/fmlonly/src/main/resources/coremods/load_fml_client.js @@ -0,0 +1,39 @@ +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_") + var clientPackSource = ASMAPI.mapField("f_91037_") + + 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.visitVarInsn(Opcodes.ALOAD, 0); + meth.visitFieldInsn(Opcodes.GETFIELD, "net/minecraft/client/Minecraft", clientPackSource, "Lnet/minecraft/client/resources/ClientPackSource;"); + 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;Lnet/minecraft/client/resources/ClientPackSource;)V", false) + for (var i=0; i + if (pkg == '') + manifest.attributes(values) + else + manifest.attributes(values, pkg) + } +} + +tasks.withType(JavaCompile) { + options.compilerArgs << '-Xlint:unchecked' +} + +artifacts { + archives jar + archives sourcesJar +} + +publishing.publications.mavenJava(MavenPublication) { + from components.java + artifact sourcesJar +} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/fml/common/Mod.java b/javafmllanguage/src/main/java/net/minecraftforge/fml/common/Mod.java similarity index 95% rename from src/main/java/net/minecraftforge/fml/common/Mod.java rename to javafmllanguage/src/main/java/net/minecraftforge/fml/common/Mod.java index f52cb385de..0bcc8b2e68 100644 --- a/src/main/java/net/minecraftforge/fml/common/Mod.java +++ b/javafmllanguage/src/main/java/net/minecraftforge/fml/common/Mod.java @@ -26,9 +26,8 @@ import java.lang.annotation.Target; import java.util.function.Supplier; import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fml.event.lifecycle.ModLifecycleEvent; +import net.minecraftforge.fml.Bindings; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; /** @@ -87,7 +86,7 @@ public @interface Mod * The main Forge Event Bus. * @see MinecraftForge#EVENT_BUS */ - FORGE(()-> MinecraftForge.EVENT_BUS), + FORGE(Bindings.getForgeBus()), /** * The mod specific Event bus. * @see FMLJavaModLoadingContext#getModEventBus() diff --git a/src/main/java/net/minecraftforge/fml/AutomaticEventSubscriber.java b/javafmllanguage/src/main/java/net/minecraftforge/fml/javafmlmod/AutomaticEventSubscriber.java similarity index 82% rename from src/main/java/net/minecraftforge/fml/AutomaticEventSubscriber.java rename to javafmllanguage/src/main/java/net/minecraftforge/fml/javafmlmod/AutomaticEventSubscriber.java index 0a6acb5279..43d1512ce0 100644 --- a/src/main/java/net/minecraftforge/fml/AutomaticEventSubscriber.java +++ b/javafmllanguage/src/main/java/net/minecraftforge/fml/javafmlmod/AutomaticEventSubscriber.java @@ -17,10 +17,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml; +package net.minecraftforge.fml.javafmlmod; import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.ModContainer; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.forgespi.language.ModFileScanData; import net.minecraftforge.fml.loading.FMLEnvironment; @@ -53,30 +53,30 @@ public class AutomaticEventSubscriber if (scanData == null) return; LOGGER.debug(LOADING,"Attempting to inject @EventBusSubscriber classes into the eventbus for {}", mod.getModId()); List ebsTargets = scanData.getAnnotations().stream(). - filter(annotationData -> AUTO_SUBSCRIBER.equals(annotationData.getAnnotationType())). + filter(annotationData -> AUTO_SUBSCRIBER.equals(annotationData.annotationType())). collect(Collectors.toList()); Map modids = scanData.getAnnotations().stream(). - filter(annotationData -> MOD_TYPE.equals(annotationData.getAnnotationType())). - collect(Collectors.toMap(a -> a.getClassType().getClassName(), a -> (String)a.getAnnotationData().get("value"))); + filter(annotationData -> MOD_TYPE.equals(annotationData.annotationType())). + collect(Collectors.toMap(a -> a.clazz().getClassName(), a -> (String)a.annotationData().get("value"))); ebsTargets.forEach(ad -> { @SuppressWarnings("unchecked") - final List sidesValue = (List)ad.getAnnotationData(). + final List sidesValue = (List)ad.annotationData(). getOrDefault("value", Arrays.asList(new ModAnnotation.EnumHolder(null, "CLIENT"), new ModAnnotation.EnumHolder(null, "DEDICATED_SERVER"))); final EnumSet sides = sidesValue.stream().map(eh -> Dist.valueOf(eh.getValue())). collect(Collectors.toCollection(() -> EnumSet.noneOf(Dist.class))); - final String modId = (String)ad.getAnnotationData().getOrDefault("modid", modids.getOrDefault(ad.getClassType().getClassName(), mod.getModId())); - final ModAnnotation.EnumHolder busTargetHolder = (ModAnnotation.EnumHolder)ad.getAnnotationData().getOrDefault("bus", new ModAnnotation.EnumHolder(null, "FORGE")); + final String modId = (String)ad.annotationData().getOrDefault("modid", modids.getOrDefault(ad.clazz().getClassName(), mod.getModId())); + final ModAnnotation.EnumHolder busTargetHolder = (ModAnnotation.EnumHolder)ad.annotationData().getOrDefault("bus", new ModAnnotation.EnumHolder(null, "FORGE")); final Mod.EventBusSubscriber.Bus busTarget = Mod.EventBusSubscriber.Bus.valueOf(busTargetHolder.getValue()); if (Objects.equals(mod.getModId(), modId) && sides.contains(FMLEnvironment.dist)) { try { - LOGGER.debug(LOADING, "Auto-subscribing {} to {}", ad.getClassType().getClassName(), busTarget); - busTarget.bus().get().register(Class.forName(ad.getClassType().getClassName(), true, loader)); + LOGGER.debug(LOADING, "Auto-subscribing {} to {}", ad.clazz().getClassName(), busTarget); + busTarget.bus().get().register(Class.forName(ad.clazz().getClassName(), true, loader)); } catch (ClassNotFoundException e) { - LOGGER.fatal(LOADING, "Failed to load mod class {} for @EventBusSubscriber annotation", ad.getClassType(), e); + LOGGER.fatal(LOADING, "Failed to load mod class {} for @EventBusSubscriber annotation", ad.clazz(), e); throw new RuntimeException(e); } } diff --git a/src/main/java/net/minecraftforge/fml/javafmlmod/FMLJavaModLanguageProvider.java b/javafmllanguage/src/main/java/net/minecraftforge/fml/javafmlmod/FMLJavaModLanguageProvider.java similarity index 74% rename from src/main/java/net/minecraftforge/fml/javafmlmod/FMLJavaModLanguageProvider.java rename to javafmllanguage/src/main/java/net/minecraftforge/fml/javafmlmod/FMLJavaModLanguageProvider.java index c19e724f6a..20b3201289 100644 --- a/src/main/java/net/minecraftforge/fml/javafmlmod/FMLJavaModLanguageProvider.java +++ b/javafmllanguage/src/main/java/net/minecraftforge/fml/javafmlmod/FMLJavaModLanguageProvider.java @@ -22,7 +22,6 @@ package net.minecraftforge.fml.javafmlmod; import cpw.mods.modlauncher.api.LamdbaExceptionUtils; import net.minecraftforge.fml.ModLoadingException; import net.minecraftforge.fml.ModLoadingStage; -import net.minecraftforge.fml.common.Mod; import net.minecraftforge.forgespi.language.ILifecycleEvent; import net.minecraftforge.forgespi.language.IModLanguageProvider; import net.minecraftforge.forgespi.language.IModInfo; @@ -39,7 +38,8 @@ import java.util.function.Function; import java.util.function.Supplier; import java.util.stream.Collectors; -import static net.minecraftforge.fml.Logging.*; +import static net.minecraftforge.fml.Logging.SCAN; +import static net.minecraftforge.fml.Logging.LOADING; public class FMLJavaModLanguageProvider implements IModLanguageProvider { @@ -63,7 +63,7 @@ public class FMLJavaModLanguageProvider implements IModLanguageProvider @SuppressWarnings("unchecked") @Override - public T loadMod(final IModInfo info, final ClassLoader modClassLoader, final ModFileScanData modFileScanResults) + public T loadMod(final IModInfo info, final ModFileScanData modFileScanResults, ModuleLayer gameLayer) { // This language class is loaded in the system level classloader - before the game even starts // So we must treat container construction as an arms length operation, and load the container @@ -72,19 +72,15 @@ public class FMLJavaModLanguageProvider implements IModLanguageProvider { final Class fmlContainer = Class.forName("net.minecraftforge.fml.javafmlmod.FMLModContainer", true, Thread.currentThread().getContextClassLoader()); LOGGER.debug(LOADING, "Loading FMLModContainer from classloader {} - got {}", Thread.currentThread().getContextClassLoader(), fmlContainer.getClassLoader()); - final Constructor constructor = fmlContainer.getConstructor(IModInfo.class, String.class, ClassLoader.class, ModFileScanData.class); - return (T)constructor.newInstance(info, className, modClassLoader, modFileScanResults); + final Constructor constructor = fmlContainer.getConstructor(IModInfo.class, String.class, ModFileScanData.class, ModuleLayer.class); + return (T)constructor.newInstance(info, className, modFileScanResults, gameLayer); } - // ALL exception handling has to be done through the classloader, because we're loaded in the wrong context, so any classes we just blind load will be in the wrong - // class loading context. Funky but works. catch (InvocationTargetException e) { LOGGER.fatal(LOADING, "Failed to build mod", e); - final Class mle = (Class)LamdbaExceptionUtils.uncheck(()->Class.forName("net.minecraftforge.fml.ModLoadingException", true, Thread.currentThread().getContextClassLoader())); - if (mle.isInstance(e.getTargetException())) { - throw mle.cast(e.getTargetException()); + if (e.getTargetException() instanceof ModLoadingException mle) { + throw mle; } else { - final Class mls = (Class) LamdbaExceptionUtils.uncheck(()->Class.forName("net.minecraftforge.fml.ModLoadingStage", true, Thread.currentThread().getContextClassLoader())); - throw LamdbaExceptionUtils.uncheck(()->LamdbaExceptionUtils.uncheck(()->mle.getConstructor(IModInfo.class, mls, String.class, Throwable.class)).newInstance(info, Enum.valueOf(mls, "CONSTRUCT"), "fml.modloading.failedtoloadmodclass", e)); + throw new ModLoadingException(info, ModLoadingStage.CONSTRUCT, "fml.modloading.failedtoloadmodclass", e); } } catch (NoSuchMethodException | ClassNotFoundException | InstantiationException | IllegalAccessException e) @@ -109,9 +105,9 @@ public class FMLJavaModLanguageProvider implements IModLanguageProvider public Consumer getFileVisitor() { return scanResult -> { final Map modTargetMap = scanResult.getAnnotations().stream() - .filter(ad -> ad.getAnnotationType().equals(MODANNOTATION)) - .peek(ad -> LOGGER.debug(SCAN, "Found @Mod class {} with id {}", ad.getClassType().getClassName(), ad.getAnnotationData().get("value"))) - .map(ad -> new FMLModTarget(ad.getClassType().getClassName(), (String)ad.getAnnotationData().get("value"))) + .filter(ad -> ad.annotationType().equals(MODANNOTATION)) + .peek(ad -> LOGGER.debug(SCAN, "Found @Mod class {} with id {}", ad.clazz().getClassName(), ad.annotationData().get("value"))) + .map(ad -> new FMLModTarget(ad.clazz().getClassName(), (String)ad.annotationData().get("value"))) .collect(Collectors.toMap(FMLModTarget::getModId, Function.identity(), (a,b)->a)); scanResult.addLanguageLoader(modTargetMap); }; diff --git a/src/main/java/net/minecraftforge/fml/javafmlmod/FMLJavaModLoadingContext.java b/javafmllanguage/src/main/java/net/minecraftforge/fml/javafmlmod/FMLJavaModLoadingContext.java similarity index 100% rename from src/main/java/net/minecraftforge/fml/javafmlmod/FMLJavaModLoadingContext.java rename to javafmllanguage/src/main/java/net/minecraftforge/fml/javafmlmod/FMLJavaModLoadingContext.java diff --git a/src/main/java/net/minecraftforge/fml/javafmlmod/FMLModContainer.java b/javafmllanguage/src/main/java/net/minecraftforge/fml/javafmlmod/FMLModContainer.java similarity index 89% rename from src/main/java/net/minecraftforge/fml/javafmlmod/FMLModContainer.java rename to javafmllanguage/src/main/java/net/minecraftforge/fml/javafmlmod/FMLModContainer.java index 73eb3ee472..fbc81e76e1 100644 --- a/src/main/java/net/minecraftforge/fml/javafmlmod/FMLModContainer.java +++ b/javafmllanguage/src/main/java/net/minecraftforge/fml/javafmlmod/FMLModContainer.java @@ -24,11 +24,10 @@ import net.minecraftforge.eventbus.api.BusBuilder; import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.IEventListener; -import net.minecraftforge.fml.AutomaticEventSubscriber; import net.minecraftforge.fml.ModContainer; import net.minecraftforge.fml.ModLoadingException; import net.minecraftforge.fml.ModLoadingStage; -import net.minecraftforge.fml.event.lifecycle.IModBusEvent; +import net.minecraftforge.fml.event.IModBusEvent; import net.minecraftforge.forgespi.language.IModInfo; import net.minecraftforge.forgespi.language.ModFileScanData; import org.apache.logging.log4j.LogManager; @@ -36,7 +35,7 @@ import org.apache.logging.log4j.Logger; import java.util.Optional; -import static net.minecraftforge.fml.Logging.LOADING; +import static net.minecraftforge.fml.loading.LogMarkers.LOADING; public class FMLModContainer extends ModContainer { @@ -46,19 +45,20 @@ public class FMLModContainer extends ModContainer private Object modInstance; private final Class modClass; - public FMLModContainer(IModInfo info, String className, ClassLoader modClassLoader, ModFileScanData modFileScanResults) + public FMLModContainer(IModInfo info, String className, ModFileScanData modFileScanResults, ModuleLayer gameLayer) { super(info); - LOGGER.debug(LOADING,"Creating FMLModContainer instance for {} with classLoader {} & {}", className, modClassLoader, getClass().getClassLoader()); + LOGGER.debug(LOADING,"Creating FMLModContainer instance for {}", className); this.scanResults = modFileScanResults; activityMap.put(ModLoadingStage.CONSTRUCT, this::constructMod); this.eventBus = BusBuilder.builder().setExceptionHandler(this::onEventFailed).setTrackPhases(false).markerType(IModBusEvent.class).build(); - this.configHandler = Optional.of(this.eventBus::post); + this.configHandler = Optional.of(ce->this.eventBus.post(ce.self())); final FMLJavaModLoadingContext contextExtension = new FMLJavaModLoadingContext(this); this.contextExtension = () -> contextExtension; try { - modClass = Class.forName(className, true, modClassLoader); + var layer = gameLayer.findModule(info.getOwningFile().moduleName()).orElseThrow(); + modClass = Class.forName(layer, className); LOGGER.trace(LOADING,"Loaded modclass {} with {}", modClass.getName(), modClass.getClassLoader()); } catch (Throwable e) @@ -78,7 +78,7 @@ public class FMLModContainer extends ModContainer try { LOGGER.trace(LOADING, "Loading mod instance {} of type {}", getModId(), modClass.getName()); - this.modInstance = modClass.newInstance(); + this.modInstance = modClass.getDeclaredConstructor().newInstance(); LOGGER.trace(LOADING, "Loaded mod instance {} of type {}", getModId(), modClass.getName()); } catch (Throwable e) diff --git a/javafmllanguage/src/main/resources/META-INF/services/net.minecraftforge.forgespi.language.IModLanguageProvider b/javafmllanguage/src/main/resources/META-INF/services/net.minecraftforge.forgespi.language.IModLanguageProvider new file mode 100644 index 0000000000..0323191ff0 --- /dev/null +++ b/javafmllanguage/src/main/resources/META-INF/services/net.minecraftforge.forgespi.language.IModLanguageProvider @@ -0,0 +1 @@ +net.minecraftforge.fml.javafmlmod.FMLJavaModLanguageProvider diff --git a/mclanguage/build.gradle b/mclanguage/build.gradle new file mode 100644 index 0000000000..2c04060d70 --- /dev/null +++ b/mclanguage/build.gradle @@ -0,0 +1,63 @@ +plugins { + id 'com.github.ben-manes.versions' + id 'org.javamodularity.moduleplugin' version '1.8.3' apply false +} +apply plugin: 'java-library' +apply plugin: 'jacoco' +apply plugin: 'org.javamodularity.moduleplugin' + +dependencyUpdates.rejectVersionIf { isNonStable(it.candidate.version) } + +dependencies { + compileOnly('org.jetbrains:annotations:21.0.1') + implementation(project(':fmlloader')) + implementation(project(':fmlcore')) +} + +task sourcesJar(type: Jar) { + archiveClassifier = 'sources' + from sourceSets.main.allSource +} + +ext { + MANIFESTS = [ + '': [ + 'FMLModType': 'LANGPROVIDER', + 'Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), + 'Git-Commit': GIT_INFO.abbreviatedId, + 'Git-Branch': GIT_INFO.branch, + 'Build-Number': "${System.getenv('BUILD_NUMBER')?:0}", + ] as LinkedHashMap, + 'net/minecraftforge/fml/mclanguageprovider/': [ + 'Specification-Title': 'FMLLoader', + 'Specification-Vendor': 'Forge Development LLC', + 'Specification-Version': '1', + 'Implementation-Title': 'FML Loader', + 'Implementation-Version': '1.0', + 'Implementation-Vendor': 'Forge' + ] as LinkedHashMap + ] +} + +jar.doFirst { + MANIFESTS.each { pkg, values -> + if (pkg == '') + manifest.attributes(values) + else + manifest.attributes(values, pkg) + } +} + +tasks.withType(JavaCompile) { + options.compilerArgs << '-Xlint:unchecked' +} + +artifacts { + archives jar + archives sourcesJar +} + +publishing.publications.mavenJava(MavenPublication) { + from components.java + artifact sourcesJar +} \ No newline at end of file diff --git a/mclanguage/src/main/java/net/minecraftforge/fml/mclanguageprovider/MinecraftModContainer.java b/mclanguage/src/main/java/net/minecraftforge/fml/mclanguageprovider/MinecraftModContainer.java new file mode 100644 index 0000000000..e4b952bf69 --- /dev/null +++ b/mclanguage/src/main/java/net/minecraftforge/fml/mclanguageprovider/MinecraftModContainer.java @@ -0,0 +1,25 @@ +package net.minecraftforge.fml.mclanguageprovider; + +import net.minecraftforge.fml.ModContainer; +import net.minecraftforge.forgespi.language.IModInfo; + +import java.util.Objects; + +public class MinecraftModContainer extends ModContainer { + private static final String MCMODINSTANCE = "minecraft, the mod"; + + public MinecraftModContainer(final IModInfo info) { + super(info); + contextExtension = () -> null; + } + + @Override + public boolean matches(final Object mod) { + return Objects.equals(mod, MCMODINSTANCE); + } + + @Override + public Object getMod() { + return MCMODINSTANCE; + } +} diff --git a/src/main/java/net/minecraftforge/fml/mclanguageprovider/MinecraftModLanguageProvider.java b/mclanguage/src/main/java/net/minecraftforge/fml/mclanguageprovider/MinecraftModLanguageProvider.java similarity index 69% rename from src/main/java/net/minecraftforge/fml/mclanguageprovider/MinecraftModLanguageProvider.java rename to mclanguage/src/main/java/net/minecraftforge/fml/mclanguageprovider/MinecraftModLanguageProvider.java index 5597760b3a..5d9ad38476 100644 --- a/src/main/java/net/minecraftforge/fml/mclanguageprovider/MinecraftModLanguageProvider.java +++ b/mclanguage/src/main/java/net/minecraftforge/fml/mclanguageprovider/MinecraftModLanguageProvider.java @@ -28,7 +28,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.lang.reflect.InvocationTargetException; -import java.util.Collections; +import java.util.Map; import java.util.Objects; import java.util.function.Consumer; import java.util.function.Supplier; @@ -46,7 +46,7 @@ public class MinecraftModLanguageProvider implements IModLanguageProvider { @Override public Consumer getFileVisitor() { - return (sd)->sd.addLanguageLoader(Collections.singletonMap("minecraft", new MinecraftModTarget())); + return (sd)->sd.addLanguageLoader(Map.of("minecraft", new MinecraftModTarget())); } @Override @@ -57,32 +57,15 @@ public class MinecraftModLanguageProvider implements IModLanguageProvider { public static class MinecraftModTarget implements IModLanguageLoader { @SuppressWarnings("unchecked") @Override - public T loadMod(final IModInfo info, final ClassLoader modClassLoader, final ModFileScanData modFileScanResults) { + public T loadMod(final IModInfo info, final ModFileScanData modFileScanResults, final ModuleLayer gameLayer) { try { - final Class mcModClass = Class.forName("net.minecraftforge.fml.mclanguageprovider.MinecraftModLanguageProvider$MinecraftModContainer", true, modClassLoader); + var module = gameLayer.findModule("minecraft").orElseThrow(); + final Class mcModClass = Class.forName(getClass().getModule(), "net.minecraftforge.fml.mclanguageprovider.MinecraftModContainer"); return (T)mcModClass.getConstructor(IModInfo.class).newInstance(info); - } catch (InstantiationException | IllegalAccessException | ClassNotFoundException | NoSuchMethodException | InvocationTargetException e) { + } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { LOGGER.fatal(LOADING,"Unable to load MinecraftModContainer, wut?", e); throw new RuntimeException(e); } } } - public static class MinecraftModContainer extends ModContainer { - private static final String MCMODINSTANCE = "minecraft, the mod"; - - public MinecraftModContainer(final IModInfo info) { - super(info); - contextExtension = ()->null; - } - - @Override - public boolean matches(final Object mod) { - return Objects.equals(mod, MCMODINSTANCE); - } - - @Override - public Object getMod() { - return MCMODINSTANCE; - } - } } diff --git a/mclanguage/src/main/resources/META-INF/services/net.minecraftforge.forgespi.language.IModLanguageProvider b/mclanguage/src/main/resources/META-INF/services/net.minecraftforge.forgespi.language.IModLanguageProvider new file mode 100644 index 0000000000..402686af66 --- /dev/null +++ b/mclanguage/src/main/resources/META-INF/services/net.minecraftforge.forgespi.language.IModLanguageProvider @@ -0,0 +1 @@ +net.minecraftforge.fml.mclanguageprovider.MinecraftModLanguageProvider diff --git a/mdk/build.gradle b/mdk/build.gradle index 17e2f9ba27..2cd5253ed4 100644 --- a/mdk/build.gradle +++ b/mdk/build.gradle @@ -1,5 +1,6 @@ buildscript { repositories { + // These repositories are only for Gradle plugins, put any other repositories in the repository block further below maven { url = 'https://maven.minecraftforge.net' } mavenCentral() } @@ -16,11 +17,12 @@ version = '1.0' group = 'com.yourname.modid' // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = 'modid' -java.toolchain.languageVersion = JavaLanguageVersion.of(8) // Mojang ships Java 8 to end users, so your mod should target Java 8. +// Mojang ships Java 16 to end users in 1.17+ instead of Java 8 in 1.16 or lower, so your mod should target Java 16. +java.toolchain.languageVersion = JavaLanguageVersion.of(16) println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch')) minecraft { - // The mappings can be changed at any time, and must be in the following format. + // The mappings can be changed at any time and must be in the following format. // Channel: Version: // snapshot YYYYMMDD Snapshot are built nightly. // stable # Stables are built at the discretion of the MCP team. @@ -29,12 +31,11 @@ minecraft { // You must be aware of the Mojang license when using the 'official' mappings. // See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md // - // Use non-default mappings at your own risk. they may not always work. + // Use non-default mappings at your own risk. They may not always work. // Simply re-run your setup task after changing the mappings to update your workspace. mappings channel: '@MAPPING_CHANNEL@', version: '@MAPPING_VERSION@' - // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. - - // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') + + // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // Currently, this location cannot be changed from the default. // Default run configurations. // These can be tweaked, removed, or duplicated as needed. @@ -43,7 +44,7 @@ minecraft { workingDirectory project.file('run') // Recommended logging data for a userdev environment - // The markers can be changed as needed. + // The markers can be added/remove as needed separated by commas. // "SCAN": For mods scan. // "REGISTRIES": For firing of registry events. // "REGISTRYDUMP": For getting the contents of all registries. @@ -65,7 +66,7 @@ minecraft { workingDirectory project.file('run') // Recommended logging data for a userdev environment - // The markers can be changed as needed. + // The markers can be added/remove as needed separated by commas. // "SCAN": For mods scan. // "REGISTRIES": For firing of registry events. // "REGISTRYDUMP": For getting the contents of all registries. @@ -87,7 +88,7 @@ minecraft { workingDirectory project.file('run') // Recommended logging data for a userdev environment - // The markers can be changed as needed. + // The markers can be added/remove as needed separated by commas. // "SCAN": For mods scan. // "REGISTRIES": For firing of registry events. // "REGISTRYDUMP": For getting the contents of all registries. @@ -113,52 +114,55 @@ minecraft { // Include resources generated by data generators. sourceSets.main.resources { srcDir 'src/generated/resources' } +repositories { + // Put repositories for dependencies here + // ForgeGradle automatically adds the Forge maven and Maven Central for you + + // If you have mod jar dependencies in ./libs, you can declare them as a repository like so: + // flatDir { + // dir 'libs' + // } +} + dependencies { - // Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed - // that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied. + // Specify the version of Minecraft to use. If this is any group other than 'net.minecraft', it is assumed + // that the dep is a ForgeGradle 'patcher' dependency, and its patches will be applied. // The userdev artifact is a special name and will get all sorts of transformations applied to it. minecraft '@FORGE_GROUP@:@FORGE_NAME@:@FORGE_VERSION@' - // You may put jars on which you depend on in ./libs or you may define them like so.. - // compile "some.group:artifact:version:classifier" - // compile "some.group:artifact:version" + // Real mod deobf dependency examples - these get remapped to your current mappings + // compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") // Adds JEI API as a compile dependency + // runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}") // Adds the full JEI mod as a runtime dependency + // implementation fg.deobf("com.tterrag.registrate:Registrate:MC${mc_version}-${registrate_version}") // Adds registrate as a dependency - // Real examples - // compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env - // compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env - - // The 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime. - // provided 'com.mod-buildcraft:buildcraft:6.0.8:dev' - - // These dependencies get remapped to your current MCP mappings - // deobf 'com.mod-buildcraft:buildcraft:6.0.8:dev' + // Examples using mod jars from ./libs + // implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}") // For more info... // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html // http://www.gradle.org/docs/current/userguide/dependency_management.html - } -// Example for how to get properties into the manifest for reading by the runtime.. +// Example for how to get properties into the manifest for reading at runtime. jar { manifest { attributes([ - "Specification-Title": "examplemod", - "Specification-Vendor": "examplemodsareus", - "Specification-Version": "1", // We are version 1 of ourselves - "Implementation-Title": project.name, - "Implementation-Version": "${version}", - "Implementation-Vendor" :"examplemodsareus", - "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") + "Specification-Title" : "examplemod", + "Specification-Vendor" : "examplemodsareus", + "Specification-Version" : "1", // We are version 1 of ourselves + "Implementation-Title" : project.name, + "Implementation-Version" : project.jar.archiveVersion, + "Implementation-Vendor" : "examplemodsareus", + "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") ]) } } -// Example configuration to allow publishing using the maven-publish task +// Example configuration to allow publishing using the maven-publish plugin // This is the preferred method to reobfuscate your jar file -jar.finalizedBy('reobfJar') +jar.finalizedBy('reobfJar') // However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing -//publish.dependsOn('reobfJar') +// publish.dependsOn('reobfJar') publishing { publications { @@ -168,7 +172,7 @@ publishing { } repositories { maven { - url "file:///${project.projectDir}/mcmodsrepo" + url "file://${project.projectDir}/mcmodsrepo" } } } diff --git a/mdk/src/main/java/com/example/examplemod/ExampleMod.java b/mdk/src/main/java/com/example/examplemod/ExampleMod.java index b96f36ae21..b7443262c0 100644 --- a/mdk/src/main/java/com/example/examplemod/ExampleMod.java +++ b/mdk/src/main/java/com/example/examplemod/ExampleMod.java @@ -1,17 +1,16 @@ package com.example.examplemod; -import net.minecraft.block.Block; -import net.minecraft.block.Blocks; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.InterModComms; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent; import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent; -import net.minecraftforge.fml.event.server.FMLServerStartingEvent; +import net.minecraftforge.fmlserverevents.FMLServerStartingEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -32,8 +31,6 @@ public class ExampleMod FMLJavaModLoadingContext.get().getModEventBus().addListener(this::enqueueIMC); // Register the processIMC method for modloading FMLJavaModLoadingContext.get().getModEventBus().addListener(this::processIMC); - // Register the doClientStuff method for modloading - FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff); // Register ourselves for server and other game events we are interested in MinecraftForge.EVENT_BUS.register(this); @@ -46,11 +43,6 @@ public class ExampleMod LOGGER.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName()); } - private void doClientStuff(final FMLClientSetupEvent event) { - // do something that can only be done on the client - LOGGER.info("Got game settings {}", event.getMinecraftSupplier().get().options); - } - private void enqueueIMC(final InterModEnqueueEvent event) { // some example code to dispatch IMC to another mod @@ -61,7 +53,7 @@ public class ExampleMod { // some example code to receive and process InterModComms from other mods LOGGER.info("Got IMC {}", event.getIMCStream(). - map(m->m.getMessageSupplier().get()). + map(m->m.messageSupplier().get()). collect(Collectors.toList())); } // You can use SubscribeEvent and let the Event Bus discover methods to call diff --git a/patches/minecraft/com/mojang/blaze3d/pipeline/RenderTarget.java.patch b/patches/minecraft/com/mojang/blaze3d/pipeline/RenderTarget.java.patch new file mode 100644 index 0000000000..910e5a4df4 --- /dev/null +++ b/patches/minecraft/com/mojang/blaze3d/pipeline/RenderTarget.java.patch @@ -0,0 +1,56 @@ +--- a/com/mojang/blaze3d/pipeline/RenderTarget.java ++++ b/com/mojang/blaze3d/pipeline/RenderTarget.java +@@ -112,7 +_,10 @@ + GlStateManager.m_84331_(3553, 34892, 0); + GlStateManager.m_84331_(3553, 10242, 33071); + GlStateManager.m_84331_(3553, 10243, 33071); ++ if (!stencilEnabled) + GlStateManager.m_84209_(3553, 0, 6402, this.f_83915_, this.f_83916_, 0, 6402, 5126, (IntBuffer)null); ++ else ++ GlStateManager.m_84209_(3553, 0, org.lwjgl.opengl.GL30.GL_DEPTH32F_STENCIL8, this.f_83915_, this.f_83916_, 0, org.lwjgl.opengl.GL30.GL_DEPTH_STENCIL, org.lwjgl.opengl.GL30.GL_FLOAT_32_UNSIGNED_INT_24_8_REV, null); + } + + this.m_83936_(9728); +@@ -123,7 +_,14 @@ + GlStateManager.m_84486_(36160, this.f_83920_); + GlStateManager.m_84173_(36160, 36064, 3553, this.f_83923_, 0); + if (this.f_83919_) { ++ if(!stencilEnabled) + GlStateManager.m_84173_(36160, 36096, 3553, this.f_83924_, 0); ++ else if(net.minecraftforge.common.ForgeConfig.CLIENT.useCombinedDepthStencilAttachment.get()) { ++ GlStateManager.m_84173_(org.lwjgl.opengl.GL30.GL_FRAMEBUFFER, org.lwjgl.opengl.GL30.GL_DEPTH_STENCIL_ATTACHMENT, 3553, this.f_83924_, 0); ++ } else { ++ GlStateManager.m_84173_(org.lwjgl.opengl.GL30.GL_FRAMEBUFFER, org.lwjgl.opengl.GL30.GL_DEPTH_ATTACHMENT, 3553, this.f_83924_, 0); ++ GlStateManager.m_84173_(org.lwjgl.opengl.GL30.GL_FRAMEBUFFER, org.lwjgl.opengl.GL30.GL_STENCIL_ATTACHMENT, 3553, this.f_83924_, 0); ++ } + } + + this.m_83949_(); +@@ -292,4 +_,27 @@ + public int m_83980_() { + return this.f_83924_; + } ++ ++ /*================================ FORGE START ================================================*/ ++ private boolean stencilEnabled = false; ++ /** ++ * Attempts to enable 8 bits of stencil buffer on this FrameBuffer. ++ * Modders must call this directly to set things up. ++ * This is to prevent the default cause where graphics cards do not support stencil bits. ++ * Make sure to call this on the main render thread! ++ */ ++ public void enableStencil() { ++ if(stencilEnabled) return; ++ stencilEnabled = true; ++ this.m_83941_(f_83917_, f_83918_, net.minecraft.client.Minecraft.f_91002_); ++ } ++ ++ /** ++ * Returns wither or not this FBO has been successfully initialized with stencil bits. ++ * If not, and a modder wishes it to be, they must call enableStencil. ++ */ ++ public boolean isStencilEnabled() { ++ return this.stencilEnabled; ++ } ++ /*================================ FORGE END ================================================*/ + } diff --git a/patches/minecraft/com/mojang/blaze3d/platform/GlStateManager.java.patch b/patches/minecraft/com/mojang/blaze3d/platform/GlStateManager.java.patch index 9a19d82d6e..a9a727160f 100644 --- a/patches/minecraft/com/mojang/blaze3d/platform/GlStateManager.java.patch +++ b/patches/minecraft/com/mojang/blaze3d/platform/GlStateManager.java.patch @@ -1,20 +1,19 @@ --- a/com/mojang/blaze3d/platform/GlStateManager.java +++ b/com/mojang/blaze3d/platform/GlStateManager.java -@@ -572,10 +_,17 @@ - GL13.glClientActiveTexture(p_227747_0_); +@@ -530,9 +_,16 @@ + f_84077_[f_84076_].f_84800_ = false; } + /* Stores the last values sent into glMultiTexCoord2f */ + public static float lastBrightnessX = 0.0f; + public static float lastBrightnessY = 0.0f; - @Deprecated - public static void func_227640_a_(int p_227640_0_, float p_227640_1_, float p_227640_2_) { - RenderSystem.assertThread(RenderSystem::isOnRenderThread); - GL13.glMultiTexCoord2f(p_227640_0_, p_227640_1_, p_227640_2_); -+ if (p_227640_0_ == GL13.GL_TEXTURE1) { -+ lastBrightnessX = p_227640_1_; -+ lastBrightnessY = p_227640_2_; + public static void m_84160_(int p_84161_, int p_84162_, float p_84163_) { + RenderSystem.m_69393_(RenderSystem::m_69587_); + GL11.glTexParameterf(p_84161_, p_84162_, p_84163_); ++ if (p_84161_ == GL13.GL_TEXTURE1) { ++ lastBrightnessX = p_84162_; ++ lastBrightnessY = p_84163_; + } } - public static void func_227706_d_(int p_227706_0_, int p_227706_1_, int p_227706_2_, int p_227706_3_) { + public static void m_84331_(int p_84332_, int p_84333_, int p_84334_) { diff --git a/patches/minecraft/com/mojang/blaze3d/platform/Window.java.patch b/patches/minecraft/com/mojang/blaze3d/platform/Window.java.patch new file mode 100644 index 0000000000..2bdeee4402 --- /dev/null +++ b/patches/minecraft/com/mojang/blaze3d/platform/Window.java.patch @@ -0,0 +1,19 @@ +--- a/com/mojang/blaze3d/platform/Window.java ++++ b/com/mojang/blaze3d/platform/Window.java +@@ -81,7 +_,7 @@ + GLFW.glfwWindowHint(139267, 2); + GLFW.glfwWindowHint(139272, 204801); + GLFW.glfwWindowHint(139270, 1); +- this.f_85349_ = GLFW.glfwCreateWindow(this.f_85359_, this.f_85360_, p_85376_, this.f_85355_ && monitor != null ? monitor.m_84954_() : 0L, 0L); ++ this.f_85349_ = net.minecraftforge.fml.loading.progress.EarlyProgressVisualization.INSTANCE.handOffWindow(()->this.f_85359_, ()->this.f_85360_, ()->p_85376_, ()->this.f_85355_ && monitor != null ? monitor.m_84954_() : 0L); + 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; +@@ -299,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; ++ if (this.f_85362_ == 0 || this.f_85361_==0) net.minecraftforge.fml.loading.progress.EarlyProgressVisualization.INSTANCE.updateFBSize(w->this.f_85361_=w, h->this.f_85362_=h); + } + + private void m_85427_(long p_85428_, int p_85429_, int p_85430_) { diff --git a/patches/minecraft/com/mojang/blaze3d/vertex/BufferBuilder.java.patch b/patches/minecraft/com/mojang/blaze3d/vertex/BufferBuilder.java.patch new file mode 100644 index 0000000000..f9feac5e30 --- /dev/null +++ b/patches/minecraft/com/mojang/blaze3d/vertex/BufferBuilder.java.patch @@ -0,0 +1,26 @@ +--- a/com/mojang/blaze3d/vertex/BufferBuilder.java ++++ b/com/mojang/blaze3d/vertex/BufferBuilder.java +@@ -332,6 +_,7 @@ + } + + ByteBuffer bytebuffer = this.f_85648_.slice(); ++ bytebuffer.order(this.f_85648_.order()); // FORGE: Fix incorrect byte order + this.f_85648_.clear(); + return Pair.of(bufferbuilder$drawstate, bytebuffer); + } +@@ -444,4 +_,15 @@ + this.f_166822_ = p_166829_; + } + } ++ ++ // Forge start ++ public void putBulkData(ByteBuffer buffer) { ++ m_85722_(buffer.limit() + this.f_85658_.m_86020_()); ++ this.f_85648_.position(this.f_85654_ * this.f_85658_.m_86020_()); ++ this.f_85648_.put(buffer); ++ this.f_85654_ += buffer.limit() / this.f_85658_.m_86020_(); ++ this.f_85652_ += buffer.limit(); ++ } ++ ++ public VertexFormat getVertexFormat() { return this.f_85658_; } + } diff --git a/patches/minecraft/com/mojang/blaze3d/vertex/IVertexBuilder.java.patch b/patches/minecraft/com/mojang/blaze3d/vertex/IVertexBuilder.java.patch deleted file mode 100644 index 8fa6655019..0000000000 --- a/patches/minecraft/com/mojang/blaze3d/vertex/IVertexBuilder.java.patch +++ /dev/null @@ -1,25 +0,0 @@ ---- a/com/mojang/blaze3d/vertex/IVertexBuilder.java -+++ b/com/mojang/blaze3d/vertex/IVertexBuilder.java -@@ -18,7 +_,7 @@ - import org.lwjgl.system.MemoryStack; - - @OnlyIn(Dist.CLIENT) --public interface IVertexBuilder { -+public interface IVertexBuilder extends net.minecraftforge.client.extensions.IForgeVertexBuilder { - Logger field_227884_f_ = LogManager.getLogger(); - - IVertexBuilder func_225582_a_(double p_225582_1_, double p_225582_3_, double p_225582_5_); -@@ -96,11 +_,12 @@ - f5 = p_227890_3_[k] * p_227890_6_; - } - -- int l = p_227890_7_[k]; -+ int l = applyBakedLighting(p_227890_7_[k], bytebuffer); - float f9 = bytebuffer.getFloat(16); - float f10 = bytebuffer.getFloat(20); - Vector4f vector4f = new Vector4f(f, f1, f2, 1.0F); - vector4f.func_229372_a_(matrix4f); -+ applyBakedNormals(vector3f, bytebuffer, p_227890_1_.func_227872_b_()); - this.func_225588_a_(vector4f.func_195910_a(), vector4f.func_195913_b(), vector4f.func_195914_c(), f3, f4, f5, 1.0F, f9, f10, p_227890_8_, l, vector3f.func_195899_a(), vector3f.func_195900_b(), vector3f.func_195902_c()); - } - } diff --git a/patches/minecraft/com/mojang/blaze3d/vertex/VertexConsumer.java.patch b/patches/minecraft/com/mojang/blaze3d/vertex/VertexConsumer.java.patch new file mode 100644 index 0000000000..f9af58b4e4 --- /dev/null +++ b/patches/minecraft/com/mojang/blaze3d/vertex/VertexConsumer.java.patch @@ -0,0 +1,25 @@ +--- a/com/mojang/blaze3d/vertex/VertexConsumer.java ++++ b/com/mojang/blaze3d/vertex/VertexConsumer.java +@@ -15,7 +_,7 @@ + import org.lwjgl.system.MemoryStack; + + @OnlyIn(Dist.CLIENT) +-public interface VertexConsumer { ++public interface VertexConsumer extends net.minecraftforge.client.extensions.IForgeVertexConsumer { + Logger f_85943_ = LogManager.getLogger(); + + VertexConsumer m_5483_(double p_85945_, double p_85946_, double p_85947_); +@@ -100,11 +_,12 @@ + f5 = afloat[k] * p_86001_; + } + +- int l = aint[k]; ++ int l = applyBakedLighting(p_86002_[k], bytebuffer); + float f9 = bytebuffer.getFloat(16); + float f10 = bytebuffer.getFloat(20); + Vector4f vector4f = new Vector4f(f, f1, f2, 1.0F); + vector4f.m_123607_(matrix4f); ++ applyBakedNormals(vector3f, bytebuffer, p_85996_.m_85864_()); + this.m_5954_(vector4f.m_123601_(), vector4f.m_123615_(), vector4f.m_123616_(), f3, f4, f5, 1.0F, f9, f10, p_86003_, l, vector3f.m_122239_(), vector3f.m_122260_(), vector3f.m_122269_()); + } + } catch (Throwable throwable1) { diff --git a/patches/minecraft/com/mojang/blaze3d/vertex/VertexFormat.java.patch b/patches/minecraft/com/mojang/blaze3d/vertex/VertexFormat.java.patch new file mode 100644 index 0000000000..2574be5e21 --- /dev/null +++ b/patches/minecraft/com/mojang/blaze3d/vertex/VertexFormat.java.patch @@ -0,0 +1,14 @@ +--- a/com/mojang/blaze3d/vertex/VertexFormat.java ++++ b/com/mojang/blaze3d/vertex/VertexFormat.java +@@ -195,4 +_,11 @@ + return i; + } + } ++ ++ public ImmutableMap getElementMapping() { return f_166905_; } ++ public int getOffset(int index) { return f_86013_.getInt(index); } ++ public boolean hasPosition() { return f_86012_.stream().anyMatch(e -> e.m_86048_() == VertexFormatElement.Usage.POSITION); } ++ public boolean hasNormal() { return f_86012_.stream().anyMatch(e -> e.m_86048_() == VertexFormatElement.Usage.NORMAL); } ++ public boolean hasColor() { return f_86012_.stream().anyMatch(e -> e.m_86048_() == VertexFormatElement.Usage.COLOR); } ++ public boolean hasUV(int which) { return f_86012_.stream().anyMatch(e -> e.m_86048_() == VertexFormatElement.Usage.UV && e.m_86049_() == which); } + } diff --git a/patches/minecraft/com/mojang/blaze3d/vertex/VertexFormatElement.java.patch b/patches/minecraft/com/mojang/blaze3d/vertex/VertexFormatElement.java.patch new file mode 100644 index 0000000000..f988836eec --- /dev/null +++ b/patches/minecraft/com/mojang/blaze3d/vertex/VertexFormatElement.java.patch @@ -0,0 +1,13 @@ +--- a/com/mojang/blaze3d/vertex/VertexFormatElement.java ++++ b/com/mojang/blaze3d/vertex/VertexFormatElement.java +@@ -90,6 +_,10 @@ + this.f_86031_.m_166978_(this.f_86032_, p_166964_); + } + ++ public int getElementCount() { ++ return f_86033_; ++ } ++ + @OnlyIn(Dist.CLIENT) + public static enum Type { + FLOAT(4, "Float", 5126), diff --git a/patches/minecraft/com/mojang/math/Matrix3f.java.patch b/patches/minecraft/com/mojang/math/Matrix3f.java.patch new file mode 100644 index 0000000000..cff8694e6e --- /dev/null +++ b/patches/minecraft/com/mojang/math/Matrix3f.java.patch @@ -0,0 +1,13 @@ +--- a/com/mojang/math/Matrix3f.java ++++ b/com/mojang/math/Matrix3f.java +@@ -588,4 +_,10 @@ + public Matrix3f m_8183_() { + return new Matrix3f(this); + } ++ ++ public void multiplyBackward(Matrix3f other) { ++ Matrix3f copy = other.m_8183_(); ++ copy.m_8178_(this); ++ this.m_8169_(copy); ++ } + } diff --git a/patches/minecraft/com/mojang/math/Matrix4f.java.patch b/patches/minecraft/com/mojang/math/Matrix4f.java.patch new file mode 100644 index 0000000000..634ccbc3a6 --- /dev/null +++ b/patches/minecraft/com/mojang/math/Matrix4f.java.patch @@ -0,0 +1,43 @@ +--- a/com/mojang/math/Matrix4f.java ++++ b/com/mojang/math/Matrix4f.java +@@ -559,4 +_,40 @@ + matrix4f.f_27614_ = p_27656_; + return matrix4f; + } ++ ++ // Forge start ++ public Matrix4f(float[] values) { ++ f_27603_ = values[0]; ++ f_27604_ = values[1]; ++ f_27605_ = values[2]; ++ f_27606_ = values[3]; ++ f_27607_ = values[4]; ++ f_27608_ = values[5]; ++ f_27609_ = values[6]; ++ f_27610_ = values[7]; ++ f_27611_ = values[8]; ++ f_27612_ = values[9]; ++ f_27613_ = values[10]; ++ f_27614_ = values[11]; ++ f_27615_ = values[12]; ++ f_27616_ = values[13]; ++ f_27617_ = values[14]; ++ f_27618_ = values[15]; ++ } ++ ++ public void multiplyBackward(Matrix4f other) { ++ Matrix4f copy = other.m_27658_(); ++ copy.m_27644_(this); ++ this.m_162210_(copy); ++ } ++ ++ public void setTranslation(float x, float y, float z) { ++ this.f_27603_ = 1.0F; ++ this.f_27608_ = 1.0F; ++ this.f_27613_ = 1.0F; ++ this.f_27618_ = 1.0F; ++ this.f_27606_ = x; ++ this.f_27610_ = y; ++ this.f_27614_ = z; ++ } + } diff --git a/patches/minecraft/com/mojang/math/Transformation.java.patch b/patches/minecraft/com/mojang/math/Transformation.java.patch new file mode 100644 index 0000000000..5188bb8569 --- /dev/null +++ b/patches/minecraft/com/mojang/math/Transformation.java.patch @@ -0,0 +1,31 @@ +--- a/com/mojang/math/Transformation.java ++++ b/com/mojang/math/Transformation.java +@@ -6,7 +_,7 @@ + import net.minecraft.Util; + import org.apache.commons.lang3.tuple.Triple; + +-public final class Transformation { ++public final class Transformation implements net.minecraftforge.client.extensions.IForgeTransformation { + private final Matrix4f f_121078_; + private boolean f_121079_; + @Nullable +@@ -145,6 +_,19 @@ + public int hashCode() { + return Objects.hash(this.f_121078_); + } ++ ++ private Matrix3f normalTransform = null; ++ public Matrix3f getNormalMatrix() { ++ checkNormalTransform(); ++ return normalTransform; ++ } ++ private void checkNormalTransform() { ++ if (normalTransform == null) { ++ normalTransform = new Matrix3f(f_121078_); ++ normalTransform.m_8187_(); ++ normalTransform.m_8155_(); ++ } ++ } + + public Transformation m_175937_(Transformation p_175938_, float p_175939_) { + Vector3f vector3f = this.m_175940_(); diff --git a/patches/minecraft/com/mojang/math/Vector3f.java.patch b/patches/minecraft/com/mojang/math/Vector3f.java.patch new file mode 100644 index 0000000000..726d301663 --- /dev/null +++ b/patches/minecraft/com/mojang/math/Vector3f.java.patch @@ -0,0 +1,19 @@ +--- a/com/mojang/math/Vector3f.java ++++ b/com/mojang/math/Vector3f.java +@@ -207,4 +_,16 @@ + public String toString() { + return "[" + this.f_122228_ + ", " + this.f_122229_ + ", " + this.f_122230_ + "]"; + } ++ ++ public Vector3f(float[] values) { ++ set(values); ++ } ++ public void set(float[] values) { ++ this.f_122228_ = values[0]; ++ this.f_122229_ = values[1]; ++ this.f_122230_ = values[2]; ++ } ++ public void setX(float x) { this.f_122228_ = x; } ++ public void setY(float y) { this.f_122229_ = y; } ++ public void setZ(float z) { this.f_122230_ = z; } + } diff --git a/patches/minecraft/com/mojang/math/Vector4f.java.patch b/patches/minecraft/com/mojang/math/Vector4f.java.patch new file mode 100644 index 0000000000..30c3e4dfc4 --- /dev/null +++ b/patches/minecraft/com/mojang/math/Vector4f.java.patch @@ -0,0 +1,18 @@ +--- a/com/mojang/math/Vector4f.java ++++ b/com/mojang/math/Vector4f.java +@@ -147,4 +_,15 @@ + public String toString() { + return "[" + this.f_123589_ + ", " + this.f_123590_ + ", " + this.f_123591_ + ", " + this.f_123592_ + "]"; + } ++ ++ public void set(float[] values) { ++ this.f_123589_ = values[0]; ++ this.f_123590_ = values[1]; ++ this.f_123591_ = values[2]; ++ this.f_123592_ = values[3]; ++ } ++ public void setX(float x) { this.f_123589_ = x; } ++ public void setY(float y) { this.f_123590_ = y; } ++ public void setZ(float z) { this.f_123591_ = z; } ++ public void setW(float w) { this.f_123592_ = w; } + } 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 c6b6802f69..67564ba3c7 100644 --- a/patches/minecraft/com/mojang/realmsclient/gui/screens/RealmsGenericErrorScreen.java.patch +++ b/patches/minecraft/com/mojang/realmsclient/gui/screens/RealmsGenericErrorScreen.java.patch @@ -1,18 +1,18 @@ --- a/com/mojang/realmsclient/gui/screens/RealmsGenericErrorScreen.java +++ b/com/mojang/realmsclient/gui/screens/RealmsGenericErrorScreen.java -@@ -63,6 +_,15 @@ - })); +@@ -69,6 +_,15 @@ + return (new TextComponent("")).m_7220_(this.f_88666_).m_130946_(": ").m_7220_(this.f_88667_); } + @Override -+ public boolean func_231046_a_(int key, int scanCode, int modifiers) { -+ if (key == org.lwjgl.glfw.GLFW.GLFW_KEY_ESCAPE) { -+ field_230706_i_.func_147108_a(this.field_224228_a); -+ return true; -+ } -+ return super.func_231046_a_(key, scanCode, modifiers); ++ public boolean m_7933_(int key, int scanCode, int modifiers) { ++ if (key == org.lwjgl.glfw.GLFW.GLFW_KEY_ESCAPE) { ++ f_96541_.m_91152_(this.f_88665_); ++ return true; ++ } ++ return super.m_7933_(key, scanCode, modifiers); + } + - public void func_230430_a_(MatrixStack p_230430_1_, int p_230430_2_, int p_230430_3_, float p_230430_4_) { - this.func_230446_a_(p_230430_1_); - func_238472_a_(p_230430_1_, this.field_230712_o_, this.field_224229_b, this.field_230708_k_ / 2, 80, 16777215); + public void m_6305_(PoseStack p_88679_, int p_88680_, int p_88681_, float p_88682_) { + this.m_7333_(p_88679_); + m_93215_(p_88679_, this.f_96547_, this.f_88666_, this.f_96543_ / 2, 80, 16777215); diff --git a/patches/minecraft/net/minecraft/CrashReport.java.patch b/patches/minecraft/net/minecraft/CrashReport.java.patch new file mode 100644 index 0000000000..e886c3c15d --- /dev/null +++ b/patches/minecraft/net/minecraft/CrashReport.java.patch @@ -0,0 +1,53 @@ +--- a/net/minecraft/CrashReport.java ++++ b/net/minecraft/CrashReport.java +@@ -55,14 +_,8 @@ + if (this.f_127506_ != null && this.f_127506_.length > 0) { + p_127520_.append("-- Head --\n"); + p_127520_.append("Thread: ").append(Thread.currentThread().getName()).append("\n"); +- p_127520_.append("Stacktrace:\n"); +- +- for(StackTraceElement stacktraceelement : this.f_127506_) { +- p_127520_.append("\t").append("at ").append((Object)stacktraceelement); +- p_127520_.append("\n"); +- } +- +- p_127520_.append("\n"); ++ p_127520_.append("Stacktrace:"); ++ p_127520_.append(net.minecraftforge.fmllegacy.CrashReportExtender.generateEnhancedStackTrace(this.f_127506_)); + } + + for(CrashReportCategory crashreportcategory : this.f_127503_) { +@@ -70,6 +_,7 @@ + p_127520_.append("\n\n"); + } + ++ net.minecraftforge.fmllegacy.CrashReportExtender.extendSystemReport(f_178624_); + this.f_178624_.m_143525_(p_127520_); + } + +@@ -89,23 +_,13 @@ + throwable.setStackTrace(this.f_127501_.getStackTrace()); + } + +- String s; +- try { +- stringwriter = new StringWriter(); +- printwriter = new PrintWriter(stringwriter); +- throwable.printStackTrace(printwriter); +- s = stringwriter.toString(); +- } finally { +- IOUtils.closeQuietly((Writer)stringwriter); +- IOUtils.closeQuietly((Writer)printwriter); +- } +- +- return s; ++ return net.minecraftforge.fmllegacy.CrashReportExtender.generateEnhancedStackTrace(throwable); + } + + public String m_127526_() { + StringBuilder stringbuilder = new StringBuilder(); + stringbuilder.append("---- Minecraft Crash Report ----\n"); ++ net.minecraftforge.fmllegacy.CrashReportExtender.addCrashReportHeader(stringbuilder, this); + stringbuilder.append("// "); + stringbuilder.append(m_127531_()); + stringbuilder.append("\n\n"); diff --git a/patches/minecraft/net/minecraft/CrashReportCategory.java.patch b/patches/minecraft/net/minecraft/CrashReportCategory.java.patch new file mode 100644 index 0000000000..b22560c5f4 --- /dev/null +++ b/patches/minecraft/net/minecraft/CrashReportCategory.java.patch @@ -0,0 +1,38 @@ +--- a/net/minecraft/CrashReportCategory.java ++++ b/net/minecraft/CrashReportCategory.java +@@ -102,8 +_,10 @@ + if (astacktraceelement.length <= 0) { + return 0; + } else { +- this.f_128139_ = new StackTraceElement[astacktraceelement.length - 3 - p_128149_]; +- System.arraycopy(astacktraceelement, 3 + p_128149_, this.f_128139_, 0, this.f_128139_.length); ++ int len = astacktraceelement.length - 3 - p_128149_; ++ if (len <= 0) len = astacktraceelement.length; ++ this.f_128139_ = new StackTraceElement[len]; ++ System.arraycopy(astacktraceelement, astacktraceelement.length - len, this.f_128139_, 0, this.f_128139_.length); + return this.f_128139_.length; + } + } +@@ -147,17 +_,17 @@ + + if (this.f_128139_ != null && this.f_128139_.length > 0) { + p_128169_.append("\nStacktrace:"); +- +- for(StackTraceElement stacktraceelement : this.f_128139_) { +- p_128169_.append("\n\tat "); +- p_128169_.append((Object)stacktraceelement); +- } ++ p_128169_.append(net.minecraftforge.fmllegacy.CrashReportExtender.generateEnhancedStackTrace(this.f_128139_)); + } + + } + + public StackTraceElement[] m_128143_() { + return this.f_128139_; ++ } ++ ++ public void applyStackTrace(Throwable t) { ++ this.f_128139_ = t.getStackTrace(); + } + + public static void m_178950_(CrashReportCategory p_178951_, LevelHeightAccessor p_178952_, BlockPos p_178953_, @Nullable BlockState p_178954_) { diff --git a/patches/minecraft/net/minecraft/SharedConstants.java.patch b/patches/minecraft/net/minecraft/SharedConstants.java.patch new file mode 100644 index 0000000000..5d5c13d006 --- /dev/null +++ b/patches/minecraft/net/minecraft/SharedConstants.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/SharedConstants.java ++++ b/net/minecraft/SharedConstants.java +@@ -160,6 +_,7 @@ + } + + static { ++ if (System.getProperty("io.netty.leakDetection.level") == null) // Forge: allow level to be manually specified + ResourceLeakDetector.setLevel(f_136180_); + CommandSyntaxException.ENABLE_COMMAND_STACK_TRACES = false; + CommandSyntaxException.BUILT_IN_EXCEPTIONS = new BrigadierExceptions(); diff --git a/patches/minecraft/net/minecraft/Util.java.patch b/patches/minecraft/net/minecraft/Util.java.patch new file mode 100644 index 0000000000..09a4df37e9 --- /dev/null +++ b/patches/minecraft/net/minecraft/Util.java.patch @@ -0,0 +1,21 @@ +--- a/net/minecraft/Util.java ++++ b/net/minecraft/Util.java +@@ -127,6 +_,9 @@ + return executorservice; + } + ++ // We add this inner class to compensate for Mojang's missing inner class and allow us to obf subsequent anon inner classes correctly. ++ @SuppressWarnings("unused") private static LongSupplier INNER_CLASS_SHIFT = new LongSupplier() { public long getAsLong() { return 0; } }; ++ + public static Executor m_137577_() { + return f_137443_; + } +@@ -205,7 +_,7 @@ + try { + type = DataFixers.m_14512_().getSchema(DataFixUtils.makeKey(SharedConstants.m_136187_().getWorldVersion())).getChoiceType(p_137552_, p_137553_); + } catch (IllegalArgumentException illegalargumentexception) { +- f_137446_.error("No data fixer registered for {}", (Object)p_137553_); ++ f_137446_.debug("No data fixer registered for {}", (Object)p_137553_); + if (SharedConstants.f_136183_) { + throw illegalargumentexception; + } diff --git a/patches/minecraft/net/minecraft/advancements/Advancement.java.patch b/patches/minecraft/net/minecraft/advancements/Advancement.java.patch index 88b3f7d0b5..bd2b709383 100644 --- a/patches/minecraft/net/minecraft/advancements/Advancement.java.patch +++ b/patches/minecraft/net/minecraft/advancements/Advancement.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/advancements/Advancement.java +++ b/net/minecraft/advancements/Advancement.java -@@ -309,6 +_,7 @@ +@@ -311,6 +_,7 @@ } - public static Advancement.Builder func_241043_a_(JsonObject p_241043_0_, ConditionArrayParser p_241043_1_) { -+ if ((p_241043_0_ = net.minecraftforge.common.crafting.ConditionalAdvancement.processConditional(p_241043_0_)) == null) return null; - ResourceLocation resourcelocation = p_241043_0_.has("parent") ? new ResourceLocation(JSONUtils.func_151200_h(p_241043_0_, "parent")) : null; - DisplayInfo displayinfo = p_241043_0_.has("display") ? DisplayInfo.func_192294_a(JSONUtils.func_152754_s(p_241043_0_, "display")) : null; - AdvancementRewards advancementrewards = p_241043_0_.has("rewards") ? AdvancementRewards.func_241096_a_(JSONUtils.func_152754_s(p_241043_0_, "rewards")) : AdvancementRewards.field_192114_a; + public static Advancement.Builder m_138380_(JsonObject p_138381_, DeserializationContext p_138382_) { ++ if ((p_138381_ = net.minecraftforge.common.crafting.ConditionalAdvancement.processConditional(p_138381_)) == 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_; diff --git a/patches/minecraft/net/minecraft/advancements/AdvancementList.java.patch b/patches/minecraft/net/minecraft/advancements/AdvancementList.java.patch index 0a7ad01d12..80436c26c0 100644 --- a/patches/minecraft/net/minecraft/advancements/AdvancementList.java.patch +++ b/patches/minecraft/net/minecraft/advancements/AdvancementList.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/advancements/AdvancementList.java +++ b/net/minecraft/advancements/AdvancementList.java -@@ -96,6 +_,7 @@ +@@ -90,6 +_,7 @@ } } -+ net.minecraftforge.common.AdvancementLoadFix.buildSortedTrees(this.field_192093_c); - field_192091_a.info("Loaded {} advancements", (int)this.field_192092_b.size()); ++ net.minecraftforge.common.AdvancementLoadFix.buildSortedTrees(this.f_139327_); + f_139325_.info("Loaded {} advancements", (int)this.f_139326_.size()); } diff --git a/patches/minecraft/net/minecraft/advancements/AdvancementManager.java.patch b/patches/minecraft/net/minecraft/advancements/AdvancementManager.java.patch deleted file mode 100644 index c75b745877..0000000000 --- a/patches/minecraft/net/minecraft/advancements/AdvancementManager.java.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/net/minecraft/advancements/AdvancementManager.java -+++ b/net/minecraft/advancements/AdvancementManager.java -@@ -36,6 +_,10 @@ - try { - JsonObject jsonobject = JSONUtils.func_151210_l(p_240923_3_, "advancement"); - Advancement.Builder advancement$builder = Advancement.Builder.func_241043_a_(jsonobject, new ConditionArrayParser(p_240923_2_, this.field_240922_d_)); -+ if (advancement$builder == null) { -+ field_192782_a.debug("Skipping loading advancement {} as it's conditions were not met", p_240923_2_); -+ return; -+ } - map.put(p_240923_2_, advancement$builder); - } catch (IllegalArgumentException | JsonParseException jsonparseexception) { - field_192782_a.error("Parsing error loading custom advancement {}: {}", p_240923_2_, jsonparseexception.getMessage()); diff --git a/patches/minecraft/net/minecraft/advancements/AdvancementRewards.java.patch b/patches/minecraft/net/minecraft/advancements/AdvancementRewards.java.patch index 5fa77a63f6..02b079c6a7 100644 --- a/patches/minecraft/net/minecraft/advancements/AdvancementRewards.java.patch +++ b/patches/minecraft/net/minecraft/advancements/AdvancementRewards.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/advancements/AdvancementRewards.java +++ b/net/minecraft/advancements/AdvancementRewards.java -@@ -39,7 +_,7 @@ +@@ -43,7 +_,7 @@ - public void func_192113_a(ServerPlayerEntity p_192113_1_) { - p_192113_1_.func_195068_e(this.field_192115_b); -- LootContext lootcontext = (new LootContext.Builder(p_192113_1_.func_71121_q())).func_216015_a(LootParameters.field_216281_a, p_192113_1_).func_216015_a(LootParameters.field_237457_g_, p_192113_1_.func_213303_ch()).func_216023_a(p_192113_1_.func_70681_au()).func_216022_a(LootParameterSets.field_216265_f); -+ LootContext lootcontext = (new LootContext.Builder(p_192113_1_.func_71121_q())).func_216015_a(LootParameters.field_216281_a, p_192113_1_).func_216015_a(LootParameters.field_237457_g_, p_192113_1_.func_213303_ch()).func_216023_a(p_192113_1_.func_70681_au()).func_186469_a(p_192113_1_.func_184817_da()).func_216022_a(LootParameterSets.field_216265_f); // FORGE: luck to LootContext + public void m_9989_(ServerPlayer p_9990_) { + p_9990_.m_6756_(this.f_9979_); +- LootContext lootcontext = (new LootContext.Builder(p_9990_.m_9236_())).m_78972_(LootContextParams.f_81455_, p_9990_).m_78972_(LootContextParams.f_81460_, p_9990_.m_20182_()).m_78977_(p_9990_.m_21187_()).m_78975_(LootContextParamSets.f_81418_); ++ LootContext lootcontext = (new LootContext.Builder(p_9990_.m_9236_())).m_78972_(LootContextParams.f_81455_, p_9990_).m_78972_(LootContextParams.f_81460_, p_9990_.m_20182_()).m_78977_(p_9990_.m_21187_()).m_78963_(p_9990_.m_36336_()).m_78975_(LootContextParamSets.f_81418_); // FORGE: luck to LootContext boolean flag = false; - for(ResourceLocation resourcelocation : this.field_192116_c) { + for(ResourceLocation resourcelocation : this.f_9980_) { diff --git a/patches/minecraft/net/minecraft/advancements/PlayerAdvancements.java.patch b/patches/minecraft/net/minecraft/advancements/PlayerAdvancements.java.patch deleted file mode 100644 index 5ddaa779b4..0000000000 --- a/patches/minecraft/net/minecraft/advancements/PlayerAdvancements.java.patch +++ /dev/null @@ -1,30 +0,0 @@ ---- a/net/minecraft/advancements/PlayerAdvancements.java -+++ b/net/minecraft/advancements/PlayerAdvancements.java -@@ -159,6 +_,10 @@ - } - - this.func_240920_c_(p_240921_1_); -+ -+ if (net.minecraftforge.common.ForgeConfig.SERVER.fixAdvancementLoading.get()) -+ net.minecraftforge.common.AdvancementLoadFix.loadVisibility(this, this.field_192759_g, this.field_192760_h, this.field_192758_f, this.field_192761_i, this::func_192738_c); -+ else - this.func_192752_d(); - this.func_240919_b_(p_240921_1_); - } -@@ -192,6 +_,8 @@ - } - - public boolean func_192750_a(Advancement p_192750_1_, String p_192750_2_) { -+ // Forge: don't grant advancements for fake players -+ if (this.field_192762_j instanceof net.minecraftforge.common.util.FakePlayer) return false; - boolean flag = false; - AdvancementProgress advancementprogress = this.func_192747_a(p_192750_1_); - boolean flag1 = advancementprogress.func_192105_a(); -@@ -204,6 +_,7 @@ - if (p_192750_1_.func_192068_c() != null && p_192750_1_.func_192068_c().func_193220_i() && this.field_192762_j.field_70170_p.func_82736_K().func_223586_b(GameRules.field_223620_w)) { - this.field_240917_e_.func_232641_a_(new TranslationTextComponent("chat.type.advancement." + p_192750_1_.func_192068_c().func_192291_d().func_192307_a(), this.field_192762_j.func_145748_c_(), p_192750_1_.func_193123_j()), ChatType.SYSTEM, Util.field_240973_b_); - } -+ net.minecraftforge.common.ForgeHooks.onAdvancement(this.field_192762_j, p_192750_1_); - } - } - diff --git a/patches/minecraft/net/minecraft/advancements/criterion/ItemPredicate.java.patch b/patches/minecraft/net/minecraft/advancements/critereon/ItemPredicate.java.patch similarity index 54% rename from patches/minecraft/net/minecraft/advancements/criterion/ItemPredicate.java.patch rename to patches/minecraft/net/minecraft/advancements/critereon/ItemPredicate.java.patch index 03996a8e0c..2b7a508b6c 100644 --- a/patches/minecraft/net/minecraft/advancements/criterion/ItemPredicate.java.patch +++ b/patches/minecraft/net/minecraft/advancements/critereon/ItemPredicate.java.patch @@ -1,27 +1,27 @@ ---- a/net/minecraft/advancements/criterion/ItemPredicate.java -+++ b/net/minecraft/advancements/criterion/ItemPredicate.java -@@ -26,6 +_,8 @@ - import net.minecraft.util.registry.Registry; +--- 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 field_192495_a = new ItemPredicate(); + public static final ItemPredicate f_45028_ = new ItemPredicate(); @Nullable - private final ITag field_200018_b; -@@ -105,6 +_,11 @@ - public static ItemPredicate func_192492_a(@Nullable JsonElement p_192492_0_) { - if (p_192492_0_ != null && !p_192492_0_.isJsonNull()) { - JsonObject jsonobject = JSONUtils.func_151210_l(p_192492_0_, "item"); + private final Tag f_45029_; +@@ -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(JSONUtils.func_151200_h(jsonobject, "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.IntBound minmaxbounds$intbound = MinMaxBounds.IntBound.func_211344_a(jsonobject.get("count")); - MinMaxBounds.IntBound minmaxbounds$intbound1 = MinMaxBounds.IntBound.func_211344_a(jsonobject.get("durability")); + 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")) { -@@ -202,6 +_,14 @@ +@@ -219,6 +_,14 @@ } else { return new ItemPredicate[0]; } diff --git a/patches/minecraft/net/minecraft/block/AbstractBlock.java.patch b/patches/minecraft/net/minecraft/block/AbstractBlock.java.patch deleted file mode 100644 index bec52c5243..0000000000 --- a/patches/minecraft/net/minecraft/block/AbstractBlock.java.patch +++ /dev/null @@ -1,172 +0,0 @@ ---- a/net/minecraft/block/AbstractBlock.java -+++ b/net/minecraft/block/AbstractBlock.java -@@ -60,7 +_,8 @@ - import net.minecraftforge.api.distmarker.Dist; - import net.minecraftforge.api.distmarker.OnlyIn; - --public abstract class AbstractBlock { -+//TODO, Delegates are weird here now, because Block extends this. -+public abstract class AbstractBlock extends net.minecraftforge.registries.ForgeRegistryEntry { - protected static final Direction[] field_212556_a = new Direction[]{Direction.WEST, Direction.EAST, Direction.NORTH, Direction.SOUTH, Direction.DOWN, Direction.UP}; - protected final Material field_149764_J; - protected final boolean field_235688_at_; -@@ -87,6 +_,8 @@ - this.field_226887_g_ = p_i241196_1_.field_226894_k_; - this.field_208621_p = p_i241196_1_.field_208772_j; - this.field_235684_aB_ = p_i241196_1_; -+ final ResourceLocation lootTableCache = p_i241196_1_.field_222381_j; -+ this.lootTableSupplier = lootTableCache != null ? () -> lootTableCache : p_i241196_1_.lootTableSupplier != null ? p_i241196_1_.lootTableSupplier : () -> new ResourceLocation(this.getRegistryName().func_110624_b(), "blocks/" + this.getRegistryName().func_110623_a()); - } - - @Deprecated -@@ -129,7 +_,7 @@ - - @Deprecated - public void func_196243_a(BlockState p_196243_1_, World p_196243_2_, BlockPos p_196243_3_, BlockState p_196243_4_, boolean p_196243_5_) { -- if (this.func_235695_q_() && !p_196243_1_.func_203425_a(p_196243_4_.func_177230_c())) { -+ if (p_196243_1_.hasTileEntity() && (!p_196243_1_.func_203425_a(p_196243_4_.func_177230_c()) || !p_196243_4_.hasTileEntity())) { - p_196243_2_.func_175713_t(p_196243_3_); - } - -@@ -191,7 +_,7 @@ - - @Deprecated - public boolean func_196253_a(BlockState p_196253_1_, BlockItemUseContext p_196253_2_) { -- return this.field_149764_J.func_76222_j() && (p_196253_2_.func_195996_i().func_190926_b() || p_196253_2_.func_195996_i().func_77973_b() != this.func_199767_j()); -+ return p_196253_1_.func_185904_a().func_76222_j() && (p_196253_2_.func_195996_i().func_190926_b() || p_196253_2_.func_195996_i().func_77973_b() != this.func_199767_j()); - } - - @Deprecated -@@ -294,8 +_,8 @@ - if (f == -1.0F) { - return 0.0F; - } else { -- int i = p_180647_2_.func_234569_d_(p_180647_1_) ? 30 : 100; -- return p_180647_2_.func_184813_a(p_180647_1_) / f / (float)i; -+ int i = net.minecraftforge.common.ForgeHooks.canHarvestBlock(p_180647_1_, p_180647_2_, p_180647_3_, p_180647_4_) ? 30 : 100; -+ return p_180647_2_.getDigSpeed(p_180647_1_, p_180647_4_) / f / (float)i; - } - } - -@@ -321,14 +_,14 @@ - return 0; - } - -+ @Deprecated //Forge: Use state.hasTileEntity() - public final boolean func_235695_q_() { - return this instanceof ITileEntityProvider; - } - - public final ResourceLocation func_220068_i() { - if (this.field_220085_g == null) { -- ResourceLocation resourcelocation = Registry.field_212618_g.func_177774_c(this.func_230328_p_()); -- this.field_220085_g = new ResourceLocation(resourcelocation.func_110624_b(), "blocks/" + resourcelocation.func_110623_a()); -+ this.field_220085_g = this.lootTableSupplier.get(); - } - - return this.field_220085_g; -@@ -346,6 +_,14 @@ - return this.field_235684_aB_.field_235800_b_.apply(this.func_230328_p_().func_176223_P()); - } - -+ protected boolean isAir(BlockState state) { -+ return ((AbstractBlockState)state).field_235702_f_; -+ } -+ -+ /* ======================================== FORGE START ===================================== */ -+ private final java.util.function.Supplier lootTableSupplier; -+ /* ========================================= FORGE END ====================================== */ -+ - public abstract static class AbstractBlockState extends StateHolder { - private final int field_215708_d; - private final boolean field_215709_e; -@@ -424,18 +_,24 @@ - return this.field_215709_e; - } - -+ /** @deprecated use {@link BlockState#getLightValue(IBlockReader, BlockPos)} */ -+ @Deprecated - public int func_185906_d() { - return this.field_215708_d; - } - -+ /** @deprecated use {@link BlockState#isAir(IBlockReader, BlockPos)} until 1.17, at which point this method will be undreprecated. See https://github.com/MinecraftForge/MinecraftForge/issues/7409 for more details */ -+ @Deprecated - public boolean func_196958_f() { -- return this.field_235702_f_; -+ return this.func_177230_c().isAir((BlockState)this); - } - - public MaterialColor func_185909_g(IBlockReader p_185909_1_, BlockPos p_185909_2_) { - return this.field_235704_h_; - } - -+ /** @deprecated use {@link BlockState#rotate(IWorld, BlockPos, Rotation)} */ -+ @Deprecated - public BlockState func_185907_a(Rotation p_185907_1_) { - return this.func_177230_c().func_185499_a(this.func_230340_p_(), p_185907_1_); - } -@@ -802,8 +_,11 @@ - private ResourceLocation field_222381_j; - private boolean field_226895_m_ = true; - private boolean field_235813_o_; -+ private int harvestLevel = -1; -+ private net.minecraftforge.common.ToolType harvestTool; -+ private java.util.function.Supplier lootTableSupplier; - private AbstractBlock.IExtendedPositionPredicate> field_235814_p_ = (p_235832_0_, p_235832_1_, p_235832_2_, p_235832_3_) -> { -- return p_235832_0_.func_224755_d(p_235832_1_, p_235832_2_, Direction.UP) && p_235832_0_.func_185906_d() < 14; -+ return p_235832_0_.func_224755_d(p_235832_1_, p_235832_2_, Direction.UP) && p_235832_0_.getLightValue(p_235832_1_, p_235832_2_) < 14; - }; - private AbstractBlock.IPositionPredicate field_235815_q_ = (p_235853_0_, p_235853_1_, p_235853_2_) -> { - return p_235853_0_.func_185904_a().func_76218_k() && p_235853_0_.func_235785_r_(p_235853_1_, p_235853_2_); -@@ -863,6 +_,8 @@ - abstractblock$properties.field_226895_m_ = p_200950_0_.field_235684_aB_.field_226895_m_; - abstractblock$properties.field_235813_o_ = p_200950_0_.field_235684_aB_.field_235813_o_; - abstractblock$properties.field_235806_h_ = p_200950_0_.field_235684_aB_.field_235806_h_; -+ abstractblock$properties.harvestLevel = p_200950_0_.field_235684_aB_.harvestLevel; -+ abstractblock$properties.harvestTool = p_200950_0_.field_235684_aB_.harvestTool; - return abstractblock$properties; - } - -@@ -877,6 +_,24 @@ - return this; - } - -+ public AbstractBlock.Properties harvestLevel(int harvestLevel) { -+ this.harvestLevel = harvestLevel; -+ return this; -+ } -+ -+ public AbstractBlock.Properties harvestTool(net.minecraftforge.common.ToolType harvestTool) { -+ this.harvestTool = harvestTool; -+ return this; -+ } -+ -+ public int getHarvestLevel() { -+ return this.harvestLevel; -+ } -+ -+ public net.minecraftforge.common.ToolType getHarvestTool() { -+ return this.harvestTool; -+ } -+ - public AbstractBlock.Properties func_200941_a(float p_200941_1_) { - this.field_200961_i = p_200941_1_; - return this; -@@ -932,9 +_,15 @@ - return this; - } - -+ @Deprecated // FORGE: Use the variant that takes a Supplier below - public AbstractBlock.Properties func_222379_b(Block p_222379_1_) { -- this.field_222381_j = p_222379_1_.func_220068_i(); -+ this.lootTableSupplier = () -> p_222379_1_.delegate.get().func_220068_i(); - return this; -+ } -+ -+ public AbstractBlock.Properties lootFrom(java.util.function.Supplier blockIn) { -+ this.lootTableSupplier = () -> blockIn.get().func_220068_i(); -+ return this; - } - - public AbstractBlock.Properties func_235859_g_() { diff --git a/patches/minecraft/net/minecraft/block/AbstractFireBlock.java.patch b/patches/minecraft/net/minecraft/block/AbstractFireBlock.java.patch deleted file mode 100644 index 58f57d3d18..0000000000 --- a/patches/minecraft/net/minecraft/block/AbstractFireBlock.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/block/AbstractFireBlock.java -+++ b/net/minecraft/block/AbstractFireBlock.java -@@ -124,6 +_,7 @@ - if (!p_220082_4_.func_203425_a(p_220082_1_.func_177230_c())) { - if (func_242649_a(p_220082_2_)) { - Optional optional = PortalSize.func_242964_a(p_220082_2_, p_220082_3_, Direction.Axis.X); -+ optional = net.minecraftforge.event.ForgeEventFactory.onTrySpawnPortal(p_220082_2_, p_220082_3_, optional); - if (optional.isPresent()) { - optional.get().func_150859_c(); - return; diff --git a/patches/minecraft/net/minecraft/block/AbstractRailBlock.java.patch b/patches/minecraft/net/minecraft/block/AbstractRailBlock.java.patch deleted file mode 100644 index c50a167e51..0000000000 --- a/patches/minecraft/net/minecraft/block/AbstractRailBlock.java.patch +++ /dev/null @@ -1,58 +0,0 @@ ---- a/net/minecraft/block/AbstractRailBlock.java -+++ b/net/minecraft/block/AbstractRailBlock.java -@@ -13,7 +_,7 @@ - import net.minecraft.world.IWorldReader; - import net.minecraft.world.World; - --public abstract class AbstractRailBlock extends Block { -+public abstract class AbstractRailBlock extends Block implements net.minecraftforge.common.extensions.IAbstractRailBlock { - protected static final VoxelShape field_185590_a = Block.func_208617_a(0.0D, 0.0D, 0.0D, 16.0D, 2.0D, 16.0D); - protected static final VoxelShape field_190959_b = Block.func_208617_a(0.0D, 0.0D, 0.0D, 16.0D, 8.0D, 16.0D); - private final boolean field_196277_c; -@@ -37,6 +_,7 @@ - - public VoxelShape func_220053_a(BlockState p_220053_1_, IBlockReader p_220053_2_, BlockPos p_220053_3_, ISelectionContext p_220053_4_) { - RailShape railshape = p_220053_1_.func_203425_a(this) ? p_220053_1_.func_177229_b(this.func_176560_l()) : null; -+ RailShape railShape2 = p_220053_1_.func_203425_a(this) ? getRailDirection(p_220053_1_, p_220053_2_, p_220053_3_, null) : null; - return railshape != null && railshape.func_208092_c() ? field_190959_b : field_185590_a; - } - -@@ -61,7 +_,7 @@ - - public void func_220069_a(BlockState p_220069_1_, World p_220069_2_, BlockPos p_220069_3_, Block p_220069_4_, BlockPos p_220069_5_, boolean p_220069_6_) { - if (!p_220069_2_.field_72995_K && p_220069_2_.func_180495_p(p_220069_3_).func_203425_a(this)) { -- RailShape railshape = p_220069_1_.func_177229_b(this.func_176560_l()); -+ RailShape railshape = getRailDirection(p_220069_1_, p_220069_2_, p_220069_3_, null); - if (func_235328_a_(p_220069_3_, p_220069_2_, railshape)) { - func_220075_c(p_220069_1_, p_220069_2_, p_220069_3_); - p_220069_2_.func_217377_a(p_220069_3_, p_220069_6_); -@@ -110,7 +_,7 @@ - public void func_196243_a(BlockState p_196243_1_, World p_196243_2_, BlockPos p_196243_3_, BlockState p_196243_4_, boolean p_196243_5_) { - if (!p_196243_5_) { - super.func_196243_a(p_196243_1_, p_196243_2_, p_196243_3_, p_196243_4_, p_196243_5_); -- if (p_196243_1_.func_177229_b(this.func_176560_l()).func_208092_c()) { -+ if (getRailDirection(p_196243_1_, p_196243_2_, p_196243_3_, null).func_208092_c()) { - p_196243_2_.func_195593_d(p_196243_3_.func_177984_a(), this); - } - -@@ -129,5 +_,20 @@ - return blockstate.func_206870_a(this.func_176560_l(), flag ? RailShape.EAST_WEST : RailShape.NORTH_SOUTH); - } - -+ @Deprecated //Forge: Use getRailDirection(IBlockAccess, BlockPos, IBlockState, EntityMinecart) for enhanced ability - public abstract Property func_176560_l(); -+ -+ /* ======================================== FORGE START =====================================*/ -+ -+ @Override -+ public boolean isFlexibleRail(BlockState state, IBlockReader world, BlockPos pos) -+ { -+ return !this.field_196277_c; -+ } -+ -+ @Override -+ public RailShape getRailDirection(BlockState state, IBlockReader world, BlockPos pos, @javax.annotation.Nullable net.minecraft.entity.item.minecart.AbstractMinecartEntity cart) { -+ return state.func_177229_b(func_176560_l()); -+ } -+ /* ========================================= FORGE END ======================================*/ - } diff --git a/patches/minecraft/net/minecraft/block/AbstractTopPlantBlock.java.patch b/patches/minecraft/net/minecraft/block/AbstractTopPlantBlock.java.patch deleted file mode 100644 index 9d27b632c1..0000000000 --- a/patches/minecraft/net/minecraft/block/AbstractTopPlantBlock.java.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- a/net/minecraft/block/AbstractTopPlantBlock.java -+++ b/net/minecraft/block/AbstractTopPlantBlock.java -@@ -32,10 +_,11 @@ - } - - public void func_225542_b_(BlockState p_225542_1_, ServerWorld p_225542_2_, BlockPos p_225542_3_, Random p_225542_4_) { -- if (p_225542_1_.func_177229_b(field_235502_d_) < 25 && p_225542_4_.nextDouble() < this.field_235503_e_) { -+ if (p_225542_1_.func_177229_b(field_235502_d_) < 25 && net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_225542_2_, p_225542_3_.func_177972_a(this.field_235498_a_), p_225542_2_.func_180495_p(p_225542_3_.func_177972_a(this.field_235498_a_)),p_225542_4_.nextDouble() < this.field_235503_e_)) { - BlockPos blockpos = p_225542_3_.func_177972_a(this.field_235498_a_); - if (this.func_230334_h_(p_225542_2_.func_180495_p(blockpos))) { - p_225542_2_.func_175656_a(blockpos, p_225542_1_.func_235896_a_(field_235502_d_)); -+ net.minecraftforge.common.ForgeHooks.onCropsGrowPost(p_225542_2_, blockpos, p_225542_2_.func_180495_p(blockpos)); - } - } - diff --git a/patches/minecraft/net/minecraft/block/BambooBlock.java.patch b/patches/minecraft/net/minecraft/block/BambooBlock.java.patch deleted file mode 100644 index b680223a7c..0000000000 --- a/patches/minecraft/net/minecraft/block/BambooBlock.java.patch +++ /dev/null @@ -1,16 +0,0 @@ ---- a/net/minecraft/block/BambooBlock.java -+++ b/net/minecraft/block/BambooBlock.java -@@ -100,10 +_,11 @@ - - public void func_225542_b_(BlockState p_225542_1_, ServerWorld p_225542_2_, BlockPos p_225542_3_, Random p_225542_4_) { - if (p_225542_1_.func_177229_b(field_220266_f) == 0) { -- if (p_225542_4_.nextInt(3) == 0 && p_225542_2_.func_175623_d(p_225542_3_.func_177984_a()) && p_225542_2_.func_226659_b_(p_225542_3_.func_177984_a(), 0) >= 9) { -+ if (p_225542_2_.func_175623_d(p_225542_3_.func_177984_a()) && p_225542_2_.func_226659_b_(p_225542_3_.func_177984_a(), 0) >= 9) { - int i = this.func_220260_b(p_225542_2_, p_225542_3_) + 1; -- if (i < 16) { -+ if (i < 16 && net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_225542_2_, p_225542_3_, p_225542_1_, p_225542_4_.nextInt(3) == 0)) { - this.func_220258_a(p_225542_1_, p_225542_2_, p_225542_3_, p_225542_4_, i); -+ net.minecraftforge.common.ForgeHooks.onCropsGrowPost(p_225542_2_, p_225542_3_, p_225542_1_); - } - } - diff --git a/patches/minecraft/net/minecraft/block/BeehiveBlock.java.patch b/patches/minecraft/net/minecraft/block/BeehiveBlock.java.patch deleted file mode 100644 index 3daa79cf68..0000000000 --- a/patches/minecraft/net/minecraft/block/BeehiveBlock.java.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/block/BeehiveBlock.java -+++ b/net/minecraft/block/BeehiveBlock.java -@@ -65,6 +_,9 @@ - public int func_180641_l(BlockState p_180641_1_, World p_180641_2_, BlockPos p_180641_3_) { - return p_180641_1_.func_177229_b(field_226873_c_); - } -+ // Forge: Fixed MC-227255 Beehives and bee nests do not rotate/mirror correctly in structure blocks -+ @Override public BlockState func_185499_a(BlockState blockState, net.minecraft.util.Rotation rotation) { return (BlockState)blockState.func_206870_a(field_226872_b_, rotation.func_185831_a(blockState.func_177229_b(field_226872_b_))); } -+ @Override public BlockState func_185471_a(BlockState blockState, net.minecraft.util.Mirror mirror) { return blockState.func_185907_a(mirror.func_185800_a(blockState.func_177229_b(field_226872_b_))); } - - public void func_180657_a(World p_180657_1_, PlayerEntity p_180657_2_, BlockPos p_180657_3_, BlockState p_180657_4_, @Nullable TileEntity p_180657_5_, ItemStack p_180657_6_) { - super.func_180657_a(p_180657_1_, p_180657_2_, p_180657_3_, p_180657_4_, p_180657_5_, p_180657_6_); -@@ -85,6 +_,7 @@ - List list = p_226881_1_.func_217357_a(BeeEntity.class, (new AxisAlignedBB(p_226881_2_)).func_72314_b(8.0D, 6.0D, 8.0D)); - if (!list.isEmpty()) { - List list1 = p_226881_1_.func_217357_a(PlayerEntity.class, (new AxisAlignedBB(p_226881_2_)).func_72314_b(8.0D, 6.0D, 8.0D)); -+ if (list1.isEmpty()) return; //Forge: Prevent Error when no players are around. - int i = list1.size(); - - for(BeeEntity beeentity : list) { diff --git a/patches/minecraft/net/minecraft/block/Block.java.patch b/patches/minecraft/net/minecraft/block/Block.java.patch deleted file mode 100644 index 638108cd35..0000000000 --- a/patches/minecraft/net/minecraft/block/Block.java.patch +++ /dev/null @@ -1,171 +0,0 @@ ---- a/net/minecraft/block/Block.java -+++ b/net/minecraft/block/Block.java -@@ -54,9 +_,10 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; - --public class Block extends AbstractBlock implements IItemProvider { -+public class Block extends AbstractBlock implements IItemProvider, net.minecraftforge.common.extensions.IForgeBlock { - protected static final Logger field_196273_d = LogManager.getLogger(); -- public static final ObjectIntIdentityMap field_176229_d = new ObjectIntIdentityMap<>(); -+ @Deprecated //Forge: Do not use, use GameRegistry -+ public static final ObjectIntIdentityMap field_176229_d = net.minecraftforge.registries.GameData.getBlockStateIDMap(); - private static final LoadingCache field_223006_b = CacheBuilder.newBuilder().maximumSize(512L).weakKeys().build(new CacheLoader() { - public Boolean load(VoxelShape p_load_1_) { - return !VoxelShapes.func_197879_c(VoxelShapes.func_197868_b(), p_load_1_, IBooleanFunction.field_223236_g_); -@@ -151,6 +_,8 @@ - super(p_i48440_1_); - StateContainer.Builder builder = new StateContainer.Builder<>(this); - this.func_206840_a(builder); -+ this.harvestLevel = p_i48440_1_.getHarvestLevel(); -+ this.harvestTool = p_i48440_1_.getHarvestTool(); - this.field_176227_L = builder.func_235882_a_(Block::func_176223_P, BlockState::new); - this.func_180632_j(this.field_176227_L.func_177621_b()); - } -@@ -261,7 +_,7 @@ - } - - public static void func_180635_a(World p_180635_0_, BlockPos p_180635_1_, ItemStack p_180635_2_) { -- if (!p_180635_0_.field_72995_K && !p_180635_2_.func_190926_b() && p_180635_0_.func_82736_K().func_223586_b(GameRules.field_223603_f)) { -+ if (!p_180635_0_.field_72995_K && !p_180635_2_.func_190926_b() && p_180635_0_.func_82736_K().func_223586_b(GameRules.field_223603_f) && !p_180635_0_.restoringBlockSnapshots) { - float f = 0.5F; - double d0 = (double)(p_180635_0_.field_73012_v.nextFloat() * 0.5F) + 0.25D; - double d1 = (double)(p_180635_0_.field_73012_v.nextFloat() * 0.5F) + 0.25D; -@@ -273,7 +_,7 @@ - } - - public void func_180637_b(ServerWorld p_180637_1_, BlockPos p_180637_2_, int p_180637_3_) { -- if (p_180637_1_.func_82736_K().func_223586_b(GameRules.field_223603_f)) { -+ if (p_180637_1_.func_82736_K().func_223586_b(GameRules.field_223603_f) && !p_180637_1_.restoringBlockSnapshots) { - while(p_180637_3_ > 0) { - int i = ExperienceOrbEntity.func_70527_a(p_180637_3_); - p_180637_3_ -= i; -@@ -283,6 +_,7 @@ - - } - -+ @Deprecated //Forge: Use more sensitive version - public float func_149638_a() { - return this.field_235689_au_; - } -@@ -332,6 +_,7 @@ - p_176216_2_.func_213317_d(p_176216_2_.func_213322_ci().func_216372_d(1.0D, 0.0D, 1.0D)); - } - -+ @Deprecated //Forge: Use more sensitive version - public ItemStack func_185473_a(IBlockReader p_185473_1_, BlockPos p_185473_2_, BlockState p_185473_3_) { - return new ItemStack(this); - } -@@ -363,6 +_,7 @@ - public void func_176224_k(World p_176224_1_, BlockPos p_176224_2_) { - } - -+ @Deprecated //Forge: Use more sensitive version - public boolean func_149659_a(Explosion p_149659_1_) { - return true; - } -@@ -382,6 +_,7 @@ - return this.field_196275_y; - } - -+ @Deprecated //Forge: Use more sensitive version {@link IForgeBlockState#getSoundType(IWorldReader, BlockPos, Entity) } - public SoundType func_220072_p(BlockState p_220072_1_) { - return this.field_149762_H; - } -@@ -391,7 +_,7 @@ - this.field_220086_i = Item.func_150898_a(this); - } - -- return this.field_220086_i; -+ return this.field_220086_i.delegate.get(); //Forge: Vanilla caches the items, update with registry replacements. - } - - public boolean func_208619_r() { -@@ -399,7 +_,7 @@ - } - - public String toString() { -- return "Block{" + Registry.field_212618_g.func_177774_c(this) + "}"; -+ return "Block{" + getRegistryName() + "}"; - } - - @OnlyIn(Dist.CLIENT) -@@ -409,6 +_,78 @@ - protected Block func_230328_p_() { - return this; - } -+ -+ /* ======================================== FORGE START =====================================*/ -+ protected Random RANDOM = new Random(); -+ private net.minecraftforge.common.ToolType harvestTool; -+ private int harvestLevel; -+ private final net.minecraftforge.common.util.ReverseTagWrapper reverseTags = new net.minecraftforge.common.util.ReverseTagWrapper<>(this, BlockTags::func_199896_a); -+ -+ @Nullable -+ @Override -+ public net.minecraftforge.common.ToolType getHarvestTool(BlockState state) { -+ return harvestTool; //TODO: RE-Evaluate -+ } -+ -+ @Override -+ public int getHarvestLevel(BlockState state) { -+ return harvestLevel; //TODO: RE-Evaluate -+ } -+ -+ @Override -+ public boolean canSustainPlant(BlockState state, IBlockReader world, BlockPos pos, Direction facing, net.minecraftforge.common.IPlantable plantable) { -+ BlockState plant = plantable.getPlant(world, pos.func_177972_a(facing)); -+ net.minecraftforge.common.PlantType type = plantable.getPlantType(world, pos.func_177972_a(facing)); -+ -+ if (plant.func_177230_c() == Blocks.field_150434_aF) -+ return state.func_203425_a(Blocks.field_150434_aF) || state.func_203425_a(Blocks.field_150354_m) || state.func_203425_a(Blocks.field_196611_F); -+ -+ if (plant.func_177230_c() == Blocks.field_196608_cF && this == Blocks.field_196608_cF) -+ return true; -+ -+ if (plantable instanceof BushBlock && ((BushBlock)plantable).func_200014_a_(state, world, pos)) -+ return true; -+ -+ if (net.minecraftforge.common.PlantType.DESERT.equals(type)) { -+ return this.getBlock() == Blocks.field_150354_m || this.getBlock() == Blocks.field_150405_ch || this.getBlock() instanceof GlazedTerracottaBlock; -+ } else if (net.minecraftforge.common.PlantType.NETHER.equals(type)) { -+ return this.getBlock() == Blocks.field_150425_aM; -+ } else if (net.minecraftforge.common.PlantType.CROP.equals(type)) { -+ return state.func_203425_a(Blocks.field_150458_ak); -+ } else if (net.minecraftforge.common.PlantType.CAVE.equals(type)) { -+ return state.func_224755_d(world, pos, Direction.UP); -+ } else if (net.minecraftforge.common.PlantType.PLAINS.equals(type)) { -+ return this.getBlock() == Blocks.field_196658_i || net.minecraftforge.common.Tags.Blocks.DIRT.func_230235_a_(this) || this.getBlock() == Blocks.field_150458_ak; -+ } else if (net.minecraftforge.common.PlantType.WATER.equals(type)) { -+ return state.func_185904_a() == net.minecraft.block.material.Material.field_151586_h; //&& state.getValue(BlockLiquidWrapper) -+ } else if (net.minecraftforge.common.PlantType.BEACH.equals(type)) { -+ boolean isBeach = state.func_203425_a(Blocks.field_196658_i) || net.minecraftforge.common.Tags.Blocks.DIRT.func_230235_a_(this) || state.func_203425_a(Blocks.field_150354_m) || state.func_203425_a(Blocks.field_196611_F); -+ boolean hasWater = false; -+ for (Direction face : Direction.Plane.HORIZONTAL) { -+ BlockState blockState = world.func_180495_p(pos.func_177972_a(face)); -+ net.minecraft.fluid.FluidState fluidState = world.func_204610_c(pos.func_177972_a(face)); -+ hasWater |= blockState.func_203425_a(Blocks.field_185778_de); -+ hasWater |= fluidState.func_206884_a(net.minecraft.tags.FluidTags.field_206959_a); -+ if (hasWater) -+ break; //No point continuing. -+ } -+ return isBeach && hasWater; -+ } -+ return false; -+ } -+ -+ @Override -+ public final java.util.Set getTags() { -+ return reverseTags.getTagNames(); -+ } -+ -+ static { -+ net.minecraftforge.common.ForgeHooks.setBlockToolSetter((block, tool, level) -> { -+ block.harvestTool = tool; -+ block.harvestLevel = level; -+ }); -+ } -+ /* ========================================= FORGE END ======================================*/ - - public static final class RenderSideCacheKey { - private final BlockState field_212164_a; diff --git a/patches/minecraft/net/minecraft/block/BlockState.java.patch b/patches/minecraft/net/minecraft/block/BlockState.java.patch deleted file mode 100644 index 7a47526268..0000000000 --- a/patches/minecraft/net/minecraft/block/BlockState.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/block/BlockState.java -+++ b/net/minecraft/block/BlockState.java -@@ -6,7 +_,7 @@ - import net.minecraft.state.Property; - import net.minecraft.util.registry.Registry; - --public class BlockState extends AbstractBlock.AbstractBlockState { -+public class BlockState extends AbstractBlock.AbstractBlockState implements net.minecraftforge.common.extensions.IForgeBlockState { - public static final Codec field_235877_b_ = func_235897_a_(Registry.field_212618_g, Block::func_176223_P).stable(); - - public BlockState(Block p_i231876_1_, ImmutableMap, Comparable> p_i231876_2_, MapCodec p_i231876_3_) { diff --git a/patches/minecraft/net/minecraft/block/Blocks.java.patch b/patches/minecraft/net/minecraft/block/Blocks.java.patch deleted file mode 100644 index fce20cf8b0..0000000000 --- a/patches/minecraft/net/minecraft/block/Blocks.java.patch +++ /dev/null @@ -1,36 +0,0 @@ ---- a/net/minecraft/block/Blocks.java -+++ b/net/minecraft/block/Blocks.java -@@ -25,6 +_,7 @@ - import net.minecraft.world.IBlockReader; - import net.minecraft.world.gen.feature.Features; - -+@net.minecraftforge.registries.ObjectHolder("minecraft") - public class Blocks { - public static final Block field_150350_a = func_222382_a("air", new AirBlock(AbstractBlock.Properties.func_200945_a(Material.field_151579_a).func_200942_a().func_222380_e().func_235859_g_())); - public static final Block field_150348_b = func_222382_a("stone", new Block(AbstractBlock.Properties.func_200949_a(Material.field_151576_e, MaterialColor.field_151665_m).func_235861_h_().func_200948_a(1.5F, 6.0F))); -@@ -119,7 +_,7 @@ - public static final Block field_196601_az = func_222382_a("green_bed", func_235422_a_(DyeColor.GREEN)); - public static final Block field_196550_aA = func_222382_a("red_bed", func_235422_a_(DyeColor.RED)); - public static final Block field_196551_aB = func_222382_a("black_bed", func_235422_a_(DyeColor.BLACK)); -- public static final Block field_196552_aC = func_222382_a("powered_rail", new PoweredRailBlock(AbstractBlock.Properties.func_200945_a(Material.field_151594_q).func_200942_a().func_200943_b(0.7F).func_200947_a(SoundType.field_185852_e))); -+ public static final Block field_196552_aC = func_222382_a("powered_rail", new PoweredRailBlock(AbstractBlock.Properties.func_200945_a(Material.field_151594_q).func_200942_a().func_200943_b(0.7F).func_200947_a(SoundType.field_185852_e), true)); - public static final Block field_150319_E = func_222382_a("detector_rail", new DetectorRailBlock(AbstractBlock.Properties.func_200945_a(Material.field_151594_q).func_200942_a().func_200943_b(0.7F).func_200947_a(SoundType.field_185852_e))); - public static final Block field_150320_F = func_222382_a("sticky_piston", func_235432_a_(true)); - public static final Block field_196553_aF = func_222382_a("cobweb", new WebBlock(AbstractBlock.Properties.func_200945_a(Material.field_151569_G).func_200942_a().func_235861_h_().func_200943_b(4.0F))); -@@ -936,16 +_,5 @@ - - public static void func_235419_a_() { - Block.field_176229_d.forEach(AbstractBlock.AbstractBlockState::func_215692_c); -- } -- -- static { -- for(Block block : Registry.field_212618_g) { -- for(BlockState blockstate : block.func_176194_O().func_177619_a()) { -- Block.field_176229_d.func_195867_b(blockstate); -- } -- -- block.func_220068_i(); -- } -- - } - } diff --git a/patches/minecraft/net/minecraft/block/BushBlock.java.patch b/patches/minecraft/net/minecraft/block/BushBlock.java.patch deleted file mode 100644 index f4d73b295b..0000000000 --- a/patches/minecraft/net/minecraft/block/BushBlock.java.patch +++ /dev/null @@ -1,33 +0,0 @@ ---- a/net/minecraft/block/BushBlock.java -+++ b/net/minecraft/block/BushBlock.java -@@ -7,7 +_,7 @@ - import net.minecraft.world.IWorld; - import net.minecraft.world.IWorldReader; - --public class BushBlock extends Block { -+public class BushBlock extends Block implements net.minecraftforge.common.IPlantable { - public BushBlock(AbstractBlock.Properties p_i48437_1_) { - super(p_i48437_1_); - } -@@ -22,6 +_,8 @@ - - public boolean func_196260_a(BlockState p_196260_1_, IWorldReader p_196260_2_, BlockPos p_196260_3_) { - BlockPos blockpos = p_196260_3_.func_177977_b(); -+ if (p_196260_1_.func_177230_c() == 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. -+ return p_196260_2_.func_180495_p(blockpos).canSustainPlant(p_196260_2_, blockpos, Direction.UP, this); - return this.func_200014_a_(p_196260_2_.func_180495_p(blockpos), p_196260_2_, blockpos); - } - -@@ -31,5 +_,12 @@ - - public boolean func_196266_a(BlockState p_196266_1_, IBlockReader p_196266_2_, BlockPos p_196266_3_, PathType p_196266_4_) { - return p_196266_4_ == PathType.AIR && !this.field_235688_at_ ? true : super.func_196266_a(p_196266_1_, p_196266_2_, p_196266_3_, p_196266_4_); -+ } -+ -+ @Override -+ public BlockState getPlant(IBlockReader world, BlockPos pos) { -+ BlockState state = world.func_180495_p(pos); -+ if (state.func_177230_c() != this) return func_176223_P(); -+ return state; - } - } diff --git a/patches/minecraft/net/minecraft/block/CactusBlock.java.patch b/patches/minecraft/net/minecraft/block/CactusBlock.java.patch deleted file mode 100644 index 1c993d30cc..0000000000 --- a/patches/minecraft/net/minecraft/block/CactusBlock.java.patch +++ /dev/null @@ -1,62 +0,0 @@ ---- a/net/minecraft/block/CactusBlock.java -+++ b/net/minecraft/block/CactusBlock.java -@@ -19,7 +_,7 @@ - import net.minecraft.world.World; - import net.minecraft.world.server.ServerWorld; - --public class CactusBlock extends Block { -+public class CactusBlock extends Block implements net.minecraftforge.common.IPlantable { - public static final IntegerProperty field_176587_a = BlockStateProperties.field_208171_X; - protected static final VoxelShape field_196400_b = Block.func_208617_a(1.0D, 0.0D, 1.0D, 15.0D, 15.0D, 15.0D); - protected static final VoxelShape field_196401_c = Block.func_208617_a(1.0D, 0.0D, 1.0D, 15.0D, 16.0D, 15.0D); -@@ -30,6 +_,7 @@ - } - - public void func_225534_a_(BlockState p_225534_1_, ServerWorld p_225534_2_, BlockPos p_225534_3_, Random p_225534_4_) { -+ if (!p_225534_2_.isAreaLoaded(p_225534_3_, 1)) return; // Forge: prevent growing cactus from loading unloaded chunks with block update - if (!p_225534_1_.func_196955_c(p_225534_2_, p_225534_3_)) { - p_225534_2_.func_175655_b(p_225534_3_, true); - } -@@ -45,6 +_,7 @@ - - if (i < 3) { - int j = p_225542_1_.func_177229_b(field_176587_a); -+ if(net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_225542_2_, blockpos, p_225542_1_, true)) { - if (j == 15) { - p_225542_2_.func_175656_a(blockpos, this.func_176223_P()); - BlockState blockstate = p_225542_1_.func_206870_a(field_176587_a, Integer.valueOf(0)); -@@ -53,7 +_,8 @@ - } else { - p_225542_2_.func_180501_a(p_225542_3_, p_225542_1_.func_206870_a(field_176587_a, Integer.valueOf(j + 1)), 4); - } -- -+ net.minecraftforge.common.ForgeHooks.onCropsGrowPost(p_225542_2_, p_225542_3_, p_225542_1_); -+ } - } - } - } -@@ -84,7 +_,7 @@ - } - - BlockState blockstate1 = p_196260_2_.func_180495_p(p_196260_3_.func_177977_b()); -- return (blockstate1.func_203425_a(Blocks.field_150434_aF) || blockstate1.func_203425_a(Blocks.field_150354_m) || blockstate1.func_203425_a(Blocks.field_196611_F)) && !p_196260_2_.func_180495_p(p_196260_3_.func_177984_a()).func_185904_a().func_76224_d(); -+ return blockstate1.canSustainPlant(p_196260_2_, p_196260_3_, Direction.UP, this) && !p_196260_2_.func_180495_p(p_196260_3_.func_177984_a()).func_185904_a().func_76224_d(); - } - - public void func_196262_a(BlockState p_196262_1_, World p_196262_2_, BlockPos p_196262_3_, Entity p_196262_4_) { -@@ -97,5 +_,15 @@ - - public boolean func_196266_a(BlockState p_196266_1_, IBlockReader p_196266_2_, BlockPos p_196266_3_, PathType p_196266_4_) { - return false; -+ } -+ -+ @Override -+ public net.minecraftforge.common.PlantType getPlantType(IBlockReader world, BlockPos pos) { -+ return net.minecraftforge.common.PlantType.DESERT; -+ } -+ -+ @Override -+ public BlockState getPlant(IBlockReader world, BlockPos pos) { -+ return func_176223_P(); - } - } diff --git a/patches/minecraft/net/minecraft/block/CampfireBlock.java.patch b/patches/minecraft/net/minecraft/block/CampfireBlock.java.patch deleted file mode 100644 index b7bf5c64a7..0000000000 --- a/patches/minecraft/net/minecraft/block/CampfireBlock.java.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/block/CampfireBlock.java -+++ b/net/minecraft/block/CampfireBlock.java -@@ -181,7 +_,7 @@ - public void func_220066_a(World p_220066_1_, BlockState p_220066_2_, BlockRayTraceResult p_220066_3_, ProjectileEntity p_220066_4_) { - if (!p_220066_1_.field_72995_K && p_220066_4_.func_70027_ad()) { - Entity entity = p_220066_4_.func_234616_v_(); -- boolean flag = entity == null || entity instanceof PlayerEntity || p_220066_1_.func_82736_K().func_223586_b(GameRules.field_223599_b); -+ boolean flag = entity == null || entity instanceof PlayerEntity || net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(p_220066_1_, entity); - if (flag && !p_220066_2_.func_177229_b(field_220101_b) && !p_220066_2_.func_177229_b(field_220103_d)) { - BlockPos blockpos = p_220066_3_.func_216350_a(); - p_220066_1_.func_180501_a(blockpos, p_220066_2_.func_206870_a(BlockStateProperties.field_208190_q, Boolean.valueOf(true)), 11); -@@ -208,7 +_,7 @@ - return true; - } - -- boolean flag = VoxelShapes.func_197879_c(field_226912_f_, blockstate.func_215685_b(p_235474_0_, p_235474_1_, ISelectionContext.func_216377_a()), IBooleanFunction.field_223238_i_); -+ boolean flag = VoxelShapes.func_197879_c(field_226912_f_, blockstate.func_215685_b(p_235474_0_, blockpos, ISelectionContext.func_216377_a()), IBooleanFunction.field_223238_i_);//Forge fix: MC-201374 - if (flag) { - BlockState blockstate1 = p_235474_0_.func_180495_p(blockpos.func_177977_b()); - return func_226915_i_(blockstate1); diff --git a/patches/minecraft/net/minecraft/block/ChestBlock.java.patch b/patches/minecraft/net/minecraft/block/ChestBlock.java.patch deleted file mode 100644 index 8ef73d440f..0000000000 --- a/patches/minecraft/net/minecraft/block/ChestBlock.java.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/net/minecraft/block/ChestBlock.java -+++ b/net/minecraft/block/ChestBlock.java -@@ -325,7 +_,8 @@ - } - - public BlockState func_185471_a(BlockState p_185471_1_, Mirror p_185471_2_) { -- return p_185471_1_.func_185907_a(p_185471_2_.func_185800_a(p_185471_1_.func_177229_b(field_176459_a))); -+ BlockState rotated = p_185471_1_.func_185907_a(p_185471_2_.func_185800_a(p_185471_1_.func_177229_b(field_176459_a))); -+ return p_185471_2_ == Mirror.NONE ? rotated : rotated.func_206870_a(field_196314_b, rotated.func_177229_b(field_196314_b).func_208081_a()); // Forge: Fixed MC-134110 Structure mirroring breaking apart double chests - } - - protected void func_206840_a(StateContainer.Builder p_206840_1_) { diff --git a/patches/minecraft/net/minecraft/block/ChorusFlowerBlock.java.patch b/patches/minecraft/net/minecraft/block/ChorusFlowerBlock.java.patch deleted file mode 100644 index 38f3da3d3f..0000000000 --- a/patches/minecraft/net/minecraft/block/ChorusFlowerBlock.java.patch +++ /dev/null @@ -1,47 +0,0 @@ ---- a/net/minecraft/block/ChorusFlowerBlock.java -+++ b/net/minecraft/block/ChorusFlowerBlock.java -@@ -40,7 +_,7 @@ - BlockPos blockpos = p_225542_3_.func_177984_a(); - if (p_225542_2_.func_175623_d(blockpos) && blockpos.func_177956_o() < 256) { - int i = p_225542_1_.func_177229_b(field_185607_a); -- if (i < 5) { -+ if (i < 5 && net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_225542_2_, blockpos, p_225542_1_, true)) { - boolean flag = false; - boolean flag1 = false; - BlockState blockstate = p_225542_2_.func_180495_p(p_225542_3_.func_177977_b()); -@@ -65,7 +_,7 @@ - if (j < 2 || j <= p_225542_4_.nextInt(flag1 ? 5 : 4)) { - flag = true; - } -- } else if (blockstate.func_196958_f()) { -+ } else if (blockstate.isAir(p_225542_2_, p_225542_3_.func_177977_b())) { - flag = true; - } - -@@ -97,7 +_,7 @@ - } else { - this.func_185605_c(p_225542_2_, p_225542_3_); - } -- -+ net.minecraftforge.common.ForgeHooks.onCropsGrowPost(p_225542_2_, p_225542_3_, p_225542_1_); - } - } - } -@@ -133,7 +_,7 @@ - public boolean func_196260_a(BlockState p_196260_1_, IWorldReader p_196260_2_, BlockPos p_196260_3_) { - BlockState blockstate = p_196260_2_.func_180495_p(p_196260_3_.func_177977_b()); - if (blockstate.func_177230_c() != this.field_196405_b && !blockstate.func_203425_a(Blocks.field_150377_bs)) { -- if (!blockstate.func_196958_f()) { -+ if (!blockstate.isAir(p_196260_2_, p_196260_3_.func_177977_b())) { - return false; - } else { - boolean flag = false; -@@ -146,7 +_,7 @@ - } - - flag = true; -- } else if (!blockstate1.func_196958_f()) { -+ } else if (!blockstate1.isAir(p_196260_2_, p_196260_3_.func_177972_a(direction))) { - return false; - } - } diff --git a/patches/minecraft/net/minecraft/block/CocoaBlock.java.patch b/patches/minecraft/net/minecraft/block/CocoaBlock.java.patch deleted file mode 100644 index a56342d3a1..0000000000 --- a/patches/minecraft/net/minecraft/block/CocoaBlock.java.patch +++ /dev/null @@ -1,16 +0,0 @@ ---- a/net/minecraft/block/CocoaBlock.java -+++ b/net/minecraft/block/CocoaBlock.java -@@ -35,10 +_,11 @@ - } - - public void func_225542_b_(BlockState p_225542_1_, ServerWorld p_225542_2_, BlockPos p_225542_3_, Random p_225542_4_) { -- if (p_225542_2_.field_73012_v.nextInt(5) == 0) { -+ if (true) { - int i = p_225542_1_.func_177229_b(field_176501_a); -- if (i < 2) { -+ if (i < 2 && net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_225542_2_, p_225542_3_, p_225542_1_, p_225542_2_.field_73012_v.nextInt(5) == 0)) { - p_225542_2_.func_180501_a(p_225542_3_, p_225542_1_.func_206870_a(field_176501_a, Integer.valueOf(i + 1)), 2); -+ net.minecraftforge.common.ForgeHooks.onCropsGrowPost(p_225542_2_, p_225542_3_, p_225542_1_); - } - } - diff --git a/patches/minecraft/net/minecraft/block/ComparatorBlock.java.patch b/patches/minecraft/net/minecraft/block/ComparatorBlock.java.patch deleted file mode 100644 index 1bb962f419..0000000000 --- a/patches/minecraft/net/minecraft/block/ComparatorBlock.java.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- a/net/minecraft/block/ComparatorBlock.java -+++ b/net/minecraft/block/ComparatorBlock.java -@@ -154,4 +_,16 @@ - protected void func_206840_a(StateContainer.Builder p_206840_1_) { - p_206840_1_.func_206894_a(field_185512_D, field_176463_b, field_196348_c); - } -+ -+ @Override -+ public boolean getWeakChanges(BlockState state, net.minecraft.world.IWorldReader world, BlockPos pos) { -+ return state.func_203425_a(Blocks.field_196762_fd); -+ } -+ -+ @Override -+ public void onNeighborChange(BlockState state, net.minecraft.world.IWorldReader world, BlockPos pos, BlockPos neighbor) { -+ if (pos.func_177956_o() == neighbor.func_177956_o() && world instanceof World && !((World)world).func_201670_d()) { -+ state.func_215697_a((World)world, pos, world.func_180495_p(neighbor).func_177230_c(), neighbor, false); -+ } -+ } - } diff --git a/patches/minecraft/net/minecraft/block/CropsBlock.java.patch b/patches/minecraft/net/minecraft/block/CropsBlock.java.patch deleted file mode 100644 index 70aa23d4b0..0000000000 --- a/patches/minecraft/net/minecraft/block/CropsBlock.java.patch +++ /dev/null @@ -1,39 +0,0 @@ ---- a/net/minecraft/block/CropsBlock.java -+++ b/net/minecraft/block/CropsBlock.java -@@ -61,12 +_,14 @@ - } - - public void func_225542_b_(BlockState p_225542_1_, ServerWorld p_225542_2_, BlockPos p_225542_3_, Random p_225542_4_) { -+ if (!p_225542_2_.isAreaLoaded(p_225542_3_, 1)) return; // Forge: prevent loading unloaded chunks when checking neighbor's light - if (p_225542_2_.func_226659_b_(p_225542_3_, 0) >= 9) { - int i = this.func_185527_x(p_225542_1_); - if (i < this.func_185526_g()) { - float f = func_180672_a(this, p_225542_2_, p_225542_3_); -- if (p_225542_4_.nextInt((int)(25.0F / f) + 1) == 0) { -+ if (net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_225542_2_, p_225542_3_, p_225542_1_, p_225542_4_.nextInt((int)(25.0F / f) + 1) == 0)) { - p_225542_2_.func_180501_a(p_225542_3_, this.func_185528_e(i + 1), 2); -+ net.minecraftforge.common.ForgeHooks.onCropsGrowPost(p_225542_2_, p_225542_3_, p_225542_1_); - } - } - } -@@ -95,9 +_,9 @@ - for(int j = -1; j <= 1; ++j) { - float f1 = 0.0F; - BlockState blockstate = p_180672_1_.func_180495_p(blockpos.func_177982_a(i, 0, j)); -- if (blockstate.func_203425_a(Blocks.field_150458_ak)) { -+ if (blockstate.canSustainPlant(p_180672_1_, blockpos.func_177982_a(i, 0, j), net.minecraft.util.Direction.UP, (net.minecraftforge.common.IPlantable) p_180672_0_)) { - f1 = 1.0F; -- if (blockstate.func_177229_b(FarmlandBlock.field_176531_a) > 0) { -+ if (blockstate.isFertile(p_180672_1_, p_180672_2_.func_177982_a(i, 0, j))) { - f1 = 3.0F; - } - } -@@ -133,7 +_,7 @@ - } - - public void func_196262_a(BlockState p_196262_1_, World p_196262_2_, BlockPos p_196262_3_, Entity p_196262_4_) { -- if (p_196262_4_ instanceof RavagerEntity && p_196262_2_.func_82736_K().func_223586_b(GameRules.field_223599_b)) { -+ if (p_196262_4_ instanceof RavagerEntity && net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(p_196262_2_, p_196262_4_)) { - p_196262_2_.func_225521_a_(p_196262_3_, true, p_196262_4_); - } - diff --git a/patches/minecraft/net/minecraft/block/DeadBushBlock.java.patch b/patches/minecraft/net/minecraft/block/DeadBushBlock.java.patch deleted file mode 100644 index f253ba929d..0000000000 --- a/patches/minecraft/net/minecraft/block/DeadBushBlock.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/block/DeadBushBlock.java -+++ b/net/minecraft/block/DeadBushBlock.java -@@ -5,7 +_,7 @@ - import net.minecraft.util.math.shapes.VoxelShape; - import net.minecraft.world.IBlockReader; - --public class DeadBushBlock extends BushBlock { -+public class DeadBushBlock extends BushBlock implements net.minecraftforge.common.IForgeShearable { - protected static final VoxelShape field_196397_a = Block.func_208617_a(2.0D, 0.0D, 2.0D, 14.0D, 13.0D, 14.0D); - - public DeadBushBlock(AbstractBlock.Properties p_i48418_1_) { diff --git a/patches/minecraft/net/minecraft/block/DetectorRailBlock.java.patch b/patches/minecraft/net/minecraft/block/DetectorRailBlock.java.patch deleted file mode 100644 index 5e38a2d969..0000000000 --- a/patches/minecraft/net/minecraft/block/DetectorRailBlock.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/block/DetectorRailBlock.java -+++ b/net/minecraft/block/DetectorRailBlock.java -@@ -131,6 +_,8 @@ - } - - List list1 = this.func_200878_a(p_180641_2_, p_180641_3_, AbstractMinecartEntity.class, EntityPredicates.field_96566_b); -+ List carts = this.func_200878_a(p_180641_2_, p_180641_3_, AbstractMinecartEntity.class, null); -+ if (!carts.isEmpty() && carts.get(0).getComparatorLevel() > -1) return carts.get(0).getComparatorLevel(); - if (!list1.isEmpty()) { - return Container.func_94526_b((IInventory)list1.get(0)); - } diff --git a/patches/minecraft/net/minecraft/block/DoublePlantBlock.java.patch b/patches/minecraft/net/minecraft/block/DoublePlantBlock.java.patch deleted file mode 100644 index 88103c304b..0000000000 --- a/patches/minecraft/net/minecraft/block/DoublePlantBlock.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/block/DoublePlantBlock.java -+++ b/net/minecraft/block/DoublePlantBlock.java -@@ -51,6 +_,7 @@ - return super.func_196260_a(p_196260_1_, p_196260_2_, p_196260_3_); - } else { - BlockState blockstate = p_196260_2_.func_180495_p(p_196260_3_.func_177977_b()); -+ if (p_196260_1_.func_177230_c() != this) return super.func_196260_a(p_196260_1_, p_196260_2_, p_196260_3_); //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. - return blockstate.func_203425_a(this) && blockstate.func_177229_b(field_176492_b) == DoubleBlockHalf.LOWER; - } - } diff --git a/patches/minecraft/net/minecraft/block/DropperBlock.java.patch b/patches/minecraft/net/minecraft/block/DropperBlock.java.patch deleted file mode 100644 index 7d70f11c19..0000000000 --- a/patches/minecraft/net/minecraft/block/DropperBlock.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/block/DropperBlock.java -+++ b/net/minecraft/block/DropperBlock.java -@@ -37,7 +_,7 @@ - p_176439_1_.func_217379_c(1001, p_176439_2_, 0); - } else { - ItemStack itemstack = dispensertileentity.func_70301_a(i); -- if (!itemstack.func_190926_b()) { -+ if (!itemstack.func_190926_b() && net.minecraftforge.items.VanillaInventoryCodeHooks.dropperInsertHook(p_176439_1_, p_176439_2_, dispensertileentity, i, itemstack)) { - Direction direction = p_176439_1_.func_180495_p(p_176439_2_).func_177229_b(field_176441_a); - IInventory iinventory = HopperTileEntity.func_195484_a(p_176439_1_, p_176439_2_.func_177972_a(direction)); - ItemStack itemstack1; diff --git a/patches/minecraft/net/minecraft/block/EnchantingTableBlock.java.patch b/patches/minecraft/net/minecraft/block/EnchantingTableBlock.java.patch deleted file mode 100644 index ca4416909c..0000000000 --- a/patches/minecraft/net/minecraft/block/EnchantingTableBlock.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/block/EnchantingTableBlock.java -+++ b/net/minecraft/block/EnchantingTableBlock.java -@@ -54,7 +_,7 @@ - if (p_180655_4_.nextInt(16) == 0) { - for(int k = 0; k <= 1; ++k) { - BlockPos blockpos = p_180655_3_.func_177982_a(i, k, j); -- if (p_180655_2_.func_180495_p(blockpos).func_203425_a(Blocks.field_150342_X)) { -+ if (p_180655_2_.func_180495_p(blockpos).getEnchantPowerBonus(p_180655_2_, blockpos) > 0) { - if (!p_180655_2_.func_175623_d(p_180655_3_.func_177982_a(i / 2, 0, j / 2))) { - break; - } diff --git a/patches/minecraft/net/minecraft/block/FallingBlock.java.patch b/patches/minecraft/net/minecraft/block/FallingBlock.java.patch deleted file mode 100644 index 858209d852..0000000000 --- a/patches/minecraft/net/minecraft/block/FallingBlock.java.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/block/FallingBlock.java -+++ b/net/minecraft/block/FallingBlock.java -@@ -30,7 +_,7 @@ - } - - public void func_225534_a_(BlockState p_225534_1_, ServerWorld p_225534_2_, BlockPos p_225534_3_, Random p_225534_4_) { -- if (func_185759_i(p_225534_2_.func_180495_p(p_225534_3_.func_177977_b())) && p_225534_3_.func_177956_o() >= 0) { -+ if (p_225534_2_.func_175623_d(p_225534_3_.func_177977_b()) || func_185759_i(p_225534_2_.func_180495_p(p_225534_3_.func_177977_b())) && p_225534_3_.func_177956_o() >= 0) { - FallingBlockEntity fallingblockentity = new FallingBlockEntity(p_225534_2_, (double)p_225534_3_.func_177958_n() + 0.5D, (double)p_225534_3_.func_177956_o(), (double)p_225534_3_.func_177952_p() + 0.5D, p_225534_2_.func_180495_p(p_225534_3_)); - this.func_149829_a(fallingblockentity); - p_225534_2_.func_217376_c(fallingblockentity); -@@ -59,7 +_,7 @@ - public void func_180655_c(BlockState p_180655_1_, World p_180655_2_, BlockPos p_180655_3_, Random p_180655_4_) { - if (p_180655_4_.nextInt(16) == 0) { - BlockPos blockpos = p_180655_3_.func_177977_b(); -- if (func_185759_i(p_180655_2_.func_180495_p(blockpos))) { -+ if (p_180655_2_.func_175623_d(blockpos) || func_185759_i(p_180655_2_.func_180495_p(blockpos))) { - double d0 = (double)p_180655_3_.func_177958_n() + p_180655_4_.nextDouble(); - double d1 = (double)p_180655_3_.func_177956_o() - 0.05D; - double d2 = (double)p_180655_3_.func_177952_p() + p_180655_4_.nextDouble(); diff --git a/patches/minecraft/net/minecraft/block/FarmlandBlock.java.patch b/patches/minecraft/net/minecraft/block/FarmlandBlock.java.patch deleted file mode 100644 index cf439f5941..0000000000 --- a/patches/minecraft/net/minecraft/block/FarmlandBlock.java.patch +++ /dev/null @@ -1,34 +0,0 @@ ---- a/net/minecraft/block/FarmlandBlock.java -+++ b/net/minecraft/block/FarmlandBlock.java -@@ -77,7 +_,7 @@ - } - - public void func_180658_a(World p_180658_1_, BlockPos p_180658_2_, Entity p_180658_3_, float p_180658_4_) { -- if (!p_180658_1_.field_72995_K && p_180658_1_.field_73012_v.nextFloat() < p_180658_4_ - 0.5F && p_180658_3_ instanceof LivingEntity && (p_180658_3_ instanceof PlayerEntity || p_180658_1_.func_82736_K().func_223586_b(GameRules.field_223599_b)) && p_180658_3_.func_213311_cf() * p_180658_3_.func_213311_cf() * p_180658_3_.func_213302_cg() > 0.512F) { -+ if (!p_180658_1_.field_72995_K && net.minecraftforge.common.ForgeHooks.onFarmlandTrample(p_180658_1_, p_180658_2_, Blocks.field_150346_d.func_176223_P(), p_180658_4_, p_180658_3_)) { // Forge: Move logic to Entity#canTrample - func_199610_d(p_180658_1_.func_180495_p(p_180658_2_), p_180658_1_, p_180658_2_); - } - -@@ -88,9 +_,10 @@ - p_199610_1_.func_175656_a(p_199610_2_, func_199601_a(p_199610_0_, Blocks.field_150346_d.func_176223_P(), p_199610_1_, p_199610_2_)); - } - -- private static boolean func_176529_d(IBlockReader p_176529_0_, BlockPos p_176529_1_) { -- Block block = p_176529_0_.func_180495_p(p_176529_1_.func_177984_a()).func_177230_c(); -- return block instanceof CropsBlock || block instanceof StemBlock || block instanceof AttachedStemBlock; -+ private boolean func_176529_d(IBlockReader p_176529_0_, BlockPos p_176529_1_) { -+ BlockState plant = p_176529_0_.func_180495_p(p_176529_1_.func_177984_a()); -+ BlockState state = p_176529_0_.func_180495_p(p_176529_1_); -+ return plant.func_177230_c() instanceof net.minecraftforge.common.IPlantable && state.canSustainPlant(p_176529_0_, p_176529_1_, Direction.UP, (net.minecraftforge.common.IPlantable)plant.func_177230_c()); - } - - private static boolean func_176530_e(IWorldReader p_176530_0_, BlockPos p_176530_1_) { -@@ -100,7 +_,7 @@ - } - } - -- return false; -+ return net.minecraftforge.common.FarmlandWaterManager.hasBlockWaterTicket(p_176530_0_, p_176530_1_); - } - - protected void func_206840_a(StateContainer.Builder p_206840_1_) { diff --git a/patches/minecraft/net/minecraft/block/FireBlock.java.patch b/patches/minecraft/net/minecraft/block/FireBlock.java.patch deleted file mode 100644 index f37807a2a3..0000000000 --- a/patches/minecraft/net/minecraft/block/FireBlock.java.patch +++ /dev/null @@ -1,136 +0,0 @@ ---- a/net/minecraft/block/FireBlock.java -+++ b/net/minecraft/block/FireBlock.java -@@ -92,13 +_,13 @@ - protected BlockState func_196448_a(IBlockReader p_196448_1_, BlockPos p_196448_2_) { - BlockPos blockpos = p_196448_2_.func_177977_b(); - BlockState blockstate = p_196448_1_.func_180495_p(blockpos); -- if (!this.func_196446_i(blockstate) && !blockstate.func_224755_d(p_196448_1_, blockpos, Direction.UP)) { -+ if (!this.canCatchFire(p_196448_1_, p_196448_2_, Direction.UP) && !blockstate.func_224755_d(p_196448_1_, blockpos, Direction.UP)) { - BlockState blockstate1 = this.func_176223_P(); - - for(Direction direction : Direction.values()) { - BooleanProperty booleanproperty = field_196449_B.get(direction); - if (booleanproperty != null) { -- blockstate1 = blockstate1.func_206870_a(booleanproperty, Boolean.valueOf(this.func_196446_i(p_196448_1_.func_180495_p(p_196448_2_.func_177972_a(direction))))); -+ blockstate1 = blockstate1.func_206870_a(booleanproperty, Boolean.valueOf(this.canCatchFire(p_196448_1_, p_196448_2_.func_177972_a(direction), direction.func_176734_d()))); - } - } - -@@ -121,7 +_,7 @@ - } - - BlockState blockstate = p_225534_2_.func_180495_p(p_225534_3_.func_177977_b()); -- boolean flag = blockstate.func_235714_a_(p_225534_2_.func_230315_m_().func_241515_q_()); -+ boolean flag = blockstate.isFireSource(p_225534_2_, p_225534_3_, Direction.UP); - int i = p_225534_1_.func_177229_b(field_176543_a); - if (!flag && p_225534_2_.func_72896_J() && this.func_176537_d(p_225534_2_, p_225534_3_) && p_225534_4_.nextFloat() < 0.2F + (float)i * 0.03F) { - p_225534_2_.func_217377_a(p_225534_3_, false); -@@ -142,7 +_,7 @@ - return; - } - -- if (i == 15 && p_225534_4_.nextInt(4) == 0 && !this.func_196446_i(p_225534_2_.func_180495_p(p_225534_3_.func_177977_b()))) { -+ if (i == 15 && p_225534_4_.nextInt(4) == 0 && !this.canCatchFire(p_225534_2_, p_225534_3_.func_177977_b(), Direction.UP)) { - p_225534_2_.func_217377_a(p_225534_3_, false); - return; - } -@@ -150,12 +_,12 @@ - - boolean flag1 = p_225534_2_.func_180502_D(p_225534_3_); - int k = flag1 ? -50 : 0; -- this.func_176536_a(p_225534_2_, p_225534_3_.func_177974_f(), 300 + k, p_225534_4_, i); -- this.func_176536_a(p_225534_2_, p_225534_3_.func_177976_e(), 300 + k, p_225534_4_, i); -- this.func_176536_a(p_225534_2_, p_225534_3_.func_177977_b(), 250 + k, p_225534_4_, i); -- this.func_176536_a(p_225534_2_, p_225534_3_.func_177984_a(), 250 + k, p_225534_4_, i); -- this.func_176536_a(p_225534_2_, p_225534_3_.func_177978_c(), 300 + k, p_225534_4_, i); -- this.func_176536_a(p_225534_2_, p_225534_3_.func_177968_d(), 300 + k, p_225534_4_, i); -+ this.tryCatchFire(p_225534_2_, p_225534_3_.func_177974_f(), 300 + k, p_225534_4_, i, Direction.WEST); -+ this.tryCatchFire(p_225534_2_, p_225534_3_.func_177976_e(), 300 + k, p_225534_4_, i, Direction.EAST); -+ this.tryCatchFire(p_225534_2_, p_225534_3_.func_177977_b(), 250 + k, p_225534_4_, i, Direction.UP); -+ this.tryCatchFire(p_225534_2_, p_225534_3_.func_177984_a(), 250 + k, p_225534_4_, i, Direction.DOWN); -+ this.tryCatchFire(p_225534_2_, p_225534_3_.func_177978_c(), 300 + k, p_225534_4_, i, Direction.SOUTH); -+ this.tryCatchFire(p_225534_2_, p_225534_3_.func_177968_d(), 300 + k, p_225534_4_, i, Direction.NORTH); - BlockPos.Mutable blockpos$mutable = new BlockPos.Mutable(); - - for(int l = -1; l <= 1; ++l) { -@@ -193,16 +_,18 @@ - return p_176537_1_.func_175727_C(p_176537_2_) || p_176537_1_.func_175727_C(p_176537_2_.func_177976_e()) || p_176537_1_.func_175727_C(p_176537_2_.func_177974_f()) || p_176537_1_.func_175727_C(p_176537_2_.func_177978_c()) || p_176537_1_.func_175727_C(p_176537_2_.func_177968_d()); - } - -+ @Deprecated //Forge: Use IForgeBlockState.getFlammability, Public for default implementation only. - public int func_220274_q(BlockState p_220274_1_) { - return p_220274_1_.func_235901_b_(BlockStateProperties.field_208198_y) && p_220274_1_.func_177229_b(BlockStateProperties.field_208198_y) ? 0 : this.field_149848_b.getInt(p_220274_1_.func_177230_c()); - } - -+ @Deprecated //Forge: Use IForgeBlockState.getFireSpreadSpeed - public int func_220275_r(BlockState p_220275_1_) { - return p_220275_1_.func_235901_b_(BlockStateProperties.field_208198_y) && p_220275_1_.func_177229_b(BlockStateProperties.field_208198_y) ? 0 : this.field_149849_a.getInt(p_220275_1_.func_177230_c()); - } - -- private void func_176536_a(World p_176536_1_, BlockPos p_176536_2_, int p_176536_3_, Random p_176536_4_, int p_176536_5_) { -- int i = this.func_220274_q(p_176536_1_.func_180495_p(p_176536_2_)); -+ private void tryCatchFire(World p_176536_1_, BlockPos p_176536_2_, int p_176536_3_, Random p_176536_4_, int p_176536_5_, Direction face) { -+ int i = p_176536_1_.func_180495_p(p_176536_2_).getFlammability(p_176536_1_, p_176536_2_, face); - if (p_176536_4_.nextInt(p_176536_3_) < i) { - BlockState blockstate = p_176536_1_.func_180495_p(p_176536_2_); - if (p_176536_4_.nextInt(p_176536_5_ + 10) < 5 && !p_176536_1_.func_175727_C(p_176536_2_)) { -@@ -212,11 +_,7 @@ - p_176536_1_.func_217377_a(p_176536_2_, false); - } - -- Block block = blockstate.func_177230_c(); -- if (block instanceof TNTBlock) { -- TNTBlock tntblock = (TNTBlock)block; -- TNTBlock.func_196534_a(p_176536_1_, p_176536_2_); -- } -+ blockstate.catchFire(p_176536_1_, p_176536_2_, face, null); - } - - } -@@ -228,7 +_,7 @@ - - private boolean func_196447_a(IBlockReader p_196447_1_, BlockPos p_196447_2_) { - for(Direction direction : Direction.values()) { -- if (this.func_196446_i(p_196447_1_.func_180495_p(p_196447_2_.func_177972_a(direction)))) { -+ if (this.canCatchFire(p_196447_1_, p_196447_2_.func_177972_a(direction), direction.func_176734_d())) { - return true; - } - } -@@ -244,13 +_,14 @@ - - for(Direction direction : Direction.values()) { - BlockState blockstate = p_176538_1_.func_180495_p(p_176538_2_.func_177972_a(direction)); -- i = Math.max(this.func_220275_r(blockstate), i); -+ i = Math.max(blockstate.getFireSpreadSpeed(p_176538_1_, p_176538_2_.func_177972_a(direction), direction.func_176734_d()), i); - } - - return i; - } - } - -+ @Deprecated //Forge: Use canCatchFire with more context - protected boolean func_196446_i(BlockState p_196446_1_) { - return this.func_220275_r(p_196446_1_) > 0; - } -@@ -269,8 +_,21 @@ - } - - private void func_180686_a(Block p_180686_1_, int p_180686_2_, int p_180686_3_) { -+ if (p_180686_1_ == Blocks.field_150350_a) throw new IllegalArgumentException("Tried to set air on fire... This is bad."); - this.field_149849_a.put(p_180686_1_, p_180686_2_); - this.field_149848_b.put(p_180686_1_, p_180686_3_); -+ } -+ -+ /** -+ * Side sensitive version that calls the block function. -+ * -+ * @param world The current world -+ * @param pos Block position -+ * @param face The side the fire is coming from -+ * @return True if the face can catch fire. -+ */ -+ public boolean canCatchFire(IBlockReader world, BlockPos pos, Direction face) { -+ return world.func_180495_p(pos).isFlammable(world, pos, face); - } - - public static void func_149843_e() { diff --git a/patches/minecraft/net/minecraft/block/FlowerPotBlock.java.patch b/patches/minecraft/net/minecraft/block/FlowerPotBlock.java.patch deleted file mode 100644 index e4d035b267..0000000000 --- a/patches/minecraft/net/minecraft/block/FlowerPotBlock.java.patch +++ /dev/null @@ -1,86 +0,0 @@ ---- a/net/minecraft/block/FlowerPotBlock.java -+++ b/net/minecraft/block/FlowerPotBlock.java -@@ -24,10 +_,33 @@ - protected static final VoxelShape field_196450_a = Block.func_208617_a(5.0D, 0.0D, 5.0D, 11.0D, 6.0D, 11.0D); - private final Block field_196452_c; - -+ @Deprecated // Mods should use the constructor below - public FlowerPotBlock(Block p_i48395_1_, AbstractBlock.Properties p_i48395_2_) { -- super(p_i48395_2_); -- this.field_196452_c = p_i48395_1_; -- field_196451_b.put(p_i48395_1_, this); -+ this(Blocks.field_150457_bL == null ? null : () -> (FlowerPotBlock) Blocks.field_150457_bL.delegate.get(), () -> p_i48395_1_.delegate.get(), p_i48395_2_); -+ if (Blocks.field_150457_bL != null) { -+ ((FlowerPotBlock)Blocks.field_150457_bL).addPlant(p_i48395_1_.getRegistryName(), () -> this); -+ } -+ } -+ -+ /** -+ * For mod use, eliminates the need to extend this class, and prevents modded -+ * flower pots from altering vanilla behavior. -+ * -+ * @param emptyPot The empty pot for this pot, or null for self. -+ * @param block The flower block. -+ * @param properties -+ */ -+ public FlowerPotBlock(@javax.annotation.Nullable java.util.function.Supplier emptyPot, java.util.function.Supplier p_i48395_1_, AbstractBlock.Properties properties) { -+ super(properties); -+ this.field_196452_c = null; // Unused, redirected by coremod -+ this.flowerDelegate = p_i48395_1_; -+ if (emptyPot == null) { -+ this.fullPots = Maps.newHashMap(); -+ this.emptyPot = null; -+ } else { -+ this.fullPots = java.util.Collections.emptyMap(); -+ this.emptyPot = emptyPot; -+ } - } - - public VoxelShape func_220053_a(BlockState p_220053_1_, IBlockReader p_220053_2_, BlockPos p_220053_3_, ISelectionContext p_220053_4_) { -@@ -41,7 +_,7 @@ - public ActionResultType func_225533_a_(BlockState p_225533_1_, World p_225533_2_, BlockPos p_225533_3_, PlayerEntity p_225533_4_, Hand p_225533_5_, BlockRayTraceResult p_225533_6_) { - ItemStack itemstack = p_225533_4_.func_184586_b(p_225533_5_); - Item item = itemstack.func_77973_b(); -- Block block = item instanceof BlockItem ? field_196451_b.getOrDefault(((BlockItem)item).func_179223_d(), Blocks.field_150350_a) : Blocks.field_150350_a; -+ Block block = item instanceof BlockItem ? getEmptyPot().fullPots.getOrDefault(((BlockItem)item).func_179223_d().getRegistryName(), Blocks.field_150350_a.delegate).get() : Blocks.field_150350_a; - boolean flag = block == Blocks.field_150350_a; - boolean flag1 = this.field_196452_c == Blocks.field_150350_a; - if (flag != flag1) { -@@ -59,7 +_,7 @@ - p_225533_4_.func_71019_a(itemstack1, false); - } - -- p_225533_2_.func_180501_a(p_225533_3_, Blocks.field_150457_bL.func_176223_P(), 3); -+ p_225533_2_.func_180501_a(p_225533_3_, getEmptyPot().func_176223_P(), 3); - } - - return ActionResultType.func_233537_a_(p_225533_2_.field_72995_K); -@@ -77,10 +_,27 @@ - } - - public Block func_220276_d() { -- return this.field_196452_c; -+ return flowerDelegate.get(); - } - - public boolean func_196266_a(BlockState p_196266_1_, IBlockReader p_196266_2_, BlockPos p_196266_3_, PathType p_196266_4_) { - return false; - } -+ -+ //Forge Start -+ private final Map> fullPots; -+ private final java.util.function.Supplier emptyPot; -+ private final java.util.function.Supplier flowerDelegate; -+ -+ public FlowerPotBlock getEmptyPot() { -+ return emptyPot == null ? this : emptyPot.get(); -+ } -+ -+ public void addPlant(net.minecraft.util.ResourceLocation flower, java.util.function.Supplier fullPot) { -+ if (getEmptyPot() != this) { -+ throw new IllegalArgumentException("Cannot add plant to non-empty pot: " + this); -+ } -+ fullPots.put(flower, fullPot); -+ } -+ //Forge End - } diff --git a/patches/minecraft/net/minecraft/block/FlowingFluidBlock.java.patch b/patches/minecraft/net/minecraft/block/FlowingFluidBlock.java.patch deleted file mode 100644 index dac95dab33..0000000000 --- a/patches/minecraft/net/minecraft/block/FlowingFluidBlock.java.patch +++ /dev/null @@ -1,85 +0,0 @@ ---- a/net/minecraft/block/FlowingFluidBlock.java -+++ b/net/minecraft/block/FlowingFluidBlock.java -@@ -29,10 +_,11 @@ - - public class FlowingFluidBlock extends Block implements IBucketPickupHandler { - public static final IntegerProperty field_176367_b = BlockStateProperties.field_208132_ag; -- protected final FlowingFluid field_204517_c; -+ private final FlowingFluid field_204517_c; - private final List field_212565_c; - public static final VoxelShape field_235510_c_ = Block.func_208617_a(0.0D, 0.0D, 0.0D, 16.0D, 8.0D, 16.0D); - -+ @Deprecated // Forge: Use the constructor that takes a supplier - public FlowingFluidBlock(FlowingFluid p_i49014_1_, AbstractBlock.Properties p_i49014_2_) { - super(p_i49014_2_); - this.field_204517_c = p_i49014_1_; -@@ -45,6 +_,19 @@ - - this.field_212565_c.add(p_i49014_1_.func_207207_a(8, true)); - this.func_180632_j(this.field_176227_L.func_177621_b().func_206870_a(field_176367_b, Integer.valueOf(0))); -+ fluidStateCacheInitialized = true; -+ supplier = p_i49014_1_.delegate; -+ } -+ -+ /** -+ * @param supplier A fluid supplier such as {@link net.minecraftforge.fml.RegistryObject} -+ */ -+ public FlowingFluidBlock(java.util.function.Supplier supplier, AbstractBlock.Properties p_i48368_1_) { -+ super(p_i48368_1_); -+ this.field_204517_c = null; -+ this.field_212565_c = Lists.newArrayList(); -+ this.func_180632_j(this.field_176227_L.func_177621_b().func_206870_a(field_176367_b, Integer.valueOf(0))); -+ this.supplier = supplier; - } - - public VoxelShape func_220071_b(BlockState p_220071_1_, IBlockReader p_220071_2_, BlockPos p_220071_3_, ISelectionContext p_220071_4_) { -@@ -69,6 +_,7 @@ - - public FluidState func_204507_t(BlockState p_204507_1_) { - int i = p_204507_1_.func_177229_b(field_176367_b); -+ if (!fluidStateCacheInitialized) initFluidStateCache(); - return this.field_212565_c.get(Math.min(i, 8)); - } - -@@ -120,13 +_,13 @@ - BlockPos blockpos = p_204515_2_.func_177972_a(direction); - if (p_204515_1_.func_204610_c(blockpos).func_206884_a(FluidTags.field_206959_a)) { - Block block = p_204515_1_.func_204610_c(p_204515_2_).func_206889_d() ? Blocks.field_150343_Z : Blocks.field_150347_e; -- p_204515_1_.func_175656_a(p_204515_2_, block.func_176223_P()); -+ p_204515_1_.func_175656_a(p_204515_2_, net.minecraftforge.event.ForgeEventFactory.fireFluidPlaceBlockEvent(p_204515_1_, p_204515_2_, p_204515_2_, block.func_176223_P())); - this.func_180688_d(p_204515_1_, p_204515_2_); - return false; - } - - if (flag && p_204515_1_.func_180495_p(blockpos).func_203425_a(Blocks.field_205164_gk)) { -- p_204515_1_.func_175656_a(p_204515_2_, Blocks.field_235337_cO_.func_176223_P()); -+ p_204515_1_.func_175656_a(p_204515_2_, net.minecraftforge.event.ForgeEventFactory.fireFluidPlaceBlockEvent(p_204515_1_, p_204515_2_, p_204515_2_, Blocks.field_235337_cO_.func_176223_P())); - this.func_180688_d(p_204515_1_, p_204515_2_); - return false; - } -@@ -151,6 +_,25 @@ - return this.field_204517_c; - } else { - return Fluids.field_204541_a; -+ } -+ } -+ -+ // Forge start -+ private final java.util.function.Supplier supplier; -+ public FlowingFluid getFluid() { -+ return (FlowingFluid)supplier.get(); -+ } -+ -+ private boolean fluidStateCacheInitialized = false; -+ protected synchronized void initFluidStateCache() { -+ if (fluidStateCacheInitialized == false) { -+ this.field_212565_c.add(getFluid().func_207204_a(false)); -+ -+ for (int i = 1; i < 8; ++i) -+ this.field_212565_c.add(getFluid().func_207207_a(8 - i, false)); -+ -+ this.field_212565_c.add(getFluid().func_207207_a(8, true)); -+ fluidStateCacheInitialized = true; - } - } - } diff --git a/patches/minecraft/net/minecraft/block/ITileEntityProvider.java.patch b/patches/minecraft/net/minecraft/block/ITileEntityProvider.java.patch deleted file mode 100644 index cecbfff826..0000000000 --- a/patches/minecraft/net/minecraft/block/ITileEntityProvider.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/block/ITileEntityProvider.java -+++ b/net/minecraft/block/ITileEntityProvider.java -@@ -4,6 +_,7 @@ - import net.minecraft.tileentity.TileEntity; - import net.minecraft.world.IBlockReader; - -+@Deprecated //Forge: Do not use, use BlockState.hasTileEntity/Block.createTileEntity - public interface ITileEntityProvider { - @Nullable - TileEntity func_196283_a_(IBlockReader p_196283_1_); diff --git a/patches/minecraft/net/minecraft/block/LeavesBlock.java.patch b/patches/minecraft/net/minecraft/block/LeavesBlock.java.patch deleted file mode 100644 index b20f63a617..0000000000 --- a/patches/minecraft/net/minecraft/block/LeavesBlock.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/block/LeavesBlock.java -+++ b/net/minecraft/block/LeavesBlock.java -@@ -19,7 +_,7 @@ - import net.minecraftforge.api.distmarker.Dist; - import net.minecraftforge.api.distmarker.OnlyIn; - --public class LeavesBlock extends Block { -+public class LeavesBlock extends Block implements net.minecraftforge.common.IForgeShearable { - public static final IntegerProperty field_208494_a = BlockStateProperties.field_208514_aa; - public static final BooleanProperty field_208495_b = BlockStateProperties.field_208515_s; - diff --git a/patches/minecraft/net/minecraft/block/MushroomBlock.java.patch b/patches/minecraft/net/minecraft/block/MushroomBlock.java.patch deleted file mode 100644 index a01a838815..0000000000 --- a/patches/minecraft/net/minecraft/block/MushroomBlock.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/block/MushroomBlock.java -+++ b/net/minecraft/block/MushroomBlock.java -@@ -64,7 +_,7 @@ - if (blockstate.func_235714_a_(BlockTags.field_242171_aD)) { - return true; - } else { -- return p_196260_2_.func_226659_b_(p_196260_3_, 0) < 13 && this.func_200014_a_(blockstate, p_196260_2_, blockpos); -+ return p_196260_2_.func_226659_b_(p_196260_3_, 0) < 13 && blockstate.canSustainPlant(p_196260_2_, blockpos, net.minecraft.util.Direction.UP, this); - } - } - diff --git a/patches/minecraft/net/minecraft/block/NetherWartBlock.java.patch b/patches/minecraft/net/minecraft/block/NetherWartBlock.java.patch deleted file mode 100644 index f07b5ea7b2..0000000000 --- a/patches/minecraft/net/minecraft/block/NetherWartBlock.java.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/net/minecraft/block/NetherWartBlock.java -+++ b/net/minecraft/block/NetherWartBlock.java -@@ -35,9 +_,10 @@ - - public void func_225542_b_(BlockState p_225542_1_, ServerWorld p_225542_2_, BlockPos p_225542_3_, Random p_225542_4_) { - int i = p_225542_1_.func_177229_b(field_176486_a); -- if (i < 3 && p_225542_4_.nextInt(10) == 0) { -+ if (i < 3 && net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_225542_2_, p_225542_3_, p_225542_1_, p_225542_4_.nextInt(10) == 0)) { - p_225542_1_ = p_225542_1_.func_206870_a(field_176486_a, Integer.valueOf(i + 1)); - p_225542_2_.func_180501_a(p_225542_3_, p_225542_1_, 2); -+ net.minecraftforge.common.ForgeHooks.onCropsGrowPost(p_225542_2_, p_225542_3_, p_225542_1_); - } - - } diff --git a/patches/minecraft/net/minecraft/block/NoteBlock.java.patch b/patches/minecraft/net/minecraft/block/NoteBlock.java.patch deleted file mode 100644 index 79ada4da25..0000000000 --- a/patches/minecraft/net/minecraft/block/NoteBlock.java.patch +++ /dev/null @@ -1,32 +0,0 @@ ---- a/net/minecraft/block/NoteBlock.java -+++ b/net/minecraft/block/NoteBlock.java -@@ -50,7 +_,7 @@ - } - - private void func_196482_a(World p_196482_1_, BlockPos p_196482_2_) { -- if (p_196482_1_.func_180495_p(p_196482_2_.func_177984_a()).func_196958_f()) { -+ if (p_196482_1_.func_175623_d(p_196482_2_.func_177984_a())) { - p_196482_1_.func_175641_c(p_196482_2_, this, 0, 0); - } - -@@ -60,7 +_,9 @@ - if (p_225533_2_.field_72995_K) { - return ActionResultType.SUCCESS; - } else { -- p_225533_1_ = p_225533_1_.func_235896_a_(field_196485_c); -+ int _new = net.minecraftforge.common.ForgeHooks.onNoteChange(p_225533_2_, p_225533_3_, p_225533_1_, p_225533_1_.func_177229_b(field_196485_c), p_225533_1_.func_235896_a_(field_196485_c).func_177229_b(field_196485_c)); -+ if (_new == -1) return ActionResultType.FAIL; -+ p_225533_1_ = p_225533_1_.func_206870_a(field_196485_c, _new); - p_225533_2_.func_180501_a(p_225533_3_, p_225533_1_, 3); - this.func_196482_a(p_225533_2_, p_225533_3_); - p_225533_4_.func_195066_a(Stats.field_188087_U); -@@ -76,6 +_,9 @@ - } - - public boolean func_189539_a(BlockState p_189539_1_, World p_189539_2_, BlockPos p_189539_3_, int p_189539_4_, int p_189539_5_) { -+ net.minecraftforge.event.world.NoteBlockEvent.Play e = new net.minecraftforge.event.world.NoteBlockEvent.Play(p_189539_2_, p_189539_3_, p_189539_1_, p_189539_1_.func_177229_b(field_196485_c), p_189539_1_.func_177229_b(field_196483_a)); -+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(e)) return false; -+ p_189539_1_ = p_189539_1_.func_206870_a(field_196485_c, e.getVanillaNoteId()).func_206870_a(field_196483_a, e.getInstrument()); - int i = p_189539_1_.func_177229_b(field_196485_c); - float f = (float)Math.pow(2.0D, (double)(i - 12) / 12.0D); - p_189539_2_.func_184133_a((PlayerEntity)null, p_189539_3_, p_189539_1_.func_177229_b(field_196483_a).func_208088_a(), SoundCategory.RECORDS, 3.0F, f); diff --git a/patches/minecraft/net/minecraft/block/OreBlock.java.patch b/patches/minecraft/net/minecraft/block/OreBlock.java.patch deleted file mode 100644 index 9e831cc6f0..0000000000 --- a/patches/minecraft/net/minecraft/block/OreBlock.java.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- a/net/minecraft/block/OreBlock.java -+++ b/net/minecraft/block/OreBlock.java -@@ -31,12 +_,10 @@ - - public void func_220062_a(BlockState p_220062_1_, ServerWorld p_220062_2_, BlockPos p_220062_3_, ItemStack p_220062_4_) { - super.func_220062_a(p_220062_1_, p_220062_2_, p_220062_3_, p_220062_4_); -- if (EnchantmentHelper.func_77506_a(Enchantments.field_185306_r, p_220062_4_) == 0) { -- int i = this.func_220281_a(p_220062_2_.field_73012_v); -- if (i > 0) { -- this.func_180637_b(p_220062_2_, p_220062_3_, i); -- } -- } -+ } - -+ @Override -+ public int getExpDrop(BlockState state, net.minecraft.world.IWorldReader reader, BlockPos pos, int fortune, int silktouch) { -+ return silktouch == 0 ? this.func_220281_a(RANDOM) : 0; - } - } diff --git a/patches/minecraft/net/minecraft/block/PistonBlock.java.patch b/patches/minecraft/net/minecraft/block/PistonBlock.java.patch deleted file mode 100644 index 44aa84927e..0000000000 --- a/patches/minecraft/net/minecraft/block/PistonBlock.java.patch +++ /dev/null @@ -1,55 +0,0 @@ ---- a/net/minecraft/block/PistonBlock.java -+++ b/net/minecraft/block/PistonBlock.java -@@ -158,6 +_,7 @@ - } - - if (p_189539_4_ == 0) { -+ if (net.minecraftforge.event.ForgeEventFactory.onPistonMovePre(p_189539_2_, p_189539_3_, direction, true)) return false; - if (!this.func_176319_a(p_189539_2_, p_189539_3_, direction, true)) { - return false; - } -@@ -165,6 +_,7 @@ - p_189539_2_.func_180501_a(p_189539_3_, p_189539_1_.func_206870_a(field_176320_b, Boolean.valueOf(true)), 67); - p_189539_2_.func_184133_a((PlayerEntity)null, p_189539_3_, SoundEvents.field_187715_dR, SoundCategory.BLOCKS, 0.5F, p_189539_2_.field_73012_v.nextFloat() * 0.25F + 0.6F); - } else if (p_189539_4_ == 1 || p_189539_4_ == 2) { -+ if (net.minecraftforge.event.ForgeEventFactory.onPistonMovePre(p_189539_2_, p_189539_3_, direction, false)) return false; - TileEntity tileentity1 = p_189539_2_.func_175625_s(p_189539_3_.func_177972_a(direction)); - if (tileentity1 instanceof PistonTileEntity) { - ((PistonTileEntity)tileentity1).func_145866_f(); -@@ -204,6 +_,7 @@ - p_189539_2_.func_184133_a((PlayerEntity)null, p_189539_3_, SoundEvents.field_187712_dQ, SoundCategory.BLOCKS, 0.5F, p_189539_2_.field_73012_v.nextFloat() * 0.15F + 0.6F); - } - -+ net.minecraftforge.event.ForgeEventFactory.onPistonMovePost(p_189539_2_, p_189539_3_, direction, (p_189539_4_ == 0)); - return true; - } - -@@ -234,7 +_,7 @@ - return false; - } - -- return !p_185646_0_.func_177230_c().func_235695_q_(); -+ return !p_185646_0_.hasTileEntity(); - } - } else { - return false; -@@ -273,7 +_,7 @@ - for(int k = list2.size() - 1; k >= 0; --k) { - BlockPos blockpos2 = list2.get(k); - BlockState blockstate1 = p_176319_1_.func_180495_p(blockpos2); -- TileEntity tileentity = blockstate1.func_177230_c().func_235695_q_() ? p_176319_1_.func_175625_s(blockpos2) : null; -+ TileEntity tileentity = blockstate1.hasTileEntity() ? p_176319_1_.func_175625_s(blockpos2) : null; - func_220059_a(blockstate1, p_176319_1_, blockpos2, tileentity); - p_176319_1_.func_180501_a(blockpos2, Blocks.field_150350_a.func_176223_P(), 18); - ablockstate[j++] = blockstate1; -@@ -335,6 +_,10 @@ - - public BlockState func_185499_a(BlockState p_185499_1_, Rotation p_185499_2_) { - return p_185499_1_.func_206870_a(field_176387_N, p_185499_2_.func_185831_a(p_185499_1_.func_177229_b(field_176387_N))); -+ } -+ -+ public BlockState rotate(BlockState state, net.minecraft.world.IWorld world, BlockPos pos, Rotation direction) { -+ return state.func_177229_b(field_176320_b) ? state : super.rotate(state, world, pos, direction); - } - - public BlockState func_185471_a(BlockState p_185471_1_, Mirror p_185471_2_) { diff --git a/patches/minecraft/net/minecraft/block/PistonBlockStructureHelper.java.patch b/patches/minecraft/net/minecraft/block/PistonBlockStructureHelper.java.patch deleted file mode 100644 index 9a5909d46b..0000000000 --- a/patches/minecraft/net/minecraft/block/PistonBlockStructureHelper.java.patch +++ /dev/null @@ -1,81 +0,0 @@ ---- a/net/minecraft/block/PistonBlockStructureHelper.java -+++ b/net/minecraft/block/PistonBlockStructureHelper.java -@@ -48,7 +_,7 @@ - } else { - for(int i = 0; i < this.field_177258_e.size(); ++i) { - BlockPos blockpos = this.field_177258_e.get(i); -- if (func_227029_a_(this.field_177261_a.func_180495_p(blockpos).func_177230_c()) && !this.func_177250_b(blockpos)) { -+ if (this.field_177261_a.func_180495_p(blockpos).isStickyBlock() && !this.func_177250_b(blockpos)) { - return false; - } - } -@@ -57,24 +_,9 @@ - } - } - -- private static boolean func_227029_a_(Block p_227029_0_) { -- return p_227029_0_ == Blocks.field_180399_cE || p_227029_0_ == Blocks.field_226907_mc_; -- } -- -- private static boolean func_227030_a_(Block p_227030_0_, Block p_227030_1_) { -- if (p_227030_0_ == Blocks.field_226907_mc_ && p_227030_1_ == Blocks.field_180399_cE) { -- return false; -- } else if (p_227030_0_ == Blocks.field_180399_cE && p_227030_1_ == Blocks.field_226907_mc_) { -- return false; -- } else { -- return func_227029_a_(p_227030_0_) || func_227029_a_(p_227030_1_); -- } -- } -- - private boolean func_177251_a(BlockPos p_177251_1_, Direction p_177251_2_) { - BlockState blockstate = this.field_177261_a.func_180495_p(p_177251_1_); -- Block block = blockstate.func_177230_c(); -- if (blockstate.func_196958_f()) { -+ if (field_177261_a.func_175623_d(p_177251_1_)) { - return true; - } else if (!PistonBlock.func_185646_a(blockstate, this.field_177261_a, p_177251_1_, this.field_177257_d, false, p_177251_2_)) { - return true; -@@ -87,12 +_,12 @@ - if (i + this.field_177258_e.size() > 12) { - return false; - } else { -- while(func_227029_a_(block)) { -+ BlockState oldState; -+ while(blockstate.isStickyBlock()) { - BlockPos blockpos = p_177251_1_.func_177967_a(this.field_177257_d.func_176734_d(), i); -- Block block1 = block; -+ oldState = blockstate; - blockstate = this.field_177261_a.func_180495_p(blockpos); -- block = blockstate.func_177230_c(); -- if (blockstate.func_196958_f() || !func_227030_a_(block1, block) || !PistonBlock.func_185646_a(blockstate, this.field_177261_a, blockpos, this.field_177257_d, false, this.field_177257_d.func_176734_d()) || blockpos.equals(this.field_177259_b)) { -+ if (blockstate.isAir(this.field_177261_a, blockpos) || !oldState.canStickTo(blockstate) || !PistonBlock.func_185646_a(blockstate, this.field_177261_a, blockpos, this.field_177257_d, false, this.field_177257_d.func_176734_d()) || blockpos.equals(this.field_177259_b)) { - break; - } - -@@ -119,7 +_,7 @@ - - for(int k = 0; k <= j + l; ++k) { - BlockPos blockpos2 = this.field_177258_e.get(k); -- if (func_227029_a_(this.field_177261_a.func_180495_p(blockpos2).func_177230_c()) && !this.func_177250_b(blockpos2)) { -+ if (this.field_177261_a.func_180495_p(blockpos2).isStickyBlock() && !this.func_177250_b(blockpos2)) { - return false; - } - } -@@ -128,7 +_,7 @@ - } - - blockstate = this.field_177261_a.func_180495_p(blockpos1); -- if (blockstate.func_196958_f()) { -+ if (blockstate.isAir(field_177261_a, blockpos1)) { - return true; - } - -@@ -173,7 +_,7 @@ - if (direction.func_176740_k() != this.field_177257_d.func_176740_k()) { - BlockPos blockpos = p_177250_1_.func_177972_a(direction); - BlockState blockstate1 = this.field_177261_a.func_180495_p(blockpos); -- if (func_227030_a_(blockstate1.func_177230_c(), blockstate.func_177230_c()) && !this.func_177251_a(blockpos, direction)) { -+ if (blockstate1.canStickTo(blockstate) && !this.func_177251_a(blockpos, direction)) { - return false; - } - } diff --git a/patches/minecraft/net/minecraft/block/PortalSize.java.patch b/patches/minecraft/net/minecraft/block/PortalSize.java.patch deleted file mode 100644 index 18e35628ec..0000000000 --- a/patches/minecraft/net/minecraft/block/PortalSize.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/block/PortalSize.java -+++ b/net/minecraft/block/PortalSize.java -@@ -16,7 +_,7 @@ - - public class PortalSize { - private static final AbstractBlock.IPositionPredicate field_242962_a = (p_242966_0_, p_242966_1_, p_242966_2_) -> { -- return p_242966_0_.func_203425_a(Blocks.field_150343_Z); -+ return p_242966_0_.isPortalFrame(p_242966_1_, p_242966_2_); - }; - private final IWorld field_150867_a; - private final Direction.Axis field_150865_b; diff --git a/patches/minecraft/net/minecraft/block/PoweredRailBlock.java.patch b/patches/minecraft/net/minecraft/block/PoweredRailBlock.java.patch deleted file mode 100644 index 3e741398d1..0000000000 --- a/patches/minecraft/net/minecraft/block/PoweredRailBlock.java.patch +++ /dev/null @@ -1,57 +0,0 @@ ---- a/net/minecraft/block/PoweredRailBlock.java -+++ b/net/minecraft/block/PoweredRailBlock.java -@@ -14,10 +_,16 @@ - public class PoweredRailBlock extends AbstractRailBlock { - public static final EnumProperty field_176568_b = BlockStateProperties.field_208166_S; - public static final BooleanProperty field_176569_M = BlockStateProperties.field_208194_u; -+ private final boolean isActivator; // TRUE for an Activator Rail, FALSE for Powered Rail - - public PoweredRailBlock(AbstractBlock.Properties p_i48349_1_) { -- super(true, p_i48349_1_); -+ this(p_i48349_1_, false); -+ } -+ -+ protected PoweredRailBlock(AbstractBlock.Properties builder, boolean isPoweredRail) { -+ super(true, builder); - this.func_180632_j(this.field_176227_L.func_177621_b().func_206870_a(field_176568_b, RailShape.NORTH_SOUTH).func_206870_a(field_176569_M, Boolean.valueOf(false))); -+ this.isActivator = !isPoweredRail; - } - - protected boolean func_176566_a(World p_176566_1_, BlockPos p_176566_2_, BlockState p_176566_3_, boolean p_176566_4_, int p_176566_5_) { -@@ -99,13 +_,13 @@ - - protected boolean func_208071_a(World p_208071_1_, BlockPos p_208071_2_, boolean p_208071_3_, int p_208071_4_, RailShape p_208071_5_) { - BlockState blockstate = p_208071_1_.func_180495_p(p_208071_2_); -- if (!blockstate.func_203425_a(this)) { -+ if (!(blockstate.func_177230_c() instanceof PoweredRailBlock)) { - return false; - } else { -- RailShape railshape = blockstate.func_177229_b(field_176568_b); -+ RailShape railshape = getRailDirection(blockstate, p_208071_1_, p_208071_2_, null); - if (p_208071_5_ != RailShape.EAST_WEST || railshape != RailShape.NORTH_SOUTH && railshape != RailShape.ASCENDING_NORTH && railshape != RailShape.ASCENDING_SOUTH) { - if (p_208071_5_ != RailShape.NORTH_SOUTH || railshape != RailShape.EAST_WEST && railshape != RailShape.ASCENDING_EAST && railshape != RailShape.ASCENDING_WEST) { -- if (blockstate.func_177229_b(field_176569_M)) { -+ if (isActivator == (((PoweredRailBlock) blockstate.func_177230_c()).isActivator)) { - return p_208071_1_.func_175640_z(p_208071_2_) ? true : this.func_176566_a(p_208071_1_, p_208071_2_, blockstate, p_208071_3_, p_208071_4_ + 1); - } else { - return false; -@@ -156,6 +_,9 @@ - return p_185499_1_.func_206870_a(field_176568_b, RailShape.SOUTH_EAST); - case NORTH_EAST: - return p_185499_1_.func_206870_a(field_176568_b, RailShape.SOUTH_WEST); -+ case NORTH_SOUTH: //Forge fix: MC-196102 -+ case EAST_WEST: -+ return p_185499_1_; - } - case COUNTERCLOCKWISE_90: - switch((RailShape)p_185499_1_.func_177229_b(field_176568_b)) { -@@ -254,5 +_,9 @@ - - protected void func_206840_a(StateContainer.Builder p_206840_1_) { - p_206840_1_.func_206894_a(field_176568_b, field_176569_M); -+ } -+ -+ public boolean isActivatorRail() { -+ return isActivator; - } - } diff --git a/patches/minecraft/net/minecraft/block/RailBlock.java.patch b/patches/minecraft/net/minecraft/block/RailBlock.java.patch deleted file mode 100644 index 95ce1dc1d6..0000000000 --- a/patches/minecraft/net/minecraft/block/RailBlock.java.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/net/minecraft/block/RailBlock.java -+++ b/net/minecraft/block/RailBlock.java -@@ -49,6 +_,9 @@ - return p_185499_1_.func_206870_a(field_176565_b, RailShape.SOUTH_EAST); - case NORTH_EAST: - return p_185499_1_.func_206870_a(field_176565_b, RailShape.SOUTH_WEST); -+ case NORTH_SOUTH: //Forge fix: MC-196102 -+ case EAST_WEST: -+ return p_185499_1_; - } - case COUNTERCLOCKWISE_90: - switch((RailShape)p_185499_1_.func_177229_b(field_176565_b)) { diff --git a/patches/minecraft/net/minecraft/block/RailState.java.patch b/patches/minecraft/net/minecraft/block/RailState.java.patch deleted file mode 100644 index a5857110ca..0000000000 --- a/patches/minecraft/net/minecraft/block/RailState.java.patch +++ /dev/null @@ -1,57 +0,0 @@ ---- a/net/minecraft/block/RailState.java -+++ b/net/minecraft/block/RailState.java -@@ -15,14 +_,16 @@ - private BlockState field_196923_d; - private final boolean field_208513_e; - private final List field_196924_e = Lists.newArrayList(); -+ private final boolean canMakeSlopes; - - public RailState(World p_i47755_1_, BlockPos p_i47755_2_, BlockState p_i47755_3_) { - this.field_196920_a = p_i47755_1_; - this.field_196921_b = p_i47755_2_; - this.field_196923_d = p_i47755_3_; - this.field_196922_c = (AbstractRailBlock)p_i47755_3_.func_177230_c(); -- RailShape railshape = p_i47755_3_.func_177229_b(this.field_196922_c.func_176560_l()); -- this.field_208513_e = this.field_196922_c.func_208490_b(); -+ RailShape railshape = this.field_196922_c.getRailDirection(field_196923_d, p_i47755_1_, p_i47755_2_, null); -+ this.field_208513_e = !this.field_196922_c.isFlexibleRail(field_196923_d, p_i47755_1_, p_i47755_2_); -+ this.canMakeSlopes = this.field_196922_c.canMakeSlopes(field_196923_d, p_i47755_1_, p_i47755_2_); - this.func_208509_a(railshape); - } - -@@ -178,7 +_,7 @@ - } - } - -- if (railshape == RailShape.NORTH_SOUTH) { -+ if (railshape == RailShape.NORTH_SOUTH && canMakeSlopes) { - if (AbstractRailBlock.func_208488_a(this.field_196920_a, blockpos.func_177984_a())) { - railshape = RailShape.ASCENDING_NORTH; - } -@@ -188,7 +_,7 @@ - } - } - -- if (railshape == RailShape.EAST_WEST) { -+ if (railshape == RailShape.EAST_WEST && canMakeSlopes) { - if (AbstractRailBlock.func_208488_a(this.field_196920_a, blockpos3.func_177984_a())) { - railshape = RailShape.ASCENDING_EAST; - } -@@ -304,7 +_,7 @@ - } - } - -- if (railshape == RailShape.NORTH_SOUTH) { -+ if (railshape == RailShape.NORTH_SOUTH && canMakeSlopes) { - if (AbstractRailBlock.func_208488_a(this.field_196920_a, blockpos.func_177984_a())) { - railshape = RailShape.ASCENDING_NORTH; - } -@@ -314,7 +_,7 @@ - } - } - -- if (railshape == RailShape.EAST_WEST) { -+ if (railshape == RailShape.EAST_WEST && canMakeSlopes) { - if (AbstractRailBlock.func_208488_a(this.field_196920_a, blockpos3.func_177984_a())) { - railshape = RailShape.ASCENDING_EAST; - } diff --git a/patches/minecraft/net/minecraft/block/RedstoneDiodeBlock.java.patch b/patches/minecraft/net/minecraft/block/RedstoneDiodeBlock.java.patch deleted file mode 100644 index c9546902aa..0000000000 --- a/patches/minecraft/net/minecraft/block/RedstoneDiodeBlock.java.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/block/RedstoneDiodeBlock.java -+++ b/net/minecraft/block/RedstoneDiodeBlock.java -@@ -65,7 +_,7 @@ - if (p_220069_1_.func_196955_c(p_220069_2_, p_220069_3_)) { - this.func_176398_g(p_220069_2_, p_220069_3_, p_220069_1_); - } else { -- TileEntity tileentity = this.func_235695_q_() ? p_220069_2_.func_175625_s(p_220069_3_) : null; -+ TileEntity tileentity = p_220069_1_.hasTileEntity() ? p_220069_2_.func_175625_s(p_220069_3_) : null; - func_220059_a(p_220069_1_, p_220069_2_, p_220069_3_, tileentity); - p_220069_2_.func_217377_a(p_220069_3_, false); - -@@ -163,6 +_,8 @@ - protected void func_176400_h(World p_176400_1_, BlockPos p_176400_2_, BlockState p_176400_3_) { - Direction direction = p_176400_3_.func_177229_b(field_185512_D); - BlockPos blockpos = p_176400_2_.func_177972_a(direction.func_176734_d()); -+ if (net.minecraftforge.event.ForgeEventFactory.onNeighborNotify(p_176400_1_, p_176400_2_, p_176400_1_.func_180495_p(p_176400_2_), java.util.EnumSet.of(direction.func_176734_d()), false).isCanceled()) -+ return; - p_176400_1_.func_190524_a(blockpos, this, p_176400_2_); - p_176400_1_.func_175695_a(blockpos, this, direction); - } diff --git a/patches/minecraft/net/minecraft/block/RedstoneOreBlock.java.patch b/patches/minecraft/net/minecraft/block/RedstoneOreBlock.java.patch deleted file mode 100644 index 69ab5d8b6a..0000000000 --- a/patches/minecraft/net/minecraft/block/RedstoneOreBlock.java.patch +++ /dev/null @@ -1,18 +0,0 @@ ---- a/net/minecraft/block/RedstoneOreBlock.java -+++ b/net/minecraft/block/RedstoneOreBlock.java -@@ -71,11 +_,11 @@ - - public void func_220062_a(BlockState p_220062_1_, ServerWorld p_220062_2_, BlockPos p_220062_3_, ItemStack p_220062_4_) { - super.func_220062_a(p_220062_1_, p_220062_2_, p_220062_3_, p_220062_4_); -- if (EnchantmentHelper.func_77506_a(Enchantments.field_185306_r, p_220062_4_) == 0) { -- int i = 1 + p_220062_2_.field_73012_v.nextInt(5); -- this.func_180637_b(p_220062_2_, p_220062_3_, i); -- } -+ } - -+ @Override -+ public int getExpDrop(BlockState state, net.minecraft.world.IWorldReader world, BlockPos pos, int fortune, int silktouch) { -+ return silktouch == 0 ? 1 + RANDOM.nextInt(5) : 0; - } - - @OnlyIn(Dist.CLIENT) diff --git a/patches/minecraft/net/minecraft/block/RedstoneWireBlock.java.patch b/patches/minecraft/net/minecraft/block/RedstoneWireBlock.java.patch deleted file mode 100644 index 18b9ede9b8..0000000000 --- a/patches/minecraft/net/minecraft/block/RedstoneWireBlock.java.patch +++ /dev/null @@ -1,42 +0,0 @@ ---- a/net/minecraft/block/RedstoneWireBlock.java -+++ b/net/minecraft/block/RedstoneWireBlock.java -@@ -184,7 +_,7 @@ - BlockState blockstate = p_235545_1_.func_180495_p(blockpos); - if (p_235545_4_) { - boolean flag = this.func_235552_b_(p_235545_1_, blockpos, blockstate); -- if (flag && func_176346_d(p_235545_1_.func_180495_p(blockpos.func_177984_a()))) { -+ if (flag && canConnectTo(p_235545_1_.func_180495_p(blockpos.func_177984_a()), p_235545_1_, blockpos.func_177984_a(), null) ) { - if (blockstate.func_224755_d(p_235545_1_, blockpos, p_235545_3_.func_176734_d())) { - return RedstoneSide.UP; - } -@@ -193,7 +_,7 @@ - } - } - -- return !func_176343_a(blockstate, p_235545_3_) && (blockstate.func_215686_e(p_235545_1_, blockpos) || !func_176346_d(p_235545_1_.func_180495_p(blockpos.func_177977_b()))) ? RedstoneSide.NONE : RedstoneSide.SIDE; -+ return !canConnectTo(blockstate, p_235545_1_, blockpos, p_235545_3_) && (blockstate.func_215686_e(p_235545_1_, blockpos) || !canConnectTo(p_235545_1_.func_180495_p(blockpos.func_177977_b()), p_235545_1_, blockpos.func_177977_b(), null)) ? RedstoneSide.NONE : RedstoneSide.SIDE; - } - - public boolean func_196260_a(BlockState p_196260_1_, IWorldReader p_196260_2_, BlockPos p_196260_3_) { -@@ -335,11 +_,7 @@ - } - } - -- protected static boolean func_176346_d(BlockState p_176346_0_) { -- return func_176343_a(p_176346_0_, (Direction)null); -- } -- -- protected static boolean func_176343_a(BlockState p_176343_0_, @Nullable Direction p_176343_1_) { -+ protected static boolean canConnectTo(BlockState p_176343_0_, IBlockReader world, BlockPos pos, @Nullable Direction p_176343_1_) { - if (p_176343_0_.func_203425_a(Blocks.field_150488_af)) { - return true; - } else if (p_176343_0_.func_203425_a(Blocks.field_196633_cV)) { -@@ -348,7 +_,7 @@ - } else if (p_176343_0_.func_203425_a(Blocks.field_190976_dk)) { - return p_176343_1_ == p_176343_0_.func_177229_b(ObserverBlock.field_176387_N); - } else { -- return p_176343_0_.func_185897_m() && p_176343_1_ != null; -+ return p_176343_0_.canConnectRedstone(world, pos, p_176343_1_) && p_176343_1_ != null; - } - } - diff --git a/patches/minecraft/net/minecraft/block/SaplingBlock.java.patch b/patches/minecraft/net/minecraft/block/SaplingBlock.java.patch deleted file mode 100644 index b0851a5867..0000000000 --- a/patches/minecraft/net/minecraft/block/SaplingBlock.java.patch +++ /dev/null @@ -1,18 +0,0 @@ ---- a/net/minecraft/block/SaplingBlock.java -+++ b/net/minecraft/block/SaplingBlock.java -@@ -29,6 +_,7 @@ - - public void func_225542_b_(BlockState p_225542_1_, ServerWorld p_225542_2_, BlockPos p_225542_3_, Random p_225542_4_) { - if (p_225542_2_.func_201696_r(p_225542_3_.func_177984_a()) >= 9 && p_225542_4_.nextInt(7) == 0) { -+ if (!p_225542_2_.isAreaLoaded(p_225542_3_, 1)) return; // Forge: prevent loading unloaded chunks when checking neighbor's light - this.func_226942_a_(p_225542_2_, p_225542_3_, p_225542_1_, p_225542_4_); - } - -@@ -38,6 +_,7 @@ - if (p_226942_3_.func_177229_b(field_176479_b) == 0) { - p_226942_1_.func_180501_a(p_226942_2_, p_226942_3_.func_235896_a_(field_176479_b), 4); - } else { -+ if (!net.minecraftforge.event.ForgeEventFactory.saplingGrowTree(p_226942_1_, p_226942_4_, p_226942_2_)) return; - this.field_196387_c.func_230339_a_(p_226942_1_, p_226942_1_.func_72863_F().func_201711_g(), p_226942_2_, p_226942_3_, p_226942_4_); - } - diff --git a/patches/minecraft/net/minecraft/block/SeaGrassBlock.java.patch b/patches/minecraft/net/minecraft/block/SeaGrassBlock.java.patch deleted file mode 100644 index 4db6d7b9d6..0000000000 --- a/patches/minecraft/net/minecraft/block/SeaGrassBlock.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/block/SeaGrassBlock.java -+++ b/net/minecraft/block/SeaGrassBlock.java -@@ -17,7 +_,7 @@ - import net.minecraft.world.World; - import net.minecraft.world.server.ServerWorld; - --public class SeaGrassBlock extends BushBlock implements IGrowable, ILiquidContainer { -+public class SeaGrassBlock extends BushBlock implements IGrowable, ILiquidContainer, net.minecraftforge.common.IForgeShearable { - protected static final VoxelShape field_207798_a = Block.func_208617_a(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D); - - public SeaGrassBlock(AbstractBlock.Properties p_i48780_1_) { diff --git a/patches/minecraft/net/minecraft/block/SoundType.java.patch b/patches/minecraft/net/minecraft/block/SoundType.java.patch deleted file mode 100644 index 9457ee2e5d..0000000000 --- a/patches/minecraft/net/minecraft/block/SoundType.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/block/SoundType.java -+++ b/net/minecraft/block/SoundType.java -@@ -59,6 +_,7 @@ - private final SoundEvent field_185865_r; - private final SoundEvent field_185866_s; - -+ @Deprecated // Forge: Use {@link net.minecraftforge.common.util.ForgeSoundType} instead for suppliers - public SoundType(float p_i46679_1_, float p_i46679_2_, SoundEvent p_i46679_3_, SoundEvent p_i46679_4_, SoundEvent p_i46679_5_, SoundEvent p_i46679_6_, SoundEvent p_i46679_7_) { - this.field_185860_m = p_i46679_1_; - this.field_185861_n = p_i46679_2_; diff --git a/patches/minecraft/net/minecraft/block/SpawnerBlock.java.patch b/patches/minecraft/net/minecraft/block/SpawnerBlock.java.patch deleted file mode 100644 index 93f36a70ad..0000000000 --- a/patches/minecraft/net/minecraft/block/SpawnerBlock.java.patch +++ /dev/null @@ -1,16 +0,0 @@ ---- a/net/minecraft/block/SpawnerBlock.java -+++ b/net/minecraft/block/SpawnerBlock.java -@@ -18,8 +_,11 @@ - - public void func_220062_a(BlockState p_220062_1_, ServerWorld p_220062_2_, BlockPos p_220062_3_, ItemStack p_220062_4_) { - super.func_220062_a(p_220062_1_, p_220062_2_, p_220062_3_, p_220062_4_); -- int i = 15 + p_220062_2_.field_73012_v.nextInt(15) + p_220062_2_.field_73012_v.nextInt(15); -- this.func_180637_b(p_220062_2_, p_220062_3_, i); -+ } -+ -+ @Override -+ public int getExpDrop(BlockState state, net.minecraft.world.IWorldReader world, BlockPos pos, int fortune, int silktouch) { -+ return 15 + RANDOM.nextInt(15) + RANDOM.nextInt(15); - } - - public BlockRenderType func_149645_b(BlockState p_149645_1_) { diff --git a/patches/minecraft/net/minecraft/block/SpongeBlock.java.patch b/patches/minecraft/net/minecraft/block/SpongeBlock.java.patch deleted file mode 100644 index 9efbca821e..0000000000 --- a/patches/minecraft/net/minecraft/block/SpongeBlock.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/block/SpongeBlock.java -+++ b/net/minecraft/block/SpongeBlock.java -@@ -64,7 +_,7 @@ - queue.add(new Tuple<>(blockpos1, j + 1)); - } - } else if (material == Material.field_203243_f || material == Material.field_204868_h) { -- TileEntity tileentity = blockstate.func_177230_c().func_235695_q_() ? p_176312_1_.func_175625_s(blockpos1) : null; -+ TileEntity tileentity = blockstate.hasTileEntity() ? p_176312_1_.func_175625_s(blockpos1) : null; - func_220059_a(blockstate, p_176312_1_, blockpos1, tileentity); - p_176312_1_.func_180501_a(blockpos1, Blocks.field_150350_a.func_176223_P(), 3); - ++i; diff --git a/patches/minecraft/net/minecraft/block/SpreadableSnowyDirtBlock.java.patch b/patches/minecraft/net/minecraft/block/SpreadableSnowyDirtBlock.java.patch deleted file mode 100644 index a8d5ded1b3..0000000000 --- a/patches/minecraft/net/minecraft/block/SpreadableSnowyDirtBlock.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/block/SpreadableSnowyDirtBlock.java -+++ b/net/minecraft/block/SpreadableSnowyDirtBlock.java -@@ -33,6 +_,7 @@ - - public void func_225542_b_(BlockState p_225542_1_, ServerWorld p_225542_2_, BlockPos p_225542_3_, Random p_225542_4_) { - if (!func_220257_b(p_225542_1_, p_225542_2_, p_225542_3_)) { -+ if (!p_225542_2_.isAreaLoaded(p_225542_3_, 3)) return; // Forge: prevent loading unloaded chunks when checking neighbor's light and spreading - p_225542_2_.func_175656_a(p_225542_3_, Blocks.field_150346_d.func_176223_P()); - } else { - if (p_225542_2_.func_201696_r(p_225542_3_.func_177984_a()) >= 9) { diff --git a/patches/minecraft/net/minecraft/block/StairsBlock.java.patch b/patches/minecraft/net/minecraft/block/StairsBlock.java.patch deleted file mode 100644 index fa883a3374..0000000000 --- a/patches/minecraft/net/minecraft/block/StairsBlock.java.patch +++ /dev/null @@ -1,39 +0,0 @@ ---- a/net/minecraft/block/StairsBlock.java -+++ b/net/minecraft/block/StairsBlock.java -@@ -83,11 +_,21 @@ - return voxelshape; - } - -+ @Deprecated // Forge: Use the other constructor that takes a Supplier - public StairsBlock(BlockState p_i48321_1_, AbstractBlock.Properties p_i48321_2_) { - super(p_i48321_2_); - this.func_180632_j(this.field_176227_L.func_177621_b().func_206870_a(field_176309_a, Direction.NORTH).func_206870_a(field_176308_b, Half.BOTTOM).func_206870_a(field_176310_M, StairsShape.STRAIGHT).func_206870_a(field_204513_t, Boolean.valueOf(false))); - this.field_150149_b = p_i48321_1_.func_177230_c(); - this.field_150151_M = p_i48321_1_; -+ this.stateSupplier = () -> p_i48321_1_; -+ } -+ -+ public StairsBlock(java.util.function.Supplier state, AbstractBlock.Properties properties) { -+ super(properties); -+ this.func_180632_j(this.field_176227_L.func_177621_b().func_206870_a(field_176309_a, Direction.NORTH).func_206870_a(field_176308_b, Half.BOTTOM).func_206870_a(field_176310_M, StairsShape.STRAIGHT).func_206870_a(field_204513_t, Boolean.valueOf(false))); -+ this.field_150149_b = Blocks.field_150350_a; // These are unused, fields are redirected -+ this.field_150151_M = Blocks.field_150350_a.func_176223_P(); -+ this.stateSupplier = state; - } - - public boolean func_220074_n(BlockState p_220074_1_) { -@@ -265,4 +_,14 @@ - public boolean func_196266_a(BlockState p_196266_1_, IBlockReader p_196266_2_, BlockPos p_196266_3_, PathType p_196266_4_) { - return false; - } -+ -+ // Forge Start -+ private final java.util.function.Supplier stateSupplier; -+ private Block getModelBlock() { -+ return getModelState().func_177230_c(); -+ } -+ private BlockState getModelState() { -+ return stateSupplier.get(); -+ } -+ // Forge end - } diff --git a/patches/minecraft/net/minecraft/block/StemBlock.java.patch b/patches/minecraft/net/minecraft/block/StemBlock.java.patch deleted file mode 100644 index ddb17d0aca..0000000000 --- a/patches/minecraft/net/minecraft/block/StemBlock.java.patch +++ /dev/null @@ -1,43 +0,0 @@ ---- a/net/minecraft/block/StemBlock.java -+++ b/net/minecraft/block/StemBlock.java -@@ -37,22 +_,24 @@ - } - - public void func_225542_b_(BlockState p_225542_1_, ServerWorld p_225542_2_, BlockPos p_225542_3_, Random p_225542_4_) { -+ if (!p_225542_2_.isAreaLoaded(p_225542_3_, 1)) return; // Forge: prevent loading unloaded chunks when checking neighbor's light - if (p_225542_2_.func_226659_b_(p_225542_3_, 0) >= 9) { - float f = CropsBlock.func_180672_a(this, p_225542_2_, p_225542_3_); -- if (p_225542_4_.nextInt((int)(25.0F / f) + 1) == 0) { -+ if (net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_225542_2_, p_225542_3_, p_225542_1_, p_225542_4_.nextInt((int)(25.0F / f) + 1) == 0)) { - int i = p_225542_1_.func_177229_b(field_176484_a); - if (i < 7) { -- p_225542_1_ = p_225542_1_.func_206870_a(field_176484_a, Integer.valueOf(i + 1)); -- p_225542_2_.func_180501_a(p_225542_3_, p_225542_1_, 2); -+ p_225542_2_.func_180501_a(p_225542_3_, p_225542_1_.func_206870_a(field_176484_a, Integer.valueOf(i + 1)), 2); - } else { - Direction direction = Direction.Plane.HORIZONTAL.func_179518_a(p_225542_4_); - BlockPos blockpos = p_225542_3_.func_177972_a(direction); - BlockState blockstate = p_225542_2_.func_180495_p(blockpos.func_177977_b()); -- if (p_225542_2_.func_180495_p(blockpos).func_196958_f() && (blockstate.func_203425_a(Blocks.field_150458_ak) || blockstate.func_203425_a(Blocks.field_150346_d) || blockstate.func_203425_a(Blocks.field_196660_k) || blockstate.func_203425_a(Blocks.field_196661_l) || blockstate.func_203425_a(Blocks.field_196658_i))) { -+ Block block = blockstate.func_177230_c(); -+ if (p_225542_2_.func_175623_d(blockpos) && (blockstate.canSustainPlant(p_225542_2_, blockpos.func_177977_b(), Direction.UP, this) || block == Blocks.field_150458_ak || block == Blocks.field_150346_d || block == Blocks.field_196660_k || block == Blocks.field_196661_l || block == Blocks.field_196658_i)) { - p_225542_2_.func_175656_a(blockpos, this.field_149877_a.func_176223_P()); - p_225542_2_.func_175656_a(p_225542_3_, this.field_149877_a.func_196523_e().func_176223_P().func_206870_a(HorizontalBlock.field_185512_D, direction)); - } - } -+ net.minecraftforge.common.ForgeHooks.onCropsGrowPost(p_225542_2_, p_225542_3_, p_225542_1_); - } - - } -@@ -96,5 +_,11 @@ - - public StemGrownBlock func_208486_d() { - return this.field_149877_a; -+ } -+ -+ //FORGE START -+ @Override -+ public net.minecraftforge.common.PlantType getPlantType(IBlockReader world, BlockPos pos) { -+ return net.minecraftforge.common.PlantType.CROP; - } - } diff --git a/patches/minecraft/net/minecraft/block/SugarCaneBlock.java.patch b/patches/minecraft/net/minecraft/block/SugarCaneBlock.java.patch deleted file mode 100644 index da29f8cff5..0000000000 --- a/patches/minecraft/net/minecraft/block/SugarCaneBlock.java.patch +++ /dev/null @@ -1,51 +0,0 @@ ---- a/net/minecraft/block/SugarCaneBlock.java -+++ b/net/minecraft/block/SugarCaneBlock.java -@@ -15,7 +_,7 @@ - import net.minecraft.world.IWorldReader; - import net.minecraft.world.server.ServerWorld; - --public class SugarCaneBlock extends Block { -+public class SugarCaneBlock extends Block implements net.minecraftforge.common.IPlantable { - public static final IntegerProperty field_176355_a = BlockStateProperties.field_208171_X; - protected static final VoxelShape field_196503_b = Block.func_208617_a(2.0D, 0.0D, 2.0D, 14.0D, 16.0D, 14.0D); - -@@ -43,12 +_,14 @@ - - if (i < 3) { - int j = p_225542_1_.func_177229_b(field_176355_a); -+ if (net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_225542_2_, p_225542_3_, p_225542_1_, true)) { - if (j == 15) { - p_225542_2_.func_175656_a(p_225542_3_.func_177984_a(), this.func_176223_P()); - p_225542_2_.func_180501_a(p_225542_3_, p_225542_1_.func_206870_a(field_176355_a, Integer.valueOf(0)), 4); - } else { - p_225542_2_.func_180501_a(p_225542_3_, p_225542_1_.func_206870_a(field_176355_a, Integer.valueOf(j + 1)), 4); - } -+ } - } - } - -@@ -63,6 +_,8 @@ - } - - public boolean func_196260_a(BlockState p_196260_1_, IWorldReader p_196260_2_, BlockPos p_196260_3_) { -+ BlockState soil = p_196260_2_.func_180495_p(p_196260_3_.func_177977_b()); -+ if (soil.canSustainPlant(p_196260_2_, p_196260_3_.func_177977_b(), Direction.UP, this)) return true; - BlockState blockstate = p_196260_2_.func_180495_p(p_196260_3_.func_177977_b()); - if (blockstate.func_177230_c() == this) { - return true; -@@ -85,5 +_,15 @@ - - protected void func_206840_a(StateContainer.Builder p_206840_1_) { - p_206840_1_.func_206894_a(field_176355_a); -+ } -+ -+ @Override -+ public net.minecraftforge.common.PlantType getPlantType(IBlockReader world, BlockPos pos) { -+ return net.minecraftforge.common.PlantType.BEACH; -+ } -+ -+ @Override -+ public BlockState getPlant(IBlockReader world, BlockPos pos) { -+ return func_176223_P(); - } - } diff --git a/patches/minecraft/net/minecraft/block/SweetBerryBushBlock.java.patch b/patches/minecraft/net/minecraft/block/SweetBerryBushBlock.java.patch deleted file mode 100644 index 8d5a46580b..0000000000 --- a/patches/minecraft/net/minecraft/block/SweetBerryBushBlock.java.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/net/minecraft/block/SweetBerryBushBlock.java -+++ b/net/minecraft/block/SweetBerryBushBlock.java -@@ -52,8 +_,9 @@ - - public void func_225542_b_(BlockState p_225542_1_, ServerWorld p_225542_2_, BlockPos p_225542_3_, Random p_225542_4_) { - int i = p_225542_1_.func_177229_b(field_220125_a); -- if (i < 3 && p_225542_4_.nextInt(5) == 0 && p_225542_2_.func_226659_b_(p_225542_3_.func_177984_a(), 0) >= 9) { -+ if (i < 3 && p_225542_2_.func_226659_b_(p_225542_3_.func_177984_a(), 0) >= 9 && net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_225542_2_, p_225542_3_, p_225542_1_,p_225542_4_.nextInt(5) == 0)) { - p_225542_2_.func_180501_a(p_225542_3_, p_225542_1_.func_206870_a(field_220125_a, Integer.valueOf(i + 1)), 2); -+ net.minecraftforge.common.ForgeHooks.onCropsGrowPost(p_225542_2_, p_225542_3_, p_225542_1_); - } - - } diff --git a/patches/minecraft/net/minecraft/block/TNTBlock.java.patch b/patches/minecraft/net/minecraft/block/TNTBlock.java.patch deleted file mode 100644 index 7ad46a4a45..0000000000 --- a/patches/minecraft/net/minecraft/block/TNTBlock.java.patch +++ /dev/null @@ -1,67 +0,0 @@ ---- a/net/minecraft/block/TNTBlock.java -+++ b/net/minecraft/block/TNTBlock.java -@@ -29,10 +_,14 @@ - this.func_180632_j(this.func_176223_P().func_206870_a(field_212569_a, Boolean.valueOf(false))); - } - -+ public void catchFire(BlockState state, World world, BlockPos pos, @Nullable net.minecraft.util.Direction face, @Nullable LivingEntity igniter) { -+ func_196535_a(world, pos, igniter); -+ } -+ - public void func_220082_b(BlockState p_220082_1_, World p_220082_2_, BlockPos p_220082_3_, BlockState p_220082_4_, boolean p_220082_5_) { - if (!p_220082_4_.func_203425_a(p_220082_1_.func_177230_c())) { - if (p_220082_2_.func_175640_z(p_220082_3_)) { -- func_196534_a(p_220082_2_, p_220082_3_); -+ catchFire(p_220082_1_, p_220082_2_, p_220082_3_, null, null); - p_220082_2_.func_217377_a(p_220082_3_, false); - } - -@@ -41,7 +_,7 @@ - - public void func_220069_a(BlockState p_220069_1_, World p_220069_2_, BlockPos p_220069_3_, Block p_220069_4_, BlockPos p_220069_5_, boolean p_220069_6_) { - if (p_220069_2_.func_175640_z(p_220069_3_)) { -- func_196534_a(p_220069_2_, p_220069_3_); -+ catchFire(p_220069_1_, p_220069_2_, p_220069_3_, null, null); - p_220069_2_.func_217377_a(p_220069_3_, false); - } - -@@ -49,7 +_,7 @@ - - public void func_176208_a(World p_176208_1_, BlockPos p_176208_2_, BlockState p_176208_3_, PlayerEntity p_176208_4_) { - if (!p_176208_1_.func_201670_d() && !p_176208_4_.func_184812_l_() && p_176208_3_.func_177229_b(field_212569_a)) { -- func_196534_a(p_176208_1_, p_176208_2_); -+ catchFire(p_176208_3_, p_176208_1_, p_176208_2_, null, null); - } - - super.func_176208_a(p_176208_1_, p_176208_2_, p_176208_3_, p_176208_4_); -@@ -63,10 +_,12 @@ - } - } - -+ @Deprecated //Forge: Prefer using IForgeBlock#catchFire - public static void func_196534_a(World p_196534_0_, BlockPos p_196534_1_) { - func_196535_a(p_196534_0_, p_196534_1_, (LivingEntity)null); - } - -+ @Deprecated //Forge: Prefer using IForgeBlock#catchFire - private static void func_196535_a(World p_196535_0_, BlockPos p_196535_1_, @Nullable LivingEntity p_196535_2_) { - if (!p_196535_0_.field_72995_K) { - TNTEntity tntentity = new TNTEntity(p_196535_0_, (double)p_196535_1_.func_177958_n() + 0.5D, (double)p_196535_1_.func_177956_o(), (double)p_196535_1_.func_177952_p() + 0.5D, p_196535_2_); -@@ -81,7 +_,7 @@ - if (item != Items.field_151033_d && item != Items.field_151059_bz) { - return super.func_225533_a_(p_225533_1_, p_225533_2_, p_225533_3_, p_225533_4_, p_225533_5_, p_225533_6_); - } else { -- func_196535_a(p_225533_2_, p_225533_3_, p_225533_4_); -+ catchFire(p_225533_1_, p_225533_2_, p_225533_3_, p_225533_6_.func_216354_b(), p_225533_4_); - p_225533_2_.func_180501_a(p_225533_3_, Blocks.field_150350_a.func_176223_P(), 11); - if (!p_225533_4_.func_184812_l_()) { - if (item == Items.field_151033_d) { -@@ -102,7 +_,7 @@ - Entity entity = p_220066_4_.func_234616_v_(); - if (p_220066_4_.func_70027_ad()) { - BlockPos blockpos = p_220066_3_.func_216350_a(); -- func_196535_a(p_220066_1_, blockpos, entity instanceof LivingEntity ? (LivingEntity)entity : null); -+ catchFire(p_220066_2_, p_220066_1_, blockpos, null, entity instanceof LivingEntity ? (LivingEntity)entity : null); - p_220066_1_.func_217377_a(blockpos, false); - } - } diff --git a/patches/minecraft/net/minecraft/block/TallGrassBlock.java.patch b/patches/minecraft/net/minecraft/block/TallGrassBlock.java.patch deleted file mode 100644 index cc29e09840..0000000000 --- a/patches/minecraft/net/minecraft/block/TallGrassBlock.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/block/TallGrassBlock.java -+++ b/net/minecraft/block/TallGrassBlock.java -@@ -8,7 +_,7 @@ - import net.minecraft.world.World; - import net.minecraft.world.server.ServerWorld; - --public class TallGrassBlock extends BushBlock implements IGrowable { -+public class TallGrassBlock extends BushBlock implements IGrowable, net.minecraftforge.common.IForgeShearable { - protected static final VoxelShape field_196389_a = Block.func_208617_a(2.0D, 0.0D, 2.0D, 14.0D, 13.0D, 14.0D); - - public TallGrassBlock(AbstractBlock.Properties p_i48310_1_) { diff --git a/patches/minecraft/net/minecraft/block/TrapDoorBlock.java.patch b/patches/minecraft/net/minecraft/block/TrapDoorBlock.java.patch deleted file mode 100644 index 36d845ff8b..0000000000 --- a/patches/minecraft/net/minecraft/block/TrapDoorBlock.java.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/block/TrapDoorBlock.java -+++ b/net/minecraft/block/TrapDoorBlock.java -@@ -147,4 +_,17 @@ - - return super.func_196271_a(p_196271_1_, p_196271_2_, p_196271_3_, p_196271_4_, p_196271_5_, p_196271_6_); - } -+ -+ //Forge Start -+ @Override -+ public boolean isLadder(BlockState state, net.minecraft.world.IWorldReader world, BlockPos pos, net.minecraft.entity.LivingEntity entity) { -+ if (state.func_177229_b(field_176283_b)) { -+ BlockPos downPos = pos.func_177977_b(); -+ BlockState down = world.func_180495_p(downPos); -+ return down.func_177230_c().makesOpenTrapdoorAboveClimbable(down, world, downPos, state); -+ } -+ return false; -+ } -+ //Forge End -+ - } diff --git a/patches/minecraft/net/minecraft/block/TripWireHookBlock.java.patch b/patches/minecraft/net/minecraft/block/TripWireHookBlock.java.patch deleted file mode 100644 index 7e07a7ff5e..0000000000 --- a/patches/minecraft/net/minecraft/block/TripWireHookBlock.java.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/net/minecraft/block/TripWireHookBlock.java -+++ b/net/minecraft/block/TripWireHookBlock.java -@@ -150,8 +_,8 @@ - BlockPos blockpos2 = p_176260_2_.func_177967_a(direction, k); - BlockState blockstate2 = ablockstate[k]; - if (blockstate2 != null) { -+ if (!p_176260_1_.func_180495_p(blockpos2).func_196958_f()) { // FORGE: fix MC-129055 - p_176260_1_.func_180501_a(blockpos2, blockstate2.func_206870_a(field_176265_M, Boolean.valueOf(flag2)), 3); -- if (!p_176260_1_.func_180495_p(blockpos2).func_196958_f()) { - } - } - } diff --git a/patches/minecraft/net/minecraft/block/TurtleEggBlock.java.patch b/patches/minecraft/net/minecraft/block/TurtleEggBlock.java.patch deleted file mode 100644 index d4813c28aa..0000000000 --- a/patches/minecraft/net/minecraft/block/TurtleEggBlock.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/block/TurtleEggBlock.java -+++ b/net/minecraft/block/TurtleEggBlock.java -@@ -149,7 +_,7 @@ - if (!(p_212570_2_ instanceof LivingEntity)) { - return false; - } else { -- return p_212570_2_ instanceof PlayerEntity || p_212570_1_.func_82736_K().func_223586_b(GameRules.field_223599_b); -+ return p_212570_2_ instanceof PlayerEntity || net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(p_212570_1_, p_212570_2_); - } - } else { - return false; diff --git a/patches/minecraft/net/minecraft/block/VineBlock.java.patch b/patches/minecraft/net/minecraft/block/VineBlock.java.patch deleted file mode 100644 index 6306c149c5..0000000000 --- a/patches/minecraft/net/minecraft/block/VineBlock.java.patch +++ /dev/null @@ -1,40 +0,0 @@ ---- a/net/minecraft/block/VineBlock.java -+++ b/net/minecraft/block/VineBlock.java -@@ -22,7 +_,7 @@ - import net.minecraft.world.IWorldReader; - import net.minecraft.world.server.ServerWorld; - --public class VineBlock extends Block { -+public class VineBlock extends Block implements net.minecraftforge.common.IForgeShearable { - public static final BooleanProperty field_176277_a = SixWayBlock.field_196496_z; - public static final BooleanProperty field_176273_b = SixWayBlock.field_196488_a; - public static final BooleanProperty field_176278_M = SixWayBlock.field_196490_b; -@@ -152,14 +_,14 @@ - } - - public void func_225542_b_(BlockState p_225542_1_, ServerWorld p_225542_2_, BlockPos p_225542_3_, Random p_225542_4_) { -- if (p_225542_2_.field_73012_v.nextInt(4) == 0) { -+ if (p_225542_2_.field_73012_v.nextInt(4) == 0 && p_225542_2_.isAreaLoaded(p_225542_3_, 4)) { // Forge: check area to prevent loading unloaded chunks - Direction direction = Direction.func_239631_a_(p_225542_4_); - BlockPos blockpos = p_225542_3_.func_177984_a(); - if (direction.func_176740_k().func_176722_c() && !p_225542_1_.func_177229_b(func_176267_a(direction))) { - if (this.func_196539_a(p_225542_2_, p_225542_3_)) { - BlockPos blockpos4 = p_225542_3_.func_177972_a(direction); - BlockState blockstate4 = p_225542_2_.func_180495_p(blockpos4); -- if (blockstate4.func_196958_f()) { -+ if (blockstate4.isAir(p_225542_2_, blockpos4)) { - Direction direction3 = direction.func_176746_e(); - Direction direction4 = direction.func_176735_f(); - boolean flag = p_225542_1_.func_177229_b(func_176267_a(direction3)); -@@ -216,8 +_,9 @@ - if (p_225542_3_.func_177956_o() > 0) { - BlockPos blockpos1 = p_225542_3_.func_177977_b(); - BlockState blockstate = p_225542_2_.func_180495_p(blockpos1); -- if (blockstate.func_196958_f() || blockstate.func_203425_a(this)) { -- BlockState blockstate1 = blockstate.func_196958_f() ? this.func_176223_P() : blockstate; -+ boolean isAir = blockstate.isAir(p_225542_2_, blockpos1); -+ if (isAir || blockstate.func_203425_a(this)) { -+ BlockState blockstate1 = isAir ? this.func_176223_P() : blockstate; - BlockState blockstate2 = this.func_196544_a(p_225542_1_, blockstate1, p_225542_4_); - if (blockstate1 != blockstate2 && this.func_196540_x(blockstate2)) { - p_225542_2_.func_180501_a(blockpos1, blockstate2, 2); diff --git a/patches/minecraft/net/minecraft/block/WebBlock.java.patch b/patches/minecraft/net/minecraft/block/WebBlock.java.patch deleted file mode 100644 index 59323bc3c3..0000000000 --- a/patches/minecraft/net/minecraft/block/WebBlock.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/block/WebBlock.java -+++ b/net/minecraft/block/WebBlock.java -@@ -5,7 +_,7 @@ - import net.minecraft.util.math.vector.Vector3d; - import net.minecraft.world.World; - --public class WebBlock extends Block { -+public class WebBlock extends Block implements net.minecraftforge.common.IForgeShearable { - public WebBlock(AbstractBlock.Properties p_i48296_1_) { - super(p_i48296_1_); - } diff --git a/patches/minecraft/net/minecraft/client/Camera.java.patch b/patches/minecraft/net/minecraft/client/Camera.java.patch new file mode 100644 index 0000000000..3e2fdda50f --- /dev/null +++ b/patches/minecraft/net/minecraft/client/Camera.java.patch @@ -0,0 +1,21 @@ +--- a/net/minecraft/client/Camera.java ++++ b/net/minecraft/client/Camera.java +@@ -211,6 +_,18 @@ + this.f_90549_ = false; + } + ++ public void setAnglesInternal(float yaw, float pitch) { ++ this.f_90558_ = yaw; ++ this.f_90557_ = pitch; ++ } ++ ++ public net.minecraft.world.level.block.state.BlockState getBlockAtCamera() { ++ if (!this.f_90549_) ++ return net.minecraft.world.level.block.Blocks.f_50016_.m_49966_(); ++ else ++ return this.f_90550_.m_8055_(this.f_90553_).getStateAtViewpoint(this.f_90550_, this.f_90553_, this.f_90552_); ++ } ++ + @OnlyIn(Dist.CLIENT) + public static class NearPlane { + final Vec3 f_167687_; diff --git a/patches/minecraft/net/minecraft/client/ClientBrandRetriever.java.patch b/patches/minecraft/net/minecraft/client/ClientBrandRetriever.java.patch index ed8654b3d5..2160fea8c7 100644 --- a/patches/minecraft/net/minecraft/client/ClientBrandRetriever.java.patch +++ b/patches/minecraft/net/minecraft/client/ClientBrandRetriever.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/client/ClientBrandRetriever.java +++ b/net/minecraft/client/ClientBrandRetriever.java -@@ -6,6 +_,6 @@ - @OnlyIn(Dist.CLIENT) - public class ClientBrandRetriever { - public static String getClientModName() { +@@ -10,6 +_,6 @@ + + @DontObfuscate + public static String m_129629_() { - return "vanilla"; -+ return net.minecraftforge.fml.BrandingControl.getClientBranding(); ++ return net.minecraftforge.fmllegacy.BrandingControl.getClientBranding(); } } diff --git a/patches/minecraft/net/minecraft/client/GameSettings.java.patch b/patches/minecraft/net/minecraft/client/GameSettings.java.patch deleted file mode 100644 index 61f8cb0e26..0000000000 --- a/patches/minecraft/net/minecraft/client/GameSettings.java.patch +++ /dev/null @@ -1,64 +0,0 @@ ---- a/net/minecraft/client/GameSettings.java -+++ b/net/minecraft/client/GameSettings.java -@@ -170,6 +_,7 @@ - public boolean field_241568_aS_; - - public GameSettings(Minecraft p_i46326_1_, File p_i46326_2_) { -+ setForgeKeybindProperties(); - this.field_74317_L = p_i46326_1_; - this.field_74354_ai = new File(p_i46326_2_, "options.txt"); - if (p_i46326_1_.func_147111_S() && Runtime.getRuntime().maxMemory() >= 1000000000L) { -@@ -529,7 +_,11 @@ - - for(KeyBinding keybinding : this.field_74324_K) { - if (s.equals("key_" + keybinding.func_151464_g())) { -- keybinding.func_197979_b(InputMappings.func_197955_a(s1)); -+ if (s1.indexOf(':') != -1) { -+ String[] pts = s1.split(":"); -+ keybinding.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.valueFromString(pts[1]), InputMappings.func_197955_a(pts[0])); -+ } else -+ keybinding.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.NONE, InputMappings.func_197955_a(s1)); - } - } - -@@ -576,6 +_,7 @@ - } - - public void func_74303_b() { -+ if (net.minecraftforge.fml.client.ClientModLoader.isLoading()) return; //Don't save settings before mods add keybindigns and the like to prevent them from being deleted. - try (PrintWriter printwriter = new PrintWriter(new OutputStreamWriter(new FileOutputStream(this.field_74354_ai), StandardCharsets.UTF_8))) { - printwriter.println("version:" + SharedConstants.func_215069_a().getWorldVersion()); - printwriter.println("autoJump:" + AbstractOption.field_216719_z.func_216741_b(this)); -@@ -661,7 +_,7 @@ - printwriter.println("syncChunkWrites:" + this.field_241568_aS_); - - for(KeyBinding keybinding : this.field_74324_K) { -- printwriter.println("key_" + keybinding.func_151464_g() + ":" + keybinding.func_197982_m()); -+ printwriter.println("key_" + keybinding.func_151464_g() + ":" + keybinding.func_197982_m() + (keybinding.getKeyModifier() != net.minecraftforge.client.settings.KeyModifier.NONE ? ":" + keybinding.getKeyModifier() : "")); - } - - for(SoundCategory soundcategory : SoundCategory.values()) { -@@ -758,6 +_,23 @@ - } - - p_198017_1_.func_198985_a(set); -+ } -+ -+ private void setForgeKeybindProperties() { -+ net.minecraftforge.client.settings.KeyConflictContext inGame = net.minecraftforge.client.settings.KeyConflictContext.IN_GAME; -+ field_74351_w.setKeyConflictContext(inGame); -+ field_74370_x.setKeyConflictContext(inGame); -+ field_74368_y.setKeyConflictContext(inGame); -+ field_74366_z.setKeyConflictContext(inGame); -+ field_74314_A.setKeyConflictContext(inGame); -+ field_228046_af_.setKeyConflictContext(inGame); -+ field_151444_V.setKeyConflictContext(inGame); -+ field_74312_F.setKeyConflictContext(inGame); -+ field_74310_D.setKeyConflictContext(inGame); -+ field_74321_H.setKeyConflictContext(inGame); -+ field_74323_J.setKeyConflictContext(inGame); -+ field_151457_aa.setKeyConflictContext(inGame); -+ field_151458_ab.setKeyConflictContext(inGame); - } - - public PointOfView func_243230_g() { diff --git a/patches/minecraft/net/minecraft/client/KeyMapping.java.patch b/patches/minecraft/net/minecraft/client/KeyMapping.java.patch new file mode 100644 index 0000000000..302797e4f9 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/KeyMapping.java.patch @@ -0,0 +1,196 @@ +--- a/net/minecraft/client/KeyMapping.java ++++ b/net/minecraft/client/KeyMapping.java +@@ -14,9 +_,9 @@ + import net.minecraftforge.api.distmarker.OnlyIn; + + @OnlyIn(Dist.CLIENT) +-public class KeyMapping implements Comparable { ++public class KeyMapping implements Comparable, net.minecraftforge.client.extensions.IForgeKeyMapping { + private static final Map f_90809_ = Maps.newHashMap(); +- private static final Map f_90810_ = Maps.newHashMap(); ++ private static final net.minecraftforge.client.settings.KeyBindingMap f_90810_ = new net.minecraftforge.client.settings.KeyBindingMap(); + private static final Set f_90811_ = Sets.newHashSet(); + public static final String f_167805_ = "key.categories.movement"; + public static final String f_167806_ = "key.categories.misc"; +@@ -42,7 +_,7 @@ + private int f_90818_; + + public static void m_90835_(InputConstants.Key p_90836_) { +- KeyMapping keymapping = f_90810_.get(p_90836_); ++ KeyMapping keymapping = f_90810_.lookupActive(p_90836_); + if (keymapping != null) { + ++keymapping.f_90818_; + } +@@ -50,7 +_,7 @@ + } + + public static void m_90837_(InputConstants.Key p_90838_, boolean p_90839_) { +- KeyMapping keymapping = f_90810_.get(p_90838_); ++ for (KeyMapping keymapping : f_90810_.lookupAll(p_90838_)) + if (keymapping != null) { + keymapping.m_7249_(p_90839_); + } +@@ -74,10 +_,10 @@ + } + + public static void m_90854_() { +- f_90810_.clear(); ++ f_90810_.clearMap(); + + for(KeyMapping keymapping : f_90809_.values()) { +- f_90810_.put(keymapping.f_90816_, keymapping); ++ f_90810_.addKey(keymapping.f_90816_, keymapping); + } + + } +@@ -92,12 +_,12 @@ + this.f_90814_ = this.f_90816_; + this.f_90815_ = p_90828_; + f_90809_.put(p_90825_, this); +- f_90810_.put(this.f_90816_, this); ++ f_90810_.addKey(this.f_90816_, this); + f_90811_.add(p_90828_); + } + + public boolean m_90857_() { +- return this.f_90817_; ++ return this.f_90817_ && isConflictContextAndModifierActive(); + } + + public String m_90858_() { +@@ -131,7 +_,13 @@ + } + + public int compareTo(KeyMapping p_90841_) { +- return this.f_90815_.equals(p_90841_.f_90815_) ? I18n.m_118938_(this.f_90813_).compareTo(I18n.m_118938_(p_90841_.f_90813_)) : f_90812_.get(this.f_90815_).compareTo(f_90812_.get(p_90841_.f_90815_)); ++ if (this.f_90815_.equals(p_90841_.f_90815_)) return I18n.m_118938_(this.f_90813_).compareTo(I18n.m_118938_(p_90841_.f_90813_)); ++ Integer tCat = f_90812_.get(this.f_90815_); ++ Integer oCat = f_90812_.get(p_90841_.f_90815_); ++ if (tCat == null && oCat != null) return 1; ++ if (tCat != null && oCat == null) return -1; ++ if (tCat == null && oCat == null) return I18n.m_118938_(this.f_90815_).compareTo(I18n.m_118938_(p_90841_.f_90815_)); ++ return tCat.compareTo(oCat); + } + + public static Supplier m_90842_(String p_90843_) { +@@ -142,6 +_,20 @@ + } + + public boolean m_90850_(KeyMapping p_90851_) { ++ if (getKeyConflictContext().conflicts(p_90851_.getKeyConflictContext()) || p_90851_.getKeyConflictContext().conflicts(getKeyConflictContext())) { ++ net.minecraftforge.client.settings.KeyModifier keyModifier = getKeyModifier(); ++ net.minecraftforge.client.settings.KeyModifier otherKeyModifier = p_90851_.getKeyModifier(); ++ if (keyModifier.matches(p_90851_.getKey()) || otherKeyModifier.matches(getKey())) { ++ return true; ++ } else if (getKey().equals(p_90851_.getKey())) { ++ // IN_GAME key contexts have a conflict when at least one modifier is NONE. ++ // For example: If you hold shift to crouch, you can still press E to open your inventory. This means that a Shift+E hotkey is in conflict with E. ++ // GUI and other key contexts do not have this limitation. ++ return keyModifier == otherKeyModifier || ++ (getKeyConflictContext().conflicts(net.minecraftforge.client.settings.KeyConflictContext.IN_GAME) && ++ (keyModifier == net.minecraftforge.client.settings.KeyModifier.NONE || otherKeyModifier == net.minecraftforge.client.settings.KeyModifier.NONE)); ++ } ++ } + return this.f_90816_.equals(p_90851_.f_90816_); + } + +@@ -162,11 +_,13 @@ + } + + public Component m_90863_() { ++ return getKeyModifier().getCombinedName(f_90816_, () -> { + return this.f_90816_.m_84875_(); ++ }); + } + + public boolean m_90864_() { +- return this.f_90816_.equals(this.f_90814_); ++ return this.f_90816_.equals(this.f_90814_) && getKeyModifier() == getKeyModifierDefault(); + } + + public String m_90865_() { +@@ -176,4 +_,84 @@ + public void m_7249_(boolean p_90846_) { + this.f_90817_ = p_90846_; + } ++ ++ /****************** Forge Start *****************************/ ++ private net.minecraftforge.client.settings.KeyModifier keyModifierDefault = net.minecraftforge.client.settings.KeyModifier.NONE; ++ private net.minecraftforge.client.settings.KeyModifier keyModifier = net.minecraftforge.client.settings.KeyModifier.NONE; ++ private net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext = net.minecraftforge.client.settings.KeyConflictContext.UNIVERSAL; ++ ++ /** ++ * Convenience constructor for creating KeyBindings with keyConflictContext set. ++ */ ++ public KeyMapping(String description, net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext, final InputConstants.Type inputType, final int keyCode, String category) { ++ this(description, keyConflictContext, inputType.m_84895_(keyCode), category); ++ } ++ ++ /** ++ * Convenience constructor for creating KeyBindings with keyConflictContext set. ++ */ ++ public KeyMapping(String description, net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext, InputConstants.Key keyCode, String category) { ++ this(description, keyConflictContext, net.minecraftforge.client.settings.KeyModifier.NONE, keyCode, category); ++ } ++ ++ /** ++ * Convenience constructor for creating KeyBindings with keyConflictContext and keyModifier set. ++ */ ++ public KeyMapping(String description, net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext, net.minecraftforge.client.settings.KeyModifier keyModifier, final InputConstants.Type inputType, final int keyCode, String category) { ++ this(description, keyConflictContext, keyModifier, inputType.m_84895_(keyCode), category); ++ } ++ ++ /** ++ * Convenience constructor for creating KeyBindings with keyConflictContext and keyModifier set. ++ */ ++ public KeyMapping(String description, net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext, net.minecraftforge.client.settings.KeyModifier keyModifier, InputConstants.Key keyCode, String category) { ++ this.f_90813_ = description; ++ this.f_90816_ = keyCode; ++ this.f_90814_ = keyCode; ++ this.f_90815_ = category; ++ this.keyConflictContext = keyConflictContext; ++ this.keyModifier = keyModifier; ++ this.keyModifierDefault = keyModifier; ++ if (this.keyModifier.matches(keyCode)) ++ this.keyModifier = net.minecraftforge.client.settings.KeyModifier.NONE; ++ f_90809_.put(description, this); ++ f_90810_.addKey(keyCode, this); ++ f_90811_.add(category); ++ } ++ ++ @Override ++ public InputConstants.Key getKey() { ++ return this.f_90816_; ++ } ++ ++ @Override ++ public void setKeyConflictContext(net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext) { ++ this.keyConflictContext = keyConflictContext; ++ } ++ ++ @Override ++ public net.minecraftforge.client.settings.IKeyConflictContext getKeyConflictContext() { ++ return keyConflictContext; ++ } ++ ++ @Override ++ public net.minecraftforge.client.settings.KeyModifier getKeyModifierDefault() { ++ return keyModifierDefault; ++ } ++ ++ @Override ++ public net.minecraftforge.client.settings.KeyModifier getKeyModifier() { ++ return keyModifier; ++ } ++ ++ @Override ++ public void setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier keyModifier, InputConstants.Key keyCode) { ++ this.f_90816_ = keyCode; ++ if (keyModifier.matches(keyCode)) ++ keyModifier = net.minecraftforge.client.settings.KeyModifier.NONE; ++ f_90810_.removeKey(this); ++ this.keyModifier = keyModifier; ++ f_90810_.addKey(keyCode, this); ++ } ++ /****************** Forge End *****************************/ + } diff --git a/patches/minecraft/net/minecraft/client/KeyboardHandler.java.patch b/patches/minecraft/net/minecraft/client/KeyboardHandler.java.patch new file mode 100644 index 0000000000..215f8fc627 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/KeyboardHandler.java.patch @@ -0,0 +1,68 @@ +--- a/net/minecraft/client/KeyboardHandler.java ++++ b/net/minecraft/client/KeyboardHandler.java +@@ -312,7 +_,9 @@ + } + + Screen screen = this.f_90867_.f_91080_; +- if (p_90897_ == 1 && (!(this.f_90867_.f_91080_ instanceof ControlsScreen) || ((ControlsScreen)screen).f_97515_ <= Util.m_137550_() - 20L)) { ++ ++ if ((!(this.f_90867_.f_91080_ instanceof ControlsScreen) || ((ControlsScreen)screen).f_97515_ <= Util.m_137550_() - 20L)) { ++ if (p_90897_ == 1) { + 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_.f_92052_ = this.f_90867_.m_91268_().m_85440_(); +@@ -331,6 +_,8 @@ + }); + return; + } ++ } else if (p_90897_ == 0 /*GLFW_RELEASE*/ && this.f_90867_.f_91080_ instanceof ControlsScreen) ++ ((ControlsScreen)this.f_90867_.f_91080_).f_97514_ = null; //Forge: Unset pure modifiers. + } + + if (NarratorChatListener.f_93311_.m_93316_()) { +@@ -354,11 +_,15 @@ + Screen.m_96579_(() -> { + if (p_90897_ != 1 && (p_90897_ != 2 || !this.f_90868_)) { + if (p_90897_ == 0) { +- aboolean[0] = screen.m_7920_(p_90895_, p_90896_, p_90898_); ++ aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onGuiKeyReleasedPre(this.f_90867_.f_91080_, p_90895_, p_90896_, p_90898_); ++ if (!aboolean[0]) aboolean[0] = screen.m_7920_(p_90895_, p_90896_, p_90898_); ++ if (!aboolean[0]) aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onGuiKeyReleasedPost(this.f_90867_.f_91080_, p_90895_, p_90896_, p_90898_); + } + } else { + screen.m_169416_(); +- aboolean[0] = screen.m_7933_(p_90895_, p_90896_, p_90898_); ++ aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onGuiKeyPressedPre(this.f_90867_.f_91080_, p_90895_, p_90896_, p_90898_); ++ if (!aboolean[0]) aboolean[0] = screen.m_7933_(p_90895_, p_90896_, p_90898_); ++ if (!aboolean[0]) aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onGuiKeyPressedPost(this.f_90867_.f_91080_, p_90895_, p_90896_, p_90898_); + } + + }, "keyPressed event handler", screen.getClass().getCanonicalName()); +@@ -411,7 +_,7 @@ + } + } + } +- ++ net.minecraftforge.client.ForgeHooksClient.fireKeyInput(p_90895_, p_90896_, p_90897_, p_90898_); + } + } + +@@ -421,12 +_,16 @@ + if (guieventlistener != null && this.f_90867_.m_91265_() == null) { + if (Character.charCount(p_90891_) == 1) { + Screen.m_96579_(() -> { +- guieventlistener.m_5534_((char)p_90891_, p_90892_); ++ if (net.minecraftforge.client.ForgeHooksClient.onGuiCharTypedPre(this.f_90867_.f_91080_, (char)p_90891_, p_90892_)) return; ++ if (guieventlistener.m_5534_((char)p_90891_, p_90892_)) return; ++ net.minecraftforge.client.ForgeHooksClient.onGuiCharTypedPost(this.f_90867_.f_91080_, (char)p_90891_, p_90892_); + }, "charTyped event handler", guieventlistener.getClass().getCanonicalName()); + } else { + for(char c0 : Character.toChars(p_90891_)) { + Screen.m_96579_(() -> { +- guieventlistener.m_5534_(c0, p_90892_); ++ if (net.minecraftforge.client.ForgeHooksClient.onGuiCharTypedPre(this.f_90867_.f_91080_, c0, p_90892_)) return; ++ if (guieventlistener.m_5534_(c0, p_90892_)) return; ++ net.minecraftforge.client.ForgeHooksClient.onGuiCharTypedPost(this.f_90867_.f_91080_, c0, p_90892_); + }, "charTyped event handler", guieventlistener.getClass().getCanonicalName()); + } + } diff --git a/patches/minecraft/net/minecraft/client/KeyboardListener.java.patch b/patches/minecraft/net/minecraft/client/KeyboardListener.java.patch deleted file mode 100644 index ff24bc5b5c..0000000000 --- a/patches/minecraft/net/minecraft/client/KeyboardListener.java.patch +++ /dev/null @@ -1,67 +0,0 @@ ---- a/net/minecraft/client/KeyboardListener.java -+++ b/net/minecraft/client/KeyboardListener.java -@@ -255,7 +_,9 @@ - } - - INestedGuiEventHandler inestedguieventhandler = this.field_197972_a.field_71462_r; -- if (p_197961_5_ == 1 && (!(this.field_197972_a.field_71462_r instanceof ControlsScreen) || ((ControlsScreen)inestedguieventhandler).field_152177_g <= Util.func_211177_b() - 20L)) { -+ -+ if ((!(this.field_197972_a.field_71462_r instanceof ControlsScreen) || ((ControlsScreen)inestedguieventhandler).field_152177_g <= Util.func_211177_b() - 20L)) { -+ if (p_197961_5_ == 1) { - if (this.field_197972_a.field_71474_y.field_152395_am.func_197976_a(p_197961_3_, p_197961_4_)) { - this.field_197972_a.func_228018_at_().func_198077_g(); - this.field_197972_a.field_71474_y.field_74353_u = this.field_197972_a.func_228018_at_().func_198113_j(); -@@ -274,6 +_,8 @@ - }); - return; - } -+ } else if (p_197961_5_ == 0 /*GLFW_RELEASE*/ && this.field_197972_a.field_71462_r instanceof ControlsScreen) -+ ((ControlsScreen)this.field_197972_a.field_71462_r).field_146491_f = null; //Forge: Unset pure modifiers. - } - - boolean flag = inestedguieventhandler == null || !(inestedguieventhandler.func_241217_q_() instanceof TextFieldWidget) || !((TextFieldWidget)inestedguieventhandler.func_241217_q_()).func_212955_f(); -@@ -289,10 +_,14 @@ - Screen.func_231153_a_(() -> { - if (p_197961_5_ != 1 && (p_197961_5_ != 2 || !this.field_197973_b)) { - if (p_197961_5_ == 0) { -- aboolean[0] = inestedguieventhandler.func_223281_a_(p_197961_3_, p_197961_4_, p_197961_6_); -+ aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onGuiKeyReleasedPre(this.field_197972_a.field_71462_r, p_197961_3_, p_197961_4_, p_197961_6_); -+ if (!aboolean[0]) aboolean[0] = inestedguieventhandler.func_223281_a_(p_197961_3_, p_197961_4_, p_197961_6_); -+ if (!aboolean[0]) aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onGuiKeyReleasedPost(this.field_197972_a.field_71462_r, p_197961_3_, p_197961_4_, p_197961_6_); - } - } else { -- aboolean[0] = inestedguieventhandler.func_231046_a_(p_197961_3_, p_197961_4_, p_197961_6_); -+ aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onGuiKeyPressedPre(this.field_197972_a.field_71462_r, p_197961_3_, p_197961_4_, p_197961_6_); -+ if (!aboolean[0]) aboolean[0] = inestedguieventhandler.func_231046_a_(p_197961_3_, p_197961_4_, p_197961_6_); -+ if (!aboolean[0]) aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onGuiKeyPressedPost(this.field_197972_a.field_71462_r, p_197961_3_, p_197961_4_, p_197961_6_); - } - - }, "keyPressed event handler", inestedguieventhandler.getClass().getCanonicalName()); -@@ -345,7 +_,7 @@ - } - } - } -- -+ net.minecraftforge.client.ForgeHooksClient.fireKeyInput(p_197961_3_, p_197961_4_, p_197961_5_, p_197961_6_); - } - } - -@@ -355,12 +_,16 @@ - if (iguieventlistener != null && this.field_197972_a.func_213250_au() == null) { - if (Character.charCount(p_197963_3_) == 1) { - Screen.func_231153_a_(() -> { -- iguieventlistener.func_231042_a_((char)p_197963_3_, p_197963_4_); -+ if (net.minecraftforge.client.ForgeHooksClient.onGuiCharTypedPre(this.field_197972_a.field_71462_r, (char)p_197963_3_, p_197963_4_)) return; -+ if (iguieventlistener.func_231042_a_((char)p_197963_3_, p_197963_4_)) return; -+ net.minecraftforge.client.ForgeHooksClient.onGuiCharTypedPost(this.field_197972_a.field_71462_r, (char)p_197963_3_, p_197963_4_); - }, "charTyped event handler", iguieventlistener.getClass().getCanonicalName()); - } else { - for(char c0 : Character.toChars(p_197963_3_)) { - Screen.func_231153_a_(() -> { -- iguieventlistener.func_231042_a_(c0, p_197963_4_); -+ if (net.minecraftforge.client.ForgeHooksClient.onGuiCharTypedPre(this.field_197972_a.field_71462_r, c0, p_197963_4_)) return; -+ if (iguieventlistener.func_231042_a_(c0, p_197963_4_)) return; -+ net.minecraftforge.client.ForgeHooksClient.onGuiCharTypedPost(this.field_197972_a.field_71462_r, c0, p_197963_4_); - }, "charTyped event handler", iguieventlistener.getClass().getCanonicalName()); - } - } diff --git a/patches/minecraft/net/minecraft/client/MainWindow.java.patch b/patches/minecraft/net/minecraft/client/MainWindow.java.patch deleted file mode 100644 index 65cde52c8b..0000000000 --- a/patches/minecraft/net/minecraft/client/MainWindow.java.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- a/net/minecraft/client/MainWindow.java -+++ b/net/minecraft/client/MainWindow.java -@@ -86,7 +_,7 @@ - GLFW.glfwWindowHint(139266, 2); - GLFW.glfwWindowHint(139267, 0); - GLFW.glfwWindowHint(139272, 0); -- this.field_198119_f = GLFW.glfwCreateWindow(this.field_198129_p, this.field_198130_q, p_i51170_5_, this.field_198125_l && monitor != null ? monitor.func_197995_f() : 0L, 0L); -+ this.field_198119_f = net.minecraftforge.fml.loading.progress.EarlyProgressVisualization.INSTANCE.handOffWindow(()->this.field_198129_p, ()->this.field_198130_q, ()->p_i51170_5_, ()->this.field_198125_l && monitor != null ? monitor.func_197995_f() : 0L); - if (monitor != null) { - VideoMode videomode = monitor.func_197992_a(this.field_198125_l ? this.field_198124_k : Optional.empty()); - this.field_198120_g = this.field_198127_n = monitor.func_197989_c() + videomode.func_198064_a() / 2 - this.field_198129_p / 2; -@@ -271,6 +_,7 @@ - GLFW.glfwGetFramebufferSize(this.field_198119_f, aint, aint1); - this.field_198131_r = aint[0]; - this.field_198132_s = aint1[0]; -+ if (this.field_198132_s == 0 || this.field_198131_r==0) net.minecraftforge.fml.loading.progress.EarlyProgressVisualization.INSTANCE.updateFBSize(w->this.field_198131_r=w, h->this.field_198132_s=h); - } - - private void func_198089_c(long p_198089_1_, int p_198089_3_, int p_198089_4_) { diff --git a/patches/minecraft/net/minecraft/client/Minecraft.java.patch b/patches/minecraft/net/minecraft/client/Minecraft.java.patch index 55ff6ea9a2..1c0c6d40e8 100644 --- a/patches/minecraft/net/minecraft/client/Minecraft.java.patch +++ b/patches/minecraft/net/minecraft/client/Minecraft.java.patch @@ -1,548 +1,523 @@ --- a/net/minecraft/client/Minecraft.java +++ b/net/minecraft/client/Minecraft.java -@@ -368,6 +_,7 @@ - public Minecraft(GameConfiguration p_i45547_1_) { +@@ -390,6 +_,7 @@ + public Minecraft(GameConfig p_91084_) { super("Client"); - field_71432_P = this; + f_90981_ = this; + net.minecraftforge.client.ForgeHooksClient.invalidateLog4jThreadCache(); - this.field_71412_D = p_i45547_1_.field_178744_c.field_178760_a; - File file1 = p_i45547_1_.field_178744_c.field_178759_c; - this.field_130070_K = p_i45547_1_.field_178744_c.field_178758_b; -@@ -382,7 +_,6 @@ - this.field_244734_au = this.func_244735_a(yggdrasilauthenticationservice, p_i45547_1_); - this.field_71449_j = p_i45547_1_.field_178745_a.field_178752_a; - field_147123_G.info("Setting user: {}", (Object)this.field_71449_j.func_111285_a()); -- field_147123_G.debug("(Session ID is {})", (Object)this.field_71449_j.func_111286_b()); - this.field_71459_aj = p_i45547_1_.field_178741_d.field_178756_a; - this.field_238175_ae_ = !p_i45547_1_.field_178741_d.field_239099_d_; - this.field_238176_af_ = !p_i45547_1_.field_178741_d.field_239100_e_; -@@ -428,13 +_,13 @@ + this.f_91069_ = p_91084_.f_101907_.f_101916_; + File file1 = p_91084_.f_101907_.f_101918_; + this.f_90985_ = p_91084_.f_101907_.f_101917_; +@@ -397,14 +_,13 @@ + this.f_91029_ = p_91084_.f_101908_.f_101928_; + this.f_90986_ = p_91084_.f_101905_.f_101944_; + this.f_91037_ = new ClientPackSource(new File(this.f_91069_, "server-resource-packs"), p_91084_.f_101907_.m_101925_()); +- this.f_91038_ = new PackRepository(Minecraft::m_167933_, this.f_91037_, new FolderRepositorySource(this.f_90985_, PackSource.f_10527_)); ++ this.f_91038_ = new PackRepository(Minecraft::createClientPackAdapter, this.f_91037_, new FolderRepositorySource(this.f_90985_, PackSource.f_10527_)); + this.f_91030_ = p_91084_.f_101905_.f_101945_; + YggdrasilAuthenticationService yggdrasilauthenticationservice = new YggdrasilAuthenticationService(this.f_91030_); + this.f_91048_ = yggdrasilauthenticationservice.createMinecraftSessionService(); + this.f_91049_ = this.m_91130_(yggdrasilauthenticationservice, 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_; +@@ -450,7 +_,6 @@ - this.field_195558_d.func_216526_a(this.field_71474_y.field_74350_i); - this.field_71417_B = new MouseHelper(this); -- this.field_71417_B.func_198029_a(this.field_195558_d.func_198092_i()); - this.field_195559_v = new KeyboardListener(this); - this.field_195559_v.func_197968_a(this.field_195558_d.func_198092_i()); - RenderSystem.initRenderer(this.field_71474_y.field_209231_W, false); - this.field_147124_at = new Framebuffer(this.field_195558_d.func_198109_k(), this.field_195558_d.func_198091_l(), true, field_142025_a); - this.field_147124_at.func_147604_a(0.0F, 0.0F, 0.0F, 0.0F); - this.field_110451_am = new SimpleReloadableResourceManager(ResourcePackType.CLIENT_RESOURCES); -+ net.minecraftforge.fml.client.ClientModLoader.begin(this, this.field_110448_aq, this.field_110451_am, this.field_195554_ax); - this.field_110448_aq.func_198983_a(); - this.field_71474_y.func_198017_a(this.field_110448_aq); - this.field_135017_as = new LanguageManager(this.field_71474_y.field_74363_ab); -@@ -476,6 +_,7 @@ - this.func_193986_ar(); - this.field_110451_am.func_219534_a(this.field_193995_ae); - this.field_71452_i = new ParticleManager(this.field_71441_e, this.field_71446_o); + this.f_90990_.m_85380_(this.f_91066_.f_92113_); + this.f_91067_ = new MouseHandler(this); +- this.f_91067_.m_91524_(this.f_90990_.m_85439_()); + this.f_91068_ = new KeyboardHandler(this); + this.f_91068_.m_90887_(this.f_90990_.m_85439_()); + RenderSystem.m_69580_(this.f_91066_.f_92035_, false); +@@ -458,6 +_,7 @@ + this.f_91042_.m_83931_(0.0F, 0.0F, 0.0F, 0.0F); + this.f_91042_.m_83954_(f_91002_); + this.f_91036_ = new SimpleReloadableResourceManager(PackType.CLIENT_RESOURCES); ++ net.minecraftforge.fmlclient.ClientModLoader.begin(this, this.f_91038_, this.f_91036_, this.f_91037_); + this.f_91038_.m_10506_(); + this.f_91066_.m_92145_(this.f_91038_); + this.f_91039_ = new LanguageManager(this.f_91066_.f_92075_); +@@ -506,6 +_,7 @@ + this.m_91271_(); + this.f_91036_.m_7217_(this.f_90997_); + this.f_91061_ = new ParticleEngine(this.f_91073_, this.f_90987_); + net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.client.event.ParticleFactoryRegisterEvent()); - this.field_110451_am.func_219534_a(this.field_71452_i); - this.field_213272_aL = new PaintingSpriteUploader(this.field_71446_o); - this.field_110451_am.func_219534_a(this.field_213272_aL); -@@ -483,7 +_,8 @@ - this.field_110451_am.func_219534_a(this.field_213273_aM); - this.field_241557_ar_ = new GPUWarning(); - this.field_110451_am.func_219534_a(this.field_241557_ar_); -- this.field_71456_v = new IngameGui(this); -+ this.field_71456_v = new net.minecraftforge.client.gui.ForgeIngameGui(this); -+ this.field_71417_B.func_198029_a(this.field_195558_d.func_198092_i()); //Forge: Moved below ingameGUI setting to prevent NPEs in handeler. - this.field_184132_p = new DebugRenderer(this); - RenderSystem.setErrorCallback(this::func_195545_a); - if (this.field_71474_y.field_74353_u && !this.field_195558_d.func_198113_j()) { -@@ -495,11 +_,6 @@ - this.field_195558_d.func_224798_d(this.field_71474_y.field_225307_E); - this.field_195558_d.func_227801_c_(); - this.func_213226_a(); -- if (s != null) { -- this.func_147108_a(new ConnectingScreen(new MainMenuScreen(), this, s, i)); -- } else { -- this.func_147108_a(new MainMenuScreen(true)); -- } - - ResourceLoadProgressGui.func_212970_a(this); - List list = this.field_110448_aq.func_232623_f_(); -@@ -508,7 +_,14 @@ - if (SharedConstants.field_206244_b) { - this.func_213256_aB(); + this.f_91036_.m_7217_(this.f_91061_); + this.f_91053_ = new PaintingTextureManager(this.f_90987_); + this.f_91036_.m_7217_(this.f_91053_); +@@ -513,7 +_,8 @@ + this.f_91036_.m_7217_(this.f_91054_); + this.f_91047_ = new GpuWarnlistManager(); + this.f_91036_.m_7217_(this.f_91047_); +- this.f_91065_ = new Gui(this); ++ this.f_91065_ = new net.minecraftforge.client.gui.ForgeIngameGui(this); ++ this.f_91067_.m_91524_(this.f_90990_.m_85439_()); //Forge: Moved below ingameGUI setting to prevent NPEs in handeler. + this.f_91064_ = new DebugRenderer(this); + RenderSystem.m_69900_(this::m_91113_); + if (this.f_91042_.f_83915_ == this.f_90990_.m_85441_() && this.f_91042_.f_83916_ == this.f_90990_.m_85442_()) { +@@ -546,13 +_,16 @@ } -- -+ if (net.minecraftforge.fml.client.ClientModLoader.completeModLoading()) return; // Do not overwrite the error screen + + this.f_167847_.m_168556_(); ++ if (net.minecraftforge.fmlclient.ClientModLoader.completeModLoading()) return; // Do not overwrite the error screen + // FORGE: Move opening initial screen to after startup and events are enabled. + // Also Fixes MC-145102 + if (s != null) { -+ this.func_147108_a(new ConnectingScreen(new MainMenuScreen(), this, s, i)); ++ ConnectScreen.m_169267_(new TitleScreen(), this, new ServerAddress(s, i), (ServerData)null); + } else { -+ this.func_147108_a(new MainMenuScreen(true)); ++ this.m_91152_(new TitleScreen(true)); + } }); }, false)); - } -@@ -556,7 +_,7 @@ +- if (s != null) { +- ConnectScreen.m_169267_(new TitleScreen(), this, new ServerAddress(s, i), (ServerData)null); +- } else { +- this.m_91152_(new TitleScreen(true)); +- } + } - private void func_229988_a_(Throwable p_229988_1_) { -- if (this.field_110448_aq.func_232621_d_().size() > 1) { -+ if (this.field_110448_aq.func_198980_d().stream().anyMatch(e -> !e.func_195797_g())) { //Forge: This caused infinite loop if any resource packs are forced. Such as mod resources. So check if we can disable any. - ITextComponent itextcomponent; - if (p_229988_1_ instanceof SimpleReloadableResourceManager.FailedPackException) { - itextcomponent = new StringTextComponent(((SimpleReloadableResourceManager.FailedPackException)p_229988_1_).func_241203_a().func_195762_a()); -@@ -644,7 +_,7 @@ - return Stream.of(Registry.field_212630_s.func_177774_c(p_213251_0_.func_77973_b())); - }); - SearchTreeReloadable searchtreereloadable = new SearchTreeReloadable<>((p_213235_0_) -> { -- return ItemTags.func_199903_a().func_199913_a(p_213235_0_.func_77973_b()).stream(); -+ return p_213235_0_.func_77973_b().getTags().stream(); - }); - NonNullList nonnulllist = NonNullList.func_191196_a(); +@@ -587,6 +_,8 @@ -@@ -714,13 +_,13 @@ - Bootstrap.func_179870_a(p_71377_0_.func_71502_e()); - if (p_71377_0_.func_71497_f() != null) { - Bootstrap.func_179870_a("#@!@# Game crashed! Crash report saved to: #@!@# " + p_71377_0_.func_71497_f()); + private SocialInteractionsService m_91130_(YggdrasilAuthenticationService p_91131_, GameConfig p_91132_) { + try { ++ if ("0".equals(p_91132_.f_101905_.f_101942_.m_92547_())) // Forge: We use "0" in dev. Short circuit to stop exception spam. ++ return new OfflineSocialInteractions(); + return p_91131_.createSocialInteractionsService(p_91132_.f_101905_.f_101942_.m_92547_()); + } catch (AuthenticationException authenticationexception) { + f_90982_.error("Failed to verify authentication", (Throwable)authenticationexception); +@@ -599,7 +_,7 @@ + } + + private void m_91239_(Throwable p_91240_) { +- 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. + Component component; + if (p_91240_ instanceof SimpleReloadableResourceManager.ResourcePackLoadingFailure) { + component = new TextComponent(((SimpleReloadableResourceManager.ResourcePackLoadingFailure)p_91240_).m_10921_().m_8017_()); +@@ -690,7 +_,7 @@ + return Stream.of(Registry.f_122827_.m_7981_(p_91317_.m_41720_())); + }); + ReloadableIdSearchTree reloadableidsearchtree = new ReloadableIdSearchTree<>((p_91121_) -> { +- return ItemTags.m_13193_().m_13394_(p_91121_.m_41720_()).stream(); ++ return p_91121_.m_41720_().getTags().stream(); + }); + NonNullList nonnulllist = NonNullList.m_122779_(); + +@@ -760,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_()); - System.exit(-1); -+ net.minecraftforge.fml.server.ServerLifecycleHooks.handleExit(-1); - } else if (p_71377_0_.func_147149_a(file2)) { - Bootstrap.func_179870_a("#@!@# Game crashed! Crash report saved to: #@!@# " + file2.getAbsolutePath()); ++ net.minecraftforge.fmllegacy.server.ServerLifecycleHooks.handleExit(-1); + } else if (p_91333_.m_127512_(file2)) { + Bootstrap.m_135875_("#@!@# Game crashed! Crash report saved to: #@!@# " + file2.getAbsolutePath()); - System.exit(-1); -+ net.minecraftforge.fml.server.ServerLifecycleHooks.handleExit(-1); ++ net.minecraftforge.fmllegacy.server.ServerLifecycleHooks.handleExit(-1); } else { - Bootstrap.func_179870_a("#@?@# Game crashed! Crash report could not be saved. #@?@#"); + Bootstrap.m_135875_("#@?@# Game crashed! Crash report could not be saved. #@?@#"); - System.exit(-2); -+ net.minecraftforge.fml.server.ServerLifecycleHooks.handleExit(-2); ++ net.minecraftforge.fmllegacy.server.ServerLifecycleHooks.handleExit(-2); } } -@@ -729,6 +_,7 @@ - return this.field_71474_y.field_211842_aO; +@@ -779,6 +_,7 @@ + return this.m_168019_(false); } + @Deprecated // Forge: Use selective refreshResources method in FMLClientHandler - public CompletableFuture func_213237_g() { - if (this.field_213276_aV != null) { - return this.field_213276_aV; -@@ -817,10 +_,6 @@ - } + private CompletableFuture m_168019_(boolean p_168020_) { + if (this.f_91024_ != null) { + return this.f_91024_; +@@ -876,10 +_,6 @@ + f_90982_.error("setScreen called from non-game thread"); + } - public void func_147108_a(@Nullable Screen p_147108_1_) { -- if (this.field_71462_r != null) { -- this.field_71462_r.func_231164_f_(); +- if (this.f_91080_ != null) { +- this.f_91080_.m_7861_(); - } - - if (p_147108_1_ == null && this.field_71441_e == null) { - p_147108_1_ = new MainMenuScreen(); - } else if (p_147108_1_ == null && this.field_71439_g.func_233643_dh_()) { -@@ -831,6 +_,14 @@ + if (p_91153_ == null && this.f_91073_ == null) { + p_91153_ = new TitleScreen(); + } else if (p_91153_ == null && this.f_91074_.m_21224_()) { +@@ -890,6 +_,14 @@ } } -+ Screen old = this.field_71462_r; -+ net.minecraftforge.client.event.GuiOpenEvent event = new net.minecraftforge.client.event.GuiOpenEvent(p_147108_1_); ++ Screen old = this.f_91080_; ++ net.minecraftforge.client.event.GuiOpenEvent event = new net.minecraftforge.client.event.GuiOpenEvent(p_91153_); + if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) return; + -+ p_147108_1_ = event.getGui(); -+ if (old != null && p_147108_1_ != old) -+ old.func_231164_f_(); ++ p_91153_ = event.getGui(); ++ if (old != null && p_91153_ != old) ++ old.m_7861_(); + - if (p_147108_1_ instanceof MainMenuScreen || p_147108_1_ instanceof MultiplayerScreen) { - this.field_71474_y.field_74330_P = false; - this.field_71456_v.func_146158_b().func_146231_a(true); -@@ -962,11 +_,13 @@ - RenderSystem.enableCull(); - this.field_71424_I.func_76319_b(); - if (!this.field_71454_w) { -+ net.minecraftforge.fml.hooks.BasicEventHooks.onRenderTickStart(this.field_71445_n ? this.field_193996_ah : this.field_71428_T.field_194147_b); - this.field_71424_I.func_219895_b("gameRenderer"); - this.field_71460_t.func_195458_a(this.field_71445_n ? this.field_193996_ah : this.field_71428_T.field_194147_b, i, p_195542_1_); - this.field_71424_I.func_219895_b("toasts"); - this.field_193034_aS.func_238541_a_(new MatrixStack()); - this.field_71424_I.func_76319_b(); -+ net.minecraftforge.fml.hooks.BasicEventHooks.onRenderTickEnd(this.field_71445_n ? this.field_193996_ah : this.field_71428_T.field_194147_b); + this.f_91080_ = p_91153_; + BufferUploader.m_166835_(); + if (p_91153_ != null) { +@@ -1018,11 +_,13 @@ + RenderSystem.m_69481_(); + this.f_91026_.m_7238_(); + if (!this.f_91079_) { ++ net.minecraftforge.fmllegacy.hooks.BasicEventHooks.onRenderTickStart(this.f_91012_ ? this.f_91013_ : this.f_90991_.f_92518_); + this.f_91026_.m_6182_("gameRenderer"); + this.f_91063_.m_109093_(this.f_91012_ ? this.f_91013_ : this.f_90991_.f_92518_, i, p_91384_); + this.f_91026_.m_6182_("toasts"); + this.f_91003_.m_94920_(new PoseStack()); + this.f_91026_.m_7238_(); ++ net.minecraftforge.fmllegacy.hooks.BasicEventHooks.onRenderTickEnd(this.f_91012_ ? this.f_91013_ : this.f_90991_.f_92518_); } - if (this.field_238174_aV_ != null) { -@@ -1065,6 +_,7 @@ + if (this.f_91056_ != null) { +@@ -1136,6 +_,7 @@ - Framebuffer framebuffer = this.func_147110_a(); - framebuffer.func_216491_a(this.field_195558_d.func_198109_k(), this.field_195558_d.func_198091_l(), field_142025_a); -+ if (this.field_71460_t != null) - this.field_71460_t.func_147704_a(this.field_195558_d.func_198109_k(), this.field_195558_d.func_198091_l()); - this.field_71417_B.func_198021_g(); + RenderTarget rendertarget = this.m_91385_(); + rendertarget.m_83941_(this.f_90990_.m_85441_(), this.f_90990_.m_85442_(), f_91002_); ++ if (this.f_91063_ != null) + this.f_91063_.m_109097_(this.f_90990_.m_85441_(), this.f_90990_.m_85442_()); + this.f_91067_.m_91599_(); } -@@ -1253,11 +_,21 @@ - if (p_147115_1_ && this.field_71476_x != null && this.field_71476_x.func_216346_c() == RayTraceResult.Type.BLOCK) { - BlockRayTraceResult blockraytraceresult = (BlockRayTraceResult)this.field_71476_x; - BlockPos blockpos = blockraytraceresult.func_216350_a(); -- if (!this.field_71441_e.func_180495_p(blockpos).func_196958_f()) { -+ if (!this.field_71441_e.func_175623_d(blockpos)) { -+ net.minecraftforge.client.event.InputEvent.ClickInputEvent inputEvent = net.minecraftforge.client.ForgeHooksClient.onClickInput(0, this.field_71474_y.field_74312_F, Hand.MAIN_HAND); +@@ -1432,11 +_,21 @@ + 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_(); +- if (!this.f_91073_.m_8055_(blockpos).m_60795_()) { ++ if (!this.f_91073_.m_46859_(blockpos)) { ++ net.minecraftforge.client.event.InputEvent.ClickInputEvent inputEvent = net.minecraftforge.client.ForgeHooksClient.onClickInput(0, this.f_91066_.f_92096_, InteractionHand.MAIN_HAND); + if (inputEvent.isCanceled()) { + if (inputEvent.shouldSwingHand()) { -+ this.field_71452_i.addBlockHitEffects(blockpos, blockraytraceresult); -+ this.field_71439_g.func_184609_a(Hand.MAIN_HAND); ++ this.f_91061_.addBlockHitEffects(blockpos, blockhitresult); ++ this.f_91074_.m_6674_(InteractionHand.MAIN_HAND); + } + return; + } - Direction direction = blockraytraceresult.func_216354_b(); - if (this.field_71442_b.func_180512_c(blockpos, direction)) { -- this.field_71452_i.func_180532_a(blockpos, direction); + Direction direction = blockhitresult.m_82434_(); + if (this.f_91072_.m_105283_(blockpos, direction)) { +- this.f_91061_.m_107367_(blockpos, direction); + if (inputEvent.shouldSwingHand()) { -+ this.field_71452_i.addBlockHitEffects(blockpos, blockraytraceresult); - this.field_71439_g.func_184609_a(Hand.MAIN_HAND); ++ this.f_91061_.addBlockHitEffects(blockpos, blockhitresult); + this.f_91074_.m_6674_(InteractionHand.MAIN_HAND); + } } } -@@ -1276,6 +_,8 @@ +@@ -1455,6 +_,8 @@ } - } else if (!this.field_71439_g.func_184838_M()) { -+ net.minecraftforge.client.event.InputEvent.ClickInputEvent inputEvent = net.minecraftforge.client.ForgeHooksClient.onClickInput(0, this.field_71474_y.field_74312_F, Hand.MAIN_HAND); + } else if (!this.f_91074_.m_108637_()) { ++ net.minecraftforge.client.event.InputEvent.ClickInputEvent inputEvent = net.minecraftforge.client.ForgeHooksClient.onClickInput(0, this.f_91066_.f_92096_, InteractionHand.MAIN_HAND); + if (!inputEvent.isCanceled()) - switch(this.field_71476_x.func_216346_c()) { + switch(this.f_91077_.m_6662_()) { case ENTITY: - this.field_71442_b.func_78764_a(this.field_71439_g, ((EntityRayTraceResult)this.field_71476_x).func_216348_a()); -@@ -1283,7 +_,7 @@ + this.f_91072_.m_105223_(this.f_91074_, ((EntityHitResult)this.f_91077_).m_82443_()); +@@ -1462,7 +_,7 @@ case BLOCK: - BlockRayTraceResult blockraytraceresult = (BlockRayTraceResult)this.field_71476_x; - BlockPos blockpos = blockraytraceresult.func_216350_a(); -- if (!this.field_71441_e.func_180495_p(blockpos).func_196958_f()) { -+ if (!this.field_71441_e.func_175623_d(blockpos)) { - this.field_71442_b.func_180511_b(blockpos, blockraytraceresult.func_216354_b()); + BlockHitResult blockhitresult = (BlockHitResult)this.f_91077_; + BlockPos blockpos = blockhitresult.m_82425_(); +- if (!this.f_91073_.m_8055_(blockpos).m_60795_()) { ++ if (!this.f_91073_.m_46859_(blockpos)) { + this.f_91072_.m_105269_(blockpos, blockhitresult.m_82434_()); break; } -@@ -1293,8 +_,10 @@ +@@ -1472,8 +_,10 @@ } - this.field_71439_g.func_184821_cY(); -+ net.minecraftforge.common.ForgeHooks.onEmptyLeftClick(this.field_71439_g); + this.f_91074_.m_36334_(); ++ net.minecraftforge.common.ForgeHooks.onEmptyLeftClick(this.f_91074_); } + if (inputEvent.shouldSwingHand()) - this.field_71439_g.func_184609_a(Hand.MAIN_HAND); + this.f_91074_.m_6674_(InteractionHand.MAIN_HAND); } } -@@ -1309,6 +_,11 @@ +@@ -1488,6 +_,11 @@ } - for(Hand hand : Hand.values()) { -+ net.minecraftforge.client.event.InputEvent.ClickInputEvent inputEvent = net.minecraftforge.client.ForgeHooksClient.onClickInput(1, this.field_71474_y.field_74313_G, hand); + for(InteractionHand interactionhand : InteractionHand.values()) { ++ net.minecraftforge.client.event.InputEvent.ClickInputEvent inputEvent = net.minecraftforge.client.ForgeHooksClient.onClickInput(1, this.f_91066_.f_92095_, interactionhand); + if (inputEvent.isCanceled()) { -+ if (inputEvent.shouldSwingHand()) this.field_71439_g.func_184609_a(hand); ++ if (inputEvent.shouldSwingHand()) this.f_91074_.m_6674_(interactionhand); + return; + } - ItemStack itemstack = this.field_71439_g.func_184586_b(hand); - if (this.field_71476_x != null) { - switch(this.field_71476_x.func_216346_c()) { -@@ -1322,6 +_,7 @@ + ItemStack itemstack = this.f_91074_.m_21120_(interactionhand); + if (this.f_91077_ != null) { + switch(this.f_91077_.m_6662_()) { +@@ -1501,6 +_,7 @@ - if (actionresulttype.func_226246_a_()) { - if (actionresulttype.func_226247_b_()) { + if (interactionresult.m_19077_()) { + if (interactionresult.m_19080_()) { + if (inputEvent.shouldSwingHand()) - this.field_71439_g.func_184609_a(hand); + this.f_91074_.m_6674_(interactionhand); } -@@ -1334,6 +_,7 @@ - ActionResultType actionresulttype1 = this.field_71442_b.func_217292_a(this.field_71439_g, this.field_71441_e, hand, blockraytraceresult); - if (actionresulttype1.func_226246_a_()) { - if (actionresulttype1.func_226247_b_()) { +@@ -1513,6 +_,7 @@ + InteractionResult interactionresult1 = this.f_91072_.m_105262_(this.f_91074_, this.f_91073_, interactionhand, blockhitresult); + if (interactionresult1.m_19077_()) { + if (interactionresult1.m_19080_()) { + if (inputEvent.shouldSwingHand()) - this.field_71439_g.func_184609_a(hand); - if (!itemstack.func_190926_b() && (itemstack.func_190916_E() != i || this.field_71442_b.func_78758_h())) { - this.field_71460_t.field_78516_c.func_187460_a(hand); -@@ -1349,6 +_,9 @@ + 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); +@@ -1528,6 +_,9 @@ } } -+ if (itemstack.func_190926_b() && (this.field_71476_x == null || this.field_71476_x.func_216346_c() == RayTraceResult.Type.MISS)) -+ net.minecraftforge.common.ForgeHooks.onEmptyClick(this.field_71439_g, hand); ++ if (itemstack.m_41619_() && (this.f_91077_ == null || this.f_91077_.m_6662_() == HitResult.Type.MISS)) ++ net.minecraftforge.common.ForgeHooks.onEmptyClick(this.f_91074_, interactionhand); + - if (!itemstack.func_190926_b()) { - ActionResultType actionresulttype2 = this.field_71442_b.func_187101_a(this.field_71439_g, this.field_71441_e, hand); - if (actionresulttype2.func_226246_a_()) { -@@ -1375,6 +_,8 @@ - --this.field_71467_ac; + if (!itemstack.m_41619_()) { + InteractionResult interactionresult2 = this.f_91072_.m_105235_(this.f_91074_, this.f_91073_, interactionhand); + if (interactionresult2.m_19077_()) { +@@ -1554,6 +_,8 @@ + --this.f_91011_; } -+ net.minecraftforge.fml.hooks.BasicEventHooks.onPreClientTick(); ++ net.minecraftforge.fmllegacy.hooks.BasicEventHooks.onPreClientTick(); + - this.field_71424_I.func_76320_a("gui"); - if (!this.field_71445_n) { - this.field_71456_v.func_73831_a(); -@@ -1500,6 +_,8 @@ - this.field_71424_I.func_219895_b("keyboard"); - this.field_195559_v.func_204870_b(); - this.field_71424_I.func_76319_b(); + this.f_91026_.m_6180_("gui"); + if (!this.f_91012_) { + this.f_91065_.m_93066_(); +@@ -1679,6 +_,8 @@ + this.f_91026_.m_6182_("keyboard"); + this.f_91068_.m_90931_(); + this.f_91026_.m_7238_(); + -+ net.minecraftforge.fml.hooks.BasicEventHooks.onPostClientTick(); ++ net.minecraftforge.fmllegacy.hooks.BasicEventHooks.onPostClientTick(); } - private boolean func_244600_aM() { -@@ -1638,11 +_,11 @@ + private boolean m_91278_() { +@@ -1814,11 +_,11 @@ } - public void func_238191_a_(String p_238191_1_) { -- this.func_238195_a_(p_238191_1_, DynamicRegistries.func_239770_b_(), Minecraft::func_238180_a_, Minecraft::func_238181_a_, false, Minecraft.WorldSelectionType.BACKUP); -+ this.loadWorld(p_238191_1_, DynamicRegistries.func_239770_b_(), Minecraft::func_238180_a_, Minecraft::func_238181_a_, false, Minecraft.WorldSelectionType.BACKUP, false); + public void m_91200_(String p_91201_) { +- this.m_91219_(p_91201_, RegistryAccess.m_123086_(), Minecraft::m_91133_, Minecraft::m_91135_, false, Minecraft.ExperimentalDialogType.BACKUP); ++ this.doLoadLevel(p_91201_, RegistryAccess.m_123086_(), Minecraft::m_91133_, Minecraft::m_91135_, false, Minecraft.ExperimentalDialogType.BACKUP, false); } - public void func_238192_a_(String p_238192_1_, WorldSettings p_238192_2_, DynamicRegistries.Impl p_238192_3_, DimensionGeneratorSettings p_238192_4_) { -- this.func_238195_a_(p_238192_1_, p_238192_3_, (p_238179_1_) -> { -+ this.loadWorld(p_238192_1_, p_238192_3_, (p_238179_1_) -> { - return p_238192_2_.func_234958_g_(); - }, (p_238187_3_, p_238187_4_, p_238187_5_, p_238187_6_) -> { - WorldGenSettingsExport worldgensettingsexport = WorldGenSettingsExport.func_240896_a_(JsonOps.INSTANCE, p_238192_3_); -@@ -1652,10 +_,10 @@ + public void m_91202_(String p_91203_, LevelSettings p_91204_, RegistryAccess.RegistryHolder p_91205_, WorldGenSettings p_91206_) { +- this.m_91219_(p_91203_, p_91205_, (p_167869_) -> { ++ this.doLoadLevel(p_91203_, p_91205_, (p_91129_) -> { + return p_91204_.m_46934_(); + }, (p_167886_, p_167887_, p_167888_, p_167889_) -> { + RegistryWriteOps registrywriteops = RegistryWriteOps.m_135767_(JsonOps.INSTANCE, p_91205_); +@@ -1828,10 +_,10 @@ }); - DimensionGeneratorSettings dimensiongeneratorsettings = dataresult.resultOrPartial(Util.func_240982_a_("Error reading worldgen settings after loading data packs: ", field_147123_G::error)).orElse(p_238192_4_); - return new ServerWorldInfo(p_238192_2_, dimensiongeneratorsettings, dataresult.lifecycle()); -- }, false, Minecraft.WorldSelectionType.CREATE); -+ }, false, Minecraft.WorldSelectionType.CREATE, true); + WorldGenSettings worldgensettings = dataresult.resultOrPartial(Util.m_137489_("Error reading worldgen settings after loading data packs: ", f_90982_::error)).orElse(p_91206_); + return new PrimaryLevelData(p_91204_, worldgensettings, dataresult.lifecycle()); +- }, false, Minecraft.ExperimentalDialogType.CREATE); ++ }, false, Minecraft.ExperimentalDialogType.CREATE, true); } -- private void func_238195_a_(String p_238195_1_, DynamicRegistries.Impl p_238195_2_, Function p_238195_3_, Function4 p_238195_4_, boolean p_238195_5_, Minecraft.WorldSelectionType p_238195_6_) { -+ private void loadWorld(String p_238195_1_, DynamicRegistries.Impl p_238195_2_, Function p_238195_3_, Function4 p_238195_4_, boolean p_238195_5_, Minecraft.WorldSelectionType p_238195_6_, boolean creating) { - SaveFormat.LevelSave saveformat$levelsave; +- private void m_91219_(String p_91220_, RegistryAccess.RegistryHolder p_91221_, Function p_91222_, Function4 p_91223_, boolean p_91224_, Minecraft.ExperimentalDialogType p_91225_) { ++ private void doLoadLevel(String p_91220_, RegistryAccess.RegistryHolder p_91221_, Function p_91222_, Function4 p_91223_, boolean p_91224_, Minecraft.ExperimentalDialogType p_91225_, boolean creating) { + LevelStorageSource.LevelStorageAccess levelstoragesource$levelstorageaccess; try { - saveformat$levelsave = this.field_71469_aa.func_237274_c_(p_238195_1_); -@@ -1667,12 +_,17 @@ + levelstoragesource$levelstorageaccess = this.f_91031_.m_78260_(p_91220_); +@@ -1843,12 +_,17 @@ } - Minecraft.PackManager minecraft$packmanager; -+ final DynamicRegistries.Impl dyn_f; + Minecraft.ServerStem minecraft$serverstem; ++ final RegistryAccess.RegistryHolder dyn_f; try { -- minecraft$packmanager = this.func_238189_a_(p_238195_2_, p_238195_3_, p_238195_4_, p_238195_5_, saveformat$levelsave); -+ Minecraft.PackManager mgr = this.func_238189_a_(p_238195_2_, p_238195_3_, p_238195_4_, p_238195_5_, saveformat$levelsave); +- minecraft$serverstem = this.m_91190_(p_91221_, p_91222_, p_91223_, p_91224_, levelstoragesource$levelstorageaccess); ++ Minecraft.ServerStem mgr = this.m_91190_(p_91221_, p_91222_, p_91223_, p_91224_, levelstoragesource$levelstorageaccess); + // We need to rebuild this if we're loading world, so that it gets all the information from AFTER we inject our mappings from the save. -+ dyn_f = creating ? p_238195_2_ : DynamicRegistries.func_239770_b_(); -+ minecraft$packmanager = creating ? mgr : this.func_238189_a_(dyn_f, p_238195_3_, p_238195_4_, p_238195_5_, saveformat$levelsave); //Note this runs the injection again... which isn't good.. but hey.. we need a better spot to hook in. ++ dyn_f = creating ? p_91221_ : RegistryAccess.m_123086_(); ++ minecraft$serverstem = creating ? mgr : this.m_91190_(dyn_f, p_91222_, p_91223_, p_91224_, levelstoragesource$levelstorageaccess); //Note this runs the injection again... which isn't good.. but hey.. we need a better spot to hook in. + } catch (Exception exception) { - field_147123_G.warn("Failed to load datapacks, can't proceed with server load", (Throwable)exception); - this.func_147108_a(new DatapackFailureScreen(() -> { -- this.func_238195_a_(p_238195_1_, p_238195_2_, p_238195_3_, p_238195_4_, true, p_238195_6_); -+ this.loadWorld(p_238195_1_, p_238195_2_, p_238195_3_, p_238195_4_, true, p_238195_6_, creating); + f_90982_.warn("Failed to load datapacks, can't proceed with server load", (Throwable)exception); + this.m_91152_(new DatapackLoadFailureScreen(() -> { +- this.m_91219_(p_91220_, p_91221_, p_91222_, p_91223_, true, p_91225_); ++ this.doLoadLevel(p_91220_, p_91221_, p_91222_, p_91223_, true, p_91225_, creating); })); try { -@@ -1692,7 +_,7 @@ - this.field_213277_ad.set((TrackingChunkStatusListener)null); +@@ -1868,7 +_,7 @@ + this.f_90999_.set((StoringChunkProgressListener)null); try { -- saveformat$levelsave.func_237287_a_(p_238195_2_, iserverconfiguration); -+ saveformat$levelsave.func_237287_a_(dyn_f, iserverconfiguration); - minecraft$packmanager.func_238225_b_().func_240971_i_(); - YggdrasilAuthenticationService yggdrasilauthenticationservice = new YggdrasilAuthenticationService(this.field_110453_aa); +- levelstoragesource$levelstorageaccess.m_78287_(p_91221_, worlddata); ++ levelstoragesource$levelstorageaccess.m_78287_(dyn_f, worlddata); + minecraft$serverstem.m_91433_().m_136179_(); + YggdrasilAuthenticationService yggdrasilauthenticationservice = new YggdrasilAuthenticationService(this.f_91030_); MinecraftSessionService minecraftsessionservice = yggdrasilauthenticationservice.createMinecraftSessionService(); -@@ -1702,7 +_,7 @@ - SkullTileEntity.func_184294_a(minecraftsessionservice); - PlayerProfileCache.func_187320_a(false); - this.field_71437_Z = MinecraftServer.func_240784_a_((p_238188_8_) -> { -- return new IntegratedServer(p_238188_8_, this, p_238195_2_, saveformat$levelsave, minecraft$packmanager.func_238224_a_(), minecraft$packmanager.func_238225_b_(), iserverconfiguration, minecraftsessionservice, gameprofilerepository, playerprofilecache, (p_238211_1_) -> { -+ return new IntegratedServer(p_238188_8_, this, dyn_f, saveformat$levelsave, minecraft$packmanager.func_238224_a_(), minecraft$packmanager.func_238225_b_(), iserverconfiguration, minecraftsessionservice, gameprofilerepository, playerprofilecache, (p_238211_1_) -> { - TrackingChunkStatusListener trackingchunkstatuslistener = new TrackingChunkStatusListener(p_238211_1_ + 0); - trackingchunkstatuslistener.func_219521_a(); - this.field_213277_ad.set(trackingchunkstatuslistener); -@@ -1747,11 +_,16 @@ - networkmanager.func_150719_a(new ClientLoginNetHandler(networkmanager, this, (Screen)null, (p_229998_0_) -> { +@@ -1880,7 +_,7 @@ + SkullBlockEntity.m_182462_(this); + GameProfileCache.m_11004_(false); + this.f_91007_ = MinecraftServer.m_129872_((p_167898_) -> { +- return new IntegratedServer(p_167898_, this, p_91221_, levelstoragesource$levelstorageaccess, minecraft$serverstem.m_91432_(), minecraft$serverstem.m_91433_(), worlddata, minecraftsessionservice, gameprofilerepository, gameprofilecache, (p_168000_) -> { ++ return new IntegratedServer(p_167898_, this, dyn_f, levelstoragesource$levelstorageaccess, minecraft$serverstem.m_91432_(), minecraft$serverstem.m_91433_(), worlddata, minecraftsessionservice, gameprofilerepository, gameprofilecache, (p_168000_) -> { + StoringChunkProgressListener storingchunkprogresslistener = new StoringChunkProgressListener(p_168000_ + 0); + this.f_90999_.set(storingchunkprogresslistener); + return ProcessorChunkProgressListener.m_143583_(storingchunkprogresslistener, this.f_91023_::add); +@@ -1924,11 +_,16 @@ + connection.m_129505_(new ClientHandshakePacketListenerImpl(connection, this, (Screen)null, (p_167998_) -> { })); - networkmanager.func_179290_a(new CHandshakePacket(socketaddress.toString(), 0, ProtocolType.LOGIN)); -- networkmanager.func_179290_a(new CLoginStartPacket(this.func_110432_I().func_148256_e())); -+ com.mojang.authlib.GameProfile gameProfile = this.func_110432_I().func_148256_e(); -+ if (!this.func_110432_I().hasCachedProperties()) { -+ gameProfile = field_152355_az.fillProfileProperties(gameProfile, true); //Forge: Fill profile properties upon game load. Fixes MC-52974. -+ this.func_110432_I().setProperties(gameProfile.getProperties()); + connection.m_129512_(new ClientIntentionPacket(socketaddress.toString(), 0, ConnectionProtocol.LOGIN)); +- connection.m_129512_(new ServerboundHelloPacket(this.m_91094_().m_92548_())); ++ com.mojang.authlib.GameProfile gameProfile = this.m_91094_().m_92548_(); ++ if (!this.m_91094_().hasCachedProperties()) { ++ gameProfile = f_91048_.fillProfileProperties(gameProfile, true); //Forge: Fill profile properties upon game load. Fixes MC-52974. ++ this.m_91094_().setProperties(gameProfile.getProperties()); + } -+ networkmanager.func_179290_a(new CLoginStartPacket(gameProfile)); - this.field_71453_ak = networkmanager; ++ connection.m_129512_(new ServerboundHelloPacket(gameProfile)); + this.f_91009_ = connection; } else { - this.func_241559_a_(p_238195_6_, p_238195_1_, flag, () -> { -- this.func_238195_a_(p_238195_1_, p_238195_2_, p_238195_3_, p_238195_4_, p_238195_5_, Minecraft.WorldSelectionType.NONE); -+ this.loadWorld(p_238195_1_, dyn_f, p_238195_3_, p_238195_4_, p_238195_5_, Minecraft.WorldSelectionType.NONE, creating); + this.m_91143_(p_91225_, p_91220_, flag, () -> { +- this.m_91219_(p_91220_, p_91221_, p_91222_, p_91223_, p_91224_, Minecraft.ExperimentalDialogType.NONE); ++ this.doLoadLevel(p_91220_, dyn_f, p_91222_, p_91223_, p_91224_, Minecraft.ExperimentalDialogType.NONE, creating); }); - minecraft$packmanager.close(); + minecraft$serverstem.close(); -@@ -1821,6 +_,7 @@ +@@ -2016,6 +_,7 @@ } - public void func_71403_a(ClientWorld p_71403_1_) { -+ if (field_71441_e != null) net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Unload(field_71441_e)); - WorkingScreen workingscreen = new WorkingScreen(); - workingscreen.func_200210_a(new TranslationTextComponent("connect.joining")); - this.func_213241_c(workingscreen); -@@ -1852,10 +_,12 @@ - IntegratedServer integratedserver = this.field_71437_Z; - this.field_71437_Z = null; - this.field_71460_t.func_190564_k(); -+ net.minecraftforge.fml.client.ClientHooks.firePlayerLogout(this.field_71442_b, this.field_71439_g); - this.field_71442_b = null; - NarratorChatListener.field_193643_a.func_193642_b(); - this.func_213241_c(p_213231_1_); - if (this.field_71441_e != null) { -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Unload(field_71441_e)); + public void m_91156_(ClientLevel p_91157_) { ++ if (f_91073_ != null) net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Unload(f_91073_)); + ProgressScreen progressscreen = new ProgressScreen(true); + progressscreen.m_6309_(new TranslatableComponent("connect.joining")); + this.m_91362_(progressscreen); +@@ -2049,10 +_,12 @@ + IntegratedServer integratedserver = this.f_91007_; + this.f_91007_ = null; + this.f_91063_.m_109150_(); ++ net.minecraftforge.fmlclient.ClientHooks.firePlayerLogout(this.f_91072_, this.f_91074_); + this.f_91072_ = null; + NarratorChatListener.f_93311_.m_93328_(); + this.m_91362_(p_91321_); + if (this.f_91073_ != null) { ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Unload(f_91073_)); if (integratedserver != null) { - this.field_71424_I.func_76320_a("waitForServer"); + this.f_91026_.m_6180_("waitForServer"); -@@ -1870,6 +_,7 @@ - this.field_71456_v.func_181029_i(); - this.field_71422_O = null; - this.field_71455_al = false; -+ net.minecraftforge.fml.client.ClientHooks.handleClientWorldClosing(field_71441_e); - this.field_213274_aO.func_216815_b(); +@@ -2067,6 +_,7 @@ + this.f_91065_.m_93089_(); + this.f_91008_ = null; + this.f_91010_ = false; ++ net.minecraftforge.fmlclient.ClientHooks.handleClientWorldClosing(f_91073_); + this.f_91004_.m_90740_(); } -@@ -1900,6 +_,7 @@ - this.field_71452_i.func_78870_a(p_213257_1_); - TileEntityRendererDispatcher.field_147556_a.func_147543_a(p_213257_1_); - this.func_230150_b_(); +@@ -2097,6 +_,7 @@ + this.f_91061_.m_107342_(p_91325_); + this.f_167845_.m_112257_(p_91325_); + this.m_91341_(); + net.minecraftforge.client.MinecraftForgeClient.clearRenderCache(); } - public boolean func_238216_r_() { -@@ -1945,112 +_,9 @@ + public boolean m_91400_() { +@@ -2152,66 +_,9 @@ - private void func_147112_ai() { - if (this.field_71476_x != null && this.field_71476_x.func_216346_c() != RayTraceResult.Type.MISS) { -- boolean flag = this.field_71439_g.field_71075_bZ.field_75098_d; -- TileEntity tileentity = null; -- RayTraceResult.Type raytraceresult$type = this.field_71476_x.func_216346_c(); + private void m_91280_() { + if (this.f_91077_ != null && this.f_91077_.m_6662_() != HitResult.Type.MISS) { +- boolean flag = this.f_91074_.m_150110_().f_35937_; +- BlockEntity blockentity = null; +- HitResult.Type hitresult$type = this.f_91077_.m_6662_(); - ItemStack itemstack; -- if (raytraceresult$type == RayTraceResult.Type.BLOCK) { -- BlockPos blockpos = ((BlockRayTraceResult)this.field_71476_x).func_216350_a(); -- BlockState blockstate = this.field_71441_e.func_180495_p(blockpos); -- Block block = blockstate.func_177230_c(); -- if (blockstate.func_196958_f()) { +- if (hitresult$type == HitResult.Type.BLOCK) { +- BlockPos blockpos = ((BlockHitResult)this.f_91077_).m_82425_(); +- BlockState blockstate = this.f_91073_.m_8055_(blockpos); +- if (blockstate.m_60795_()) { - return; - } - -- itemstack = block.func_185473_a(this.field_71441_e, blockpos, blockstate); -- if (itemstack.func_190926_b()) { +- Block block = blockstate.m_60734_(); +- itemstack = block.m_7397_(this.f_91073_, blockpos, blockstate); +- if (itemstack.m_41619_()) { - return; - } - -- if (flag && Screen.func_231172_r_() && block.func_235695_q_()) { -- tileentity = this.field_71441_e.func_175625_s(blockpos); +- if (flag && Screen.m_96637_() && blockstate.m_155947_()) { +- blockentity = this.f_91073_.m_7702_(blockpos); - } - } else { -- if (raytraceresult$type != RayTraceResult.Type.ENTITY || !flag) { +- if (hitresult$type != HitResult.Type.ENTITY || !flag) { - return; - } - -- Entity entity = ((EntityRayTraceResult)this.field_71476_x).func_216348_a(); -- if (entity instanceof PaintingEntity) { -- itemstack = new ItemStack(Items.field_151159_an); -- } else if (entity instanceof LeashKnotEntity) { -- itemstack = new ItemStack(Items.field_151058_ca); -- } else if (entity instanceof ItemFrameEntity) { -- ItemFrameEntity itemframeentity = (ItemFrameEntity)entity; -- ItemStack itemstack1 = itemframeentity.func_82335_i(); -- if (itemstack1.func_190926_b()) { -- itemstack = new ItemStack(Items.field_151160_bD); -- } else { -- itemstack = itemstack1.func_77946_l(); -- } -- } else if (entity instanceof AbstractMinecartEntity) { -- AbstractMinecartEntity abstractminecartentity = (AbstractMinecartEntity)entity; -- Item item; -- switch(abstractminecartentity.func_184264_v()) { -- case FURNACE: -- item = Items.field_151109_aJ; -- break; -- case CHEST: -- item = Items.field_151108_aI; -- break; -- case TNT: -- item = Items.field_151142_bV; -- break; -- case HOPPER: -- item = Items.field_151140_bW; -- break; -- case COMMAND_BLOCK: -- item = Items.field_151095_cc; -- break; -- default: -- item = Items.field_151143_au; -- } -- -- itemstack = new ItemStack(item); -- } else if (entity instanceof BoatEntity) { -- itemstack = new ItemStack(((BoatEntity)entity).func_184455_j()); -- } else if (entity instanceof ArmorStandEntity) { -- itemstack = new ItemStack(Items.field_179565_cj); -- } else if (entity instanceof EnderCrystalEntity) { -- itemstack = new ItemStack(Items.field_185158_cP); -- } else { -- SpawnEggItem spawneggitem = SpawnEggItem.func_200889_b(entity.func_200600_R()); -- if (spawneggitem == null) { -- return; -- } -- -- itemstack = new ItemStack(spawneggitem); +- Entity entity = ((EntityHitResult)this.f_91077_).m_82443_(); +- itemstack = entity.m_142340_(); +- if (itemstack == null) { +- return; - } - } - -- if (itemstack.func_190926_b()) { +- if (itemstack.m_41619_()) { - String s = ""; -- if (raytraceresult$type == RayTraceResult.Type.BLOCK) { -- s = Registry.field_212618_g.func_177774_c(this.field_71441_e.func_180495_p(((BlockRayTraceResult)this.field_71476_x).func_216350_a()).func_177230_c()).toString(); -- } else if (raytraceresult$type == RayTraceResult.Type.ENTITY) { -- s = Registry.field_212629_r.func_177774_c(((EntityRayTraceResult)this.field_71476_x).func_216348_a().func_200600_R()).toString(); +- if (hitresult$type == HitResult.Type.BLOCK) { +- s = Registry.f_122824_.m_7981_(this.f_91073_.m_8055_(((BlockHitResult)this.f_91077_).m_82425_()).m_60734_()).toString(); +- } else if (hitresult$type == HitResult.Type.ENTITY) { +- s = Registry.f_122826_.m_7981_(((EntityHitResult)this.f_91077_).m_82443_().m_6095_()).toString(); - } - -- field_147123_G.warn("Picking on: [{}] {} gave null item", raytraceresult$type, s); +- f_90982_.warn("Picking on: [{}] {} gave null item", hitresult$type, s); - } else { -- PlayerInventory playerinventory = this.field_71439_g.field_71071_by; -- if (tileentity != null) { -- this.func_184119_a(itemstack, tileentity); +- Inventory inventory = this.f_91074_.m_150109_(); +- if (blockentity != null) { +- this.m_91122_(itemstack, blockentity); - } - -- int i = playerinventory.func_184429_b(itemstack); +- int i = inventory.m_36030_(itemstack); - if (flag) { -- playerinventory.func_184434_a(itemstack); -- this.field_71442_b.func_78761_a(this.field_71439_g.func_184586_b(Hand.MAIN_HAND), 36 + playerinventory.field_70461_c); +- inventory.m_36012_(itemstack); +- this.f_91072_.m_105241_(this.f_91074_.m_21120_(InteractionHand.MAIN_HAND), 36 + inventory.f_35977_); - } else if (i != -1) { -- if (PlayerInventory.func_184435_e(i)) { -- playerinventory.field_70461_c = i; +- if (Inventory.m_36045_(i)) { +- inventory.f_35977_ = i; - } else { -- this.field_71442_b.func_187100_a(i); +- this.f_91072_.m_105206_(i); - } - } - - } -+ if (!net.minecraftforge.client.ForgeHooksClient.onClickInput(2, this.field_71474_y.field_74322_I, Hand.MAIN_HAND).isCanceled()) -+ net.minecraftforge.common.ForgeHooks.onPickBlock(this.field_71476_x, this.field_71439_g, this.field_71441_e); -+ // We delete this code wholly instead of commenting it out, to make sure we detect changes in it between MC versions ++ if (!net.minecraftforge.client.ForgeHooksClient.onClickInput(2, this.f_91066_.f_92097_, InteractionHand.MAIN_HAND).isCanceled()) ++ net.minecraftforge.common.ForgeHooks.onPickBlock(this.f_91077_, this.f_91074_, this.f_91073_); ++ // We delete this code wholly instead of commenting it out, to make sure we detect changes in it between MC versions } } -@@ -2140,6 +_,7 @@ - return field_71432_P; +@@ -2318,6 +_,7 @@ + return f_90981_; } + @Deprecated // Forge: Use selective scheduleResourceRefresh method in FMLClientHandler - public CompletableFuture func_213245_w() { - return this.func_213169_a(this::func_213237_g).thenCompose((p_229993_0_) -> { - return p_229993_0_; -@@ -2451,7 +_,7 @@ - supplier = func_228022_c_(supplier); - } - -- return new ResourcePackInfo(p_228011_0_, p_228011_1_, supplier, p_228011_3_, p_228011_4_, p_228011_5_, p_228011_6_); -+ return new ResourcePackInfo(p_228011_0_, p_228011_1_, supplier, p_228011_3_, p_228011_4_, p_228011_5_, p_228011_6_, p_228011_3_.isHidden()); + public CompletableFuture m_91088_() { + return this.m_18691_(() -> this.m_91391_()).thenCompose((p_167945_) -> { + return p_167945_; +@@ -2768,7 +_,7 @@ + return this.f_90993_; } - private static Supplier func_228021_b_(Supplier p_228021_0_) { -@@ -2468,6 +_,14 @@ +- private static Pack m_167933_(String p_167934_, Component p_167935_, boolean p_167936_, Supplier p_167937_, PackMetadataSection p_167938_, Pack.Position p_167939_, PackSource p_167940_) { ++ private static Pack createClientPackAdapter(String p_167934_, Component p_167935_, boolean p_167936_, Supplier p_167937_, PackMetadataSection p_167938_, Pack.Position p_167939_, PackSource p_167940_, boolean hidden) { + int i = p_167938_.m_10374_(); + Supplier supplier = p_167937_; + if (i <= 3) { +@@ -2779,7 +_,7 @@ + supplier = m_91352_(supplier); + } - public void func_228020_b_(int p_228020_1_) { - this.field_175617_aL.func_229355_a_(p_228020_1_); +- return new Pack(p_167934_, p_167935_, p_167936_, supplier, p_167938_, PackType.CLIENT_RESOURCES, p_167939_, p_167940_); ++ return new Pack(p_167934_, p_167935_, p_167936_, supplier, p_167938_, PackType.CLIENT_RESOURCES, p_167939_, p_167940_, hidden); + } + + private static Supplier m_91330_(Supplier p_91331_) { +@@ -2796,6 +_,14 @@ + + public void m_91312_(int p_91313_) { + this.f_91051_.m_119410_(p_91313_); + } + + public ItemColors getItemColors() { -+ return this.field_184128_aI; ++ return this.f_91041_; + } + -+ public SearchTreeManager getSearchTreeManager() { -+ return this.field_193995_ae; ++ public SearchRegistry getSearchTreeManager() { ++ return this.f_90997_; } - @OnlyIn(Dist.CLIENT) + public EntityModelSet m_167973_() { diff --git a/patches/minecraft/net/minecraft/client/MouseHandler.java.patch b/patches/minecraft/net/minecraft/client/MouseHandler.java.patch new file mode 100644 index 0000000000..230c2fe4a6 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/MouseHandler.java.patch @@ -0,0 +1,92 @@ +--- a/net/minecraft/client/MouseHandler.java ++++ b/net/minecraft/client/MouseHandler.java +@@ -69,6 +_,7 @@ + this.f_91510_ = -1; + } + ++ if (net.minecraftforge.client.ForgeHooksClient.onRawMouseClicked(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) { +@@ -82,11 +_,15 @@ + if (flag) { + screen.m_169415_(); + Screen.m_96579_(() -> { +- aboolean[0] = screen.m_6375_(d0, d1, i); ++ aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onGuiMouseClickedPre(this.f_91503_.f_91080_, d0, d1, i); ++ if (!aboolean[0]) aboolean[0] = this.f_91503_.f_91080_.m_6375_(d0, d1, i); ++ if (!aboolean[0]) aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onGuiMouseClickedPost(this.f_91503_.f_91080_, d0, d1, i); + }, "mouseClicked event handler", screen.getClass().getCanonicalName()); + } else { + Screen.m_96579_(() -> { +- aboolean[0] = screen.m_6348_(d0, d1, i); ++ aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onGuiMouseReleasedPre(this.f_91503_.f_91080_, d0, d1, i); ++ if (!aboolean[0]) aboolean[0] = this.f_91503_.f_91080_.m_6348_(d0, d1, i); ++ if (!aboolean[0]) aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onGuiMouseReleasedPost(this.f_91503_.f_91080_, d0, d1, i); + }, "mouseReleased event handler", screen.getClass().getCanonicalName()); + } + } +@@ -110,19 +_,26 @@ + } + } + } +- ++ net.minecraftforge.client.ForgeHooksClient.fireMouseInput(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_.f_92045_ ? Math.signum(p_91529_) : p_91529_) * this.f_91503_.f_91066_.f_92033_; ++ // 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_.f_92045_ ? Math.signum(offset) : offset) * this.f_91503_.f_91066_.f_92033_; + if (this.f_91503_.m_91265_() == null) { + if (this.f_91503_.f_91080_ != null) { + double d1 = this.f_91507_ * (double)this.f_91503_.m_91268_().m_85445_() / (double)this.f_91503_.m_91268_().m_85443_(); + double 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); + this.f_91503_.f_91080_.m_169415_(); ++ if (net.minecraftforge.client.ForgeHooksClient.onGuiMouseScrollPre(this, this.f_91503_.f_91080_, d0)) return; ++ if (this.f_91503_.f_91080_.m_6050_(d1, d2, d0)) return; ++ net.minecraftforge.client.ForgeHooksClient.onGuiMouseScrollPost(this, this.f_91503_.f_91080_, d0); + } 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; +@@ -135,6 +_,7 @@ + } + + this.f_91518_ -= (double)f1; ++ if (net.minecraftforge.client.ForgeHooksClient.onMouseScroll(this, d0)) 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_94769_((double)(-f1)); +@@ -203,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.onGuiMouseDragPre(this.f_91503_.f_91080_, d0, d1, this.f_91510_, d2, d3)) return; ++ if (screen.m_7979_(d0, d1, this.f_91510_, d2, d3)) return; ++ net.minecraftforge.client.ForgeHooksClient.onGuiMouseDragPost(this.f_91503_.f_91080_, d0, d1, this.f_91510_, d2, d3); + }, "mouseDragged event handler", screen.getClass().getCanonicalName()); + } + +@@ -286,6 +_,14 @@ + + public double m_91594_() { + return this.f_91508_; ++ } ++ ++ public double getXVelocity() { ++ return this.f_91516_; ++ } ++ ++ public double getYVelocity() { ++ return this.f_91517_; + } + + public void m_91599_() { diff --git a/patches/minecraft/net/minecraft/client/MouseHelper.java.patch b/patches/minecraft/net/minecraft/client/MouseHelper.java.patch deleted file mode 100644 index 6306bba5d6..0000000000 --- a/patches/minecraft/net/minecraft/client/MouseHelper.java.patch +++ /dev/null @@ -1,102 +0,0 @@ ---- a/net/minecraft/client/MouseHelper.java -+++ b/net/minecraft/client/MouseHelper.java -@@ -71,6 +_,7 @@ - this.field_198042_g = -1; - } - -+ if (net.minecraftforge.client.ForgeHooksClient.onRawMouseClicked(p_198023_3_, p_198023_4_, p_198023_5_)) return; - boolean[] aboolean = new boolean[]{false}; - if (this.field_198036_a.field_213279_p == null) { - if (this.field_198036_a.field_71462_r == null) { -@@ -82,11 +_,15 @@ - double d1 = this.field_198041_f * (double)this.field_198036_a.func_228018_at_().func_198087_p() / (double)this.field_198036_a.func_228018_at_().func_198083_n(); - if (flag) { - Screen.func_231153_a_(() -> { -- aboolean[0] = this.field_198036_a.field_71462_r.func_231044_a_(d0, d1, i); -+ aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onGuiMouseClickedPre(this.field_198036_a.field_71462_r, d0, d1, i); -+ if (!aboolean[0]) aboolean[0] = this.field_198036_a.field_71462_r.func_231044_a_(d0, d1, i); -+ if (!aboolean[0]) aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onGuiMouseClickedPost(this.field_198036_a.field_71462_r, d0, d1, i); - }, "mouseClicked event handler", this.field_198036_a.field_71462_r.getClass().getCanonicalName()); - } else { - Screen.func_231153_a_(() -> { -- aboolean[0] = this.field_198036_a.field_71462_r.func_231048_c_(d0, d1, i); -+ aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onGuiMouseReleasedPre(this.field_198036_a.field_71462_r, d0, d1, i); -+ if (!aboolean[0]) aboolean[0] = this.field_198036_a.field_71462_r.func_231048_c_(d0, d1, i); -+ if (!aboolean[0]) aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onGuiMouseReleasedPost(this.field_198036_a.field_71462_r, d0, d1, i); - }, "mouseReleased event handler", this.field_198036_a.field_71462_r.getClass().getCanonicalName()); - } - } -@@ -110,18 +_,26 @@ - } - } - } -- -+ net.minecraftforge.client.ForgeHooksClient.fireMouseInput(p_198023_3_, p_198023_4_, p_198023_5_); - } - } - - private void func_198020_a(long p_198020_1_, double p_198020_3_, double p_198020_5_) { - if (p_198020_1_ == Minecraft.func_71410_x().func_228018_at_().func_198092_i()) { -- double d0 = (this.field_198036_a.field_71474_y.field_216843_O ? Math.signum(p_198020_5_) : p_198020_5_) * this.field_198036_a.field_71474_y.field_208033_V; -+ // FORGE: Allows for Horizontal Scroll to be recognized as Vertical Scroll - Fixes MC-121772 -+ double offset = p_198020_5_; -+ if (Minecraft.field_142025_a && p_198020_5_ == 0) { -+ offset = p_198020_3_; -+ } -+ -+ double d0 = (this.field_198036_a.field_71474_y.field_216843_O ? Math.signum(offset) : offset) * this.field_198036_a.field_71474_y.field_208033_V; - if (this.field_198036_a.field_213279_p == null) { - if (this.field_198036_a.field_71462_r != null) { - double d1 = this.field_198040_e * (double)this.field_198036_a.func_228018_at_().func_198107_o() / (double)this.field_198036_a.func_228018_at_().func_198105_m(); - double d2 = this.field_198041_f * (double)this.field_198036_a.func_228018_at_().func_198087_p() / (double)this.field_198036_a.func_228018_at_().func_198083_n(); -- this.field_198036_a.field_71462_r.func_231043_a_(d1, d2, d0); -+ if (net.minecraftforge.client.ForgeHooksClient.onGuiMouseScrollPre(this, this.field_198036_a.field_71462_r, d0)) return; -+ if (this.field_198036_a.field_71462_r.func_231043_a_(d1, d2, d0)) return; -+ net.minecraftforge.client.ForgeHooksClient.onGuiMouseScrollPost(this, this.field_198036_a.field_71462_r, d0); - } else if (this.field_198036_a.field_71439_g != null) { - if (this.field_200542_o != 0.0D && Math.signum(d0) != Math.signum(this.field_200542_o)) { - this.field_200542_o = 0.0D; -@@ -134,6 +_,7 @@ - } - - this.field_200542_o -= (double)f1; -+ if (net.minecraftforge.client.ForgeHooksClient.onMouseScroll(this, d0)) return; - if (this.field_198036_a.field_71439_g.func_175149_v()) { - if (this.field_198036_a.field_71456_v.func_175187_g().func_175262_a()) { - this.field_198036_a.field_71456_v.func_175187_g().func_195621_a((double)(-f1)); -@@ -202,7 +_,9 @@ - double d2 = (p_198022_3_ - this.field_198040_e) * (double)this.field_198036_a.func_228018_at_().func_198107_o() / (double)this.field_198036_a.func_228018_at_().func_198105_m(); - double d3 = (p_198022_5_ - this.field_198041_f) * (double)this.field_198036_a.func_228018_at_().func_198087_p() / (double)this.field_198036_a.func_228018_at_().func_198083_n(); - Screen.func_231153_a_(() -> { -- iguieventlistener.func_231045_a_(d0, d1, this.field_198042_g, d2, d3); -+ if (net.minecraftforge.client.ForgeHooksClient.onGuiMouseDragPre(this.field_198036_a.field_71462_r, d0, d1, this.field_198042_g, d2, d3)) return; -+ if (iguieventlistener.func_231045_a_(d0, d1, this.field_198042_g, d2, d3)) return; -+ net.minecraftforge.client.ForgeHooksClient.onGuiMouseDragPost(this.field_198036_a.field_71462_r, d0, d1, this.field_198042_g, d2, d3); - }, "mouseDragged event handler", iguieventlistener.getClass().getCanonicalName()); - } - } -@@ -267,12 +_,24 @@ - return this.field_198039_d; - } - -+ public boolean isMiddleDown() { -+ return this.field_198038_c; -+ } -+ - public double func_198024_e() { - return this.field_198040_e; - } - - public double func_198026_f() { - return this.field_198041_f; -+ } -+ -+ public double getXVelocity() { -+ return this.field_198048_m; -+ } -+ -+ public double getYVelocity() { -+ return this.field_198049_n; - } - - public void func_198021_g() { diff --git a/patches/minecraft/net/minecraft/client/Options.java.patch b/patches/minecraft/net/minecraft/client/Options.java.patch new file mode 100644 index 0000000000..d2f2002421 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/Options.java.patch @@ -0,0 +1,59 @@ +--- a/net/minecraft/client/Options.java ++++ b/net/minecraft/client/Options.java +@@ -179,6 +_,7 @@ + public boolean f_92076_; + + public Options(Minecraft p_92138_, File p_92139_) { ++ setForgeKeybindProperties(); + this.f_92060_ = p_92138_; + this.f_92110_ = new File(p_92139_, "options.txt"); + if (p_92138_.m_91103_() && Runtime.getRuntime().maxMemory() >= 1000000000L) { +@@ -283,10 +_,14 @@ + this.f_92076_ = p_168428_.m_142682_("syncChunkWrites", this.f_92076_); + + for(KeyMapping keymapping : this.f_92059_) { +- String s = keymapping.m_90865_(); ++ String s = keymapping.m_90865_() + (keymapping.getKeyModifier() != net.minecraftforge.client.settings.KeyModifier.NONE ? ":" + keymapping.getKeyModifier() : ""); + String s1 = p_168428_.m_141943_("key_" + keymapping.m_90860_(), s); + if (!s.equals(s1)) { +- keymapping.m_90848_(InputConstants.m_84851_(s1)); ++ if (s1.indexOf(':') != -1) { ++ String[] pts = s1.split(":"); ++ keymapping.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.valueFromString(pts[1]), InputConstants.m_84851_(pts[0])); ++ } else ++ keymapping.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.NONE, InputConstants.m_84851_(s1)); + } + } + +@@ -474,6 +_,7 @@ + } + + public void m_92169_() { ++ if (net.minecraftforge.fmlclient.ClientModLoader.isLoading()) return; //Don't save settings before mods add keybindigns and the like to prevent them from being deleted. + try { + final PrintWriter printwriter = new PrintWriter(new OutputStreamWriter(new FileOutputStream(this.f_92110_), StandardCharsets.UTF_8)); + +@@ -622,6 +_,23 @@ + } + + p_92146_.m_10509_(set); ++ } ++ ++ private void setForgeKeybindProperties() { ++ net.minecraftforge.client.settings.KeyConflictContext inGame = net.minecraftforge.client.settings.KeyConflictContext.IN_GAME; ++ f_92085_.setKeyConflictContext(inGame); ++ f_92086_.setKeyConflictContext(inGame); ++ f_92087_.setKeyConflictContext(inGame); ++ f_92088_.setKeyConflictContext(inGame); ++ f_92089_.setKeyConflictContext(inGame); ++ f_92090_.setKeyConflictContext(inGame); ++ f_92091_.setKeyConflictContext(inGame); ++ f_92096_.setKeyConflictContext(inGame); ++ f_92098_.setKeyConflictContext(inGame); ++ f_92099_.setKeyConflictContext(inGame); ++ f_92100_.setKeyConflictContext(inGame); ++ f_92103_.setKeyConflictContext(inGame); ++ f_92104_.setKeyConflictContext(inGame); + } + + public CameraType m_92176_() { diff --git a/patches/minecraft/net/minecraft/client/Screenshot.java.patch b/patches/minecraft/net/minecraft/client/Screenshot.java.patch new file mode 100644 index 0000000000..f97dbd6697 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/Screenshot.java.patch @@ -0,0 +1,29 @@ +--- a/net/minecraft/client/Screenshot.java ++++ b/net/minecraft/client/Screenshot.java +@@ -61,13 +_,23 @@ + file2 = new File(file1, p_92307_); + } + ++ net.minecraftforge.client.event.ScreenshotEvent event = net.minecraftforge.client.ForgeHooksClient.onScreenshot(nativeimage, file2); ++ if (event.isCanceled()) { ++ p_92311_.accept(event.getCancelMessage()); ++ return; ++ } ++ final File target = event.getScreenshotFile(); ++ + Util.m_137579_().execute(() -> { + try { +- nativeimage.m_85056_(file2); ++ nativeimage.m_85056_(target); + Component component = (new TextComponent(file2.getName())).m_130940_(ChatFormatting.UNDERLINE).m_130938_((p_168608_) -> { +- return p_168608_.m_131142_(new ClickEvent(ClickEvent.Action.OPEN_FILE, file2.getAbsolutePath())); ++ return p_168608_.m_131142_(new ClickEvent(ClickEvent.Action.OPEN_FILE, target.getAbsolutePath())); + }); +- p_92311_.accept(new TranslatableComponent("screenshot.success", component)); ++ if (event.getResultMessage() != null) ++ p_92311_.accept(event.getResultMessage()); ++ else ++ p_92311_.accept(new TranslatableComponent("screenshot.success", component)); + } catch (Exception exception) { + f_92276_.warn("Couldn't save screenshot", (Throwable)exception); + p_92311_.accept(new TranslatableComponent("screenshot.failure", exception.getMessage())); diff --git a/patches/minecraft/net/minecraft/client/ToggleKeyMapping.java.patch b/patches/minecraft/net/minecraft/client/ToggleKeyMapping.java.patch new file mode 100644 index 0000000000..89dd794f71 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/ToggleKeyMapping.java.patch @@ -0,0 +1,17 @@ +--- a/net/minecraft/client/ToggleKeyMapping.java ++++ b/net/minecraft/client/ToggleKeyMapping.java +@@ -16,7 +_,7 @@ + + public void m_7249_(boolean p_92534_) { + if (this.f_92527_.getAsBoolean()) { +- if (p_92534_) { ++ if (p_92534_ && isConflictContextAndModifierActive()) { + super.m_7249_(!this.m_90857_()); + } + } else { +@@ -24,4 +_,5 @@ + } + + } ++ @Override public boolean m_90857_() { return this.f_90817_ && (isConflictContextAndModifierActive() || f_92527_.getAsBoolean()); } + } diff --git a/patches/minecraft/net/minecraft/client/User.java.patch b/patches/minecraft/net/minecraft/client/User.java.patch new file mode 100644 index 0000000000..068e648478 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/User.java.patch @@ -0,0 +1,49 @@ +--- a/net/minecraft/client/User.java ++++ b/net/minecraft/client/User.java +@@ -18,8 +_,22 @@ + private final String f_92536_; + private final String f_92537_; + 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_92540_, String p_92541_, String p_92542_, String p_92543_) { ++ if (p_92540_ == null || p_92540_.isEmpty()) { ++ p_92540_ = "MissingName"; ++ p_92541_ = p_92542_ = "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_92540_; + this.f_92536_ = p_92541_; + this.f_92537_ = p_92542_; +@@ -45,10 +_,22 @@ + public GameProfile m_92548_() { + try { + UUID uuid = UUIDTypeAdapter.fromString(this.m_92545_()); +- return new GameProfile(uuid, this.m_92546_()); ++ GameProfile ret = new GameProfile(uuid, this.m_92546_()); //Forge: Adds cached GameProfile properties to returned GameProfile. ++ if (properties != null) ret.getProperties().putAll(properties); // Helps to cut down on calls to the session service, ++ return ret; // which helps to fix MC-52974. + } catch (IllegalArgumentException illegalargumentexception) { + return new GameProfile((UUID)null, this.m_92546_()); + } ++ } ++ ++ //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 User.Type m_168638_() { diff --git a/patches/minecraft/net/minecraft/client/audio/SoundEngine.java.patch b/patches/minecraft/net/minecraft/client/audio/SoundEngine.java.patch deleted file mode 100644 index 7012ada43f..0000000000 --- a/patches/minecraft/net/minecraft/client/audio/SoundEngine.java.patch +++ /dev/null @@ -1,50 +0,0 @@ ---- a/net/minecraft/client/audio/SoundEngine.java -+++ b/net/minecraft/client/audio/SoundEngine.java -@@ -56,6 +_,7 @@ - this.field_148622_c = p_i50892_1_; - this.field_148619_d = p_i50892_2_; - this.field_217939_i = new AudioStreamManager(p_i50892_3_); -+ net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.client.event.sound.SoundLoadEvent(this)); - } - - public void func_148596_a() { -@@ -71,6 +_,7 @@ - - this.func_148613_b(); - this.func_148608_i(); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.sound.SoundLoadEvent(this)); - } - - private synchronized void func_148608_i() { -@@ -266,7 +_,8 @@ - - public void func_148611_c(ISound p_148611_1_) { - if (this.field_148617_f) { -- if (p_148611_1_.func_230510_t_()) { -+ p_148611_1_ = net.minecraftforge.client.ForgeHooksClient.playSound(this, p_148611_1_); -+ if (p_148611_1_ != null && p_148611_1_.func_230510_t_()) { - SoundEventAccessor soundeventaccessor = p_148611_1_.func_184366_a(this.field_148622_c); - ResourceLocation resourcelocation = p_148611_1_.func_147650_b(); - if (soundeventaccessor == null) { -@@ -331,11 +_,13 @@ - p_239543_8_.func_216420_a(vector3d); - p_239543_8_.func_216432_b(flag); - }); -+ final ISound isound = p_148611_1_; - if (!flag3) { - this.field_217939_i.func_217909_a(sound.func_188721_b()).thenAccept((p_217934_1_) -> { - channelmanager$entry.func_217888_a((p_217925_1_) -> { - p_217925_1_.func_216429_a(p_217934_1_); - p_217925_1_.func_216438_c(); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.sound.PlaySoundSourceEvent(this, isound, p_217925_1_)); - }); - }); - } else { -@@ -343,6 +_,7 @@ - channelmanager$entry.func_217888_a((p_217935_1_) -> { - p_217935_1_.func_216433_a(p_217928_1_); - p_217935_1_.func_216438_c(); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.sound.PlayStreamingSourceEvent(this, isound, p_217935_1_)); - }); - }); - } diff --git a/patches/minecraft/net/minecraft/client/audio/SoundHandler.java.patch b/patches/minecraft/net/minecraft/client/audio/SoundHandler.java.patch deleted file mode 100644 index be49f5e646..0000000000 --- a/patches/minecraft/net/minecraft/client/audio/SoundHandler.java.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/net/minecraft/client/audio/SoundHandler.java -+++ b/net/minecraft/client/audio/SoundHandler.java -@@ -192,6 +_,11 @@ - this.field_147694_f.func_195855_a(p_195478_1_, p_195478_2_); - } - -+ //@Override //TODO: Filtered reload -+ public net.minecraftforge.resource.IResourceType getResourceType() { -+ return net.minecraftforge.resource.VanillaResourceType.SOUNDS; -+ } -+ - public String func_215293_f() { - return this.field_147694_f.func_217932_f(); - } diff --git a/patches/minecraft/net/minecraft/client/color/block/BlockColors.java.patch b/patches/minecraft/net/minecraft/client/color/block/BlockColors.java.patch new file mode 100644 index 0000000000..531cd10055 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/color/block/BlockColors.java.patch @@ -0,0 +1,42 @@ +--- a/net/minecraft/client/color/block/BlockColors.java ++++ b/net/minecraft/client/color/block/BlockColors.java +@@ -28,7 +_,8 @@ + @OnlyIn(Dist.CLIENT) + public class BlockColors { + private static final int f_168640_ = -1; +- private final IdMapper f_92571_ = new IdMapper<>(32); ++ // FORGE: Use RegistryDelegates as non-Vanilla block ids are not constant ++ private final java.util.Map, BlockColor> f_92571_ = new java.util.HashMap<>(); + private final Map>> f_92572_ = Maps.newHashMap(); + + public static BlockColors m_92574_() { +@@ -73,11 +_,12 @@ + blockcolors.m_92589_((p_92596_, p_92597_, p_92598_, p_92599_) -> { + return p_92597_ != null && p_92598_ != null ? 2129968 : 7455580; + }, Blocks.f_50196_); ++ net.minecraftforge.client.ForgeHooksClient.onBlockColorsInit(blockcolors); + return blockcolors; + } + + public int m_92582_(BlockState p_92583_, Level p_92584_, BlockPos p_92585_) { +- BlockColor blockcolor = this.f_92571_.m_7942_(Registry.f_122824_.m_7447_(p_92583_.m_60734_())); ++ BlockColor blockcolor = this.f_92571_.get(p_92583_.m_60734_().delegate); + if (blockcolor != null) { + return blockcolor.m_92566_(p_92583_, (BlockAndTintGetter)null, (BlockPos)null, 0); + } else { +@@ -87,13 +_,13 @@ + } + + public int m_92577_(BlockState p_92578_, @Nullable BlockAndTintGetter p_92579_, @Nullable BlockPos p_92580_, int p_92581_) { +- BlockColor blockcolor = this.f_92571_.m_7942_(Registry.f_122824_.m_7447_(p_92578_.m_60734_())); ++ BlockColor blockcolor = this.f_92571_.get(p_92578_.m_60734_().delegate); + return blockcolor == null ? -1 : blockcolor.m_92566_(p_92578_, p_92579_, p_92580_, p_92581_); + } + + public void m_92589_(BlockColor p_92590_, Block... p_92591_) { + for(Block block : p_92591_) { +- this.f_92571_.m_122664_(p_92590_, Registry.f_122824_.m_7447_(block)); ++ this.f_92571_.put(block.delegate, p_92590_); + } + + } diff --git a/patches/minecraft/net/minecraft/client/color/item/ItemColors.java.patch b/patches/minecraft/net/minecraft/client/color/item/ItemColors.java.patch new file mode 100644 index 0000000000..1ab1c1def5 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/color/item/ItemColors.java.patch @@ -0,0 +1,33 @@ +--- a/net/minecraft/client/color/item/ItemColors.java ++++ b/net/minecraft/client/color/item/ItemColors.java +@@ -24,7 +_,8 @@ + @OnlyIn(Dist.CLIENT) + public class ItemColors { + private static final int f_168642_ = -1; +- private final IdMapper f_92674_ = new IdMapper<>(32); ++ // FORGE: Use RegistryDelegates as non-Vanilla item ids are not constant ++ private final java.util.Map, ItemColor> f_92674_ = new java.util.HashMap<>(); + + public static ItemColors m_92683_(BlockColors p_92684_) { + ItemColors itemcolors = new ItemColors(); +@@ -84,17 +_,18 @@ + itemcolors.m_92689_((p_92693_, p_92694_) -> { + return p_92694_ == 0 ? -1 : MapItem.m_42918_(p_92693_); + }, Items.f_42573_); ++ net.minecraftforge.client.ForgeHooksClient.onItemColorsInit(itemcolors, p_92684_); + return itemcolors; + } + + public int m_92676_(ItemStack p_92677_, int p_92678_) { +- ItemColor itemcolor = this.f_92674_.m_7942_(Registry.f_122827_.m_7447_(p_92677_.m_41720_())); ++ ItemColor itemcolor = this.f_92674_.get(p_92677_.m_41720_().delegate); + return itemcolor == null ? -1 : itemcolor.m_92671_(p_92677_, p_92678_); + } + + public void m_92689_(ItemColor p_92690_, ItemLike... p_92691_) { + for(ItemLike itemlike : p_92691_) { +- this.f_92674_.m_122664_(p_92690_, Item.m_41393_(itemlike.m_5456_())); ++ this.f_92674_.put(itemlike.m_5456_().delegate, p_92690_); + } + + } diff --git a/patches/minecraft/net/minecraft/client/entity/player/AbstractClientPlayerEntity.java.patch b/patches/minecraft/net/minecraft/client/entity/player/AbstractClientPlayerEntity.java.patch deleted file mode 100644 index 529419b3eb..0000000000 --- a/patches/minecraft/net/minecraft/client/entity/player/AbstractClientPlayerEntity.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/client/entity/player/AbstractClientPlayerEntity.java -+++ b/net/minecraft/client/entity/player/AbstractClientPlayerEntity.java -@@ -126,6 +_,6 @@ - f *= 1.0F - f1 * 0.15F; - } - -- return MathHelper.func_219799_g(Minecraft.func_71410_x().field_71474_y.field_243227_aN, 1.0F, f); -+ return net.minecraftforge.client.ForgeHooksClient.getOffsetFOV(this, f); - } - } diff --git a/patches/minecraft/net/minecraft/client/entity/player/ClientPlayerEntity.java.patch b/patches/minecraft/net/minecraft/client/entity/player/ClientPlayerEntity.java.patch deleted file mode 100644 index 24c32fc4e3..0000000000 --- a/patches/minecraft/net/minecraft/client/entity/player/ClientPlayerEntity.java.patch +++ /dev/null @@ -1,57 +0,0 @@ ---- a/net/minecraft/client/entity/player/ClientPlayerEntity.java -+++ b/net/minecraft/client/entity/player/ClientPlayerEntity.java -@@ -134,6 +_,7 @@ - } - - public boolean func_70097_a(DamageSource p_70097_1_, float p_70097_2_) { -+ net.minecraftforge.common.ForgeHooks.onPlayerAttack(this, p_70097_1_, p_70097_2_); - return false; - } - -@@ -457,6 +_,11 @@ - } - - public void func_184185_a(SoundEvent p_184185_1_, float p_184185_2_, float p_184185_3_) { -+ net.minecraftforge.event.entity.PlaySoundAtEntityEvent event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtEntity(this, p_184185_1_, this.func_184176_by(), p_184185_2_, p_184185_3_); -+ if (event.isCanceled() || event.getSound() == null) return; -+ p_184185_1_ = event.getSound(); -+ p_184185_2_ = event.getVolume(); -+ p_184185_3_ = event.getPitch(); - this.field_70170_p.func_184134_a(this.func_226277_ct_(), this.func_226278_cu_(), this.func_226281_cx_(), p_184185_1_, this.func_184176_by(), p_184185_2_, p_184185_3_, false); - } - -@@ -595,6 +_,7 @@ - boolean flag2 = this.func_223110_ee(); - this.field_239203_ch_ = !this.field_71075_bZ.field_75100_b && !this.func_203007_ba() && this.func_213298_c(Pose.CROUCHING) && (this.func_225608_bj_() || !this.func_70608_bn() && !this.func_213298_c(Pose.STANDING)); - this.field_71158_b.func_225607_a_(this.func_228354_I_()); -+ net.minecraftforge.client.ForgeHooksClient.onInputUpdate(this, this.field_71158_b); - this.field_71159_c.func_193032_ao().func_193293_a(this.field_71158_b); - if (this.func_184587_cr() && !this.func_184218_aH()) { - this.field_71158_b.field_78902_a *= 0.2F; -@@ -667,7 +_,7 @@ - - if (this.field_71158_b.field_78901_c && !flag7 && !flag && !this.field_71075_bZ.field_75100_b && !this.func_184218_aH() && !this.func_70617_f_()) { - ItemStack itemstack = this.func_184582_a(EquipmentSlotType.CHEST); -- if (itemstack.func_77973_b() == Items.field_185160_cR && ElytraItem.func_185069_d(itemstack) && this.func_226566_ei_()) { -+ if (itemstack.canElytraFly(this) && this.func_226566_ei_()) { - this.field_71174_a.func_147297_a(new CEntityActionPacket(this, CEntityActionPacket.Action.START_FALL_FLYING)); - } - } -@@ -974,5 +_,17 @@ - } else { - return super.func_241843_o(p_241843_1_); - } -+ } -+ -+ public void updateSyncFields(ClientPlayerEntity old) { -+ this.field_175172_bI = old.field_175172_bI; -+ this.field_175166_bJ = old.field_175166_bJ; -+ this.field_175167_bK = old.field_175167_bK; -+ this.field_175164_bL = old.field_175164_bL; -+ this.field_175165_bM = old.field_175165_bM; -+ this.field_184841_cd = old.field_184841_cd; -+ this.field_228351_cj_ = old.field_228351_cj_; -+ this.field_175171_bO = old.field_175171_bO; -+ this.field_175168_bP = old.field_175168_bP; - } - } diff --git a/patches/minecraft/net/minecraft/client/entity/player/RemoteClientPlayerEntity.java.patch b/patches/minecraft/net/minecraft/client/entity/player/RemoteClientPlayerEntity.java.patch deleted file mode 100644 index 61d827d647..0000000000 --- a/patches/minecraft/net/minecraft/client/entity/player/RemoteClientPlayerEntity.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/client/entity/player/RemoteClientPlayerEntity.java -+++ b/net/minecraft/client/entity/player/RemoteClientPlayerEntity.java -@@ -29,6 +_,7 @@ - } - - public boolean func_70097_a(DamageSource p_70097_1_, float p_70097_2_) { -+ net.minecraftforge.common.ForgeHooks.onPlayerAttack(this, p_70097_1_, p_70097_2_); - return true; - } - diff --git a/patches/minecraft/net/minecraft/client/gui/DisplayEffectsScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/DisplayEffectsScreen.java.patch deleted file mode 100644 index cf4058a84f..0000000000 --- a/patches/minecraft/net/minecraft/client/gui/DisplayEffectsScreen.java.patch +++ /dev/null @@ -1,33 +0,0 @@ ---- a/net/minecraft/client/gui/DisplayEffectsScreen.java -+++ b/net/minecraft/client/gui/DisplayEffectsScreen.java -@@ -35,6 +_,9 @@ - this.field_147003_i = (this.field_230708_k_ - this.field_146999_f) / 2; - this.field_147045_u = false; - } else { -+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.PotionShiftEvent(this))) -+ this.field_147003_i = (this.field_230708_k_ - this.field_146999_f) / 2; -+ else - this.field_147003_i = 160 + (this.field_230708_k_ - this.field_146999_f - 200) / 2; - this.field_147045_u = true; - } -@@ -59,7 +_,7 @@ - j = 132 / (collection.size() - 1); - } - -- Iterable iterable = Ordering.natural().sortedCopy(collection); -+ Iterable iterable = collection.stream().filter(effectInstance -> effectInstance.shouldRender()).sorted().collect(java.util.stream.Collectors.toList()); - this.func_238810_a_(p_238811_1_, i, j, iterable); - this.func_238812_b_(p_238811_1_, i, j, iterable); - this.func_238813_c_(p_238811_1_, i, j, iterable); -@@ -96,6 +_,11 @@ - int i = this.field_147009_r; - - for(EffectInstance effectinstance : p_238813_4_) { -+ effectinstance.renderInventoryEffect(this, p_238813_1_, p_238813_2_, i, this.func_230927_p_()); -+ if (!effectinstance.shouldRenderInvText()) { -+ i += p_238813_3_; -+ continue; -+ } - String s = I18n.func_135052_a(effectinstance.func_188419_a().func_76393_a()); - if (effectinstance.func_76458_c() >= 1 && effectinstance.func_76458_c() <= 9) { - s = s + ' ' + I18n.func_135052_a("enchantment.level." + (effectinstance.func_76458_c() + 1)); diff --git a/patches/minecraft/net/minecraft/client/gui/Gui.java.patch b/patches/minecraft/net/minecraft/client/gui/Gui.java.patch new file mode 100644 index 0000000000..87407fe9b0 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/Gui.java.patch @@ -0,0 +1,55 @@ +--- a/net/minecraft/client/gui/Gui.java ++++ b/net/minecraft/client/gui/Gui.java +@@ -446,6 +_,10 @@ + + for(MobEffectInstance mobeffectinstance : Ordering.natural().reverse().sortedCopy(collection)) { + MobEffect mobeffect = mobeffectinstance.m_19544_(); ++ net.minecraftforge.client.EffectRenderer renderer = net.minecraftforge.client.RenderProperties.getEffectRenderer(mobeffectinstance); ++ if (!renderer.shouldRenderHUD(mobeffectinstance)) continue; ++ // Rebind in case previous renderHUDEffect changed texture ++ RenderSystem.m_157456_(0, AbstractContainerScreen.f_97725_); + if (mobeffectinstance.m_19575_()) { + int k = this.f_92977_; + int l = 1; +@@ -483,6 +_,7 @@ + RenderSystem.m_157429_(1.0F, 1.0F, 1.0F, f1); + m_93200_(p_93029_, j1 + 3, k1 + 3, this.m_93252_(), 18, 18, textureatlassprite); + }); ++ renderer.renderHUDEffect(mobeffectinstance,this, p_93029_, k, l, this.m_93252_(), f); + } + } + +@@ -608,7 +_,8 @@ + mutablecomponent.m_130940_(ChatFormatting.ITALIC); + } + +- int i = this.m_93082_().m_92852_(mutablecomponent); ++ Component highlightTip = this.f_92994_.getHighlightTip(mutablecomponent); ++ int i = this.m_93082_().m_92852_(highlightTip); + int j = (this.f_92977_ - i) / 2; + int k = this.f_92978_ - 59; + if (!this.f_92986_.f_91072_.m_105205_()) { +@@ -624,7 +_,13 @@ + RenderSystem.m_69478_(); + RenderSystem.m_69453_(); + m_93172_(p_93070_, j - 2, k - 2, j + i + 2, k + 9 + 2, this.f_92986_.f_91066_.m_92143_(0)); +- this.m_93082_().m_92763_(p_93070_, mutablecomponent, (float)j, (float)k, 16777215 + (l << 24)); ++ Font font = net.minecraftforge.client.RenderProperties.get(f_92994_).getFont(f_92994_); ++ if (font == null) { ++ this.m_93082_().m_92763_(p_93070_, highlightTip, (float)j, (float)k, 16777215 + (l << 24)); ++ } else { ++ j = (this.f_92977_ - font.m_92852_(highlightTip)) / 2; ++ font.m_92763_(p_93070_, highlightTip, (float)j, (float)k, 16777215 + (l << 24)); ++ } + RenderSystem.m_69461_(); + } + } +@@ -1128,7 +_,7 @@ + ItemStack itemstack = this.f_92986_.f_91074_.m_150109_().m_36056_(); + if (itemstack.m_41619_()) { + this.f_92993_ = 0; +- } else if (!this.f_92994_.m_41619_() && itemstack.m_150930_(this.f_92994_.m_41720_()) && itemstack.m_41786_().equals(this.f_92994_.m_41786_())) { ++ } else if (!this.f_92994_.m_41619_() && itemstack.m_41720_() == this.f_92994_.m_41720_() && (itemstack.m_41786_().equals(this.f_92994_.m_41786_()) && itemstack.getHighlightTip(itemstack.m_41786_()).equals(f_92994_.getHighlightTip(f_92994_.m_41786_())))) { + if (this.f_92993_ > 0) { + --this.f_92993_; + } diff --git a/patches/minecraft/net/minecraft/client/gui/IngameGui.java.patch b/patches/minecraft/net/minecraft/client/gui/IngameGui.java.patch deleted file mode 100644 index 8ce90013b5..0000000000 --- a/patches/minecraft/net/minecraft/client/gui/IngameGui.java.patch +++ /dev/null @@ -1,63 +0,0 @@ ---- a/net/minecraft/client/gui/IngameGui.java -+++ b/net/minecraft/client/gui/IngameGui.java -@@ -79,7 +_,7 @@ - protected static final ResourceLocation field_110329_b = new ResourceLocation("textures/misc/vignette.png"); - protected static final ResourceLocation field_110330_c = new ResourceLocation("textures/gui/widgets.png"); - protected static final ResourceLocation field_110328_d = new ResourceLocation("textures/misc/pumpkinblur.png"); -- protected static final ITextComponent field_243249_e = new TranslationTextComponent("demo.demoExpired"); -+ private static final ITextComponent field_243249_e = new TranslationTextComponent("demo.demoExpired"); - protected final Random field_73842_c = new Random(); - protected final Minecraft field_73839_d; - protected final ItemRenderer field_73841_b; -@@ -415,6 +_,9 @@ - - for(EffectInstance effectinstance : Ordering.natural().reverse().sortedCopy(collection)) { - Effect effect = effectinstance.func_188419_a(); -+ if (!effectinstance.shouldRenderHUD()) continue; -+ // Rebind in case previous renderHUDEffect changed texture -+ this.field_73839_d.func_110434_K().func_110577_a(ContainerScreen.field_147001_a); - if (effectinstance.func_205348_f()) { - int k = this.field_194811_H; - int l = 1; -@@ -452,6 +_,7 @@ - RenderSystem.color4f(1.0F, 1.0F, 1.0F, f1); - func_238470_a_(p_238444_1_, j1 + 3, k1 + 3, this.func_230927_p_(), 18, 18, textureatlassprite); - }); -+ effectinstance.renderHUDEffect(this, p_238444_1_, k, l, this.func_230927_p_(), f); - } - } - -@@ -576,7 +_,8 @@ - iformattabletextcomponent.func_240699_a_(TextFormatting.ITALIC); - } - -- int i = this.func_175179_f().func_238414_a_(iformattabletextcomponent); -+ ITextComponent highlightTip = this.field_92016_l.getHighlightTip(iformattabletextcomponent); -+ int i = this.func_175179_f().func_238414_a_(highlightTip); - int j = (this.field_194811_H - i) / 2; - int k = this.field_194812_I - 59; - if (!this.field_73839_d.field_71442_b.func_78755_b()) { -@@ -593,7 +_,13 @@ - RenderSystem.enableBlend(); - RenderSystem.defaultBlendFunc(); - func_238467_a_(p_238453_1_, j - 2, k - 2, j + i + 2, k + 9 + 2, this.field_73839_d.field_71474_y.func_216839_a(0)); -- this.func_175179_f().func_243246_a(p_238453_1_, iformattabletextcomponent, (float)j, (float)k, 16777215 + (l << 24)); -+ FontRenderer font = field_92016_l.func_77973_b().getFontRenderer(field_92016_l); -+ if (font == null) { -+ this.func_175179_f().func_243246_a(p_238453_1_, highlightTip, (float)j, (float)k, 16777215 + (l << 24)); -+ } else { -+ j = (this.field_194811_H - font.func_238414_a_(highlightTip)) / 2; -+ font.func_243246_a(p_238453_1_, highlightTip, (float)j, (float)k, 16777215 + (l << 24)); -+ } - RenderSystem.disableBlend(); - RenderSystem.popMatrix(); - } -@@ -1056,7 +_,7 @@ - ItemStack itemstack = this.field_73839_d.field_71439_g.field_71071_by.func_70448_g(); - if (itemstack.func_190926_b()) { - this.field_92017_k = 0; -- } else if (!this.field_92016_l.func_190926_b() && itemstack.func_77973_b() == this.field_92016_l.func_77973_b() && itemstack.func_200301_q().equals(this.field_92016_l.func_200301_q())) { -+ } else if (!this.field_92016_l.func_190926_b() && itemstack.func_77973_b() == this.field_92016_l.func_77973_b() && (itemstack.func_200301_q().equals(this.field_92016_l.func_200301_q()) && itemstack.getHighlightTip(itemstack.func_200301_q()).equals(field_92016_l.getHighlightTip(field_92016_l.func_200301_q())))) { - if (this.field_92017_k > 0) { - --this.field_92017_k; - } diff --git a/patches/minecraft/net/minecraft/client/gui/MapItemRenderer.java.patch b/patches/minecraft/net/minecraft/client/gui/MapItemRenderer.java.patch deleted file mode 100644 index 7f32a92348..0000000000 --- a/patches/minecraft/net/minecraft/client/gui/MapItemRenderer.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/client/gui/MapItemRenderer.java -+++ b/net/minecraft/client/gui/MapItemRenderer.java -@@ -115,6 +_,7 @@ - - for(MapDecoration mapdecoration : this.field_148242_b.field_76203_h.values()) { - if (!p_228089_3_ || mapdecoration.func_191180_f()) { -+ if (mapdecoration.render(k)) { k++; continue; } - p_228089_1_.func_227860_a_(); - p_228089_1_.func_227861_a_((double)(0.0F + (float)mapdecoration.func_176112_b() / 2.0F + 64.0F), (double)(0.0F + (float)mapdecoration.func_176113_c() / 2.0F + 64.0F), (double)-0.02F); - p_228089_1_.func_227863_a_(Vector3f.field_229183_f_.func_229187_a_((float)(mapdecoration.func_176111_d() * 360) / 16.0F)); diff --git a/patches/minecraft/net/minecraft/client/gui/MapRenderer.java.patch b/patches/minecraft/net/minecraft/client/gui/MapRenderer.java.patch new file mode 100644 index 0000000000..0152c302be --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/MapRenderer.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/client/gui/MapRenderer.java ++++ b/net/minecraft/client/gui/MapRenderer.java +@@ -123,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_85837_((double)(0.0F + (float)mapdecoration.m_77804_() / 2.0F + 64.0F), (double)(0.0F + (float)mapdecoration.m_77805_() / 2.0F + 64.0F), (double)-0.02F); + p_93292_.m_85845_(Vector3f.f_122227_.m_122240_((float)(mapdecoration.m_77806_() * 360) / 16.0F)); diff --git a/patches/minecraft/net/minecraft/client/gui/ResourceLoadProgressGui.java.patch b/patches/minecraft/net/minecraft/client/gui/ResourceLoadProgressGui.java.patch deleted file mode 100644 index d9dbfeb036..0000000000 --- a/patches/minecraft/net/minecraft/client/gui/ResourceLoadProgressGui.java.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- a/net/minecraft/client/gui/ResourceLoadProgressGui.java -+++ b/net/minecraft/client/gui/ResourceLoadProgressGui.java -@@ -97,6 +_,7 @@ - int l1 = (int)((double)this.field_212974_b.func_228018_at_().func_198087_p() * 0.8325D); - float f3 = this.field_212975_c.func_219555_b(); - this.field_212978_f = MathHelper.func_76131_a(this.field_212978_f * 0.95F + f3 * 0.050000012F, 0.0F, 1.0F); -+ net.minecraftforge.fml.client.ClientModLoader.renderProgressText(); - if (f < 1.0F) { - this.func_238629_a_(p_230430_1_, i / 2 - k1, l1 - 5, i / 2 + k1, l1 + 5, 1.0F - MathHelper.func_76131_a(f, 0.0F, 1.0F)); - } -@@ -106,6 +_,7 @@ - } - - if (this.field_212979_g == -1L && this.field_212975_c.func_219554_d() && (!this.field_212977_e || f1 >= 2.0F)) { -+ this.field_212979_g = Util.func_211177_b(); // Moved up to guard against inf loops caused by callback - try { - this.field_212975_c.func_219556_e(); - this.field_212976_d.accept(Optional.empty()); -@@ -113,7 +_,6 @@ - this.field_212976_d.accept(Optional.of(throwable)); - } - -- this.field_212979_g = Util.func_211177_b(); - if (this.field_212974_b.field_71462_r != null) { - this.field_212974_b.field_71462_r.func_231158_b_(this.field_212974_b, this.field_212974_b.func_228018_at_().func_198107_o(), this.field_212974_b.func_228018_at_().func_198087_p()); - } diff --git a/patches/minecraft/net/minecraft/client/gui/ScreenManager.java.patch b/patches/minecraft/net/minecraft/client/gui/ScreenManager.java.patch deleted file mode 100644 index 3d4f94b975..0000000000 --- a/patches/minecraft/net/minecraft/client/gui/ScreenManager.java.patch +++ /dev/null @@ -1,25 +0,0 @@ ---- a/net/minecraft/client/gui/ScreenManager.java -+++ b/net/minecraft/client/gui/ScreenManager.java -@@ -40,6 +_,10 @@ - private static final Map, ScreenManager.IScreenFactory> field_216914_b = Maps.newHashMap(); - - public static void func_216909_a(@Nullable ContainerType p_216909_0_, Minecraft p_216909_1_, int p_216909_2_, ITextComponent p_216909_3_) { -+ getScreenFactory(p_216909_0_, p_216909_1_, p_216909_2_, p_216909_3_).ifPresent(f -> f.func_216908_a(p_216909_3_, p_216909_0_, p_216909_1_, p_216909_2_)); -+ } -+ -+ public static java.util.Optional> getScreenFactory(@Nullable ContainerType p_216909_0_, Minecraft p_216909_1_, int p_216909_2_, ITextComponent p_216909_3_) { - if (p_216909_0_ == null) { - field_216913_a.warn("Trying to open invalid screen with name: {}", (Object)p_216909_3_.getString()); - } else { -@@ -47,9 +_,10 @@ - if (iscreenfactory == null) { - field_216913_a.warn("Failed to create screen for menu type: {}", (Object)Registry.field_218366_G.func_177774_c(p_216909_0_)); - } else { -- iscreenfactory.func_216908_a(p_216909_3_, p_216909_0_, p_216909_1_, p_216909_2_); -+ return java.util.Optional.of(iscreenfactory); - } - } -+ return java.util.Optional.empty(); - } - - @Nullable diff --git a/patches/minecraft/net/minecraft/client/gui/advancements/AdvancementTabGui.java.patch b/patches/minecraft/net/minecraft/client/gui/advancements/AdvancementTabGui.java.patch deleted file mode 100644 index e266b3741b..0000000000 --- a/patches/minecraft/net/minecraft/client/gui/advancements/AdvancementTabGui.java.patch +++ /dev/null @@ -1,37 +0,0 @@ ---- a/net/minecraft/client/gui/advancements/AdvancementTabGui.java -+++ b/net/minecraft/client/gui/advancements/AdvancementTabGui.java -@@ -38,6 +_,7 @@ - private int field_191814_q = Integer.MIN_VALUE; - private float field_191815_r; - private boolean field_192992_s; -+ private int page; - - public AdvancementTabGui(Minecraft p_i47589_1_, AdvancementsScreen p_i47589_2_, AdvancementTabType p_i47589_3_, int p_i47589_4_, Advancement p_i47589_5_, DisplayInfo p_i47589_6_) { - this.field_191802_a = p_i47589_1_; -@@ -52,6 +_,15 @@ - this.func_193937_a(this.field_191809_l, p_i47589_5_); - } - -+ public AdvancementTabGui(Minecraft mc, AdvancementsScreen screen, AdvancementTabType type, int index, int page, Advancement adv, DisplayInfo info) { -+ this(mc, screen, type, index, adv, info); -+ this.page = page; -+ } -+ -+ public int getPage() { -+ return page; -+ } -+ - public Advancement func_193935_c() { - return this.field_191805_h; - } -@@ -152,8 +_,8 @@ - return null; - } else { - for(AdvancementTabType advancementtabtype : AdvancementTabType.values()) { -- if (p_193936_2_ < advancementtabtype.func_192650_a()) { -- return new AdvancementTabGui(p_193936_0_, p_193936_1_, advancementtabtype, p_193936_2_, p_193936_3_, p_193936_3_.func_192068_c()); -+ if ((p_193936_2_ % AdvancementTabType.MAX_TABS) < advancementtabtype.func_192650_a()) { -+ return new AdvancementTabGui(p_193936_0_, p_193936_1_, advancementtabtype, p_193936_2_ % AdvancementTabType.MAX_TABS, p_193936_2_ / AdvancementTabType.MAX_TABS, p_193936_3_, p_193936_3_.func_192068_c()); - } - - p_193936_2_ -= advancementtabtype.func_192650_a(); diff --git a/patches/minecraft/net/minecraft/client/gui/advancements/AdvancementTabType.java.patch b/patches/minecraft/net/minecraft/client/gui/advancements/AdvancementTabType.java.patch deleted file mode 100644 index 20042ac1de..0000000000 --- a/patches/minecraft/net/minecraft/client/gui/advancements/AdvancementTabType.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/client/gui/advancements/AdvancementTabType.java -+++ b/net/minecraft/client/gui/advancements/AdvancementTabType.java -@@ -14,6 +_,7 @@ - LEFT(0, 64, 32, 28, 5), - RIGHT(96, 64, 32, 28, 5); - -+ public static final int MAX_TABS = java.util.Arrays.stream(values()).mapToInt(e -> e.field_192664_j).sum(); - private final int field_192660_f; - private final int field_192661_g; - private final int field_192662_h; diff --git a/patches/minecraft/net/minecraft/client/gui/advancements/AdvancementsScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/advancements/AdvancementsScreen.java.patch deleted file mode 100644 index 90c5b02ec4..0000000000 --- a/patches/minecraft/net/minecraft/client/gui/advancements/AdvancementsScreen.java.patch +++ /dev/null @@ -1,72 +0,0 @@ ---- a/net/minecraft/client/gui/advancements/AdvancementsScreen.java -+++ b/net/minecraft/client/gui/advancements/AdvancementsScreen.java -@@ -29,6 +_,7 @@ - private final Map field_191947_i = Maps.newLinkedHashMap(); - private AdvancementTabGui field_191940_s; - private boolean field_191944_v; -+ private static int tabPage, maxPages; - - public AdvancementsScreen(ClientAdvancementManager p_i47383_1_) { - super(NarratorChatListener.field_216868_a); -@@ -44,7 +_,13 @@ - } else { - this.field_191946_h.func_194230_a(this.field_191940_s == null ? null : this.field_191940_s.func_193935_c(), true); - } -- -+ if (this.field_191947_i.size() > AdvancementTabType.MAX_TABS) { -+ int guiLeft = (this.field_230708_k_ - 252) / 2; -+ int guiTop = (this.field_230709_l_ - 140) / 2; -+ func_230480_a_(new net.minecraft.client.gui.widget.button.Button(guiLeft, guiTop - 50, 20, 20, new net.minecraft.util.text.StringTextComponent("<"), b -> tabPage = Math.max(tabPage - 1, 0 ))); -+ func_230480_a_(new net.minecraft.client.gui.widget.button.Button(guiLeft + 252 - 20, guiTop - 50, 20, 20, new net.minecraft.util.text.StringTextComponent(">"), b -> tabPage = Math.min(tabPage + 1, maxPages))); -+ maxPages = this.field_191947_i.size() / AdvancementTabType.MAX_TABS; -+ } - } - - public void func_231164_f_() { -@@ -62,7 +_,7 @@ - int j = (this.field_230709_l_ - 140) / 2; - - for(AdvancementTabGui advancementtabgui : this.field_191947_i.values()) { -- if (advancementtabgui.func_195627_a(i, j, p_231044_1_, p_231044_3_)) { -+ if (advancementtabgui.getPage() == tabPage && advancementtabgui.func_195627_a(i, j, p_231044_1_, p_231044_3_)) { - this.field_191946_h.func_194230_a(advancementtabgui.func_193935_c(), true); - break; - } -@@ -86,6 +_,12 @@ - int i = (this.field_230708_k_ - 252) / 2; - int j = (this.field_230709_l_ - 140) / 2; - this.func_230446_a_(p_230430_1_); -+ if (maxPages != 0) { -+ net.minecraft.util.text.ITextComponent page = new net.minecraft.util.text.StringTextComponent(String.format("%d / %d", tabPage + 1, maxPages + 1)); -+ int width = this.field_230712_o_.func_238414_a_(page); -+ RenderSystem.disableLighting(); -+ this.field_230712_o_.func_238407_a_(p_230430_1_, page.func_241878_f(), i + (252 / 2) - (width / 2), j - 44, -1); -+ } - this.func_238696_c_(p_230430_1_, p_230430_2_, p_230430_3_, i, j); - this.func_238695_a_(p_230430_1_, i, j); - this.func_238697_d_(p_230430_1_, p_230430_2_, p_230430_3_, i, j); -@@ -132,6 +_,7 @@ - this.field_230706_i_.func_110434_K().func_110577_a(field_191945_g); - - for(AdvancementTabGui advancementtabgui : this.field_191947_i.values()) { -+ if (advancementtabgui.getPage() == tabPage) - advancementtabgui.func_238683_a_(p_238695_1_, p_238695_2_, p_238695_3_, advancementtabgui == this.field_191940_s); - } - -@@ -139,6 +_,7 @@ - RenderSystem.defaultBlendFunc(); - - for(AdvancementTabGui advancementtabgui1 : this.field_191947_i.values()) { -+ if (advancementtabgui1.getPage() == tabPage) - advancementtabgui1.func_191796_a(p_238695_2_, p_238695_3_, this.field_230707_j_); - } - -@@ -161,7 +_,7 @@ - - if (this.field_191947_i.size() > 1) { - for(AdvancementTabGui advancementtabgui : this.field_191947_i.values()) { -- if (advancementtabgui.func_195627_a(p_238697_4_, p_238697_5_, (double)p_238697_2_, (double)p_238697_3_)) { -+ if (advancementtabgui.getPage() == tabPage && advancementtabgui.func_195627_a(p_238697_4_, p_238697_5_, (double)p_238697_2_, (double)p_238697_3_)) { - this.func_238652_a_(p_238697_1_, advancementtabgui.func_238685_d_(), p_238697_2_, p_238697_3_); - } - } diff --git a/patches/minecraft/net/minecraft/client/gui/components/AbstractSelectionList.java.patch b/patches/minecraft/net/minecraft/client/gui/components/AbstractSelectionList.java.patch new file mode 100644 index 0000000000..987492630b --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/components/AbstractSelectionList.java.patch @@ -0,0 +1,16 @@ +--- a/net/minecraft/client/gui/components/AbstractSelectionList.java ++++ b/net/minecraft/client/gui/components/AbstractSelectionList.java +@@ -532,6 +_,13 @@ + + } + ++ public int getWidth() { return this.f_93388_; } ++ public int getHeight() { return this.f_93389_; } ++ public int getTop() { return this.f_93390_; } ++ public int getBottom() { return this.f_93391_; } ++ public int getLeft() { return this.f_93393_; } ++ public int getRight() { return this.f_93392_; } ++ + @OnlyIn(Dist.CLIENT) + public abstract static class Entry> implements GuiEventListener { + @Deprecated diff --git a/patches/minecraft/net/minecraft/client/gui/components/AbstractWidget.java.patch b/patches/minecraft/net/minecraft/client/gui/components/AbstractWidget.java.patch new file mode 100644 index 0000000000..130f63de49 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/components/AbstractWidget.java.patch @@ -0,0 +1,42 @@ +--- a/net/minecraft/client/gui/components/AbstractWidget.java ++++ b/net/minecraft/client/gui/components/AbstractWidget.java +@@ -86,7 +_,7 @@ + this.m_93228_(p_93676_, this.f_93620_, this.f_93621_, 0, 46 + i * 20, this.f_93618_ / 2, this.f_93619_); + this.m_93228_(p_93676_, this.f_93620_ + this.f_93618_ / 2, this.f_93621_, 200 - this.f_93618_ / 2, 46 + i * 20, this.f_93618_ / 2, this.f_93619_); + this.m_7906_(p_93676_, minecraft, p_93677_, p_93678_); +- int j = this.f_93623_ ? 16777215 : 10526880; ++ int j = getFGColor(); + m_93215_(p_93676_, font, this.m_6035_(), this.f_93620_ + this.f_93618_ / 2, this.f_93621_ + (this.f_93619_ - 8) / 2, j | Mth.m_14167_(this.f_93625_ * 255.0F) << 24); + } + +@@ -181,6 +_,10 @@ + 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_; + } +@@ -203,6 +_,19 @@ + + protected void m_93692_(boolean p_93693_) { + this.f_93616_ = p_93693_; ++ } ++ ++ public static final int UNSET_FG_COLOR = -1; ++ protected int packedFGColor = UNSET_FG_COLOR; ++ public int getFGColor() { ++ if (packedFGColor != UNSET_FG_COLOR) return packedFGColor; ++ return this.f_93623_ ? 16777215 : 10526880; // White : Light Grey ++ } ++ public void setFGColor(int color) { ++ this.packedFGColor = color; ++ } ++ public void clearFGColor() { ++ this.packedFGColor = UNSET_FG_COLOR; + } + + public NarratableEntry.NarrationPriority m_142684_() { diff --git a/patches/minecraft/net/minecraft/client/gui/components/BossHealthOverlay.java.patch b/patches/minecraft/net/minecraft/client/gui/components/BossHealthOverlay.java.patch new file mode 100644 index 0000000000..9a626bf75c --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/components/BossHealthOverlay.java.patch @@ -0,0 +1,23 @@ +--- a/net/minecraft/client/gui/components/BossHealthOverlay.java ++++ b/net/minecraft/client/gui/components/BossHealthOverlay.java +@@ -34,6 +_,9 @@ + + for(LerpingBossEvent lerpingbossevent : this.f_93699_.values()) { + int k = i / 2 - 91; ++ net.minecraftforge.client.event.RenderGameOverlayEvent.BossInfo event = ++ net.minecraftforge.client.ForgeHooksClient.bossBarRenderPre(p_93705_, this.f_93698_.m_91268_(), lerpingbossevent, k, j, 10 + this.f_93698_.f_91062_.f_92710_); ++ if (!event.isCanceled()) { + RenderSystem.m_157429_(1.0F, 1.0F, 1.0F, 1.0F); + RenderSystem.m_157456_(0, f_93697_); + this.m_93706_(p_93705_, k, j, lerpingbossevent); +@@ -42,7 +_,9 @@ + int i1 = i / 2 - l / 2; + int j1 = j - 9; + this.f_93698_.f_91062_.m_92763_(p_93705_, component, (float)i1, (float)j1, 16777215); +- j += 10 + 9; ++ } ++ j += event.getIncrement(); ++ net.minecraftforge.client.ForgeHooksClient.bossBarRenderPost(p_93705_, this.f_93698_.m_91268_()); + if (j >= this.f_93698_.m_91268_().m_85446_() / 3) { + break; + } diff --git a/patches/minecraft/net/minecraft/client/gui/components/DebugScreenOverlay.java.patch b/patches/minecraft/net/minecraft/client/gui/components/DebugScreenOverlay.java.patch new file mode 100644 index 0000000000..659bc2cf32 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/components/DebugScreenOverlay.java.patch @@ -0,0 +1,28 @@ +--- a/net/minecraft/client/gui/components/DebugScreenOverlay.java ++++ b/net/minecraft/client/gui/components/DebugScreenOverlay.java +@@ -354,7 +_,7 @@ + list.add(this.m_94071_(entry)); + } + +- for(ResourceLocation resourcelocation : this.f_94030_.m_91403_().m_105148_().m_144452_(Registry.f_122901_).m_13394_(blockstate.m_60734_())) { ++ for(ResourceLocation resourcelocation : blockstate.m_60734_().getTags()) { + list.add("#" + resourcelocation); + } + } +@@ -370,7 +_,7 @@ + list.add(this.m_94071_(entry1)); + } + +- for(ResourceLocation resourcelocation1 : this.f_94030_.m_91403_().m_105148_().m_144452_(Registry.f_122899_).m_13394_(fluidstate.m_76152_())) { ++ for(ResourceLocation resourcelocation1 : fluidstate.m_76152_().getTags()) { + list.add("#" + resourcelocation1); + } + } +@@ -380,6 +_,7 @@ + list.add(""); + list.add(ChatFormatting.UNDERLINE + "Targeted Entity"); + list.add(String.valueOf((Object)Registry.f_122826_.m_7981_(entity.m_6095_()))); ++ entity.m_6095_().getTags().forEach(t -> list.add("#" + t)); + } + + return list; diff --git a/patches/minecraft/net/minecraft/client/gui/overlay/BossOverlayGui.java.patch b/patches/minecraft/net/minecraft/client/gui/overlay/BossOverlayGui.java.patch deleted file mode 100644 index 55de676224..0000000000 --- a/patches/minecraft/net/minecraft/client/gui/overlay/BossOverlayGui.java.patch +++ /dev/null @@ -1,23 +0,0 @@ ---- a/net/minecraft/client/gui/overlay/BossOverlayGui.java -+++ b/net/minecraft/client/gui/overlay/BossOverlayGui.java -@@ -32,6 +_,9 @@ - - for(ClientBossInfo clientbossinfo : this.field_184060_g.values()) { - int k = i / 2 - 91; -+ net.minecraftforge.client.event.RenderGameOverlayEvent.BossInfo event = -+ net.minecraftforge.client.ForgeHooksClient.bossBarRenderPre(p_238484_1_, this.field_184059_f.func_228018_at_(), clientbossinfo, k, j, 10 + this.field_184059_f.field_71466_p.field_78288_b); -+ if (!event.isCanceled()) { - RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); - this.field_184059_f.func_110434_K().func_110577_a(field_184058_a); - this.func_238485_a_(p_238484_1_, k, j, clientbossinfo); -@@ -40,7 +_,9 @@ - int i1 = i / 2 - l / 2; - int j1 = j - 9; - this.field_184059_f.field_71466_p.func_243246_a(p_238484_1_, itextcomponent, (float)i1, (float)j1, 16777215); -- j += 10 + 9; -+ } -+ j += event.getIncrement(); -+ net.minecraftforge.client.ForgeHooksClient.bossBarRenderPost(p_238484_1_, this.field_184059_f.func_228018_at_()); - if (j >= this.field_184059_f.func_228018_at_().func_198087_p() / 3) { - break; - } diff --git a/patches/minecraft/net/minecraft/client/gui/overlay/DebugOverlayGui.java.patch b/patches/minecraft/net/minecraft/client/gui/overlay/DebugOverlayGui.java.patch deleted file mode 100644 index 7168c2c606..0000000000 --- a/patches/minecraft/net/minecraft/client/gui/overlay/DebugOverlayGui.java.patch +++ /dev/null @@ -1,28 +0,0 @@ ---- a/net/minecraft/client/gui/overlay/DebugOverlayGui.java -+++ b/net/minecraft/client/gui/overlay/DebugOverlayGui.java -@@ -362,7 +_,7 @@ - list.add(this.func_211534_a(entry)); - } - -- for(ResourceLocation resourcelocation : this.field_175242_a.func_147114_u().func_199724_l().func_241835_a().func_199913_a(blockstate.func_177230_c())) { -+ for(ResourceLocation resourcelocation : blockstate.func_177230_c().getTags()) { - list.add("#" + resourcelocation); - } - } -@@ -378,7 +_,7 @@ - list.add(this.func_211534_a(entry1)); - } - -- for(ResourceLocation resourcelocation1 : this.field_175242_a.func_147114_u().func_199724_l().func_241837_c().func_199913_a(fluidstate.func_206886_c())) { -+ for(ResourceLocation resourcelocation1 : fluidstate.func_206886_c().getTags()) { - list.add("#" + resourcelocation1); - } - } -@@ -388,6 +_,7 @@ - list.add(""); - list.add(TextFormatting.UNDERLINE + "Targeted Entity"); - list.add(String.valueOf((Object)Registry.field_212629_r.func_177774_c(entity.func_200600_R()))); -+ entity.func_200600_R().getTags().forEach(t -> list.add("#" + t)); - } - - return list; diff --git a/patches/minecraft/net/minecraft/client/gui/recipebook/RecipeBookGui.java.patch b/patches/minecraft/net/minecraft/client/gui/recipebook/RecipeBookGui.java.patch deleted file mode 100644 index d038ea7134..0000000000 --- a/patches/minecraft/net/minecraft/client/gui/recipebook/RecipeBookGui.java.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/client/gui/recipebook/RecipeBookGui.java -+++ b/net/minecraft/client/gui/recipebook/RecipeBookGui.java -@@ -95,7 +_,7 @@ - this.func_205702_a(); - this.field_193018_j.clear(); - -- for(RecipeBookCategories recipebookcategories : RecipeBookCategories.func_243236_a(this.field_201522_g.func_241850_m())) { -+ for(RecipeBookCategories recipebookcategories : this.field_201522_g.getRecipeBookCategories()) { - this.field_193018_j.add(new RecipeTabToggleWidget(recipebookcategories)); - } - -@@ -434,7 +_,7 @@ - - languagemanager.func_135045_a(language); - this.field_191888_F.field_71474_y.field_74363_ab = language.getCode(); -- this.field_191888_F.func_213237_g(); -+ net.minecraftforge.client.ForgeHooksClient.refreshResources(this.field_191888_F, net.minecraftforge.resource.VanillaResourceType.LANGUAGES); - this.field_191888_F.field_71474_y.func_74303_b(); - } - diff --git a/patches/minecraft/net/minecraft/client/gui/screen/BiomeGeneratorTypeScreens.java.patch b/patches/minecraft/net/minecraft/client/gui/screen/BiomeGeneratorTypeScreens.java.patch deleted file mode 100644 index 0eb3814ec7..0000000000 --- a/patches/minecraft/net/minecraft/client/gui/screen/BiomeGeneratorTypeScreens.java.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- a/net/minecraft/client/gui/screen/BiomeGeneratorTypeScreens.java -+++ b/net/minecraft/client/gui/screen/BiomeGeneratorTypeScreens.java -@@ -113,6 +_,9 @@ - private BiomeGeneratorTypeScreens(String p_i232324_1_) { - this.field_239076_k_ = new TranslationTextComponent("generator." + p_i232324_1_); - } -+ public BiomeGeneratorTypeScreens(ITextComponent displayName) { -+ this.field_239076_k_ = displayName; -+ } - - private static DimensionGeneratorSettings func_243452_a(DynamicRegistries p_243452_0_, DimensionGeneratorSettings p_243452_1_, BiomeGeneratorTypeScreens p_243452_2_, Biome p_243452_3_) { - BiomeProvider biomeprovider = new SingleBiomeProvider(p_243452_3_); -@@ -166,4 +_,8 @@ - public interface IFactory { - Screen createEditScreen(CreateWorldScreen p_createEditScreen_1_, DimensionGeneratorSettings p_createEditScreen_2_); - } -+ -+ // Forge start -+ // For internal use only, automatically called for all ForgeWorldTypes. Register your ForgeWorldType in the forge registry! -+ public static void registerGenerator(BiomeGeneratorTypeScreens gen) { field_239068_c_.add(gen); } - } diff --git a/patches/minecraft/net/minecraft/client/gui/screen/ControlsScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screen/ControlsScreen.java.patch deleted file mode 100644 index 70336c181a..0000000000 --- a/patches/minecraft/net/minecraft/client/gui/screen/ControlsScreen.java.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- a/net/minecraft/client/gui/screen/ControlsScreen.java -+++ b/net/minecraft/client/gui/screen/ControlsScreen.java -@@ -33,7 +_,7 @@ - this.field_230705_e_.add(this.field_146494_r); - this.field_146493_s = this.func_230480_a_(new Button(this.field_230708_k_ / 2 - 155, this.field_230709_l_ - 29, 150, 20, new TranslationTextComponent("controls.resetAll"), (p_213125_1_) -> { - for(KeyBinding keybinding : this.field_228183_b_.field_74324_K) { -- keybinding.func_197979_b(keybinding.func_197977_i()); -+ keybinding.setToDefault(); - } - - KeyBinding.func_74508_b(); -@@ -57,11 +_,14 @@ - public boolean func_231046_a_(int p_231046_1_, int p_231046_2_, int p_231046_3_) { - if (this.field_146491_f != null) { - if (p_231046_1_ == 256) { -+ this.field_146491_f.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.getActiveModifier(), InputMappings.field_197958_a); - this.field_228183_b_.func_198014_a(this.field_146491_f, InputMappings.field_197958_a); - } else { -+ this.field_146491_f.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.getActiveModifier(), InputMappings.func_197954_a(p_231046_1_, p_231046_2_)); - this.field_228183_b_.func_198014_a(this.field_146491_f, InputMappings.func_197954_a(p_231046_1_, p_231046_2_)); - } - -+ if (!net.minecraftforge.client.settings.KeyModifier.isKeyCodeModifier(this.field_146491_f.getKey())) - this.field_146491_f = null; - this.field_152177_g = Util.func_211177_b(); - KeyBinding.func_74508_b(); diff --git a/patches/minecraft/net/minecraft/client/gui/screen/CreateWorldScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screen/CreateWorldScreen.java.patch deleted file mode 100644 index 2fe57a3798..0000000000 --- a/patches/minecraft/net/minecraft/client/gui/screen/CreateWorldScreen.java.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- a/net/minecraft/client/gui/screen/CreateWorldScreen.java -+++ b/net/minecraft/client/gui/screen/CreateWorldScreen.java -@@ -110,7 +_,7 @@ - - public static CreateWorldScreen func_243425_a(@Nullable Screen p_243425_0_) { - DynamicRegistries.Impl dynamicregistries$impl = DynamicRegistries.func_239770_b_(); -- return new CreateWorldScreen(p_243425_0_, DatapackCodec.field_234880_a_, new WorldOptionsScreen(dynamicregistries$impl, DimensionGeneratorSettings.func_242751_a(dynamicregistries$impl.func_243612_b(Registry.field_239698_ad_), dynamicregistries$impl.func_243612_b(Registry.field_239720_u_), dynamicregistries$impl.func_243612_b(Registry.field_243549_ar)), Optional.of(BiomeGeneratorTypeScreens.field_239066_a_), OptionalLong.empty())); -+ return new CreateWorldScreen(p_243425_0_, DatapackCodec.field_234880_a_, new WorldOptionsScreen(dynamicregistries$impl, net.minecraftforge.client.ForgeHooksClient.getDefaultWorldType().map(type -> type.func_241220_a_(dynamicregistries$impl, new java.util.Random().nextLong(), true, false)).orElseGet(() -> DimensionGeneratorSettings.func_242751_a(dynamicregistries$impl.func_243612_b(Registry.field_239698_ad_), dynamicregistries$impl.func_243612_b(Registry.field_239720_u_), dynamicregistries$impl.func_243612_b(Registry.field_243549_ar))), net.minecraftforge.client.ForgeHooksClient.getDefaultWorldType(), OptionalLong.empty())); - } - - private CreateWorldScreen(@Nullable Screen p_i242063_1_, DatapackCodec p_i242063_2_, WorldOptionsScreen p_i242063_3_) { -@@ -542,6 +_,7 @@ - File file1 = path.toFile(); - if (this.field_243416_G == null) { - this.field_243416_G = new ResourcePackList(new ServerPackFinder(), new FolderPackFinder(file1, IPackNameDecorator.field_232625_a_)); -+ net.minecraftforge.fml.packs.ResourcePackLoader.loadResourcePacks(this.field_243416_G, net.minecraftforge.fml.server.ServerLifecycleHooks::buildPackFinder); - this.field_243416_G.func_198983_a(); - } - diff --git a/patches/minecraft/net/minecraft/client/gui/screen/DeathScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screen/DeathScreen.java.patch deleted file mode 100644 index e646008074..0000000000 --- a/patches/minecraft/net/minecraft/client/gui/screen/DeathScreen.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/client/gui/screen/DeathScreen.java -+++ b/net/minecraft/client/gui/screen/DeathScreen.java -@@ -35,6 +_,7 @@ - })); - Button button = this.func_230480_a_(new Button(this.field_230708_k_ / 2 - 100, this.field_230709_l_ / 4 + 96, 200, 20, new TranslationTextComponent("deathScreen.titleScreen"), (p_213020_1_) -> { - if (this.field_213023_c) { -+ func_213022_a(true); - this.func_228177_a_(); - } else { - ConfirmScreen confirmscreen = new ConfirmScreen(this::func_213022_a, new TranslationTextComponent("deathScreen.quit.confirm"), StringTextComponent.field_240750_d_, new TranslationTextComponent("deathScreen.titleScreen"), new TranslationTextComponent("deathScreen.respawn")); diff --git a/patches/minecraft/net/minecraft/client/gui/screen/EnchantmentScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screen/EnchantmentScreen.java.patch deleted file mode 100644 index 48a04998a0..0000000000 --- a/patches/minecraft/net/minecraft/client/gui/screen/EnchantmentScreen.java.patch +++ /dev/null @@ -1,28 +0,0 @@ ---- a/net/minecraft/client/gui/screen/EnchantmentScreen.java -+++ b/net/minecraft/client/gui/screen/EnchantmentScreen.java -@@ -149,7 +_,7 @@ - int i2 = 86 - this.field_230712_o_.func_78256_a(s); - ITextProperties itextproperties = EnchantmentNameParts.func_178176_a().func_238816_a_(this.field_230712_o_, i2); - int j2 = 6839882; -- if ((l < i1 + 1 || this.field_230706_i_.field_71439_g.field_71068_ca < l1) && !this.field_230706_i_.field_71439_g.field_71075_bZ.field_75098_d) { -+ if (((l < i1 + 1 || this.field_230706_i_.field_71439_g.field_71068_ca < l1) && !this.field_230706_i_.field_71439_g.field_71075_bZ.field_75098_d) || this.field_147002_h.field_185001_h[i1] == -1) { // Forge: render buttons as disabled when enchantable but enchantability not met on lower levels - this.func_238474_b_(p_230450_1_, j1, j + 14 + 19 * i1, 0, 185, 108, 19); - this.func_238474_b_(p_230450_1_, j1 + 1, j + 15 + 19 * i1, 16 * i1, 239, 16, 16); - this.field_230712_o_.func_238418_a_(itextproperties, k1, j + 16 + 19 * i1, i2, (j2 & 16711422) >> 1); -@@ -188,10 +_,13 @@ - Enchantment enchantment = Enchantment.func_185262_c((this.field_147002_h).field_185001_h[j]); - int l = (this.field_147002_h).field_185002_i[j]; - int i1 = j + 1; -- if (this.func_195359_a(60, 14 + 19 * j, 108, 17, (double)p_230430_2_, (double)p_230430_3_) && k > 0 && l >= 0 && enchantment != null) { -+ if (this.func_195359_a(60, 14 + 19 * j, 108, 17, (double)p_230430_2_, (double)p_230430_3_) && k > 0) { - List list = Lists.newArrayList(); -- list.add((new TranslationTextComponent("container.enchant.clue", enchantment.func_200305_d(l))).func_240699_a_(TextFormatting.WHITE)); -- if (!flag) { -+ list.add((new TranslationTextComponent("container.enchant.clue", enchantment == null ? "" : enchantment.func_200305_d(l))).func_240699_a_(TextFormatting.WHITE)); -+ if(enchantment == null) { -+ list.add(new StringTextComponent("")); -+ list.add(new TranslationTextComponent("forge.container.enchant.limitedEnchantability").func_240699_a_(TextFormatting.RED)); -+ } else if (!flag) { - list.add(StringTextComponent.field_240750_d_); - if (this.field_230706_i_.field_71439_g.field_71068_ca < k) { - list.add((new TranslationTextComponent("container.enchant.level.requirement", (this.field_147002_h).field_75167_g[j])).func_240699_a_(TextFormatting.RED)); diff --git a/patches/minecraft/net/minecraft/client/gui/screen/LanguageScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screen/LanguageScreen.java.patch deleted file mode 100644 index e9aed17848..0000000000 --- a/patches/minecraft/net/minecraft/client/gui/screen/LanguageScreen.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/gui/screen/LanguageScreen.java -+++ b/net/minecraft/client/gui/screen/LanguageScreen.java -@@ -46,7 +_,7 @@ - if (languagescreen$list$languageentry != null && !languagescreen$list$languageentry.field_214398_b.getCode().equals(this.field_146454_h.func_135041_c().getCode())) { - this.field_146454_h.func_135045_a(languagescreen$list$languageentry.field_214398_b); - this.field_228183_b_.field_74363_ab = languagescreen$list$languageentry.field_214398_b.getCode(); -- this.field_230706_i_.func_213237_g(); -+ net.minecraftforge.client.ForgeHooksClient.refreshResources(this.field_230706_i_, net.minecraftforge.resource.VanillaResourceType.LANGUAGES); - this.field_146452_r.func_238482_a_(DialogTexts.field_240632_c_); - this.field_211832_i.func_238482_a_(AbstractOption.field_216684_H.func_238152_c_(this.field_228183_b_)); - this.field_228183_b_.func_74303_b(); diff --git a/patches/minecraft/net/minecraft/client/gui/screen/MainMenuScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screen/MainMenuScreen.java.patch deleted file mode 100644 index b199962bec..0000000000 --- a/patches/minecraft/net/minecraft/client/gui/screen/MainMenuScreen.java.patch +++ /dev/null @@ -1,68 +0,0 @@ ---- a/net/minecraft/client/gui/screen/MainMenuScreen.java -+++ b/net/minecraft/client/gui/screen/MainMenuScreen.java -@@ -54,6 +_,7 @@ - private final RenderSkybox field_209101_K = new RenderSkybox(field_213098_a); - private final boolean field_213102_y; - private long field_213103_z; -+ private net.minecraftforge.client.gui.NotificationModUpdateScreen modUpdateNotification; - - public MainMenuScreen() { - this(false); -@@ -97,11 +_,16 @@ - this.field_193979_N = this.field_230708_k_ - this.field_193978_M - 2; - int i = 24; - int j = this.field_230709_l_ / 4 + 48; -+ Button modButton = null; - if (this.field_230706_i_.func_71355_q()) { - this.func_73972_b(j, 24); - } else { - this.func_73969_a(j, 24); -+ modButton = this.func_230480_a_(new Button(this.field_230708_k_ / 2 - 100, j + 24 * 2, 98, 20, new TranslationTextComponent("fml.menu.mods"), button -> { -+ this.field_230706_i_.func_147108_a(new net.minecraftforge.fml.client.gui.screen.ModListScreen(this)); -+ })); - } -+ modUpdateNotification = net.minecraftforge.client.gui.NotificationModUpdateScreen.init(this, modButton); - - this.func_230480_a_(new ImageButton(this.field_230708_k_ / 2 - 124, j + 72 + 12, 20, 20, 0, 106, 20, Button.field_230687_i_, 256, 256, (p_213090_1_) -> { - this.field_230706_i_.func_147108_a(new LanguageScreen(this, this.field_230706_i_.field_71474_y, this.field_230706_i_.func_135016_M())); -@@ -143,7 +_,7 @@ - Screen screen = (Screen)(this.field_230706_i_.field_71474_y.field_230152_Z_ ? new MultiplayerScreen(this) : new MultiplayerWarningScreen(this)); - this.field_230706_i_.func_147108_a(screen); - }, button$itooltip))).field_230693_o_ = flag; -- (this.func_230480_a_(new Button(this.field_230708_k_ / 2 - 100, p_73969_1_ + p_73969_2_ * 2, 200, 20, new TranslationTextComponent("menu.online"), (p_238661_1_) -> { -+ (this.func_230480_a_(new Button(this.field_230708_k_ / 2 + 2, p_73969_1_ + p_73969_2_ * 2, 98, 20, new TranslationTextComponent("menu.online"), (p_238661_1_) -> { - this.func_140005_i(); - }, button$itooltip))).field_230693_o_ = flag; - } -@@ -229,6 +_,7 @@ - - this.field_230706_i_.func_110434_K().func_110577_a(field_194400_H); - func_238463_a_(p_230430_1_, j + 88, 67, 0.0F, 0.0F, 98, 14, 128, 16); -+ net.minecraftforge.client.ForgeHooksClient.renderMainMenu(this, p_230430_1_, this.field_230712_o_, this.field_230708_k_, this.field_230709_l_, l); - if (this.field_73975_c != null) { - RenderSystem.pushMatrix(); - RenderSystem.translatef((float)(this.field_230708_k_ / 2 + 90), 70.0F, 0.0F); -@@ -251,7 +_,14 @@ - s = s + I18n.func_135052_a("menu.modded"); - } - -- func_238476_c_(p_230430_1_, this.field_230712_o_, s, 2, this.field_230709_l_ - 10, 16777215 | l); -+ net.minecraftforge.fml.BrandingControl.forEachLine(true, true, (brdline, brd) -> -+ func_238476_c_(p_230430_1_, this.field_230712_o_, brd, 2, this.field_230709_l_ - ( 10 + brdline * (this.field_230712_o_.field_78288_b + 1)), 16777215 | l) -+ ); -+ -+ net.minecraftforge.fml.BrandingControl.forEachAboveCopyrightLine((brdline, brd) -> -+ func_238476_c_(p_230430_1_, this.field_230712_o_, brd, this.field_230708_k_ - field_230712_o_.func_78256_a(brd), this.field_230709_l_ - (10 + (brdline + 1) * ( this.field_230712_o_.field_78288_b + 1)), 16777215 | l) -+ ); -+ - func_238476_c_(p_230430_1_, this.field_230712_o_, "Copyright Mojang AB. Do not distribute!", this.field_193979_N, this.field_230709_l_ - 10, 16777215 | l); - if (p_230430_2_ > this.field_193979_N && p_230430_2_ < this.field_193979_N + this.field_193978_M && p_230430_3_ > this.field_230709_l_ - 10 && p_230430_3_ < this.field_230709_l_) { - func_238467_a_(p_230430_1_, this.field_193979_N, this.field_230709_l_ - 1, this.field_193979_N + this.field_193978_M, this.field_230709_l_, 16777215 | l); -@@ -265,6 +_,7 @@ - if (this.func_183501_a() && f1 >= 1.0F) { - this.field_183503_M.func_230430_a_(p_230430_1_, p_230430_2_, p_230430_3_, p_230430_4_); - } -+ modUpdateNotification.func_230430_a_(p_230430_1_, p_230430_2_, p_230430_3_, p_230430_4_); - - } - } diff --git a/patches/minecraft/net/minecraft/client/gui/screen/MultiplayerScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screen/MultiplayerScreen.java.patch deleted file mode 100644 index 7e6457c584..0000000000 --- a/patches/minecraft/net/minecraft/client/gui/screen/MultiplayerScreen.java.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/net/minecraft/client/gui/screen/MultiplayerScreen.java -+++ b/net/minecraft/client/gui/screen/MultiplayerScreen.java -@@ -241,6 +_,11 @@ - - } - -+ @Override -+ public void func_231175_as__() { -+ this.field_230706_i_.func_147108_a(this.field_146798_g); -+ } -+ - public ServerPinger func_146789_i() { - return this.field_146797_f; - } diff --git a/patches/minecraft/net/minecraft/client/gui/screen/OptionsScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screen/OptionsScreen.java.patch deleted file mode 100644 index 0fbbbd237c..0000000000 --- a/patches/minecraft/net/minecraft/client/gui/screen/OptionsScreen.java.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- a/net/minecraft/client/gui/screen/OptionsScreen.java -+++ b/net/minecraft/client/gui/screen/OptionsScreen.java -@@ -146,4 +_,12 @@ - func_238472_a_(p_230430_1_, this.field_230712_o_, this.field_230704_d_, this.field_230708_k_ / 2, 15, 16777215); - super.func_230430_a_(p_230430_1_, p_230430_2_, p_230430_3_, p_230430_4_); - } -+ -+ @Override -+ public void func_231175_as__() { -+ // We need to consider 2 potential parent screens here: -+ // 1. From the main menu, in which case display the main menu -+ // 2. From the pause menu, in which case exit back to game -+ this.field_230706_i_.func_147108_a(this.field_146441_g instanceof IngameMenuScreen ? null : this.field_146441_g); -+ } - } diff --git a/patches/minecraft/net/minecraft/client/gui/screen/PackLoadingManager.java.patch b/patches/minecraft/net/minecraft/client/gui/screen/PackLoadingManager.java.patch deleted file mode 100644 index e2f684e9cb..0000000000 --- a/patches/minecraft/net/minecraft/client/gui/screen/PackLoadingManager.java.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- a/net/minecraft/client/gui/screen/PackLoadingManager.java -+++ b/net/minecraft/client/gui/screen/PackLoadingManager.java -@@ -134,6 +_,11 @@ - public void func_230468_k_() { - this.func_238879_a_(1); - } -+ -+ @Override -+ public boolean notHidden() { -+ return !field_238878_b_.isHidden(); -+ } - } - - @OnlyIn(Dist.CLIENT) -@@ -229,5 +_,7 @@ - boolean func_230469_o_(); - - boolean func_230470_p_(); -+ -+ default boolean notHidden() { return true; } - } - } diff --git a/patches/minecraft/net/minecraft/client/gui/screen/PackScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screen/PackScreen.java.patch deleted file mode 100644 index bf3b64ea9c..0000000000 --- a/patches/minecraft/net/minecraft/client/gui/screen/PackScreen.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/gui/screen/PackScreen.java -+++ b/net/minecraft/client/gui/screen/PackScreen.java -@@ -129,7 +_,7 @@ - - private void func_238899_a_(net.minecraft.client.gui.widget.list.ResourcePackList p_238899_1_, Stream p_238899_2_) { - p_238899_1_.func_231039_at__().clear(); -- p_238899_2_.forEach((p_238898_2_) -> { -+ p_238899_2_.filter(PackLoadingManager.IPack::notHidden).forEach((p_238898_2_) -> { - p_238899_1_.func_231039_at__().add(new net.minecraft.client.gui.widget.list.ResourcePackList.ResourcePackEntry(this.field_230706_i_, p_238899_1_, this, p_238898_2_)); - }); - } diff --git a/patches/minecraft/net/minecraft/client/gui/screen/Screen.java.patch b/patches/minecraft/net/minecraft/client/gui/screen/Screen.java.patch deleted file mode 100644 index 622f77e957..0000000000 --- a/patches/minecraft/net/minecraft/client/gui/screen/Screen.java.patch +++ /dev/null @@ -1,94 +0,0 @@ ---- a/net/minecraft/client/gui/screen/Screen.java -+++ b/net/minecraft/client/gui/screen/Screen.java -@@ -113,7 +_,10 @@ - } - - protected void func_230457_a_(MatrixStack p_230457_1_, ItemStack p_230457_2_, int p_230457_3_, int p_230457_4_) { -- this.func_243308_b(p_230457_1_, this.func_231151_a_(p_230457_2_), p_230457_3_, p_230457_4_); -+ FontRenderer font = p_230457_2_.func_77973_b().getFontRenderer(p_230457_2_); -+ net.minecraftforge.fml.client.gui.GuiUtils.preItemToolTip(p_230457_2_); -+ this.renderWrappedToolTip(p_230457_1_, this.func_231151_a_(p_230457_2_), p_230457_3_, p_230457_4_, (font == null ? this.field_230712_o_ : font)); -+ net.minecraftforge.fml.client.gui.GuiUtils.postItemToolTip(); - } - - public List func_231151_a_(ItemStack p_231151_1_) { -@@ -121,14 +_,20 @@ - } - - public void func_238652_a_(MatrixStack p_238652_1_, ITextComponent p_238652_2_, int p_238652_3_, int p_238652_4_) { -- this.func_238654_b_(p_238652_1_, Arrays.asList(p_238652_2_.func_241878_f()), p_238652_3_, p_238652_4_); -+ this.func_243308_b(p_238652_1_, Arrays.asList(p_238652_2_), p_238652_3_, p_238652_4_); - } - - public void func_243308_b(MatrixStack p_243308_1_, List p_243308_2_, int p_243308_3_, int p_243308_4_) { -- this.func_238654_b_(p_243308_1_, Lists.transform(p_243308_2_, ITextComponent::func_241878_f), p_243308_3_, p_243308_4_); -+ this.renderWrappedToolTip(p_243308_1_, p_243308_2_, p_243308_3_, p_243308_4_, field_230712_o_); -+ } -+ public void renderWrappedToolTip(MatrixStack matrixStack, List tooltips, int mouseX, int mouseY, FontRenderer font) { -+ net.minecraftforge.fml.client.gui.GuiUtils.drawHoveringText(matrixStack, tooltips, mouseX, mouseY, field_230708_k_, field_230709_l_, -1, font); - } - - public void func_238654_b_(MatrixStack p_238654_1_, List p_238654_2_, int p_238654_3_, int p_238654_4_) { -+ this.renderToolTip(p_238654_1_, p_238654_2_, p_238654_3_, p_238654_4_, field_230712_o_); -+ } -+ public void renderToolTip(MatrixStack p_238654_1_, List p_238654_2_, int p_238654_3_, int p_238654_4_, FontRenderer font) { - if (!p_238654_2_.isEmpty()) { - int i = 0; - -@@ -289,9 +_,12 @@ - } - - public void func_231159_b_(String p_231159_1_, boolean p_231159_2_) { -+ p_231159_1_ = net.minecraftforge.event.ForgeEventFactory.onClientSendMessage(p_231159_1_); -+ if (p_231159_1_.isEmpty()) return; - if (p_231159_2_) { - this.field_230706_i_.field_71456_v.func_146158_b().func_146239_a(p_231159_1_); - } -+ //if (net.minecraftforge.client.ClientCommandHandler.instance.executeCommand(mc.player, msg) != 0) return; //Forge: TODO Client command re-write - - this.field_230706_i_.field_71439_g.func_71165_d(p_231159_1_); - } -@@ -302,10 +_,17 @@ - this.field_230712_o_ = p_231158_1_.field_71466_p; - this.field_230708_k_ = p_231158_2_; - this.field_230709_l_ = p_231158_3_; -+ java.util.function.Consumer remove = (b) -> { -+ field_230710_m_.remove(b); -+ field_230705_e_.remove(b); -+ }; -+ if (!net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent.Pre(this, this.field_230710_m_, this::func_230480_a_, remove))) { - this.field_230710_m_.clear(); - this.field_230705_e_.clear(); - this.func_231035_a_((IGuiEventListener)null); - this.func_231160_c_(); -+ } -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent.Post(this, this.field_230710_m_, this::func_230480_a_, remove)); - } - - public List func_231039_at__() { -@@ -328,6 +_,7 @@ - public void func_238651_a_(MatrixStack p_238651_1_, int p_238651_2_) { - if (this.field_230706_i_.field_71441_e != null) { - this.func_238468_a_(p_238651_1_, 0, 0, this.field_230708_k_, this.field_230709_l_, -1072689136, -804253680); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.BackgroundDrawnEvent(this, p_238651_1_)); - } else { - this.func_231165_f_(p_238651_2_); - } -@@ -346,6 +_,7 @@ - bufferbuilder.func_225582_a_((double)this.field_230708_k_, 0.0D, 0.0D).func_225583_a_((float)this.field_230708_k_ / 32.0F, (float)p_231165_1_).func_225586_a_(64, 64, 64, 255).func_181675_d(); - bufferbuilder.func_225582_a_(0.0D, 0.0D, 0.0D).func_225583_a_(0.0F, (float)p_231165_1_).func_225586_a_(64, 64, 64, 255).func_181675_d(); - tessellator.func_78381_a(); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.BackgroundDrawnEvent(this, new MatrixStack())); - } - - public boolean func_231177_au__() { -@@ -431,5 +_,9 @@ - } - - public void func_230476_a_(List p_230476_1_) { -+ } -+ -+ public Minecraft getMinecraft() { -+ return this.field_230706_i_; - } - } diff --git a/patches/minecraft/net/minecraft/client/gui/screen/ServerSelectionList.java.patch b/patches/minecraft/net/minecraft/client/gui/screen/ServerSelectionList.java.patch deleted file mode 100644 index 73e4bc6809..0000000000 --- a/patches/minecraft/net/minecraft/client/gui/screen/ServerSelectionList.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/gui/screen/ServerSelectionList.java -+++ b/net/minecraft/client/gui/screen/ServerSelectionList.java -@@ -307,6 +_,8 @@ - this.field_148303_c.func_238854_b_(list1); - } - -+ net.minecraftforge.fml.client.ClientHooks.drawForgePingInfo(this.field_148303_c, field_148301_e, p_230432_1_, p_230432_4_, p_230432_3_, p_230432_5_, i1, j1); -+ - if (this.field_148300_d.field_71474_y.field_85185_A || p_230432_9_) { - this.field_148300_d.func_110434_K().func_110577_a(ServerSelectionList.field_214360_d); - AbstractGui.func_238467_a_(p_230432_1_, p_230432_4_, p_230432_3_, p_230432_4_ + 32, p_230432_3_ + 32, -1601138544); diff --git a/patches/minecraft/net/minecraft/client/gui/screen/WorldOptionsScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screen/WorldOptionsScreen.java.patch deleted file mode 100644 index 81ad181038..0000000000 --- a/patches/minecraft/net/minecraft/client/gui/screen/WorldOptionsScreen.java.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- a/net/minecraft/client/gui/screen/WorldOptionsScreen.java -+++ b/net/minecraft/client/gui/screen/WorldOptionsScreen.java -@@ -134,6 +_,7 @@ - this.field_239035_i_.field_230693_o_ = this.field_239040_n_.isPresent(); - this.field_239036_j_ = p_239048_1_.func_230480_a_(new Button(j, 120, 150, 20, new TranslationTextComponent("selectWorld.customizeType"), (p_239044_3_) -> { - BiomeGeneratorTypeScreens.IFactory biomegeneratortypescreens$ifactory = BiomeGeneratorTypeScreens.field_239069_d_.get(this.field_239040_n_); -+ biomegeneratortypescreens$ifactory = net.minecraftforge.client.ForgeHooksClient.getBiomeGeneratorTypeScreenFactory(this.field_239040_n_, biomegeneratortypescreens$ifactory); - if (biomegeneratortypescreens$ifactory != null) { - p_239048_2_.func_147108_a(biomegeneratortypescreens$ifactory.createEditScreen(p_239048_1_, this.field_239039_m_)); - } -@@ -292,7 +_,7 @@ - } else { - this.field_239034_h_.field_230694_p_ = p_239059_1_; - this.field_239027_a_.field_230694_p_ = p_239059_1_; -- this.field_239036_j_.field_230694_p_ = p_239059_1_ && BiomeGeneratorTypeScreens.field_239069_d_.containsKey(this.field_239040_n_); -+ this.field_239036_j_.field_230694_p_ = p_239059_1_ && (BiomeGeneratorTypeScreens.field_239069_d_.containsKey(this.field_239040_n_) || net.minecraftforge.client.ForgeHooksClient.hasBiomeGeneratorSettingsOptionsScreen(this.field_239040_n_)); - this.field_239037_k_.field_230694_p_ = p_239059_1_; - } - diff --git a/patches/minecraft/net/minecraft/client/gui/screen/inventory/ContainerScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screen/inventory/ContainerScreen.java.patch deleted file mode 100644 index 82de7a733d..0000000000 --- a/patches/minecraft/net/minecraft/client/gui/screen/inventory/ContainerScreen.java.patch +++ /dev/null @@ -1,173 +0,0 @@ ---- a/net/minecraft/client/gui/screen/inventory/ContainerScreen.java -+++ b/net/minecraft/client/gui/screen/inventory/ContainerScreen.java -@@ -86,6 +_,7 @@ - int i = this.field_147003_i; - int j = this.field_147009_r; - this.func_230450_a_(p_230430_1_, p_230430_4_, p_230430_2_, p_230430_3_); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiContainerEvent.DrawBackground(this, p_230430_1_, p_230430_2_, p_230430_3_)); - RenderSystem.disableRescaleNormal(); - RenderSystem.disableDepthTest(); - super.func_230430_a_(p_230430_1_, p_230430_2_, p_230430_3_, p_230430_4_); -@@ -111,13 +_,15 @@ - int j1 = slot.field_75223_e; - int k1 = slot.field_75221_f; - RenderSystem.colorMask(true, true, true, false); -- this.func_238468_a_(p_230430_1_, j1, k1, j1 + 16, k1 + 16, -2130706433, -2130706433); -+ int slotColor = this.getSlotColor(i1); -+ this.func_238468_a_(p_230430_1_, j1, k1, j1 + 16, k1 + 16, slotColor, slotColor); - RenderSystem.colorMask(true, true, true, true); - RenderSystem.enableDepthTest(); - } - } - - this.func_230451_b_(p_230430_1_, p_230430_2_, p_230430_3_); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiContainerEvent.DrawForeground(this, p_230430_1_, p_230430_2_, p_230430_3_)); - PlayerInventory playerinventory = this.field_230706_i_.field_71439_g.field_71071_by; - ItemStack itemstack = this.field_147012_x.func_190926_b() ? playerinventory.func_70445_o() : this.field_147012_x; - if (!itemstack.func_190926_b()) { -@@ -167,8 +_,10 @@ - RenderSystem.translatef(0.0F, 0.0F, 32.0F); - this.func_230926_e_(200); - this.field_230707_j_.field_77023_b = 200.0F; -+ net.minecraft.client.gui.FontRenderer font = p_146982_1_.func_77973_b().getFontRenderer(p_146982_1_); -+ if (font == null) font = this.field_230712_o_; - this.field_230707_j_.func_180450_b(p_146982_1_, p_146982_2_, p_146982_3_); -- this.field_230707_j_.func_180453_a(this.field_230712_o_, p_146982_1_, p_146982_2_, p_146982_3_ - (this.field_147012_x.func_190926_b() ? 0 : 8), p_146982_4_); -+ this.field_230707_j_.func_180453_a(font, p_146982_1_, p_146982_2_, p_146982_3_ - (this.field_147012_x.func_190926_b() ? 0 : 8), p_146982_4_); - this.func_230926_e_(0); - this.field_230707_j_.field_77023_b = 0.0F; - } -@@ -278,7 +_,8 @@ - if (super.func_231044_a_(p_231044_1_, p_231044_3_, p_231044_5_)) { - return true; - } else { -- boolean flag = this.field_230706_i_.field_71474_y.field_74322_I.func_197984_a(p_231044_5_); -+ InputMappings.Input mouseKey = InputMappings.Type.MOUSE.func_197944_a(p_231044_5_); -+ boolean flag = this.field_230706_i_.field_71474_y.field_74322_I.isActiveAndMatches(mouseKey); - Slot slot = this.func_195360_a(p_231044_1_, p_231044_3_); - long i = Util.func_211177_b(); - this.field_146993_M = this.field_146998_K == slot && i - this.field_146997_J < 250L && this.field_146992_L == p_231044_5_; -@@ -289,6 +_,7 @@ - int j = this.field_147003_i; - int k = this.field_147009_r; - boolean flag1 = this.func_195361_a(p_231044_1_, p_231044_3_, j, k, p_231044_5_); -+ if (slot != null) flag1 = false; // Forge, prevent dropping of items through slots outside of GUI boundaries - int l = -1; - if (slot != null) { - l = slot.field_75222_d; -@@ -314,7 +_,7 @@ - } - } else if (!this.field_147007_t) { - if (this.field_230706_i_.field_71439_g.field_71071_by.func_70445_o().func_190926_b()) { -- if (this.field_230706_i_.field_71474_y.field_74322_I.func_197984_a(p_231044_5_)) { -+ if (this.field_230706_i_.field_71474_y.field_74322_I.isActiveAndMatches(mouseKey)) { - this.func_184098_a(slot, l, p_231044_5_, ClickType.CLONE); - } else { - boolean flag2 = l != -999 && (InputMappings.func_216506_a(Minecraft.func_71410_x().func_228018_at_().func_198092_i(), 340) || InputMappings.func_216506_a(Minecraft.func_71410_x().func_228018_at_().func_198092_i(), 344)); -@@ -338,7 +_,7 @@ - this.field_146987_F = 0; - } else if (p_231044_5_ == 1) { - this.field_146987_F = 1; -- } else if (this.field_230706_i_.field_71474_y.field_74322_I.func_197984_a(p_231044_5_)) { -+ } else if (this.field_230706_i_.field_71474_y.field_74322_I.isActiveAndMatches(mouseKey)) { - this.field_146987_F = 2; - } - } -@@ -407,10 +_,13 @@ - } - - public boolean func_231048_c_(double p_231048_1_, double p_231048_3_, int p_231048_5_) { -+ super.func_231048_c_(p_231048_1_, p_231048_3_, p_231048_5_); //Forge, Call parent to release buttons - Slot slot = this.func_195360_a(p_231048_1_, p_231048_3_); - int i = this.field_147003_i; - int j = this.field_147009_r; - boolean flag = this.func_195361_a(p_231048_1_, p_231048_3_, i, j, p_231048_5_); -+ if (slot != null) flag = false; // Forge, prevent dropping of items through slots outside of GUI boundaries -+ InputMappings.Input mouseKey = InputMappings.Type.MOUSE.func_197944_a(p_231048_5_); - int k = -1; - if (slot != null) { - k = slot.field_75222_d; -@@ -424,7 +_,7 @@ - if (func_231173_s_()) { - if (!this.field_146994_N.func_190926_b()) { - for(Slot slot2 : this.field_147002_h.field_75151_b) { -- if (slot2 != null && slot2.func_82869_a(this.field_230706_i_.field_71439_g) && slot2.func_75216_d() && slot2.field_75224_c == slot.field_75224_c && Container.func_94527_a(slot2, this.field_146994_N, true)) { -+ if (slot2 != null && slot2.func_82869_a(this.field_230706_i_.field_71439_g) && slot2.func_75216_d() && slot2.isSameInventory(slot) && Container.func_94527_a(slot2, this.field_146994_N, true)) { - this.func_184098_a(slot2, slot2.field_75222_d, p_231048_5_, ClickType.QUICK_MOVE); - } - } -@@ -488,7 +_,7 @@ - - this.func_184098_a((Slot)null, -999, Container.func_94534_d(2, this.field_146987_F), ClickType.QUICK_CRAFT); - } else if (!this.field_230706_i_.field_71439_g.field_71071_by.func_70445_o().func_190926_b()) { -- if (this.field_230706_i_.field_71474_y.field_74322_I.func_197984_a(p_231048_5_)) { -+ if (this.field_230706_i_.field_71474_y.field_74322_I.isActiveAndMatches(mouseKey)) { - this.func_184098_a(slot, k, p_231048_5_, ClickType.CLONE); - } else { - boolean flag1 = k != -999 && (InputMappings.func_216506_a(Minecraft.func_71410_x().func_228018_at_().func_198092_i(), 340) || InputMappings.func_216506_a(Minecraft.func_71410_x().func_228018_at_().func_198092_i(), 344)); -@@ -530,34 +_,39 @@ - } - - public boolean func_231046_a_(int p_231046_1_, int p_231046_2_, int p_231046_3_) { -+ InputMappings.Input mouseKey = InputMappings.func_197954_a(p_231046_1_, p_231046_2_); - if (super.func_231046_a_(p_231046_1_, p_231046_2_, p_231046_3_)) { - return true; -- } else if (this.field_230706_i_.field_71474_y.field_151445_Q.func_197976_a(p_231046_1_, p_231046_2_)) { -+ } else if (this.field_230706_i_.field_71474_y.field_151445_Q.isActiveAndMatches(mouseKey)) { - this.func_231175_as__(); - return true; - } else { -- this.func_195363_d(p_231046_1_, p_231046_2_); -+ boolean handled = this.func_195363_d(p_231046_1_, p_231046_2_);// Forge MC-146650: Needs to return true when the key is handled - if (this.field_147006_u != null && this.field_147006_u.func_75216_d()) { -- if (this.field_230706_i_.field_71474_y.field_74322_I.func_197976_a(p_231046_1_, p_231046_2_)) { -+ if (this.field_230706_i_.field_71474_y.field_74322_I.isActiveAndMatches(mouseKey)) { - this.func_184098_a(this.field_147006_u, this.field_147006_u.field_75222_d, 0, ClickType.CLONE); -- } else if (this.field_230706_i_.field_71474_y.field_74316_C.func_197976_a(p_231046_1_, p_231046_2_)) { -+ handled = true; -+ } else if (this.field_230706_i_.field_71474_y.field_74316_C.isActiveAndMatches(mouseKey)) { - this.func_184098_a(this.field_147006_u, this.field_147006_u.field_75222_d, func_231172_r_() ? 1 : 0, ClickType.THROW); -+ handled = true; - } -+ } else if (this.field_230706_i_.field_71474_y.field_74316_C.isActiveAndMatches(mouseKey)) { -+ handled = true; // Forge MC-146650: Emulate MC bug, so we don't drop from hotbar when pressing drop without hovering over a item. - } - -- return true; -+ return handled; - } - } - - protected boolean func_195363_d(int p_195363_1_, int p_195363_2_) { - if (this.field_230706_i_.field_71439_g.field_71071_by.func_70445_o().func_190926_b() && this.field_147006_u != null) { -- if (this.field_230706_i_.field_71474_y.field_186718_X.func_197976_a(p_195363_1_, p_195363_2_)) { -+ if (this.field_230706_i_.field_71474_y.field_186718_X.isActiveAndMatches(InputMappings.func_197954_a(p_195363_1_, p_195363_2_))) { - this.func_184098_a(this.field_147006_u, this.field_147006_u.field_75222_d, 40, ClickType.SWAP); - return true; - } - - for(int i = 0; i < 9; ++i) { -- if (this.field_230706_i_.field_71474_y.field_151456_ac[i].func_197976_a(p_195363_1_, p_195363_2_)) { -+ if (this.field_230706_i_.field_71474_y.field_151456_ac[i].isActiveAndMatches(InputMappings.func_197954_a(p_195363_1_, p_195363_2_))) { - this.func_184098_a(this.field_147006_u, this.field_147006_u.field_75222_d, i, ClickType.SWAP); - return true; - } -@@ -587,6 +_,18 @@ - - public T func_212873_a_() { - return this.field_147002_h; -+ } -+ -+ @javax.annotation.Nullable -+ public Slot getSlotUnderMouse() { return this.field_147006_u; } -+ public int getGuiLeft() { return field_147003_i; } -+ public int getGuiTop() { return field_147009_r; } -+ public int getXSize() { return field_146999_f; } -+ public int getYSize() { return field_147000_g; } -+ -+ protected int slotColor = -2130706433; -+ public int getSlotColor(int index) { -+ return slotColor; - } - - public void func_231175_as__() { diff --git a/patches/minecraft/net/minecraft/client/gui/screen/inventory/CreativeScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screen/inventory/CreativeScreen.java.patch deleted file mode 100644 index 530dd198f0..0000000000 --- a/patches/minecraft/net/minecraft/client/gui/screen/inventory/CreativeScreen.java.patch +++ /dev/null @@ -1,278 +0,0 @@ ---- a/net/minecraft/client/gui/screen/inventory/CreativeScreen.java -+++ b/net/minecraft/client/gui/screen/inventory/CreativeScreen.java -@@ -65,6 +_,8 @@ - private Slot field_147064_C; - private CreativeCraftingListener field_147059_E; - private boolean field_195377_F; -+ private static int tabPage = 0; -+ private int maxPages = 0; - private boolean field_199506_G; - private final Map> field_214085_w = Maps.newTreeMap(); - -@@ -234,6 +_,12 @@ - protected void func_231160_c_() { - if (this.field_230706_i_.field_71442_b.func_78758_h()) { - super.func_231160_c_(); -+ int tabCount = ItemGroup.field_78032_a.length; -+ if (tabCount > 12) { -+ func_230480_a_(new net.minecraft.client.gui.widget.button.Button(field_147003_i, field_147009_r - 50, 20, 20, new StringTextComponent("<"), b -> tabPage = Math.max(tabPage - 1, 0 ))); -+ func_230480_a_(new net.minecraft.client.gui.widget.button.Button(field_147003_i + field_146999_f - 20, field_147009_r - 50, 20, 20, new StringTextComponent(">"), b -> tabPage = Math.min(tabPage + 1, maxPages))); -+ maxPages = (int) Math.ceil((tabCount - 12) / 10D); -+ } - this.field_230706_i_.field_195559_v.func_197967_a(true); - this.field_147062_A = new TextFieldWidget(this.field_230712_o_, this.field_147003_i + 82, this.field_147009_r + 6, 80, 9, new TranslationTextComponent("itemGroup.search")); - this.field_147062_A.func_146203_f(50); -@@ -275,7 +_,7 @@ - public boolean func_231042_a_(char p_231042_1_, int p_231042_2_) { - if (this.field_195377_F) { - return false; -- } else if (field_147058_w != ItemGroup.field_78027_g.func_78021_a()) { -+ } else if (!ItemGroup.field_78032_a[field_147058_w].hasSearchBar()) { - return false; - } else { - String s = this.field_147062_A.func_146179_b(); -@@ -293,7 +_,7 @@ - - public boolean func_231046_a_(int p_231046_1_, int p_231046_2_, int p_231046_3_) { - this.field_195377_F = false; -- if (field_147058_w != ItemGroup.field_78027_g.func_78021_a()) { -+ if (!ItemGroup.field_78032_a[field_147058_w].hasSearchBar()) { - if (this.field_230706_i_.field_71474_y.field_74310_D.func_197976_a(p_231046_1_, p_231046_2_)) { - this.field_195377_F = true; - this.func_147050_b(ItemGroup.field_78027_g); -@@ -330,6 +_,32 @@ - private void func_147053_i() { - (this.field_147002_h).field_148330_a.clear(); - this.field_214085_w.clear(); -+ -+ ItemGroup tab = ItemGroup.field_78032_a[field_147058_w]; -+ if (tab.hasSearchBar() && tab != ItemGroup.field_78027_g) { -+ tab.func_78018_a(field_147002_h.field_148330_a); -+ if (!this.field_147062_A.func_146179_b().isEmpty()) { -+ //TODO: Make this a SearchTree not a manual search -+ String search = this.field_147062_A.func_146179_b().toLowerCase(Locale.ROOT); -+ java.util.Iterator itr = field_147002_h.field_148330_a.iterator(); -+ while (itr.hasNext()) { -+ ItemStack stack = itr.next(); -+ boolean matches = false; -+ for (ITextComponent line : stack.func_82840_a(this.field_230706_i_.field_71439_g, this.field_230706_i_.field_71474_y.field_82882_x ? ITooltipFlag.TooltipFlags.ADVANCED : ITooltipFlag.TooltipFlags.NORMAL)) { -+ if (TextFormatting.func_110646_a(line.getString()).toLowerCase(Locale.ROOT).contains(search)) { -+ matches = true; -+ break; -+ } -+ } -+ if (!matches) -+ itr.remove(); -+ } -+ } -+ this.field_147067_x = 0.0F; -+ field_147002_h.func_148329_a(0.0F); -+ return; -+ } -+ - String s = this.field_147062_A.func_146179_b(); - if (s.isEmpty()) { - for(Item item : Registry.field_212630_s) { -@@ -375,9 +_,9 @@ - - protected void func_230451_b_(MatrixStack p_230451_1_, int p_230451_2_, int p_230451_3_) { - ItemGroup itemgroup = ItemGroup.field_78032_a[field_147058_w]; -- if (itemgroup.func_78019_g()) { -+ if (itemgroup != null && itemgroup.func_78019_g()) { - RenderSystem.disableBlend(); -- this.field_230712_o_.func_243248_b(p_230451_1_, itemgroup.func_242392_c(), 8.0F, 6.0F, 4210752); -+ this.field_230712_o_.func_243248_b(p_230451_1_, itemgroup.func_242392_c(), 8.0F, 6.0F, itemgroup.getLabelColor()); - } - - } -@@ -388,7 +_,7 @@ - double d1 = p_231044_3_ - (double)this.field_147009_r; - - for(ItemGroup itemgroup : ItemGroup.field_78032_a) { -- if (this.func_195375_a(itemgroup, d0, d1)) { -+ if (itemgroup != null && this.func_195375_a(itemgroup, d0, d1)) { - return true; - } - } -@@ -409,7 +_,7 @@ - this.field_147066_y = false; - - for(ItemGroup itemgroup : ItemGroup.field_78032_a) { -- if (this.func_195375_a(itemgroup, d0, d1)) { -+ if (itemgroup != null && this.func_195375_a(itemgroup, d0, d1)) { - this.func_147050_b(itemgroup); - return true; - } -@@ -420,12 +_,15 @@ - } - - private boolean func_147055_p() { -+ if (ItemGroup.field_78032_a[field_147058_w] == null) return false; - return field_147058_w != ItemGroup.field_78036_m.func_78021_a() && ItemGroup.field_78032_a[field_147058_w].func_78017_i() && this.field_147002_h.func_148328_e(); - } - - private void func_147050_b(ItemGroup p_147050_1_) { -+ if (p_147050_1_ == null) return; - int i = field_147058_w; - field_147058_w = p_147050_1_.func_78021_a(); -+ slotColor = p_147050_1_.getSlotColor(); - this.field_147008_s.clear(); - (this.field_147002_h).field_148330_a.clear(); - if (p_147050_1_ == ItemGroup.field_192395_m) { -@@ -502,13 +_,15 @@ - } - - if (this.field_147062_A != null) { -- if (p_147050_1_ == ItemGroup.field_78027_g) { -+ if (p_147050_1_.hasSearchBar()) { - this.field_147062_A.func_146189_e(true); - this.field_147062_A.func_146205_d(false); - this.field_147062_A.func_146195_b(true); - if (i != p_147050_1_.func_78021_a()) { - this.field_147062_A.func_146180_a(""); - } -+ this.field_147062_A.func_230991_b_(p_147050_1_.getSearchbarWidth()); -+ this.field_147062_A.field_230690_l_ = this.field_147003_i + (82 /*default left*/ + 89 /*default width*/) - this.field_147062_A.func_230998_h_(); - - this.func_147053_i(); - } else { -@@ -568,16 +_,35 @@ - this.func_230446_a_(p_230430_1_); - super.func_230430_a_(p_230430_1_, p_230430_2_, p_230430_3_, p_230430_4_); - -- for(ItemGroup itemgroup : ItemGroup.field_78032_a) { -- if (this.func_238809_a_(p_230430_1_, itemgroup, p_230430_2_, p_230430_3_)) { -+ int start = tabPage * 10; -+ int end = Math.min(ItemGroup.field_78032_a.length, ((tabPage + 1) * 10) + 2); -+ if (tabPage != 0) start += 2; -+ boolean rendered = false; -+ -+ for (int x = start; x < end; x++) { -+ ItemGroup itemgroup = ItemGroup.field_78032_a[x]; -+ if (itemgroup != null && this.func_238809_a_(p_230430_1_, itemgroup, p_230430_2_, p_230430_3_)) { -+ rendered = true; - break; - } - } -+ if (!rendered && !this.func_238809_a_(p_230430_1_, ItemGroup.field_78027_g, p_230430_2_, p_230430_3_)) -+ this.func_238809_a_(p_230430_1_, ItemGroup.field_78036_m, p_230430_2_, p_230430_3_); - - if (this.field_147064_C != null && field_147058_w == ItemGroup.field_78036_m.func_78021_a() && this.func_195359_a(this.field_147064_C.field_75223_e, this.field_147064_C.field_75221_f, 16, 16, (double)p_230430_2_, (double)p_230430_3_)) { - this.func_238652_a_(p_230430_1_, field_243345_D, p_230430_2_, p_230430_3_); - } - -+ if (maxPages != 0) { -+ ITextComponent page = new StringTextComponent(String.format("%d / %d", tabPage + 1, maxPages + 1)); -+ RenderSystem.disableLighting(); -+ this.func_230926_e_(300); -+ this.field_230707_j_.field_77023_b = 300.0F; -+ field_230712_o_.func_238407_a_(p_230430_1_, page.func_241878_f(), field_147003_i + (field_146999_f / 2) - (field_230712_o_.func_238414_a_(page) / 2), field_147009_r - 44, -1); -+ this.func_230926_e_(0); -+ this.field_230707_j_.field_77023_b = 0.0F; -+ } -+ - RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); - this.func_230459_a_(p_230430_1_, p_230430_2_, p_230430_3_); - } -@@ -612,7 +_,10 @@ - list1.add(1, itemgroup.func_242392_c().func_230532_e_().func_240699_a_(TextFormatting.BLUE)); - } - -- this.func_243308_b(p_230457_1_, list1, p_230457_3_, p_230457_4_); -+ net.minecraft.client.gui.FontRenderer font = p_230457_2_.func_77973_b().getFontRenderer(p_230457_2_); -+ net.minecraftforge.fml.client.gui.GuiUtils.preItemToolTip(p_230457_2_); -+ this.renderWrappedToolTip(p_230457_1_, list1, p_230457_3_, p_230457_4_, (font == null ? this.field_230712_o_ : font)); -+ net.minecraftforge.fml.client.gui.GuiUtils.postItemToolTip(); - } else { - super.func_230457_a_(p_230457_1_, p_230457_2_, p_230457_3_, p_230457_4_); - } -@@ -623,25 +_,44 @@ - RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); - ItemGroup itemgroup = ItemGroup.field_78032_a[field_147058_w]; - -- for(ItemGroup itemgroup1 : ItemGroup.field_78032_a) { -- this.field_230706_i_.func_110434_K().func_110577_a(field_147061_u); -- if (itemgroup1.func_78021_a() != field_147058_w) { -+ int start = tabPage * 10; -+ int end = Math.min(ItemGroup.field_78032_a.length, ((tabPage + 1) * 10 + 2)); -+ if (tabPage != 0) start += 2; -+ -+ for (int idx = start; idx < end; idx++) { -+ ItemGroup itemgroup1 = ItemGroup.field_78032_a[idx]; -+ if (itemgroup1 != null && itemgroup1.func_78021_a() != field_147058_w) { -+ this.field_230706_i_.func_110434_K().func_110577_a(itemgroup1.getTabsImage()); - this.func_238808_a_(p_230450_1_, itemgroup1); - } - } - -- this.field_230706_i_.func_110434_K().func_110577_a(new ResourceLocation("textures/gui/container/creative_inventory/tab_" + itemgroup.func_78015_f())); -+ if (tabPage != 0) { -+ if (itemgroup != ItemGroup.field_78027_g) { -+ this.field_230706_i_.func_110434_K().func_110577_a(ItemGroup.field_78027_g.getTabsImage()); -+ func_238808_a_(p_230450_1_, ItemGroup.field_78027_g); -+ } -+ if (itemgroup != ItemGroup.field_78036_m) { -+ this.field_230706_i_.func_110434_K().func_110577_a(ItemGroup.field_78036_m.getTabsImage()); -+ func_238808_a_(p_230450_1_, ItemGroup.field_78036_m); -+ } -+ } -+ -+ this.field_230706_i_.func_110434_K().func_110577_a(itemgroup.getBackgroundImage()); - this.func_238474_b_(p_230450_1_, this.field_147003_i, this.field_147009_r, 0, 0, this.field_146999_f, this.field_147000_g); - this.field_147062_A.func_230430_a_(p_230450_1_, p_230450_3_, p_230450_4_, p_230450_2_); - RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); - int i = this.field_147003_i + 175; - int j = this.field_147009_r + 18; - int k = j + 112; -- this.field_230706_i_.func_110434_K().func_110577_a(field_147061_u); -+ this.field_230706_i_.func_110434_K().func_110577_a(itemgroup.getTabsImage()); - if (itemgroup.func_78017_i()) { - this.func_238474_b_(p_230450_1_, i, j + (int)((float)(k - j - 17) * this.field_147067_x), 232 + (this.func_147055_p() ? 0 : 12), 0, 12, 15); - } - -+ if ((itemgroup == null || itemgroup.getTabPage() != tabPage) && (itemgroup != ItemGroup.field_78027_g && itemgroup != ItemGroup.field_78036_m)) -+ return; -+ - this.func_238808_a_(p_230450_1_, itemgroup); - if (itemgroup == ItemGroup.field_78036_m) { - InventoryScreen.func_228187_a_(this.field_147003_i + 88, this.field_147009_r + 45, 20, (float)(this.field_147003_i + 88 - p_230450_3_), (float)(this.field_147009_r + 45 - 30 - p_230450_4_), this.field_230706_i_.field_71439_g); -@@ -650,6 +_,7 @@ - } - - protected boolean func_195375_a(ItemGroup p_195375_1_, double p_195375_2_, double p_195375_4_) { -+ if (p_195375_1_.getTabPage() != tabPage && p_195375_1_ != ItemGroup.field_78027_g && p_195375_1_ != ItemGroup.field_78036_m) return false; - int i = p_195375_1_.func_78020_k(); - int j = 28 * i; - int k = 0; -@@ -718,6 +_,8 @@ - i1 = i1 + (this.field_147000_g - 4); - } - -+ RenderSystem.color3f(1F, 1F, 1F); //Forge: Reset color in case Items change it. -+ RenderSystem.enableBlend(); //Forge: Make sure blend is enabled else tabs show a white border. - this.func_238474_b_(p_238808_1_, l, i1, j, k, 28, 32); - this.field_230707_j_.field_77023_b = 100.0F; - l = l + 6; -@@ -883,6 +_,22 @@ - - public boolean func_82869_a(PlayerEntity p_82869_1_) { - return this.field_148332_b.func_82869_a(p_82869_1_); -+ } -+ -+ @Override -+ public int getSlotIndex() { -+ return this.field_148332_b.getSlotIndex(); -+ } -+ -+ @Override -+ public boolean isSameInventory(Slot other) { -+ return this.field_148332_b.isSameInventory(other); -+ } -+ -+ @Override -+ public Slot setBackground(ResourceLocation atlas, ResourceLocation sprite) { -+ this.field_148332_b.setBackground(atlas, sprite); -+ return this; - } - } - diff --git a/patches/minecraft/net/minecraft/client/gui/screens/DeathScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/DeathScreen.java.patch new file mode 100644 index 0000000000..438b09e4d2 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/screens/DeathScreen.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/client/gui/screens/DeathScreen.java ++++ b/net/minecraft/client/gui/screens/DeathScreen.java +@@ -37,6 +_,7 @@ + }))); + this.f_169295_.add(this.m_142416_(new Button(this.f_96543_ / 2 - 100, this.f_96544_ / 4 + 96, 200, 20, new TranslatableComponent("deathScreen.titleScreen"), (p_95925_) -> { + if (this.f_95908_) { ++ m_95931_(true); + this.m_95934_(); + } else { + ConfirmScreen confirmscreen = new ConfirmScreen(this::m_95931_, new TranslatableComponent("deathScreen.quit.confirm"), TextComponent.f_131282_, new TranslatableComponent("deathScreen.titleScreen"), new TranslatableComponent("deathScreen.respawn")); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/LanguageSelectScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/LanguageSelectScreen.java.patch new file mode 100644 index 0000000000..fe2b465559 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/screens/LanguageSelectScreen.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/client/gui/screens/LanguageSelectScreen.java ++++ b/net/minecraft/client/gui/screens/LanguageSelectScreen.java +@@ -36,7 +_,7 @@ + if (languageselectscreen$languageselectionlist$entry != null && !languageselectscreen$languageselectionlist$entry.f_96116_.getCode().equals(this.f_96080_.m_118983_().getCode())) { + this.f_96080_.m_118974_(languageselectscreen$languageselectionlist$entry.f_96116_); + this.f_96282_.f_92075_ = languageselectscreen$languageselectionlist$entry.f_96116_.getCode(); +- this.f_96541_.m_91391_(); ++ net.minecraftforge.client.ForgeHooksClient.refreshResources(this.f_96541_, net.minecraftforge.resource.VanillaResourceType.LANGUAGES); + this.f_96282_.m_92169_(); + } + diff --git a/patches/minecraft/net/minecraft/client/gui/screens/LoadingOverlay.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/LoadingOverlay.java.patch new file mode 100644 index 0000000000..78f7ad90d0 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/screens/LoadingOverlay.java.patch @@ -0,0 +1,26 @@ +--- a/net/minecraft/client/gui/screens/LoadingOverlay.java ++++ b/net/minecraft/client/gui/screens/LoadingOverlay.java +@@ -119,6 +_,7 @@ + int k1 = (int)((double)this.f_96163_.m_91268_().m_85446_() * 0.8325D); + float f6 = this.f_96164_.m_7750_(); + this.f_96167_ = Mth.m_14036_(this.f_96167_ * 0.95F + f6 * 0.050000012F, 0.0F, 1.0F); ++ net.minecraftforge.fmlclient.ClientModLoader.renderProgressText(); + if (f < 1.0F) { + this.m_96182_(p_96178_, i / 2 - j1, k1 - 5, i / 2 + j1, k1 + 5, 1.0F - Mth.m_14036_(f, 0.0F, 1.0F)); + } +@@ -128,6 +_,7 @@ + } + + if (this.f_96168_ == -1L && this.f_96164_.m_7746_() && (!this.f_96166_ || f1 >= 2.0F)) { ++ this.f_96168_ = Util.m_137550_(); // Moved up to guard against inf loops caused by callback + try { + this.f_96164_.m_7748_(); + this.f_96165_.accept(Optional.empty()); +@@ -135,7 +_,6 @@ + this.f_96165_.accept(Optional.of(throwable)); + } + +- this.f_96168_ = Util.m_137550_(); + if (this.f_96163_.f_91080_ != null) { + this.f_96163_.f_91080_.m_6575_(this.f_96163_, this.f_96163_.m_91268_().m_85445_(), this.f_96163_.m_91268_().m_85446_()); + } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/MenuScreens.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/MenuScreens.java.patch new file mode 100644 index 0000000000..beff574d78 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/screens/MenuScreens.java.patch @@ -0,0 +1,25 @@ +--- a/net/minecraft/client/gui/screens/MenuScreens.java ++++ b/net/minecraft/client/gui/screens/MenuScreens.java +@@ -40,6 +_,10 @@ + private static final Map, MenuScreens.ScreenConstructor> f_96196_ = Maps.newHashMap(); + + public static void m_96201_(@Nullable MenuType p_96202_, Minecraft p_96203_, int p_96204_, Component p_96205_) { ++ getScreenFactory(p_96202_, p_96203_, p_96204_, p_96205_).ifPresent(f -> f.m_96209_(p_96205_, p_96202_, p_96203_, p_96204_)); ++ } ++ ++ public static java.util.Optional> getScreenFactory(@Nullable MenuType p_96202_, Minecraft p_96203_, int p_96204_, Component p_96205_) { + if (p_96202_ == null) { + f_96195_.warn("Trying to open invalid screen with name: {}", (Object)p_96205_.getString()); + } else { +@@ -47,9 +_,10 @@ + if (screenconstructor == null) { + f_96195_.warn("Failed to create screen for menu type: {}", (Object)Registry.f_122863_.m_7981_(p_96202_)); + } else { +- screenconstructor.m_96209_(p_96205_, p_96202_, p_96203_, p_96204_); ++ return java.util.Optional.of(screenconstructor); + } + } ++ return java.util.Optional.empty(); + } + + @Nullable diff --git a/patches/minecraft/net/minecraft/client/gui/screens/OptionsScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/OptionsScreen.java.patch new file mode 100644 index 0000000000..c008c74cbe --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/screens/OptionsScreen.java.patch @@ -0,0 +1,15 @@ +--- a/net/minecraft/client/gui/screens/OptionsScreen.java ++++ b/net/minecraft/client/gui/screens/OptionsScreen.java +@@ -134,4 +_,12 @@ + m_93215_(p_96249_, this.f_96547_, this.f_96539_, this.f_96543_ / 2, 15, 16777215); + super.m_6305_(p_96249_, p_96250_, p_96251_, p_96252_); + } ++ ++ @Override ++ public void m_7379_() { ++ // We need to consider 2 potential parent screens here: ++ // 1. From the main menu, in which case display the main menu ++ // 2. From the pause menu, in which case exit back to game ++ this.f_96541_.m_91152_(this.f_96235_ instanceof PauseScreen ? null : this.f_96235_); ++ } + } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/Screen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/Screen.java.patch new file mode 100644 index 0000000000..9cebb9f5bf --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/screens/Screen.java.patch @@ -0,0 +1,142 @@ +--- a/net/minecraft/client/gui/screens/Screen.java ++++ b/net/minecraft/client/gui/screens/Screen.java +@@ -163,7 +_,10 @@ + } + + protected void m_6057_(PoseStack p_96566_, ItemStack p_96567_, int p_96568_, int p_96569_) { +- this.m_169388_(p_96566_, this.m_96555_(p_96567_), p_96567_.m_150921_(), p_96568_, p_96569_); ++ Font font = net.minecraftforge.client.RenderProperties.get(p_96567_).getFont(p_96567_); ++ net.minecraftforge.fmlclient.gui.GuiUtils.preItemToolTip(p_96567_); ++ this.renderComponentToolTip(p_96566_, this.m_96555_(p_96567_), p_96568_, p_96569_, (font == null ? this.f_96547_ : font)); ++ net.minecraftforge.fmlclient.gui.GuiUtils.postItemToolTip(); + } + + public void m_169388_(PoseStack p_169389_, List p_169390_, Optional p_169391_, int p_169392_, int p_169393_) { +@@ -171,7 +_,7 @@ + p_169391_.ifPresent((p_169399_) -> { + list.add(1, ClientTooltipComponent.m_169950_(p_169399_)); + }); +- this.m_169383_(p_169389_, list, p_169392_, p_169393_); ++ this.renderTooltipInternal(p_169389_, list, p_169392_, p_169393_, f_96547_); + } + + public List m_96555_(ItemStack p_96556_) { +@@ -179,24 +_,30 @@ + } + + public void m_96602_(PoseStack p_96603_, Component p_96604_, int p_96605_, int p_96606_) { +- this.m_96617_(p_96603_, Arrays.asList(p_96604_.m_7532_()), p_96605_, p_96606_); ++ this.m_96597_(p_96603_, Arrays.asList(p_96604_), p_96605_, p_96606_); + } + + public void m_96597_(PoseStack p_96598_, List p_96599_, int p_96600_, int p_96601_) { +- this.m_96617_(p_96598_, Lists.transform(p_96599_, Component::m_7532_), p_96600_, p_96601_); ++ this.renderComponentToolTip(p_96598_, p_96599_, p_96600_, p_96601_, f_96547_); ++ } ++ public void renderComponentToolTip(PoseStack matrixStack, List tooltips, int mouseX, int mouseY, Font font) { ++ net.minecraftforge.fmlclient.gui.GuiUtils.drawHoveringText(matrixStack, tooltips, mouseX, mouseY, f_96543_, f_96544_, -1, font); + } + + public void m_96617_(PoseStack p_96618_, List p_96619_, int p_96620_, int p_96621_) { +- this.m_169383_(p_96618_, p_96619_.stream().map(ClientTooltipComponent::m_169948_).collect(Collectors.toList()), p_96620_, p_96621_); ++ this.renderToolTip(p_96618_, p_96619_, p_96620_, p_96621_, f_96547_); ++ } ++ public void renderToolTip(PoseStack p_96618_, List p_96619_, int p_96620_, int p_96621_, Font font) { ++ this.renderTooltipInternal(p_96618_, p_96619_.stream().map(ClientTooltipComponent::m_169948_).collect(Collectors.toList()), p_96620_, p_96621_, font); + } + +- private void m_169383_(PoseStack p_169384_, List p_169385_, int p_169386_, int p_169387_) { ++ private void renderTooltipInternal(PoseStack p_169384_, List p_169385_, int p_169386_, int p_169387_, Font font) { + if (!p_169385_.isEmpty()) { + int i = 0; + int j = p_169385_.size() == 1 ? -2 : 0; + + for(ClientTooltipComponent clienttooltipcomponent : p_169385_) { +- int k = clienttooltipcomponent.m_142069_(this.f_96547_); ++ int k = clienttooltipcomponent.m_142069_(font); + if (k > i) { + i = k; + } +@@ -249,7 +_,7 @@ + + for(int i2 = 0; i2 < p_169385_.size(); ++i2) { + ClientTooltipComponent clienttooltipcomponent1 = p_169385_.get(i2); +- clienttooltipcomponent1.m_142440_(this.f_96547_, j2, l1, matrix4f, multibuffersource$buffersource); ++ clienttooltipcomponent1.m_142440_(font, j2, l1, matrix4f, multibuffersource$buffersource); + l1 += clienttooltipcomponent1.m_142103_() + (i2 == 0 ? 2 : 0); + } + +@@ -259,7 +_,7 @@ + + for(int l2 = 0; l2 < p_169385_.size(); ++l2) { + ClientTooltipComponent clienttooltipcomponent2 = p_169385_.get(l2); +- clienttooltipcomponent2.m_142162_(this.f_96547_, j2, l1, p_169384_, this.f_96542_, 400, this.f_96541_.m_91097_()); ++ clienttooltipcomponent2.m_142162_(font, j2, l1, p_169384_, this.f_96542_, 400, this.f_96541_.m_91097_()); + l1 += clienttooltipcomponent2.m_142103_() + (l2 == 0 ? 2 : 0); + } + +@@ -353,9 +_,12 @@ + } + + public void m_96612_(String p_96613_, boolean p_96614_) { ++ p_96613_ = net.minecraftforge.event.ForgeEventFactory.onClientSendMessage(p_96613_); ++ if (p_96613_.isEmpty()) return; + if (p_96614_) { + this.f_96541_.f_91065_.m_93076_().m_93783_(p_96613_); + } ++ //if (net.minecraftforge.client.ClientCommandHandler.instance.executeCommand(mc.player, msg) != 0) return; //Forge: TODO Client command re-write + + this.f_96541_.f_91074_.m_108739_(p_96613_); + } +@@ -366,11 +_,24 @@ + this.f_96547_ = p_96607_.f_91062_; + this.f_96543_ = p_96608_; + this.f_96544_ = p_96609_; ++ java.util.function.Consumer add = (b) -> { ++ if (b instanceof Widget) { ++ this.f_169369_.add((Widget)b); ++ } ++ ++ if (b instanceof NarratableEntry) { ++ this.f_169368_.add((NarratableEntry)b); ++ } ++ f_96540_.remove(b); ++ }; ++ if (!net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent.Pre(this, this.f_96540_, add, this::m_169411_))) { + this.m_169413_(); + this.m_7522_((GuiEventListener)null); + this.m_7856_(); + this.m_169407_(false); + this.m_169378_(f_169370_); ++ } ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent.Post(this, this.f_96540_, add, this::m_169411_)); + } + + public List m_6702_() { +@@ -393,6 +_,7 @@ + public void m_96558_(PoseStack p_96559_, int p_96560_) { + if (this.f_96541_.f_91073_ != null) { + this.m_93179_(p_96559_, 0, 0, this.f_96543_, this.f_96544_, -1072689136, -804253680); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.BackgroundDrawnEvent(this, p_96559_)); + } else { + this.m_96626_(p_96560_); + } +@@ -412,6 +_,7 @@ + bufferbuilder.m_5483_((double)this.f_96543_, 0.0D, 0.0D).m_7421_((float)this.f_96543_ / 32.0F, (float)p_96627_).m_6122_(64, 64, 64, 255).m_5752_(); + bufferbuilder.m_5483_(0.0D, 0.0D, 0.0D).m_7421_(0.0F, (float)p_96627_).m_6122_(64, 64, 64, 255).m_5752_(); + tesselator.m_85914_(); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.BackgroundDrawnEvent(this, new PoseStack())); + } + + public boolean m_7043_() { +@@ -497,6 +_,10 @@ + } + + public void m_7400_(List p_96591_) { ++ } ++ ++ public Minecraft getMinecraft() { ++ return this.f_96541_; + } + + private void m_169380_(long p_169381_, boolean p_169382_) { diff --git a/patches/minecraft/net/minecraft/client/gui/screens/TitleScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/TitleScreen.java.patch new file mode 100644 index 0000000000..5892a818f7 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/screens/TitleScreen.java.patch @@ -0,0 +1,68 @@ +--- a/net/minecraft/client/gui/screens/TitleScreen.java ++++ b/net/minecraft/client/gui/screens/TitleScreen.java +@@ -63,6 +_,7 @@ + private final PanoramaRenderer f_96729_ = new PanoramaRenderer(f_96716_); + private final boolean f_96714_; + private long f_96715_; ++ private net.minecraftforge.client.gui.NotificationModUpdateScreen modUpdateNotification; + + public TitleScreen() { + this(false); +@@ -106,11 +_,16 @@ + this.f_96728_ = this.f_96543_ - this.f_96727_ - 2; + int i = 24; + int j = this.f_96544_ / 4 + 48; ++ Button modButton = null; + if (this.f_96541_.m_91402_()) { + this.m_96772_(j, 24); + } else { + this.m_96763_(j, 24); ++ modButton = this.m_142416_(new Button(this.f_96543_ / 2 - 100, j + 24 * 2, 98, 20, new TranslatableComponent("fml.menu.mods"), button -> { ++ this.f_96541_.m_91152_(new net.minecraftforge.fmlclient.gui.screen.ModListScreen(this)); ++ })); + } ++ modUpdateNotification = net.minecraftforge.client.gui.NotificationModUpdateScreen.init(this, modButton); + + this.m_142416_(new ImageButton(this.f_96543_ / 2 - 124, j + 72 + 12, 20, 20, 0, 106, 20, Button.f_93617_, 256, 256, (p_96791_) -> { + this.f_96541_.m_91152_(new LanguageSelectScreen(this, this.f_96541_.f_91066_, this.f_96541_.m_91102_())); +@@ -158,7 +_,7 @@ + Screen screen = (Screen)(this.f_96541_.f_91066_.f_92083_ ? new JoinMultiplayerScreen(this) : new SafetyScreen(this)); + this.f_96541_.m_91152_(screen); + }, button$ontooltip))).f_93623_ = flag; +- (this.m_142416_(new Button(this.f_96543_ / 2 - 100, p_96764_ + p_96765_ * 2, 200, 20, new TranslatableComponent("menu.online"), (p_96776_) -> { ++ (this.m_142416_(new Button(this.f_96543_ / 2 + 2, p_96764_ + p_96765_ * 2, 98, 20, new TranslatableComponent("menu.online"), (p_96771_) -> { + this.m_96793_(); + }, button$ontooltip))).f_93623_ = flag; + } +@@ -283,6 +_,7 @@ + + RenderSystem.m_157456_(0, f_96724_); + m_93133_(p_96739_, j + 88, 67, 0.0F, 0.0F, 98, 14, 128, 16); ++ net.minecraftforge.client.ForgeHooksClient.renderMainMenu(this, p_96739_, this.f_96547_, this.f_96543_, this.f_96544_, l); + if (this.f_96721_ != null) { + p_96739_.m_85836_(); + p_96739_.m_85837_((double)(this.f_96543_ / 2 + 90), 70.0D, 0.0D); +@@ -305,7 +_,14 @@ + s = s + I18n.m_118938_("menu.modded"); + } + +- m_93236_(p_96739_, this.f_96547_, s, 2, this.f_96544_ - 10, 16777215 | l); ++ net.minecraftforge.fmllegacy.BrandingControl.forEachLine(true, true, (brdline, brd) -> ++ m_93236_(p_96739_, this.f_96547_, brd, 2, this.f_96544_ - ( 10 + brdline * (this.f_96547_.f_92710_ + 1)), 16777215 | l) ++ ); ++ ++ net.minecraftforge.fmllegacy.BrandingControl.forEachAboveCopyrightLine((brdline, brd) -> ++ m_93236_(p_96739_, this.f_96547_, brd, this.f_96543_ - f_96547_.m_92895_(brd), this.f_96544_ - (10 + (brdline + 1) * ( this.f_96547_.f_92710_ + 1)), 16777215 | l) ++ ); ++ + m_93236_(p_96739_, this.f_96547_, "Copyright Mojang AB. Do not distribute!", this.f_96728_, this.f_96544_ - 10, 16777215 | l); + if (p_96740_ > this.f_96728_ && p_96740_ < this.f_96728_ + this.f_96727_ && p_96741_ > this.f_96544_ - 10 && p_96741_ < this.f_96544_) { + m_93172_(p_96739_, this.f_96728_, this.f_96544_ - 1, this.f_96728_ + this.f_96727_, this.f_96544_, 16777215 | l); +@@ -321,6 +_,7 @@ + if (this.m_96789_() && f1 >= 1.0F) { + this.f_96726_.m_6305_(p_96739_, p_96740_, p_96741_, p_96742_); + } ++ modUpdateNotification.m_6305_(p_96739_, p_96740_, p_96741_, p_96742_); + + } + } 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 new file mode 100644 index 0000000000..c00f842b5d --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementTab.java.patch @@ -0,0 +1,37 @@ +--- a/net/minecraft/client/gui/screens/advancements/AdvancementTab.java ++++ b/net/minecraft/client/gui/screens/advancements/AdvancementTab.java +@@ -39,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_) { + this.f_97126_ = p_97145_; +@@ -53,6 +_,15 @@ + this.m_97175_(this.f_97134_, p_97149_); + } + ++ public AdvancementTab(Minecraft mc, AdvancementsScreen screen, AdvancementTabType type, int index, int page, Advancement adv, DisplayInfo info) { ++ this(mc, screen, type, index, adv, info); ++ this.page = page; ++ } ++ ++ public int getPage() { ++ return page; ++ } ++ + public AdvancementTabType m_169538_() { + return this.f_97128_; + } +@@ -165,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_()); ++ 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_()); + } + + 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 new file mode 100644 index 0000000000..950427740f --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementTabType.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/client/gui/screens/advancements/AdvancementTabType.java ++++ b/net/minecraft/client/gui/screens/advancements/AdvancementTabType.java +@@ -14,6 +_,7 @@ + LEFT(0, 64, 32, 28, 5), + RIGHT(96, 64, 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 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 new file mode 100644 index 0000000000..7f758839e7 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java.patch @@ -0,0 +1,70 @@ +--- a/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java ++++ b/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java +@@ -42,6 +_,7 @@ + private final Map f_97335_ = Maps.newLinkedHashMap(); + private AdvancementTab f_97336_; + private boolean f_97337_; ++ private static int tabPage, maxPages; + + public AdvancementsScreen(ClientAdvancements p_97340_) { + super(NarratorChatListener.f_93310_); +@@ -57,7 +_,13 @@ + } else { + this.f_97334_.m_104401_(this.f_97336_ == null ? null : this.f_97336_.m_97182_(), true); + } +- ++ if (this.f_97335_.size() > AdvancementTabType.MAX_TABS) { ++ int guiLeft = (this.f_96543_ - 252) / 2; ++ int guiTop = (this.f_96544_ - 140) / 2; ++ m_142416_(new net.minecraft.client.gui.components.Button(guiLeft, guiTop - 50, 20, 20, new net.minecraft.network.chat.TextComponent("<"), b -> tabPage = Math.max(tabPage - 1, 0 ))); ++ m_142416_(new net.minecraft.client.gui.components.Button(guiLeft + 252 - 20, guiTop - 50, 20, 20, new net.minecraft.network.chat.TextComponent(">"), b -> tabPage = Math.min(tabPage + 1, maxPages))); ++ maxPages = this.f_97335_.size() / AdvancementTabType.MAX_TABS; ++ } + } + + public void m_7861_() { +@@ -75,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); + break; + } +@@ -99,6 +_,11 @@ + int i = (this.f_96543_ - 252) / 2; + int j = (this.f_96544_ - 140) / 2; + this.m_7333_(p_97361_); ++ if (maxPages != 0) { ++ net.minecraft.network.chat.Component page = new net.minecraft.network.chat.TextComponent(String.format("%d / %d", tabPage + 1, maxPages + 1)); ++ int width = this.f_96547_.m_92852_(page); ++ this.f_96547_.m_92744_(p_97361_, page.m_7532_(), i + (252 / 2) - (width / 2), j - 44, -1); ++ } + this.m_97373_(p_97361_, p_97362_, p_97363_, i, j); + this.m_97356_(p_97361_, i, j); + this.m_97381_(p_97361_, p_97362_, p_97363_, i, j); +@@ -149,12 +_,14 @@ + RenderSystem.m_157456_(0, f_97330_); + + for(AdvancementTab advancementtab : this.f_97335_.values()) { ++ if (advancementtab.getPage() == tabPage) + advancementtab.m_97165_(p_97357_, p_97358_, p_97359_, advancementtab == this.f_97336_); + } + + RenderSystem.m_69453_(); + + for(AdvancementTab advancementtab1 : this.f_97335_.values()) { ++ if (advancementtab1.getPage() == tabPage) + advancementtab1.m_97159_(p_97358_, p_97359_, this.f_96542_); + } + +@@ -180,7 +_,7 @@ + + if (this.f_97335_.size() > 1) { + for(AdvancementTab advancementtab : this.f_97335_.values()) { +- if (advancementtab.m_97154_(p_97385_, p_97386_, (double)p_97383_, (double)p_97384_)) { ++ if (advancementtab.getPage() == tabPage && advancementtab.m_97154_(p_97385_, p_97386_, (double)p_97383_, (double)p_97384_)) { + this.m_96602_(p_97382_, advancementtab.m_97189_(), p_97383_, p_97384_); + } + } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/controls/ControlList.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/controls/ControlList.java.patch new file mode 100644 index 0000000000..332c783fef --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/screens/controls/ControlList.java.patch @@ -0,0 +1,60 @@ +--- a/net/minecraft/client/gui/screens/controls/ControlList.java ++++ b/net/minecraft/client/gui/screens/controls/ControlList.java +@@ -53,7 +_,7 @@ + } + + protected int m_5756_() { +- return super.m_5756_() + 15; ++ return super.m_5756_() + 15 + 20; + } + + public int m_5759_() { +@@ -109,7 +_,7 @@ + KeyEntry(final KeyMapping p_97451_, final Component p_97452_) { + this.f_97445_ = p_97451_; + this.f_97446_ = p_97452_; +- this.f_97447_ = new Button(0, 0, 75, 20, p_97452_, (p_97479_) -> { ++ this.f_97447_ = new Button(0, 0, 75 + 20 /*Forge: add space*/, 20, p_97452_, (p_97479_) -> { + ControlList.this.f_97396_.f_97514_ = p_97451_; + }) { + protected MutableComponent m_5646_() { +@@ -117,6 +_,7 @@ + } + }; + this.f_97448_ = new Button(0, 0, 50, 20, new TranslatableComponent("controls.reset"), (p_97475_) -> { ++ f_97445_.setToDefault(); + ControlList.this.f_93386_.f_91066_.m_92159_(p_97451_, p_97451_.m_90861_()); + KeyMapping.m_90854_(); + }) { +@@ -130,7 +_,7 @@ + boolean flag = ControlList.this.f_97396_.f_97514_ == this.f_97445_; + float f = (float)(p_97466_ + 90 - ControlList.this.f_97397_); + ControlList.this.f_93386_.f_91062_.m_92889_(p_97463_, this.f_97446_, f, (float)(p_97465_ + p_97468_ / 2 - 9 / 2), 16777215); +- this.f_97448_.f_93620_ = p_97466_ + 190; ++ this.f_97448_.f_93620_ = p_97466_ + 190 + 20; + this.f_97448_.f_93621_ = p_97465_; + this.f_97448_.f_93623_ = !this.f_97445_.m_90864_(); + this.f_97448_.m_6305_(p_97463_, p_97469_, p_97470_, p_97472_); +@@ -138,11 +_,12 @@ + this.f_97447_.f_93621_ = p_97465_; + this.f_97447_.m_93666_(this.f_97445_.m_90863_()); + boolean flag1 = false; ++ boolean keyCodeModifierConflict = true; // less severe form of conflict, like SHIFT conflicting with SHIFT+G + if (!this.f_97445_.m_90862_()) { + for(KeyMapping keymapping : ControlList.this.f_93386_.f_91066_.f_92059_) { + if (keymapping != this.f_97445_ && this.f_97445_.m_90850_(keymapping)) { + flag1 = true; +- break; ++ keyCodeModifierConflict &= keymapping.hasKeyCodeModifierConflict(keymapping); + } + } + } +@@ -150,7 +_,7 @@ + if (flag) { + this.f_97447_.m_93666_((new TextComponent("> ")).m_7220_(this.f_97447_.m_6035_().m_6881_().m_130940_(ChatFormatting.YELLOW)).m_130946_(" <").m_130940_(ChatFormatting.YELLOW)); + } else if (flag1) { +- this.f_97447_.m_93666_(this.f_97447_.m_6035_().m_6881_().m_130940_(ChatFormatting.RED)); ++ this.f_97447_.m_93666_(this.f_97447_.m_6035_().m_6881_().m_130940_(keyCodeModifierConflict ? ChatFormatting.GOLD : ChatFormatting.RED)); + } + + this.f_97447_.m_6305_(p_97463_, p_97469_, p_97470_, p_97472_); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/controls/ControlsScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/controls/ControlsScreen.java.patch new file mode 100644 index 0000000000..4382ad76f9 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/screens/controls/ControlsScreen.java.patch @@ -0,0 +1,26 @@ +--- a/net/minecraft/client/gui/screens/controls/ControlsScreen.java ++++ b/net/minecraft/client/gui/screens/controls/ControlsScreen.java +@@ -35,7 +_,7 @@ + this.m_7787_(this.f_97516_); + this.f_97517_ = this.m_142416_(new Button(this.f_96543_ / 2 - 155, this.f_96544_ - 29, 150, 20, new TranslatableComponent("controls.resetAll"), (p_97538_) -> { + for(KeyMapping keymapping : this.f_96282_.f_92059_) { +- keymapping.m_90848_(keymapping.m_90861_()); ++ keymapping.setToDefault(); + } + + KeyMapping.m_90854_(); +@@ -59,11 +_,14 @@ + public boolean m_7933_(int p_97526_, int p_97527_, int p_97528_) { + if (this.f_97514_ != null) { + if (p_97526_ == 256) { ++ this.f_97514_.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.getActiveModifier(), InputConstants.f_84822_); + this.f_96282_.m_92159_(this.f_97514_, InputConstants.f_84822_); + } else { ++ this.f_97514_.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.getActiveModifier(), InputConstants.m_84827_(p_97526_, p_97527_)); + this.f_96282_.m_92159_(this.f_97514_, InputConstants.m_84827_(p_97526_, p_97527_)); + } + ++ if (!net.minecraftforge.client.settings.KeyModifier.isKeyCodeModifier(this.f_97514_.getKey())) + this.f_97514_ = null; + this.f_97515_ = Util.m_137550_(); + KeyMapping.m_90854_(); 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 new file mode 100644 index 0000000000..9937ba9840 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java.patch @@ -0,0 +1,185 @@ +--- a/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java ++++ b/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java +@@ -91,6 +_,7 @@ + int i = this.f_97735_; + int j = this.f_97736_; + this.m_7286_(p_97795_, p_97798_, p_97796_, p_97797_); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiContainerEvent.DrawBackground(this, p_97795_, p_97796_, p_97797_)); + RenderSystem.m_69465_(); + super.m_6305_(p_97795_, p_97796_, p_97797_, p_97798_); + PoseStack posestack = RenderSystem.m_157191_(); +@@ -112,11 +_,12 @@ + this.f_97734_ = slot; + int l = slot.f_40220_; + int i1 = slot.f_40221_; +- m_169606_(p_97795_, l, i1, this.m_93252_()); ++ renderSlotHighlight(p_97795_, l, i1, this.m_93252_(), this.getSlotColor(i1)); + } + } + + this.m_7027_(p_97795_, p_97796_, p_97797_); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiContainerEvent.DrawForeground(this, p_97795_, p_97796_, p_97797_)); + ItemStack itemstack = this.f_97711_.m_41619_() ? this.f_97732_.m_142621_() : this.f_97711_; + if (!itemstack.m_41619_()) { + int l1 = 8; +@@ -156,9 +_,13 @@ + } + + public static void m_169606_(PoseStack p_169607_, int p_169608_, int p_169609_, int p_169610_) { ++ renderSlotHighlight(p_169607_, p_169608_, p_169609_, p_169610_, -2130706433); ++ } ++ ++ public static void renderSlotHighlight(PoseStack p_169607_, int p_169608_, int p_169609_, int p_169610_, int slotColor) { + RenderSystem.m_69465_(); + RenderSystem.m_69444_(true, true, true, false); +- m_168740_(p_169607_, p_169608_, p_169609_, p_169608_ + 16, p_169609_ + 16, -2130706433, -2130706433, p_169610_); ++ m_168740_(p_169607_, p_169608_, p_169609_, p_169608_ + 16, p_169609_ + 16, slotColor, slotColor, p_169610_); + RenderSystem.m_69444_(true, true, true, true); + RenderSystem.m_69482_(); + } +@@ -176,8 +_,10 @@ + RenderSystem.m_157182_(); + this.m_93250_(200); + this.f_96542_.f_115093_ = 200.0F; ++ net.minecraft.client.gui.Font font = net.minecraftforge.client.RenderProperties.get(p_97783_).getFont(p_97783_); ++ if (font == null) font = this.f_96547_; + this.f_96542_.m_115203_(p_97783_, p_97784_, p_97785_); +- this.f_96542_.m_115174_(this.f_96547_, p_97783_, p_97784_, p_97785_ - (this.f_97711_.m_41619_() ? 0 : 8), p_97786_); ++ this.f_96542_.m_115174_(font, p_97783_, p_97784_, p_97785_ - (this.f_97711_.m_41619_() ? 0 : 8), p_97786_); + this.m_93250_(0); + this.f_96542_.f_115093_ = 0.0F; + } +@@ -287,7 +_,8 @@ + if (super.m_6375_(p_97748_, p_97749_, p_97750_)) { + return true; + } else { +- boolean flag = this.f_96541_.f_91066_.f_92097_.m_90830_(p_97750_); ++ InputConstants.Key mouseKey = InputConstants.Type.MOUSE.m_84895_(p_97750_); ++ boolean flag = this.f_96541_.f_91066_.f_92097_.isActiveAndMatches(mouseKey); + 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_; +@@ -298,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_); ++ if (slot != null) flag1 = false; // Forge, prevent dropping of items through slots outside of GUI boundaries + int l = -1; + if (slot != null) { + l = slot.f_40219_; +@@ -323,7 +_,7 @@ + } + } else if (!this.f_97738_) { + if (this.f_97732_.m_142621_().m_41619_()) { +- if (this.f_96541_.f_91066_.f_92097_.m_90830_(p_97750_)) { ++ if (this.f_96541_.f_91066_.f_92097_.isActiveAndMatches(mouseKey)) { + 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)); +@@ -347,7 +_,7 @@ + this.f_97717_ = 0; + } else if (p_97750_ == 1) { + this.f_97717_ = 1; +- } else if (this.f_96541_.f_91066_.f_92097_.m_90830_(p_97750_)) { ++ } else if (this.f_96541_.f_91066_.f_92097_.isActiveAndMatches(mouseKey)) { + this.f_97717_ = 2; + } + } +@@ -416,10 +_,13 @@ + } + + public boolean m_6348_(double p_97812_, double p_97813_, int p_97814_) { ++ super.m_6348_(p_97812_, p_97813_, p_97814_); //Forge, Call parent to release buttons + Slot slot = this.m_97744_(p_97812_, p_97813_); + int i = this.f_97735_; + int j = this.f_97736_; + boolean flag = this.m_7467_(p_97812_, p_97813_, i, j, p_97814_); ++ if (slot != null) flag = false; // Forge, prevent dropping of items through slots outside of GUI boundaries ++ InputConstants.Key mouseKey = InputConstants.Type.MOUSE.m_84895_(p_97814_); + int k = -1; + if (slot != null) { + k = slot.f_40219_; +@@ -433,7 +_,7 @@ + if (m_96638_()) { + if (!this.f_97724_.m_41619_()) { + for(Slot slot2 : this.f_97732_.f_38839_) { +- if (slot2 != null && slot2.m_8010_(this.f_96541_.f_91074_) && slot2.m_6657_() && slot2.f_40218_ == slot.f_40218_ && AbstractContainerMenu.m_38899_(slot2, this.f_97724_, true)) { ++ if (slot2 != null && slot2.m_8010_(this.f_96541_.f_91074_) && slot2.m_6657_() && slot2.isSameInventory(slot) && AbstractContainerMenu.m_38899_(slot2, this.f_97724_, true)) { + this.m_6597_(slot2, slot2.f_40219_, p_97814_, ClickType.QUICK_MOVE); + } + } +@@ -497,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_()) { +- if (this.f_96541_.f_91066_.f_92097_.m_90830_(p_97814_)) { ++ if (this.f_96541_.f_91066_.f_92097_.isActiveAndMatches(mouseKey)) { + 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)); +@@ -539,34 +_,39 @@ + } + + public boolean m_7933_(int p_97765_, int p_97766_, int p_97767_) { ++ InputConstants.Key mouseKey = InputConstants.m_84827_(p_97765_, p_97766_); + if (super.m_7933_(p_97765_, p_97766_, p_97767_)) { + return true; +- } else if (this.f_96541_.f_91066_.f_92092_.m_90832_(p_97765_, p_97766_)) { ++ } else if (this.f_96541_.f_91066_.f_92092_.isActiveAndMatches(mouseKey)) { + this.m_7379_(); + return true; + } else { +- this.m_97805_(p_97765_, p_97766_); ++ boolean handled = this.m_97805_(p_97765_, p_97766_);// Forge MC-146650: Needs to return true when the key is handled + if (this.f_97734_ != null && this.f_97734_.m_6657_()) { +- if (this.f_96541_.f_91066_.f_92097_.m_90832_(p_97765_, p_97766_)) { ++ if (this.f_96541_.f_91066_.f_92097_.isActiveAndMatches(mouseKey)) { + this.m_6597_(this.f_97734_, this.f_97734_.f_40219_, 0, ClickType.CLONE); +- } else if (this.f_96541_.f_91066_.f_92094_.m_90832_(p_97765_, p_97766_)) { ++ handled = true; ++ } else if (this.f_96541_.f_91066_.f_92094_.isActiveAndMatches(mouseKey)) { + this.m_6597_(this.f_97734_, this.f_97734_.f_40219_, m_96637_() ? 1 : 0, ClickType.THROW); ++ handled = true; + } ++ } else if (this.f_96541_.f_91066_.f_92094_.isActiveAndMatches(mouseKey)) { ++ handled = true; // Forge MC-146650: Emulate MC bug, so we don't drop from hotbar when pressing drop without hovering over a item. + } + +- return true; ++ return handled; + } + } + + protected boolean m_97805_(int p_97806_, int p_97807_) { + if (this.f_97732_.m_142621_().m_41619_() && this.f_97734_ != null) { +- if (this.f_96541_.f_91066_.f_92093_.m_90832_(p_97806_, p_97807_)) { ++ if (this.f_96541_.f_91066_.f_92093_.isActiveAndMatches(InputConstants.m_84827_(p_97806_, p_97807_))) { + this.m_6597_(this.f_97734_, this.f_97734_.f_40219_, 40, ClickType.SWAP); + return true; + } + + for(int i = 0; i < 9; ++i) { +- if (this.f_96541_.f_91066_.f_92056_[i].m_90832_(p_97806_, p_97807_)) { ++ if (this.f_96541_.f_91066_.f_92056_[i].isActiveAndMatches(InputConstants.m_84827_(p_97806_, p_97807_))) { + this.m_6597_(this.f_97734_, this.f_97734_.f_40219_, i, ClickType.SWAP); + return true; + } +@@ -601,6 +_,18 @@ + + public T m_6262_() { + return this.f_97732_; ++ } ++ ++ @javax.annotation.Nullable ++ public Slot getSlotUnderMouse() { return this.f_97734_; } ++ public int getGuiLeft() { return f_97735_; } ++ public int getGuiTop() { return f_97736_; } ++ public int getXSize() { return f_97726_; } ++ public int getYSize() { return f_97727_; } ++ ++ protected int slotColor = -2130706433; ++ public int getSlotColor(int index) { ++ return slotColor; + } + + public void m_7379_() { 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 new file mode 100644 index 0000000000..342057ee45 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java.patch @@ -0,0 +1,279 @@ +--- a/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java ++++ b/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java +@@ -74,6 +_,8 @@ + private Slot f_98512_; + private CreativeInventoryListener f_98513_; + private boolean f_98514_; ++ private static int tabPage = 0; ++ private int maxPages = 0; + private boolean f_98515_; + private final Map> f_98516_ = Maps.newTreeMap(); + +@@ -242,6 +_,12 @@ + protected void m_7856_() { + if (this.f_96541_.f_91072_.m_105290_()) { + super.m_7856_(); ++ int tabCount = CreativeModeTab.f_40748_.length; ++ if (tabCount > 12) { ++ m_142416_(new net.minecraft.client.gui.components.Button(f_97735_, f_97736_ - 50, 20, 20, new TextComponent("<"), b -> tabPage = Math.max(tabPage - 1, 0 ))); ++ m_142416_(new net.minecraft.client.gui.components.Button(f_97735_ + f_97726_ - 20, f_97736_ - 50, 20, 20, new TextComponent(">"), b -> tabPage = Math.min(tabPage + 1, maxPages))); ++ maxPages = (int) Math.ceil((tabCount - 12) / 10D); ++ } + this.f_96541_.f_91068_.m_90926_(true); + this.f_98510_ = new EditBox(this.f_96547_, this.f_97735_ + 82, this.f_97736_ + 6, 80, 9, new TranslatableComponent("itemGroup.search")); + this.f_98510_.m_94199_(50); +@@ -283,7 +_,7 @@ + public boolean m_5534_(char p_98521_, int p_98522_) { + if (this.f_98514_) { + return false; +- } else if (f_98507_ != CreativeModeTab.f_40754_.m_40775_()) { ++ } else if (!CreativeModeTab.f_40748_[f_98507_].hasSearchBar()) { + return false; + } else { + String s = this.f_98510_.m_94155_(); +@@ -301,7 +_,7 @@ + + public boolean m_7933_(int p_98547_, int p_98548_, int p_98549_) { + this.f_98514_ = false; +- if (f_98507_ != CreativeModeTab.f_40754_.m_40775_()) { ++ if (!CreativeModeTab.f_40748_[f_98507_].hasSearchBar()) { + if (this.f_96541_.f_91066_.f_92098_.m_90832_(p_98547_, p_98548_)) { + this.f_98514_ = true; + this.m_98560_(CreativeModeTab.f_40754_); +@@ -338,6 +_,32 @@ + private void m_98630_() { + (this.f_97732_).f_98639_.clear(); + this.f_98516_.clear(); ++ ++ CreativeModeTab tab = CreativeModeTab.f_40748_[f_98507_]; ++ if (tab.hasSearchBar() && tab != CreativeModeTab.f_40754_) { ++ tab.m_6151_(f_97732_.f_98639_); ++ if (!this.f_98510_.m_94155_().isEmpty()) { ++ //TODO: Make this a SearchTree not a manual search ++ String search = this.f_98510_.m_94155_().toLowerCase(Locale.ROOT); ++ java.util.Iterator itr = f_97732_.f_98639_.iterator(); ++ while (itr.hasNext()) { ++ ItemStack stack = itr.next(); ++ boolean matches = false; ++ for (Component line : stack.m_41651_(this.f_96541_.f_91074_, this.f_96541_.f_91066_.f_92125_ ? TooltipFlag.Default.ADVANCED : TooltipFlag.Default.NORMAL)) { ++ if (ChatFormatting.m_126649_(line.getString()).toLowerCase(Locale.ROOT).contains(search)) { ++ matches = true; ++ break; ++ } ++ } ++ if (!matches) ++ itr.remove(); ++ } ++ } ++ this.f_98508_ = 0.0F; ++ f_97732_.m_98642_(0.0F); ++ return; ++ } ++ + String s = this.f_98510_.m_94155_(); + if (s.isEmpty()) { + for(Item item : Registry.f_122827_) { +@@ -383,9 +_,9 @@ + + protected void m_7027_(PoseStack p_98616_, int p_98617_, int p_98618_) { + CreativeModeTab creativemodetab = CreativeModeTab.f_40748_[f_98507_]; +- if (creativemodetab.m_40789_()) { ++ if (creativemodetab != null && creativemodetab.m_40789_()) { + RenderSystem.m_69461_(); +- this.f_96547_.m_92889_(p_98616_, creativemodetab.m_40786_(), 8.0F, 6.0F, 4210752); ++ this.f_96547_.m_92889_(p_98616_, creativemodetab.m_40786_(), 8.0F, 6.0F, creativemodetab.getLabelColor()); + } + + } +@@ -396,7 +_,7 @@ + double d1 = p_98532_ - (double)this.f_97736_; + + for(CreativeModeTab creativemodetab : CreativeModeTab.f_40748_) { +- if (this.m_98562_(creativemodetab, d0, d1)) { ++ if (creativemodetab != null && this.m_98562_(creativemodetab, d0, d1)) { + return true; + } + } +@@ -417,7 +_,7 @@ + this.f_98509_ = false; + + for(CreativeModeTab creativemodetab : CreativeModeTab.f_40748_) { +- if (this.m_98562_(creativemodetab, d0, d1)) { ++ if (creativemodetab != null && this.m_98562_(creativemodetab, d0, d1)) { + this.m_98560_(creativemodetab); + return true; + } +@@ -428,12 +_,15 @@ + } + + private boolean m_98631_() { ++ if (CreativeModeTab.f_40748_[f_98507_] == null) return false; + return f_98507_ != CreativeModeTab.f_40761_.m_40775_() && CreativeModeTab.f_40748_[f_98507_].m_40791_() && this.f_97732_.m_98654_(); + } + + private void m_98560_(CreativeModeTab p_98561_) { ++ if (p_98561_ == null) return; + int i = f_98507_; + f_98507_ = p_98561_.m_40775_(); ++ slotColor = p_98561_.getSlotColor(); + this.f_97737_.clear(); + (this.f_97732_).f_98639_.clear(); + if (p_98561_ == CreativeModeTab.f_40760_) { +@@ -510,13 +_,15 @@ + } + + if (this.f_98510_ != null) { +- if (p_98561_ == CreativeModeTab.f_40754_) { ++ if (p_98561_.hasSearchBar()) { + this.f_98510_.m_94194_(true); + this.f_98510_.m_94190_(false); + this.f_98510_.m_94178_(true); + if (i != p_98561_.m_40775_()) { + this.f_98510_.m_94144_(""); + } ++ this.f_98510_.m_93674_(p_98561_.getSearchbarWidth()); ++ this.f_98510_.f_93620_ = this.f_97735_ + (82 /*default left*/ + 89 /*default width*/) - this.f_98510_.m_5711_(); + + this.m_98630_(); + } else { +@@ -576,16 +_,34 @@ + this.m_7333_(p_98577_); + super.m_6305_(p_98577_, p_98578_, p_98579_, p_98580_); + +- for(CreativeModeTab creativemodetab : CreativeModeTab.f_40748_) { +- if (this.m_98584_(p_98577_, creativemodetab, p_98578_, p_98579_)) { ++ int start = tabPage * 10; ++ int end = Math.min(CreativeModeTab.f_40748_.length, ((tabPage + 1) * 10) + 2); ++ if (tabPage != 0) start += 2; ++ boolean rendered = false; ++ ++ for (int x = start; x < end; x++) { ++ CreativeModeTab creativemodetab = CreativeModeTab.f_40748_[x]; ++ if (creativemodetab != null && this.m_98584_(p_98577_, creativemodetab, p_98578_, p_98579_)) { ++ rendered = true; + break; + } + } ++ if (!rendered && !this.m_98584_(p_98577_, CreativeModeTab.f_40754_, p_98578_, p_98579_)) ++ this.m_98584_(p_98577_, CreativeModeTab.f_40761_, p_98578_, p_98579_); + + if (this.f_98512_ != null && f_98507_ == CreativeModeTab.f_40761_.m_40775_() && this.m_6774_(this.f_98512_.f_40220_, this.f_98512_.f_40221_, 16, 16, (double)p_98578_, (double)p_98579_)) { + this.m_96602_(p_98577_, f_98506_, p_98578_, p_98579_); + } + ++ if (maxPages != 0) { ++ Component page = new TextComponent(String.format("%d / %d", tabPage + 1, maxPages + 1)); ++ this.m_93250_(300); ++ this.f_96542_.f_115093_ = 300.0F; ++ f_96547_.m_92744_(p_98577_, page.m_7532_(), f_97735_ + (f_97726_ / 2) - (f_96547_.m_92852_(page) / 2), f_97736_ - 44, -1); ++ this.m_93250_(0); ++ this.f_96542_.f_115093_ = 0.0F; ++ } ++ + RenderSystem.m_157429_(1.0F, 1.0F, 1.0F, 1.0F); + this.m_7025_(p_98577_, p_98578_, p_98579_); + } +@@ -620,7 +_,10 @@ + list1.add(1, creativemodetab.m_40786_().m_6881_().m_130940_(ChatFormatting.BLUE)); + } + +- this.m_169388_(p_98590_, list1, p_98591_.m_150921_(), p_98592_, p_98593_); ++ net.minecraft.client.gui.Font font = net.minecraftforge.client.RenderProperties.get(p_98591_).getFont(p_98591_); ++ net.minecraftforge.fmlclient.gui.GuiUtils.preItemToolTip(p_98591_); ++ this.renderComponentToolTip(p_98590_, list1, p_98592_, p_98593_, (font == null ? this.f_96547_ : font)); ++ net.minecraftforge.fmlclient.gui.GuiUtils.postItemToolTip(); + } else { + super.m_6057_(p_98590_, p_98591_, p_98592_, p_98593_); + } +@@ -631,16 +_,32 @@ + RenderSystem.m_157429_(1.0F, 1.0F, 1.0F, 1.0F); + CreativeModeTab creativemodetab = CreativeModeTab.f_40748_[f_98507_]; + +- for(CreativeModeTab creativemodetab1 : CreativeModeTab.f_40748_) { ++ int start = tabPage * 10; ++ int end = Math.min(CreativeModeTab.f_40748_.length, ((tabPage + 1) * 10 + 2)); ++ if (tabPage != 0) start += 2; ++ ++ for (int idx = start; idx < end; idx++) { + RenderSystem.m_157427_(GameRenderer::m_172817_); +- RenderSystem.m_157456_(0, f_98504_); +- if (creativemodetab1.m_40775_() != f_98507_) { ++ CreativeModeTab creativemodetab1 = CreativeModeTab.f_40748_[idx]; ++ if (creativemodetab1 != null && creativemodetab1.m_40775_() != f_98507_) { ++ RenderSystem.m_157456_(0, creativemodetab1.getTabsImage()); + this.m_98581_(p_98572_, creativemodetab1); + } + } + + RenderSystem.m_157427_(GameRenderer::m_172817_); +- RenderSystem.m_157456_(0, new ResourceLocation("textures/gui/container/creative_inventory/tab_" + creativemodetab.m_40788_())); ++ if (tabPage != 0) { ++ if (creativemodetab != CreativeModeTab.f_40754_) { ++ RenderSystem.m_157456_(0, CreativeModeTab.f_40754_.getTabsImage()); ++ m_98581_(p_98572_, CreativeModeTab.f_40754_); ++ } ++ if (creativemodetab != CreativeModeTab.f_40761_) { ++ RenderSystem.m_157456_(0, CreativeModeTab.f_40761_.getTabsImage()); ++ m_98581_(p_98572_, CreativeModeTab.f_40761_); ++ } ++ } ++ ++ RenderSystem.m_157456_(0, creativemodetab.getBackgroundImage()); + this.m_93228_(p_98572_, this.f_97735_, this.f_97736_, 0, 0, this.f_97726_, this.f_97727_); + this.f_98510_.m_6305_(p_98572_, p_98574_, p_98575_, p_98573_); + RenderSystem.m_157429_(1.0F, 1.0F, 1.0F, 1.0F); +@@ -648,11 +_,14 @@ + int j = this.f_97736_ + 18; + int k = j + 112; + RenderSystem.m_157427_(GameRenderer::m_172817_); +- RenderSystem.m_157456_(0, f_98504_); ++ RenderSystem.m_157456_(0, creativemodetab.getTabsImage()); + if (creativemodetab.m_40791_()) { + this.m_93228_(p_98572_, i, j + (int)((float)(k - j - 17) * this.f_98508_), 232 + (this.m_98631_() ? 0 : 12), 0, 12, 15); + } + ++ if ((creativemodetab == null || creativemodetab.getTabPage() != tabPage) && (creativemodetab != CreativeModeTab.f_40754_ && creativemodetab != CreativeModeTab.f_40761_)) ++ return; ++ + this.m_98581_(p_98572_, creativemodetab); + if (creativemodetab == CreativeModeTab.f_40761_) { + InventoryScreen.m_98850_(this.f_97735_ + 88, this.f_97736_ + 45, 20, (float)(this.f_97735_ + 88 - p_98574_), (float)(this.f_97736_ + 45 - 30 - p_98575_), this.f_96541_.f_91074_); +@@ -661,6 +_,7 @@ + } + + protected boolean m_98562_(CreativeModeTab p_98563_, double p_98564_, double p_98565_) { ++ if (p_98563_.getTabPage() != tabPage && p_98563_ != CreativeModeTab.f_40754_ && p_98563_ != CreativeModeTab.f_40761_) return false; + int i = p_98563_.m_40793_(); + int j = 28 * i; + int k = 0; +@@ -729,6 +_,7 @@ + i1 = i1 + (this.f_97727_ - 4); + } + ++ RenderSystem.m_69478_(); //Forge: Make sure blend is enabled else tabs show a white border. + this.m_93228_(p_98582_, l, i1, j, k, 28, 32); + this.f_96542_.f_115093_ = 100.0F; + l = l + 6; +@@ -918,6 +_,22 @@ + + public boolean m_8010_(Player p_98665_) { + return this.f_98655_.m_8010_(p_98665_); ++ } ++ ++ @Override ++ public int getSlotIndex() { ++ return this.f_98655_.getSlotIndex(); ++ } ++ ++ @Override ++ public boolean isSameInventory(Slot other) { ++ return this.f_98655_.isSameInventory(other); ++ } ++ ++ @Override ++ public Slot setBackground(ResourceLocation atlas, ResourceLocation sprite) { ++ this.f_98655_.setBackground(atlas, sprite); ++ return this; + } + } + } 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 new file mode 100644 index 0000000000..3462fc3c3b --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/screens/inventory/EffectRenderingInventoryScreen.java.patch @@ -0,0 +1,34 @@ +--- a/net/minecraft/client/gui/screens/inventory/EffectRenderingInventoryScreen.java ++++ b/net/minecraft/client/gui/screens/inventory/EffectRenderingInventoryScreen.java +@@ -34,6 +_,9 @@ + this.f_97735_ = (this.f_96543_ - this.f_97726_) / 2; + this.f_98699_ = false; + } else { ++ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.PotionShiftEvent(this))) ++ this.f_97735_ = (this.f_96543_ - this.f_97726_) / 2; ++ else + this.f_97735_ = 160 + (this.f_96543_ - this.f_97726_ - 200) / 2; + this.f_98699_ = true; + } +@@ -58,7 +_,7 @@ + j = 132 / (collection.size() - 1); + } + +- Iterable iterable = Ordering.natural().sortedCopy(collection); ++ Iterable iterable = collection.stream().filter(net.minecraftforge.client.ForgeHooksClient::shouldRender).sorted().collect(java.util.stream.Collectors.toList()); + this.m_98709_(p_98716_, i, j, iterable); + this.m_98717_(p_98716_, i, j, iterable); + this.m_98722_(p_98716_, i, j, iterable); +@@ -95,6 +_,12 @@ + int i = this.f_97736_; + + for(MobEffectInstance mobeffectinstance : p_98726_) { ++ net.minecraftforge.client.EffectRenderer renderer = net.minecraftforge.client.RenderProperties.getEffectRenderer(mobeffectinstance); ++ renderer.renderInventoryEffect(mobeffectinstance, this, p_98723_, p_98724_, i, this.m_93252_()); ++ if (!renderer.shouldRenderInvText(mobeffectinstance)) { ++ i += p_98725_; ++ continue; ++ } + String s = I18n.m_118938_(mobeffectinstance.m_19544_().m_19481_()); + if (mobeffectinstance.m_19564_() >= 1 && mobeffectinstance.m_19564_() <= 9) { + s = s + " " + I18n.m_118938_("enchantment.level." + (mobeffectinstance.m_19564_() + 1)); 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 new file mode 100644 index 0000000000..a88da97caa --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java.patch @@ -0,0 +1,28 @@ +--- a/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java ++++ b/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java +@@ -151,7 +_,7 @@ + int i2 = 86 - this.f_96547_.m_92895_(s); + FormattedText formattedtext = EnchantmentNames.m_98734_().m_98737_(this.f_96547_, i2); + int j2 = 6839882; +- if ((l < i1 + 1 || this.f_96541_.f_91074_.f_36078_ < l1) && !this.f_96541_.f_91074_.m_150110_().f_35937_) { ++ if (((l < i1 + 1 || this.f_96541_.f_91074_.f_36078_ < l1) && !this.f_96541_.f_91074_.m_150110_().f_35937_) || this.f_97732_.f_39447_[i1] == -1) { // Forge: render buttons as disabled when enchantable but enchantability not met on lower levels + this.m_93228_(p_98762_, j1, j + 14 + 19 * i1, 0, 185, 108, 19); + this.m_93228_(p_98762_, j1 + 1, j + 15 + 19 * i1, 16 * i1, 239, 16, 16); + this.f_96547_.m_92857_(formattedtext, k1, j + 16 + 19 * i1, i2, (j2 & 16711422) >> 1); +@@ -190,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; +- if (this.m_6774_(60, 14 + 19 * j, 108, 17, (double)p_98768_, (double)p_98769_) && k > 0 && l >= 0 && enchantment != null) { ++ if (this.m_6774_(60, 14 + 19 * j, 108, 17, (double)p_98768_, (double)p_98769_) && k > 0) { + List list = Lists.newArrayList(); +- list.add((new TranslatableComponent("container.enchant.clue", enchantment.m_44700_(l))).m_130940_(ChatFormatting.WHITE)); +- if (!flag) { ++ list.add((new TranslatableComponent("container.enchant.clue", enchantment == null ? "" : enchantment.m_44700_(l))).m_130940_(ChatFormatting.WHITE)); ++ if (enchantment == null) { ++ list.add(new TextComponent("")); ++ list.add(new TranslatableComponent("forge.container.enchant.limitedEnchantability").m_130940_(ChatFormatting.RED)); ++ } else if (!flag) { + list.add(TextComponent.f_131282_); + if (this.f_96541_.f_91074_.f_36078_ < k) { + list.add((new TranslatableComponent("container.enchant.level.requirement", (this.f_97732_).f_39446_[j])).m_130940_(ChatFormatting.RED)); 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 new file mode 100644 index 0000000000..815db0c752 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/screens/multiplayer/JoinMultiplayerScreen.java.patch @@ -0,0 +1,14 @@ +--- a/net/minecraft/client/gui/screens/multiplayer/JoinMultiplayerScreen.java ++++ b/net/minecraft/client/gui/screens/multiplayer/JoinMultiplayerScreen.java +@@ -247,6 +_,11 @@ + + } + ++ @Override ++ public void m_7379_() { ++ this.f_96541_.m_91152_(this.f_99676_); ++ } ++ + public ServerStatusPinger m_99731_() { + return this.f_99675_; + } 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 new file mode 100644 index 0000000000..088affe534 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/screens/multiplayer/ServerSelectionList.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/client/gui/screens/multiplayer/ServerSelectionList.java ++++ b/net/minecraft/client/gui/screens/multiplayer/ServerSelectionList.java +@@ -333,6 +_,8 @@ + this.f_99855_.m_99707_(list1); + } + ++ net.minecraftforge.fmlclient.ClientHooks.drawForgePingInfo(this.f_99855_, f_99857_, p_99879_, p_99882_, p_99881_, p_99883_, i1, j1); ++ + if (this.f_99856_.f_91066_.f_92051_ || p_99887_) { + RenderSystem.m_157456_(0, ServerSelectionList.f_99759_); + GuiComponent.m_93172_(p_99879_, p_99882_, p_99881_, p_99882_ + 32, p_99881_ + 32, -1601138544); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/packs/PackSelectionModel.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/packs/PackSelectionModel.java.patch new file mode 100644 index 0000000000..13567ec115 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/screens/packs/PackSelectionModel.java.patch @@ -0,0 +1,23 @@ +--- a/net/minecraft/client/gui/screens/packs/PackSelectionModel.java ++++ b/net/minecraft/client/gui/screens/packs/PackSelectionModel.java +@@ -102,6 +_,8 @@ + boolean m_7802_(); + + boolean m_7803_(); ++ ++ default boolean notHidden() { return true; } + } + + @OnlyIn(Dist.CLIENT) +@@ -176,6 +_,11 @@ + + public void m_7845_() { + this.m_99938_(1); ++ } ++ ++ @Override ++ public boolean notHidden() { ++ return !f_99933_.isHidden(); + } + } + 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 new file mode 100644 index 0000000000..6afde4d114 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/screens/packs/PackSelectionScreen.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/client/gui/screens/packs/PackSelectionScreen.java ++++ b/net/minecraft/client/gui/screens/packs/PackSelectionScreen.java +@@ -139,7 +_,7 @@ + + private void m_100013_(TransferableSelectionList p_100014_, Stream p_100015_) { + p_100014_.m_6702_().clear(); +- p_100015_.forEach((p_170000_) -> { ++ p_100015_.filter(PackSelectionModel.Entry::notHidden).forEach((p_170000_) -> { + p_100014_.m_6702_().add(new TransferableSelectionList.PackEntry(this.f_96541_, p_100014_, this, p_170000_)); + }); + } 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 new file mode 100644 index 0000000000..d6844c4d28 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/screens/recipebook/RecipeBookComponent.java.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/client/gui/screens/recipebook/RecipeBookComponent.java ++++ b/net/minecraft/client/gui/screens/recipebook/RecipeBookComponent.java +@@ -107,7 +_,7 @@ + this.m_5674_(); + this.f_100279_.clear(); + +- for(RecipeBookCategories recipebookcategories : RecipeBookCategories.m_92269_(this.f_100271_.m_5867_())) { ++ for(RecipeBookCategories recipebookcategories : this.f_100271_.getRecipeBookCategories()) { + this.f_100279_.add(new RecipeBookTabButton(recipebookcategories)); + } + +@@ -462,7 +_,7 @@ + + languagemanager.m_118974_(languageinfo); + this.f_100272_.f_91066_.f_92075_ = languageinfo.getCode(); +- this.f_100272_.m_91391_(); ++ net.minecraftforge.client.ForgeHooksClient.refreshResources(this.f_100272_, net.minecraftforge.resource.VanillaResourceType.LANGUAGES); + this.f_100272_.f_91066_.m_92169_(); + } + 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 new file mode 100644 index 0000000000..69d2845f2a --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java.patch @@ -0,0 +1,19 @@ +--- a/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java ++++ b/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java +@@ -117,7 +_,7 @@ + + public static CreateWorldScreen m_100898_(@Nullable Screen p_100899_) { + RegistryAccess.RegistryHolder registryaccess$registryholder = RegistryAccess.m_123086_(); +- return new CreateWorldScreen(p_100899_, DataPackConfig.f_45842_, new WorldGenSettingsComponent(registryaccess$registryholder, WorldGenSettings.m_64641_(registryaccess$registryholder.m_175515_(Registry.f_122818_), registryaccess$registryholder.m_175515_(Registry.f_122885_), registryaccess$registryholder.m_175515_(Registry.f_122878_)), Optional.of(WorldPreset.f_101506_), OptionalLong.empty())); ++ return new CreateWorldScreen(p_100899_, DataPackConfig.f_45842_, new WorldGenSettingsComponent(registryaccess$registryholder, net.minecraftforge.client.ForgeHooksClient.getDefaultWorldType().map(type -> type.m_7012_(registryaccess$registryholder, new java.util.Random().nextLong(), true, false)).orElseGet(() -> WorldGenSettings.m_64641_(registryaccess$registryholder.m_175512_(Registry.f_122818_), registryaccess$registryholder.m_175512_(Registry.f_122885_), registryaccess$registryholder.m_175512_(Registry.f_122878_))), net.minecraftforge.client.ForgeHooksClient.getDefaultWorldType(), OptionalLong.empty())); + } + + private CreateWorldScreen(@Nullable Screen p_100861_, DataPackConfig p_100862_, WorldGenSettingsComponent p_100863_) { +@@ -596,6 +_,7 @@ + File file1 = path.toFile(); + if (this.f_100832_ == null) { + this.f_100832_ = new PackRepository(PackType.SERVER_DATA, new ServerPacksSource(), new FolderRepositorySource(file1, PackSource.f_10527_)); ++ net.minecraftforge.fmllegacy.packs.ResourcePackLoader.loadResourcePacks(this.f_100832_, net.minecraftforge.fmllegacy.server.ServerLifecycleHooks::buildPackFinder); + this.f_100832_.m_10506_(); + } + diff --git a/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldGenSettingsComponent.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldGenSettingsComponent.java.patch new file mode 100644 index 0000000000..c32470f858 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldGenSettingsComponent.java.patch @@ -0,0 +1,19 @@ +--- a/net/minecraft/client/gui/screens/worldselection/WorldGenSettingsComponent.java ++++ b/net/minecraft/client/gui/screens/worldselection/WorldGenSettingsComponent.java +@@ -113,6 +_,7 @@ + this.f_170244_.f_93624_ = false; + this.f_101391_ = p_101430_.m_142416_(new Button(j, 120, 150, 20, new TranslatableComponent("selectWorld.customizeType"), (p_170248_) -> { + WorldPreset.PresetEditor worldpreset$preseteditor = WorldPreset.f_101509_.get(this.f_101395_); ++ worldpreset$preseteditor = net.minecraftforge.client.ForgeHooksClient.getBiomeGeneratorTypeScreenFactory(this.f_101395_, worldpreset$preseteditor); + if (worldpreset$preseteditor != null) { + p_101431_.m_91152_(worldpreset$preseteditor.m_101642_(p_101430_, this.f_101394_)); + } +@@ -283,7 +_,7 @@ + } else { + this.f_101389_.f_93624_ = p_170288_; + this.f_101380_.f_93624_ = p_170288_; +- this.f_101391_.f_93624_ = p_170288_ && WorldPreset.f_101509_.containsKey(this.f_101395_); ++ this.f_101391_.f_93624_ = p_170288_ && (WorldPreset.f_101509_.containsKey(this.f_101395_) || net.minecraftforge.client.ForgeHooksClient.hasBiomeGeneratorSettingsOptionsScreen(this.f_101395_)); + this.f_101392_.f_93624_ = p_170288_; + } + diff --git a/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldPreset.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldPreset.java.patch new file mode 100644 index 0000000000..994ea79a86 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldPreset.java.patch @@ -0,0 +1,21 @@ +--- a/net/minecraft/client/gui/screens/worldselection/WorldPreset.java ++++ b/net/minecraft/client/gui/screens/worldselection/WorldPreset.java +@@ -116,6 +_,9 @@ + WorldPreset(String p_101519_) { + this.f_101516_ = new TranslatableComponent("generator." + p_101519_); + } ++ public WorldPreset(Component displayName) { ++ this.f_101516_ = displayName; ++ } + + private static WorldGenSettings m_101549_(RegistryAccess p_101550_, WorldGenSettings p_101551_, WorldPreset p_101552_, Biome p_101553_) { + BiomeSource biomesource = new FixedBiomeSource(p_101553_); +@@ -173,4 +_,8 @@ + public interface PresetEditor { + Screen m_101642_(CreateWorldScreen p_101643_, WorldGenSettings p_101644_); + } ++ ++ // Forge start ++ // For internal use only, automatically called for all ForgeWorldTypes. Register your ForgeWorldType in the forge registry! ++ public static void registerGenerator(WorldPreset gen) { f_101508_.add(gen); } + } diff --git a/patches/minecraft/net/minecraft/client/gui/widget/Widget.java.patch b/patches/minecraft/net/minecraft/client/gui/widget/Widget.java.patch deleted file mode 100644 index a2b29fd509..0000000000 --- a/patches/minecraft/net/minecraft/client/gui/widget/Widget.java.patch +++ /dev/null @@ -1,41 +0,0 @@ ---- a/net/minecraft/client/gui/widget/Widget.java -+++ b/net/minecraft/client/gui/widget/Widget.java -@@ -111,7 +_,7 @@ - this.func_238474_b_(p_230431_1_, this.field_230690_l_, this.field_230691_m_, 0, 46 + i * 20, this.field_230688_j_ / 2, this.field_230689_k_); - this.func_238474_b_(p_230431_1_, this.field_230690_l_ + this.field_230688_j_ / 2, this.field_230691_m_, 200 - this.field_230688_j_ / 2, 46 + i * 20, this.field_230688_j_ / 2, this.field_230689_k_); - this.func_230441_a_(p_230431_1_, minecraft, p_230431_2_, p_230431_3_); -- int j = this.field_230693_o_ ? 16777215 : 10526880; -+ int j = getFGColor(); - func_238472_a_(p_230431_1_, fontrenderer, this.func_230458_i_(), this.field_230690_l_ + this.field_230688_j_ / 2, this.field_230691_m_ + (this.field_230689_k_ - 8) / 2, j | MathHelper.func_76123_f(this.field_230695_q_ * 255.0F) << 24); - } - -@@ -206,6 +_,10 @@ - this.field_230688_j_ = p_230991_1_; - } - -+ public void setHeight(int value) { -+ this.field_230689_k_ = value; -+ } -+ - public void func_230986_a_(float p_230986_1_) { - this.field_230695_q_ = p_230986_1_; - } -@@ -232,5 +_,18 @@ - - protected void func_230996_d_(boolean p_230996_1_) { - this.field_230686_c_ = p_230996_1_; -+ } -+ -+ public static final int UNSET_FG_COLOR = -1; -+ protected int packedFGColor = UNSET_FG_COLOR; -+ public int getFGColor() { -+ if (packedFGColor != UNSET_FG_COLOR) return packedFGColor; -+ return this.field_230693_o_ ? 16777215 : 10526880; // White : Light Grey -+ } -+ public void setFGColor(int color) { -+ this.packedFGColor = color; -+ } -+ public void clearFGColor() { -+ this.packedFGColor = UNSET_FG_COLOR; - } - } diff --git a/patches/minecraft/net/minecraft/client/gui/widget/list/AbstractList.java.patch b/patches/minecraft/net/minecraft/client/gui/widget/list/AbstractList.java.patch deleted file mode 100644 index 50fa8c0ede..0000000000 --- a/patches/minecraft/net/minecraft/client/gui/widget/list/AbstractList.java.patch +++ /dev/null @@ -1,16 +0,0 @@ ---- a/net/minecraft/client/gui/widget/list/AbstractList.java -+++ b/net/minecraft/client/gui/widget/list/AbstractList.java -@@ -492,6 +_,13 @@ - p_238480_1_.field_230666_a_ = this; - } - -+ public int getWidth() { return this.field_230670_d_; } -+ public int getHeight() { return this.field_230671_e_; } -+ public int getTop() { return this.field_230672_i_; } -+ public int getBottom() { return this.field_230673_j_; } -+ public int getLeft() { return this.field_230675_l_; } -+ public int getRight() { return this.field_230674_k_; } -+ - @OnlyIn(Dist.CLIENT) - public abstract static class AbstractListEntry> implements IGuiEventListener { - @Deprecated diff --git a/patches/minecraft/net/minecraft/client/gui/widget/list/KeyBindingList.java.patch b/patches/minecraft/net/minecraft/client/gui/widget/list/KeyBindingList.java.patch deleted file mode 100644 index 271e8bc3ff..0000000000 --- a/patches/minecraft/net/minecraft/client/gui/widget/list/KeyBindingList.java.patch +++ /dev/null @@ -1,60 +0,0 @@ ---- a/net/minecraft/client/gui/widget/list/KeyBindingList.java -+++ b/net/minecraft/client/gui/widget/list/KeyBindingList.java -@@ -50,7 +_,7 @@ - } - - protected int func_230952_d_() { -- return super.func_230952_d_() + 15; -+ return super.func_230952_d_() + 15 + 20; - } - - public int func_230949_c_() { -@@ -94,7 +_,7 @@ - private KeyEntry(final KeyBinding p_i232281_2_, final ITextComponent p_i232281_3_) { - this.field_148282_b = p_i232281_2_; - this.field_148283_c = p_i232281_3_; -- this.field_148280_d = new Button(0, 0, 75, 20, p_i232281_3_, (p_214386_2_) -> { -+ this.field_148280_d = new Button(0, 0, 75 + 20 /*Forge: add space*/, 20, p_i232281_3_, (p_214386_2_) -> { - KeyBindingList.this.field_148191_k.field_146491_f = p_i232281_2_; - }) { - protected IFormattableTextComponent func_230442_c_() { -@@ -102,6 +_,7 @@ - } - }; - this.field_148281_e = new Button(0, 0, 50, 20, new TranslationTextComponent("controls.reset"), (p_214387_2_) -> { -+ field_148282_b.setToDefault(); - KeyBindingList.this.field_230668_b_.field_71474_y.func_198014_a(p_i232281_2_, p_i232281_2_.func_197977_i()); - KeyBinding.func_74508_b(); - }) { -@@ -114,7 +_,7 @@ - public void func_230432_a_(MatrixStack p_230432_1_, int p_230432_2_, int p_230432_3_, int p_230432_4_, int p_230432_5_, int p_230432_6_, int p_230432_7_, int p_230432_8_, boolean p_230432_9_, float p_230432_10_) { - boolean flag = KeyBindingList.this.field_148191_k.field_146491_f == this.field_148282_b; - KeyBindingList.this.field_230668_b_.field_71466_p.func_243248_b(p_230432_1_, this.field_148283_c, (float)(p_230432_4_ + 90 - KeyBindingList.this.field_148188_n), (float)(p_230432_3_ + p_230432_6_ / 2 - 9 / 2), 16777215); -- this.field_148281_e.field_230690_l_ = p_230432_4_ + 190; -+ this.field_148281_e.field_230690_l_ = p_230432_4_ + 190 + 20; - this.field_148281_e.field_230691_m_ = p_230432_3_; - this.field_148281_e.field_230693_o_ = !this.field_148282_b.func_197985_l(); - this.field_148281_e.func_230430_a_(p_230432_1_, p_230432_7_, p_230432_8_, p_230432_10_); -@@ -122,11 +_,12 @@ - this.field_148280_d.field_230691_m_ = p_230432_3_; - this.field_148280_d.func_238482_a_(this.field_148282_b.func_238171_j_()); - boolean flag1 = false; -+ boolean keyCodeModifierConflict = true; // less severe form of conflict, like SHIFT conflicting with SHIFT+G - if (!this.field_148282_b.func_197986_j()) { - for(KeyBinding keybinding : KeyBindingList.this.field_230668_b_.field_71474_y.field_74324_K) { - if (keybinding != this.field_148282_b && this.field_148282_b.func_197983_b(keybinding)) { - flag1 = true; -- break; -+ keyCodeModifierConflict &= keybinding.hasKeyCodeModifierConflict(keybinding); - } - } - } -@@ -134,7 +_,7 @@ - if (flag) { - this.field_148280_d.func_238482_a_((new StringTextComponent("> ")).func_230529_a_(this.field_148280_d.func_230458_i_().func_230532_e_().func_240699_a_(TextFormatting.YELLOW)).func_240702_b_(" <").func_240699_a_(TextFormatting.YELLOW)); - } else if (flag1) { -- this.field_148280_d.func_238482_a_(this.field_148280_d.func_230458_i_().func_230532_e_().func_240699_a_(TextFormatting.RED)); -+ this.field_148280_d.func_238482_a_(this.field_148280_d.func_230458_i_().func_230532_e_().func_240699_a_(keyCodeModifierConflict ? TextFormatting.GOLD : TextFormatting.RED)); - } - - this.field_148280_d.func_230430_a_(p_230432_1_, p_230432_7_, p_230432_8_, p_230432_10_); diff --git a/patches/minecraft/net/minecraft/client/main/Main.java.patch b/patches/minecraft/net/minecraft/client/main/Main.java.patch index eb2dff2fa9..743b407619 100644 --- a/patches/minecraft/net/minecraft/client/main/Main.java.patch +++ b/patches/minecraft/net/minecraft/client/main/Main.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/client/main/Main.java +++ b/net/minecraft/client/main/Main.java -@@ -120,7 +_,7 @@ - String s7 = func_206236_a(optionset, optionspec); - Integer integer = func_206236_a(optionset, optionspec1); - CrashReport.func_230188_h_(); -- Bootstrap.func_151354_b(); -+ net.minecraftforge.fml.loading.BackgroundWaiter.runAndTick(()->Bootstrap.func_151354_b(), net.minecraftforge.fml.loading.FMLLoader.progressWindowTick); - Bootstrap.func_218821_c(); - Util.func_240994_l_(); - Session session = new Session(optionspec10.value(optionset), s5, optionspec12.value(optionset), optionspec21.value(optionset)); +@@ -122,7 +_,7 @@ + String s7 = m_129638_(optionset, optionspec); + Integer integer = m_129638_(optionset, optionspec1); + CrashReport.m_127529_(); +- Bootstrap.m_135870_(); ++ net.minecraftforge.fml.loading.BackgroundWaiter.runAndTick(()->Bootstrap.m_135870_(), net.minecraftforge.fml.loading.FMLLoader.progressWindowTick); + Bootstrap.m_135889_(); + Util.m_137584_(); + User user = new User(optionspec9.value(optionset), s5, optionspec11.value(optionset), optionspec20.value(optionset)); diff --git a/patches/minecraft/net/minecraft/client/model/geom/LayerDefinitions.java.patch b/patches/minecraft/net/minecraft/client/model/geom/LayerDefinitions.java.patch new file mode 100644 index 0000000000..76293cd8c9 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/model/geom/LayerDefinitions.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/client/model/geom/LayerDefinitions.java ++++ b/net/minecraft/client/model/geom/LayerDefinitions.java +@@ -284,6 +_,7 @@ + WoodType.m_61843_().forEach((p_171114_) -> { + builder.put(ModelLayers.m_171291_(p_171114_), layerdefinition19); + }); ++ net.minecraftforge.fmlclient.registry.RenderingRegistry.loadLayerDefinitions(builder); + ImmutableMap immutablemap = builder.build(); + List list = ModelLayers.m_171288_().filter((p_171117_) -> { + return !immutablemap.containsKey(p_171117_); diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ClientChunkCache.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ClientChunkCache.java.patch new file mode 100644 index 0000000000..756950cb01 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/multiplayer/ClientChunkCache.java.patch @@ -0,0 +1,18 @@ +--- 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_); + LevelChunk levelchunk = this.f_104410_.m_104479_(i); + if (m_104438_(levelchunk, p_104456_, p_104457_)) { ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.ChunkEvent.Unload(levelchunk)); + this.f_104410_.m_104487_(i, levelchunk, (LevelChunk)null); + } + +@@ -110,6 +_,7 @@ + } + + this.f_104411_.m_171649_(chunkpos); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.ChunkEvent.Load(levelchunk)); + return levelchunk; + } + } diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ClientChunkProvider.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ClientChunkProvider.java.patch deleted file mode 100644 index 3d80367a67..0000000000 --- a/patches/minecraft/net/minecraft/client/multiplayer/ClientChunkProvider.java.patch +++ /dev/null @@ -1,18 +0,0 @@ ---- a/net/minecraft/client/multiplayer/ClientChunkProvider.java -+++ b/net/minecraft/client/multiplayer/ClientChunkProvider.java -@@ -59,6 +_,7 @@ - int i = this.field_217256_d.func_217191_a(p_73234_1_, p_73234_2_); - Chunk chunk = this.field_217256_d.func_217192_a(i); - if (func_217249_a(chunk, p_73234_1_, p_73234_2_)) { -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.ChunkEvent.Unload(chunk)); - this.field_217256_d.func_217190_a(i, chunk, (Chunk)null); - } - -@@ -112,6 +_,7 @@ - } - - this.field_73235_d.func_228323_e_(p_228313_1_, p_228313_2_); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.ChunkEvent.Load(chunk)); - return chunk; - } - } diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java.patch new file mode 100644 index 0000000000..f30cef9951 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java.patch @@ -0,0 +1,18 @@ +--- a/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java ++++ b/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java +@@ -115,6 +_,7 @@ + this.f_104521_.accept(new TranslatableComponent("connect.joining")); + this.f_104523_ = p_104547_.m_134774_(); + this.f_104522_.m_129498_(ConnectionProtocol.PLAY); ++ net.minecraftforge.fmllegacy.network.NetworkHooks.handleClientLoginSuccess(this.f_104522_); + this.f_104522_.m_129505_(new ClientPacketListener(this.f_104519_, this.f_104520_, this.f_104522_, this.f_104523_)); + } + +@@ -143,6 +_,7 @@ + } + + public void m_7254_(ClientboundCustomQueryPacket p_104545_) { ++ if (net.minecraftforge.fmllegacy.network.NetworkHooks.onCustomPayload(p_104545_, this.f_104522_)) return; + this.f_104521_.accept(new TranslatableComponent("connect.negotiating")); + this.f_104522_.m_129512_(new ServerboundCustomQueryPacket(p_104545_.m_134755_(), (FriendlyByteBuf)null)); + } diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ClientLevel.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ClientLevel.java.patch new file mode 100644 index 0000000000..af7cf85325 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/multiplayer/ClientLevel.java.patch @@ -0,0 +1,72 @@ +--- a/net/minecraft/client/multiplayer/ClientLevel.java ++++ b/net/minecraft/client/multiplayer/ClientLevel.java +@@ -112,6 +_,8 @@ + this.m_104752_(new BlockPos(8, 64, 8), 0.0F); + this.m_46465_(); + this.m_46466_(); ++ this.gatherCapabilities(); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Load(this)); + } + + public DimensionSpecialEffects m_104583_() { +@@ -171,6 +_,7 @@ + this.m_46473_().m_6521_(() -> { + return Registry.f_122826_.m_7981_(p_104640_.m_6095_()).toString(); + }); ++ if (p_104640_.canUpdate()) + p_104640_.m_8119_(); + this.m_46473_().m_7238_(); + +@@ -233,8 +_,10 @@ + } + + private void m_104739_(int p_104740_, Entity p_104741_) { ++ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityJoinWorldEvent(p_104741_, this))) return; + this.m_171642_(p_104740_, Entity.RemovalReason.DISCARDED); + this.f_171631_.m_157653_(p_104741_); ++ p_104741_.onAddedToWorld(); + } + + public void m_171642_(int p_171643_, Entity.RemovalReason p_171644_) { +@@ -367,6 +_,11 @@ + } + + public void m_6263_(@Nullable Player p_104645_, double p_104646_, double p_104647_, double p_104648_, SoundEvent p_104649_, SoundSource p_104650_, float p_104651_, float p_104652_) { ++ net.minecraftforge.event.entity.PlaySoundAtEntityEvent event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtEntity(p_104645_, p_104649_, p_104650_, p_104651_, p_104652_); ++ if (event.isCanceled() || event.getSound() == null) return; ++ p_104649_ = event.getSound(); ++ p_104650_ = event.getCategory(); ++ p_104651_ = event.getVolume(); + if (p_104645_ == this.f_104565_.f_91074_) { + this.m_7785_(p_104646_, p_104647_, p_104648_, p_104649_, p_104650_, p_104651_, p_104652_, false); + } +@@ -374,6 +_,11 @@ + } + + public void m_6269_(@Nullable Player p_104659_, Entity p_104660_, SoundEvent p_104661_, SoundSource p_104662_, float p_104663_, float p_104664_) { ++ net.minecraftforge.event.entity.PlaySoundAtEntityEvent event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtEntity(p_104659_, p_104661_, p_104662_, p_104663_, p_104664_); ++ if (event.isCanceled() || event.getSound() == null) return; ++ p_104661_ = event.getSound(); ++ p_104662_ = event.getCategory(); ++ p_104663_ = event.getVolume(); + if (p_104659_ == this.f_104565_.f_91074_) { + this.f_104565_.m_91106_().m_120367_(new EntityBoundSoundInstance(p_104661_, p_104662_, p_104663_, p_104664_, p_104660_)); + } +@@ -818,6 +_,7 @@ + } + + public void m_104851_(Difficulty p_104852_) { ++ net.minecraftforge.common.ForgeHooks.onDifficultyChange(p_104852_, this.f_104840_); + this.f_104840_ = p_104852_; + } + +@@ -860,6 +_,9 @@ + public void m_141981_(Entity p_171716_) { + p_171716_.m_19877_(); + ClientLevel.this.f_104566_.remove(p_171716_); ++ ++ p_171716_.onRemovedFromWorld(); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityLeaveWorldEvent(p_171716_, ClientLevel.this)); + } + } + diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ClientPacketListener.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ClientPacketListener.java.patch new file mode 100644 index 0000000000..95960faac4 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/multiplayer/ClientPacketListener.java.patch @@ -0,0 +1,109 @@ +--- a/net/minecraft/client/multiplayer/ClientPacketListener.java ++++ b/net/minecraft/client/multiplayer/ClientPacketListener.java +@@ -360,6 +_,7 @@ + + this.f_104888_.f_91064_.m_113434_(); + this.f_104888_.f_91074_.m_172530_(); ++ net.minecraftforge.fmlclient.ClientHooks.firePlayerLogin(this.f_104888_.f_91072_, this.f_104888_.f_91074_, this.f_104888_.m_91403_().m_6198_()); + int i = p_105030_.m_132398_(); + this.f_104888_.f_91074_.m_20234_(i); + this.f_104889_.m_104630_(i, this.f_104888_.f_91074_); +@@ -370,6 +_,7 @@ + this.f_104888_.f_91074_.m_36393_(p_105030_.m_132410_()); + this.f_104888_.f_91074_.m_108711_(p_105030_.m_132411_()); + this.f_104888_.f_91072_.m_171805_(p_105030_.m_132403_(), p_105030_.m_132404_()); ++ net.minecraftforge.fmllegacy.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.m_129629_()))); + this.f_104888_.m_91309_().m_90739_(); +@@ -612,7 +_,7 @@ + BlockPos blockpos = new BlockPos(compoundtag.m_128451_("x"), compoundtag.m_128451_("y"), compoundtag.m_128451_("z")); + BlockEntity blockentity = levelchunk.m_5685_(blockpos, LevelChunk.EntityCreationType.IMMEDIATE); + if (blockentity != null) { +- blockentity.m_142466_(compoundtag); ++ blockentity.handleUpdateTag(compoundtag); + } + } + } +@@ -694,7 +_,9 @@ + + public void m_5784_(ClientboundChatPacket p_104986_) { + PacketUtils.m_131363_(p_104986_, this, this.f_104888_); +- this.f_104888_.f_91065_.m_93051_(p_104986_.m_131840_(), p_104986_.m_131836_(), p_104986_.m_131841_()); ++ net.minecraft.network.chat.Component message = net.minecraftforge.event.ForgeEventFactory.onClientChat(p_104986_.m_131840_(), p_104986_.m_131836_(), p_104986_.m_131841_()); ++ if (message == null) return; ++ this.f_104888_.f_91065_.m_93051_(p_104986_.m_131840_(), message, p_104986_.m_131841_()); + } + + public void m_7791_(ClientboundAnimatePacket p_104968_) { +@@ -865,8 +_,10 @@ + localplayer1.m_21204_().m_22159_(localplayer.m_21204_()); + } + ++ localplayer1.updateSyncFields(localplayer); // Forge: fix MC-10657 + localplayer1.m_172530_(); + localplayer1.m_108748_(s); ++ net.minecraftforge.fmlclient.ClientHooks.firePlayerRespawn(this.f_104888_.f_91072_, localplayer, localplayer1, localplayer1.f_108617_.m_6198_()); + this.f_104889_.m_104630_(i, localplayer1); + localplayer1.m_146922_(-180.0F); + localplayer1.f_108618_ = new KeyboardInput(this.f_104888_.f_91066_); +@@ -977,6 +_,12 @@ + + if (flag && this.f_104888_.f_91080_ instanceof CommandBlockEditScreen) { + ((CommandBlockEditScreen)this.f_104888_.f_91080_).m_98398_(); ++ } else { ++ if (blockentity == null) { ++ f_104883_.error("Received invalid update packet for null tile entity at {} with data: {}", p_104976_.m_131704_(), p_104976_.m_131708_()); ++ return; ++ } ++ blockentity.onDataPacket(f_104885_, p_104976_); + } + + } +@@ -1139,6 +_,7 @@ + clientrecipebook.m_90625_(this.f_104900_.m_44051_()); + clientrecipebook.m_90639_().forEach(mutablesearchtree::m_8080_); + mutablesearchtree.m_7729_(); ++ net.minecraftforge.client.ForgeHooksClient.onRecipesUpdated(this.f_104900_); + } + + public void m_7244_(ClientboundPlayerLookAtPacket p_105054_) { +@@ -1216,7 +_,7 @@ + PacketUtils.m_131363_(p_105130_, this, this.f_104888_); + Entity entity = this.f_104889_.m_6815_(p_105130_.m_133622_()); + if (entity instanceof LivingEntity) { +- MobEffect mobeffect = MobEffect.m_19453_(p_105130_.m_133623_()); ++ MobEffect mobeffect = MobEffect.m_19453_(p_105130_.m_133623_() & 0xFF); + if (mobeffect != null) { + MobEffectInstance mobeffectinstance = new MobEffectInstance(mobeffect, p_105130_.m_133625_(), p_105130_.m_133624_(), p_105130_.m_133627_(), p_105130_.m_133626_(), p_105130_.m_133628_()); + mobeffectinstance.m_19562_(p_105130_.m_133619_()); +@@ -1228,11 +_,14 @@ + public void m_5859_(ClientboundUpdateTagsPacket p_105134_) { + PacketUtils.m_131363_(p_105134_, this, this.f_104888_); + TagContainer tagcontainer = TagContainer.m_144449_(this.f_104903_, p_105134_.m_179482_()); +- Multimap>, ResourceLocation> multimap = StaticTags.m_13283_(tagcontainer); ++ boolean vanillaConnection = net.minecraftforge.fmllegacy.network.NetworkHooks.isVanillaConnection(f_104885_); ++ Multimap>, ResourceLocation> multimap = vanillaConnection ? StaticTags.m_13283_(net.minecraftforge.common.ForgeTagHandler.withNoCustom(tagcontainer)) : StaticTags.validateVanillaTags(tagcontainer);//Forge: If we are connecting to vanilla validate all tags to properly validate custom tags the client may "require", and if we are connecting to forge only validate the vanilla tag types as the custom tag types get synced in a separate packet so may still arrive + if (!multimap.isEmpty()) { + f_104883_.warn("Incomplete server tags, disconnecting. Missing: {}", (Object)multimap); + this.f_104885_.m_129507_(new TranslatableComponent("multiplayer.disconnect.missing_tags")); + } else { ++ net.minecraftforge.common.ForgeTagHandler.resetCachedTagCollections(true, vanillaConnection); ++ tagcontainer = TagContainer.reinjectOptionalTags(tagcontainer); + this.f_104895_ = tagcontainer; + if (!this.f_104885_.m_129531_()) { + tagcontainer.m_13431_(); +@@ -1780,10 +_,12 @@ + int i5 = friendlybytebuf.m_130242_(); + this.f_104888_.f_91064_.f_173815_.m_173830_(positionsource, i5); + } else { +- f_104883_.warn("Unknown custom packed identifier: {}", (Object)resourcelocation); ++ if (!net.minecraftforge.fmllegacy.network.NetworkHooks.onCustomPayload(p_105004_, this.f_104885_)) ++ f_104883_.warn("Unknown custom packet identifier: {}", (Object)resourcelocation); + } + } finally { + if (friendlybytebuf != null) { ++ if (false) // Forge: let packet handle releasing buffer + friendlybytebuf.release(); + } + diff --git a/patches/minecraft/net/minecraft/client/multiplayer/MultiPlayerGameMode.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/MultiPlayerGameMode.java.patch new file mode 100644 index 0000000000..bbc1893cac --- /dev/null +++ b/patches/minecraft/net/minecraft/client/multiplayer/MultiPlayerGameMode.java.patch @@ -0,0 +1,164 @@ +--- a/net/minecraft/client/multiplayer/MultiPlayerGameMode.java ++++ b/net/minecraft/client/multiplayer/MultiPlayerGameMode.java +@@ -102,6 +_,7 @@ + } + + public boolean m_105267_(BlockPos p_105268_) { ++ if (f_105189_.f_91074_.m_21205_().onBlockStartBreak(p_105268_, f_105189_.f_91074_)) return false; + if (this.f_105189_.f_91074_.m_36187_(this.f_105189_.f_91073_, p_105268_, this.f_105197_)) { + return false; + } else { +@@ -116,9 +_,8 @@ + } else if (blockstate.m_60795_()) { + return false; + } else { +- block.m_5707_(level, p_105268_, blockstate, this.f_105189_.f_91074_); + FluidState fluidstate = level.m_6425_(p_105268_); +- boolean flag = level.m_7731_(p_105268_, fluidstate.m_76188_(), 11); ++ boolean flag = blockstate.removedByPlayer(level, p_105268_, f_105189_.f_91074_, false, fluidstate); + if (flag) { + block.m_6786_(level, p_105268_, blockstate); + } +@@ -139,21 +_,25 @@ + BlockState blockstate = this.f_105189_.f_91073_.m_8055_(p_105270_); + this.f_105189_.m_91301_().m_120581_(this.f_105189_.f_91073_, p_105270_, blockstate, 1.0F); + this.m_105272_(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, p_105270_, p_105271_); ++ if (!net.minecraftforge.common.ForgeHooks.onLeftClickBlock(this.f_105189_.f_91074_, p_105270_, p_105271_).isCanceled()) + this.m_105267_(p_105270_); + this.f_105195_ = 5; + } else if (!this.f_105196_ || !this.m_105281_(p_105270_)) { + if (this.f_105196_) { + this.m_105272_(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_); + + BlockState blockstate1 = this.f_105189_.f_91073_.m_8055_(p_105270_); + this.f_105189_.m_91301_().m_120581_(this.f_105189_.f_91073_, p_105270_, blockstate1, 0.0F); + this.m_105272_(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, p_105270_, p_105271_); + boolean flag = !blockstate1.m_60795_(); + if (flag && this.f_105193_ == 0.0F) { ++ if (event.getUseBlock() != net.minecraftforge.eventbus.api.Event.Result.DENY) + blockstate1.m_60686_(this.f_105189_.f_91073_, p_105270_, this.f_105189_.f_91074_); + } + ++ if (event.getUseItem() == net.minecraftforge.eventbus.api.Event.Result.DENY) return true; + if (flag && blockstate1.m_60625_(this.f_105189_.f_91074_, this.f_105189_.f_91074_.f_19853_, p_105270_) >= 1.0F) { + this.m_105267_(p_105270_); + } else { +@@ -193,6 +_,7 @@ + BlockState blockstate1 = this.f_105189_.f_91073_.m_8055_(p_105284_); + this.f_105189_.m_91301_().m_120581_(this.f_105189_.f_91073_, p_105284_, blockstate1, 1.0F); + this.m_105272_(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, p_105284_, p_105285_); ++ if (!net.minecraftforge.common.ForgeHooks.onLeftClickBlock(this.f_105189_.f_91074_, p_105284_, p_105285_).isCanceled()) + this.m_105267_(p_105284_); + return true; + } else if (this.m_105281_(p_105284_)) { +@@ -203,12 +_,13 @@ + } else { + this.f_105193_ += blockstate.m_60625_(this.f_105189_.f_91074_, this.f_105189_.f_91074_.f_19853_, p_105284_); + if (this.f_105194_ % 4.0F == 0.0F) { +- SoundType soundtype = blockstate.m_60827_(); ++ SoundType soundtype = blockstate.getSoundType(this.f_105189_.f_91073_, p_105284_, this.f_105189_.f_91074_); + this.f_105189_.m_91106_().m_120367_(new SimpleSoundInstance(soundtype.m_56778_(), SoundSource.BLOCKS, (soundtype.m_56773_() + 1.0F) / 8.0F, soundtype.m_56774_() * 0.5F, p_105284_)); + } + + ++this.f_105194_; + this.f_105189_.m_91301_().m_120581_(this.f_105189_.f_91073_, p_105284_, blockstate, Mth.m_14036_(this.f_105193_, 0.0F, 1.0F)); ++ if (net.minecraftforge.common.ForgeHooks.onLeftClickBlock(this.f_105189_.f_91074_, p_105284_, p_105285_).getUseItem() == net.minecraftforge.eventbus.api.Event.Result.DENY) return true; + if (this.f_105193_ >= 1.0F) { + this.f_105196_ = false; + this.m_105272_(ServerboundPlayerActionPacket.Action.STOP_DESTROY_BLOCK, p_105284_, p_105285_); +@@ -227,7 +_,8 @@ + } + + public float m_105286_() { +- return this.f_105197_.m_46408_() ? 5.0F : 4.5F; ++ float attrib = (float)f_105189_.f_91074_.m_21051_(net.minecraftforge.common.ForgeMod.REACH_DISTANCE.get()).m_22135_(); ++ return this.f_105197_.m_46408_() ? attrib : attrib - 0.5F; + } + + public void m_105287_() { +@@ -244,7 +_,7 @@ + ItemStack itemstack = this.f_105189_.f_91074_.m_21205_(); + boolean flag = this.f_105192_.m_41619_() && itemstack.m_41619_(); + if (!this.f_105192_.m_41619_() && !itemstack.m_41619_()) { +- flag = itemstack.m_150930_(this.f_105192_.m_41720_()) && ItemStack.m_41658_(itemstack, this.f_105192_) && (itemstack.m_41763_() || itemstack.m_41773_() == this.f_105192_.m_41773_()); ++ flag = !this.f_105192_.shouldCauseBlockBreakReset(itemstack); + } + + return p_105282_.equals(this.f_105191_) && flag; +@@ -266,13 +_,27 @@ + return InteractionResult.FAIL; + } else { + ItemStack itemstack = p_105263_.m_21120_(p_105265_); ++ net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock event = net.minecraftforge.common.ForgeHooks ++ .onRightClickBlock(p_105263_, p_105265_, blockpos, p_105266_); ++ if (event.isCanceled()) { ++ this.f_105190_.m_104955_(new ServerboundUseItemOnPacket(p_105265_, p_105266_)); ++ return event.getCancellationResult(); ++ } + if (this.f_105197_ == GameType.SPECTATOR) { + this.f_105190_.m_104955_(new ServerboundUseItemOnPacket(p_105265_, p_105266_)); + return InteractionResult.SUCCESS; + } else { +- boolean flag = !p_105263_.m_21205_().m_41619_() || !p_105263_.m_21206_().m_41619_(); ++ UseOnContext useoncontext = new UseOnContext(p_105263_, p_105265_, p_105266_); ++ if (event.getUseItem() != net.minecraftforge.eventbus.api.Event.Result.DENY) { ++ InteractionResult result = itemstack.onItemUseFirst(useoncontext); ++ if (result != InteractionResult.PASS) { ++ this.f_105190_.m_104955_(new ServerboundUseItemOnPacket(p_105265_, p_105266_)); ++ return result; ++ } ++ } ++ boolean flag = !p_105263_.m_21205_().doesSneakBypassUse(p_105264_,blockpos,p_105263_) || !p_105263_.m_21206_().doesSneakBypassUse(p_105264_,blockpos,p_105263_); + boolean flag1 = p_105263_.m_36341_() && flag; +- if (!flag1) { ++ if (event.getUseBlock() == net.minecraftforge.eventbus.api.Event.Result.ALLOW || (event.getUseBlock() != net.minecraftforge.eventbus.api.Event.Result.DENY && !flag1)) { + InteractionResult interactionresult = p_105264_.m_8055_(blockpos).m_60664_(p_105264_, p_105263_, p_105265_, p_105266_); + if (interactionresult.m_19077_()) { + this.f_105190_.m_104955_(new ServerboundUseItemOnPacket(p_105265_, p_105266_)); +@@ -281,8 +_,8 @@ + } + + this.f_105190_.m_104955_(new ServerboundUseItemOnPacket(p_105265_, p_105266_)); +- if (!itemstack.m_41619_() && !p_105263_.m_36335_().m_41519_(itemstack.m_41720_())) { +- UseOnContext useoncontext = new UseOnContext(p_105263_, p_105265_, p_105266_); ++ if (event.getUseItem() == net.minecraftforge.eventbus.api.Event.Result.DENY) return InteractionResult.PASS; ++ if (event.getUseItem() == net.minecraftforge.eventbus.api.Event.Result.ALLOW || (!itemstack.m_41619_() && !p_105263_.m_36335_().m_41519_(itemstack.m_41720_()))) { + InteractionResult interactionresult1; + if (this.f_105197_.m_46408_()) { + int i = itemstack.m_41613_(); +@@ -311,10 +_,13 @@ + if (p_105236_.m_36335_().m_41519_(itemstack.m_41720_())) { + return InteractionResult.PASS; + } else { ++ InteractionResult cancelResult = net.minecraftforge.common.ForgeHooks.onItemRightClick(p_105236_, p_105238_); ++ if (cancelResult != null) return cancelResult; + InteractionResultHolder interactionresultholder = itemstack.m_41682_(p_105237_, p_105236_, p_105238_); + ItemStack itemstack1 = interactionresultholder.m_19095_(); + if (itemstack1 != itemstack) { + p_105236_.m_21008_(p_105238_, itemstack1); ++ if (itemstack1.m_41619_()) net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(p_105236_, itemstack, p_105238_); + } + + return interactionresultholder.m_19089_(); +@@ -343,6 +_,9 @@ + public InteractionResult m_105226_(Player p_105227_, Entity p_105228_, InteractionHand p_105229_) { + this.m_105297_(); + this.f_105190_.m_104955_(ServerboundInteractPacket.m_179608_(p_105228_, p_105227_.m_6144_(), p_105229_)); ++ if (this.f_105197_ == GameType.SPECTATOR) return InteractionResult.PASS; // don't fire for spectators to match non-specific EntityInteract ++ InteractionResult cancelResult = net.minecraftforge.common.ForgeHooks.onInteractEntity(p_105227_, p_105228_, p_105229_); ++ if(cancelResult != null) return cancelResult; + return this.f_105197_ == GameType.SPECTATOR ? InteractionResult.PASS : p_105227_.m_36157_(p_105228_, p_105229_); + } + +@@ -350,6 +_,9 @@ + 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)); ++ 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; + return this.f_105197_ == GameType.SPECTATOR ? InteractionResult.PASS : p_105232_.m_7111_(p_105231_, vec3, p_105234_); + } + diff --git a/patches/minecraft/net/minecraft/client/multiplayer/PlayerController.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/PlayerController.java.patch deleted file mode 100644 index 2d6a0cd5d5..0000000000 --- a/patches/minecraft/net/minecraft/client/multiplayer/PlayerController.java.patch +++ /dev/null @@ -1,174 +0,0 @@ ---- a/net/minecraft/client/multiplayer/PlayerController.java -+++ b/net/minecraft/client/multiplayer/PlayerController.java -@@ -93,6 +_,7 @@ - } - - public boolean func_187103_a(BlockPos p_187103_1_) { -+ if (field_78776_a.field_71439_g.func_184614_ca().onBlockStartBreak(p_187103_1_, field_78776_a.field_71439_g)) return false; - if (this.field_78776_a.field_71439_g.func_223729_a(this.field_78776_a.field_71441_e, p_187103_1_, this.field_78779_k)) { - return false; - } else { -@@ -104,12 +_,11 @@ - Block block = blockstate.func_177230_c(); - if ((block instanceof CommandBlockBlock || block instanceof StructureBlock || block instanceof JigsawBlock) && !this.field_78776_a.field_71439_g.func_195070_dx()) { - return false; -- } else if (blockstate.func_196958_f()) { -+ } else if (blockstate.isAir(world, p_187103_1_)) { - return false; - } else { -- block.func_176208_a(world, p_187103_1_, blockstate, this.field_78776_a.field_71439_g); - FluidState fluidstate = world.func_204610_c(p_187103_1_); -- boolean flag = world.func_180501_a(p_187103_1_, fluidstate.func_206883_i(), 11); -+ boolean flag = blockstate.removedByPlayer(world, p_187103_1_, field_78776_a.field_71439_g, false, fluidstate); - if (flag) { - block.func_176206_d(world, p_187103_1_, blockstate); - } -@@ -130,21 +_,25 @@ - BlockState blockstate = this.field_78776_a.field_71441_e.func_180495_p(p_180511_1_); - this.field_78776_a.func_193032_ao().func_193294_a(this.field_78776_a.field_71441_e, p_180511_1_, blockstate, 1.0F); - this.func_225324_a(CPlayerDiggingPacket.Action.START_DESTROY_BLOCK, p_180511_1_, p_180511_2_); -+ if (!net.minecraftforge.common.ForgeHooks.onLeftClickBlock(this.field_78776_a.field_71439_g, p_180511_1_, p_180511_2_).isCanceled()) - this.func_187103_a(p_180511_1_); - this.field_78781_i = 5; - } else if (!this.field_78778_j || !this.func_178893_a(p_180511_1_)) { - if (this.field_78778_j) { - this.func_225324_a(CPlayerDiggingPacket.Action.ABORT_DESTROY_BLOCK, this.field_178895_c, p_180511_2_); - } -+ net.minecraftforge.event.entity.player.PlayerInteractEvent.LeftClickBlock event = net.minecraftforge.common.ForgeHooks.onLeftClickBlock(this.field_78776_a.field_71439_g, p_180511_1_, p_180511_2_); - - BlockState blockstate1 = this.field_78776_a.field_71441_e.func_180495_p(p_180511_1_); - this.field_78776_a.func_193032_ao().func_193294_a(this.field_78776_a.field_71441_e, p_180511_1_, blockstate1, 0.0F); - this.func_225324_a(CPlayerDiggingPacket.Action.START_DESTROY_BLOCK, p_180511_1_, p_180511_2_); -- boolean flag = !blockstate1.func_196958_f(); -+ boolean flag = !blockstate1.isAir(this.field_78776_a.field_71441_e, p_180511_1_); - if (flag && this.field_78770_f == 0.0F) { -+ if (event.getUseBlock() != net.minecraftforge.eventbus.api.Event.Result.DENY) - blockstate1.func_196942_a(this.field_78776_a.field_71441_e, p_180511_1_, this.field_78776_a.field_71439_g); - } - -+ if (event.getUseItem() == net.minecraftforge.eventbus.api.Event.Result.DENY) return true; - if (flag && blockstate1.func_185903_a(this.field_78776_a.field_71439_g, this.field_78776_a.field_71439_g.field_70170_p, p_180511_1_) >= 1.0F) { - this.func_187103_a(p_180511_1_); - } else { -@@ -184,22 +_,24 @@ - BlockState blockstate1 = this.field_78776_a.field_71441_e.func_180495_p(p_180512_1_); - this.field_78776_a.func_193032_ao().func_193294_a(this.field_78776_a.field_71441_e, p_180512_1_, blockstate1, 1.0F); - this.func_225324_a(CPlayerDiggingPacket.Action.START_DESTROY_BLOCK, p_180512_1_, p_180512_2_); -+ if (!net.minecraftforge.common.ForgeHooks.onLeftClickBlock(this.field_78776_a.field_71439_g, p_180512_1_, p_180512_2_).isCanceled()) - this.func_187103_a(p_180512_1_); - return true; - } else if (this.func_178893_a(p_180512_1_)) { - BlockState blockstate = this.field_78776_a.field_71441_e.func_180495_p(p_180512_1_); -- if (blockstate.func_196958_f()) { -+ if (blockstate.isAir(this.field_78776_a.field_71441_e, p_180512_1_)) { - this.field_78778_j = false; - return false; - } else { - this.field_78770_f += blockstate.func_185903_a(this.field_78776_a.field_71439_g, this.field_78776_a.field_71439_g.field_70170_p, p_180512_1_); - if (this.field_78780_h % 4.0F == 0.0F) { -- SoundType soundtype = blockstate.func_215695_r(); -+ SoundType soundtype = blockstate.getSoundType(this.field_78776_a.field_71441_e, p_180512_1_, this.field_78776_a.field_71439_g); - this.field_78776_a.func_147118_V().func_147682_a(new SimpleSound(soundtype.func_185846_f(), SoundCategory.BLOCKS, (soundtype.func_185843_a() + 1.0F) / 8.0F, soundtype.func_185847_b() * 0.5F, p_180512_1_)); - } - - ++this.field_78780_h; - this.field_78776_a.func_193032_ao().func_193294_a(this.field_78776_a.field_71441_e, p_180512_1_, blockstate, MathHelper.func_76131_a(this.field_78770_f, 0.0F, 1.0F)); -+ if (net.minecraftforge.common.ForgeHooks.onLeftClickBlock(this.field_78776_a.field_71439_g, p_180512_1_, p_180512_2_).getUseItem() == net.minecraftforge.eventbus.api.Event.Result.DENY) return true; - if (this.field_78770_f >= 1.0F) { - this.field_78778_j = false; - this.func_225324_a(CPlayerDiggingPacket.Action.STOP_DESTROY_BLOCK, p_180512_1_, p_180512_2_); -@@ -218,7 +_,8 @@ - } - - public float func_78757_d() { -- return this.field_78779_k.func_77145_d() ? 5.0F : 4.5F; -+ float attrib = (float)field_78776_a.field_71439_g.func_110148_a(net.minecraftforge.common.ForgeMod.REACH_DISTANCE.get()).func_111126_e(); -+ return this.field_78779_k.func_77145_d() ? attrib : attrib - 0.5F; - } - - public void func_78765_e() { -@@ -235,7 +_,7 @@ - ItemStack itemstack = this.field_78776_a.field_71439_g.func_184614_ca(); - boolean flag = this.field_85183_f.func_190926_b() && itemstack.func_190926_b(); - if (!this.field_85183_f.func_190926_b() && !itemstack.func_190926_b()) { -- flag = itemstack.func_77973_b() == this.field_85183_f.func_77973_b() && ItemStack.func_77970_a(itemstack, this.field_85183_f) && (itemstack.func_77984_f() || itemstack.func_77952_i() == this.field_85183_f.func_77952_i()); -+ flag = !this.field_85183_f.shouldCauseBlockBreakReset(itemstack); - } - - return p_178893_1_.equals(this.field_178895_c) && flag; -@@ -257,13 +_,27 @@ - return ActionResultType.FAIL; - } else { - ItemStack itemstack = p_217292_1_.func_184586_b(p_217292_3_); -+ net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock event = net.minecraftforge.common.ForgeHooks -+ .onRightClickBlock(p_217292_1_, p_217292_3_, blockpos, p_217292_4_); -+ if (event.isCanceled()) { -+ this.field_78774_b.func_147297_a(new CPlayerTryUseItemOnBlockPacket(p_217292_3_, p_217292_4_)); -+ return event.getCancellationResult(); -+ } - if (this.field_78779_k == GameType.SPECTATOR) { - this.field_78774_b.func_147297_a(new CPlayerTryUseItemOnBlockPacket(p_217292_3_, p_217292_4_)); - return ActionResultType.SUCCESS; - } else { -- boolean flag = !p_217292_1_.func_184614_ca().func_190926_b() || !p_217292_1_.func_184592_cb().func_190926_b(); -+ ItemUseContext itemusecontext = new ItemUseContext(p_217292_1_, p_217292_3_, p_217292_4_); -+ if (event.getUseItem() != net.minecraftforge.eventbus.api.Event.Result.DENY) { -+ ActionResultType result = itemstack.onItemUseFirst(itemusecontext); -+ if (result != ActionResultType.PASS) { -+ this.field_78774_b.func_147297_a(new CPlayerTryUseItemOnBlockPacket(p_217292_3_, p_217292_4_)); -+ return result; -+ } -+ } -+ boolean flag = !p_217292_1_.func_184614_ca().doesSneakBypassUse(p_217292_2_,blockpos,p_217292_1_) || !p_217292_1_.func_184592_cb().doesSneakBypassUse(p_217292_2_,blockpos,p_217292_1_); - boolean flag1 = p_217292_1_.func_226563_dT_() && flag; -- if (!flag1) { -+ if (event.getUseBlock() == net.minecraftforge.eventbus.api.Event.Result.ALLOW || (event.getUseBlock() != net.minecraftforge.eventbus.api.Event.Result.DENY && !flag1)) { - ActionResultType actionresulttype = p_217292_2_.func_180495_p(blockpos).func_227031_a_(p_217292_2_, p_217292_1_, p_217292_3_, p_217292_4_); - if (actionresulttype.func_226246_a_()) { - this.field_78774_b.func_147297_a(new CPlayerTryUseItemOnBlockPacket(p_217292_3_, p_217292_4_)); -@@ -272,8 +_,8 @@ - } - - this.field_78774_b.func_147297_a(new CPlayerTryUseItemOnBlockPacket(p_217292_3_, p_217292_4_)); -- if (!itemstack.func_190926_b() && !p_217292_1_.func_184811_cZ().func_185141_a(itemstack.func_77973_b())) { -- ItemUseContext itemusecontext = new ItemUseContext(p_217292_1_, p_217292_3_, p_217292_4_); -+ if (event.getUseItem() == net.minecraftforge.eventbus.api.Event.Result.DENY) return ActionResultType.PASS; -+ if (event.getUseItem() == net.minecraftforge.eventbus.api.Event.Result.ALLOW || (!itemstack.func_190926_b() && !p_217292_1_.func_184811_cZ().func_185141_a(itemstack.func_77973_b()))) { - ActionResultType actionresulttype1; - if (this.field_78779_k.func_77145_d()) { - int i = itemstack.func_190916_E(); -@@ -301,11 +_,14 @@ - if (p_187101_1_.func_184811_cZ().func_185141_a(itemstack.func_77973_b())) { - return ActionResultType.PASS; - } else { -+ ActionResultType cancelResult = net.minecraftforge.common.ForgeHooks.onItemRightClick(p_187101_1_, p_187101_3_); -+ if (cancelResult != null) return cancelResult; - int i = itemstack.func_190916_E(); - ActionResult actionresult = itemstack.func_77957_a(p_187101_2_, p_187101_1_, p_187101_3_); - ItemStack itemstack1 = actionresult.func_188398_b(); - if (itemstack1 != itemstack) { - p_187101_1_.func_184611_a(p_187101_3_, itemstack1); -+ if (itemstack1.func_190926_b()) net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(p_187101_1_, itemstack, p_187101_3_); - } - - return actionresult.func_188397_a(); -@@ -334,6 +_,9 @@ - public ActionResultType func_187097_a(PlayerEntity p_187097_1_, Entity p_187097_2_, Hand p_187097_3_) { - this.func_78750_j(); - this.field_78774_b.func_147297_a(new CUseEntityPacket(p_187097_2_, p_187097_3_, p_187097_1_.func_225608_bj_())); -+ if (this.field_78779_k == GameType.SPECTATOR) return ActionResultType.PASS; // don't fire for spectators to match non-specific EntityInteract -+ ActionResultType cancelResult = net.minecraftforge.common.ForgeHooks.onInteractEntity(p_187097_1_, p_187097_2_, p_187097_3_); -+ if(cancelResult != null) return cancelResult; - return this.field_78779_k == GameType.SPECTATOR ? ActionResultType.PASS : p_187097_1_.func_190775_a(p_187097_2_, p_187097_3_); - } - -@@ -341,6 +_,9 @@ - this.func_78750_j(); - Vector3d vector3d = p_187102_3_.func_216347_e().func_178786_a(p_187102_2_.func_226277_ct_(), p_187102_2_.func_226278_cu_(), p_187102_2_.func_226281_cx_()); - this.field_78774_b.func_147297_a(new CUseEntityPacket(p_187102_2_, p_187102_4_, vector3d, p_187102_1_.func_225608_bj_())); -+ if (this.field_78779_k == GameType.SPECTATOR) return ActionResultType.PASS; // don't fire for spectators to match non-specific EntityInteract -+ ActionResultType cancelResult = net.minecraftforge.common.ForgeHooks.onInteractEntityAt(p_187102_1_, p_187102_2_, p_187102_3_, p_187102_4_); -+ if(cancelResult != null) return cancelResult; - return this.field_78779_k == GameType.SPECTATOR ? ActionResultType.PASS : p_187102_2_.func_184199_a(p_187102_1_, vector3d, p_187102_4_); - } - diff --git a/patches/minecraft/net/minecraft/client/multiplayer/PlayerInfo.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/PlayerInfo.java.patch new file mode 100644 index 0000000000..33581bd2af --- /dev/null +++ b/patches/minecraft/net/minecraft/client/multiplayer/PlayerInfo.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/client/multiplayer/PlayerInfo.java ++++ b/net/minecraft/client/multiplayer/PlayerInfo.java +@@ -50,6 +_,7 @@ + } + + protected void m_105317_(GameType p_105318_) { ++ net.minecraftforge.client.ForgeHooksClient.onClientChangeGameMode(this, this.f_105300_, p_105318_); + this.f_105300_ = 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 c52ae4f822..6c05cf6f7d 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 @@ -26,6 +_,7 @@ @Nullable - private String field_147411_m; - private boolean field_181042_l; -+ public net.minecraftforge.fml.client.ExtendedServerListData forgeData = null; + private String f_105372_; + private boolean f_105373_; ++ public net.minecraftforge.fmlclient.ExtendedServerListData forgeData = null; - public ServerData(String p_i46420_1_, String p_i46420_2_, boolean p_i46420_3_) { - this.field_78847_a = p_i46420_1_; + public ServerData(String p_105375_, String p_105376_, boolean p_105377_) { + 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 new file mode 100644 index 0000000000..2960aa3981 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/multiplayer/ServerStatusPinger.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/client/multiplayer/ServerStatusPinger.java ++++ b/net/minecraft/client/multiplayer/ServerStatusPinger.java +@@ -125,6 +_,7 @@ + p_105461_.run(); + } + ++ net.minecraftforge.fmlclient.ClientHooks.processForgeListPingData(serverstatus, p_105460_); + this.f_105477_ = Util.m_137550_(); + connection.m_129512_(new ServerboundPingRequestPacket(this.f_105477_)); + this.f_105475_ = true; diff --git a/patches/minecraft/net/minecraft/client/network/ServerPinger.java.patch b/patches/minecraft/net/minecraft/client/network/ServerPinger.java.patch deleted file mode 100644 index 0caf1289a8..0000000000 --- a/patches/minecraft/net/minecraft/client/network/ServerPinger.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/client/network/ServerPinger.java -+++ b/net/minecraft/client/network/ServerPinger.java -@@ -116,6 +_,7 @@ - p_147224_2_.run(); - } - -+ net.minecraftforge.fml.client.ClientHooks.processForgeListPingData(serverstatusresponse, p_147224_1_); - this.field_175092_e = Util.func_211177_b(); - networkmanager.func_179290_a(new CPingPacket(this.field_175092_e)); - this.field_147403_d = true; diff --git a/patches/minecraft/net/minecraft/client/network/handshake/ClientHandshakeNetHandler.java.patch b/patches/minecraft/net/minecraft/client/network/handshake/ClientHandshakeNetHandler.java.patch deleted file mode 100644 index 56b0c71470..0000000000 --- a/patches/minecraft/net/minecraft/client/network/handshake/ClientHandshakeNetHandler.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/client/network/handshake/ClientHandshakeNetHandler.java -+++ b/net/minecraft/client/network/handshake/ClientHandshakeNetHandler.java -@@ -20,6 +_,7 @@ - } - - public void func_147383_a(CHandshakePacket p_147383_1_) { -+ if (!net.minecraftforge.fml.server.ServerLifecycleHooks.handleServerLogin(p_147383_1_, this.field_147384_b)) return; - this.field_147384_b.func_150723_a(p_147383_1_.func_149594_c()); - this.field_147384_b.func_150719_a(new ServerLoginNetHandler(this.field_147385_a, this.field_147384_b)); - } diff --git a/patches/minecraft/net/minecraft/client/network/login/ClientLoginNetHandler.java.patch b/patches/minecraft/net/minecraft/client/network/login/ClientLoginNetHandler.java.patch deleted file mode 100644 index ec577514ac..0000000000 --- a/patches/minecraft/net/minecraft/client/network/login/ClientLoginNetHandler.java.patch +++ /dev/null @@ -1,18 +0,0 @@ ---- a/net/minecraft/client/network/login/ClientLoginNetHandler.java -+++ b/net/minecraft/client/network/login/ClientLoginNetHandler.java -@@ -115,6 +_,7 @@ - this.field_209525_d.accept(new TranslationTextComponent("connect.joining")); - this.field_175091_e = p_147390_1_.func_179730_a(); - this.field_147393_d.func_150723_a(ProtocolType.PLAY); -+ net.minecraftforge.fml.network.NetworkHooks.handleClientLoginSuccess(this.field_147393_d); - this.field_147393_d.func_150719_a(new ClientPlayNetHandler(this.field_147394_b, this.field_147395_c, this.field_147393_d, this.field_175091_e)); - } - -@@ -143,6 +_,7 @@ - } - - public void func_209521_a(SCustomPayloadLoginPacket p_209521_1_) { -+ if (net.minecraftforge.fml.network.NetworkHooks.onCustomPayload(p_209521_1_, this.field_147393_d)) return; - this.field_209525_d.accept(new TranslationTextComponent("connect.negotiating")); - this.field_147393_d.func_179290_a(new CCustomPayloadLoginPacket(p_209521_1_.func_209918_a(), (PacketBuffer)null)); - } diff --git a/patches/minecraft/net/minecraft/client/network/play/ClientPlayNetHandler.java.patch b/patches/minecraft/net/minecraft/client/network/play/ClientPlayNetHandler.java.patch deleted file mode 100644 index 977a4ec76c..0000000000 --- a/patches/minecraft/net/minecraft/client/network/play/ClientPlayNetHandler.java.patch +++ /dev/null @@ -1,120 +0,0 @@ ---- a/net/minecraft/client/network/play/ClientPlayNetHandler.java -+++ b/net/minecraft/client/network/play/ClientPlayNetHandler.java -@@ -384,6 +_,7 @@ - - this.field_147299_f.field_184132_p.func_217737_a(); - this.field_147299_f.field_71439_g.func_70065_x(); -+ net.minecraftforge.fml.client.ClientHooks.firePlayerLogin(this.field_147299_f.field_71442_b, this.field_147299_f.field_71439_g, this.field_147299_f.func_147114_u().func_147298_b()); - int i = p_147282_1_.func_149197_c(); - this.field_147300_g.func_217408_a(i, this.field_147299_f.field_71439_g); - this.field_147299_f.field_71439_g.field_71158_b = new MovementInputFromOptions(this.field_147299_f.field_71474_y); -@@ -395,6 +_,7 @@ - this.field_147299_f.field_71439_g.func_228355_a_(p_147282_1_.func_229743_k_()); - this.field_147299_f.field_71442_b.func_78746_a(p_147282_1_.func_149198_e()); - this.field_147299_f.field_71442_b.func_241675_a_(p_147282_1_.func_241786_f_()); -+ net.minecraftforge.fml.network.NetworkHooks.sendMCRegistryPackets(field_147302_e, "PLAY_TO_SERVER"); - this.field_147299_f.field_71474_y.func_82879_c(); - this.field_147302_e.func_179290_a(new CCustomPayloadPacket(CCustomPayloadPacket.field_210344_a, (new PacketBuffer(Unpooled.buffer())).func_180714_a(ClientBrandRetriever.getClientModName()))); - this.field_147299_f.func_213229_ar().func_216814_a(); -@@ -734,7 +_,7 @@ - BlockPos blockpos = new BlockPos(compoundnbt.func_74762_e("x"), compoundnbt.func_74762_e("y"), compoundnbt.func_74762_e("z")); - TileEntity tileentity = this.field_147300_g.func_175625_s(blockpos); - if (tileentity != null) { -- tileentity.func_230337_a_(this.field_147300_g.func_180495_p(blockpos), compoundnbt); -+ tileentity.handleUpdateTag(this.field_147300_g.func_180495_p(blockpos), compoundnbt); - } - } - -@@ -815,7 +_,9 @@ - - public void func_147251_a(SChatPacket p_147251_1_) { - PacketThreadUtil.func_218797_a(p_147251_1_, this, this.field_147299_f); -- this.field_147299_f.field_71456_v.func_238450_a_(p_147251_1_.func_192590_c(), p_147251_1_.func_148915_c(), p_147251_1_.func_240810_e_()); -+ net.minecraft.util.text.ITextComponent message = net.minecraftforge.event.ForgeEventFactory.onClientChat(p_147251_1_.func_192590_c(), p_147251_1_.func_148915_c(), p_147251_1_.func_240810_e_()); -+ if (message == null) return; -+ this.field_147299_f.field_71456_v.func_238450_a_(p_147251_1_.func_192590_c(), message, p_147251_1_.func_240810_e_()); - } - - public void func_147279_a(SAnimateHandPacket p_147279_1_) { -@@ -854,8 +_,8 @@ - livingentity.func_213312_b(d0, d1, d2); - livingentity.field_70761_aq = (float)(p_147281_1_.func_149032_n() * 360) / 256.0F; - livingentity.field_70759_as = (float)(p_147281_1_.func_149032_n() * 360) / 256.0F; -- if (livingentity instanceof EnderDragonEntity) { -- EnderDragonPartEntity[] aenderdragonpartentity = ((EnderDragonEntity)livingentity).func_213404_dT(); -+ if (livingentity.isMultipartEntity()) { -+ net.minecraftforge.entity.PartEntity[] aenderdragonpartentity = livingentity.getParts(); - - for(int i = 0; i < aenderdragonpartentity.length; ++i) { - aenderdragonpartentity[i].func_145769_d(i + p_147281_1_.func_149024_d()); -@@ -1004,8 +_,10 @@ - clientplayerentity1.func_233645_dx_().func_233784_a_(clientplayerentity.func_233645_dx_()); - } - -+ clientplayerentity1.updateSyncFields(clientplayerentity); // Forge: fix MC-10657 - clientplayerentity1.func_70065_x(); - clientplayerentity1.func_175158_f(s); -+ net.minecraftforge.fml.client.ClientHooks.firePlayerRespawn(this.field_147299_f.field_71442_b, clientplayerentity, clientplayerentity1, clientplayerentity1.field_71174_a.func_147298_b()); - this.field_147300_g.func_217408_a(i, clientplayerentity1); - clientplayerentity1.field_70177_z = -180.0F; - clientplayerentity1.field_71158_b = new MovementInputFromOptions(this.field_147299_f.field_71474_y); -@@ -1131,6 +_,12 @@ - - if (flag && this.field_147299_f.field_71462_r instanceof CommandBlockScreen) { - ((CommandBlockScreen)this.field_147299_f.field_71462_r).func_184075_a(); -+ } else { -+ if(tileentity == null) { -+ field_147301_d.error("Received invalid update packet for null tile entity at {} with data: {}", p_147273_1_.func_179823_a(), p_147273_1_.func_148857_g()); -+ return; -+ } -+ tileentity.onDataPacket(field_147302_e, p_147273_1_); - } - - } -@@ -1299,6 +_,7 @@ - clientrecipebook.func_243196_a(this.field_199528_o.func_199510_b()); - clientrecipebook.func_199642_d().forEach(imutablesearchtree::func_217872_a); - imutablesearchtree.func_194040_a(); -+ net.minecraftforge.client.ForgeHooksClient.onRecipesUpdated(this.field_199528_o); - } - - public void func_200232_a(SPlayerLookPacket p_200232_1_) { -@@ -1376,7 +_,7 @@ - PacketThreadUtil.func_218797_a(p_147260_1_, this, this.field_147299_f); - Entity entity = this.field_147300_g.func_73045_a(p_147260_1_.func_149426_d()); - if (entity instanceof LivingEntity) { -- Effect effect = Effect.func_188412_a(p_147260_1_.func_149427_e()); -+ Effect effect = Effect.func_188412_a(p_147260_1_.func_149427_e() & 0xFF); - if (effect != null) { - EffectInstance effectinstance = new EffectInstance(effect, p_147260_1_.func_180755_e(), p_147260_1_.func_149428_f(), p_147260_1_.func_186984_g(), p_147260_1_.func_179707_f(), p_147260_1_.func_205527_h()); - effectinstance.func_100012_b(p_147260_1_.func_149429_c()); -@@ -1388,11 +_,14 @@ - public void func_199723_a(STagsListPacket p_199723_1_) { - PacketThreadUtil.func_218797_a(p_199723_1_, this, this.field_147299_f); - ITagCollectionSupplier itagcollectionsupplier = p_199723_1_.func_199858_a(); -- Multimap multimap = TagRegistryManager.func_242198_b(itagcollectionsupplier); -+ boolean vanillaConnection = net.minecraftforge.fml.network.NetworkHooks.isVanillaConnection(field_147302_e); -+ Multimap multimap = vanillaConnection ? TagRegistryManager.func_242198_b(net.minecraftforge.common.ForgeTagHandler.withNoCustom(itagcollectionsupplier)) : TagRegistryManager.validateVanillaTags(itagcollectionsupplier);//Forge: If we are connecting to vanilla validate all tags to properly validate custom tags the client may "require", and if we are connecting to forge only validate the vanilla tag types as the custom tag types get synced in a separate packet so may still arrive - if (!multimap.isEmpty()) { - field_147301_d.warn("Incomplete server tags, disconnecting. Missing: {}", (Object)multimap); - this.field_147302_e.func_150718_a(new TranslationTextComponent("multiplayer.disconnect.missing_tags")); - } else { -+ net.minecraftforge.common.ForgeTagHandler.resetCachedTagCollections(true, vanillaConnection); -+ itagcollectionsupplier = ITagCollectionSupplier.reinjectOptionalTags(itagcollectionsupplier); - this.field_199725_m = itagcollectionsupplier; - if (!this.field_147302_e.func_150731_c()) { - itagcollectionsupplier.func_242212_e(); -@@ -1885,10 +_,12 @@ - int l5 = packetbuffer.readInt(); - this.field_147299_f.field_184132_p.field_229018_q_.func_229022_a_(blockpos8, l3, s10, l5); - } else { -- field_147301_d.warn("Unknown custom packed identifier: {}", (Object)resourcelocation); -+ if (!net.minecraftforge.fml.network.NetworkHooks.onCustomPayload(p_147240_1_, this.field_147302_e)) -+ field_147301_d.warn("Unknown custom packet identifier: {}", (Object)resourcelocation); - } - } finally { - if (packetbuffer != null) { -+ if (false) // Forge: let packet handle releasing buffer - packetbuffer.release(); - } - diff --git a/patches/minecraft/net/minecraft/client/network/play/NetworkPlayerInfo.java.patch b/patches/minecraft/net/minecraft/client/network/play/NetworkPlayerInfo.java.patch deleted file mode 100644 index e0ee3cdbda..0000000000 --- a/patches/minecraft/net/minecraft/client/network/play/NetworkPlayerInfo.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/client/network/play/NetworkPlayerInfo.java -+++ b/net/minecraft/client/network/play/NetworkPlayerInfo.java -@@ -50,6 +_,7 @@ - } - - protected void func_178839_a(GameType p_178839_1_) { -+ net.minecraftforge.client.ForgeHooksClient.onClientChangeGameMode(this, this.field_178866_b, p_178839_1_); - this.field_178866_b = p_178839_1_; - } - diff --git a/patches/minecraft/net/minecraft/client/particle/DiggingParticle.java.patch b/patches/minecraft/net/minecraft/client/particle/DiggingParticle.java.patch deleted file mode 100644 index d5ab7fb64d..0000000000 --- a/patches/minecraft/net/minecraft/client/particle/DiggingParticle.java.patch +++ /dev/null @@ -1,25 +0,0 @@ ---- a/net/minecraft/client/particle/DiggingParticle.java -+++ b/net/minecraft/client/particle/DiggingParticle.java -@@ -36,6 +_,7 @@ - } - - public DiggingParticle func_174846_a(BlockPos p_174846_1_) { -+ updateSprite(p_174846_1_); - this.field_181019_az = p_174846_1_; - if (this.field_174847_a.func_203425_a(Blocks.field_196658_i)) { - return this; -@@ -92,7 +_,13 @@ - public static class Factory implements IParticleFactory { - public Particle func_199234_a(BlockParticleData p_199234_1_, ClientWorld p_199234_2_, double p_199234_3_, double p_199234_5_, double p_199234_7_, double p_199234_9_, double p_199234_11_, double p_199234_13_) { - BlockState blockstate = p_199234_1_.func_197584_c(); -- return !blockstate.func_196958_f() && !blockstate.func_203425_a(Blocks.field_196603_bb) ? (new DiggingParticle(p_199234_2_, p_199234_3_, p_199234_5_, p_199234_7_, p_199234_9_, p_199234_11_, p_199234_13_, blockstate)).func_174845_l() : null; -+ return !blockstate.func_196958_f() && !blockstate.func_203425_a(Blocks.field_196603_bb) ? (new DiggingParticle(p_199234_2_, p_199234_3_, p_199234_5_, p_199234_7_, p_199234_9_, p_199234_11_, p_199234_13_, blockstate)).func_174845_l().updateSprite(p_199234_1_.getPos()) : null; - } -+ } -+ -+ private Particle updateSprite(BlockPos pos) { //FORGE: we cannot assume that the x y z of the particles match the block pos of the block. -+ if (pos != null) // There are cases where we are not able to obtain the correct source pos, and need to fallback to the non-model data version -+ this.func_217567_a(Minecraft.func_71410_x().func_175602_ab().func_175023_a().getTexture(field_174847_a, field_187122_b, pos)); -+ return this; - } - } diff --git a/patches/minecraft/net/minecraft/client/particle/Particle.java.patch b/patches/minecraft/net/minecraft/client/particle/Particle.java.patch index 3d1feb2ede..db479a31e3 100644 --- a/patches/minecraft/net/minecraft/client/particle/Particle.java.patch +++ b/patches/minecraft/net/minecraft/client/particle/Particle.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/client/particle/Particle.java +++ b/net/minecraft/client/particle/Particle.java -@@ -208,4 +_,12 @@ - public void func_187108_a(AxisAlignedBB p_187108_1_) { - this.field_187120_G = p_187108_1_; +@@ -226,4 +_,12 @@ + public Optional m_142654_() { + return Optional.empty(); } + -+ /** -+ * Forge added method that controls if a particle should be culled to it's bounding box. -+ * Default behaviour is culling enabled -+ */ -+ public boolean shouldCull() { -+ return true; -+ } ++ /** ++ * Forge added method that controls if a particle should be culled to it's bounding box. ++ * Default behaviour is culling enabled ++ */ ++ public boolean shouldCull() { ++ return true; ++ } } diff --git a/patches/minecraft/net/minecraft/client/particle/ParticleEngine.java.patch b/patches/minecraft/net/minecraft/client/particle/ParticleEngine.java.patch new file mode 100644 index 0000000000..ae07076a48 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/particle/ParticleEngine.java.patch @@ -0,0 +1,90 @@ +--- a/net/minecraft/client/particle/ParticleEngine.java ++++ b/net/minecraft/client/particle/ParticleEngine.java +@@ -70,7 +_,7 @@ + private final Queue f_107290_ = Queues.newArrayDeque(); + private final TextureManager f_107291_; + private final Random f_107292_ = new Random(); +- private final Int2ObjectMap> f_107293_ = new Int2ObjectOpenHashMap<>(); ++ private final Map> f_107293_ = new java.util.HashMap<>(); + private final Queue f_107294_ = Queues.newArrayDeque(); + private final Map f_107295_ = Maps.newHashMap(); + private final TextureAtlas f_107296_; +@@ -177,13 +_,13 @@ + } + + public void m_107381_(ParticleType p_107382_, ParticleProvider p_107383_) { +- this.f_107293_.put(Registry.f_122829_.m_7447_(p_107382_), p_107383_); ++ this.f_107293_.put(Registry.f_122829_.m_7981_(p_107382_), p_107383_); + } + + public void m_107378_(ParticleType p_107379_, ParticleEngine.SpriteParticleRegistration p_107380_) { + ParticleEngine.MutableSpriteSet particleengine$mutablespriteset = new ParticleEngine.MutableSpriteSet(); + this.f_107295_.put(Registry.f_122829_.m_7981_(p_107379_), particleengine$mutablespriteset); +- this.f_107293_.put(Registry.f_122829_.m_7447_(p_107379_), p_107380_.m_107419_(particleengine$mutablespriteset)); ++ this.f_107293_.put(Registry.f_122829_.m_7981_(p_107379_), p_107380_.m_107419_(particleengine$mutablespriteset)); + } + + public CompletableFuture m_5540_(PreparableReloadListener.PreparationBarrier p_107305_, ResourceManager p_107306_, ProfilerFiller p_107307_, ProfilerFiller p_107308_, Executor p_107309_, Executor p_107310_) { +@@ -301,7 +_,7 @@ + + @Nullable + private Particle m_107395_(T p_107396_, double p_107397_, double p_107398_, double p_107399_, double p_107400_, double p_107401_, double p_107402_) { +- ParticleProvider particleprovider = (ParticleProvider)this.f_107293_.get(Registry.f_122829_.m_7447_(p_107396_.m_6012_())); ++ ParticleProvider particleprovider = (ParticleProvider)this.f_107293_.get(Registry.f_122829_.m_7981_(p_107396_.m_6012_())); + return particleprovider == null ? null : particleprovider.m_6966_(p_107396_, this.f_107287_, p_107397_, p_107398_, p_107399_, p_107400_, p_107401_, p_107402_); + } + +@@ -382,7 +_,13 @@ + } + } + ++ /**@deprecated Forge: use {@link #render(PoseStack, MultiBufferSource.BufferSource, LightTexture, Camera, float, net.minecraft.client.renderer.culling.Frustum)} with Frustum as additional parameter*/ ++ @Deprecated + public void m_107336_(PoseStack p_107337_, MultiBufferSource.BufferSource p_107338_, LightTexture p_107339_, Camera p_107340_, float p_107341_) { ++ render(p_107337_, p_107338_, p_107339_, p_107340_, p_107341_, null); ++ } ++ ++ public void render(PoseStack p_107337_, MultiBufferSource.BufferSource p_107338_, LightTexture p_107339_, Camera p_107340_, float p_107341_, @Nullable net.minecraft.client.renderer.culling.Frustum clippingHelper) { + p_107339_.m_109896_(); + RenderSystem.m_69482_(); + PoseStack posestack = RenderSystem.m_157191_(); +@@ -390,7 +_,8 @@ + posestack.m_166854_(p_107337_.m_85850_().m_85861_()); + RenderSystem.m_157182_(); + +- for(ParticleRenderType particlerendertype : f_107288_) { ++ for(ParticleRenderType particlerendertype : this.f_107289_.keySet()) { // Forge: allow custom IParticleRenderType's ++ if (particlerendertype == ParticleRenderType.f_107434_) continue; + Iterable iterable = this.f_107289_.get(particlerendertype); + if (iterable != null) { + RenderSystem.m_157427_(GameRenderer::m_172829_); +@@ -400,6 +_,7 @@ + particlerendertype.m_6505_(bufferbuilder, this.f_107291_); + + for(Particle particle : iterable) { ++ if (clippingHelper != null && particle.shouldCull() && !clippingHelper.m_113029_(particle.m_107277_())) continue; + try { + particle.m_5744_(bufferbuilder, p_107340_, p_107341_); + } catch (Throwable throwable) { +@@ -430,7 +_,7 @@ + } + + public void m_107355_(BlockPos p_107356_, BlockState p_107357_) { +- if (!p_107357_.m_60795_()) { ++ if (!p_107357_.m_60795_() && !net.minecraftforge.client.RenderProperties.get(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; + voxelshape.m_83286_((p_172273_, p_172274_, p_172275_, p_172276_, p_172277_, p_172278_) -> { +@@ -500,6 +_,12 @@ + + public String m_107403_() { + return String.valueOf(this.f_107289_.values().stream().mapToInt(Collection::size).sum()); ++ } ++ ++ public void addBlockHitEffects(BlockPos pos, net.minecraft.world.phys.BlockHitResult target) { ++ BlockState state = f_107287_.m_8055_(pos); ++ if (!net.minecraftforge.client.RenderProperties.get(state).addHitEffects(state, f_107287_, target, this)) ++ m_107367_(pos, target.m_82434_()); + } + + private boolean m_172279_(ParticleGroup p_172280_) { diff --git a/patches/minecraft/net/minecraft/client/particle/ParticleManager.java.patch b/patches/minecraft/net/minecraft/client/particle/ParticleManager.java.patch deleted file mode 100644 index cc3538b3c5..0000000000 --- a/patches/minecraft/net/minecraft/client/particle/ParticleManager.java.patch +++ /dev/null @@ -1,97 +0,0 @@ ---- a/net/minecraft/client/particle/ParticleManager.java -+++ b/net/minecraft/client/particle/ParticleManager.java -@@ -65,7 +_,7 @@ - private final Queue field_178933_d = Queues.newArrayDeque(); - private final TextureManager field_78877_c; - private final Random field_78875_d = new Random(); -- private final Int2ObjectMap> field_178932_g = new Int2ObjectOpenHashMap<>(); -+ private final Map> field_178932_g = new java.util.HashMap<>(); - private final Queue field_187241_h = Queues.newArrayDeque(); - private final Map field_215242_i = Maps.newHashMap(); - private final AtlasTexture field_215243_j = new AtlasTexture(AtlasTexture.field_215262_g); -@@ -153,13 +_,13 @@ - } - - public void func_199283_a(ParticleType p_199283_1_, IParticleFactory p_199283_2_) { -- this.field_178932_g.put(Registry.field_212632_u.func_148757_b(p_199283_1_), p_199283_2_); -+ this.field_178932_g.put(Registry.field_212632_u.func_177774_c(p_199283_1_), p_199283_2_); - } - - public void func_215234_a(ParticleType p_215234_1_, ParticleManager.IParticleMetaFactory p_215234_2_) { - ParticleManager.AnimatedSpriteImpl particlemanager$animatedspriteimpl = new ParticleManager.AnimatedSpriteImpl(); - this.field_215242_i.put(Registry.field_212632_u.func_177774_c(p_215234_1_), particlemanager$animatedspriteimpl); -- this.field_178932_g.put(Registry.field_212632_u.func_148757_b(p_215234_1_), p_215234_2_.create(particlemanager$animatedspriteimpl)); -+ this.field_178932_g.put(Registry.field_212632_u.func_177774_c(p_215234_1_), p_215234_2_.create(particlemanager$animatedspriteimpl)); - } - - public CompletableFuture func_215226_a(IFutureReloadListener.IStage p_215226_1_, IResourceManager p_215226_2_, IProfiler p_215226_3_, IProfiler p_215226_4_, Executor p_215226_5_, Executor p_215226_6_) { -@@ -248,7 +_,7 @@ - - @Nullable - private Particle func_199927_b(T p_199927_1_, double p_199927_2_, double p_199927_4_, double p_199927_6_, double p_199927_8_, double p_199927_10_, double p_199927_12_) { -- IParticleFactory iparticlefactory = (IParticleFactory)this.field_178932_g.get(Registry.field_212632_u.func_148757_b(p_199927_1_.func_197554_b())); -+ IParticleFactory iparticlefactory = (IParticleFactory)this.field_178932_g.get(Registry.field_212632_u.func_177774_c(p_199927_1_.func_197554_b())); - return iparticlefactory == null ? null : iparticlefactory.func_199234_a(p_199927_1_, this.field_78878_a, p_199927_2_, p_199927_4_, p_199927_6_, p_199927_8_, p_199927_10_, p_199927_12_); - } - -@@ -313,16 +_,29 @@ - } - } - -+ /**@deprecated Forge: use {@link #renderParticles(MatrixStack, IRenderTypeBuffer.Impl, LightTexture, ActiveRenderInfo, float, net.minecraft.client.renderer.culling.ClippingHelper)} with ClippingHelper as additional parameter*/ -+ @Deprecated - public void func_228345_a_(MatrixStack p_228345_1_, IRenderTypeBuffer.Impl p_228345_2_, LightTexture p_228345_3_, ActiveRenderInfo p_228345_4_, float p_228345_5_) { -+ renderParticles(p_228345_1_, p_228345_2_, p_228345_3_, p_228345_4_, p_228345_5_, null); -+ } -+ -+ public void renderParticles(MatrixStack p_228345_1_, IRenderTypeBuffer.Impl p_228345_2_, LightTexture p_228345_3_, ActiveRenderInfo p_228345_4_, float p_228345_5_, @Nullable net.minecraft.client.renderer.culling.ClippingHelper clippingHelper) { - p_228345_3_.func_205109_c(); -+ Runnable enable = () -> { - RenderSystem.enableAlphaTest(); - RenderSystem.defaultAlphaFunc(); - RenderSystem.enableDepthTest(); - RenderSystem.enableFog(); -+ RenderSystem.activeTexture(org.lwjgl.opengl.GL13.GL_TEXTURE2); -+ RenderSystem.enableTexture(); -+ RenderSystem.activeTexture(org.lwjgl.opengl.GL13.GL_TEXTURE0); -+ }; - RenderSystem.pushMatrix(); - RenderSystem.multMatrix(p_228345_1_.func_227866_c_().func_227870_a_()); - -- for(IParticleRenderType iparticlerendertype : field_215241_b) { -+ for(IParticleRenderType iparticlerendertype : this.field_78876_b.keySet()) { // Forge: allow custom IParticleRenderType's -+ if (iparticlerendertype == IParticleRenderType.field_217606_f) continue; -+ enable.run(); //Forge: MC-168672 Make sure all render types have the correct GL state. - Iterable iterable = this.field_78876_b.get(iparticlerendertype); - if (iterable != null) { - RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); -@@ -331,6 +_,7 @@ - iparticlerendertype.func_217600_a(bufferbuilder, this.field_78877_c); - - for(Particle particle : iterable) { -+ if (clippingHelper != null && particle.shouldCull() && !clippingHelper.func_228957_a_(particle.func_187116_l())) continue; - try { - particle.func_225606_a_(bufferbuilder, p_228345_4_, p_228345_5_); - } catch (Throwable throwable) { -@@ -362,7 +_,7 @@ - } - - public void func_180533_a(BlockPos p_180533_1_, BlockState p_180533_2_) { -- if (!p_180533_2_.func_196958_f()) { -+ if (!p_180533_2_.isAir(this.field_78878_a, p_180533_1_) && !p_180533_2_.addDestroyEffects(this.field_78878_a, p_180533_1_, this)) { - VoxelShape voxelshape = p_180533_2_.func_196954_c(this.field_78878_a, p_180533_1_); - double d0 = 0.25D; - voxelshape.func_197755_b((p_228348_3_, p_228348_5_, p_228348_7_, p_228348_9_, p_228348_11_, p_228348_13_) -> { -@@ -432,6 +_,12 @@ - - public String func_78869_b() { - return String.valueOf(this.field_78876_b.values().stream().mapToInt(Collection::size).sum()); -+ } -+ -+ public void addBlockHitEffects(BlockPos pos, net.minecraft.util.math.BlockRayTraceResult target) { -+ BlockState state = field_78878_a.func_180495_p(pos); -+ if (!state.addHitEffects(field_78878_a, target, this)) -+ func_180532_a(pos, target.func_216354_b()); - } - - @OnlyIn(Dist.CLIENT) diff --git a/patches/minecraft/net/minecraft/client/particle/TerrainParticle.java.patch b/patches/minecraft/net/minecraft/client/particle/TerrainParticle.java.patch new file mode 100644 index 0000000000..63c3814a7a --- /dev/null +++ b/patches/minecraft/net/minecraft/client/particle/TerrainParticle.java.patch @@ -0,0 +1,17 @@ +--- a/net/minecraft/client/particle/TerrainParticle.java ++++ b/net/minecraft/client/particle/TerrainParticle.java +@@ -69,7 +_,13 @@ + 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_) ? (new TerrainParticle(p_108305_, p_108306_, p_108307_, p_108308_, p_108309_, p_108310_, p_108311_, blockstate)).updateSprite(blockstate, p_108304_.getPos()) : null; + } ++ } ++ ++ private Particle updateSprite(BlockState state, BlockPos pos) { //FORGE: we cannot assume that the x y z of the particles match the block pos of the block. ++ if (pos != null) // There are cases where we are not able to obtain the correct source pos, and need to fallback to the non-model data version ++ this.m_108337_(Minecraft.m_91087_().m_91289_().m_110907_().getTexture(state, f_107208_, pos)); ++ return this; + } + } diff --git a/patches/minecraft/net/minecraft/client/player/AbstractClientPlayer.java.patch b/patches/minecraft/net/minecraft/client/player/AbstractClientPlayer.java.patch new file mode 100644 index 0000000000..06dcfcda83 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/player/AbstractClientPlayer.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/client/player/AbstractClientPlayer.java ++++ b/net/minecraft/client/player/AbstractClientPlayer.java +@@ -143,6 +_,6 @@ + } + } + +- return Mth.m_14179_(Minecraft.m_91087_().f_91066_.f_92070_, 1.0F, f); ++ return net.minecraftforge.client.ForgeHooksClient.getOffsetFOV(this, f); + } + } diff --git a/patches/minecraft/net/minecraft/client/player/LocalPlayer.java.patch b/patches/minecraft/net/minecraft/client/player/LocalPlayer.java.patch new file mode 100644 index 0000000000..9552df67f8 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/player/LocalPlayer.java.patch @@ -0,0 +1,58 @@ +--- a/net/minecraft/client/player/LocalPlayer.java ++++ b/net/minecraft/client/player/LocalPlayer.java +@@ -139,6 +_,7 @@ + } + + public boolean m_6469_(DamageSource p_108662_, float p_108663_) { ++ net.minecraftforge.common.ForgeHooks.onPlayerAttack(this, p_108662_, p_108663_); + return false; + } + +@@ -462,6 +_,11 @@ + } + + public void m_5496_(SoundEvent p_108651_, float p_108652_, float p_108653_) { ++ net.minecraftforge.event.entity.PlaySoundAtEntityEvent event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtEntity(this, p_108651_, this.m_5720_(), p_108652_, p_108653_); ++ if (event.isCanceled() || event.getSound() == null) return; ++ p_108651_ = event.getSound(); ++ p_108652_ = event.getVolume(); ++ p_108653_ = event.getPitch(); + this.f_19853_.m_7785_(this.m_20185_(), this.m_20186_(), this.m_20189_(), p_108651_, this.m_5720_(), p_108652_, p_108653_, false); + } + +@@ -617,6 +_,7 @@ + boolean flag2 = this.m_108733_(); + 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)); + this.f_108618_.m_7606_(this.m_108635_()); ++ net.minecraftforge.client.ForgeHooksClient.onInputUpdate(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; +@@ -689,7 +_,7 @@ + + if (this.f_108618_.f_108572_ && !flag7 && !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)); + } + } +@@ -1004,6 +_,18 @@ + } else { + return super.m_7398_(p_108758_); + } ++ } ++ ++ public void updateSyncFields(LocalPlayer old) { ++ this.f_108595_ = old.f_108595_; ++ this.f_108596_ = old.f_108596_; ++ this.f_108597_ = old.f_108597_; ++ this.f_108598_ = old.f_108598_; ++ this.f_108599_ = old.f_108599_; ++ this.f_108600_ = old.f_108600_; ++ this.f_108602_ = old.f_108602_; ++ this.f_108603_ = old.f_108603_; ++ this.f_108604_ = old.f_108604_; + } + + public void m_141945_(ItemStack p_172532_, ItemStack p_172533_, ClickAction p_172534_) { diff --git a/patches/minecraft/net/minecraft/client/player/RemotePlayer.java.patch b/patches/minecraft/net/minecraft/client/player/RemotePlayer.java.patch new file mode 100644 index 0000000000..e838305c87 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/player/RemotePlayer.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/client/player/RemotePlayer.java ++++ b/net/minecraft/client/player/RemotePlayer.java +@@ -29,6 +_,7 @@ + } + + public boolean m_6469_(DamageSource p_108772_, float p_108773_) { ++ net.minecraftforge.common.ForgeHooks.onPlayerAttack(this, p_108772_, p_108773_); + return true; + } + diff --git a/patches/minecraft/net/minecraft/client/renderer/ActiveRenderInfo.java.patch b/patches/minecraft/net/minecraft/client/renderer/ActiveRenderInfo.java.patch deleted file mode 100644 index c8dbf6dc05..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/ActiveRenderInfo.java.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- a/net/minecraft/client/renderer/ActiveRenderInfo.java -+++ b/net/minecraft/client/renderer/ActiveRenderInfo.java -@@ -170,4 +_,16 @@ - this.field_216791_c = null; - this.field_216789_a = false; - } -+ -+ public void setAnglesInternal(float yaw, float pitch) { -+ this.field_216798_j = yaw; -+ this.field_216797_i = pitch; -+ } -+ -+ public net.minecraft.block.BlockState getBlockAtCamera() { -+ if (!this.field_216789_a) -+ return net.minecraft.block.Blocks.field_150350_a.func_176223_P(); -+ else -+ return this.field_216790_b.func_180495_p(this.field_216793_e).getStateAtViewpoint(this.field_216790_b, this.field_216793_e, this.field_216792_d); -+ } - } diff --git a/patches/minecraft/net/minecraft/client/renderer/Atlases.java.patch b/patches/minecraft/net/minecraft/client/renderer/Atlases.java.patch deleted file mode 100644 index 27380db9cc..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/Atlases.java.patch +++ /dev/null @@ -1,25 +0,0 @@ ---- a/net/minecraft/client/renderer/Atlases.java -+++ b/net/minecraft/client/renderer/Atlases.java -@@ -129,7 +_,8 @@ - } - - public static RenderMaterial func_228773_a_(WoodType p_228773_0_) { -- return new RenderMaterial(field_228746_e_, new ResourceLocation("entity/signs/" + p_228773_0_.func_227048_b_())); -+ ResourceLocation location = new ResourceLocation(p_228773_0_.func_227048_b_()); -+ return new RenderMaterial(field_228746_e_, new ResourceLocation(location.func_110624_b(), "entity/signs/" + location.func_110623_a())); - } - - private static RenderMaterial func_228774_a_(String p_228774_0_) { -@@ -156,5 +_,12 @@ - default: - return p_228772_1_; - } -+ } -+ -+ /** -+ * Not threadsafe. Enqueue it in client setup. -+ */ -+ public static void addWoodType(WoodType woodType) { -+ field_228750_i_.put(woodType, func_228773_a_(woodType)); - } - } diff --git a/patches/minecraft/net/minecraft/client/renderer/BlockModelRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/BlockModelRenderer.java.patch deleted file mode 100644 index 0f5fb29524..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/BlockModelRenderer.java.patch +++ /dev/null @@ -1,125 +0,0 @@ ---- a/net/minecraft/client/renderer/BlockModelRenderer.java -+++ b/net/minecraft/client/renderer/BlockModelRenderer.java -@@ -37,65 +_,78 @@ - this.field_187499_a = p_i46575_1_; - } - -+ @Deprecated //Forge: Model data argument - public boolean func_228802_a_(IBlockDisplayReader p_228802_1_, IBakedModel p_228802_2_, BlockState p_228802_3_, BlockPos p_228802_4_, MatrixStack p_228802_5_, IVertexBuilder p_228802_6_, boolean p_228802_7_, Random p_228802_8_, long p_228802_9_, int p_228802_11_) { -- boolean flag = Minecraft.func_71379_u() && p_228802_3_.func_185906_d() == 0 && p_228802_2_.func_177555_b(); -- Vector3d vector3d = p_228802_3_.func_191059_e(p_228802_1_, p_228802_4_); -- p_228802_5_.func_227861_a_(vector3d.field_72450_a, vector3d.field_72448_b, vector3d.field_72449_c); -+ return renderModel(p_228802_1_, p_228802_2_, p_228802_3_, p_228802_4_, p_228802_5_, p_228802_6_, p_228802_7_, p_228802_8_, p_228802_9_, p_228802_11_, net.minecraftforge.client.model.data.EmptyModelData.INSTANCE); -+ } -+ public boolean renderModel(IBlockDisplayReader worldIn, IBakedModel modelIn, BlockState stateIn, BlockPos posIn, MatrixStack matrixIn, IVertexBuilder buffer, boolean checkSides, Random randomIn, long rand, int combinedOverlayIn, net.minecraftforge.client.model.data.IModelData modelData) { -+ boolean flag = Minecraft.func_71379_u() && stateIn.getLightValue(worldIn, posIn) == 0 && modelIn.func_177555_b(); -+ Vector3d vector3d = stateIn.func_191059_e(worldIn, posIn); -+ matrixIn.func_227861_a_(vector3d.field_72450_a, vector3d.field_72448_b, vector3d.field_72449_c); -+ modelData = modelIn.getModelData(worldIn, posIn, stateIn, modelData); - - try { -- return flag ? this.func_228805_b_(p_228802_1_, p_228802_2_, p_228802_3_, p_228802_4_, p_228802_5_, p_228802_6_, p_228802_7_, p_228802_8_, p_228802_9_, p_228802_11_) : this.func_228806_c_(p_228802_1_, p_228802_2_, p_228802_3_, p_228802_4_, p_228802_5_, p_228802_6_, p_228802_7_, p_228802_8_, p_228802_9_, p_228802_11_); -+ return flag ? this.renderModelSmooth(worldIn, modelIn, stateIn, posIn, matrixIn, buffer, checkSides, randomIn, rand, combinedOverlayIn, modelData) : this.renderModelFlat(worldIn, modelIn, stateIn, posIn, matrixIn, buffer, checkSides, randomIn, rand, combinedOverlayIn, modelData); - } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.func_85055_a(throwable, "Tesselating block model"); - CrashReportCategory crashreportcategory = crashreport.func_85058_a("Block model being tesselated"); -- CrashReportCategory.func_175750_a(crashreportcategory, p_228802_4_, p_228802_3_); -+ CrashReportCategory.func_175750_a(crashreportcategory, posIn, stateIn); - crashreportcategory.func_71507_a("Using AO", flag); - throw new ReportedException(crashreport); - } - } - -+ @Deprecated //Forge: Model data argument - public boolean func_228805_b_(IBlockDisplayReader p_228805_1_, IBakedModel p_228805_2_, BlockState p_228805_3_, BlockPos p_228805_4_, MatrixStack p_228805_5_, IVertexBuilder p_228805_6_, boolean p_228805_7_, Random p_228805_8_, long p_228805_9_, int p_228805_11_) { -+ return renderModelSmooth(p_228805_1_, p_228805_2_, p_228805_3_, p_228805_4_, p_228805_5_, p_228805_6_, p_228805_7_, p_228805_8_, p_228805_9_, p_228805_11_, net.minecraftforge.client.model.data.EmptyModelData.INSTANCE); -+ } -+ public boolean renderModelSmooth(IBlockDisplayReader worldIn, IBakedModel modelIn, BlockState stateIn, BlockPos posIn, MatrixStack matrixStackIn, IVertexBuilder buffer, boolean checkSides, Random randomIn, long rand, int combinedOverlayIn, net.minecraftforge.client.model.data.IModelData modelData) { - boolean flag = false; - float[] afloat = new float[Direction.values().length * 2]; - BitSet bitset = new BitSet(3); - BlockModelRenderer.AmbientOcclusionFace blockmodelrenderer$ambientocclusionface = new BlockModelRenderer.AmbientOcclusionFace(); - - for(Direction direction : Direction.values()) { -- p_228805_8_.setSeed(p_228805_9_); -- List list = p_228805_2_.func_200117_a(p_228805_3_, direction, p_228805_8_); -- if (!list.isEmpty() && (!p_228805_7_ || Block.func_176225_a(p_228805_3_, p_228805_1_, p_228805_4_, direction))) { -- this.func_228799_a_(p_228805_1_, p_228805_3_, p_228805_4_, p_228805_5_, p_228805_6_, list, afloat, bitset, blockmodelrenderer$ambientocclusionface, p_228805_11_); -+ randomIn.setSeed(rand); -+ List list = modelIn.getQuads(stateIn, direction, randomIn, modelData); -+ if (!list.isEmpty() && (!checkSides || Block.func_176225_a(stateIn, worldIn, posIn, direction))) { -+ this.func_228799_a_(worldIn, stateIn, posIn, matrixStackIn, buffer, list, afloat, bitset, blockmodelrenderer$ambientocclusionface, combinedOverlayIn); - flag = true; - } - } - -- p_228805_8_.setSeed(p_228805_9_); -- List list1 = p_228805_2_.func_200117_a(p_228805_3_, (Direction)null, p_228805_8_); -+ randomIn.setSeed(rand); -+ List list1 = modelIn.getQuads(stateIn, (Direction)null, randomIn, modelData); - if (!list1.isEmpty()) { -- this.func_228799_a_(p_228805_1_, p_228805_3_, p_228805_4_, p_228805_5_, p_228805_6_, list1, afloat, bitset, blockmodelrenderer$ambientocclusionface, p_228805_11_); -+ this.func_228799_a_(worldIn, stateIn, posIn, matrixStackIn, buffer, list1, afloat, bitset, blockmodelrenderer$ambientocclusionface, combinedOverlayIn); - flag = true; - } - - return flag; - } - -+ @Deprecated //Forge: Model data argument - public boolean func_228806_c_(IBlockDisplayReader p_228806_1_, IBakedModel p_228806_2_, BlockState p_228806_3_, BlockPos p_228806_4_, MatrixStack p_228806_5_, IVertexBuilder p_228806_6_, boolean p_228806_7_, Random p_228806_8_, long p_228806_9_, int p_228806_11_) { -+ return renderModelFlat(p_228806_1_, p_228806_2_, p_228806_3_, p_228806_4_, p_228806_5_, p_228806_6_, p_228806_7_, p_228806_8_, p_228806_9_, p_228806_11_, net.minecraftforge.client.model.data.EmptyModelData.INSTANCE); -+ } -+ public boolean renderModelFlat(IBlockDisplayReader worldIn, IBakedModel modelIn, BlockState stateIn, BlockPos posIn, MatrixStack matrixStackIn, IVertexBuilder buffer, boolean checkSides, Random randomIn, long rand, int combinedOverlayIn, net.minecraftforge.client.model.data.IModelData modelData) { - boolean flag = false; - BitSet bitset = new BitSet(3); - - for(Direction direction : Direction.values()) { -- p_228806_8_.setSeed(p_228806_9_); -- List list = p_228806_2_.func_200117_a(p_228806_3_, direction, p_228806_8_); -- if (!list.isEmpty() && (!p_228806_7_ || Block.func_176225_a(p_228806_3_, p_228806_1_, p_228806_4_, direction))) { -- int i = WorldRenderer.func_228420_a_(p_228806_1_, p_228806_3_, p_228806_4_.func_177972_a(direction)); -- this.func_228798_a_(p_228806_1_, p_228806_3_, p_228806_4_, i, p_228806_11_, false, p_228806_5_, p_228806_6_, list, bitset); -+ randomIn.setSeed(rand); -+ List list = modelIn.getQuads(stateIn, direction, randomIn, modelData); -+ if (!list.isEmpty() && (!checkSides || Block.func_176225_a(stateIn, worldIn, posIn, direction))) { -+ int i = WorldRenderer.func_228420_a_(worldIn, stateIn, posIn.func_177972_a(direction)); -+ this.func_228798_a_(worldIn, stateIn, posIn, i, combinedOverlayIn, false, matrixStackIn, buffer, list, bitset); - flag = true; - } - } - -- p_228806_8_.setSeed(p_228806_9_); -- List list1 = p_228806_2_.func_200117_a(p_228806_3_, (Direction)null, p_228806_8_); -+ randomIn.setSeed(rand); -+ List list1 = modelIn.getQuads(stateIn, (Direction)null, randomIn, modelData); - if (!list1.isEmpty()) { -- this.func_228798_a_(p_228806_1_, p_228806_3_, p_228806_4_, -1, p_228806_11_, true, p_228806_5_, p_228806_6_, list1, bitset); -+ this.func_228798_a_(worldIn, stateIn, posIn, -1, combinedOverlayIn, true, matrixStackIn, buffer, list1, bitset); - flag = true; - } - -@@ -209,17 +_,21 @@ - - } - -+ @Deprecated //Forge: Model data argument - public void func_228804_a_(MatrixStack.Entry p_228804_1_, IVertexBuilder p_228804_2_, @Nullable BlockState p_228804_3_, IBakedModel p_228804_4_, float p_228804_5_, float p_228804_6_, float p_228804_7_, int p_228804_8_, int p_228804_9_) { -+ renderModel(p_228804_1_, p_228804_2_, p_228804_3_, p_228804_4_, p_228804_5_, p_228804_6_, p_228804_7_, p_228804_8_, p_228804_9_, net.minecraftforge.client.model.data.EmptyModelData.INSTANCE); -+ } -+ public void renderModel(MatrixStack.Entry p_228804_1_, IVertexBuilder p_228804_2_, @Nullable BlockState p_228804_3_, IBakedModel p_228804_4_, float p_228804_5_, float p_228804_6_, float p_228804_7_, int p_228804_8_, int p_228804_9_, net.minecraftforge.client.model.data.IModelData modelData) { - Random random = new Random(); - long i = 42L; - - for(Direction direction : Direction.values()) { - random.setSeed(42L); -- func_228803_a_(p_228804_1_, p_228804_2_, p_228804_5_, p_228804_6_, p_228804_7_, p_228804_4_.func_200117_a(p_228804_3_, direction, random), p_228804_8_, p_228804_9_); -+ func_228803_a_(p_228804_1_, p_228804_2_, p_228804_5_, p_228804_6_, p_228804_7_, p_228804_4_.getQuads(p_228804_3_, direction, random, modelData), p_228804_8_, p_228804_9_); - } - - random.setSeed(42L); -- func_228803_a_(p_228804_1_, p_228804_2_, p_228804_5_, p_228804_6_, p_228804_7_, p_228804_4_.func_200117_a(p_228804_3_, (Direction)null, random), p_228804_8_, p_228804_9_); -+ func_228803_a_(p_228804_1_, p_228804_2_, p_228804_5_, p_228804_6_, p_228804_7_, p_228804_4_.getQuads(p_228804_3_, (Direction)null, random, modelData), p_228804_8_, p_228804_9_); - } - - private static void func_228803_a_(MatrixStack.Entry p_228803_0_, IVertexBuilder p_228803_1_, float p_228803_2_, float p_228803_3_, float p_228803_4_, List p_228803_5_, int p_228803_6_, int p_228803_7_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/BlockModelShapes.java.patch b/patches/minecraft/net/minecraft/client/renderer/BlockModelShapes.java.patch deleted file mode 100644 index c5d92c7956..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/BlockModelShapes.java.patch +++ /dev/null @@ -1,18 +0,0 @@ ---- a/net/minecraft/client/renderer/BlockModelShapes.java -+++ b/net/minecraft/client/renderer/BlockModelShapes.java -@@ -24,8 +_,14 @@ - this.field_178128_c = p_i46245_1_; - } - -+ @Deprecated - public TextureAtlasSprite func_178122_a(BlockState p_178122_1_) { -- return this.func_178125_b(p_178122_1_).func_177554_e(); -+ return this.func_178125_b(p_178122_1_).getParticleTexture(net.minecraftforge.client.model.data.EmptyModelData.INSTANCE); -+ } -+ -+ public TextureAtlasSprite getTexture(BlockState state, net.minecraft.world.World world, net.minecraft.util.math.BlockPos pos) { -+ net.minecraftforge.client.model.data.IModelData data = net.minecraftforge.client.model.ModelDataManager.getModelData(world, pos); -+ return this.func_178125_b(state).getParticleTexture(data == null ? net.minecraftforge.client.model.data.EmptyModelData.INSTANCE : data); - } - - public IBakedModel func_178125_b(BlockState p_178125_1_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/BlockRendererDispatcher.java.patch b/patches/minecraft/net/minecraft/client/renderer/BlockRendererDispatcher.java.patch deleted file mode 100644 index 393fcbee5d..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/BlockRendererDispatcher.java.patch +++ /dev/null @@ -1,86 +0,0 @@ ---- a/net/minecraft/client/renderer/BlockRendererDispatcher.java -+++ b/net/minecraft/client/renderer/BlockRendererDispatcher.java -@@ -33,7 +_,7 @@ - public BlockRendererDispatcher(BlockModelShapes p_i46577_1_, BlockColors p_i46577_2_) { - this.field_175028_a = p_i46577_1_; - this.field_228790_e_ = p_i46577_2_; -- this.field_175027_c = new BlockModelRenderer(this.field_228790_e_); -+ this.field_175027_c = new net.minecraftforge.client.model.pipeline.ForgeBlockModelRenderer(this.field_228790_e_); - this.field_175025_e = new FluidBlockRenderer(); - } - -@@ -41,22 +_,30 @@ - return this.field_175028_a; - } - -+ @Deprecated //Forge: Model parameter - public void func_228792_a_(BlockState p_228792_1_, BlockPos p_228792_2_, IBlockDisplayReader p_228792_3_, MatrixStack p_228792_4_, IVertexBuilder p_228792_5_) { -- if (p_228792_1_.func_185901_i() == BlockRenderType.MODEL) { -- IBakedModel ibakedmodel = this.field_175028_a.func_178125_b(p_228792_1_); -- long i = p_228792_1_.func_209533_a(p_228792_2_); -- this.field_175027_c.func_228802_a_(p_228792_3_, ibakedmodel, p_228792_1_, p_228792_2_, p_228792_4_, p_228792_5_, true, this.field_195476_e, i, OverlayTexture.field_229196_a_); -+ renderBlockDamage(p_228792_1_,p_228792_2_, p_228792_3_, p_228792_4_, p_228792_5_, net.minecraftforge.client.model.data.EmptyModelData.INSTANCE); -+ } -+ public void renderBlockDamage(BlockState blockStateIn, BlockPos posIn, IBlockDisplayReader lightReaderIn, MatrixStack matrixStackIn, IVertexBuilder vertexBuilderIn, net.minecraftforge.client.model.data.IModelData modelData) { -+ if (blockStateIn.func_185901_i() == BlockRenderType.MODEL) { -+ IBakedModel ibakedmodel = this.field_175028_a.func_178125_b(blockStateIn); -+ long i = blockStateIn.func_209533_a(posIn); -+ this.field_175027_c.renderModel(lightReaderIn, ibakedmodel, blockStateIn, posIn, matrixStackIn, vertexBuilderIn, true, this.field_195476_e, i, OverlayTexture.field_229196_a_, modelData); - } - } - -+ @Deprecated //Forge: Model parameter - public boolean func_228793_a_(BlockState p_228793_1_, BlockPos p_228793_2_, IBlockDisplayReader p_228793_3_, MatrixStack p_228793_4_, IVertexBuilder p_228793_5_, boolean p_228793_6_, Random p_228793_7_) { -+ return renderModel(p_228793_1_, p_228793_2_, p_228793_3_, p_228793_4_, p_228793_5_, p_228793_6_, p_228793_7_, net.minecraftforge.client.model.data.EmptyModelData.INSTANCE); -+ } -+ public boolean renderModel(BlockState blockStateIn, BlockPos posIn, IBlockDisplayReader lightReaderIn, MatrixStack matrixStackIn, IVertexBuilder vertexBuilderIn, boolean checkSides, Random rand, net.minecraftforge.client.model.data.IModelData modelData) { - try { -- BlockRenderType blockrendertype = p_228793_1_.func_185901_i(); -- return blockrendertype != BlockRenderType.MODEL ? false : this.field_175027_c.func_228802_a_(p_228793_3_, this.func_184389_a(p_228793_1_), p_228793_1_, p_228793_2_, p_228793_4_, p_228793_5_, p_228793_6_, p_228793_7_, p_228793_1_.func_209533_a(p_228793_2_), OverlayTexture.field_229196_a_); -+ BlockRenderType blockrendertype = blockStateIn.func_185901_i(); -+ return blockrendertype != BlockRenderType.MODEL ? false : this.field_175027_c.renderModel(lightReaderIn, this.func_184389_a(blockStateIn), blockStateIn, posIn, matrixStackIn, vertexBuilderIn, checkSides, rand, blockStateIn.func_209533_a(posIn), OverlayTexture.field_229196_a_, modelData); - } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.func_85055_a(throwable, "Tesselating block in world"); - CrashReportCategory crashreportcategory = crashreport.func_85058_a("Block being tesselated"); -- CrashReportCategory.func_175750_a(crashreportcategory, p_228793_2_, p_228793_1_); -+ CrashReportCategory.func_175750_a(crashreportcategory, posIn, blockStateIn); - throw new ReportedException(crashreport); - } - } -@@ -80,7 +_,11 @@ - return this.field_175028_a.func_178125_b(p_184389_1_); - } - -+ @Deprecated //Forge: Model parameter - public void func_228791_a_(BlockState p_228791_1_, MatrixStack p_228791_2_, IRenderTypeBuffer p_228791_3_, int p_228791_4_, int p_228791_5_) { -+ renderBlock(p_228791_1_, p_228791_2_, p_228791_3_, p_228791_4_, p_228791_5_, net.minecraftforge.client.model.data.EmptyModelData.INSTANCE); -+ } -+ public void renderBlock(BlockState p_228791_1_, MatrixStack p_228791_2_, IRenderTypeBuffer p_228791_3_, int p_228791_4_, int p_228791_5_, net.minecraftforge.client.model.data.IModelData modelData) { - BlockRenderType blockrendertype = p_228791_1_.func_185901_i(); - if (blockrendertype != BlockRenderType.INVISIBLE) { - switch(blockrendertype) { -@@ -90,10 +_,11 @@ - float f = (float)(i >> 16 & 255) / 255.0F; - float f1 = (float)(i >> 8 & 255) / 255.0F; - float f2 = (float)(i & 255) / 255.0F; -- this.field_175027_c.func_228804_a_(p_228791_2_.func_227866_c_(), p_228791_3_.getBuffer(RenderTypeLookup.func_239220_a_(p_228791_1_, false)), p_228791_1_, ibakedmodel, f, f1, f2, p_228791_4_, p_228791_5_); -+ this.field_175027_c.renderModel(p_228791_2_.func_227866_c_(), p_228791_3_.getBuffer(RenderTypeLookup.func_239220_a_(p_228791_1_, false)), p_228791_1_, ibakedmodel, f, f1, f2, p_228791_4_, p_228791_5_, modelData); - break; - case ENTITYBLOCK_ANIMATED: -- ItemStackTileEntityRenderer.field_147719_a.func_239207_a_(new ItemStack(p_228791_1_.func_177230_c()), ItemCameraTransforms.TransformType.NONE, p_228791_2_, p_228791_3_, p_228791_4_, p_228791_5_); -+ ItemStack stack = new ItemStack(p_228791_1_.func_177230_c()); -+ stack.func_77973_b().getItemStackTileEntityRenderer().func_239207_a_(stack, ItemCameraTransforms.TransformType.NONE, p_228791_2_, p_228791_3_, p_228791_4_, p_228791_5_); - } - - } -@@ -101,5 +_,10 @@ - - public void func_195410_a(IResourceManager p_195410_1_) { - this.field_175025_e.func_178268_a(); -+ } -+ -+ @Override -+ public net.minecraftforge.resource.IResourceType getResourceType() { -+ return net.minecraftforge.resource.VanillaResourceType.MODELS; - } - } diff --git a/patches/minecraft/net/minecraft/client/renderer/BufferBuilder.java.patch b/patches/minecraft/net/minecraft/client/renderer/BufferBuilder.java.patch deleted file mode 100644 index 0f73f6e90c..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/BufferBuilder.java.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- a/net/minecraft/client/renderer/BufferBuilder.java -+++ b/net/minecraft/client/renderer/BufferBuilder.java -@@ -297,6 +_,7 @@ - } - - ByteBuffer bytebuffer = this.field_179001_a.slice(); -+ bytebuffer.order(this.field_179001_a.order()); // FORGE: Fix incorrect byte order - ((Buffer)this.field_179001_a).clear(); - return Pair.of(bufferbuilder$drawstate, bytebuffer); - } -@@ -364,4 +_,15 @@ - this.field_179018_e = p_i225907_2_; - } - } -+ -+ // Forge start -+ public void putBulkData(ByteBuffer buffer) { -+ func_181670_b(buffer.limit() + this.field_179011_q.func_177338_f()); -+ ((Buffer)this.field_179001_a).position(this.field_178997_d * this.field_179011_q.func_177338_f()); -+ this.field_179001_a.put(buffer); -+ this.field_178997_d += buffer.limit() / this.field_179011_q.func_177338_f(); -+ this.field_227824_l_ += buffer.limit(); -+ } -+ -+ public VertexFormat getVertexFormat() { return this.field_179011_q; } - } diff --git a/patches/minecraft/net/minecraft/client/world/DimensionRenderInfo.java.patch b/patches/minecraft/net/minecraft/client/renderer/DimensionSpecialEffects.java.patch similarity index 76% rename from patches/minecraft/net/minecraft/client/world/DimensionRenderInfo.java.patch rename to patches/minecraft/net/minecraft/client/renderer/DimensionSpecialEffects.java.patch index 84155dbfcc..bd0131443f 100644 --- a/patches/minecraft/net/minecraft/client/world/DimensionRenderInfo.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/DimensionSpecialEffects.java.patch @@ -1,20 +1,20 @@ ---- a/net/minecraft/client/world/DimensionRenderInfo.java -+++ b/net/minecraft/client/world/DimensionRenderInfo.java +--- a/net/minecraft/client/renderer/DimensionSpecialEffects.java ++++ b/net/minecraft/client/renderer/DimensionSpecialEffects.java @@ -26,6 +_,10 @@ - private final DimensionRenderInfo.FogType field_241680_e_; - private final boolean field_241681_f_; - private final boolean field_239212_e_; + private final DimensionSpecialEffects.SkyType f_108861_; + private final boolean f_108862_; + private final boolean f_108863_; + private net.minecraftforge.client.IWeatherRenderHandler weatherRenderHandler = null; + private net.minecraftforge.client.IWeatherParticleRenderHandler weatherParticleRenderHandler = null; + private net.minecraftforge.client.ISkyRenderHandler skyRenderHandler = null; + private net.minecraftforge.client.ICloudRenderHandler cloudRenderHandler = null; - public DimensionRenderInfo(float p_i241259_1_, boolean p_i241259_2_, DimensionRenderInfo.FogType p_i241259_3_, boolean p_i241259_4_, boolean p_i241259_5_) { - this.field_239210_c_ = p_i241259_1_; + public DimensionSpecialEffects(float p_108866_, boolean p_108867_, DimensionSpecialEffects.SkyType p_108868_, boolean p_108869_, boolean p_108870_) { + this.f_108859_ = p_108866_; @@ -80,6 +_,35 @@ - public boolean func_239217_c_() { - return this.field_239212_e_; + public boolean m_108885_() { + return this.f_108863_; + } + + public void setWeatherRenderHandler(net.minecraftforge.client.IWeatherRenderHandler weatherRenderHandler) { diff --git a/patches/minecraft/net/minecraft/client/renderer/EffectInstance.java.patch b/patches/minecraft/net/minecraft/client/renderer/EffectInstance.java.patch new file mode 100644 index 0000000000..9b6d4d00b1 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/EffectInstance.java.patch @@ -0,0 +1,22 @@ +--- a/net/minecraft/client/renderer/EffectInstance.java ++++ b/net/minecraft/client/renderer/EffectInstance.java +@@ -60,7 +_,8 @@ + private final EffectProgram f_108938_; + + public EffectInstance(ResourceManager p_108941_, String p_108942_) throws IOException { +- ResourceLocation resourcelocation = new ResourceLocation("shaders/program/" + p_108942_ + ".json"); ++ ResourceLocation rl = ResourceLocation.m_135820_(p_108942_); ++ ResourceLocation resourcelocation = new ResourceLocation(rl.m_135827_(), "shaders/program/" + rl.m_135815_() + ".json"); + this.f_108932_ = p_108942_; + Resource resource = null; + +@@ -162,7 +_,8 @@ + } else { + EffectProgram effectprogram; + if (program == null) { +- ResourceLocation resourcelocation = new ResourceLocation("shaders/program/" + p_172569_ + p_172568_.m_85569_()); ++ ResourceLocation rl = ResourceLocation.m_135820_(p_172569_); ++ ResourceLocation resourcelocation = new ResourceLocation(rl.m_135827_(), "shaders/program/" + rl.m_135815_() + p_172568_.m_85569_()); + Resource resource = p_172567_.m_142591_(resourcelocation); + + try { diff --git a/patches/minecraft/net/minecraft/client/renderer/FirstPersonRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/FirstPersonRenderer.java.patch deleted file mode 100644 index 80bb271fe5..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/FirstPersonRenderer.java.patch +++ /dev/null @@ -1,45 +0,0 @@ ---- a/net/minecraft/client/renderer/FirstPersonRenderer.java -+++ b/net/minecraft/client/renderer/FirstPersonRenderer.java -@@ -208,7 +_,7 @@ - boolean flag1 = true; - if (p_228396_4_.func_184587_cr()) { - ItemStack itemstack = p_228396_4_.func_184607_cu(); -- if (itemstack.func_77973_b() == Items.field_151031_f || itemstack.func_77973_b() == Items.field_222114_py) { -+ if (itemstack.func_77973_b() instanceof net.minecraft.item.ShootableItem) { - flag = p_228396_4_.func_184600_cs() == Hand.MAIN_HAND; - flag1 = !flag; - } -@@ -240,12 +_,14 @@ - if (flag) { - float f5 = hand == Hand.MAIN_HAND ? f : 0.0F; - float f2 = 1.0F - MathHelper.func_219799_g(p_228396_1_, this.field_187470_g, this.field_187469_f); -+ if(!net.minecraftforge.client.ForgeHooksClient.renderSpecificFirstPersonHand(Hand.MAIN_HAND, p_228396_2_, p_228396_3_, p_228396_5_, p_228396_1_, f1, f5, f2, this.field_187467_d)) - this.func_228405_a_(p_228396_4_, p_228396_1_, f1, Hand.MAIN_HAND, f5, this.field_187467_d, f2, p_228396_2_, p_228396_3_, p_228396_5_); - } - - if (flag1) { - float f6 = hand == Hand.OFF_HAND ? f : 0.0F; - float f7 = 1.0F - MathHelper.func_219799_g(p_228396_1_, this.field_187472_i, this.field_187471_h); -+ if(!net.minecraftforge.client.ForgeHooksClient.renderSpecificFirstPersonHand(Hand.OFF_HAND, p_228396_2_, p_228396_3_, p_228396_5_, p_228396_1_, f1, f6, f7, this.field_187468_e)) - this.func_228405_a_(p_228396_4_, p_228396_1_, f1, Hand.OFF_HAND, f6, this.field_187468_e, f7, p_228396_2_, p_228396_3_, p_228396_5_); - } - -@@ -410,8 +_,16 @@ - this.field_187471_h = MathHelper.func_76131_a(this.field_187471_h - 0.4F, 0.0F, 1.0F); - } else { - float f = clientplayerentity.func_184825_o(1.0F); -- this.field_187469_f += MathHelper.func_76131_a((this.field_187467_d == itemstack ? f * f * f : 0.0F) - this.field_187469_f, -0.4F, 0.4F); -- this.field_187471_h += MathHelper.func_76131_a((float)(this.field_187468_e == itemstack1 ? 1 : 0) - this.field_187471_h, -0.4F, 0.4F); -+ boolean requipM = net.minecraftforge.client.ForgeHooksClient.shouldCauseReequipAnimation(this.field_187467_d, itemstack, clientplayerentity.field_71071_by.field_70461_c); -+ boolean requipO = net.minecraftforge.client.ForgeHooksClient.shouldCauseReequipAnimation(this.field_187468_e, itemstack1, -1); -+ -+ if (!requipM && this.field_187467_d != itemstack) -+ this.field_187467_d = itemstack; -+ if (!requipO && this.field_187468_e != itemstack1) -+ this.field_187468_e = itemstack1; -+ -+ this.field_187469_f += MathHelper.func_76131_a((!requipM ? f * f * f : 0.0F) - this.field_187469_f, -0.4F, 0.4F); -+ this.field_187471_h += MathHelper.func_76131_a((float)(!requipO ? 1 : 0) - this.field_187471_h, -0.4F, 0.4F); - } - - if (this.field_187469_f < 0.1F) { diff --git a/patches/minecraft/net/minecraft/client/renderer/FluidBlockRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/FluidBlockRenderer.java.patch deleted file mode 100644 index 8a2a105b1a..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/FluidBlockRenderer.java.patch +++ /dev/null @@ -1,107 +0,0 @@ ---- a/net/minecraft/client/renderer/FluidBlockRenderer.java -+++ b/net/minecraft/client/renderer/FluidBlockRenderer.java -@@ -70,9 +_,10 @@ - - public boolean func_228796_a_(IBlockDisplayReader p_228796_1_, BlockPos p_228796_2_, IVertexBuilder p_228796_3_, FluidState p_228796_4_) { - boolean flag = p_228796_4_.func_206884_a(FluidTags.field_206960_b); -- TextureAtlasSprite[] atextureatlassprite = flag ? this.field_178272_a : this.field_178271_b; -+ TextureAtlasSprite[] atextureatlassprite = net.minecraftforge.client.ForgeHooksClient.getFluidSprites(p_228796_1_, p_228796_2_, p_228796_4_); - BlockState blockstate = p_228796_1_.func_180495_p(p_228796_2_); -- int i = flag ? 16777215 : BiomeColors.func_228363_c_(p_228796_1_, p_228796_2_); -+ int i = p_228796_4_.func_206886_c().getAttributes().getColor(p_228796_1_, p_228796_2_); -+ float alpha = (float)(i >> 24 & 255) / 255.0F; - float f = (float)(i >> 16 & 255) / 255.0F; - float f1 = (float)(i >> 8 & 255) / 255.0F; - float f2 = (float)(i & 255) / 255.0F; -@@ -157,15 +_,15 @@ - float f25 = f4 * f; - float f26 = f4 * f1; - float f27 = f4 * f2; -- this.func_228797_a_(p_228796_3_, d0 + 0.0D, d1 + (double)f7, d2 + 0.0D, f25, f26, f27, f13, f17, j); -- this.func_228797_a_(p_228796_3_, d0 + 0.0D, d1 + (double)f8, d2 + 1.0D, f25, f26, f27, f14, f18, j); -- this.func_228797_a_(p_228796_3_, d0 + 1.0D, d1 + (double)f9, d2 + 1.0D, f25, f26, f27, f15, f19, j); -- this.func_228797_a_(p_228796_3_, d0 + 1.0D, d1 + (double)f10, d2 + 0.0D, f25, f26, f27, f16, f20, j); -+ this.vertexVanilla(p_228796_3_, d0 + 0.0D, d1 + (double)f7, d2 + 0.0D, f25, f26, f27, alpha, f13, f17, j); -+ this.vertexVanilla(p_228796_3_, d0 + 0.0D, d1 + (double)f8, d2 + 1.0D, f25, f26, f27, alpha, f14, f18, j); -+ this.vertexVanilla(p_228796_3_, d0 + 1.0D, d1 + (double)f9, d2 + 1.0D, f25, f26, f27, alpha, f15, f19, j); -+ this.vertexVanilla(p_228796_3_, d0 + 1.0D, d1 + (double)f10, d2 + 0.0D, f25, f26, f27, alpha, f16, f20, j); - if (p_228796_4_.func_205586_a(p_228796_1_, p_228796_2_.func_177984_a())) { -- this.func_228797_a_(p_228796_3_, d0 + 0.0D, d1 + (double)f7, d2 + 0.0D, f25, f26, f27, f13, f17, j); -- this.func_228797_a_(p_228796_3_, d0 + 1.0D, d1 + (double)f10, d2 + 0.0D, f25, f26, f27, f16, f20, j); -- this.func_228797_a_(p_228796_3_, d0 + 1.0D, d1 + (double)f9, d2 + 1.0D, f25, f26, f27, f15, f19, j); -- this.func_228797_a_(p_228796_3_, d0 + 0.0D, d1 + (double)f8, d2 + 1.0D, f25, f26, f27, f14, f18, j); -+ this.vertexVanilla(p_228796_3_, d0 + 0.0D, d1 + (double)f7, d2 + 0.0D, f25, f26, f27, alpha, f13, f17, j); -+ this.vertexVanilla(p_228796_3_, d0 + 1.0D, d1 + (double)f10, d2 + 0.0D, f25, f26, f27, alpha, f16, f20, j); -+ this.vertexVanilla(p_228796_3_, d0 + 1.0D, d1 + (double)f9, d2 + 1.0D, f25, f26, f27, alpha, f15, f19, j); -+ this.vertexVanilla(p_228796_3_, d0 + 0.0D, d1 + (double)f8, d2 + 1.0D, f25, f26, f27, alpha, f14, f18, j); - } - } - -@@ -178,10 +_,10 @@ - float f40 = f3 * f; - float f41 = f3 * f1; - float f42 = f3 * f2; -- this.func_228797_a_(p_228796_3_, d0, d1 + (double)f12, d2 + 1.0D, f40, f41, f42, f34, f39, i1); -- this.func_228797_a_(p_228796_3_, d0, d1 + (double)f12, d2, f40, f41, f42, f34, f37, i1); -- this.func_228797_a_(p_228796_3_, d0 + 1.0D, d1 + (double)f12, d2, f40, f41, f42, f35, f37, i1); -- this.func_228797_a_(p_228796_3_, d0 + 1.0D, d1 + (double)f12, d2 + 1.0D, f40, f41, f42, f35, f39, i1); -+ this.vertexVanilla(p_228796_3_, d0, d1 + (double)f12, d2 + 1.0D, f40, f41, f42, alpha, f34, f39, i1); -+ this.vertexVanilla(p_228796_3_, d0, d1 + (double)f12, d2, f40, f41, f42, alpha, f34, f37, i1); -+ this.vertexVanilla(p_228796_3_, d0 + 1.0D, d1 + (double)f12, d2, f40, f41, f42, alpha, f35, f37, i1); -+ this.vertexVanilla(p_228796_3_, d0 + 1.0D, d1 + (double)f12, d2 + 1.0D, f40, f41, f42, alpha, f35, f39, i1); - flag7 = true; - } - -@@ -236,10 +_,9 @@ - flag7 = true; - BlockPos blockpos = p_228796_2_.func_177972_a(direction); - TextureAtlasSprite textureatlassprite2 = atextureatlassprite[1]; -- if (!flag) { -- Block block = p_228796_1_.func_180495_p(blockpos).func_177230_c(); -- if (block instanceof BreakableBlock || block instanceof LeavesBlock) { -- textureatlassprite2 = this.field_187501_d; -+ if (atextureatlassprite[2] != null) { -+ if (p_228796_1_.func_180495_p(blockpos).shouldDisplayFluidOverlay(p_228796_1_, blockpos, p_228796_4_)) { -+ textureatlassprite2 = atextureatlassprite[2]; - } - } - -@@ -253,15 +_,15 @@ - float f31 = f4 * f30 * f; - float f32 = f4 * f30 * f1; - float f33 = f4 * f30 * f2; -- this.func_228797_a_(p_228796_3_, d3, d1 + (double)f36, d4, f31, f32, f33, f48, f50, k); -- this.func_228797_a_(p_228796_3_, d5, d1 + (double)f38, d6, f31, f32, f33, f49, f28, k); -- this.func_228797_a_(p_228796_3_, d5, d1 + (double)f12, d6, f31, f32, f33, f49, f29, k); -- this.func_228797_a_(p_228796_3_, d3, d1 + (double)f12, d4, f31, f32, f33, f48, f29, k); -- if (textureatlassprite2 != this.field_187501_d) { -- this.func_228797_a_(p_228796_3_, d3, d1 + (double)f12, d4, f31, f32, f33, f48, f29, k); -- this.func_228797_a_(p_228796_3_, d5, d1 + (double)f12, d6, f31, f32, f33, f49, f29, k); -- this.func_228797_a_(p_228796_3_, d5, d1 + (double)f38, d6, f31, f32, f33, f49, f28, k); -- this.func_228797_a_(p_228796_3_, d3, d1 + (double)f36, d4, f31, f32, f33, f48, f50, k); -+ this.vertexVanilla(p_228796_3_, d3, d1 + (double)f36, d4, f31, f32, f33, alpha, f48, f50, k); -+ this.vertexVanilla(p_228796_3_, d5, d1 + (double)f38, d6, f31, f32, f33, alpha, f49, f28, k); -+ this.vertexVanilla(p_228796_3_, d5, d1 + (double)f12, d6, f31, f32, f33, alpha, f49, f29, k); -+ this.vertexVanilla(p_228796_3_, d3, d1 + (double)f12, d4, f31, f32, f33, alpha, f48, f29, k); -+ if (textureatlassprite2 != atextureatlassprite[2]) { -+ this.vertexVanilla(p_228796_3_, d3, d1 + (double)f12, d4, f31, f32, f33, alpha, f48, f29, k); -+ this.vertexVanilla(p_228796_3_, d5, d1 + (double)f12, d6, f31, f32, f33, alpha, f49, f29, k); -+ this.vertexVanilla(p_228796_3_, d5, d1 + (double)f38, d6, f31, f32, f33, alpha, f49, f28, k); -+ this.vertexVanilla(p_228796_3_, d3, d1 + (double)f36, d4, f31, f32, f33, alpha, f48, f50, k); - } - } - } -@@ -270,8 +_,12 @@ - } - } - -+ @Deprecated - private void func_228797_a_(IVertexBuilder p_228797_1_, double p_228797_2_, double p_228797_4_, double p_228797_6_, float p_228797_8_, float p_228797_9_, float p_228797_10_, float p_228797_11_, float p_228797_12_, int p_228797_13_) { -- p_228797_1_.func_225582_a_(p_228797_2_, p_228797_4_, p_228797_6_).func_227885_a_(p_228797_8_, p_228797_9_, p_228797_10_, 1.0F).func_225583_a_(p_228797_11_, p_228797_12_).func_227886_a_(p_228797_13_).func_225584_a_(0.0F, 1.0F, 0.0F).func_181675_d(); -+ vertexVanilla(p_228797_1_, p_228797_2_, p_228797_4_, p_228797_6_, p_228797_8_, p_228797_9_, p_228797_10_, 1.0F, p_228797_11_, p_228797_12_, p_228797_13_); -+ } -+ private void vertexVanilla(IVertexBuilder vertexBuilderIn, double x, double y, double z, float red, float green, float blue, float alpha, float u, float v, int packedLight) { -+ vertexBuilderIn.func_225582_a_(x, y, z).func_227885_a_(red, green, blue, alpha).func_225583_a_(u, v).func_227886_a_(packedLight).func_225584_a_(0.0F, 1.0F, 0.0F).func_181675_d(); - } - - private int func_228795_a_(IBlockDisplayReader p_228795_1_, BlockPos p_228795_2_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/FogRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/FogRenderer.java.patch index 452fa3c3be..15605bd35d 100644 --- a/patches/minecraft/net/minecraft/client/renderer/FogRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/FogRenderer.java.patch @@ -1,58 +1,52 @@ --- a/net/minecraft/client/renderer/FogRenderer.java +++ b/net/minecraft/client/renderer/FogRenderer.java -@@ -156,17 +_,28 @@ - } +@@ -171,21 +_,40 @@ - float f9 = Math.min(1.0F / field_205093_c, Math.min(1.0F / field_205094_d, 1.0F / field_205095_e)); + if (f_109010_ != 0.0F && f_109011_ != 0.0F && f_109012_ != 0.0F) { + float f8 = Math.min(1.0F / f_109010_, Math.min(1.0F / f_109011_, 1.0F / f_109012_)); + // Forge: fix MC-4647 and MC-10480 -+ if (Float.isInfinite(f9)) f9 = Math.nextAfter(f9, 0.0); - field_205093_c = field_205093_c * (1.0F - f6) + field_205093_c * f9 * f6; - field_205094_d = field_205094_d * (1.0F - f6) + field_205094_d * f9 * f6; - field_205095_e = field_205095_e * (1.0F - f6) + field_205095_e * f9 * f6; - } else if (p_228371_0_.func_216773_g() instanceof LivingEntity && ((LivingEntity)p_228371_0_.func_216773_g()).func_70644_a(Effects.field_76439_r)) { - float f7 = GameRenderer.func_180438_a((LivingEntity)p_228371_0_.func_216773_g(), p_228371_1_); - float f10 = Math.min(1.0F / field_205093_c, Math.min(1.0F / field_205094_d, 1.0F / field_205095_e)); -+ // Forge: fix MC-4647 and MC-10480 -+ if (Float.isInfinite(f10)) f10 = Math.nextAfter(f10, 0.0); - field_205093_c = field_205093_c * (1.0F - f7) + field_205093_c * f10 * f7; - field_205094_d = field_205094_d * (1.0F - f7) + field_205094_d * f10 * f7; - field_205095_e = field_205095_e * (1.0F - f7) + field_205095_e * f10 * f7; ++ if (Float.isInfinite(f8)) f8 = Math.nextAfter(f8, 0.0); + f_109010_ = f_109010_ * (1.0F - f6) + f_109010_ * f8 * f6; + f_109011_ = f_109011_ * (1.0F - f6) + f_109011_ * f8 * f6; + f_109012_ = f_109012_ * (1.0F - f6) + f_109012_ * f8 * f6; } -+ net.minecraftforge.client.event.EntityViewRenderEvent.FogColors event = new net.minecraftforge.client.event.EntityViewRenderEvent.FogColors(p_228371_0_, p_228371_1_, field_205093_c, field_205094_d, field_205095_e); ++ net.minecraftforge.client.event.EntityViewRenderEvent.FogColors event = new net.minecraftforge.client.event.EntityViewRenderEvent.FogColors(p_109019_, p_109020_, f_109010_, f_109011_, f_109012_); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); + -+ field_205093_c = event.getRed(); -+ field_205094_d = event.getGreen(); -+ field_205095_e = event.getBlue(); ++ f_109010_ = event.getRed(); ++ f_109011_ = event.getGreen(); ++ f_109012_ = event.getBlue(); + - RenderSystem.clearColor(field_205093_c, field_205094_d, field_205095_e, 0.0F); + RenderSystem.m_69424_(f_109010_, f_109011_, f_109012_, 0.0F); } -@@ -174,10 +_,17 @@ - RenderSystem.fogDensity(0.0F); - RenderSystem.fogMode(GlStateManager.FogMode.EXP2); + public static void m_109017_() { + RenderSystem.m_157445_(Float.MAX_VALUE); } - + @Deprecated // FORGE: Pass in partialTicks - public static void func_228372_a_(ActiveRenderInfo p_228372_0_, FogRenderer.FogType p_228372_1_, float p_228372_2_, boolean p_228372_3_) { -+ setupFog(p_228372_0_, p_228372_1_, p_228372_2_, p_228372_3_, 0); + public static void m_109024_(Camera p_109025_, FogRenderer.FogMode p_109026_, float p_109027_, boolean p_109028_) { ++ setupFog(p_109025_, p_109026_, p_109027_, p_109028_, 0); + } + -+ public static void setupFog(ActiveRenderInfo p_228372_0_, FogRenderer.FogType p_228372_1_, float p_228372_2_, boolean p_228372_3_, float partialTicks) { - FluidState fluidstate = p_228372_0_.func_216771_k(); - Entity entity = p_228372_0_.func_216773_g(); -+ float hook = net.minecraftforge.client.ForgeHooksClient.getFogDensity(p_228372_1_, p_228372_0_, partialTicks, 0.1F); -+ if (hook >= 0) RenderSystem.fogDensity(hook); -+ else - if (fluidstate.func_206884_a(FluidTags.field_206959_a)) { - float f = 1.0F; - f = 0.05F; -@@ -228,6 +_,7 @@ - RenderSystem.fogEnd(f3); - RenderSystem.fogMode(GlStateManager.FogMode.LINEAR); - RenderSystem.setupNvFogDistance(); -+ net.minecraftforge.client.ForgeHooksClient.onFogRender(p_228372_1_, p_228372_0_, partialTicks, f3); ++ public static void setupFog(Camera p_109025_, FogRenderer.FogMode p_109026_, float p_109027_, boolean p_109028_, float partialTicks) { + FogType fogtype = p_109025_.m_167685_(); + Entity entity = p_109025_.m_90592_(); ++ // TODO ++ float hook = net.minecraftforge.client.ForgeHooksClient.getFogDensity(p_109026_, p_109025_, partialTicks, 0.1F); ++ if (hook >= 0) { ++ RenderSystem.m_157445_(-8.0F); ++ RenderSystem.m_157443_(hook * 0.5F); ++ } else + if (fogtype == FogType.WATER) { + float f = 192.0F; + if (entity instanceof LocalPlayer) { +@@ -244,6 +_,7 @@ + + RenderSystem.m_157445_(f2); + RenderSystem.m_157443_(f3); ++ net.minecraftforge.client.ForgeHooksClient.onFogRender(p_109026_, p_109025_, partialTicks, f3); } } diff --git a/patches/minecraft/net/minecraft/client/renderer/GameRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/GameRenderer.java.patch index b4b783253c..747752c69d 100644 --- a/patches/minecraft/net/minecraft/client/renderer/GameRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/GameRenderer.java.patch @@ -1,65 +1,59 @@ --- a/net/minecraft/client/renderer/GameRenderer.java +++ b/net/minecraft/client/renderer/GameRenderer.java -@@ -135,6 +_,8 @@ - this.func_175069_a(new ResourceLocation("shaders/post/spider.json")); - } else if (p_175066_1_ instanceof EndermanEntity) { - this.func_175069_a(new ResourceLocation("shaders/post/invert.json")); +@@ -285,6 +_,8 @@ + this.m_109128_(new ResourceLocation("shaders/post/spider.json")); + } else if (p_109107_ instanceof EnderMan) { + this.m_109128_(new ResourceLocation("shaders/post/invert.json")); + } else { -+ net.minecraftforge.client.ForgeHooksClient.loadEntityShader(p_175066_1_, this); ++ net.minecraftforge.client.ForgeHooksClient.loadEntityShader(p_109107_, this); } } -@@ -310,7 +_,7 @@ - d0 = d0 * 60.0D / 70.0D; +@@ -703,7 +_,7 @@ + d0 *= (double)Mth.m_14179_(this.f_109059_.f_91066_.f_92070_, 1.0F, 0.85714287F); } - return d0; -+ return net.minecraftforge.client.ForgeHooksClient.getFOVModifier(this, p_215311_1_, p_215311_2_, d0); ++ return net.minecraftforge.client.ForgeHooksClient.getFOVModifier(this, p_109142_, p_109143_, d0); } } -@@ -439,6 +_,7 @@ - RenderSystem.loadIdentity(); - this.field_147707_d.func_148018_a(p_195458_1_); - RenderSystem.popMatrix(); -+ RenderSystem.enableTexture(); //FORGE: Fix MC-194675 +@@ -879,7 +_,7 @@ } - - this.field_78531_r.func_147110_a().func_147610_a(true); -@@ -486,7 +_,7 @@ - } - } else if (this.field_78531_r.field_71462_r != null) { + } else if (this.f_109059_.f_91080_ != null) { try { -- this.field_78531_r.field_71462_r.func_230430_a_(matrixstack, i, j, this.field_78531_r.func_193989_ak()); -+ net.minecraftforge.client.ForgeHooksClient.drawScreen(this.field_78531_r.field_71462_r, matrixstack, i, j, this.field_78531_r.func_193989_ak()); - } catch (Throwable throwable) { - CrashReport crashreport1 = CrashReport.func_85055_a(throwable, "Rendering screen"); - CrashReportCategory crashreportcategory1 = crashreport1.func_85058_a("Screen render details"); -@@ -595,9 +_,16 @@ - Matrix4f matrix4f = matrixstack.func_227866_c_().func_227870_a_(); - this.func_228379_a_(matrix4f); - activerenderinfo.func_216772_a(this.field_78531_r.field_71441_e, (Entity)(this.field_78531_r.func_175606_aa() == null ? this.field_78531_r.field_71439_g : this.field_78531_r.func_175606_aa()), !this.field_78531_r.field_71474_y.func_243230_g().func_243192_a(), this.field_78531_r.field_71474_y.func_243230_g().func_243193_b(), p_228378_1_); +- this.f_109059_.f_91080_.m_6305_(posestack1, i, j, this.f_109059_.m_91297_()); ++ net.minecraftforge.client.ForgeHooksClient.drawScreen(this.f_109059_.f_91080_, posestack1, 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"); +@@ -1036,10 +_,17 @@ + Matrix4f matrix4f = posestack.m_85850_().m_85861_(); + this.m_109111_(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_); + -+ net.minecraftforge.client.event.EntityViewRenderEvent.CameraSetup cameraSetup = net.minecraftforge.client.ForgeHooksClient.onCameraSetup(this, activerenderinfo, p_228378_1_); -+ activerenderinfo.setAnglesInternal(cameraSetup.getYaw(), cameraSetup.getPitch()); -+ p_228378_4_.func_227863_a_(Vector3f.field_229183_f_.func_229187_a_(cameraSetup.getRoll())); ++ net.minecraftforge.client.event.EntityViewRenderEvent.CameraSetup cameraSetup = net.minecraftforge.client.ForgeHooksClient.onCameraSetup(this, camera, p_109090_); ++ camera.setAnglesInternal(cameraSetup.getYaw(), cameraSetup.getPitch()); ++ p_109092_.m_85845_(Vector3f.f_122227_.m_122240_(cameraSetup.getRoll())); + - p_228378_4_.func_227863_a_(Vector3f.field_229179_b_.func_229187_a_(activerenderinfo.func_216777_e())); - p_228378_4_.func_227863_a_(Vector3f.field_229181_d_.func_229187_a_(activerenderinfo.func_216778_f() + 180.0F)); - this.field_78531_r.field_71438_f.func_228426_a_(p_228378_4_, p_228378_1_, p_228378_2_, flag, activerenderinfo, this, this.field_78513_d, matrix4f); -+ this.field_78531_r.func_213239_aq().func_219895_b("forge_render_last"); -+ net.minecraftforge.client.ForgeHooksClient.dispatchRenderLast(this.field_78531_r.field_71438_f, p_228378_4_, p_228378_1_, matrix4f, p_228378_2_); - this.field_78531_r.func_213239_aq().func_219895_b("hand"); - if (this.field_175074_C) { - RenderSystem.clear(256, Minecraft.field_142025_a); -@@ -708,5 +_,10 @@ + p_109092_.m_85845_(Vector3f.f_122223_.m_122240_(camera.m_90589_())); + p_109092_.m_85845_(Vector3f.f_122225_.m_122240_(camera.m_90590_() + 180.0F)); + this.f_109059_.f_91060_.m_172961_(p_109092_, camera.m_90583_(), this.m_172716_(Math.max(d0, this.f_109059_.f_91066_.f_92068_))); + 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.dispatchRenderLast(this.f_109059_.f_91060_, p_109092_, p_109090_, matrix4f, p_109091_); + this.f_109059_.m_91307_().m_6182_("hand"); + if (this.f_109070_) { + RenderSystem.m_69421_(256, Minecraft.f_91002_); +@@ -1151,6 +_,11 @@ - public OverlayTexture func_228385_m_() { - return this.field_228375_t_; + public OverlayTexture m_109155_() { + return this.f_109075_; + } + + @Override + public net.minecraftforge.resource.IResourceType getResourceType() { + return net.minecraftforge.resource.VanillaResourceType.SHADERS; } - } + + @Nullable diff --git a/patches/minecraft/net/minecraft/client/renderer/ItemBlockRenderTypes.java.patch b/patches/minecraft/net/minecraft/client/renderer/ItemBlockRenderTypes.java.patch new file mode 100644 index 0000000000..cd251785ae --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/ItemBlockRenderTypes.java.patch @@ -0,0 +1,103 @@ +--- a/net/minecraft/client/renderer/ItemBlockRenderTypes.java ++++ b/net/minecraft/client/renderer/ItemBlockRenderTypes.java +@@ -19,6 +_,7 @@ + + @OnlyIn(Dist.CLIENT) + public class ItemBlockRenderTypes { ++ @Deprecated + private static final Map f_109275_ = Util.m_137469_(Maps.newHashMap(), (p_109296_) -> { + RenderType rendertype = RenderType.m_110503_(); + p_109296_.put(Blocks.f_50267_, rendertype); +@@ -286,6 +_,7 @@ + p_109296_.put(Blocks.f_50628_, rendertype3); + p_109296_.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); +@@ -293,6 +_,7 @@ + }); + private static boolean f_109277_; + ++ @Deprecated // FORGE: Use canRenderInLayer + public static RenderType m_109282_(BlockState p_109283_) { + Block block = p_109283_.m_60734_(); + if (block instanceof LeavesBlock) { +@@ -303,6 +_,7 @@ + } + } + ++ @Deprecated // FORGE: Use canRenderInLayer + public static RenderType m_109293_(BlockState p_109294_) { + Block block = p_109294_.m_60734_(); + if (block instanceof LeavesBlock) { +@@ -318,8 +_,7 @@ + } + + public static RenderType m_109284_(BlockState p_109285_, boolean p_109286_) { +- RenderType rendertype = m_109282_(p_109285_); +- if (rendertype == RenderType.m_110466_()) { ++ if (canRenderInLayer(p_109285_, RenderType.m_110466_())) { + if (!Minecraft.m_91085_()) { + return Sheets.m_110792_(); + } else { +@@ -340,9 +_,58 @@ + } + } + ++ @Deprecated // FORGE: Use canRenderInLayer + public static RenderType m_109287_(FluidState p_109288_) { + RenderType rendertype = f_109276_.get(p_109288_.m_76152_()); + return rendertype != null ? rendertype : RenderType.m_110451_(); ++ } ++ ++ // FORGE START ++ ++ private static final Map, java.util.function.Predicate> blockRenderChecks = Maps.newHashMap(); ++ private static final Map, java.util.function.Predicate> fluidRenderChecks = Maps.newHashMap(); ++ static { ++ f_109275_.forEach(ItemBlockRenderTypes::setRenderLayer); ++ f_109276_.forEach(ItemBlockRenderTypes::setRenderLayer); ++ } ++ ++ public static boolean canRenderInLayer(BlockState state, RenderType type) { ++ Block block = state.m_60734_(); ++ if (block instanceof LeavesBlock) { ++ return f_109277_ ? type == RenderType.m_110457_() : type == RenderType.m_110451_(); ++ } else { ++ java.util.function.Predicate rendertype; ++ synchronized (ItemBlockRenderTypes.class) { ++ rendertype = blockRenderChecks.get(block.delegate); ++ } ++ return rendertype != null ? rendertype.test(type) : type == RenderType.m_110451_(); ++ } ++ } ++ ++ public static boolean canRenderInLayer(FluidState fluid, RenderType type) { ++ java.util.function.Predicate rendertype; ++ synchronized (ItemBlockRenderTypes.class) { ++ rendertype = fluidRenderChecks.get(fluid.m_76152_().delegate); ++ } ++ return rendertype != null ? rendertype.test(type) : type == RenderType.m_110451_(); ++ } ++ ++ public static void setRenderLayer(Block block, RenderType type) { ++ java.util.Objects.requireNonNull(type); ++ setRenderLayer(block, type::equals); ++ } ++ ++ public static synchronized void setRenderLayer(Block block, java.util.function.Predicate predicate) { ++ blockRenderChecks.put(block.delegate, predicate); ++ } ++ ++ public static void setRenderLayer(Fluid fluid, RenderType type) { ++ java.util.Objects.requireNonNull(type); ++ setRenderLayer(fluid, type::equals); ++ } ++ ++ public static synchronized void setRenderLayer(Fluid fluid, java.util.function.Predicate predicate) { ++ fluidRenderChecks.put(fluid.delegate, predicate); + } + + public static void m_109291_(boolean p_109292_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/ItemInHandRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/ItemInHandRenderer.java.patch new file mode 100644 index 0000000000..d794492bc8 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/ItemInHandRenderer.java.patch @@ -0,0 +1,36 @@ +--- a/net/minecraft/client/renderer/ItemInHandRenderer.java ++++ b/net/minecraft/client/renderer/ItemInHandRenderer.java +@@ -286,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_); ++ if(!net.minecraftforge.client.ForgeHooksClient.renderSpecificFirstPersonHand(InteractionHand.MAIN_HAND, p_109316_, p_109317_, p_109319_, p_109315_, f1, f5, f2, this.f_109300_)) + this.m_109371_(p_109318_, p_109315_, f1, InteractionHand.MAIN_HAND, f4, this.f_109300_, f5, p_109316_, p_109317_, p_109319_); + } + + if (iteminhandrenderer$handrenderselection.f_172922_) { + float f6 = interactionhand == InteractionHand.OFF_HAND ? f : 0.0F; + float f7 = 1.0F - Mth.m_14179_(p_109315_, this.f_109305_, this.f_109304_); ++ if(!net.minecraftforge.client.ForgeHooksClient.renderSpecificFirstPersonHand(InteractionHand.OFF_HAND, p_109316_, p_109317_, p_109319_, p_109315_, f1, f6, f7, this.f_109301_)) + this.m_109371_(p_109318_, p_109315_, f1, InteractionHand.OFF_HAND, f6, this.f_109301_, f7, p_109316_, p_109317_, p_109319_); + } + +@@ -487,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); +- this.f_109302_ += Mth.m_14036_((this.f_109300_ == itemstack ? f * f * f : 0.0F) - this.f_109302_, -0.4F, 0.4F); +- this.f_109304_ += Mth.m_14036_((float)(this.f_109301_ == itemstack1 ? 1 : 0) - this.f_109304_, -0.4F, 0.4F); ++ boolean requipM = net.minecraftforge.client.ForgeHooksClient.shouldCauseReequipAnimation(this.f_109300_, itemstack, localplayer.m_150109_().f_35977_); ++ boolean requipO = net.minecraftforge.client.ForgeHooksClient.shouldCauseReequipAnimation(this.f_109301_, itemstack1, -1); ++ ++ if (!requipM && this.f_109300_ != itemstack) ++ this.f_109300_ = itemstack; ++ if (!requipO && this.f_109301_ != itemstack1) ++ this.f_109301_ = itemstack1; ++ ++ this.f_109302_ += Mth.m_14036_((!requipM ? f * f * f : 0.0F) - this.f_109302_, -0.4F, 0.4F); ++ this.f_109304_ += Mth.m_14036_((float)(!requipO ? 1 : 0) - this.f_109304_, -0.4F, 0.4F); + } + + if (this.f_109302_ < 0.1F) { diff --git a/patches/minecraft/net/minecraft/client/renderer/ItemModelMesher.java.patch b/patches/minecraft/net/minecraft/client/renderer/ItemModelMesher.java.patch deleted file mode 100644 index ed748d5ec8..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/ItemModelMesher.java.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/net/minecraft/client/renderer/ItemModelMesher.java -+++ b/net/minecraft/client/renderer/ItemModelMesher.java -@@ -31,7 +_,8 @@ - - public TextureAtlasSprite func_199309_a(ItemStack p_199309_1_) { - IBakedModel ibakedmodel = this.func_178089_a(p_199309_1_); -- return ibakedmodel == this.field_178090_d.func_174951_a() && p_199309_1_.func_77973_b() instanceof BlockItem ? this.field_178090_d.func_174954_c().func_178122_a(((BlockItem)p_199309_1_.func_77973_b()).func_179223_d().func_176223_P()) : ibakedmodel.func_177554_e(); -+ // FORGE: Make sure to call the item overrides -+ return ibakedmodel == this.field_178090_d.func_174951_a() && p_199309_1_.func_77973_b() instanceof BlockItem ? this.field_178090_d.func_174954_c().func_178122_a(((BlockItem)p_199309_1_.func_77973_b()).func_179223_d().func_176223_P()) : ibakedmodel.func_188617_f().func_239290_a_(ibakedmodel, p_199309_1_, null, null).getParticleTexture(net.minecraftforge.client.model.data.EmptyModelData.INSTANCE); - } - - public IBakedModel func_178089_a(ItemStack p_178089_1_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/ItemModelShaper.java.patch b/patches/minecraft/net/minecraft/client/renderer/ItemModelShaper.java.patch new file mode 100644 index 0000000000..36e98ecc80 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/ItemModelShaper.java.patch @@ -0,0 +1,12 @@ +--- a/net/minecraft/client/renderer/ItemModelShaper.java ++++ b/net/minecraft/client/renderer/ItemModelShaper.java +@@ -31,7 +_,8 @@ + + public TextureAtlasSprite m_109399_(ItemStack p_109400_) { + BakedModel bakedmodel = this.m_109406_(p_109400_); +- return bakedmodel == this.f_109390_.m_119409_() && p_109400_.m_41720_() instanceof BlockItem ? this.f_109390_.m_119430_().m_110882_(((BlockItem)p_109400_.m_41720_()).m_40614_().m_49966_()) : bakedmodel.m_6160_(); ++ // FORGE: Make sure to call the item overrides ++ return bakedmodel == this.f_109390_.m_119409_() && p_109400_.m_41720_() instanceof BlockItem ? this.f_109390_.m_119430_().m_110882_(((BlockItem)p_109400_.m_41720_()).m_40614_().m_49966_()) : bakedmodel.m_7343_().m_173464_(bakedmodel, p_109400_, null, null, 0).getParticleIcon(net.minecraftforge.client.model.data.EmptyModelData.INSTANCE); + } + + public BakedModel m_109406_(ItemStack p_109407_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/ItemRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/ItemRenderer.java.patch deleted file mode 100644 index 36546c42e0..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/ItemRenderer.java.patch +++ /dev/null @@ -1,92 +0,0 @@ ---- a/net/minecraft/client/renderer/ItemRenderer.java -+++ b/net/minecraft/client/renderer/ItemRenderer.java -@@ -59,7 +_,7 @@ - - public ItemRenderer(TextureManager p_i46552_1_, ModelManager p_i46552_2_, ItemColors p_i46552_3_) { - this.field_175057_n = p_i46552_1_; -- this.field_175059_m = new ItemModelMesher(p_i46552_2_); -+ this.field_175059_m = new net.minecraftforge.client.ItemModelMesherForge(p_i46552_2_); - - for(Item item : Registry.field_212630_s) { - if (!field_195411_c.contains(item)) { -@@ -95,7 +_,7 @@ - p_229111_8_ = this.field_175059_m.func_178083_a().func_174953_a(new ModelResourceLocation("minecraft:trident#inventory")); - } - -- p_229111_8_.func_177552_f().func_181688_b(p_229111_2_).func_228830_a_(p_229111_3_, p_229111_4_); -+ p_229111_8_ = net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms(p_229111_4_, p_229111_8_, p_229111_2_, p_229111_3_); - p_229111_4_.func_227861_a_(-0.5D, -0.5D, -0.5D); - if (!p_229111_8_.func_188618_c() && (p_229111_1_.func_77973_b() != Items.field_203184_eO || flag)) { - boolean flag1; -@@ -105,7 +_,8 @@ - } else { - flag1 = true; - } -- -+ if (p_229111_8_.isLayered()) { net.minecraftforge.client.ForgeHooksClient.drawItemLayered(this, p_229111_8_, p_229111_1_, p_229111_4_, p_229111_5_, p_229111_6_, p_229111_7_, flag1); } -+ else { - RenderType rendertype = RenderTypeLookup.func_239219_a_(p_229111_1_, flag1); - IVertexBuilder ivertexbuilder; - if (p_229111_1_.func_77973_b() == Items.field_151111_aL && p_229111_1_.func_77962_s()) { -@@ -131,8 +_,9 @@ - } - - this.func_229114_a_(p_229111_8_, p_229111_1_, p_229111_6_, p_229111_7_, p_229111_4_, ivertexbuilder); -+ } - } else { -- ItemStackTileEntityRenderer.field_147719_a.func_239207_a_(p_229111_1_, p_229111_2_, p_229111_4_, p_229111_5_, p_229111_6_, p_229111_7_); -+ p_229111_1_.func_77973_b().getItemStackTileEntityRenderer().func_239207_a_(p_229111_1_, p_229111_2_, p_229111_4_, p_229111_5_, p_229111_6_, p_229111_7_); - } - - p_229111_4_.func_227865_b_(); -@@ -176,7 +_,7 @@ - float f = (float)(i >> 16 & 255) / 255.0F; - float f1 = (float)(i >> 8 & 255) / 255.0F; - float f2 = (float)(i & 255) / 255.0F; -- p_229112_2_.func_227889_a_(matrixstack$entry, bakedquad, f, f1, f2, p_229112_5_, p_229112_6_); -+ p_229112_2_.addVertexData(matrixstack$entry, bakedquad, f, f1, f2, p_229112_5_, p_229112_6_, true); - } - - } -@@ -267,6 +_,7 @@ - crashreportcategory.func_189529_a("Item Type", () -> { - return String.valueOf((Object)p_239387_2_.func_77973_b()); - }); -+ crashreportcategory.func_189529_a("Registry Name", () -> String.valueOf(p_239387_2_.func_77973_b().getRegistryName())); - crashreportcategory.func_189529_a("Item Damage", () -> { - return String.valueOf(p_239387_2_.func_77952_i()); - }); -@@ -298,18 +_,16 @@ - irendertypebuffer$impl.func_228461_a_(); - } - -- if (p_180453_2_.func_77951_h()) { -+ if (p_180453_2_.func_77973_b().showDurabilityBar(p_180453_2_)) { - RenderSystem.disableDepthTest(); - RenderSystem.disableTexture(); - RenderSystem.disableAlphaTest(); - RenderSystem.disableBlend(); - Tessellator tessellator = Tessellator.func_178181_a(); - BufferBuilder bufferbuilder = tessellator.func_178180_c(); -- float f = (float)p_180453_2_.func_77952_i(); -- float f1 = (float)p_180453_2_.func_77958_k(); -- float f2 = Math.max(0.0F, (f1 - f) / f1); -- int i = Math.round(13.0F - f * 13.0F / f1); -- int j = MathHelper.func_181758_c(f2 / 3.0F, 1.0F, 1.0F); -+ double health = p_180453_2_.func_77973_b().getDurabilityForDisplay(p_180453_2_); -+ int i = Math.round(13.0F - (float)health * 13.0F); -+ int j = p_180453_2_.func_77973_b().getRGBDurabilityForDisplay(p_180453_2_); - this.func_181565_a(bufferbuilder, p_180453_3_ + 2, p_180453_4_ + 13, 13, 2, 0, 0, 0, 255); - this.func_181565_a(bufferbuilder, p_180453_3_ + 2, p_180453_4_ + 13, i, 1, j >> 16 & 255, j >> 8 & 255, j & 255, 255); - RenderSystem.enableBlend(); -@@ -346,5 +_,10 @@ - - public void func_195410_a(IResourceManager p_195410_1_) { - this.field_175059_m.func_178085_b(); -+ } -+ -+ @Override -+ public net.minecraftforge.resource.IResourceType getResourceType() { -+ return net.minecraftforge.resource.VanillaResourceType.MODELS; - } - } diff --git a/patches/minecraft/net/minecraft/client/renderer/LevelRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/LevelRenderer.java.patch new file mode 100644 index 0000000000..7f2f71ea59 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/LevelRenderer.java.patch @@ -0,0 +1,212 @@ +--- a/net/minecraft/client/renderer/LevelRenderer.java ++++ b/net/minecraft/client/renderer/LevelRenderer.java +@@ -241,6 +_,11 @@ + } + + private void m_109703_(LightTexture p_109704_, float p_109705_, double p_109706_, double p_109707_, double p_109708_) { ++ net.minecraftforge.client.IWeatherRenderHandler renderHandler = f_109465_.m_104583_().getWeatherRenderHandler(); ++ if (renderHandler != null) { ++ renderHandler.render(f_109477_, p_109705_, f_109465_, f_109461_, p_109704_, p_109706_, p_109707_, p_109708_); ++ return; ++ } + float f = this.f_109461_.f_91073_.m_46722_(p_109705_); + if (!(f <= 0.0F)) { + p_109704_.m_109896_(); +@@ -362,6 +_,11 @@ + } + + public void m_109693_(Camera p_109694_) { ++ net.minecraftforge.client.IWeatherParticleRenderHandler renderHandler = f_109465_.m_104583_().getWeatherParticleRenderHandler(); ++ if (renderHandler != null) { ++ renderHandler.render(f_109477_, f_109465_, f_109461_, p_109694_); ++ return; ++ } + float f = this.f_109461_.f_91073_.m_46722_(1.0F) / (Minecraft.m_91405_() ? 1.0F : 2.0F); + if (!(f <= 0.0F)) { + Random random = new Random((long)this.f_109477_ * 312987231L); +@@ -804,7 +_,7 @@ + this.f_109448_ = true; + BlockPos blockpos2 = chunkrenderdispatcher$renderchunk1.m_112839_().m_142082_(8, 8, 8); + boolean flag = blockpos2.m_123331_(blockpos) < 768.0D; +- if (!chunkrenderdispatcher$renderchunk1.m_112842_() && !flag) { ++ if (net.minecraftforge.common.ForgeConfig.CLIENT.alwaysSetupTerrainOffThread.get() || !chunkrenderdispatcher$renderchunk1.m_112842_() && !flag) { + this.f_109466_.add(chunkrenderdispatcher$renderchunk1); + } else { + this.f_109461_.m_91307_().m_6180_("build near"); +@@ -980,13 +_,14 @@ + RenderSystem.m_69421_(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_(); ++ FogRenderer.setupFog(p_109604_, FogRenderer.FogMode.FOG_SKY, f, flag1, p_109601_); + profilerfiller.m_6182_("sky"); + RenderSystem.m_157427_(GameRenderer::m_172808_); + this.m_181409_(p_109600_, p_109607_, p_109601_, () -> { + FogRenderer.m_109024_(p_109604_, FogRenderer.FogMode.FOG_SKY, f, flag1); + }); + profilerfiller.m_6182_("fog"); +- FogRenderer.m_109024_(p_109604_, FogRenderer.FogMode.FOG_TERRAIN, Math.max(f - 16.0F, 32.0F), flag1); ++ FogRenderer.setupFog(p_109604_, FogRenderer.FogMode.FOG_TERRAIN, Math.max(f - 16.0F, 32.0F), flag1, p_109601_); + profilerfiller.m_6182_("terrain_setup"); + this.m_109695_(p_109604_, frustum, flag, this.f_109449_++, this.f_109461_.f_91074_.m_5833_()); + profilerfiller.m_6182_("updatechunks"); +@@ -1007,7 +_,9 @@ + this.m_109510_(p_109602_ + l1); + profilerfiller.m_6182_("terrain"); + this.m_172993_(RenderType.m_110451_(), p_109600_, d0, d1, d2, p_109607_); ++ this.f_109461_.m_91304_().m_119428_(TextureAtlas.f_118259_).setBlurMipmap(false, this.f_109461_.f_91066_.f_92027_ > 0); // FORGE: fix flickering leaves when mods mess up the blurMipmap settings + this.m_172993_(RenderType.m_110457_(), p_109600_, d0, d1, d2, p_109607_); ++ this.f_109461_.m_91304_().m_119428_(TextureAtlas.f_118259_).restoreLastBlurMipmap(); + this.m_172993_(RenderType.m_110463_(), p_109600_, d0, d1, d2, p_109607_); + if (this.f_109465_.m_104583_().m_108885_()) { + Lighting.m_84925_(p_109600_.m_85850_().m_85861_()); +@@ -1037,7 +_,7 @@ + MultiBufferSource.BufferSource multibuffersource$buffersource = this.f_109464_.m_110104_(); + + 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_)) && (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_109463_.m_114397_(entity, frustum, d0, d1, d2) || entity.m_20367_(this.f_109461_.f_91074_)) && (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_(); +@@ -1076,6 +_,7 @@ + List list = levelrenderer$renderchunkinfo.f_109839_.m_112835_().m_112773_(); + if (!list.isEmpty()) { + for(BlockEntity blockentity1 : list) { ++ if(!frustum.m_113029_(blockentity1.getRenderBoundingBox())) continue; + BlockPos blockpos3 = blockentity1.m_58899_(); + MultiBufferSource multibuffersource1 = multibuffersource$buffersource; + p_109600_.m_85836_(); +@@ -1101,6 +_,7 @@ + + synchronized(this.f_109468_) { + for(BlockEntity blockentity : this.f_109468_) { ++ if(!frustum.m_113029_(blockentity.getRenderBoundingBox())) continue; + BlockPos blockpos2 = blockentity.m_58899_(); + p_109600_.m_85836_(); + p_109600_.m_85837_((double)blockpos2.m_123341_() - d0, (double)blockpos2.m_123342_() - d1, (double)blockpos2.m_123343_() - d2); +@@ -1152,10 +_,13 @@ + profilerfiller.m_6182_("outline"); + BlockPos blockpos = ((BlockHitResult)hitresult).m_82425_(); + BlockState blockstate = this.f_109465_.m_8055_(blockpos); ++ if (!net.minecraftforge.client.ForgeHooksClient.onDrawBlockHighlight(this, p_109604_, hitresult, p_109601_, p_109600_, multibuffersource$buffersource)) + if (!blockstate.m_60795_() && this.f_109465_.m_6857_().m_61937_(blockpos)) { + VertexConsumer vertexconsumer2 = multibuffersource$buffersource.m_6299_(RenderType.m_110504_()); + this.m_109637_(p_109600_, vertexconsumer2, p_109604_.m_90592_(), d0, d1, d2, blockpos, blockstate); + } ++ } else if (hitresult != null && hitresult.m_6662_() == HitResult.Type.ENTITY) { ++ net.minecraftforge.client.ForgeHooksClient.onDrawBlockHighlight(this, p_109604_, hitresult, p_109601_, p_109600_, multibuffersource$buffersource); + } + + PoseStack posestack = RenderSystem.m_157191_(); +@@ -1190,7 +_,7 @@ + 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); + RenderStateShard.f_110126_.m_110188_(); + } else { + profilerfiller.m_6182_("translucent"); +@@ -1204,7 +_,7 @@ + profilerfiller.m_6182_("string"); + this.m_172993_(RenderType.m_110503_(), p_109600_, d0, d1, d2, p_109607_); + 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); + } + + posestack.m_85836_(); +@@ -1632,6 +_,11 @@ + + public void m_181409_(PoseStack p_181410_, Matrix4f p_181411_, float p_181412_, Runnable p_181413_) { + p_181413_.run(); ++ net.minecraftforge.client.ISkyRenderHandler renderHandler = f_109465_.m_104583_().getSkyRenderHandler(); ++ if (renderHandler != null) { ++ renderHandler.render(f_109477_, p_181412_, p_181410_, f_109465_, f_109461_); ++ return; ++ } + if (this.f_109461_.f_91073_.m_104583_().m_108883_() == DimensionSpecialEffects.SkyType.END) { + this.m_109780_(p_181410_); + } else if (this.f_109461_.f_91073_.m_104583_().m_108883_() == DimensionSpecialEffects.SkyType.NORMAL) { +@@ -1746,6 +_,11 @@ + } + + public void m_172954_(PoseStack p_172955_, Matrix4f p_172956_, float p_172957_, double p_172958_, double p_172959_, double p_172960_) { ++ net.minecraftforge.client.ICloudRenderHandler renderHandler = f_109465_.m_104583_().getCloudRenderHandler(); ++ if (renderHandler != null) { ++ renderHandler.render(f_109477_, p_172957_, p_172955_, f_109465_, f_109461_, p_172958_, p_172959_, p_172960_); ++ return; ++ } + float f = this.f_109465_.m_104583_().m_108871_(); + if (!Float.isNaN(f)) { + RenderSystem.m_69464_(); +@@ -1923,7 +_,7 @@ + + while(iterator.hasNext()) { + ChunkRenderDispatcher.RenderChunk chunkrenderdispatcher$renderchunk = iterator.next(); +- if (chunkrenderdispatcher$renderchunk.m_112842_()) { ++ if (!net.minecraftforge.common.ForgeConfig.CLIENT.alwaysSetupTerrainOffThread.get() && chunkrenderdispatcher$renderchunk.m_112842_()) { + this.f_109436_.m_112715_(chunkrenderdispatcher$renderchunk); + } else { + chunkrenderdispatcher$renderchunk.m_112820_(this.f_109436_); +@@ -2216,7 +_,12 @@ + this.f_109469_.m_110859_(p_109502_, p_109503_, p_109504_, p_109505_); + } + ++ @Deprecated // Forge: use item aware function below + public void m_109514_(@Nullable SoundEvent p_109515_, BlockPos p_109516_) { ++ this.playStreamingMusic(p_109515_, p_109516_, p_109515_ == null? null : RecordItem.m_43040_(p_109515_)); ++ } ++ ++ public void playStreamingMusic(@Nullable SoundEvent p_109515_, BlockPos p_109516_, @Nullable RecordItem musicDiscItem) { + SoundInstance soundinstance = this.f_109410_.get(p_109516_); + if (soundinstance != null) { + this.f_109461_.m_91106_().m_120399_(soundinstance); +@@ -2224,7 +_,7 @@ + } + + if (p_109515_ != null) { +- RecordItem recorditem = RecordItem.m_43040_(p_109515_); ++ RecordItem recorditem = musicDiscItem; + if (recorditem != null) { + this.f_109461_.f_91065_.m_93055_(recorditem.m_43050_()); + } +@@ -2376,7 +_,7 @@ + break; + case 1010: + if (Item.m_41445_(p_109536_) instanceof RecordItem) { +- this.m_109514_(((RecordItem)Item.m_41445_(p_109536_)).m_43051_(), p_109535_); ++ this.playStreamingMusic(((RecordItem)Item.m_41445_(p_109536_)).m_43051_(), p_109535_, (RecordItem) Item.m_41445_(p_109536_)); + } else { + this.m_109514_((SoundEvent)null, p_109535_); + } +@@ -2546,7 +_,7 @@ + case 2001: + BlockState blockstate = Block.m_49803_(p_109536_); + if (!blockstate.m_60795_()) { +- SoundType soundtype = blockstate.m_60827_(); ++ SoundType soundtype = blockstate.getSoundType(this.f_109465_, p_109535_, null); + this.f_109465_.m_104677_(p_109535_, soundtype.m_56775_(), SoundSource.BLOCKS, (soundtype.m_56773_() + 1.0F) / 2.0F, soundtype.m_56774_() * 0.8F, false); + } + +@@ -2711,7 +_,7 @@ + } else { + int i = p_109538_.m_45517_(LightLayer.SKY, p_109540_); + int j = p_109538_.m_45517_(LightLayer.BLOCK, p_109540_); +- int k = p_109539_.m_60791_(); ++ int k = p_109539_.getLightEmission(p_109538_, p_109540_); + if (j < k) { + j = k; + } +@@ -2748,6 +_,11 @@ + @Nullable + public RenderTarget m_109832_() { + return this.f_109417_; ++ } ++ ++ @Override ++ public net.minecraftforge.resource.IResourceType getResourceType() { ++ return net.minecraftforge.resource.VanillaResourceType.MODELS; + } + + @OnlyIn(Dist.CLIENT) diff --git a/patches/minecraft/net/minecraft/client/renderer/LightTexture.java.patch b/patches/minecraft/net/minecraft/client/renderer/LightTexture.java.patch index 3c53caba3e..5905d2bf9c 100644 --- a/patches/minecraft/net/minecraft/client/renderer/LightTexture.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/LightTexture.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/client/renderer/LightTexture.java +++ b/net/minecraft/client/renderer/LightTexture.java -@@ -169,7 +_,7 @@ +@@ -160,7 +_,7 @@ } - public static int func_228450_a_(int p_228450_0_) { -- return p_228450_0_ >> 4 & '\uffff'; -+ return (p_228450_0_ & 0xFFFF) >> 4; // Forge: Fix fullbright quads showing dark artifacts. Reported as MC-169806 + public static int m_109883_(int p_109884_) { +- return p_109884_ >> 4 & '\uffff'; ++ return (p_109884_ & 0xFFFF) >> 4; // Forge: Fix fullbright quads showing dark artifacts. Reported as MC-169806 } - public static int func_228454_b_(int p_228454_0_) { + public static int m_109894_(int p_109895_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/OverlayRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/OverlayRenderer.java.patch deleted file mode 100644 index 12c9ebe93f..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/OverlayRenderer.java.patch +++ /dev/null @@ -1,48 +0,0 @@ ---- a/net/minecraft/client/renderer/OverlayRenderer.java -+++ b/net/minecraft/client/renderer/OverlayRenderer.java -@@ -27,18 +_,21 @@ - RenderSystem.disableAlphaTest(); - PlayerEntity playerentity = p_228734_0_.field_71439_g; - if (!playerentity.field_70145_X) { -- BlockState blockstate = func_230018_a_(playerentity); -- if (blockstate != null) { -- func_228735_a_(p_228734_0_, p_228734_0_.func_175602_ab().func_175023_a().func_178122_a(blockstate), p_228734_1_); -+ org.apache.commons.lang3.tuple.Pair overlay = getOverlayBlock(playerentity); -+ if (overlay != null) { -+ if (!net.minecraftforge.event.ForgeEventFactory.renderBlockOverlay(playerentity, p_228734_1_, net.minecraftforge.client.event.RenderBlockOverlayEvent.OverlayType.BLOCK, overlay.getLeft(), overlay.getRight())) -+ func_228735_a_(p_228734_0_, p_228734_0_.func_175602_ab().func_175023_a().getTexture(overlay.getLeft(), p_228734_0_.field_71441_e, overlay.getRight()), p_228734_1_); - } - } - - if (!p_228734_0_.field_71439_g.func_175149_v()) { - if (p_228734_0_.field_71439_g.func_208600_a(FluidTags.field_206959_a)) { -+ if (!net.minecraftforge.event.ForgeEventFactory.renderWaterOverlay(playerentity, p_228734_1_)) - func_228736_b_(p_228734_0_, p_228734_1_); - } - - if (p_228734_0_.field_71439_g.func_70027_ad()) { -+ if (!net.minecraftforge.event.ForgeEventFactory.renderFireOverlay(playerentity, p_228734_1_)) - func_228737_c_(p_228734_0_, p_228734_1_); - } - } -@@ -48,6 +_,11 @@ - - @Nullable - private static BlockState func_230018_a_(PlayerEntity p_230018_0_) { -+ return getOverlayBlock(p_230018_0_).getLeft(); -+ } -+ -+ @Nullable -+ private static org.apache.commons.lang3.tuple.Pair getOverlayBlock(PlayerEntity p_230018_0_) { - BlockPos.Mutable blockpos$mutable = new BlockPos.Mutable(); - - for(int i = 0; i < 8; ++i) { -@@ -57,7 +_,7 @@ - blockpos$mutable.func_189532_c(d0, d1, d2); - BlockState blockstate = p_230018_0_.field_70170_p.func_180495_p(blockpos$mutable); - if (blockstate.func_185901_i() != BlockRenderType.INVISIBLE && blockstate.func_215696_m(p_230018_0_.field_70170_p, blockpos$mutable)) { -- return blockstate; -+ return org.apache.commons.lang3.tuple.Pair.of(blockstate, blockpos$mutable.func_185334_h()); - } - } - diff --git a/patches/minecraft/net/minecraft/client/renderer/PostChain.java.patch b/patches/minecraft/net/minecraft/client/renderer/PostChain.java.patch new file mode 100644 index 0000000000..2d1c19f5b4 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/PostChain.java.patch @@ -0,0 +1,12 @@ +--- a/net/minecraft/client/renderer/PostChain.java ++++ b/net/minecraft/client/renderer/PostChain.java +@@ -168,7 +_,8 @@ + throw new ChainedJsonException("Render target '" + s4 + "' can't be used as depth buffer"); + } + +- ResourceLocation resourcelocation = new ResourceLocation("textures/effect/" + s4 + ".png"); ++ ResourceLocation rl = ResourceLocation.m_135820_(s4); ++ ResourceLocation resourcelocation = new ResourceLocation(rl.m_135827_(), "textures/effect/" + rl.m_135815_() + ".png"); + Resource resource = null; + + try { diff --git a/patches/minecraft/net/minecraft/client/renderer/RenderType.java.patch b/patches/minecraft/net/minecraft/client/renderer/RenderType.java.patch deleted file mode 100644 index ce87c03e95..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/RenderType.java.patch +++ /dev/null @@ -1,16 +0,0 @@ ---- a/net/minecraft/client/renderer/RenderType.java -+++ b/net/minecraft/client/renderer/RenderType.java -@@ -215,11 +_,11 @@ - } - - public static RenderType func_228658_l_(ResourceLocation p_228658_0_) { -- return func_228633_a_("text", DefaultVertexFormats.field_227852_q_, 7, 256, false, true, RenderType.State.func_228694_a_().func_228724_a_(new RenderState.TextureState(p_228658_0_, false, false)).func_228713_a_(field_228517_i_).func_228726_a_(field_228515_g_).func_228719_a_(field_228528_t_).func_228728_a_(false)); -+ return net.minecraftforge.client.ForgeRenderTypes.getText(p_228658_0_); - } - - public static RenderType func_228660_m_(ResourceLocation p_228660_0_) { -- return func_228633_a_("text_see_through", DefaultVertexFormats.field_227852_q_, 7, 256, false, true, RenderType.State.func_228694_a_().func_228724_a_(new RenderState.TextureState(p_228660_0_, false, false)).func_228713_a_(field_228517_i_).func_228726_a_(field_228515_g_).func_228719_a_(field_228528_t_).func_228715_a_(field_228492_B_).func_228727_a_(field_228496_F_).func_228728_a_(false)); -+ return net.minecraftforge.client.ForgeRenderTypes.getTextSeeThrough(p_228660_0_); - } - - public static RenderType func_228657_l_() { diff --git a/patches/minecraft/net/minecraft/client/renderer/RenderTypeLookup.java.patch b/patches/minecraft/net/minecraft/client/renderer/RenderTypeLookup.java.patch deleted file mode 100644 index 66fb1d3e8a..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/RenderTypeLookup.java.patch +++ /dev/null @@ -1,103 +0,0 @@ ---- a/net/minecraft/client/renderer/RenderTypeLookup.java -+++ b/net/minecraft/client/renderer/RenderTypeLookup.java -@@ -19,6 +_,7 @@ - - @OnlyIn(Dist.CLIENT) - public class RenderTypeLookup { -+ @Deprecated - private static final Map field_228386_a_ = Util.func_200696_a(Maps.newHashMap(), (p_228395_0_) -> { - RenderType rendertype = RenderType.func_241715_r_(); - p_228395_0_.put(Blocks.field_150473_bD, rendertype); -@@ -263,6 +_,7 @@ - p_228395_0_.put(Blocks.field_185778_de, rendertype3); - p_228395_0_.put(Blocks.field_203203_C, rendertype3); - }); -+ @Deprecated - private static final Map field_228387_b_ = Util.func_200696_a(Maps.newHashMap(), (p_228392_0_) -> { - RenderType rendertype = RenderType.func_228645_f_(); - p_228392_0_.put(Fluids.field_207212_b, rendertype); -@@ -270,6 +_,7 @@ - }); - private static boolean field_228388_c_; - -+ @Deprecated // FORGE: Use canRenderInLayer - public static RenderType func_228390_a_(BlockState p_228390_0_) { - Block block = p_228390_0_.func_177230_c(); - if (block instanceof LeavesBlock) { -@@ -280,6 +_,7 @@ - } - } - -+ @Deprecated // FORGE: Use canRenderInLayer - public static RenderType func_239221_b_(BlockState p_239221_0_) { - Block block = p_239221_0_.func_177230_c(); - if (block instanceof LeavesBlock) { -@@ -295,8 +_,7 @@ - } - - public static RenderType func_239220_a_(BlockState p_239220_0_, boolean p_239220_1_) { -- RenderType rendertype = func_228390_a_(p_239220_0_); -- if (rendertype == RenderType.func_228645_f_()) { -+ if (canRenderInLayer(p_239220_0_, RenderType.func_228645_f_())) { - if (!Minecraft.func_238218_y_()) { - return Atlases.func_228785_j_(); - } else { -@@ -317,9 +_,58 @@ - } - } - -+ @Deprecated // FORGE: Use canRenderInLayer - public static RenderType func_228391_a_(FluidState p_228391_0_) { - RenderType rendertype = field_228387_b_.get(p_228391_0_.func_206886_c()); - return rendertype != null ? rendertype : RenderType.func_228639_c_(); -+ } -+ -+ // FORGE START -+ -+ private static final Map, java.util.function.Predicate> blockRenderChecks = Maps.newHashMap(); -+ private static final Map, java.util.function.Predicate> fluidRenderChecks = Maps.newHashMap(); -+ static { -+ field_228386_a_.forEach(RenderTypeLookup::setRenderLayer); -+ field_228387_b_.forEach(RenderTypeLookup::setRenderLayer); -+ } -+ -+ public static boolean canRenderInLayer(BlockState state, RenderType type) { -+ Block block = state.func_177230_c(); -+ if (block instanceof LeavesBlock) { -+ return field_228388_c_ ? type == RenderType.func_228641_d_() : type == RenderType.func_228639_c_(); -+ } else { -+ java.util.function.Predicate rendertype; -+ synchronized (RenderTypeLookup.class) { -+ rendertype = blockRenderChecks.get(block.delegate); -+ } -+ return rendertype != null ? rendertype.test(type) : type == RenderType.func_228639_c_(); -+ } -+ } -+ -+ public static boolean canRenderInLayer(FluidState fluid, RenderType type) { -+ java.util.function.Predicate rendertype; -+ synchronized (RenderTypeLookup.class) { -+ rendertype = fluidRenderChecks.get(fluid.func_206886_c().delegate); -+ } -+ return rendertype != null ? rendertype.test(type) : type == RenderType.func_228639_c_(); -+ } -+ -+ public static void setRenderLayer(Block block, RenderType type) { -+ java.util.Objects.requireNonNull(type); -+ setRenderLayer(block, type::equals); -+ } -+ -+ public static synchronized void setRenderLayer(Block block, java.util.function.Predicate predicate) { -+ blockRenderChecks.put(block.delegate, predicate); -+ } -+ -+ public static void setRenderLayer(Fluid fluid, RenderType type) { -+ java.util.Objects.requireNonNull(type); -+ setRenderLayer(fluid, type::equals); -+ } -+ -+ public static synchronized void setRenderLayer(Fluid fluid, java.util.function.Predicate predicate) { -+ fluidRenderChecks.put(fluid.delegate, predicate); - } - - public static void func_228393_a_(boolean p_228393_0_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/ScreenEffectRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/ScreenEffectRenderer.java.patch new file mode 100644 index 0000000000..dc73c3b165 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/ScreenEffectRenderer.java.patch @@ -0,0 +1,48 @@ +--- a/net/minecraft/client/renderer/ScreenEffectRenderer.java ++++ b/net/minecraft/client/renderer/ScreenEffectRenderer.java +@@ -30,18 +_,21 @@ + public static void m_110718_(Minecraft p_110719_, PoseStack p_110720_) { + Player player = p_110719_.f_91074_; + if (!player.f_19794_) { +- BlockState blockstate = m_110716_(player); +- if (blockstate != null) { +- m_173296_(p_110719_.m_91289_().m_110907_().m_110882_(blockstate), p_110720_); ++ org.apache.commons.lang3.tuple.Pair overlay = getOverlayBlock(player); ++ if (overlay != null) { ++ if (!net.minecraftforge.event.ForgeEventFactory.renderBlockOverlay(player, p_110720_, net.minecraftforge.client.event.RenderBlockOverlayEvent.OverlayType.BLOCK, overlay.getLeft(), overlay.getRight())) ++ m_173296_(p_110719_.m_91289_().m_110907_().getTexture(overlay.getLeft(), p_110719_.f_91073_, overlay.getRight()), p_110720_); + } + } + + if (!p_110719_.f_91074_.m_5833_()) { + if (p_110719_.f_91074_.m_19941_(FluidTags.f_13131_)) { ++ if (!net.minecraftforge.event.ForgeEventFactory.renderWaterOverlay(player, p_110720_)) + m_110725_(p_110719_, p_110720_); + } + + if (p_110719_.f_91074_.m_6060_()) { ++ if (!net.minecraftforge.event.ForgeEventFactory.renderFireOverlay(player, p_110720_)) + m_110728_(p_110719_, p_110720_); + } + } +@@ -50,6 +_,11 @@ + + @Nullable + private static BlockState m_110716_(Player p_110717_) { ++ return getOverlayBlock(p_110717_).getLeft(); ++ } ++ ++ @Nullable ++ private static org.apache.commons.lang3.tuple.Pair getOverlayBlock(Player p_110717_) { + BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); + + for(int i = 0; i < 8; ++i) { +@@ -59,7 +_,7 @@ + blockpos$mutableblockpos.m_122169_(d0, d1, d2); + BlockState blockstate = p_110717_.f_19853_.m_8055_(blockpos$mutableblockpos); + if (blockstate.m_60799_() != RenderShape.INVISIBLE && blockstate.m_60831_(p_110717_.f_19853_, blockpos$mutableblockpos)) { +- return blockstate; ++ return org.apache.commons.lang3.tuple.Pair.of(blockstate, blockpos$mutableblockpos.m_7949_()); + } + } + diff --git a/patches/minecraft/net/minecraft/client/renderer/Sheets.java.patch b/patches/minecraft/net/minecraft/client/renderer/Sheets.java.patch new file mode 100644 index 0000000000..9ae217780b --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/Sheets.java.patch @@ -0,0 +1,25 @@ +--- a/net/minecraft/client/renderer/Sheets.java ++++ b/net/minecraft/client/renderer/Sheets.java +@@ -127,7 +_,8 @@ + } + + private static Material m_173385_(WoodType p_173386_) { +- return new Material(f_110739_, new ResourceLocation("entity/signs/" + p_173386_.m_61846_())); ++ ResourceLocation location = new ResourceLocation(p_173386_.m_61846_()); ++ return new Material(f_110739_, new ResourceLocation(location.m_135827_(), "entity/signs/" + location.m_135815_())); + } + + public static Material m_173381_(WoodType p_173382_) { +@@ -174,5 +_,12 @@ + default: + return p_110773_; + } ++ } ++ ++ /** ++ * Not threadsafe. Enqueue it in client setup. ++ */ ++ public static void addWoodType(WoodType woodType) { ++ f_110743_.put(woodType, m_173385_(woodType)); + } + } diff --git a/patches/minecraft/net/minecraft/client/renderer/WorldRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/WorldRenderer.java.patch deleted file mode 100644 index 40bd40eceb..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/WorldRenderer.java.patch +++ /dev/null @@ -1,215 +0,0 @@ ---- a/net/minecraft/client/renderer/WorldRenderer.java -+++ b/net/minecraft/client/renderer/WorldRenderer.java -@@ -222,6 +_,11 @@ - } - - private void func_228438_a_(LightTexture p_228438_1_, float p_228438_2_, double p_228438_3_, double p_228438_5_, double p_228438_7_) { -+ net.minecraftforge.client.IWeatherRenderHandler renderHandler = field_72769_h.func_239132_a_().getWeatherRenderHandler(); -+ if (renderHandler != null) { -+ renderHandler.render(field_72773_u, p_228438_2_, field_72769_h, field_72777_q, p_228438_1_, p_228438_3_, p_228438_5_, p_228438_7_); -+ return; -+ } - float f = this.field_72777_q.field_71441_e.func_72867_j(p_228438_2_); - if (!(f <= 0.0F)) { - p_228438_1_.func_205109_c(); -@@ -347,6 +_,11 @@ - } - - public void func_228436_a_(ActiveRenderInfo p_228436_1_) { -+ net.minecraftforge.client.IWeatherParticleRenderHandler renderHandler = field_72769_h.func_239132_a_().getWeatherParticleRenderHandler(); -+ if (renderHandler != null) { -+ renderHandler.render(field_72773_u, field_72769_h, field_72777_q, p_228436_1_); -+ return; -+ } - float f = this.field_72777_q.field_71441_e.func_72867_j(1.0F) / (Minecraft.func_71375_t() ? 1.0F : 2.0F); - if (!(f <= 0.0F)) { - Random random = new Random((long)this.field_72773_u * 312987231L); -@@ -830,7 +_,7 @@ - this.field_147595_R = true; - BlockPos blockpos2 = chunkrenderdispatcher$chunkrender4.func_178568_j().func_177982_a(8, 8, 8); - boolean flag1 = blockpos2.func_177951_i(blockpos) < 768.0D; -- if (!chunkrenderdispatcher$chunkrender4.func_188281_o() && !flag1) { -+ if (net.minecraftforge.common.ForgeConfig.CLIENT.alwaysSetupTerrainOffThread.get() || !chunkrenderdispatcher$chunkrender4.func_188281_o() && !flag1) { - this.field_175009_l.add(chunkrenderdispatcher$chunkrender4); - } else { - this.field_72777_q.func_213239_aq().func_76320_a("build near"); -@@ -915,13 +_,13 @@ - float f = p_228426_7_.func_205001_m(); - boolean flag1 = this.field_72777_q.field_71441_e.func_239132_a_().func_230493_a_(MathHelper.func_76128_c(d0), MathHelper.func_76128_c(d1)) || this.field_72777_q.field_71456_v.func_184046_j().func_184056_f(); - if (this.field_72777_q.field_71474_y.field_151451_c >= 4) { -- FogRenderer.func_228372_a_(p_228426_6_, FogRenderer.FogType.FOG_SKY, f, flag1); -+ FogRenderer.setupFog(p_228426_6_, FogRenderer.FogType.FOG_SKY, f, flag1, p_228426_2_); - iprofiler.func_219895_b("sky"); - this.func_228424_a_(p_228426_1_, p_228426_2_); - } - - iprofiler.func_219895_b("fog"); -- FogRenderer.func_228372_a_(p_228426_6_, FogRenderer.FogType.FOG_TERRAIN, Math.max(f - 16.0F, 32.0F), flag1); -+ FogRenderer.setupFog(p_228426_6_, FogRenderer.FogType.FOG_TERRAIN, Math.max(f - 16.0F, 32.0F), flag1, p_228426_2_); - iprofiler.func_219895_b("terrain_setup"); - this.func_228437_a_(p_228426_6_, clippinghelper, flag, this.field_228409_ai_++, this.field_72777_q.field_71439_g.func_175149_v()); - iprofiler.func_219895_b("updatechunks"); -@@ -942,7 +_,9 @@ - this.func_174967_a(p_228426_3_ + l1); - iprofiler.func_219895_b("terrain"); - this.func_228441_a_(RenderType.func_228639_c_(), p_228426_1_, d0, d1, d2); -+ this.field_72777_q.func_209506_al().func_229356_a_(AtlasTexture.field_110575_b).setBlurMipmap(false, this.field_72777_q.field_71474_y.field_151442_I > 0); // FORGE: fix flickering leaves when mods mess up the blurMipmap settings - this.func_228441_a_(RenderType.func_228641_d_(), p_228426_1_, d0, d1, d2); -+ this.field_72777_q.func_209506_al().func_229356_a_(AtlasTexture.field_110575_b).restoreLastBlurMipmap(); - this.func_228441_a_(RenderType.func_228643_e_(), p_228426_1_, d0, d1, d2); - if (this.field_72769_h.func_239132_a_().func_239217_c_()) { - RenderHelper.func_237533_a_(p_228426_1_.func_227866_c_().func_227870_a_()); -@@ -972,7 +_,7 @@ - IRenderTypeBuffer.Impl irendertypebuffer$impl = this.field_228415_m_.func_228487_b_(); - - for(Entity entity : this.field_72769_h.func_217416_b()) { -- if ((this.field_175010_j.func_229086_a_(entity, clippinghelper, d0, d1, d2) || entity.func_184215_y(this.field_72777_q.field_71439_g)) && (entity != p_228426_6_.func_216773_g() || p_228426_6_.func_216770_i() || p_228426_6_.func_216773_g() instanceof LivingEntity && ((LivingEntity)p_228426_6_.func_216773_g()).func_70608_bn()) && (!(entity instanceof ClientPlayerEntity) || p_228426_6_.func_216773_g() == entity)) { -+ if ((this.field_175010_j.func_229086_a_(entity, clippinghelper, d0, d1, d2) || entity.func_184215_y(this.field_72777_q.field_71439_g)) && (entity != p_228426_6_.func_216773_g() || p_228426_6_.func_216770_i() || p_228426_6_.func_216773_g() instanceof LivingEntity && ((LivingEntity)p_228426_6_.func_216773_g()).func_70608_bn()) && (!(entity instanceof ClientPlayerEntity) || p_228426_6_.func_216773_g() == entity || (entity == field_72777_q.field_71439_g && !field_72777_q.field_71439_g.func_175149_v()))) { //FORGE: render local player entity when it is not the renderViewEntity - ++this.field_72749_I; - if (entity.field_70173_aa == 0) { - entity.field_70142_S = entity.func_226277_ct_(); -@@ -1010,6 +_,7 @@ - List list = worldrenderer$localrenderinformationcontainer.field_178036_a.func_178571_g().func_178485_b(); - if (!list.isEmpty()) { - for(TileEntity tileentity1 : list) { -+ if(!clippinghelper.func_228957_a_(tileentity1.getRenderBoundingBox())) continue; - BlockPos blockpos3 = tileentity1.func_174877_v(); - IRenderTypeBuffer irendertypebuffer1 = irendertypebuffer$impl; - p_228426_1_.func_227860_a_(); -@@ -1035,6 +_,7 @@ - - synchronized(this.field_181024_n) { - for(TileEntity tileentity : this.field_181024_n) { -+ if(!clippinghelper.func_228957_a_(tileentity.getRenderBoundingBox())) continue; - BlockPos blockpos2 = tileentity.func_174877_v(); - p_228426_1_.func_227860_a_(); - p_228426_1_.func_227861_a_((double)blockpos2.func_177958_n() - d0, (double)blockpos2.func_177956_o() - d1, (double)blockpos2.func_177952_p() - d2); -@@ -1084,10 +_,13 @@ - iprofiler.func_219895_b("outline"); - BlockPos blockpos = ((BlockRayTraceResult)raytraceresult).func_216350_a(); - BlockState blockstate = this.field_72769_h.func_180495_p(blockpos); -- if (!blockstate.func_196958_f() && this.field_72769_h.func_175723_af().func_177746_a(blockpos)) { -+ if (!net.minecraftforge.client.ForgeHooksClient.onDrawBlockHighlight(this, p_228426_6_, raytraceresult, p_228426_2_, p_228426_1_, irendertypebuffer$impl)) -+ if (!blockstate.isAir(this.field_72769_h, blockpos) && this.field_72769_h.func_175723_af().func_177746_a(blockpos)) { - IVertexBuilder ivertexbuilder2 = irendertypebuffer$impl.getBuffer(RenderType.func_228659_m_()); - this.func_228429_a_(p_228426_1_, ivertexbuilder2, p_228426_6_.func_216773_g(), d0, d1, d2, blockpos, blockstate); - } -+ } else if (raytraceresult != null && raytraceresult.func_216346_c() == RayTraceResult.Type.ENTITY) { -+ net.minecraftforge.client.ForgeHooksClient.onDrawBlockHighlight(this, p_228426_6_, raytraceresult, p_228426_2_, p_228426_1_, irendertypebuffer$impl); - } - - RenderSystem.pushMatrix(); -@@ -1119,7 +_,7 @@ - this.field_239224_H_.func_237506_a_(this.field_72777_q.func_147110_a()); - RenderState.field_239237_T_.func_228547_a_(); - iprofiler.func_219895_b("particles"); -- this.field_72777_q.field_71452_i.func_228345_a_(p_228426_1_, irendertypebuffer$impl, p_228426_8_, p_228426_6_, p_228426_2_); -+ this.field_72777_q.field_71452_i.renderParticles(p_228426_1_, irendertypebuffer$impl, p_228426_8_, p_228426_6_, p_228426_2_, clippinghelper); - RenderState.field_239237_T_.func_228549_b_(); - } else { - iprofiler.func_219895_b("translucent"); -@@ -1129,7 +_,7 @@ - iprofiler.func_219895_b("string"); - this.func_228441_a_(RenderType.func_241715_r_(), p_228426_1_, d0, d1, d2); - iprofiler.func_219895_b("particles"); -- this.field_72777_q.field_71452_i.func_228345_a_(p_228426_1_, irendertypebuffer$impl, p_228426_8_, p_228426_6_, p_228426_2_); -+ this.field_72777_q.field_71452_i.renderParticles(p_228426_1_, irendertypebuffer$impl, p_228426_8_, p_228426_6_, p_228426_2_, clippinghelper); - } - - RenderSystem.pushMatrix(); -@@ -1481,6 +_,11 @@ - } - - public void func_228424_a_(MatrixStack p_228424_1_, float p_228424_2_) { -+ net.minecraftforge.client.ISkyRenderHandler renderHandler = field_72769_h.func_239132_a_().getSkyRenderHandler(); -+ if (renderHandler != null) { -+ renderHandler.render(field_72773_u, p_228424_2_, p_228424_1_, field_72769_h, field_72777_q); -+ return; -+ } - if (this.field_72777_q.field_71441_e.func_239132_a_().func_241683_c_() == DimensionRenderInfo.FogType.END) { - this.func_228444_b_(p_228424_1_); - } else if (this.field_72777_q.field_71441_e.func_239132_a_().func_241683_c_() == DimensionRenderInfo.FogType.NORMAL) { -@@ -1609,6 +_,11 @@ - } - - public void func_228425_a_(MatrixStack p_228425_1_, float p_228425_2_, double p_228425_3_, double p_228425_5_, double p_228425_7_) { -+ net.minecraftforge.client.ICloudRenderHandler renderHandler = field_72769_h.func_239132_a_().getCloudRenderHandler(); -+ if (renderHandler != null) { -+ renderHandler.render(field_72773_u, p_228425_2_, p_228425_1_, field_72769_h, field_72777_q, p_228425_3_, p_228425_5_, p_228425_7_); -+ return; -+ } - float f = this.field_72769_h.func_239132_a_().func_239213_a_(); - if (!Float.isNaN(f)) { - RenderSystem.disableCull(); -@@ -1792,7 +_,7 @@ - - while(iterator.hasNext()) { - ChunkRenderDispatcher.ChunkRender chunkrenderdispatcher$chunkrender = iterator.next(); -- if (chunkrenderdispatcher$chunkrender.func_188281_o()) { -+ if (!net.minecraftforge.common.ForgeConfig.CLIENT.alwaysSetupTerrainOffThread.get() && chunkrenderdispatcher$chunkrender.func_188281_o()) { - this.field_174995_M.func_228902_a_(chunkrenderdispatcher$chunkrender); - } else { - chunkrenderdispatcher$chunkrender.func_228929_a_(this.field_174995_M); -@@ -2076,7 +_,12 @@ - this.field_175008_n.func_217628_a(p_215319_1_, p_215319_2_, p_215319_3_, p_215319_4_); - } - -+ @Deprecated // Forge: use item aware function below - public void func_184377_a(@Nullable SoundEvent p_184377_1_, BlockPos p_184377_2_) { -+ this.playRecord(p_184377_1_, p_184377_2_, p_184377_1_ == null? null : MusicDiscItem.func_185074_a(p_184377_1_)); -+ } -+ -+ public void playRecord(@Nullable SoundEvent p_184377_1_, BlockPos p_184377_2_, @Nullable MusicDiscItem musicDiscItem) { - ISound isound = this.field_147593_P.get(p_184377_2_); - if (isound != null) { - this.field_72777_q.func_147118_V().func_147683_b(isound); -@@ -2084,7 +_,7 @@ - } - - if (p_184377_1_ != null) { -- MusicDiscItem musicdiscitem = MusicDiscItem.func_185074_a(p_184377_1_); -+ MusicDiscItem musicdiscitem = musicDiscItem; - if (musicdiscitem != null) { - this.field_72777_q.field_71456_v.func_238451_a_(musicdiscitem.func_234801_g_()); - } -@@ -2232,7 +_,7 @@ - break; - case 1010: - if (Item.func_150899_d(p_180439_4_) instanceof MusicDiscItem) { -- this.func_184377_a(((MusicDiscItem)Item.func_150899_d(p_180439_4_)).func_185075_h(), p_180439_3_); -+ this.playRecord(((MusicDiscItem)Item.func_150899_d(p_180439_4_)).func_185075_h(), p_180439_3_, (MusicDiscItem) Item.func_150899_d(p_180439_4_)); - } else { - this.func_184377_a((SoundEvent)null, p_180439_3_); - } -@@ -2382,8 +_,8 @@ - break; - case 2001: - BlockState blockstate = Block.func_196257_b(p_180439_4_); -- if (!blockstate.func_196958_f()) { -- SoundType soundtype = blockstate.func_215695_r(); -+ if (!blockstate.isAir(this.field_72769_h, p_180439_3_)) { -+ SoundType soundtype = blockstate.getSoundType(this.field_72769_h, p_180439_3_, null); - this.field_72769_h.func_184156_a(p_180439_3_, soundtype.func_185845_c(), SoundCategory.BLOCKS, (soundtype.func_185843_a() + 1.0F) / 2.0F, soundtype.func_185847_b() * 0.8F, false); - } - -@@ -2531,7 +_,7 @@ - } else { - int i = p_228420_0_.func_226658_a_(LightType.SKY, p_228420_2_); - int j = p_228420_0_.func_226658_a_(LightType.BLOCK, p_228420_2_); -- int k = p_228420_1_.func_185906_d(); -+ int k = p_228420_1_.getLightValue(p_228420_0_, p_228420_2_); - if (j < k) { - j = k; - } -@@ -2568,6 +_,11 @@ - @Nullable - public Framebuffer func_239232_u_() { - return this.field_239226_J_; -+ } -+ -+ @Override -+ public net.minecraftforge.resource.IResourceType getResourceType() { -+ return net.minecraftforge.resource.VanillaResourceType.MODELS; - } - - @OnlyIn(Dist.CLIENT) diff --git a/patches/minecraft/net/minecraft/client/renderer/block/BlockModelShaper.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/BlockModelShaper.java.patch new file mode 100644 index 0000000000..b89574c68a --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/block/BlockModelShaper.java.patch @@ -0,0 +1,18 @@ +--- a/net/minecraft/client/renderer/block/BlockModelShaper.java ++++ b/net/minecraft/client/renderer/block/BlockModelShaper.java +@@ -24,8 +_,14 @@ + this.f_110878_ = p_110880_; + } + ++ @Deprecated + public TextureAtlasSprite m_110882_(BlockState p_110883_) { +- return this.m_110893_(p_110883_).m_6160_(); ++ return this.m_110893_(p_110883_).getParticleIcon(net.minecraftforge.client.model.data.EmptyModelData.INSTANCE); ++ } ++ ++ public TextureAtlasSprite getTexture(BlockState p_110883_, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos) { ++ net.minecraftforge.client.model.data.IModelData data = net.minecraftforge.client.model.ModelDataManager.getModelData(level, pos); ++ return this.m_110893_(p_110883_).getParticleIcon(data == null ? net.minecraftforge.client.model.data.EmptyModelData.INSTANCE : data); + } + + public BakedModel m_110893_(BlockState p_110894_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/block/BlockRenderDispatcher.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/BlockRenderDispatcher.java.patch new file mode 100644 index 0000000000..2acda8e9d6 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/block/BlockRenderDispatcher.java.patch @@ -0,0 +1,77 @@ +--- a/net/minecraft/client/renderer/block/BlockRenderDispatcher.java ++++ b/net/minecraft/client/renderer/block/BlockRenderDispatcher.java +@@ -37,7 +_,7 @@ + this.f_110899_ = p_173399_; + this.f_173397_ = p_173400_; + this.f_110903_ = p_173401_; +- this.f_110900_ = new ModelBlockRenderer(this.f_110903_); ++ this.f_110900_ = new net.minecraftforge.client.model.pipeline.ForgeBlockModelRenderer(this.f_110903_); + this.f_110901_ = new LiquidBlockRenderer(); + } + +@@ -45,18 +_,26 @@ + return this.f_110899_; + } + ++ @Deprecated //Forge: Model parameter + public void m_110918_(BlockState p_110919_, BlockPos p_110920_, BlockAndTintGetter p_110921_, PoseStack p_110922_, VertexConsumer p_110923_) { ++ renderBreakingTexture(p_110919_,p_110920_, p_110921_, p_110922_, p_110923_, net.minecraftforge.client.model.data.EmptyModelData.INSTANCE); ++ } ++ public void renderBreakingTexture(BlockState p_110919_, BlockPos p_110920_, BlockAndTintGetter p_110921_, PoseStack p_110922_, VertexConsumer p_110923_, net.minecraftforge.client.model.data.IModelData modelData) { + if (p_110919_.m_60799_() == RenderShape.MODEL) { + BakedModel bakedmodel = this.f_110899_.m_110893_(p_110919_); + long i = p_110919_.m_60726_(p_110920_); +- this.f_110900_.m_111047_(p_110921_, bakedmodel, p_110919_, p_110920_, p_110922_, p_110923_, true, this.f_110902_, i, OverlayTexture.f_118083_); ++ this.f_110900_.tesselateBlock(p_110921_, bakedmodel, p_110919_, p_110920_, p_110922_, p_110923_, true, this.f_110902_, i, OverlayTexture.f_118083_, modelData); + } + } + ++ @Deprecated //Forge: Model parameter + public boolean m_110924_(BlockState p_110925_, BlockPos p_110926_, BlockAndTintGetter p_110927_, PoseStack p_110928_, VertexConsumer p_110929_, boolean p_110930_, Random p_110931_) { ++ return renderBatched(p_110925_, p_110926_, p_110927_, p_110928_, p_110929_, p_110930_, p_110931_, net.minecraftforge.client.model.data.EmptyModelData.INSTANCE); ++ } ++ public boolean renderBatched(BlockState p_110925_, BlockPos p_110926_, BlockAndTintGetter p_110927_, PoseStack p_110928_, VertexConsumer p_110929_, boolean p_110930_, Random p_110931_, net.minecraftforge.client.model.data.IModelData modelData) { + try { + RenderShape rendershape = p_110925_.m_60799_(); +- return rendershape != RenderShape.MODEL ? false : this.f_110900_.m_111047_(p_110927_, this.m_110910_(p_110925_), p_110925_, p_110926_, p_110928_, p_110929_, p_110930_, p_110931_, p_110925_.m_60726_(p_110926_), OverlayTexture.f_118083_); ++ return rendershape != RenderShape.MODEL ? false : this.f_110900_.tesselateBlock(p_110927_, this.m_110910_(p_110925_), p_110925_, p_110926_, p_110928_, p_110929_, p_110930_, p_110931_, p_110925_.m_60726_(p_110926_), OverlayTexture.f_118083_, modelData); + } catch (Throwable throwable) { + CrashReport crashreport = CrashReport.m_127521_(throwable, "Tesselating block in world"); + CrashReportCategory crashreportcategory = crashreport.m_127514_("Block being tesselated"); +@@ -84,7 +_,11 @@ + return this.f_110899_.m_110893_(p_110911_); + } + ++ @Deprecated //Forge: Model parameter + public void m_110912_(BlockState p_110913_, PoseStack p_110914_, MultiBufferSource p_110915_, int p_110916_, int p_110917_) { ++ renderSingleBlock(p_110913_, p_110914_, p_110915_, p_110916_, p_110917_, net.minecraftforge.client.model.data.EmptyModelData.INSTANCE); ++ } ++ public void renderSingleBlock(BlockState p_110913_, PoseStack p_110914_, MultiBufferSource p_110915_, int p_110916_, int p_110917_, net.minecraftforge.client.model.data.IModelData modelData) { + RenderShape rendershape = p_110913_.m_60799_(); + if (rendershape != RenderShape.INVISIBLE) { + switch(rendershape) { +@@ -94,10 +_,11 @@ + float f = (float)(i >> 16 & 255) / 255.0F; + float f1 = (float)(i >> 8 & 255) / 255.0F; + float f2 = (float)(i & 255) / 255.0F; +- this.f_110900_.m_111067_(p_110914_.m_85850_(), p_110915_.m_6299_(ItemBlockRenderTypes.m_109284_(p_110913_, false)), p_110913_, bakedmodel, f, f1, f2, p_110916_, p_110917_); ++ this.f_110900_.renderModel(p_110914_.m_85850_(), p_110915_.m_6299_(ItemBlockRenderTypes.m_109284_(p_110913_, false)), p_110913_, bakedmodel, f, f1, f2, p_110916_, p_110917_, modelData); + break; + case ENTITYBLOCK_ANIMATED: +- this.f_173397_.m_108829_(new ItemStack(p_110913_.m_60734_()), ItemTransforms.TransformType.NONE, p_110914_, p_110915_, p_110916_, p_110917_); ++ ItemStack stack = new ItemStack(p_110913_.m_60734_()); ++ net.minecraftforge.client.RenderProperties.get(stack).getItemStackRenderer().m_108829_(stack, ItemTransforms.TransformType.NONE, p_110914_, p_110915_, p_110916_, p_110917_); + } + + } +@@ -105,5 +_,10 @@ + + public void m_6213_(ResourceManager p_110909_) { + this.f_110901_.m_110944_(); ++ } ++ ++ @Override ++ public net.minecraftforge.resource.IResourceType getResourceType() { ++ return net.minecraftforge.resource.VanillaResourceType.MODELS; + } + } diff --git a/patches/minecraft/net/minecraft/client/renderer/block/LiquidBlockRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/LiquidBlockRenderer.java.patch new file mode 100644 index 0000000000..738f973461 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/block/LiquidBlockRenderer.java.patch @@ -0,0 +1,103 @@ +--- a/net/minecraft/client/renderer/block/LiquidBlockRenderer.java ++++ b/net/minecraft/client/renderer/block/LiquidBlockRenderer.java +@@ -72,9 +_,10 @@ + + public boolean m_110954_(BlockAndTintGetter p_110955_, BlockPos p_110956_, VertexConsumer p_110957_, FluidState p_110958_) { + boolean flag = p_110958_.m_76153_(FluidTags.f_13132_); +- TextureAtlasSprite[] atextureatlassprite = flag ? this.f_110940_ : this.f_110941_; ++ TextureAtlasSprite[] atextureatlassprite = net.minecraftforge.client.ForgeHooksClient.getFluidSprites(p_110955_, p_110956_, p_110958_); + BlockState blockstate = p_110955_.m_8055_(p_110956_); +- int i = flag ? 16777215 : BiomeColors.m_108811_(p_110955_, p_110956_); ++ int i = p_110958_.m_76152_().getAttributes().getColor(p_110955_, p_110956_); ++ float alpha = (float)(i >> 24 & 255) / 255.0F; + float f = (float)(i >> 16 & 255) / 255.0F; + float f1 = (float)(i >> 8 & 255) / 255.0F; + float f2 = (float)(i & 255) / 255.0F; +@@ -159,15 +_,15 @@ + float f25 = f4 * f; + float f26 = f4 * f1; + float f27 = f4 * f2; +- this.m_110984_(p_110957_, d0 + 0.0D, d1 + (double)f7, d2 + 0.0D, f25, f26, f27, f13, f17, j); +- this.m_110984_(p_110957_, d0 + 0.0D, d1 + (double)f8, d2 + 1.0D, f25, f26, f27, f14, f18, j); +- this.m_110984_(p_110957_, d0 + 1.0D, d1 + (double)f9, d2 + 1.0D, f25, f26, f27, f15, f19, j); +- this.m_110984_(p_110957_, d0 + 1.0D, d1 + (double)f10, d2 + 0.0D, f25, f26, f27, f16, f20, j); ++ this.vertex(p_110957_, d0 + 0.0D, d1 + (double)f7, d2 + 0.0D, f25, f26, f27, alpha, f13, f17, j); ++ this.vertex(p_110957_, d0 + 0.0D, d1 + (double)f8, d2 + 1.0D, f25, f26, f27, alpha, f14, f18, j); ++ this.vertex(p_110957_, d0 + 1.0D, d1 + (double)f9, d2 + 1.0D, f25, f26, f27, alpha, f15, f19, j); ++ this.vertex(p_110957_, d0 + 1.0D, d1 + (double)f10, d2 + 0.0D, f25, f26, f27, alpha, f16, f20, j); + if (p_110958_.m_76171_(p_110955_, p_110956_.m_7494_())) { +- this.m_110984_(p_110957_, d0 + 0.0D, d1 + (double)f7, d2 + 0.0D, f25, f26, f27, f13, f17, j); +- this.m_110984_(p_110957_, d0 + 1.0D, d1 + (double)f10, d2 + 0.0D, f25, f26, f27, f16, f20, j); +- this.m_110984_(p_110957_, d0 + 1.0D, d1 + (double)f9, d2 + 1.0D, f25, f26, f27, f15, f19, j); +- this.m_110984_(p_110957_, d0 + 0.0D, d1 + (double)f8, d2 + 1.0D, f25, f26, f27, f14, f18, j); ++ this.vertex(p_110957_, d0 + 0.0D, d1 + (double)f7, d2 + 0.0D, f25, f26, f27, alpha, f13, f17, j); ++ this.vertex(p_110957_, d0 + 1.0D, d1 + (double)f10, d2 + 0.0D, f25, f26, f27, alpha, f16, f20, j); ++ this.vertex(p_110957_, d0 + 1.0D, d1 + (double)f9, d2 + 1.0D, f25, f26, f27, alpha, f15, f19, j); ++ this.vertex(p_110957_, d0 + 0.0D, d1 + (double)f8, d2 + 1.0D, f25, f26, f27, alpha, f14, f18, j); + } + } + +@@ -180,10 +_,10 @@ + float f41 = f3 * f; + float f42 = f3 * f1; + float f43 = f3 * f2; +- this.m_110984_(p_110957_, d0, d1 + (double)f12, d2 + 1.0D, f41, f42, f43, f35, f39, i1); +- this.m_110984_(p_110957_, d0, d1 + (double)f12, d2, f41, f42, f43, f35, f37, i1); +- this.m_110984_(p_110957_, d0 + 1.0D, d1 + (double)f12, d2, f41, f42, f43, f36, f37, i1); +- this.m_110984_(p_110957_, d0 + 1.0D, d1 + (double)f12, d2 + 1.0D, f41, f42, f43, f36, f39, i1); ++ this.vertex(p_110957_, d0, d1 + (double)f12, d2 + 1.0D, f41, f42, f43, alpha, f35, f39, i1); ++ this.vertex(p_110957_, d0, d1 + (double)f12, d2, f41, f42, f43, alpha, f35, f37, i1); ++ this.vertex(p_110957_, d0 + 1.0D, d1 + (double)f12, d2, f41, f42, f43, alpha, f36, f37, i1); ++ this.vertex(p_110957_, d0 + 1.0D, d1 + (double)f12, d2 + 1.0D, f41, f42, f43, alpha, f36, f39, i1); + flag7 = true; + } + +@@ -240,10 +_,9 @@ + flag7 = true; + BlockPos blockpos = p_110956_.m_142300_(direction); + TextureAtlasSprite textureatlassprite2 = atextureatlassprite[1]; +- if (!flag) { +- Block block = p_110955_.m_8055_(blockpos).m_60734_(); +- if (block instanceof HalfTransparentBlock || block instanceof LeavesBlock) { +- textureatlassprite2 = this.f_110942_; ++ if (atextureatlassprite[2] != null) { ++ if (p_110955_.m_8055_(blockpos).shouldDisplayFluidOverlay(p_110955_, blockpos, p_110958_)) { ++ textureatlassprite2 = atextureatlassprite[2]; + } + } + +@@ -256,15 +_,15 @@ + float f32 = f4 * f31 * f; + float f33 = f4 * f31 * f1; + float f34 = f4 * f31 * f2; +- this.m_110984_(p_110957_, d3, d1 + (double)f38, d4, f32, f33, f34, f49, f28, k); +- this.m_110984_(p_110957_, d5, d1 + (double)f40, d6, f32, f33, f34, f50, f29, k); +- this.m_110984_(p_110957_, d5, d1 + (double)f12, d6, f32, f33, f34, f50, f30, k); +- this.m_110984_(p_110957_, d3, d1 + (double)f12, d4, f32, f33, f34, f49, f30, k); ++ this.vertex(p_110957_, d3, d1 + (double)f38, d4, f32, f33, f34, alpha, f49, f28, k); ++ this.vertex(p_110957_, d5, d1 + (double)f40, d6, f32, f33, f34, alpha, f50, f29, k); ++ this.vertex(p_110957_, d5, d1 + (double)f12, d6, f32, f33, f34, alpha, f50, f30, k); ++ this.vertex(p_110957_, d3, d1 + (double)f12, d4, f32, f33, f34, alpha, f49, f30, k); + if (textureatlassprite2 != this.f_110942_) { +- this.m_110984_(p_110957_, d3, d1 + (double)f12, d4, f32, f33, f34, f49, f30, k); +- this.m_110984_(p_110957_, d5, d1 + (double)f12, d6, f32, f33, f34, f50, f30, k); +- this.m_110984_(p_110957_, d5, d1 + (double)f40, d6, f32, f33, f34, f50, f29, k); +- this.m_110984_(p_110957_, d3, d1 + (double)f38, d4, f32, f33, f34, f49, f28, k); ++ this.vertex(p_110957_, d3, d1 + (double)f12, d4, f32, f33, f34, alpha, f49, f30, k); ++ this.vertex(p_110957_, d5, d1 + (double)f12, d6, f32, f33, f34, alpha, f50, f30, k); ++ this.vertex(p_110957_, d5, d1 + (double)f40, d6, f32, f33, f34, alpha, f50, f29, k); ++ this.vertex(p_110957_, d3, d1 + (double)f38, d4, f32, f33, f34, alpha, f49, f28, k); + } + } + } +@@ -273,8 +_,8 @@ + } + } + +- private void m_110984_(VertexConsumer p_110985_, double p_110986_, double p_110987_, double p_110988_, float p_110989_, float p_110990_, float p_110991_, float p_110992_, float p_110993_, int p_110994_) { +- p_110985_.m_5483_(p_110986_, p_110987_, p_110988_).m_85950_(p_110989_, p_110990_, p_110991_, 1.0F).m_7421_(p_110992_, p_110993_).m_85969_(p_110994_).m_5601_(0.0F, 1.0F, 0.0F).m_5752_(); ++ private void vertex(VertexConsumer p_110985_, double p_110986_, double p_110987_, double p_110988_, float p_110989_, float p_110990_, float p_110991_, float alpha, float p_110992_, float p_110993_, int p_110994_) { ++ p_110985_.m_5483_(p_110986_, p_110987_, p_110988_).m_85950_(p_110989_, p_110990_, p_110991_, alpha).m_7421_(p_110992_, p_110993_).m_85969_(p_110994_).m_5601_(0.0F, 1.0F, 0.0F).m_5752_(); + } + + private int m_110945_(BlockAndTintGetter p_110946_, BlockPos p_110947_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/block/ModelBlockRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/ModelBlockRenderer.java.patch new file mode 100644 index 0000000000..fe8f20416c --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/block/ModelBlockRenderer.java.patch @@ -0,0 +1,106 @@ +--- a/net/minecraft/client/renderer/block/ModelBlockRenderer.java ++++ b/net/minecraft/client/renderer/block/ModelBlockRenderer.java +@@ -40,13 +_,18 @@ + this.f_110995_ = p_110999_; + } + ++ @Deprecated //Forge: Model data argument + public boolean m_111047_(BlockAndTintGetter p_111048_, BakedModel p_111049_, BlockState p_111050_, BlockPos p_111051_, PoseStack p_111052_, VertexConsumer p_111053_, boolean p_111054_, Random p_111055_, long p_111056_, int p_111057_) { +- boolean flag = Minecraft.m_91086_() && p_111050_.m_60791_() == 0 && p_111049_.m_7541_(); ++ return tesselateBlock(p_111048_, p_111049_, p_111050_, p_111051_, p_111052_, p_111053_, p_111054_, p_111055_, p_111056_, p_111057_, net.minecraftforge.client.model.data.EmptyModelData.INSTANCE); ++ } ++ public boolean tesselateBlock(BlockAndTintGetter p_111048_, BakedModel p_111049_, BlockState p_111050_, BlockPos p_111051_, PoseStack p_111052_, VertexConsumer p_111053_, boolean p_111054_, Random p_111055_, long p_111056_, int p_111057_, net.minecraftforge.client.model.data.IModelData modelData) { ++ boolean flag = Minecraft.m_91086_() && p_111050_.getLightEmission(p_111048_, p_111051_) == 0 && p_111049_.m_7541_(); + Vec3 vec3 = p_111050_.m_60824_(p_111048_, p_111051_); + p_111052_.m_85837_(vec3.f_82479_, vec3.f_82480_, vec3.f_82481_); ++ modelData = p_111049_.getModelData(p_111048_, p_111051_, p_111050_, modelData); + + try { +- return flag ? this.m_111078_(p_111048_, p_111049_, p_111050_, p_111051_, p_111052_, p_111053_, p_111054_, p_111055_, p_111056_, p_111057_) : this.m_111090_(p_111048_, p_111049_, p_111050_, p_111051_, p_111052_, p_111053_, p_111054_, p_111055_, p_111056_, p_111057_); ++ return flag ? this.tesselateWithAO(p_111048_, p_111049_, p_111050_, p_111051_, p_111052_, p_111053_, p_111054_, p_111055_, p_111056_, p_111057_, modelData) : this.tesselateWithoutAO(p_111048_, p_111049_, p_111050_, p_111051_, p_111052_, p_111053_, p_111054_, p_111055_, p_111056_, p_111057_, modelData); + } catch (Throwable throwable) { + CrashReport crashreport = CrashReport.m_127521_(throwable, "Tesselating block model"); + CrashReportCategory crashreportcategory = crashreport.m_127514_("Block model being tesselated"); +@@ -56,7 +_,11 @@ + } + } + ++ @Deprecated //Forge: Model data argument + public boolean m_111078_(BlockAndTintGetter p_111079_, BakedModel p_111080_, BlockState p_111081_, BlockPos p_111082_, PoseStack p_111083_, VertexConsumer p_111084_, boolean p_111085_, Random p_111086_, long p_111087_, int p_111088_) { ++ return tesselateWithAO(p_111079_, p_111080_, p_111081_, p_111082_, p_111083_, p_111084_, p_111085_, p_111086_, p_111087_, p_111088_, net.minecraftforge.client.model.data.EmptyModelData.INSTANCE); ++ } ++ public boolean tesselateWithAO(BlockAndTintGetter p_111079_, BakedModel p_111080_, BlockState p_111081_, BlockPos p_111082_, PoseStack p_111083_, VertexConsumer p_111084_, boolean p_111085_, Random p_111086_, long p_111087_, int p_111088_, net.minecraftforge.client.model.data.IModelData modelData) { + boolean flag = false; + float[] afloat = new float[f_173405_.length * 2]; + BitSet bitset = new BitSet(3); +@@ -65,7 +_,7 @@ + + for(Direction direction : f_173405_) { + p_111086_.setSeed(p_111087_); +- List list = p_111080_.m_6840_(p_111081_, direction, p_111086_); ++ List list = p_111080_.getQuads(p_111081_, direction, p_111086_, modelData); + if (!list.isEmpty()) { + blockpos$mutableblockpos.m_122159_(p_111082_, direction); + if (!p_111085_ || Block.m_152444_(p_111081_, p_111079_, p_111082_, direction, blockpos$mutableblockpos)) { +@@ -76,7 +_,7 @@ + } + + p_111086_.setSeed(p_111087_); +- List list1 = p_111080_.m_6840_(p_111081_, (Direction)null, p_111086_); ++ List list1 = p_111080_.getQuads(p_111081_, (Direction)null, p_111086_, modelData); + if (!list1.isEmpty()) { + this.m_111012_(p_111079_, p_111081_, p_111082_, p_111083_, p_111084_, list1, afloat, bitset, modelblockrenderer$ambientocclusionface, p_111088_); + flag = true; +@@ -85,14 +_,18 @@ + return flag; + } + ++ @Deprecated //Forge: Model data argument + public boolean m_111090_(BlockAndTintGetter p_111091_, BakedModel p_111092_, BlockState p_111093_, BlockPos p_111094_, PoseStack p_111095_, VertexConsumer p_111096_, boolean p_111097_, Random p_111098_, long p_111099_, int p_111100_) { ++ return tesselateWithoutAO(p_111091_, p_111092_, p_111093_, p_111094_, p_111095_, p_111096_, p_111097_, p_111098_, p_111099_, p_111100_, net.minecraftforge.client.model.data.EmptyModelData.INSTANCE); ++ } ++ public boolean tesselateWithoutAO(BlockAndTintGetter p_111091_, BakedModel p_111092_, BlockState p_111093_, BlockPos p_111094_, PoseStack p_111095_, VertexConsumer p_111096_, boolean p_111097_, Random p_111098_, long p_111099_, int p_111100_, net.minecraftforge.client.model.data.IModelData modelData) { + boolean flag = false; + BitSet bitset = new BitSet(3); + BlockPos.MutableBlockPos blockpos$mutableblockpos = p_111094_.m_122032_(); + + for(Direction direction : f_173405_) { + p_111098_.setSeed(p_111099_); +- List list = p_111092_.m_6840_(p_111093_, direction, p_111098_); ++ List list = p_111092_.getQuads(p_111093_, direction, p_111098_, modelData); + if (!list.isEmpty()) { + blockpos$mutableblockpos.m_122159_(p_111094_, direction); + if (!p_111097_ || Block.m_152444_(p_111093_, p_111091_, p_111094_, direction, blockpos$mutableblockpos)) { +@@ -104,7 +_,7 @@ + } + + p_111098_.setSeed(p_111099_); +- List list1 = p_111092_.m_6840_(p_111093_, (Direction)null, p_111098_); ++ List list1 = p_111092_.getQuads(p_111093_, (Direction)null, p_111098_, modelData); + if (!list1.isEmpty()) { + this.m_111001_(p_111091_, p_111093_, p_111094_, -1, p_111100_, true, p_111095_, p_111096_, list1, bitset); + flag = true; +@@ -220,17 +_,21 @@ + + } + ++ @Deprecated //Forge: Model data argument + public void m_111067_(PoseStack.Pose p_111068_, VertexConsumer p_111069_, @Nullable BlockState p_111070_, BakedModel p_111071_, float p_111072_, float p_111073_, float p_111074_, int p_111075_, int p_111076_) { ++ renderModel(p_111068_, p_111069_, p_111070_, p_111071_, p_111072_, p_111073_, p_111074_, p_111075_, p_111076_, net.minecraftforge.client.model.data.EmptyModelData.INSTANCE); ++ } ++ public void renderModel(PoseStack.Pose p_111068_, VertexConsumer p_111069_, @Nullable BlockState p_111070_, BakedModel p_111071_, float p_111072_, float p_111073_, float p_111074_, int p_111075_, int p_111076_, net.minecraftforge.client.model.data.IModelData modelData) { + Random random = new Random(); + long i = 42L; + + for(Direction direction : f_173405_) { + random.setSeed(42L); +- m_111058_(p_111068_, p_111069_, p_111072_, p_111073_, p_111074_, p_111071_.m_6840_(p_111070_, direction, random), p_111075_, p_111076_); ++ m_111058_(p_111068_, p_111069_, p_111072_, p_111073_, p_111074_, p_111071_.getQuads(p_111070_, direction, random, modelData), p_111075_, p_111076_); + } + + random.setSeed(42L); +- m_111058_(p_111068_, p_111069_, p_111072_, p_111073_, p_111074_, p_111071_.m_6840_(p_111070_, (Direction)null, random), p_111075_, p_111076_); ++ m_111058_(p_111068_, p_111069_, p_111072_, p_111073_, p_111074_, p_111071_.getQuads(p_111070_, (Direction)null, random, modelData), p_111075_, p_111076_); + } + + private static void m_111058_(PoseStack.Pose p_111059_, VertexConsumer p_111060_, float p_111061_, float p_111062_, float p_111063_, List p_111064_, int p_111065_, int p_111066_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/BakedQuad.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/BakedQuad.java.patch new file mode 100644 index 0000000000..e1183a0c42 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/BakedQuad.java.patch @@ -0,0 +1,23 @@ +--- a/net/minecraft/client/renderer/block/model/BakedQuad.java ++++ b/net/minecraft/client/renderer/block/model/BakedQuad.java +@@ -6,7 +_,7 @@ + import net.minecraftforge.api.distmarker.OnlyIn; + + @OnlyIn(Dist.CLIENT) +-public class BakedQuad { ++public class BakedQuad implements net.minecraftforge.client.model.pipeline.IVertexProducer { + protected final int[] f_111292_; + protected final int f_111293_; + protected final Direction f_111294_; +@@ -39,6 +_,11 @@ + + public Direction m_111306_() { + return this.f_111294_; ++ } ++ ++ @Override ++ public void pipe(net.minecraftforge.client.model.pipeline.IVertexConsumer consumer) { ++ net.minecraftforge.client.model.pipeline.LightUtil.putBakedQuad(consumer, this); + } + + public boolean m_111307_() { diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/BlockModel.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/BlockModel.java.patch new file mode 100644 index 0000000000..82bd787264 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/BlockModel.java.patch @@ -0,0 +1,89 @@ +--- a/net/minecraft/client/renderer/block/model/BlockModel.java ++++ b/net/minecraft/client/renderer/block/model/BlockModel.java +@@ -66,9 +_,10 @@ + public BlockModel f_111418_; + @Nullable + protected ResourceLocation f_111419_; ++ public final net.minecraftforge.client.model.BlockModelConfiguration customData = new net.minecraftforge.client.model.BlockModelConfiguration(this); + + public static BlockModel m_111461_(Reader p_111462_) { +- return GsonHelper.m_13776_(f_111415_, p_111462_, BlockModel.class); ++ return GsonHelper.m_13776_(net.minecraftforge.client.model.ModelLoaderRegistry.ExpandedBlockModelDeserializer.INSTANCE, p_111462_, BlockModel.class); + } + + public static BlockModel m_111463_(String p_111464_) { +@@ -85,10 +_,15 @@ + this.f_111426_ = p_111435_; + } + ++ @Deprecated + public List m_111436_() { ++ if (customData.hasCustomGeometry()) return java.util.Collections.emptyList(); + return this.f_111422_.isEmpty() && this.f_111418_ != null ? this.f_111418_.m_111436_() : this.f_111422_; + } + ++ @Nullable ++ public ResourceLocation getParentLocation() { return f_111419_; } ++ + public boolean m_111476_() { + return this.f_111418_ != null ? this.f_111418_.m_111476_() : this.f_111424_; + } +@@ -113,6 +_,10 @@ + return this.f_111426_.isEmpty() ? ItemOverrides.f_111734_ : new ItemOverrides(p_111447_, p_111448_, p_111447_::m_119341_, this.f_111426_); + } + ++ public ItemOverrides getOverrides(ModelBakery p_111447_, BlockModel p_111448_, Function textureGetter) { ++ return this.f_111426_.isEmpty() ? ItemOverrides.f_111734_ : new ItemOverrides(p_111447_, p_111448_, p_111447_::m_119341_, textureGetter, this.f_111426_); ++ } ++ + public Collection m_7970_() { + Set set = Sets.newHashSet(); + +@@ -156,6 +_,9 @@ + + Set set1 = Sets.newHashSet(this.m_111480_("particle")); + ++ if (customData.hasCustomGeometry()) ++ set1.addAll(customData.getTextureDependencies(p_111469_, p_111470_)); ++ else + for(BlockElement blockelement : this.m_111436_()) { + for(BlockElementFace blockelementface : blockelement.f_111310_.values()) { + Material material = this.m_111480_(blockelementface.f_111356_); +@@ -182,11 +_,17 @@ + return set1; + } + ++ @Deprecated //Forge: Use Boolean variant + public BakedModel m_7611_(ModelBakery p_111457_, Function p_111458_, ModelState p_111459_, ResourceLocation p_111460_) { + return this.m_111449_(p_111457_, this, p_111458_, p_111459_, p_111460_, true); + } + + public BakedModel m_111449_(ModelBakery p_111450_, BlockModel p_111451_, Function p_111452_, ModelState p_111453_, ResourceLocation p_111454_, boolean p_111455_) { ++ return net.minecraftforge.client.model.ModelLoaderRegistry.bakeHelper(this, p_111450_, p_111451_, p_111452_, p_111453_, p_111454_, p_111455_); ++ } ++ ++ @Deprecated //Forge: exposed for our callbacks only. Use the above function. ++ public BakedModel bakeVanilla(ModelBakery p_111450_, BlockModel p_111451_, Function p_111452_, ModelState p_111453_, ResourceLocation p_111454_, boolean p_111455_) { + TextureAtlasSprite textureatlassprite = p_111452_.apply(this.m_111480_("particle")); + if (this.m_111490_() == ModelBakery.f_119233_) { + return new BuiltInModel(this.m_111491_(), this.m_111446_(p_111450_, p_111451_), textureatlassprite, this.m_111479_().m_111526_()); +@@ -213,6 +_,10 @@ + return f_111421_.m_111600_(p_111438_.f_111308_, p_111438_.f_111309_, p_111439_, p_111440_, p_111441_, p_111442_, p_111438_.f_111311_, p_111438_.f_111312_, p_111443_); + } + ++ public static BakedQuad makeBakedQuad(BlockElement p_111438_, BlockElementFace p_111439_, TextureAtlasSprite p_111440_, Direction p_111441_, ModelState p_111442_, ResourceLocation p_111443_) { ++ return m_111437_(p_111438_, p_111439_, p_111440_, p_111441_, p_111442_, p_111443_); ++ } ++ + public boolean m_111477_(String p_111478_) { + return !MissingTextureAtlasSprite.m_118071_().equals(this.m_111480_(p_111478_).m_119203_()); + } +@@ -388,6 +_,8 @@ + public boolean m_111526_() { + return this == SIDE; + } ++ ++ public String getSerializedName() { return f_111519_; } + } + + @OnlyIn(Dist.CLIENT) 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 new file mode 100644 index 0000000000..b9e7626b1f --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/FaceBakery.java.patch @@ -0,0 +1,21 @@ +--- a/net/minecraft/client/renderer/block/model/FaceBakery.java ++++ b/net/minecraft/client/renderer/block/model/FaceBakery.java +@@ -49,6 +_,7 @@ + this.m_111630_(aint, direction); + } + ++ net.minecraftforge.client.ForgeHooksClient.fillNormal(aint, direction); + return new BakedQuad(aint, p_111603_.f_111355_, direction, p_111604_, p_111608_); + } + +@@ -131,8 +_,8 @@ + p_111615_[i + 1] = Float.floatToRawIntBits(p_111617_.m_122260_()); + p_111615_[i + 2] = Float.floatToRawIntBits(p_111617_.m_122269_()); + 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_111586_(Vector3f p_111587_, @Nullable BlockElementRotation p_111588_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/ItemModelGenerator.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/ItemModelGenerator.java.patch new file mode 100644 index 0000000000..5ef8da470d --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/ItemModelGenerator.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/client/renderer/block/model/ItemModelGenerator.java ++++ b/net/minecraft/client/renderer/block/model/ItemModelGenerator.java +@@ -39,6 +_,7 @@ + map.put("particle", p_111672_.m_111477_("particle") ? Either.left(p_111672_.m_111480_("particle")) : map.get("layer0")); + BlockModel blockmodel = new BlockModel((ResourceLocation)null, list, map, false, p_111672_.m_111479_(), p_111672_.m_111491_(), p_111672_.m_111484_()); + blockmodel.f_111416_ = p_111672_.f_111416_; ++ blockmodel.customData.copyFrom(p_111672_.customData); + return blockmodel; + } + diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/ItemOverrides.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/ItemOverrides.java.patch new file mode 100644 index 0000000000..d8a5f951cb --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/ItemOverrides.java.patch @@ -0,0 +1,46 @@ +--- a/net/minecraft/client/renderer/block/model/ItemOverrides.java ++++ b/net/minecraft/client/renderer/block/model/ItemOverrides.java +@@ -32,7 +_,11 @@ + this.f_173461_ = new ResourceLocation[0]; + } + ++ @Deprecated //Forge: Use IUnbakedModel, add texture getter + public ItemOverrides(ModelBakery p_111740_, BlockModel p_111741_, Function p_111742_, List p_111743_) { ++ this(p_111740_, p_111741_, p_111742_, p_111740_.getSpriteMap()::m_117971_, p_111743_); ++ } ++ public ItemOverrides(ModelBakery p_111740_, UnbakedModel p_111741_, Function p_111742_, Function textureGetter, List p_111743_) { + this.f_173461_ = p_111743_.stream().flatMap(ItemOverride::m_173449_).map(ItemOverride.Predicate::m_173459_).distinct().toArray((p_173479_) -> { + return new ResourceLocation[p_173479_]; + }); +@@ -46,7 +_,7 @@ + + for(int j = p_111743_.size() - 1; j >= 0; --j) { + ItemOverride itemoverride = p_111743_.get(j); +- BakedModel bakedmodel = this.m_173470_(p_111740_, p_111741_, p_111742_, itemoverride); ++ BakedModel bakedmodel = this.bakeModel(p_111740_, p_111741_, p_111742_, textureGetter, itemoverride); + ItemOverrides.PropertyMatcher[] aitemoverrides$propertymatcher = itemoverride.m_173449_().map((p_173477_) -> { + int k = object2intmap.getInt(p_173477_.m_173459_()); + return new ItemOverrides.PropertyMatcher(k, p_173477_.m_173460_()); +@@ -60,9 +_,9 @@ + } + + @Nullable +- private BakedModel m_173470_(ModelBakery p_173471_, BlockModel p_173472_, Function p_173473_, ItemOverride p_173474_) { ++ private BakedModel bakeModel(ModelBakery p_173471_, UnbakedModel p_173472_, Function p_173473_, Function textureGetter, ItemOverride p_173474_) { + UnbakedModel unbakedmodel = p_173473_.apply(p_173474_.m_111718_()); +- return Objects.equals(unbakedmodel, p_173472_) ? null : p_173471_.m_119349_(p_173474_.m_111718_(), BlockModelRotation.X0_Y0); ++ return Objects.equals(unbakedmodel, p_173472_) ? null : p_173471_.bake(p_173474_.m_111718_(), BlockModelRotation.X0_Y0, textureGetter); + } + + @Nullable +@@ -95,6 +_,10 @@ + } + + return p_173465_; ++ } ++ ++ public com.google.common.collect.ImmutableList getOverrides() { ++ return com.google.common.collect.ImmutableList.copyOf(f_111735_); + } + + @OnlyIn(Dist.CLIENT) diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/ItemTransform.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/ItemTransform.java.patch new file mode 100644 index 0000000000..aca09cc555 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/ItemTransform.java.patch @@ -0,0 +1,14 @@ +--- a/net/minecraft/client/renderer/block/model/ItemTransform.java ++++ b/net/minecraft/client/renderer/block/model/ItemTransform.java +@@ -14,7 +_,11 @@ + import net.minecraftforge.api.distmarker.Dist; + import net.minecraftforge.api.distmarker.OnlyIn; + ++/** ++ * @deprecated use {@link net.minecraft.util.math.vector.TransformationMatrix} through {@link net.minecraftforge.client.extensions.IForgeBakedModel#handlePerspective} ++ */ + @OnlyIn(Dist.CLIENT) ++@Deprecated + public class ItemTransform { + public static final ItemTransform f_111754_ = new ItemTransform(new Vector3f(), new Vector3f(), new Vector3f(1.0F, 1.0F, 1.0F)); + public final Vector3f f_111755_; diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/ItemTransforms.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/ItemTransforms.java.patch new file mode 100644 index 0000000000..d525437e5c --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/ItemTransforms.java.patch @@ -0,0 +1,26 @@ +--- a/net/minecraft/client/renderer/block/model/ItemTransforms.java ++++ b/net/minecraft/client/renderer/block/model/ItemTransforms.java +@@ -25,6 +_,7 @@ + this(ItemTransform.f_111754_, ItemTransform.f_111754_, ItemTransform.f_111754_, ItemTransform.f_111754_, ItemTransform.f_111754_, ItemTransform.f_111754_, ItemTransform.f_111754_, ItemTransform.f_111754_); + } + ++ @Deprecated + public ItemTransforms(ItemTransforms p_111807_) { + this.f_111787_ = p_111807_.f_111787_; + this.f_111788_ = p_111807_.f_111788_; +@@ -36,6 +_,7 @@ + this.f_111794_ = p_111807_.f_111794_; + } + ++ @Deprecated + public ItemTransforms(ItemTransform p_111798_, ItemTransform p_111799_, ItemTransform p_111800_, ItemTransform p_111801_, ItemTransform p_111802_, ItemTransform p_111803_, ItemTransform p_111804_, ItemTransform p_111805_) { + this.f_111787_ = p_111798_; + this.f_111788_ = p_111799_; +@@ -47,6 +_,7 @@ + this.f_111794_ = p_111805_; + } + ++ @Deprecated + public ItemTransform m_111808_(ItemTransforms.TransformType p_111809_) { + switch(p_111809_) { + case THIRD_PERSON_LEFT_HAND: diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/MultiVariant.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/MultiVariant.java.patch new file mode 100644 index 0000000000..34d453bf29 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/MultiVariant.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/client/renderer/block/model/MultiVariant.java ++++ b/net/minecraft/client/renderer/block/model/MultiVariant.java +@@ -70,7 +_,7 @@ + WeightedBakedModel.Builder weightedbakedmodel$builder = new WeightedBakedModel.Builder(); + + for(Variant variant : this.m_111848_()) { +- BakedModel bakedmodel = p_111850_.m_119349_(variant.m_111883_(), variant); ++ BakedModel bakedmodel = p_111850_.bake(variant.m_111883_(), variant, p_111851_); + weightedbakedmodel$builder.m_119559_(bakedmodel, variant.m_111886_()); + } + diff --git a/patches/minecraft/net/minecraft/client/renderer/blockentity/BlockEntityRenderers.java.patch b/patches/minecraft/net/minecraft/client/renderer/blockentity/BlockEntityRenderers.java.patch new file mode 100644 index 0000000000..da62612fc6 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/blockentity/BlockEntityRenderers.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/client/renderer/blockentity/BlockEntityRenderers.java ++++ b/net/minecraft/client/renderer/blockentity/BlockEntityRenderers.java +@@ -12,7 +_,7 @@ + + @OnlyIn(Dist.CLIENT) + public class BlockEntityRenderers { +- private static final Map, BlockEntityRendererProvider> f_173587_ = Maps.newHashMap(); ++ private static final Map, BlockEntityRendererProvider> f_173587_ = new java.util.concurrent.ConcurrentHashMap<>(); + + public static void m_173590_(BlockEntityType p_173591_, BlockEntityRendererProvider p_173592_) { + f_173587_.put(p_173591_, p_173592_); diff --git a/patches/minecraft/net/minecraft/client/renderer/blockentity/ChestRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/blockentity/ChestRenderer.java.patch new file mode 100644 index 0000000000..f7cced50ce --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/blockentity/ChestRenderer.java.patch @@ -0,0 +1,21 @@ +--- a/net/minecraft/client/renderer/blockentity/ChestRenderer.java ++++ b/net/minecraft/client/renderer/blockentity/ChestRenderer.java +@@ -120,7 +_,7 @@ + f1 = 1.0F - f1; + f1 = 1.0F - f1 * f1 * f1; + int i = neighborcombineresult.m_5649_(new BrightnessCombiner<>()).applyAsInt(p_112367_); +- Material material = Sheets.m_110767_(p_112363_, chesttype, this.f_112359_); ++ Material material = this.getMaterial(p_112363_, chesttype); + VertexConsumer vertexconsumer = material.m_119194_(p_112366_, RenderType::m_110452_); + if (flag1) { + if (chesttype == ChestType.LEFT) { +@@ -142,5 +_,9 @@ + p_112372_.m_104301_(p_112370_, p_112371_, p_112376_, p_112377_); + p_112373_.m_104301_(p_112370_, p_112371_, p_112376_, p_112377_); + p_112374_.m_104301_(p_112370_, p_112371_, p_112376_, p_112377_); ++ } ++ ++ protected Material getMaterial(T blockEntity, ChestType chestType) { ++ return Sheets.m_110767_(blockEntity, chestType, this.f_112359_); + } + } diff --git a/patches/minecraft/net/minecraft/client/renderer/blockentity/PistonHeadRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/blockentity/PistonHeadRenderer.java.patch new file mode 100644 index 0000000000..4ce31025da --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/blockentity/PistonHeadRenderer.java.patch @@ -0,0 +1,15 @@ +--- a/net/minecraft/client/renderer/blockentity/PistonHeadRenderer.java ++++ b/net/minecraft/client/renderer/blockentity/PistonHeadRenderer.java +@@ -60,9 +_,12 @@ + } + + private void m_112458_(BlockPos p_112459_, BlockState p_112460_, PoseStack p_112461_, MultiBufferSource p_112462_, Level p_112463_, boolean p_112464_, int p_112465_) { ++ net.minecraftforge.client.ForgeHooksClient.renderPistonMovedBlocks(p_112459_, p_112460_, p_112461_, p_112462_, p_112463_, p_112464_, p_112465_, f_112441_ == null ? f_112441_ = net.minecraft.client.Minecraft.m_91087_().m_91289_() : f_112441_); ++ if(false) { + RenderType rendertype = ItemBlockRenderTypes.m_109293_(p_112460_); + VertexConsumer vertexconsumer = p_112462_.m_6299_(rendertype); + this.f_112441_.m_110937_().m_111047_(p_112463_, this.f_112441_.m_110910_(p_112460_), p_112460_, p_112459_, p_112461_, vertexconsumer, p_112464_, new Random(), p_112460_.m_60726_(p_112459_), p_112465_); ++ } + } + + public int m_142163_() { diff --git a/patches/minecraft/net/minecraft/client/renderer/chunk/ChunkRenderDispatcher.java.patch b/patches/minecraft/net/minecraft/client/renderer/chunk/ChunkRenderDispatcher.java.patch index e2e74f0945..a6e93c9738 100644 --- a/patches/minecraft/net/minecraft/client/renderer/chunk/ChunkRenderDispatcher.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/chunk/ChunkRenderDispatcher.java.patch @@ -1,172 +1,163 @@ --- a/net/minecraft/client/renderer/chunk/ChunkRenderDispatcher.java +++ b/net/minecraft/client/renderer/chunk/ChunkRenderDispatcher.java -@@ -68,12 +_,15 @@ - private Vector3d field_217672_l = Vector3d.field_186680_a; +@@ -70,12 +_,15 @@ + private Vec3 f_112683_ = Vec3.f_82478_; - public ChunkRenderDispatcher(World p_i226020_1_, WorldRenderer p_i226020_2_, Executor p_i226020_3_, boolean p_i226020_4_, RegionRenderCacheBuilder p_i226020_5_) { -+ this(p_i226020_1_, p_i226020_2_, p_i226020_3_, p_i226020_4_, p_i226020_5_, -1); + public ChunkRenderDispatcher(Level p_112686_, LevelRenderer p_112687_, Executor p_112688_, boolean p_112689_, ChunkBufferBuilderPack p_112690_) { ++ this(p_112686_, p_112687_, p_112688_, p_112689_, p_112690_, -1); + } -+ public ChunkRenderDispatcher(World p_i226020_1_, WorldRenderer p_i226020_2_, Executor p_i226020_3_, boolean p_i226020_4_, RegionRenderCacheBuilder p_i226020_5_, int countRenderBuilders) { - this.field_228893_j_ = p_i226020_1_; - this.field_228894_k_ = p_i226020_2_; - int i = Math.max(1, (int)((double)Runtime.getRuntime().maxMemory() * 0.3D) / (RenderType.func_228661_n_().stream().mapToInt(RenderType::func_228662_o_).sum() * 4) - 1); ++ public ChunkRenderDispatcher(Level p_112686_, LevelRenderer p_112687_, Executor p_112688_, boolean p_112689_, ChunkBufferBuilderPack p_112690_, int countRenderBuilders) { + this.f_112681_ = p_112686_; + this.f_112682_ = p_112687_; + 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_i226020_4_ ? j : Math.min(j, 4); + int k = p_112689_ ? 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.field_228890_g_ = p_i226020_5_; - List list = Lists.newArrayListWithExpectedSize(l); + this.f_112678_ = p_112690_; + List list = Lists.newArrayListWithExpectedSize(l); -@@ -206,7 +_,7 @@ +@@ -258,7 +_,7 @@ } @OnlyIn(Dist.CLIENT) -- public class ChunkRender { -+ public class ChunkRender implements net.minecraftforge.client.extensions.IForgeRenderChunk { - public final AtomicReference field_178590_b = new AtomicReference<>(ChunkRenderDispatcher.CompiledChunk.field_178502_a); - @Nullable - private ChunkRenderDispatcher.ChunkRender.RebuildTask field_228921_d_; -@@ -332,7 +_,7 @@ - if (!chunkrenderdispatcher$compiledchunk.field_178501_c.contains(p_228925_1_)) { +- public class RenderChunk { ++ public class RenderChunk implements net.minecraftforge.client.extensions.IForgeRenderChunk { + public static final int f_173716_ = 16; + public final int f_173717_; + public final AtomicReference f_112784_ = new AtomicReference<>(ChunkRenderDispatcher.CompiledChunk.f_112748_); +@@ -390,7 +_,7 @@ + if (!chunkrenderdispatcher$compiledchunk.f_112750_.contains(p_112810_)) { return false; } else { -- this.field_228922_e_ = new ChunkRenderDispatcher.ChunkRender.SortTransparencyTask(this.func_188280_f(), chunkrenderdispatcher$compiledchunk); -+ this.field_228922_e_ = new ChunkRenderDispatcher.ChunkRender.SortTransparencyTask(new net.minecraft.util.math.ChunkPos(func_178568_j()), this.func_188280_f(), chunkrenderdispatcher$compiledchunk); - p_228925_2_.func_228900_a_(this.field_228922_e_); +- 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; } -@@ -355,8 +_,8 @@ - this.func_228935_i_(); - BlockPos blockpos = this.field_178586_f.func_185334_h(); +@@ -413,8 +_,8 @@ + this.m_112843_(); + BlockPos blockpos = this.f_112793_.m_7949_(); int i = 1; -- ChunkRenderCache chunkrendercache = ChunkRenderCache.func_212397_a(ChunkRenderDispatcher.this.field_228893_j_, blockpos.func_177982_a(-1, -1, -1), blockpos.func_177982_a(16, 16, 16), 1); -- this.field_228921_d_ = new ChunkRenderDispatcher.ChunkRender.RebuildTask(this.func_188280_f(), chunkrendercache); -+ ChunkRenderCache chunkrendercache = createRegionRenderCache(ChunkRenderDispatcher.this.field_228893_j_, blockpos.func_177982_a(-1, -1, -1), blockpos.func_177982_a(16, 16, 16), 1); -+ this.field_228921_d_ = new ChunkRenderDispatcher.ChunkRender.RebuildTask(new net.minecraft.util.math.ChunkPos(func_178568_j()), this.func_188280_f(), chunkrendercache); - return this.field_228921_d_; +- RenderChunkRegion renderchunkregion = RenderChunkRegion.m_112920_(ChunkRenderDispatcher.this.f_112681_, blockpos.m_142082_(-1, -1, -1), blockpos.m_142082_(16, 16, 16), 1); +- this.f_112787_ = new ChunkRenderDispatcher.RenderChunk.RebuildTask(this.m_112832_(), renderchunkregion); ++ RenderChunkRegion renderchunkregion = createRegionRenderCache(ChunkRenderDispatcher.this.f_112681_, blockpos.m_142082_(-1, -1, -1), blockpos.m_142082_(16, 16, 16), 1); ++ this.f_112787_ = new ChunkRenderDispatcher.RenderChunk.RebuildTask(new net.minecraft.world.level.ChunkPos(m_112839_()), this.m_112832_(), renderchunkregion); + return this.f_112787_; } -@@ -384,9 +_,19 @@ - abstract class ChunkRenderTask implements Comparable { - protected final double field_188229_e; - protected final AtomicBoolean field_178554_h = new AtomicBoolean(false); -+ protected java.util.Map modelData; +@@ -442,9 +_,19 @@ + abstract class ChunkCompileTask implements Comparable { + protected final double f_112847_; + protected final AtomicBoolean f_112848_ = new AtomicBoolean(false); ++ protected java.util.Map modelData; - public ChunkRenderTask(double p_i226023_2_) { -+ this(null, p_i226023_2_); + public ChunkCompileTask(double p_112852_) { ++ this(null, p_112852_); + } + -+ public ChunkRenderTask(@Nullable net.minecraft.util.math.ChunkPos pos, double p_i226023_2_) { - this.field_188229_e = p_i226023_2_; ++ public ChunkCompileTask(@Nullable net.minecraft.world.level.ChunkPos pos, double p_112852_) { + this.f_112847_ = p_112852_; + if (pos == null) { + this.modelData = java.util.Collections.emptyMap(); + } else { -+ this.modelData = net.minecraftforge.client.model.ModelDataManager.getModelData(net.minecraft.client.Minecraft.func_71410_x().field_71441_e, pos); ++ this.modelData = net.minecraftforge.client.model.ModelDataManager.getModelData(net.minecraft.client.Minecraft.m_91087_().f_91073_, pos); + } } - public abstract CompletableFuture func_225618_a_(RegionRenderCacheBuilder p_225618_1_); -@@ -396,6 +_,10 @@ - public int compareTo(ChunkRenderDispatcher.ChunkRender.ChunkRenderTask p_compareTo_1_) { - return Doubles.compare(this.field_188229_e, p_compareTo_1_.field_188229_e); + public abstract CompletableFuture m_5869_(ChunkBufferBuilderPack p_112853_); +@@ -454,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.IModelData getModelData(net.minecraft.util.math.BlockPos pos) { ++ public net.minecraftforge.client.model.data.IModelData getModelData(net.minecraft.core.BlockPos pos) { + return modelData.getOrDefault(pos, net.minecraftforge.client.model.data.EmptyModelData.INSTANCE); + } } @OnlyIn(Dist.CLIENT) -@@ -403,8 +_,13 @@ +@@ -461,8 +_,13 @@ @Nullable - protected ChunkRenderCache field_228938_d_; + protected RenderChunkRegion f_112858_; + @Deprecated - public RebuildTask(double p_i226024_2_, @Nullable ChunkRenderCache p_i226024_4_) { -- super(p_i226024_2_); -+ this(null, p_i226024_2_, p_i226024_4_); + public RebuildTask(@Nullable double p_112862_, RenderChunkRegion p_112863_) { +- super(p_112862_); ++ this(null, p_112862_, p_112863_); + } + -+ public RebuildTask(@Nullable net.minecraft.util.math.ChunkPos pos, double p_i226024_2_, @Nullable ChunkRenderCache p_i226024_4_) { -+ super(pos, p_i226024_2_); - this.field_228938_d_ = p_i226024_4_; ++ public RebuildTask(@Nullable net.minecraft.world.level.ChunkPos pos, double p_112862_, @Nullable RenderChunkRegion p_112863_) { ++ super(pos, p_112862_); + this.f_112858_ = p_112863_; } -@@ -470,7 +_,7 @@ - visgraph.func_178606_a(blockpos2); +@@ -535,8 +_,10 @@ } -- if (block.func_235695_q_()) { -+ if (blockstate.hasTileEntity()) { - TileEntity tileentity = chunkrendercache.func_212399_a(blockpos2, Chunk.CreateEntityType.CHECK); - if (tileentity != null) { - this.func_228942_a_(p_228940_4_, set, tileentity); -@@ -478,8 +_,10 @@ - } - - FluidState fluidstate = chunkrendercache.func_204610_c(blockpos2); -- if (!fluidstate.func_206888_e()) { -- RenderType rendertype = RenderTypeLookup.func_228391_a_(fluidstate); + FluidState fluidstate = renderchunkregion.m_6425_(blockpos2); +- if (!fluidstate.m_76178_()) { +- RenderType rendertype = ItemBlockRenderTypes.m_109287_(fluidstate); + net.minecraftforge.client.model.data.IModelData modelData = getModelData(blockpos2); -+ for (RenderType rendertype : RenderType.func_228661_n_()) { ++ for (RenderType rendertype : RenderType.m_110506_()) { + net.minecraftforge.client.ForgeHooksClient.setRenderLayer(rendertype); -+ if (!fluidstate.func_206888_e() && RenderTypeLookup.canRenderInLayer(fluidstate, rendertype)) { - BufferBuilder bufferbuilder = p_228940_5_.func_228366_a_(rendertype); - if (p_228940_4_.field_178501_c.add(rendertype)) { - ChunkRender.this.func_228923_a_(bufferbuilder); -@@ -491,8 +_,8 @@ ++ if (!fluidstate.m_76178_() && ItemBlockRenderTypes.canRenderInLayer(fluidstate, rendertype)) { + BufferBuilder bufferbuilder = p_112870_.m_108839_(rendertype); + if (p_112869_.f_112750_.add(rendertype)) { + RenderChunk.this.m_112805_(bufferbuilder); +@@ -548,8 +_,8 @@ } } -- if (blockstate.func_185901_i() != BlockRenderType.INVISIBLE) { -- RenderType rendertype1 = RenderTypeLookup.func_228390_a_(blockstate); -+ if (blockstate.func_185901_i() != BlockRenderType.INVISIBLE && RenderTypeLookup.canRenderInLayer(blockstate, rendertype)) { +- if (blockstate.m_60799_() != RenderShape.INVISIBLE) { +- RenderType rendertype1 = ItemBlockRenderTypes.m_109282_(blockstate); ++ if (blockstate.m_60799_() != RenderShape.INVISIBLE && ItemBlockRenderTypes.canRenderInLayer(blockstate, rendertype)) { + RenderType rendertype1 = rendertype; - BufferBuilder bufferbuilder2 = p_228940_5_.func_228366_a_(rendertype1); - if (p_228940_4_.field_178501_c.add(rendertype1)) { - ChunkRender.this.func_228923_a_(bufferbuilder2); -@@ -500,14 +_,16 @@ + BufferBuilder bufferbuilder2 = p_112870_.m_108839_(rendertype1); + if (p_112869_.f_112750_.add(rendertype1)) { + RenderChunk.this.m_112805_(bufferbuilder2); +@@ -557,14 +_,16 @@ - matrixstack.func_227860_a_(); - matrixstack.func_227861_a_((double)(blockpos2.func_177958_n() & 15), (double)(blockpos2.func_177956_o() & 15), (double)(blockpos2.func_177952_p() & 15)); -- if (blockrendererdispatcher.func_228793_a_(blockstate, blockpos2, chunkrendercache, matrixstack, bufferbuilder2, true, random)) { -+ if (blockrendererdispatcher.renderModel(blockstate, blockpos2, chunkrendercache, matrixstack, bufferbuilder2, true, random, modelData)) { - p_228940_4_.field_178498_d = false; - p_228940_4_.field_178500_b.add(rendertype1); + posestack.m_85836_(); + posestack.m_85837_((double)(blockpos2.m_123341_() & 15), (double)(blockpos2.m_123342_() & 15), (double)(blockpos2.m_123343_() & 15)); +- if (blockrenderdispatcher.m_110924_(blockstate, blockpos2, renderchunkregion, posestack, bufferbuilder2, true, random)) { ++ if (blockrenderdispatcher.renderBatched(blockstate, blockpos2, renderchunkregion, posestack, bufferbuilder2, true, random, modelData)) { + p_112869_.f_112751_ = false; + p_112869_.f_112749_.add(rendertype1); } - matrixstack.func_227865_b_(); + posestack.m_85849_(); } + } } + net.minecraftforge.client.ForgeHooksClient.setRenderLayer(null); - if (p_228940_4_.field_178500_b.contains(RenderType.func_228645_f_())) { - BufferBuilder bufferbuilder1 = p_228940_5_.func_228366_a_(RenderType.func_228645_f_()); -@@ -526,10 +_,10 @@ - private void func_228942_a_(ChunkRenderDispatcher.CompiledChunk p_228942_1_, Set p_228942_2_, E p_228942_3_) { - TileEntityRenderer tileentityrenderer = TileEntityRendererDispatcher.field_147556_a.func_147547_b(p_228942_3_); - if (tileentityrenderer != null) { -- p_228942_1_.field_178499_e.add(p_228942_3_); - if (tileentityrenderer.func_188185_a(p_228942_3_)) { - p_228942_2_.add(p_228942_3_); + if (p_112869_.f_112749_.contains(RenderType.m_110466_())) { + BufferBuilder bufferbuilder1 = p_112870_.m_108839_(RenderType.m_110466_()); +@@ -583,10 +_,10 @@ + private void m_112877_(ChunkRenderDispatcher.CompiledChunk p_112878_, Set p_112879_, E p_112880_) { + BlockEntityRenderer blockentityrenderer = Minecraft.m_91087_().m_167982_().m_112265_(p_112880_); + if (blockentityrenderer != null) { +- p_112878_.f_112752_.add(p_112880_); + if (blockentityrenderer.m_5932_(p_112880_)) { + p_112879_.add(p_112880_); } -+ else p_228942_1_.field_178499_e.add(p_228942_3_); //FORGE: Fix MC-112730 ++ else p_112878_.f_112752_.add(p_112880_); //FORGE: Fix MC-112730 } } -@@ -547,8 +_,13 @@ - class SortTransparencyTask extends ChunkRenderDispatcher.ChunkRender.ChunkRenderTask { - private final ChunkRenderDispatcher.CompiledChunk field_228945_e_; +@@ -604,8 +_,13 @@ + class ResortTransparencyTask extends ChunkRenderDispatcher.RenderChunk.ChunkCompileTask { + private final ChunkRenderDispatcher.CompiledChunk f_112886_; + @Deprecated - public SortTransparencyTask(double p_i226025_2_, ChunkRenderDispatcher.CompiledChunk p_i226025_4_) { -- super(p_i226025_2_); -+ this(null, p_i226025_2_, p_i226025_4_); + public ResortTransparencyTask(double p_112889_, ChunkRenderDispatcher.CompiledChunk p_112890_) { +- super(p_112889_); ++ this(null, p_112889_, p_112890_); + } + -+ public SortTransparencyTask(@Nullable net.minecraft.util.math.ChunkPos pos, double p_i226025_2_, ChunkRenderDispatcher.CompiledChunk p_i226025_4_) { -+ super(pos, p_i226025_2_); - this.field_228945_e_ = p_i226025_4_; ++ public ResortTransparencyTask(@Nullable net.minecraft.world.level.ChunkPos pos, double p_112889_, ChunkRenderDispatcher.CompiledChunk p_112890_) { ++ super(pos, p_112889_); + this.f_112886_ = p_112890_; } diff --git a/patches/minecraft/net/minecraft/client/renderer/color/BlockColors.java.patch b/patches/minecraft/net/minecraft/client/renderer/color/BlockColors.java.patch deleted file mode 100644 index d2f85a396b..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/color/BlockColors.java.patch +++ /dev/null @@ -1,42 +0,0 @@ ---- a/net/minecraft/client/renderer/color/BlockColors.java -+++ b/net/minecraft/client/renderer/color/BlockColors.java -@@ -27,7 +_,8 @@ - - @OnlyIn(Dist.CLIENT) - public class BlockColors { -- private final ObjectIntIdentityMap field_186725_a = new ObjectIntIdentityMap<>(32); -+ // FORGE: Use RegistryDelegates as non-Vanilla block ids are not constant -+ private final java.util.Map, IBlockColor> field_186725_a = new java.util.HashMap<>(); - private final Map>> field_225311_b = Maps.newHashMap(); - - public static BlockColors func_186723_a() { -@@ -72,11 +_,12 @@ - blockcolors.func_186722_a((p_228055_0_, p_228055_1_, p_228055_2_, p_228055_3_) -> { - return p_228055_1_ != null && p_228055_2_ != null ? 2129968 : 7455580; - }, Blocks.field_196651_dG); -+ net.minecraftforge.client.ForgeHooksClient.onBlockColorsInit(blockcolors); - return blockcolors; - } - - public int func_189991_a(BlockState p_189991_1_, World p_189991_2_, BlockPos p_189991_3_) { -- IBlockColor iblockcolor = this.field_186725_a.func_148745_a(Registry.field_212618_g.func_148757_b(p_189991_1_.func_177230_c())); -+ IBlockColor iblockcolor = this.field_186725_a.get(p_189991_1_.func_177230_c().delegate); - if (iblockcolor != null) { - return iblockcolor.getColor(p_189991_1_, (IBlockDisplayReader)null, (BlockPos)null, 0); - } else { -@@ -86,13 +_,13 @@ - } - - public int func_228054_a_(BlockState p_228054_1_, @Nullable IBlockDisplayReader p_228054_2_, @Nullable BlockPos p_228054_3_, int p_228054_4_) { -- IBlockColor iblockcolor = this.field_186725_a.func_148745_a(Registry.field_212618_g.func_148757_b(p_228054_1_.func_177230_c())); -+ IBlockColor iblockcolor = this.field_186725_a.get(p_228054_1_.func_177230_c().delegate); - return iblockcolor == null ? -1 : iblockcolor.getColor(p_228054_1_, p_228054_2_, p_228054_3_, p_228054_4_); - } - - public void func_186722_a(IBlockColor p_186722_1_, Block... p_186722_2_) { - for(Block block : p_186722_2_) { -- this.field_186725_a.func_148746_a(p_186722_1_, Registry.field_212618_g.func_148757_b(block)); -+ this.field_186725_a.put(block.delegate, p_186722_1_); - } - - } diff --git a/patches/minecraft/net/minecraft/client/renderer/color/ItemColors.java.patch b/patches/minecraft/net/minecraft/client/renderer/color/ItemColors.java.patch deleted file mode 100644 index 0e8add93a8..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/color/ItemColors.java.patch +++ /dev/null @@ -1,33 +0,0 @@ ---- a/net/minecraft/client/renderer/color/ItemColors.java -+++ b/net/minecraft/client/renderer/color/ItemColors.java -@@ -22,7 +_,8 @@ - - @OnlyIn(Dist.CLIENT) - public class ItemColors { -- private final ObjectIntIdentityMap field_186732_a = new ObjectIntIdentityMap<>(32); -+ // FORGE: Use RegistryDelegates as non-Vanilla item ids are not constant -+ private final java.util.Map, IItemColor> field_186732_a = new java.util.HashMap<>(); - - public static ItemColors func_186729_a(BlockColors p_186729_0_) { - ItemColors itemcolors = new ItemColors(); -@@ -82,17 +_,18 @@ - itemcolors.func_199877_a((p_210237_0_, p_210237_1_) -> { - return p_210237_1_ == 0 ? -1 : FilledMapItem.func_190907_h(p_210237_0_); - }, Items.field_151098_aY); -+ net.minecraftforge.client.ForgeHooksClient.onItemColorsInit(itemcolors, p_186729_0_); - return itemcolors; - } - - public int func_186728_a(ItemStack p_186728_1_, int p_186728_2_) { -- IItemColor iitemcolor = this.field_186732_a.func_148745_a(Registry.field_212630_s.func_148757_b(p_186728_1_.func_77973_b())); -+ IItemColor iitemcolor = this.field_186732_a.get(p_186728_1_.func_77973_b().delegate); - return iitemcolor == null ? -1 : iitemcolor.getColor(p_186728_1_, p_186728_2_); - } - - public void func_199877_a(IItemColor p_199877_1_, IItemProvider... p_199877_2_) { - for(IItemProvider iitemprovider : p_199877_2_) { -- this.field_186732_a.func_148746_a(p_199877_1_, Item.func_150891_b(iitemprovider.func_199767_j())); -+ this.field_186732_a.put(iitemprovider.func_199767_j().delegate, p_199877_1_); - } - - } diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java.patch new file mode 100644 index 0000000000..60f65333a0 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java.patch @@ -0,0 +1,28 @@ +--- a/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java ++++ b/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java +@@ -161,12 +_,12 @@ + private static void m_114441_(PoseStack p_114442_, VertexConsumer p_114443_, Entity p_114444_, float p_114445_) { + AABB aabb = p_114444_.m_142469_().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); +- if (p_114444_ instanceof EnderDragon) { ++ if (p_114444_.isMultipartEntity()) { + double d0 = -Mth.m_14139_((double)p_114445_, p_114444_.f_19790_, p_114444_.m_20185_()); + double d1 = -Mth.m_14139_((double)p_114445_, p_114444_.f_19791_, p_114444_.m_20186_()); + double d2 = -Mth.m_14139_((double)p_114445_, p_114444_.f_19792_, p_114444_.m_20189_()); + +- for(EnderDragonPart enderdragonpart : ((EnderDragon)p_114444_).m_31156_()) { ++ for(net.minecraftforge.entity.PartEntity enderdragonpart : p_114444_.getParts()) { + p_114442_.m_85836_(); + double d3 = d0 + Mth.m_14139_((double)p_114445_, enderdragonpart.f_19790_, enderdragonpart.m_20185_()); + double d4 = d1 + Mth.m_14139_((double)p_114445_, enderdragonpart.f_19791_, enderdragonpart.m_20186_()); +@@ -322,6 +_,10 @@ + + public Quaternion m_114470_() { + return this.f_114367_; ++ } ++ ++ public Map> getSkinMap() { ++ return java.util.Collections.unmodifiableMap(f_114363_); + } + + public void m_6213_(ResourceManager p_174004_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderer.java.patch index 7c86558676..e9ea8b88c0 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderer.java.patch @@ -1,24 +1,24 @@ --- a/net/minecraft/client/renderer/entity/EntityRenderer.java +++ b/net/minecraft/client/renderer/entity/EntityRenderer.java -@@ -60,8 +_,10 @@ +@@ -63,8 +_,10 @@ } - public void func_225623_a_(T p_225623_1_, float p_225623_2_, float p_225623_3_, MatrixStack p_225623_4_, IRenderTypeBuffer p_225623_5_, int p_225623_6_) { -- if (this.func_177070_b(p_225623_1_)) { -- this.func_225629_a_(p_225623_1_, p_225623_1_.func_145748_c_(), p_225623_4_, p_225623_5_, p_225623_6_); -+ net.minecraftforge.client.event.RenderNameplateEvent renderNameplateEvent = new net.minecraftforge.client.event.RenderNameplateEvent(p_225623_1_, p_225623_1_.func_145748_c_(), this, p_225623_4_, p_225623_5_, p_225623_6_, p_225623_3_); + public void m_7392_(T p_114485_, float p_114486_, float p_114487_, PoseStack p_114488_, MultiBufferSource p_114489_, int p_114490_) { +- if (this.m_6512_(p_114485_)) { +- this.m_7649_(p_114485_, p_114485_.m_5446_(), p_114488_, p_114489_, p_114490_); ++ net.minecraftforge.client.event.RenderNameplateEvent renderNameplateEvent = new net.minecraftforge.client.event.RenderNameplateEvent(p_114485_, p_114485_.m_5446_(), this, p_114488_, p_114489_, p_114490_, p_114487_); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(renderNameplateEvent); -+ if (renderNameplateEvent.getResult() != net.minecraftforge.eventbus.api.Event.Result.DENY && (renderNameplateEvent.getResult() == net.minecraftforge.eventbus.api.Event.Result.ALLOW || this.func_177070_b(p_225623_1_))) { -+ this.func_225629_a_(p_225623_1_, renderNameplateEvent.getContent(), p_225623_4_, p_225623_5_, p_225623_6_); ++ if (renderNameplateEvent.getResult() != net.minecraftforge.eventbus.api.Event.Result.DENY && (renderNameplateEvent.getResult() == net.minecraftforge.eventbus.api.Event.Result.ALLOW || this.m_6512_(p_114485_))) { ++ this.m_7649_(p_114485_, renderNameplateEvent.getContent(), p_114488_, p_114489_, p_114490_); } } -@@ -77,7 +_,7 @@ +@@ -80,7 +_,7 @@ - protected void func_225629_a_(T p_225629_1_, ITextComponent p_225629_2_, MatrixStack p_225629_3_, IRenderTypeBuffer p_225629_4_, int p_225629_5_) { - double d0 = this.field_76990_c.func_229099_b_(p_225629_1_); + protected void m_7649_(T p_114498_, Component p_114499_, PoseStack p_114500_, MultiBufferSource p_114501_, int p_114502_) { + double d0 = this.f_114476_.m_114471_(p_114498_); - if (!(d0 > 4096.0D)) { -+ if (net.minecraftforge.client.ForgeHooksClient.isNameplateInRenderDistance(p_225629_1_, d0)) { - boolean flag = !p_225629_1_.func_226273_bm_(); - float f = p_225629_1_.func_213302_cg() + 0.5F; - int i = "deadmau5".equals(p_225629_2_.getString()) ? -10 : 0; ++ if (net.minecraftforge.client.ForgeHooksClient.isNameplateInRenderDistance(p_114498_, d0)) { + boolean flag = !p_114498_.m_20163_(); + float f = p_114498_.m_20206_() + 0.5F; + int i = "deadmau5".equals(p_114499_.getString()) ? -10 : 0; diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/EntityRendererManager.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/EntityRendererManager.java.patch deleted file mode 100644 index f6951f8019..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/entity/EntityRendererManager.java.patch +++ /dev/null @@ -1,38 +0,0 @@ ---- a/net/minecraft/client/renderer/entity/EntityRendererManager.java -+++ b/net/minecraft/client/renderer/entity/EntityRendererManager.java -@@ -188,7 +_,10 @@ - this.field_178637_m = new PlayerRenderer(this); - this.field_178636_l.put("default", this.field_178637_m); - this.field_178636_l.put("slim", new PlayerRenderer(this, true)); -+ } - -+ //FORGE: Validate the existence of a renderer for each entity type after modded entity renderers have been added -+ public void validateRendererExistence() { - for(EntityType entitytype : Registry.field_212629_r) { - if (entitytype != EntityType.field_200729_aH && !this.field_78729_o.containsKey(entitytype)) { - throw new IllegalStateException("No renderer registered for " + Registry.field_212629_r.func_177774_c(entitytype)); -@@ -280,12 +_,12 @@ - private void func_229093_a_(MatrixStack p_229093_1_, IVertexBuilder p_229093_2_, Entity p_229093_3_, float p_229093_4_) { - float f = p_229093_3_.func_213311_cf() / 2.0F; - this.func_229094_a_(p_229093_1_, p_229093_2_, p_229093_3_, 1.0F, 1.0F, 1.0F); -- if (p_229093_3_ instanceof EnderDragonEntity) { -+ if (p_229093_3_.isMultipartEntity()) { - double d0 = -MathHelper.func_219803_d((double)p_229093_4_, p_229093_3_.field_70142_S, p_229093_3_.func_226277_ct_()); - double d1 = -MathHelper.func_219803_d((double)p_229093_4_, p_229093_3_.field_70137_T, p_229093_3_.func_226278_cu_()); - double d2 = -MathHelper.func_219803_d((double)p_229093_4_, p_229093_3_.field_70136_U, p_229093_3_.func_226281_cx_()); - -- for(EnderDragonPartEntity enderdragonpartentity : ((EnderDragonEntity)p_229093_3_).func_213404_dT()) { -+ for(net.minecraftforge.entity.PartEntity enderdragonpartentity : p_229093_3_.getParts()) { - p_229093_1_.func_227860_a_(); - double d3 = d0 + MathHelper.func_219803_d((double)p_229093_4_, enderdragonpartentity.field_70142_S, enderdragonpartentity.func_226277_ct_()); - double d4 = d1 + MathHelper.func_219803_d((double)p_229093_4_, enderdragonpartentity.field_70137_T, enderdragonpartentity.func_226278_cu_()); -@@ -449,5 +_,9 @@ - - public FontRenderer func_78716_a() { - return this.field_78736_p; -+ } -+ -+ public Map getSkinMap() { -+ return (Map) java.util.Collections.unmodifiableMap(field_178636_l); - } - } diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/FallingBlockRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/FallingBlockRenderer.java.patch index 4a47d86d98..57698c4f67 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/FallingBlockRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/FallingBlockRenderer.java.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/client/renderer/entity/FallingBlockRenderer.java +++ b/net/minecraft/client/renderer/entity/FallingBlockRenderer.java @@ -33,7 +_,13 @@ - BlockPos blockpos = new BlockPos(p_225623_1_.func_226277_ct_(), p_225623_1_.func_174813_aQ().field_72337_e, p_225623_1_.func_226281_cx_()); - p_225623_4_.func_227861_a_(-0.5D, 0.0D, -0.5D); - BlockRendererDispatcher blockrendererdispatcher = Minecraft.func_71410_x().func_175602_ab(); -- blockrendererdispatcher.func_175019_b().func_228802_a_(world, blockrendererdispatcher.func_184389_a(blockstate), blockstate, blockpos, p_225623_4_, p_225623_5_.getBuffer(RenderTypeLookup.func_239221_b_(blockstate)), false, new Random(), blockstate.func_209533_a(p_225623_1_.func_184531_j()), OverlayTexture.field_229196_a_); -+ for (net.minecraft.client.renderer.RenderType type : net.minecraft.client.renderer.RenderType.func_228661_n_()) { -+ if (RenderTypeLookup.canRenderInLayer(blockstate, type)) { + BlockPos blockpos = new BlockPos(p_114634_.m_20185_(), p_114634_.m_142469_().f_82292_, p_114634_.m_20189_()); + p_114637_.m_85837_(-0.5D, 0.0D, -0.5D); + BlockRenderDispatcher blockrenderdispatcher = Minecraft.m_91087_().m_91289_(); +- blockrenderdispatcher.m_110937_().m_111047_(level, blockrenderdispatcher.m_110910_(blockstate), blockstate, blockpos, p_114637_, p_114638_.m_6299_(ItemBlockRenderTypes.m_109293_(blockstate)), false, new Random(), blockstate.m_60726_(p_114634_.m_31978_()), OverlayTexture.f_118083_); ++ for (net.minecraft.client.renderer.RenderType type : net.minecraft.client.renderer.RenderType.m_110506_()) { ++ if (ItemBlockRenderTypes.canRenderInLayer(blockstate, type)) { + net.minecraftforge.client.ForgeHooksClient.setRenderLayer(type); -+ blockrendererdispatcher.func_175019_b().func_228802_a_(world, blockrendererdispatcher.func_184389_a(blockstate), blockstate, blockpos, p_225623_4_, p_225623_5_.getBuffer(type), false, new Random(), blockstate.func_209533_a(p_225623_1_.func_184531_j()), OverlayTexture.field_229196_a_); ++ blockrenderdispatcher.m_110937_().m_111047_(level, blockrenderdispatcher.m_110910_(blockstate), blockstate, blockpos, p_114637_, p_114638_.m_6299_(type), false, new Random(), blockstate.m_60726_(p_114634_.m_31978_()), OverlayTexture.f_118083_); + } + } + net.minecraftforge.client.ForgeHooksClient.setRenderLayer(null); - p_225623_4_.func_227865_b_(); - super.func_225623_a_(p_225623_1_, p_225623_2_, p_225623_3_, p_225623_4_, p_225623_5_, p_225623_6_); + p_114637_.m_85849_(); + super.m_7392_(p_114634_, p_114635_, p_114636_, p_114637_, p_114638_, p_114639_); } diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/ItemEntityRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/ItemEntityRenderer.java.patch new file mode 100644 index 0000000000..b498636b1f --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/entity/ItemEntityRenderer.java.patch @@ -0,0 +1,68 @@ +--- a/net/minecraft/client/renderer/entity/ItemEntityRenderer.java ++++ b/net/minecraft/client/renderer/entity/ItemEntityRenderer.java +@@ -62,17 +_,14 @@ + int j = this.m_115042_(itemstack); + float f = 0.25F; + float f1 = Mth.m_14031_(((float)p_115036_.m_32059_() + p_115038_) / 10.0F + p_115036_.f_31983_) * 0.1F + 0.1F; +- float f2 = bakedmodel.m_7442_().m_111808_(ItemTransforms.TransformType.GROUND).f_111757_.m_122260_(); ++ float f2 = shouldBob() ? bakedmodel.m_7442_().m_111808_(ItemTransforms.TransformType.GROUND).f_111757_.m_122260_() : 0; + p_115039_.m_85837_(0.0D, (double)(f1 + 0.25F * f2), 0.0D); + float f3 = p_115036_.m_32008_(p_115038_); + p_115039_.m_85845_(Vector3f.f_122225_.m_122270_(f3)); +- float f4 = bakedmodel.m_7442_().f_111793_.f_111757_.m_122239_(); +- float f5 = bakedmodel.m_7442_().f_111793_.f_111757_.m_122260_(); +- float f6 = bakedmodel.m_7442_().f_111793_.f_111757_.m_122269_(); + if (!flag) { +- float f7 = -0.0F * (float)(j - 1) * 0.5F * f4; +- float f8 = -0.0F * (float)(j - 1) * 0.5F * f5; +- float f9 = -0.09375F * (float)(j - 1) * 0.5F * f6; ++ float f7 = -0.0F * (float)(j - 1) * 0.5F; ++ float f8 = -0.0F * (float)(j - 1) * 0.5F; ++ float f9 = -0.09375F * (float)(j - 1) * 0.5F; + p_115039_.m_85837_((double)f7, (double)f8, (double)f9); + } + +@@ -83,18 +_,18 @@ + float f11 = (this.f_115020_.nextFloat() * 2.0F - 1.0F) * 0.15F; + float f13 = (this.f_115020_.nextFloat() * 2.0F - 1.0F) * 0.15F; + float f10 = (this.f_115020_.nextFloat() * 2.0F - 1.0F) * 0.15F; +- p_115039_.m_85837_((double)f11, (double)f13, (double)f10); ++ p_115039_.m_85837_(shouldSpreadItems() ? f11 : 0, shouldSpreadItems() ? f13 : 0, shouldSpreadItems() ? f10 : 0); + } else { + float f12 = (this.f_115020_.nextFloat() * 2.0F - 1.0F) * 0.15F * 0.5F; + float f14 = (this.f_115020_.nextFloat() * 2.0F - 1.0F) * 0.15F * 0.5F; +- p_115039_.m_85837_((double)f12, (double)f14, 0.0D); ++ p_115039_.m_85837_(shouldSpreadItems() ? f12 : 0, shouldSpreadItems() ? f14 : 0, 0.0D); + } + } + + this.f_115019_.m_115143_(itemstack, ItemTransforms.TransformType.GROUND, false, p_115039_, p_115040_, p_115041_, OverlayTexture.f_118083_, bakedmodel); + p_115039_.m_85849_(); + if (!flag) { +- p_115039_.m_85837_((double)(0.0F * f4), (double)(0.0F * f5), (double)(0.09375F * f6)); ++ p_115039_.m_85837_(0.0, 0.0, 0.09375F); + } + } + +@@ -105,4 +_,21 @@ + public ResourceLocation m_5478_(ItemEntity p_115034_) { + return TextureAtlas.f_118259_; + } ++ ++ /*==================================== FORGE START ===========================================*/ ++ ++ /** ++ * @return If items should spread out when rendered in 3D ++ */ ++ public boolean shouldSpreadItems() { ++ return true; ++ } ++ ++ /** ++ * @return If items should have a bob effect ++ */ ++ public boolean shouldBob() { ++ return true; ++ } ++ /*==================================== FORGE END =============================================*/ + } diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/ItemFrameRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/ItemFrameRenderer.java.patch index 573a8131b8..03ab6b9989 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/ItemFrameRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/ItemFrameRenderer.java.patch @@ -1,44 +1,45 @@ --- a/net/minecraft/client/renderer/entity/ItemFrameRenderer.java +++ b/net/minecraft/client/renderer/entity/ItemFrameRenderer.java -@@ -50,7 +_,7 @@ +@@ -61,7 +_,7 @@ if (!flag) { - BlockRendererDispatcher blockrendererdispatcher = this.field_147917_g.func_175602_ab(); - ModelManager modelmanager = blockrendererdispatcher.func_175023_a().func_178126_b(); -- ModelResourceLocation modelresourcelocation = p_225623_1_.func_82335_i().func_77973_b() == Items.field_151098_aY ? field_209586_g : field_209585_f; -+ ModelResourceLocation modelresourcelocation = p_225623_1_.func_82335_i().func_77973_b() instanceof FilledMapItem ? field_209586_g : field_209585_f; - p_225623_4_.func_227860_a_(); - p_225623_4_.func_227861_a_(-0.5D, -0.5D, -0.5D); - blockrendererdispatcher.func_175019_b().func_228804_a_(p_225623_4_.func_227866_c_(), p_225623_5_.getBuffer(Atlases.func_228782_g_()), (BlockState)null, modelmanager.func_174953_a(modelresourcelocation), 1.0F, 1.0F, 1.0F, p_225623_6_, OverlayTexture.field_229196_a_); -@@ -59,21 +_,21 @@ + BlockRenderDispatcher blockrenderdispatcher = this.f_115046_.m_91289_(); + ModelManager modelmanager = blockrenderdispatcher.m_110907_().m_110881_(); +- ModelResourceLocation modelresourcelocation = this.m_174212_(p_115076_, itemstack); ++ ModelResourceLocation modelresourcelocation = p_115076_.m_31822_().m_41720_() instanceof MapItem ? f_115045_ : f_115044_; + p_115079_.m_85836_(); + p_115079_.m_85837_(-0.5D, -0.5D, -0.5D); + blockrenderdispatcher.m_110937_().m_111067_(p_115079_.m_85850_(), p_115080_.m_6299_(Sheets.m_110789_()), (BlockState)null, modelmanager.m_119422_(modelresourcelocation), 1.0F, 1.0F, 1.0F, p_115081_, OverlayTexture.f_118083_); +@@ -69,22 +_,22 @@ + } - ItemStack itemstack = p_225623_1_.func_82335_i(); - if (!itemstack.func_190926_b()) { -- boolean flag1 = itemstack.func_77973_b() == Items.field_151098_aY; -+ MapData mapdata = FilledMapItem.func_195950_a(itemstack, p_225623_1_.field_70170_p); + if (!itemstack.m_41619_()) { +- boolean flag1 = itemstack.m_150930_(Items.f_42573_); ++ MapItemSavedData mapitemsaveddata = MapItem.m_42853_(itemstack, p_115076_.f_19853_); if (flag) { - p_225623_4_.func_227861_a_(0.0D, 0.0D, 0.5D); + p_115079_.m_85837_(0.0D, 0.0D, 0.5D); } else { - p_225623_4_.func_227861_a_(0.0D, 0.0D, 0.4375D); + p_115079_.m_85837_(0.0D, 0.0D, 0.4375D); } -- int i = flag1 ? p_225623_1_.func_82333_j() % 4 * 2 : p_225623_1_.func_82333_j(); -+ int i = mapdata != null ? p_225623_1_.func_82333_j() % 4 * 2 : p_225623_1_.func_82333_j(); - p_225623_4_.func_227863_a_(Vector3f.field_229183_f_.func_229187_a_((float)i * 360.0F / 8.0F)); +- int j = flag1 ? p_115076_.m_31823_() % 4 * 2 : p_115076_.m_31823_(); ++ int j = mapitemsaveddata != null ? p_115076_.m_31823_() % 4 * 2 : p_115076_.m_31823_(); + p_115079_.m_85845_(Vector3f.f_122227_.m_122240_((float)j * 360.0F / 8.0F)); - if (flag1) { -+ if (!net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderItemInFrameEvent(p_225623_1_, this, p_225623_4_, p_225623_5_, p_225623_6_))) { -+ if (mapdata != null) { - p_225623_4_.func_227863_a_(Vector3f.field_229183_f_.func_229187_a_(180.0F)); ++ if (!net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderItemInFrameEvent(p_115076_, this, p_115079_, p_115080_, p_115081_))) { ++ if (mapitemsaveddata != null) { + p_115079_.m_85845_(Vector3f.f_122227_.m_122240_(180.0F)); float f = 0.0078125F; - p_225623_4_.func_227862_a_(0.0078125F, 0.0078125F, 0.0078125F); - p_225623_4_.func_227861_a_(-64.0D, -64.0D, 0.0D); -- MapData mapdata = FilledMapItem.func_195950_a(itemstack, p_225623_1_.field_70170_p); - p_225623_4_.func_227861_a_(0.0D, 0.0D, -1.0D); - if (mapdata != null) { - this.field_147917_g.field_71460_t.func_147701_i().func_228086_a_(p_225623_4_, p_225623_5_, mapdata, true, p_225623_6_); -@@ -81,6 +_,7 @@ - } else { - p_225623_4_.func_227862_a_(0.5F, 0.5F, 0.5F); - this.field_177074_h.func_229110_a_(itemstack, ItemCameraTransforms.TransformType.FIXED, p_225623_6_, OverlayTexture.field_229196_a_, p_225623_4_, p_225623_5_); + p_115079_.m_85841_(0.0078125F, 0.0078125F, 0.0078125F); + p_115079_.m_85837_(-64.0D, -64.0D, 0.0D); + Integer integer = MapItem.m_151131_(itemstack); +- MapItemSavedData mapitemsaveddata = MapItem.m_151128_(integer, p_115076_.f_19853_); + p_115079_.m_85837_(0.0D, 0.0D, -1.0D); + if (mapitemsaveddata != null) { + int i = this.m_174208_(p_115076_, 15728850, p_115081_); +@@ -94,6 +_,7 @@ + int k = this.m_174208_(p_115076_, 15728880, p_115081_); + p_115079_.m_85841_(0.5F, 0.5F, 0.5F); + this.f_115047_.m_174269_(itemstack, ItemTransforms.TransformType.FIXED, k, OverlayTexture.f_118083_, p_115079_, p_115080_, p_115076_.m_142049_()); + } } } diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/ItemRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/ItemRenderer.java.patch index e40728095a..a38281a16a 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/ItemRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/ItemRenderer.java.patch @@ -1,68 +1,93 @@ --- a/net/minecraft/client/renderer/entity/ItemRenderer.java +++ b/net/minecraft/client/renderer/entity/ItemRenderer.java -@@ -54,17 +_,14 @@ - int j = this.func_177078_a(itemstack); - float f = 0.25F; - float f1 = MathHelper.func_76126_a(((float)p_225623_1_.func_174872_o() + p_225623_3_) / 10.0F + p_225623_1_.field_70290_d) * 0.1F + 0.1F; -- float f2 = ibakedmodel.func_177552_f().func_181688_b(ItemCameraTransforms.TransformType.GROUND).field_178363_d.func_195900_b(); -+ float f2 = shouldBob() ? ibakedmodel.func_177552_f().func_181688_b(ItemCameraTransforms.TransformType.GROUND).field_178363_d.func_195900_b() : 0; - p_225623_4_.func_227861_a_(0.0D, (double)(f1 + 0.25F * f2), 0.0D); - float f3 = p_225623_1_.func_234272_a_(p_225623_3_); - p_225623_4_.func_227863_a_(Vector3f.field_229181_d_.func_229193_c_(f3)); -- float f4 = ibakedmodel.func_177552_f().field_181699_o.field_178363_d.func_195899_a(); -- float f5 = ibakedmodel.func_177552_f().field_181699_o.field_178363_d.func_195900_b(); -- float f6 = ibakedmodel.func_177552_f().field_181699_o.field_178363_d.func_195902_c(); - if (!flag) { -- float f7 = -0.0F * (float)(j - 1) * 0.5F * f4; -- float f8 = -0.0F * (float)(j - 1) * 0.5F * f5; -- float f9 = -0.09375F * (float)(j - 1) * 0.5F * f6; -+ float f7 = -0.0F * (float)(j - 1) * 0.5F; -+ float f8 = -0.0F * (float)(j - 1) * 0.5F; -+ float f9 = -0.09375F * (float)(j - 1) * 0.5F; - p_225623_4_.func_227861_a_((double)f7, (double)f8, (double)f9); - } +@@ -76,8 +_,8 @@ -@@ -75,18 +_,18 @@ - float f11 = (this.field_177079_e.nextFloat() * 2.0F - 1.0F) * 0.15F; - float f13 = (this.field_177079_e.nextFloat() * 2.0F - 1.0F) * 0.15F; - float f10 = (this.field_177079_e.nextFloat() * 2.0F - 1.0F) * 0.15F; -- p_225623_4_.func_227861_a_((double)f11, (double)f13, (double)f10); -+ p_225623_4_.func_227861_a_(shouldSpreadItems() ? f11 : 0, shouldSpreadItems() ? f13 : 0, shouldSpreadItems() ? f10 : 0); - } else { - float f12 = (this.field_177079_e.nextFloat() * 2.0F - 1.0F) * 0.15F * 0.5F; - float f14 = (this.field_177079_e.nextFloat() * 2.0F - 1.0F) * 0.15F * 0.5F; -- p_225623_4_.func_227861_a_((double)f12, (double)f14, 0.0D); -+ p_225623_4_.func_227861_a_(shouldSpreadItems() ? f12 : 0, shouldSpreadItems() ? f14 : 0, 0.0D); + public ItemRenderer(TextureManager p_174225_, ModelManager p_174226_, ItemColors p_174227_, BlockEntityWithoutLevelRenderer p_174228_) { + this.f_115096_ = p_174225_; +- this.f_115095_ = new ItemModelShaper(p_174226_); + this.f_174223_ = p_174228_; ++ this.f_115095_ = new net.minecraftforge.client.ItemModelMesherForge(p_174226_); + + for(Item item : Registry.f_122827_) { + if (!f_115094_.contains(item)) { +@@ -117,7 +_,7 @@ } } - this.field_177080_a.func_229111_a_(itemstack, ItemCameraTransforms.TransformType.GROUND, false, p_225623_4_, p_225623_5_, p_225623_6_, OverlayTexture.field_229196_a_, ibakedmodel); - p_225623_4_.func_227865_b_(); - if (!flag) { -- p_225623_4_.func_227861_a_((double)(0.0F * f4), (double)(0.0F * f5), (double)(0.09375F * f6)); -+ p_225623_4_.func_227861_a_(0.0, 0.0, 0.09375F); +- p_115151_.m_7442_().m_111808_(p_115145_).m_111763_(p_115146_, p_115147_); ++ p_115151_ = net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms(p_115147_, p_115151_, p_115145_, p_115146_); + p_115147_.m_85837_(-0.5D, -0.5D, -0.5D); + if (!p_115151_.m_7521_() && (!p_115144_.m_150930_(Items.f_42713_) || flag)) { + boolean flag1; +@@ -127,7 +_,8 @@ + } else { + flag1 = true; + } +- ++ if (p_115151_.isLayered()) { net.minecraftforge.client.ForgeHooksClient.drawItemLayered(this, p_115151_, p_115144_, p_115147_, p_115148_, p_115149_, p_115150_, flag1); } ++ else { + RenderType rendertype = ItemBlockRenderTypes.m_109279_(p_115144_, flag1); + VertexConsumer vertexconsumer; + if (p_115144_.m_150930_(Items.f_42522_) && p_115144_.m_41790_()) { +@@ -153,8 +_,9 @@ + } + + this.m_115189_(p_115151_, p_115144_, p_115149_, p_115150_, p_115147_, vertexconsumer); ++ } + } else { +- this.f_174223_.m_108829_(p_115144_, p_115145_, p_115147_, p_115148_, p_115149_, p_115150_); ++ net.minecraftforge.client.RenderProperties.get(p_115144_).getItemStackRenderer().m_108829_(p_115144_, p_115145_, p_115147_, p_115148_, p_115149_, p_115150_); } + + p_115147_.m_85849_(); +@@ -198,7 +_,7 @@ + float f = (float)(i >> 16 & 255) / 255.0F; + float f1 = (float)(i >> 8 & 255) / 255.0F; + float f2 = (float)(i & 255) / 255.0F; +- p_115164_.m_85987_(posestack$pose, bakedquad, f, f1, f2, p_115167_, p_115168_); ++ p_115164_.putBulkData(posestack$pose, bakedquad, f, f1, f2, p_115167_, p_115168_, true); } -@@ -97,4 +_,21 @@ - public ResourceLocation func_110775_a(ItemEntity p_110775_1_) { - return AtlasTexture.field_110575_b; } -+ -+ /*==================================== FORGE START ===========================================*/ -+ -+ /** -+ * @return If items should spread out when rendered in 3D -+ */ -+ public boolean shouldSpreadItems() { -+ return true; +@@ -301,6 +_,7 @@ + crashreportcategory.m_128165_("Item Type", () -> { + return String.valueOf((Object)p_174237_.m_41720_()); + }); ++ crashreportcategory.m_128165_("Registry Name", () -> String.valueOf(p_174237_.m_41720_().getRegistryName())); + crashreportcategory.m_128165_("Item Damage", () -> { + return String.valueOf(p_174237_.m_41773_()); + }); +@@ -332,14 +_,15 @@ + multibuffersource$buffersource.m_109911_(); + } + +- if (p_115176_.m_150947_()) { ++ if (p_115176_.m_41720_().showDurabilityBar(p_115176_)) { + RenderSystem.m_69465_(); + RenderSystem.m_69472_(); + RenderSystem.m_69461_(); + Tesselator tesselator = Tesselator.m_85913_(); + BufferBuilder bufferbuilder = tesselator.m_85915_(); +- int i = p_115176_.m_150948_(); +- int j = p_115176_.m_150949_(); ++ double health = p_115176_.m_41720_().getDurabilityForDisplay(p_115176_); ++ int i = Math.round(13.0F - (float)health * 13.0F); ++ int j = p_115176_.m_41720_().getRGBDurabilityForDisplay(p_115176_); + this.m_115152_(bufferbuilder, p_115177_ + 2, p_115178_ + 13, 13, 2, 0, 0, 0, 255); + this.m_115152_(bufferbuilder, p_115177_ + 2, p_115178_ + 13, i, 1, j >> 16 & 255, j >> 8 & 255, j & 255, 255); + RenderSystem.m_69478_(); +@@ -377,5 +_,14 @@ + + public void m_6213_(ResourceManager p_115105_) { + this.f_115095_.m_109403_(); + } + -+ /** -+ * @return If items should have a bob effect -+ */ -+ public boolean shouldBob() { -+ return true; ++ public BlockEntityWithoutLevelRenderer getBlockEntityRenderer() { ++ return f_174223_; + } -+ /*==================================== FORGE END =============================================*/ ++ ++ @Override ++ public net.minecraftforge.resource.IResourceType getResourceType() { ++ return net.minecraftforge.resource.VanillaResourceType.MODELS; + } } diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/LivingEntityRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/LivingEntityRenderer.java.patch new file mode 100644 index 0000000000..fcdb1caa0a --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/entity/LivingEntityRenderer.java.patch @@ -0,0 +1,39 @@ +--- a/net/minecraft/client/renderer/entity/LivingEntityRenderer.java ++++ b/net/minecraft/client/renderer/entity/LivingEntityRenderer.java +@@ -49,14 +_,17 @@ + } + + public void m_7392_(T p_115308_, float p_115309_, float p_115310_, PoseStack p_115311_, MultiBufferSource p_115312_, int p_115313_) { ++ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderLivingEvent.Pre(p_115308_, this, p_115310_, p_115311_, p_115312_, p_115313_))) return; + p_115311_.m_85836_(); + this.f_115290_.f_102608_ = this.m_115342_(p_115308_, p_115310_); +- this.f_115290_.f_102609_ = p_115308_.m_20159_(); ++ ++ boolean shouldSit = p_115308_.m_20159_() && (p_115308_.m_20202_() != null && p_115308_.m_20202_().shouldRiderSit()); ++ this.f_115290_.f_102609_ = shouldSit; + this.f_115290_.f_102610_ = p_115308_.m_6162_(); + 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 (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; +@@ -93,7 +_,7 @@ + p_115311_.m_85837_(0.0D, (double)-1.501F, 0.0D); + float f8 = 0.0F; + float f5 = 0.0F; +- if (!p_115308_.m_20159_() && p_115308_.m_6084_()) { ++ if (!shouldSit && p_115308_.m_6084_()) { + f8 = Mth.m_14179_(p_115310_, p_115308_.f_20923_, p_115308_.f_20924_); + f5 = p_115308_.f_20925_ - p_115308_.f_20924_ * (1.0F - p_115310_); + if (p_115308_.m_6162_()) { +@@ -126,6 +_,7 @@ + + p_115311_.m_85849_(); + super.m_7392_(p_115308_, p_115309_, p_115310_, p_115311_, p_115312_, p_115313_); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderLivingEvent.Post(p_115308_, this, p_115310_, p_115311_, p_115312_, p_115313_)); + } + + @Nullable diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/LivingRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/LivingRenderer.java.patch deleted file mode 100644 index 39085f6227..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/entity/LivingRenderer.java.patch +++ /dev/null @@ -1,39 +0,0 @@ ---- a/net/minecraft/client/renderer/entity/LivingRenderer.java -+++ b/net/minecraft/client/renderer/entity/LivingRenderer.java -@@ -48,14 +_,17 @@ - } - - public void func_225623_a_(T p_225623_1_, float p_225623_2_, float p_225623_3_, MatrixStack p_225623_4_, IRenderTypeBuffer p_225623_5_, int p_225623_6_) { -+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderLivingEvent.Pre(p_225623_1_, this, p_225623_3_, p_225623_4_, p_225623_5_, p_225623_6_))) return; - p_225623_4_.func_227860_a_(); - this.field_77045_g.field_217112_c = this.func_77040_d(p_225623_1_, p_225623_3_); -- this.field_77045_g.field_217113_d = p_225623_1_.func_184218_aH(); -+ -+ boolean shouldSit = p_225623_1_.func_184218_aH() && (p_225623_1_.func_184187_bx() != null && p_225623_1_.func_184187_bx().shouldRiderSit()); -+ this.field_77045_g.field_217113_d = shouldSit; - this.field_77045_g.field_217114_e = p_225623_1_.func_70631_g_(); - float f = MathHelper.func_219805_h(p_225623_3_, p_225623_1_.field_70760_ar, p_225623_1_.field_70761_aq); - float f1 = MathHelper.func_219805_h(p_225623_3_, p_225623_1_.field_70758_at, p_225623_1_.field_70759_as); - float f2 = f1 - f; -- if (p_225623_1_.func_184218_aH() && p_225623_1_.func_184187_bx() instanceof LivingEntity) { -+ if (shouldSit && p_225623_1_.func_184187_bx() instanceof LivingEntity) { - LivingEntity livingentity = (LivingEntity)p_225623_1_.func_184187_bx(); - f = MathHelper.func_219805_h(p_225623_3_, livingentity.field_70760_ar, livingentity.field_70761_aq); - f2 = f1 - f; -@@ -92,7 +_,7 @@ - p_225623_4_.func_227861_a_(0.0D, (double)-1.501F, 0.0D); - float f8 = 0.0F; - float f5 = 0.0F; -- if (!p_225623_1_.func_184218_aH() && p_225623_1_.func_70089_S()) { -+ if (!shouldSit && p_225623_1_.func_70089_S()) { - f8 = MathHelper.func_219799_g(p_225623_3_, p_225623_1_.field_184618_aE, p_225623_1_.field_70721_aZ); - f5 = p_225623_1_.field_184619_aG - p_225623_1_.field_70721_aZ * (1.0F - p_225623_3_); - if (p_225623_1_.func_70631_g_()) { -@@ -125,6 +_,7 @@ - - p_225623_4_.func_227865_b_(); - super.func_225623_a_(p_225623_1_, p_225623_2_, p_225623_3_, p_225623_4_, p_225623_5_, p_225623_6_); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderLivingEvent.Post(p_225623_1_, this, p_225623_3_, p_225623_4_, p_225623_5_, p_225623_6_)); - } - - @Nullable diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/PlayerRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/PlayerRenderer.java.patch deleted file mode 100644 index bbb4533ae5..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/entity/PlayerRenderer.java.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/net/minecraft/client/renderer/entity/PlayerRenderer.java -+++ b/net/minecraft/client/renderer/entity/PlayerRenderer.java -@@ -60,7 +_,9 @@ - - public void func_225623_a_(AbstractClientPlayerEntity p_225623_1_, float p_225623_2_, float p_225623_3_, MatrixStack p_225623_4_, IRenderTypeBuffer p_225623_5_, int p_225623_6_) { - this.func_177137_d(p_225623_1_); -+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderPlayerEvent.Pre(p_225623_1_, this, p_225623_3_, p_225623_4_, p_225623_5_, p_225623_6_))) return; - super.func_225623_a_(p_225623_1_, p_225623_2_, p_225623_3_, p_225623_4_, p_225623_5_, p_225623_6_); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderPlayerEvent.Post(p_225623_1_, this, p_225623_3_, p_225623_4_, p_225623_5_, p_225623_6_)); - } - - public Vector3d func_225627_b_(AbstractClientPlayerEntity p_225627_1_, float p_225627_2_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/layers/BipedArmorLayer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/layers/BipedArmorLayer.java.patch deleted file mode 100644 index 14c4d7f486..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/entity/layers/BipedArmorLayer.java.patch +++ /dev/null @@ -1,91 +0,0 @@ ---- a/net/minecraft/client/renderer/entity/layers/BipedArmorLayer.java -+++ b/net/minecraft/client/renderer/entity/layers/BipedArmorLayer.java -@@ -44,19 +_,20 @@ - if (itemstack.func_77973_b() instanceof ArmorItem) { - ArmorItem armoritem = (ArmorItem)itemstack.func_77973_b(); - if (armoritem.func_185083_B_() == p_241739_4_) { -+ p_241739_6_ = getArmorModelHook(p_241739_3_, itemstack, p_241739_4_, p_241739_6_); - this.func_215332_c().func_217148_a(p_241739_6_); - this.func_188359_a(p_241739_6_, p_241739_4_); - boolean flag = this.func_188363_b(p_241739_4_); - boolean flag1 = itemstack.func_77962_s(); -- if (armoritem instanceof DyeableArmorItem) { -- int i = ((DyeableArmorItem)armoritem).func_200886_f(itemstack); -+ if (armoritem instanceof net.minecraft.item.IDyeableArmorItem) { -+ int i = ((net.minecraft.item.IDyeableArmorItem)armoritem).func_200886_f(itemstack); - float f = (float)(i >> 16 & 255) / 255.0F; - float f1 = (float)(i >> 8 & 255) / 255.0F; - float f2 = (float)(i & 255) / 255.0F; -- this.func_241738_a_(p_241739_1_, p_241739_2_, p_241739_5_, armoritem, flag1, p_241739_6_, flag, f, f1, f2, (String)null); -- this.func_241738_a_(p_241739_1_, p_241739_2_, p_241739_5_, armoritem, flag1, p_241739_6_, flag, 1.0F, 1.0F, 1.0F, "overlay"); -+ this.renderModel(p_241739_1_, p_241739_2_, p_241739_5_, flag1, p_241739_6_, f, f1, f2, this.getArmorResource(p_241739_3_, itemstack, p_241739_4_, null)); -+ this.renderModel(p_241739_1_, p_241739_2_, p_241739_5_, flag1, p_241739_6_, 1.0F, 1.0F, 1.0F, this.getArmorResource(p_241739_3_, itemstack, p_241739_4_, "overlay")); - } else { -- this.func_241738_a_(p_241739_1_, p_241739_2_, p_241739_5_, armoritem, flag1, p_241739_6_, flag, 1.0F, 1.0F, 1.0F, (String)null); -+ this.renderModel(p_241739_1_, p_241739_2_, p_241739_5_, flag1, p_241739_6_, 1.0F, 1.0F, 1.0F, this.getArmorResource(p_241739_3_, itemstack, p_241739_4_, null)); - } - - } -@@ -88,7 +_,10 @@ - } - - private void func_241738_a_(MatrixStack p_241738_1_, IRenderTypeBuffer p_241738_2_, int p_241738_3_, ArmorItem p_241738_4_, boolean p_241738_5_, A p_241738_6_, boolean p_241738_7_, float p_241738_8_, float p_241738_9_, float p_241738_10_, @Nullable String p_241738_11_) { -- IVertexBuilder ivertexbuilder = ItemRenderer.func_239386_a_(p_241738_2_, RenderType.func_239263_a_(this.func_241737_a_(p_241738_4_, p_241738_7_, p_241738_11_)), false, p_241738_5_); -+ renderModel(p_241738_1_, p_241738_2_, p_241738_3_, p_241738_5_, p_241738_6_, p_241738_8_, p_241738_9_, p_241738_10_, this.func_241737_a_(p_241738_4_, p_241738_7_, p_241738_11_)); -+ } -+ private void renderModel(MatrixStack p_241738_1_, IRenderTypeBuffer p_241738_2_, int p_241738_3_, boolean p_241738_5_, A p_241738_6_, float p_241738_8_, float p_241738_9_, float p_241738_10_, ResourceLocation armorResource) { -+ IVertexBuilder ivertexbuilder = ItemRenderer.func_239386_a_(p_241738_2_, RenderType.func_239263_a_(armorResource), false, p_241738_5_); - p_241738_6_.func_225598_a_(p_241738_1_, ivertexbuilder, p_241738_3_, OverlayTexture.field_229196_a_, p_241738_8_, p_241738_9_, p_241738_10_, 1.0F); - } - -@@ -100,8 +_,50 @@ - return p_188363_1_ == EquipmentSlotType.LEGS; - } - -+ @Deprecated //Use the more sensitive version getArmorResource below - private ResourceLocation func_241737_a_(ArmorItem p_241737_1_, boolean p_241737_2_, @Nullable String p_241737_3_) { - String s = "textures/models/armor/" + p_241737_1_.func_200880_d().func_200897_d() + "_layer_" + (p_241737_2_ ? 2 : 1) + (p_241737_3_ == null ? "" : "_" + p_241737_3_) + ".png"; - return field_177191_j.computeIfAbsent(s, ResourceLocation::new); - } -+ -+ /*=================================== FORGE START =========================================*/ -+ -+ /** -+ * Hook to allow item-sensitive armor model. for LayerBipedArmor. -+ */ -+ protected A getArmorModelHook(T entity, ItemStack itemStack, EquipmentSlotType slot, A model) { -+ return net.minecraftforge.client.ForgeHooksClient.getArmorModel(entity, itemStack, slot, model); -+ } -+ -+ /** -+ * More generic ForgeHook version of the above function, it allows for Items to have more control over what texture they provide. -+ * -+ * @param entity Entity wearing the armor -+ * @param stack ItemStack for the armor -+ * @param slot Slot ID that the item is in -+ * @param type Subtype, can be null or "overlay" -+ * @return ResourceLocation pointing at the armor's texture -+ */ -+ public ResourceLocation getArmorResource(net.minecraft.entity.Entity entity, ItemStack stack, EquipmentSlotType slot, @Nullable String type) { -+ ArmorItem item = (ArmorItem)stack.func_77973_b(); -+ String texture = item.func_200880_d().func_200897_d(); -+ String domain = "minecraft"; -+ int idx = texture.indexOf(':'); -+ if (idx != -1) { -+ domain = texture.substring(0, idx); -+ texture = texture.substring(idx + 1); -+ } -+ String s1 = String.format("%s:textures/models/armor/%s_layer_%d%s.png", domain, texture, (func_188363_b(slot) ? 2 : 1), type == null ? "" : String.format("_%s", type)); -+ -+ s1 = net.minecraftforge.client.ForgeHooksClient.getArmorTexture(entity, stack, s1, slot, type); -+ ResourceLocation resourcelocation = field_177191_j.get(s1); -+ -+ if (resourcelocation == null) { -+ resourcelocation = new ResourceLocation(s1); -+ field_177191_j.put(s1, resourcelocation); -+ } -+ -+ return resourcelocation; -+ } -+ /*=================================== FORGE END ===========================================*/ - } 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 dfd72d6fe4..887023f783 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,30 +1,30 @@ --- a/net/minecraft/client/renderer/entity/layers/ElytraLayer.java +++ b/net/minecraft/client/renderer/entity/layers/ElytraLayer.java -@@ -30,7 +_,7 @@ +@@ -33,7 +_,7 @@ - public void func_225628_a_(MatrixStack p_225628_1_, IRenderTypeBuffer p_225628_2_, int p_225628_3_, T p_225628_4_, float p_225628_5_, float p_225628_6_, float p_225628_7_, float p_225628_8_, float p_225628_9_, float p_225628_10_) { - ItemStack itemstack = p_225628_4_.func_184582_a(EquipmentSlotType.CHEST); -- if (itemstack.func_77973_b() == Items.field_185160_cR) { -+ if (shouldRender(itemstack, p_225628_4_)) { + 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); +- if (itemstack.m_150930_(Items.f_42741_)) { ++ if (shouldRender(itemstack, p_116954_)) { ResourceLocation resourcelocation; - if (p_225628_4_ instanceof AbstractClientPlayerEntity) { - AbstractClientPlayerEntity abstractclientplayerentity = (AbstractClientPlayerEntity)p_225628_4_; -@@ -39,10 +_,10 @@ - } else if (abstractclientplayerentity.func_152122_n() && abstractclientplayerentity.func_110303_q() != null && abstractclientplayerentity.func_175148_a(PlayerModelPart.CAPE)) { - resourcelocation = abstractclientplayerentity.func_110303_q(); + 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_(); } else { -- resourcelocation = field_188355_a; -+ resourcelocation = getElytraTexture(itemstack, p_225628_4_); +- resourcelocation = f_116934_; ++ resourcelocation = getElytraTexture(itemstack, p_116954_); } } else { -- resourcelocation = field_188355_a; -+ resourcelocation = getElytraTexture(itemstack, p_225628_4_); +- resourcelocation = f_116934_; ++ resourcelocation = getElytraTexture(itemstack, p_116954_); } - p_225628_1_.func_227860_a_(); -@@ -53,5 +_,30 @@ - this.field_188357_c.func_225598_a_(p_225628_1_, ivertexbuilder, p_225628_3_, OverlayTexture.field_229196_a_, 1.0F, 1.0F, 1.0F, 1.0F); - p_225628_1_.func_227865_b_(); + p_116951_.m_85836_(); +@@ -56,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_(); } + } + @@ -38,7 +38,7 @@ + * @return If the ElytraLayer should render. + */ + public boolean shouldRender(ItemStack stack, T entity) { -+ return stack.func_77973_b() == Items.field_185160_cR; ++ return stack.m_41720_() == Items.f_42741_; + } + + /** @@ -50,6 +50,6 @@ + * @return The texture. + */ + public ResourceLocation getElytraTexture(ItemStack stack, T entity) { -+ return field_188355_a; ++ return f_116934_; } } 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 new file mode 100644 index 0000000000..d6f144a888 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/entity/layers/HumanoidArmorLayer.java.patch @@ -0,0 +1,91 @@ +--- a/net/minecraft/client/renderer/entity/layers/HumanoidArmorLayer.java ++++ b/net/minecraft/client/renderer/entity/layers/HumanoidArmorLayer.java +@@ -44,19 +_,20 @@ + if (itemstack.m_41720_() instanceof ArmorItem) { + ArmorItem armoritem = (ArmorItem)itemstack.m_41720_(); + if (armoritem.m_40402_() == p_117122_) { ++ p_117124_ = getArmorModelHook(p_117121_, itemstack, p_117122_, p_117124_); + this.m_117386_().m_102872_(p_117124_); + this.m_117125_(p_117124_, p_117122_); + boolean flag = this.m_117128_(p_117122_); + boolean flag1 = itemstack.m_41790_(); +- if (armoritem instanceof DyeableArmorItem) { +- int i = ((DyeableArmorItem)armoritem).m_41121_(itemstack); ++ if (armoritem instanceof net.minecraft.world.item.DyeableLeatherItem) { ++ int i = ((net.minecraft.world.item.DyeableLeatherItem)armoritem).m_41121_(itemstack); + float f = (float)(i >> 16 & 255) / 255.0F; + float f1 = (float)(i >> 8 & 255) / 255.0F; + float f2 = (float)(i & 255) / 255.0F; +- this.m_117106_(p_117119_, p_117120_, p_117123_, armoritem, flag1, p_117124_, flag, f, f1, f2, (String)null); +- this.m_117106_(p_117119_, p_117120_, p_117123_, armoritem, flag1, p_117124_, flag, 1.0F, 1.0F, 1.0F, "overlay"); ++ this.renderModel(p_117119_, p_117120_, p_117123_, flag1, p_117124_, f, f1, f2, this.getArmorResource(p_117121_, itemstack, p_117122_, null)); ++ this.renderModel(p_117119_, p_117120_, p_117123_, flag1, p_117124_, 1.0F, 1.0F, 1.0F, this.getArmorResource(p_117121_, itemstack, p_117122_, "overlay")); + } else { +- this.m_117106_(p_117119_, p_117120_, p_117123_, armoritem, flag1, p_117124_, flag, 1.0F, 1.0F, 1.0F, (String)null); ++ this.renderModel(p_117119_, p_117120_, p_117123_, flag1, p_117124_, 1.0F, 1.0F, 1.0F, this.getArmorResource(p_117121_, itemstack, p_117122_, null)); + } + + } +@@ -88,7 +_,10 @@ + } + + private void m_117106_(PoseStack p_117107_, MultiBufferSource p_117108_, int p_117109_, ArmorItem p_117110_, boolean p_117111_, A p_117112_, boolean p_117113_, float p_117114_, float p_117115_, float p_117116_, @Nullable String p_117117_) { +- VertexConsumer vertexconsumer = ItemRenderer.m_115184_(p_117108_, RenderType.m_110431_(this.m_117080_(p_117110_, p_117113_, p_117117_)), false, p_117111_); ++ renderModel(p_117107_, p_117108_, p_117109_, p_117111_, p_117112_, p_117114_, p_117115_, p_117116_, this.m_117080_(p_117110_, p_117113_, p_117117_)); ++ } ++ private void renderModel(PoseStack p_117107_, MultiBufferSource p_117108_, int p_117109_, boolean p_117111_, A p_117112_, float p_117114_, float p_117115_, float p_117116_, ResourceLocation armorResource) { ++ VertexConsumer vertexconsumer = ItemRenderer.m_115184_(p_117108_, RenderType.m_110431_(armorResource), false, p_117111_); + p_117112_.m_7695_(p_117107_, vertexconsumer, p_117109_, OverlayTexture.f_118083_, p_117114_, p_117115_, p_117116_, 1.0F); + } + +@@ -100,8 +_,50 @@ + return p_117129_ == EquipmentSlot.LEGS; + } + ++ @Deprecated //Use the more sensitive version getArmorResource below + private ResourceLocation m_117080_(ArmorItem p_117081_, boolean p_117082_, @Nullable String p_117083_) { + String s = "textures/models/armor/" + p_117081_.m_40401_().m_6082_() + "_layer_" + (p_117082_ ? 2 : 1) + (p_117083_ == null ? "" : "_" + p_117083_) + ".png"; + return f_117070_.computeIfAbsent(s, ResourceLocation::new); + } ++ ++ /*=================================== FORGE START =========================================*/ ++ ++ /** ++ * Hook to allow item-sensitive armor model. for LayerBipedArmor. ++ */ ++ protected A getArmorModelHook(T entity, ItemStack itemStack, EquipmentSlot slot, A model) { ++ return net.minecraftforge.client.ForgeHooksClient.getArmorModel(entity, itemStack, slot, model); ++ } ++ ++ /** ++ * More generic ForgeHook version of the above function, it allows for Items to have more control over what texture they provide. ++ * ++ * @param entity Entity wearing the armor ++ * @param stack ItemStack for the armor ++ * @param slot Slot ID that the item is in ++ * @param type Subtype, can be null or "overlay" ++ * @return ResourceLocation pointing at the armor's texture ++ */ ++ public ResourceLocation getArmorResource(net.minecraft.world.entity.Entity entity, ItemStack stack, EquipmentSlot slot, @Nullable String type) { ++ ArmorItem item = (ArmorItem)stack.m_41720_(); ++ String texture = item.m_40401_().m_6082_(); ++ String domain = "minecraft"; ++ int idx = texture.indexOf(':'); ++ if (idx != -1) { ++ domain = texture.substring(0, idx); ++ texture = texture.substring(idx + 1); ++ } ++ String s1 = String.format("%s:textures/models/armor/%s_layer_%d%s.png", domain, texture, (m_117128_(slot) ? 2 : 1), type == null ? "" : String.format("_%s", type)); ++ ++ s1 = net.minecraftforge.client.ForgeHooksClient.getArmorTexture(entity, stack, s1, slot, type); ++ ResourceLocation resourcelocation = f_117070_.get(s1); ++ ++ if (resourcelocation == null) { ++ resourcelocation = new ResourceLocation(s1); ++ f_117070_.put(s1, resourcelocation); ++ } ++ ++ return resourcelocation; ++ } ++ /*=================================== FORGE END ===========================================*/ + } 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 new file mode 100644 index 0000000000..c8cc516b9e --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/entity/player/PlayerRenderer.java.patch @@ -0,0 +1,12 @@ +--- a/net/minecraft/client/renderer/entity/player/PlayerRenderer.java ++++ b/net/minecraft/client/renderer/entity/player/PlayerRenderer.java +@@ -58,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_); ++ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderPlayerEvent.Pre(p_117788_, this, p_117790_, p_117791_, p_117792_, p_117793_))) return; + super.m_7392_(p_117788_, p_117789_, p_117790_, p_117791_, p_117792_, p_117793_); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderPlayerEvent.Post(p_117788_, this, p_117790_, p_117791_, p_117792_, p_117793_)); + } + + public Vec3 m_7860_(AbstractClientPlayer p_117785_, float p_117786_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/item/ItemProperties.java.patch b/patches/minecraft/net/minecraft/client/renderer/item/ItemProperties.java.patch new file mode 100644 index 0000000000..d84c628aa6 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/item/ItemProperties.java.patch @@ -0,0 +1,115 @@ +--- a/net/minecraft/client/renderer/item/ItemProperties.java ++++ b/net/minecraft/client/renderer/item/ItemProperties.java +@@ -47,7 +_,7 @@ + }; + private static final Map> f_117825_ = Maps.newHashMap(); + +- private static ClampedItemPropertyFunction m_174581_(ResourceLocation p_174582_, ClampedItemPropertyFunction p_174583_) { ++ public static ItemPropertyFunction registerGeneric(ResourceLocation p_174582_, ItemPropertyFunction p_174583_) { + f_117820_.put(p_174582_, p_174583_); + return p_174583_; + } +@@ -56,7 +_,7 @@ + f_117820_.put(new ResourceLocation("custom_model_data"), p_174580_); + } + +- private static void m_174570_(Item p_174571_, ResourceLocation p_174572_, ClampedItemPropertyFunction p_174573_) { ++ public static void register(Item p_174571_, ResourceLocation p_174572_, ItemPropertyFunction p_174573_) { + f_117825_.computeIfAbsent(p_174571_, (p_117828_) -> { + return Maps.newHashMap(); + }).put(p_174572_, p_174573_); +@@ -84,29 +_,29 @@ + } + + static { +- m_174581_(new ResourceLocation("lefthanded"), (p_174650_, p_174651_, p_174652_, p_174653_) -> { ++ registerGeneric(new ResourceLocation("lefthanded"), (p_174650_, p_174651_, p_174652_, p_174653_) -> { + return p_174652_ != null && p_174652_.m_5737_() != HumanoidArm.RIGHT ? 1.0F : 0.0F; + }); +- m_174581_(new ResourceLocation("cooldown"), (p_174645_, p_174646_, p_174647_, p_174648_) -> { ++ registerGeneric(new ResourceLocation("cooldown"), (p_174645_, p_174646_, p_174647_, p_174648_) -> { + return p_174647_ instanceof Player ? ((Player)p_174647_).m_36335_().m_41521_(p_174645_.m_41720_(), 0.0F) : 0.0F; + }); + m_174579_((p_174640_, p_174641_, p_174642_, p_174643_) -> { + return p_174640_.m_41782_() ? (float)p_174640_.m_41783_().m_128451_("CustomModelData") : 0.0F; + }); +- m_174570_(Items.f_42411_, new ResourceLocation("pull"), (p_174635_, p_174636_, p_174637_, p_174638_) -> { ++ register(Items.f_42411_, new ResourceLocation("pull"), (p_174635_, p_174636_, p_174637_, p_174638_) -> { + if (p_174637_ == null) { + return 0.0F; + } else { + return p_174637_.m_21211_() != p_174635_ ? 0.0F : (float)(p_174635_.m_41779_() - p_174637_.m_21212_()) / 20.0F; + } + }); +- m_174570_(Items.f_42411_, new ResourceLocation("pulling"), (p_174630_, p_174631_, p_174632_, p_174633_) -> { ++ register(Items.f_42411_, new ResourceLocation("pulling"), (p_174630_, p_174631_, p_174632_, p_174633_) -> { + return p_174632_ != null && p_174632_.m_6117_() && p_174632_.m_21211_() == p_174630_ ? 1.0F : 0.0F; + }); +- m_174570_(Items.f_151058_, new ResourceLocation("filled"), (p_174625_, p_174626_, p_174627_, p_174628_) -> { ++ register(Items.f_151058_, new ResourceLocation("filled"), (p_174625_, p_174626_, p_174627_, p_174628_) -> { + return BundleItem.m_150766_(p_174625_); + }); +- m_174570_(Items.f_42524_, new ResourceLocation("time"), new ClampedItemPropertyFunction() { ++ register(Items.f_42524_, new ResourceLocation("time"), new ClampedItemPropertyFunction() { + private double f_117899_; + private double f_117900_; + private long f_117901_; +@@ -149,7 +_,7 @@ + return this.f_117899_; + } + }); +- m_174570_(Items.f_42522_, new ResourceLocation("angle"), new ClampedItemPropertyFunction() { ++ register(Items.f_42522_, new ResourceLocation("angle"), new ClampedItemPropertyFunction() { + private final ItemProperties.CompassWobble f_117910_ = new ItemProperties.CompassWobble(); + private final ItemProperties.CompassWobble f_117911_ = new ItemProperties.CompassWobble(); + +@@ -235,26 +_,26 @@ + return Math.atan2(p_117919_.m_7094_() - p_117920_.m_20189_(), p_117919_.m_7096_() - p_117920_.m_20185_()); + } + }); +- m_174570_(Items.f_42717_, new ResourceLocation("pull"), (p_174620_, p_174621_, p_174622_, p_174623_) -> { ++ register(Items.f_42717_, new ResourceLocation("pull"), (p_174620_, p_174621_, p_174622_, p_174623_) -> { + if (p_174622_ == null) { + return 0.0F; + } else { + return CrossbowItem.m_40932_(p_174620_) ? 0.0F : (float)(p_174620_.m_41779_() - p_174622_.m_21212_()) / (float)CrossbowItem.m_40939_(p_174620_); + } + }); +- m_174570_(Items.f_42717_, new ResourceLocation("pulling"), (p_174615_, p_174616_, p_174617_, p_174618_) -> { ++ register(Items.f_42717_, new ResourceLocation("pulling"), (p_174615_, p_174616_, p_174617_, p_174618_) -> { + return p_174617_ != null && p_174617_.m_6117_() && p_174617_.m_21211_() == p_174615_ && !CrossbowItem.m_40932_(p_174615_) ? 1.0F : 0.0F; + }); +- m_174570_(Items.f_42717_, new ResourceLocation("charged"), (p_174610_, p_174611_, p_174612_, p_174613_) -> { ++ register(Items.f_42717_, new ResourceLocation("charged"), (p_174610_, p_174611_, p_174612_, p_174613_) -> { + return p_174612_ != null && CrossbowItem.m_40932_(p_174610_) ? 1.0F : 0.0F; + }); +- m_174570_(Items.f_42717_, new ResourceLocation("firework"), (p_174605_, p_174606_, p_174607_, p_174608_) -> { ++ register(Items.f_42717_, new ResourceLocation("firework"), (p_174605_, p_174606_, p_174607_, p_174608_) -> { + return p_174607_ != null && CrossbowItem.m_40932_(p_174605_) && CrossbowItem.m_40871_(p_174605_, Items.f_42688_) ? 1.0F : 0.0F; + }); +- m_174570_(Items.f_42741_, new ResourceLocation("broken"), (p_174600_, p_174601_, p_174602_, p_174603_) -> { ++ register(Items.f_42741_, new ResourceLocation("broken"), (p_174600_, p_174601_, p_174602_, p_174603_) -> { + return ElytraItem.m_41140_(p_174600_) ? 0.0F : 1.0F; + }); +- m_174570_(Items.f_42523_, new ResourceLocation("cast"), (p_174595_, p_174596_, p_174597_, p_174598_) -> { ++ register(Items.f_42523_, new ResourceLocation("cast"), (p_174595_, p_174596_, p_174597_, p_174598_) -> { + if (p_174597_ == null) { + return 0.0F; + } else { +@@ -267,13 +_,13 @@ + return (flag || flag1) && p_174597_ instanceof Player && ((Player)p_174597_).f_36083_ != null ? 1.0F : 0.0F; + } + }); +- m_174570_(Items.f_42740_, new ResourceLocation("blocking"), (p_174590_, p_174591_, p_174592_, p_174593_) -> { ++ register(Items.f_42740_, new ResourceLocation("blocking"), (p_174590_, p_174591_, p_174592_, p_174593_) -> { + return p_174592_ != null && p_174592_.m_6117_() && p_174592_.m_21211_() == p_174590_ ? 1.0F : 0.0F; + }); +- m_174570_(Items.f_42713_, new ResourceLocation("throwing"), (p_174585_, p_174586_, p_174587_, p_174588_) -> { ++ register(Items.f_42713_, new ResourceLocation("throwing"), (p_174585_, p_174586_, p_174587_, p_174588_) -> { + return p_174587_ != null && p_174587_.m_6117_() && p_174587_.m_21211_() == p_174585_ ? 1.0F : 0.0F; + }); +- m_174570_(Items.f_151033_, new ResourceLocation("level"), (p_174575_, p_174576_, p_174577_, p_174578_) -> { ++ register(Items.f_151033_, new ResourceLocation("level"), (p_174575_, p_174576_, p_174577_, p_174578_) -> { + CompoundTag compoundtag = p_174575_.m_41737_("BlockStateTag"); + + try { diff --git a/patches/minecraft/net/minecraft/client/renderer/model/BakedQuad.java.patch b/patches/minecraft/net/minecraft/client/renderer/model/BakedQuad.java.patch deleted file mode 100644 index 73808c286e..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/model/BakedQuad.java.patch +++ /dev/null @@ -1,27 +0,0 @@ ---- a/net/minecraft/client/renderer/model/BakedQuad.java -+++ b/net/minecraft/client/renderer/model/BakedQuad.java -@@ -6,7 +_,7 @@ - import net.minecraftforge.api.distmarker.OnlyIn; - - @OnlyIn(Dist.CLIENT) --public class BakedQuad { -+public class BakedQuad implements net.minecraftforge.client.model.pipeline.IVertexProducer { - protected final int[] field_178215_a; - protected final int field_178213_b; - protected final Direction field_178214_c; -@@ -35,6 +_,15 @@ - - public Direction func_178210_d() { - return this.field_178214_c; -+ } -+ -+ @Override -+ public void pipe(net.minecraftforge.client.model.pipeline.IVertexConsumer consumer) { -+ net.minecraftforge.client.model.pipeline.LightUtil.putBakedQuad(consumer, this); -+ } -+ -+ public TextureAtlasSprite func_187508_a() { -+ return field_187509_d; - } - - public boolean func_239287_f_() { diff --git a/patches/minecraft/net/minecraft/client/renderer/model/BlockModel.java.patch b/patches/minecraft/net/minecraft/client/renderer/model/BlockModel.java.patch deleted file mode 100644 index 465ebe3db4..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/model/BlockModel.java.patch +++ /dev/null @@ -1,88 +0,0 @@ ---- a/net/minecraft/client/renderer/model/BlockModel.java -+++ b/net/minecraft/client/renderer/model/BlockModel.java -@@ -57,9 +_,10 @@ - public BlockModel field_178315_d; - @Nullable - protected ResourceLocation field_178316_e; -+ public final net.minecraftforge.client.model.BlockModelConfiguration customData = new net.minecraftforge.client.model.BlockModelConfiguration(this); - - public static BlockModel func_178307_a(Reader p_178307_0_) { -- return JSONUtils.func_193839_a(field_178319_a, p_178307_0_, BlockModel.class); -+ return JSONUtils.func_193839_a(net.minecraftforge.client.model.ModelLoaderRegistry.ExpandedBlockModelDeserializer.INSTANCE, p_178307_0_, BlockModel.class); - } - - public static BlockModel func_178294_a(String p_178294_0_) { -@@ -76,10 +_,15 @@ - this.field_187968_k = p_i230056_7_; - } - -+ @Deprecated - public List func_178298_a() { -+ if (customData.hasCustomGeometry()) return java.util.Collections.emptyList(); - return this.field_178314_g.isEmpty() && this.field_178315_d != null ? this.field_178315_d.func_178298_a() : this.field_178314_g; - } - -+ @Nullable -+ public ResourceLocation getParentLocation() { return field_178316_e; } -+ - public boolean func_178309_b() { - return this.field_178315_d != null ? this.field_178315_d.func_178309_b() : this.field_178322_i; - } -@@ -100,6 +_,10 @@ - return this.field_187968_k.isEmpty() ? ItemOverrideList.field_188022_a : new ItemOverrideList(p_217646_1_, p_217646_2_, p_217646_1_::func_209597_a, this.field_187968_k); - } - -+ public ItemOverrideList getOverrides(ModelBakery p_217646_1_, BlockModel p_217646_2_, Function textureGetter) { -+ return this.field_187968_k.isEmpty() ? ItemOverrideList.field_188022_a : new ItemOverrideList(p_217646_1_, p_217646_2_, p_217646_1_::func_209597_a, textureGetter, this.field_187968_k); -+ } -+ - public Collection func_187965_e() { - Set set = Sets.newHashSet(); - -@@ -143,6 +_,9 @@ - - Set set1 = Sets.newHashSet(this.func_228816_c_("particle")); - -+ if(customData.hasCustomGeometry()) -+ set1.addAll(customData.getTextureDependencies(p_225614_1_, p_225614_2_)); -+ else - for(BlockPart blockpart : this.func_178298_a()) { - for(BlockPartFace blockpartface : blockpart.field_178240_c.values()) { - RenderMaterial rendermaterial = this.func_228816_c_(blockpartface.field_178242_d); -@@ -169,11 +_,17 @@ - return set1; - } - -+ @Deprecated //Forge: Use Boolean variant - public IBakedModel func_225613_a_(ModelBakery p_225613_1_, Function p_225613_2_, IModelTransform p_225613_3_, ResourceLocation p_225613_4_) { - return this.func_228813_a_(p_225613_1_, this, p_225613_2_, p_225613_3_, p_225613_4_, true); - } - - public IBakedModel func_228813_a_(ModelBakery p_228813_1_, BlockModel p_228813_2_, Function p_228813_3_, IModelTransform p_228813_4_, ResourceLocation p_228813_5_, boolean p_228813_6_) { -+ return net.minecraftforge.client.model.ModelLoaderRegistry.bakeHelper(this, p_228813_1_, p_228813_2_, p_228813_3_, p_228813_4_, p_228813_5_, p_228813_6_); -+ } -+ -+ @Deprecated //Forge: exposed for our callbacks only. Use the above function. -+ public IBakedModel bakeVanilla(ModelBakery p_228813_1_, BlockModel p_228813_2_, Function p_228813_3_, IModelTransform p_228813_4_, ResourceLocation p_228813_5_, boolean p_228813_6_) { - TextureAtlasSprite textureatlassprite = p_228813_3_.apply(this.func_228816_c_("particle")); - if (this.func_178310_f() == ModelBakery.field_177616_r) { - return new BuiltInModel(this.func_181682_g(), this.func_217646_a(p_228813_1_, p_228813_2_), textureatlassprite, this.func_230176_c_().func_230178_a_()); -@@ -200,6 +_,10 @@ - return field_217647_g.func_228824_a_(p_228812_0_.field_178241_a, p_228812_0_.field_178239_b, p_228812_1_, p_228812_2_, p_228812_3_, p_228812_4_, p_228812_0_.field_178237_d, p_228812_0_.field_178238_e, p_228812_5_); - } - -+ public static BakedQuad makeBakedQuad(BlockPart p_228812_0_, BlockPartFace p_228812_1_, TextureAtlasSprite p_228812_2_, Direction p_228812_3_, IModelTransform p_228812_4_, ResourceLocation p_228812_5_) { -+ return func_228812_a_(p_228812_0_, p_228812_1_, p_228812_2_, p_228812_3_, p_228812_4_, p_228812_5_); -+ } -+ - public boolean func_178300_b(String p_178300_1_) { - return !MissingTextureSprite.func_195675_b().equals(this.func_228816_c_(p_178300_1_).func_229313_b_()); - } -@@ -373,5 +_,7 @@ - public boolean func_230178_a_() { - return this == SIDE; - } -+ -+ public String getSerializedName() { return field_230177_c_; } - } - } diff --git a/patches/minecraft/net/minecraft/client/renderer/model/FaceBakery.java.patch b/patches/minecraft/net/minecraft/client/renderer/model/FaceBakery.java.patch deleted file mode 100644 index e6e25e1e64..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/model/FaceBakery.java.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- a/net/minecraft/client/renderer/model/FaceBakery.java -+++ b/net/minecraft/client/renderer/model/FaceBakery.java -@@ -43,6 +_,7 @@ - this.func_178408_a(aint, direction); - } - -+ net.minecraftforge.client.ForgeHooksClient.fillNormal(aint, direction); - return new BakedQuad(aint, p_228824_3_.field_178245_c, direction, p_228824_4_, p_228824_8_); - } - -@@ -125,8 +_,8 @@ - p_239288_1_[i + 1] = Float.floatToRawIntBits(p_239288_3_.func_195900_b()); - p_239288_1_[i + 2] = Float.floatToRawIntBits(p_239288_3_.func_195902_c()); - p_239288_1_[i + 3] = -1; -- p_239288_1_[i + 4] = Float.floatToRawIntBits(p_239288_4_.func_94214_a((double)p_239288_5_.func_178348_a(p_239288_2_))); -- p_239288_1_[i + 4 + 1] = Float.floatToRawIntBits(p_239288_4_.func_94207_b((double)p_239288_5_.func_178346_b(p_239288_2_))); -+ p_239288_1_[i + 4] = Float.floatToRawIntBits(p_239288_4_.func_94214_a((double)p_239288_5_.func_178348_a(p_239288_2_) * .999 + p_239288_5_.func_178348_a((p_239288_2_ + 2) % 4) * .001)); -+ p_239288_1_[i + 4 + 1] = Float.floatToRawIntBits(p_239288_4_.func_94207_b((double)p_239288_5_.func_178346_b(p_239288_2_) * .999 + p_239288_5_.func_178346_b((p_239288_2_ + 2) % 4) * .001)); - } - - private void func_199336_a(Vector3f p_199336_1_, @Nullable BlockPartRotation p_199336_2_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/model/IBakedModel.java.patch b/patches/minecraft/net/minecraft/client/renderer/model/IBakedModel.java.patch deleted file mode 100644 index cbc0270cfb..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/model/IBakedModel.java.patch +++ /dev/null @@ -1,28 +0,0 @@ ---- a/net/minecraft/client/renderer/model/IBakedModel.java -+++ b/net/minecraft/client/renderer/model/IBakedModel.java -@@ -10,7 +_,9 @@ - import net.minecraftforge.api.distmarker.OnlyIn; - - @OnlyIn(Dist.CLIENT) --public interface IBakedModel { -+public interface IBakedModel extends net.minecraftforge.client.extensions.IForgeBakedModel { -+ /**@deprecated Forge: Use {@link net.minecraftforge.client.extensions.IForgeBakedModel#getQuads(IBlockState, EnumFacing, Random, net.minecraftforge.client.model.data.IModelData)}*/ -+ @Deprecated - List func_200117_a(@Nullable BlockState p_200117_1_, @Nullable Direction p_200117_2_, Random p_200117_3_); - - boolean func_177555_b(); -@@ -21,9 +_,13 @@ - - boolean func_188618_c(); - -+ /**@deprecated Forge: Use {@link net.minecraftforge.client.extensions.IForgeBakedModel#getParticleTexture(net.minecraftforge.client.model.data.IModelData)}*/ -+ @Deprecated - TextureAtlasSprite func_177554_e(); - -- ItemCameraTransforms func_177552_f(); -+ /**@deprecated Forge: Use {@link net.minecraftforge.client.extensions.IForgeBakedModel#handlePerspective(net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType, com.mojang.blaze3d.matrix.MatrixStack)} instead */ -+ @Deprecated -+ default ItemCameraTransforms func_177552_f() { return ItemCameraTransforms.field_178357_a; } - - ItemOverrideList func_188617_f(); - } diff --git a/patches/minecraft/net/minecraft/client/renderer/model/IModelTransform.java.patch b/patches/minecraft/net/minecraft/client/renderer/model/IModelTransform.java.patch deleted file mode 100644 index 8c3dcd2da4..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/model/IModelTransform.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/renderer/model/IModelTransform.java -+++ b/net/minecraft/client/renderer/model/IModelTransform.java -@@ -5,7 +_,7 @@ - import net.minecraftforge.api.distmarker.OnlyIn; - - @OnlyIn(Dist.CLIENT) --public interface IModelTransform { -+public interface IModelTransform extends net.minecraftforge.client.extensions.IForgeModelTransform { - default TransformationMatrix func_225615_b_() { - return TransformationMatrix.func_227983_a_(); - } diff --git a/patches/minecraft/net/minecraft/client/renderer/model/IUnbakedModel.java.patch b/patches/minecraft/net/minecraft/client/renderer/model/IUnbakedModel.java.patch deleted file mode 100644 index 3cfed35858..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/model/IUnbakedModel.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/renderer/model/IUnbakedModel.java -+++ b/net/minecraft/client/renderer/model/IUnbakedModel.java -@@ -11,7 +_,7 @@ - import net.minecraftforge.api.distmarker.OnlyIn; - - @OnlyIn(Dist.CLIENT) --public interface IUnbakedModel { -+public interface IUnbakedModel extends net.minecraftforge.client.extensions.IForgeUnbakedModel { - Collection func_187965_e(); - - Collection func_225614_a_(Function p_225614_1_, Set> p_225614_2_); diff --git a/patches/minecraft/net/minecraft/client/renderer/model/ItemCameraTransforms.java.patch b/patches/minecraft/net/minecraft/client/renderer/model/ItemCameraTransforms.java.patch deleted file mode 100644 index 31063f7cc9..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/model/ItemCameraTransforms.java.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- a/net/minecraft/client/renderer/model/ItemCameraTransforms.java -+++ b/net/minecraft/client/renderer/model/ItemCameraTransforms.java -@@ -25,6 +_,7 @@ - this(ItemTransformVec3f.field_178366_a, ItemTransformVec3f.field_178366_a, ItemTransformVec3f.field_178366_a, ItemTransformVec3f.field_178366_a, ItemTransformVec3f.field_178366_a, ItemTransformVec3f.field_178366_a, ItemTransformVec3f.field_178366_a, ItemTransformVec3f.field_178366_a); - } - -+ @Deprecated - public ItemCameraTransforms(ItemCameraTransforms p_i46443_1_) { - this.field_188036_k = p_i46443_1_.field_188036_k; - this.field_188037_l = p_i46443_1_.field_188037_l; -@@ -36,6 +_,7 @@ - this.field_181700_p = p_i46443_1_.field_181700_p; - } - -+ @Deprecated - public ItemCameraTransforms(ItemTransformVec3f p_i46569_1_, ItemTransformVec3f p_i46569_2_, ItemTransformVec3f p_i46569_3_, ItemTransformVec3f p_i46569_4_, ItemTransformVec3f p_i46569_5_, ItemTransformVec3f p_i46569_6_, ItemTransformVec3f p_i46569_7_, ItemTransformVec3f p_i46569_8_) { - this.field_188036_k = p_i46569_1_; - this.field_188037_l = p_i46569_2_; -@@ -47,6 +_,7 @@ - this.field_181700_p = p_i46569_8_; - } - -+ @Deprecated - public ItemTransformVec3f func_181688_b(ItemCameraTransforms.TransformType p_181688_1_) { - switch(p_181688_1_) { - case THIRD_PERSON_LEFT_HAND: diff --git a/patches/minecraft/net/minecraft/client/renderer/model/ItemModelGenerator.java.patch b/patches/minecraft/net/minecraft/client/renderer/model/ItemModelGenerator.java.patch deleted file mode 100644 index 6eb5bfd1ab..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/model/ItemModelGenerator.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/client/renderer/model/ItemModelGenerator.java -+++ b/net/minecraft/client/renderer/model/ItemModelGenerator.java -@@ -36,6 +_,7 @@ - map.put("particle", p_209579_2_.func_178300_b("particle") ? Either.left(p_209579_2_.func_228816_c_("particle")) : map.get("layer0")); - BlockModel blockmodel = new BlockModel((ResourceLocation)null, list, map, false, p_209579_2_.func_230176_c_(), p_209579_2_.func_181682_g(), p_209579_2_.func_187966_f()); - blockmodel.field_178317_b = p_209579_2_.field_178317_b; -+ blockmodel.customData.copyFrom(p_209579_2_.customData); - return blockmodel; - } - diff --git a/patches/minecraft/net/minecraft/client/renderer/model/ItemOverrideList.java.patch b/patches/minecraft/net/minecraft/client/renderer/model/ItemOverrideList.java.patch deleted file mode 100644 index 61cc49b6ac..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/model/ItemOverrideList.java.patch +++ /dev/null @@ -1,28 +0,0 @@ ---- a/net/minecraft/client/renderer/model/ItemOverrideList.java -+++ b/net/minecraft/client/renderer/model/ItemOverrideList.java -@@ -24,10 +_,14 @@ - this.field_209582_c = Collections.emptyList(); - } - -+ @Deprecated //Forge: Use IUnbakedModel, add texture getter - public ItemOverrideList(ModelBakery p_i50984_1_, BlockModel p_i50984_2_, Function p_i50984_3_, List p_i50984_4_) { -+ this(p_i50984_1_, (IUnbakedModel)p_i50984_2_, p_i50984_3_, p_i50984_1_.getSpriteMap()::func_229151_a_, p_i50984_4_); -+ } -+ public ItemOverrideList(ModelBakery p_i50984_1_, IUnbakedModel p_i50984_2_, Function p_i50984_3_, Function textureGetter, List p_i50984_4_) { - this.field_209582_c = p_i50984_4_.stream().map((p_217649_3_) -> { - IUnbakedModel iunbakedmodel = p_i50984_3_.apply(p_217649_3_.func_188026_a()); -- return Objects.equals(iunbakedmodel, p_i50984_2_) ? null : p_i50984_1_.func_217845_a(p_217649_3_.func_188026_a(), ModelRotation.X0_Y0); -+ return Objects.equals(iunbakedmodel, p_i50984_2_) ? null : p_i50984_1_.getBakedModel(p_217649_3_.func_188026_a(), ModelRotation.X0_Y0, textureGetter); - }).collect(Collectors.toList()); - Collections.reverse(this.field_209582_c); - -@@ -54,5 +_,9 @@ - } - - return p_239290_1_; -+ } -+ -+ public com.google.common.collect.ImmutableList getOverrides() { -+ return com.google.common.collect.ImmutableList.copyOf(field_188023_b); - } - } diff --git a/patches/minecraft/net/minecraft/client/renderer/model/ItemTransformVec3f.java.patch b/patches/minecraft/net/minecraft/client/renderer/model/ItemTransformVec3f.java.patch deleted file mode 100644 index f6822bc383..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/model/ItemTransformVec3f.java.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/net/minecraft/client/renderer/model/ItemTransformVec3f.java -+++ b/net/minecraft/client/renderer/model/ItemTransformVec3f.java -@@ -14,7 +_,11 @@ - import net.minecraftforge.api.distmarker.Dist; - import net.minecraftforge.api.distmarker.OnlyIn; - -+/** -+ * @deprecated use {@link net.minecraft.util.math.vector.TransformationMatrix} through {@link net.minecraftforge.client.extensions.IForgeBakedModel#handlePerspective} -+ */ - @OnlyIn(Dist.CLIENT) -+@Deprecated - public class ItemTransformVec3f { - public static final ItemTransformVec3f field_178366_a = new ItemTransformVec3f(new Vector3f(), new Vector3f(), new Vector3f(1.0F, 1.0F, 1.0F)); - public final Vector3f field_178364_b; diff --git a/patches/minecraft/net/minecraft/client/renderer/model/ModelBakery.java.patch b/patches/minecraft/net/minecraft/client/renderer/model/ModelBakery.java.patch deleted file mode 100644 index 461a14cdce..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/model/ModelBakery.java.patch +++ /dev/null @@ -1,107 +0,0 @@ ---- a/net/minecraft/client/renderer/model/ModelBakery.java -+++ b/net/minecraft/client/renderer/model/ModelBakery.java -@@ -146,8 +_,17 @@ - }); - - public ModelBakery(IResourceManager p_i226056_1_, BlockColors p_i226056_2_, IProfiler p_i226056_3_, int p_i226056_4_) { -+ this(p_i226056_1_, p_i226056_2_, true); -+ processLoading(p_i226056_3_, p_i226056_4_); -+ } -+ -+ protected ModelBakery(IResourceManager p_i226056_1_, BlockColors p_i226056_2_, boolean vanillaBakery) { - this.field_177598_f = p_i226056_1_; - this.field_225365_D = p_i226056_2_; -+ } -+ -+ protected void processLoading(IProfiler p_i226056_3_, int p_i226056_4_) { -+ net.minecraftforge.client.model.ModelLoaderRegistry.onModelLoadingStart(); - p_i226056_3_.func_76320_a("missing_model"); - - try { -@@ -180,12 +_,16 @@ - - p_i226056_3_.func_219895_b("special"); - this.func_217843_a(new ModelResourceLocation("minecraft:trident_in_hand#inventory")); -+ for (ResourceLocation rl : getSpecialModels()) { -+ addModelToCache(rl); -+ } - p_i226056_3_.func_219895_b("textures"); - Set> set = Sets.newLinkedHashSet(); - Set set1 = this.field_217851_H.values().stream().flatMap((p_229342_2_) -> { - return p_229342_2_.func_225614_a_(this::func_209597_a, set).stream(); - }).collect(Collectors.toSet()); - set1.addAll(field_177602_b); -+ net.minecraftforge.client.ForgeHooksClient.gatherFluidTextures(set1); - set.stream().filter((p_229346_0_) -> { - return !p_229346_0_.getSecond().equals(field_229321_r_); - }).forEach((p_229330_0_) -> { -@@ -224,6 +_,7 @@ - try { - ibakedmodel = this.func_217845_a(p_229350_1_, ModelRotation.X0_Y0); - } catch (Exception exception) { -+ exception.printStackTrace(); - field_177603_c.warn("Unable to bake model: '{}': {}", p_229350_1_, exception); - } - -@@ -442,6 +_,13 @@ - this.field_217848_D.addAll(p_209593_2_.func_187965_e()); - } - -+ // Same as loadTopModel but without restricting to MRL's -+ private void addModelToCache(ResourceLocation p_217843_1_) { -+ IUnbakedModel iunbakedmodel = this.func_209597_a(p_217843_1_); -+ this.field_217849_F.put(p_217843_1_, iunbakedmodel); -+ this.field_217851_H.put(p_217843_1_, iunbakedmodel); -+ } -+ - private void func_217843_a(ModelResourceLocation p_217843_1_) { - IUnbakedModel iunbakedmodel = this.func_209597_a(p_217843_1_); - this.field_217849_F.put(p_217843_1_, iunbakedmodel); -@@ -456,7 +_,13 @@ - } - - @Nullable -+ @Deprecated - public IBakedModel func_217845_a(ResourceLocation p_217845_1_, IModelTransform p_217845_2_) { -+ return getBakedModel(p_217845_1_, p_217845_2_, this.field_229322_z_::func_229151_a_); -+ } -+ -+ @Nullable -+ public IBakedModel getBakedModel(ResourceLocation p_217845_1_, IModelTransform p_217845_2_, java.util.function.Function textureGetter) { - Triple triple = Triple.of(p_217845_1_, p_217845_2_.func_225615_b_(), p_217845_2_.func_188049_c()); - if (this.field_217850_G.containsKey(triple)) { - return this.field_217850_G.get(triple); -@@ -467,11 +_,11 @@ - if (iunbakedmodel instanceof BlockModel) { - BlockModel blockmodel = (BlockModel)iunbakedmodel; - if (blockmodel.func_178310_f() == field_177606_o) { -- return field_217854_z.func_209579_a(this.field_229322_z_::func_229151_a_, blockmodel).func_228813_a_(this, blockmodel, this.field_229322_z_::func_229151_a_, p_217845_2_, p_217845_1_, false); -+ return field_217854_z.func_209579_a(textureGetter, blockmodel).func_228813_a_(this, blockmodel, this.field_229322_z_::func_229151_a_, p_217845_2_, p_217845_1_, false); - } - } - -- IBakedModel ibakedmodel = iunbakedmodel.func_225613_a_(this, this.field_229322_z_::func_229151_a_, p_217845_2_, p_217845_1_); -+ IBakedModel ibakedmodel = iunbakedmodel.func_225613_a_(this, textureGetter, p_217845_2_, p_217845_1_); - this.field_217850_G.put(triple, ibakedmodel); - return ibakedmodel; - } -@@ -524,11 +_,19 @@ - return this.field_225367_M; - } - -+ public Set getSpecialModels() { -+ return java.util.Collections.emptySet(); -+ } -+ - @OnlyIn(Dist.CLIENT) - static class BlockStateDefinitionException extends RuntimeException { - public BlockStateDefinitionException(String p_i49526_1_) { - super(p_i49526_1_); - } -+ } -+ -+ public SpriteMap getSpriteMap() { -+ return this.field_229322_z_; - } - - @OnlyIn(Dist.CLIENT) diff --git a/patches/minecraft/net/minecraft/client/renderer/model/ModelManager.java.patch b/patches/minecraft/net/minecraft/client/renderer/model/ModelManager.java.patch deleted file mode 100644 index e7076f854c..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/model/ModelManager.java.patch +++ /dev/null @@ -1,59 +0,0 @@ ---- a/net/minecraft/client/renderer/model/ModelManager.java -+++ b/net/minecraft/client/renderer/model/ModelManager.java -@@ -19,7 +_,7 @@ - - @OnlyIn(Dist.CLIENT) - public class ModelManager extends ReloadListener implements AutoCloseable { -- private Map field_174958_a; -+ private Map field_174958_a = new java.util.HashMap<>(); - @Nullable - private SpriteMap field_229352_b_; - private final BlockModelShapes field_174957_c; -@@ -36,6 +_,10 @@ - this.field_174957_c = new BlockModelShapes(this); - } - -+ public IBakedModel getModel(ResourceLocation modelLocation) { -+ return this.field_174958_a.getOrDefault(modelLocation, this.field_174955_d); -+ } -+ - public IBakedModel func_174953_a(ModelResourceLocation p_174953_1_) { - return this.field_174958_a.getOrDefault(p_174953_1_, this.field_174955_d); - } -@@ -50,7 +_,7 @@ - - protected ModelBakery func_212854_a_(IResourceManager p_212854_1_, IProfiler p_212854_2_) { - p_212854_2_.func_219894_a(); -- ModelBakery modelbakery = new ModelBakery(p_212854_1_, this.field_224743_d, p_212854_2_, this.field_229354_f_); -+ net.minecraftforge.client.model.ModelLoader modelbakery = new net.minecraftforge.client.model.ModelLoader(p_212854_1_, this.field_224743_d, p_212854_2_, this.field_229354_f_); - p_212854_2_.func_219897_b(); - return modelbakery; - } -@@ -66,6 +_,7 @@ - this.field_174958_a = p_212853_1_.func_217846_a(); - this.field_224744_f = p_212853_1_.func_225354_b(); - this.field_174955_d = this.field_174958_a.get(ModelBakery.field_177604_a); -+ net.minecraftforge.client.ForgeHooksClient.onModelBake(this, this.field_174958_a, (net.minecraftforge.client.model.ModelLoader) p_212853_1_); - p_212853_3_.func_219895_b("cache"); - this.field_174957_c.func_178124_c(); - p_212853_3_.func_76319_b(); -@@ -91,6 +_,7 @@ - } - - public AtlasTexture func_229356_a_(ResourceLocation p_229356_1_) { -+ if (this.field_229352_b_ == null) throw new RuntimeException("getAtlasTexture called too early!"); - return this.field_229352_b_.func_229152_a_(p_229356_1_); - } - -@@ -103,5 +_,11 @@ - - public void func_229355_a_(int p_229355_1_) { - this.field_229354_f_ = p_229355_1_; -+ } -+ -+ // TODO -+ //@Override -+ public net.minecraftforge.resource.IResourceType getResourceType() { -+ return net.minecraftforge.resource.VanillaResourceType.MODELS; - } - } diff --git a/patches/minecraft/net/minecraft/client/renderer/model/MultipartBakedModel.java.patch b/patches/minecraft/net/minecraft/client/renderer/model/MultipartBakedModel.java.patch deleted file mode 100644 index d0cd640fca..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/model/MultipartBakedModel.java.patch +++ /dev/null @@ -1,86 +0,0 @@ ---- a/net/minecraft/client/renderer/model/MultipartBakedModel.java -+++ b/net/minecraft/client/renderer/model/MultipartBakedModel.java -@@ -18,7 +_,7 @@ - import org.apache.commons.lang3.tuple.Pair; - - @OnlyIn(Dist.CLIENT) --public class MultipartBakedModel implements IBakedModel { -+public class MultipartBakedModel implements net.minecraftforge.client.model.data.IDynamicBakedModel { - private final List, IBakedModel>> field_188626_f; - protected final boolean field_188621_a; - protected final boolean field_188622_b; -@@ -27,10 +_,12 @@ - protected final ItemCameraTransforms field_188624_d; - protected final ItemOverrideList field_188625_e; - private final Map field_210277_g = new Object2ObjectOpenCustomHashMap<>(Util.func_212443_g()); -+ private final IBakedModel defaultModel; - - public MultipartBakedModel(List, IBakedModel>> p_i48273_1_) { - this.field_188626_f = p_i48273_1_; - IBakedModel ibakedmodel = p_i48273_1_.iterator().next().getRight(); -+ this.defaultModel = ibakedmodel; - this.field_188621_a = ibakedmodel.func_177555_b(); - this.field_188622_b = ibakedmodel.func_177556_c(); - this.field_230185_c_ = ibakedmodel.func_230044_c_(); -@@ -39,7 +_,8 @@ - this.field_188625_e = ibakedmodel.func_188617_f(); - } - -- public List func_200117_a(@Nullable BlockState p_200117_1_, @Nullable Direction p_200117_2_, Random p_200117_3_) { -+ // FORGE: Implement our overloads (here and below) so child models can have custom logic -+ public List getQuads(@Nullable BlockState p_200117_1_, @Nullable Direction p_200117_2_, Random p_200117_3_, net.minecraftforge.client.model.data.IModelData modelData) { - if (p_200117_1_ == null) { - return Collections.emptyList(); - } else { -@@ -62,7 +_,7 @@ - - for(int j = 0; j < bitset.length(); ++j) { - if (bitset.get(j)) { -- list.addAll(this.field_188626_f.get(j).getRight().func_200117_a(p_200117_1_, p_200117_2_, new Random(k))); -+ list.addAll(this.field_188626_f.get(j).getRight().getQuads(p_200117_1_, p_200117_2_, new Random(k), net.minecraftforge.client.model.data.MultipartModelData.resolve(this.field_188626_f.get(j).getRight(), modelData))); - } - } - -@@ -74,6 +_,10 @@ - return this.field_188621_a; - } - -+ public boolean isAmbientOcclusion(BlockState state) { -+ return this.defaultModel.isAmbientOcclusion(state); -+ } -+ - public boolean func_177556_c() { - return this.field_188622_b; - } -@@ -86,16 +_,31 @@ - return false; - } - -+ @Deprecated - public TextureAtlasSprite func_177554_e() { - return this.field_188623_c; - } - -+ public TextureAtlasSprite getParticleTexture(net.minecraftforge.client.model.data.IModelData modelData) { -+ return this.defaultModel.getParticleTexture(modelData); -+ } -+ -+ @Deprecated - public ItemCameraTransforms func_177552_f() { - return this.field_188624_d; - } - -+ public IBakedModel handlePerspective(net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType transformType, com.mojang.blaze3d.matrix.MatrixStack matrixStack) { -+ return this.defaultModel.handlePerspective(transformType, matrixStack); -+ } -+ - public ItemOverrideList func_188617_f() { - return this.field_188625_e; -+ } -+ -+ @Override -+ public net.minecraftforge.client.model.data.IModelData getModelData(net.minecraft.world.IBlockDisplayReader world, net.minecraft.util.math.BlockPos pos, BlockState state, net.minecraftforge.client.model.data.IModelData tileData) { -+ return net.minecraftforge.client.model.data.MultipartModelData.create(field_188626_f, world, pos, state, tileData); - } - - @OnlyIn(Dist.CLIENT) diff --git a/patches/minecraft/net/minecraft/client/renderer/model/SimpleBakedModel.java.patch b/patches/minecraft/net/minecraft/client/renderer/model/SimpleBakedModel.java.patch deleted file mode 100644 index 9c005a5242..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/model/SimpleBakedModel.java.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/net/minecraft/client/renderer/model/SimpleBakedModel.java -+++ b/net/minecraft/client/renderer/model/SimpleBakedModel.java -@@ -77,6 +_,10 @@ - private final boolean field_177653_e; - private final ItemCameraTransforms field_177651_f; - -+ public Builder(net.minecraftforge.client.model.IModelConfiguration model, ItemOverrideList overrides) { -+ this(model.useSmoothLighting(), model.isSideLit(), model.isShadedInGui(), model.getCameraTransforms(), overrides); -+ } -+ - public Builder(BlockModel p_i230060_1_, ItemOverrideList p_i230060_2_, boolean p_i230060_3_) { - this(p_i230060_1_.func_178309_b(), p_i230060_1_.func_230176_c_().func_230178_a_(), p_i230060_3_, p_i230060_1_.func_181682_g(), p_i230060_2_); - } diff --git a/patches/minecraft/net/minecraft/client/renderer/model/UVTransformationUtil.java.patch b/patches/minecraft/net/minecraft/client/renderer/model/UVTransformationUtil.java.patch deleted file mode 100644 index 87a4daee4c..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/model/UVTransformationUtil.java.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- a/net/minecraft/client/renderer/model/UVTransformationUtil.java -+++ b/net/minecraft/client/renderer/model/UVTransformationUtil.java -@@ -27,7 +_,7 @@ - }); - public static final EnumMap field_229377_b_ = Util.func_200696_a(Maps.newEnumMap(Direction.class), (p_229381_0_) -> { - for(Direction direction : Direction.values()) { -- p_229381_0_.put(direction, field_229376_a_.get(direction).func_227987_b_()); -+ p_229381_0_.put(direction, field_229376_a_.get(direction).inverse()); - } - - }); -@@ -41,12 +_,12 @@ - - public static TransformationMatrix func_229380_a_(TransformationMatrix p_229380_0_, Direction p_229380_1_, Supplier p_229380_2_) { - Direction direction = Direction.func_229385_a_(p_229380_0_.func_227988_c_(), p_229380_1_); -- TransformationMatrix transformationmatrix = p_229380_0_.func_227987_b_(); -+ TransformationMatrix transformationmatrix = p_229380_0_.inverse(); - if (transformationmatrix == null) { - field_229378_c_.warn(p_229380_2_.get()); - return new TransformationMatrix((Vector3f)null, (Quaternion)null, new Vector3f(0.0F, 0.0F, 0.0F), (Quaternion)null); - } else { -- TransformationMatrix transformationmatrix1 = field_229377_b_.get(p_229380_1_).func_227985_a_(transformationmatrix).func_227985_a_(field_229376_a_.get(direction)); -+ TransformationMatrix transformationmatrix1 = field_229377_b_.get(p_229380_1_).compose(transformationmatrix).compose(field_229376_a_.get(direction)); - return func_229379_a_(transformationmatrix1); - } - } diff --git a/patches/minecraft/net/minecraft/client/renderer/model/VariantList.java.patch b/patches/minecraft/net/minecraft/client/renderer/model/VariantList.java.patch deleted file mode 100644 index 8819b7f91d..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/model/VariantList.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/renderer/model/VariantList.java -+++ b/net/minecraft/client/renderer/model/VariantList.java -@@ -64,7 +_,7 @@ - WeightedBakedModel.Builder weightedbakedmodel$builder = new WeightedBakedModel.Builder(); - - for(Variant variant : this.func_188114_a()) { -- IBakedModel ibakedmodel = p_225613_1_.func_217845_a(variant.func_188046_a(), variant); -+ IBakedModel ibakedmodel = p_225613_1_.getBakedModel(variant.func_188046_a(), variant, p_225613_2_); - weightedbakedmodel$builder.func_177677_a(ibakedmodel, variant.func_188047_d()); - } - diff --git a/patches/minecraft/net/minecraft/client/renderer/model/WeightedBakedModel.java.patch b/patches/minecraft/net/minecraft/client/renderer/model/WeightedBakedModel.java.patch deleted file mode 100644 index 39b760f11c..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/model/WeightedBakedModel.java.patch +++ /dev/null @@ -1,51 +0,0 @@ ---- a/net/minecraft/client/renderer/model/WeightedBakedModel.java -+++ b/net/minecraft/client/renderer/model/WeightedBakedModel.java -@@ -12,7 +_,7 @@ - import net.minecraftforge.api.distmarker.OnlyIn; - - @OnlyIn(Dist.CLIENT) --public class WeightedBakedModel implements IBakedModel { -+public class WeightedBakedModel implements net.minecraftforge.client.model.data.IDynamicBakedModel { - private final int field_177567_a; - private final List field_177565_b; - private final IBakedModel field_177566_c; -@@ -23,14 +_,20 @@ - this.field_177566_c = (p_i46073_1_.get(0)).field_185281_b; - } - -- public List func_200117_a(@Nullable BlockState p_200117_1_, @Nullable Direction p_200117_2_, Random p_200117_3_) { -- return (WeightedRandom.func_180166_a(this.field_177565_b, Math.abs((int)p_200117_3_.nextLong()) % this.field_177567_a)).field_185281_b.func_200117_a(p_200117_1_, p_200117_2_, p_200117_3_); -+ // FORGE: Implement our overloads (here and below) so child models can have custom logic -+ public List getQuads(@Nullable BlockState p_200117_1_, @Nullable Direction p_200117_2_, Random p_200117_3_, net.minecraftforge.client.model.data.IModelData modelData) { -+ return (WeightedRandom.func_180166_a(this.field_177565_b, Math.abs((int)p_200117_3_.nextLong()) % this.field_177567_a)).field_185281_b.getQuads(p_200117_1_, p_200117_2_, p_200117_3_, modelData); - } - - public boolean func_177555_b() { - return this.field_177566_c.func_177555_b(); - } - -+ @Override -+ public boolean isAmbientOcclusion(BlockState state) { -+ return this.field_177566_c.isAmbientOcclusion(state); -+ } -+ - public boolean func_177556_c() { - return this.field_177566_c.func_177556_c(); - } -@@ -47,8 +_,16 @@ - return this.field_177566_c.func_177554_e(); - } - -+ public TextureAtlasSprite getParticleTexture(net.minecraftforge.client.model.data.IModelData modelData) { -+ return this.field_177566_c.getParticleTexture(modelData); -+ } -+ - public ItemCameraTransforms func_177552_f() { - return this.field_177566_c.func_177552_f(); -+ } -+ -+ public IBakedModel handlePerspective(net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType transformType, com.mojang.blaze3d.matrix.MatrixStack matrixStack) { -+ return this.field_177566_c.handlePerspective(transformType, matrixStack); - } - - public ItemOverrideList func_188617_f() { diff --git a/patches/minecraft/net/minecraft/client/renderer/texture/AbstractTexture.java.patch b/patches/minecraft/net/minecraft/client/renderer/texture/AbstractTexture.java.patch new file mode 100644 index 0000000000..66389edcd7 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/texture/AbstractTexture.java.patch @@ -0,0 +1,23 @@ +--- a/net/minecraft/client/renderer/texture/AbstractTexture.java ++++ b/net/minecraft/client/renderer/texture/AbstractTexture.java +@@ -36,6 +_,20 @@ + GlStateManager.m_84331_(3553, 10240, j); + } + ++ // FORGE: This seems to have been stripped out, but we need it ++ private boolean lastBlur; ++ private boolean lastMipmap; ++ ++ public void setBlurMipmap(boolean blur, boolean mipmap) { ++ this.lastBlur = this.f_117951_; ++ this.lastMipmap = this.f_117952_; ++ m_117960_(blur, mipmap); ++ } ++ ++ public void restoreLastBlurMipmap() { ++ m_117960_(this.lastBlur, this.lastMipmap); ++ } ++ + public int m_117963_() { + RenderSystem.m_69393_(RenderSystem::m_69587_); + if (this.f_117950_ == -1) { diff --git a/patches/minecraft/net/minecraft/client/renderer/texture/AtlasTexture.java.patch b/patches/minecraft/net/minecraft/client/renderer/texture/AtlasTexture.java.patch deleted file mode 100644 index 3299f161cd..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/texture/AtlasTexture.java.patch +++ /dev/null @@ -1,37 +0,0 @@ ---- a/net/minecraft/client/renderer/texture/AtlasTexture.java -+++ b/net/minecraft/client/renderer/texture/AtlasTexture.java -@@ -78,6 +_,7 @@ - } - } - -+ net.minecraftforge.client.ForgeHooksClient.onTextureStitchedPost(this); - } - - public AtlasTexture.SheetData func_229220_a_(IResourceManager p_229220_1_, Stream p_229220_2_, IProfiler p_229220_3_, int p_229220_4_) { -@@ -92,6 +_,7 @@ - int j = Integer.MAX_VALUE; - int k = 1 << p_229220_4_; - p_229220_3_.func_219895_b("extracting_frames"); -+ net.minecraftforge.client.ForgeHooksClient.onTextureStitchedPre(this, set); - - for(TextureAtlasSprite.Info textureatlassprite$info : this.func_215256_a(p_229220_1_, set)) { - j = Math.min(j, Math.min(textureatlassprite$info.func_229250_b_(), textureatlassprite$info.func_229252_c_())); -@@ -106,7 +_,8 @@ - - int i1 = Math.min(j, k); - int j1 = MathHelper.func_151239_c(i1); -- int k1; -+ int k1 = p_229220_4_; -+ if (false) // FORGE: do not lower the mipmap level - if (j1 < p_229220_4_) { - field_147635_d.warn("{}: dropping miplevel from {} to {}, because of minimum power of two: {}", this.field_229214_j_, p_229220_4_, j1, i1); - k1 = j1; -@@ -200,6 +_,8 @@ - - try (IResource iresource = p_229218_1_.func_199002_a(resourcelocation)) { - NativeImage nativeimage = NativeImage.func_195713_a(iresource.func_199027_b()); -+ TextureAtlasSprite customSprite = net.minecraftforge.client.ForgeHooksClient.loadTextureAtlasSprite(this, p_229218_1_, p_229218_2_, iresource, p_229218_3_, p_229218_4_, p_229218_6_, p_229218_7_, p_229218_5_, nativeimage); -+ if (customSprite != null) return customSprite; - return new TextureAtlasSprite(this, p_229218_2_, p_229218_5_, p_229218_3_, p_229218_4_, p_229218_6_, p_229218_7_, nativeimage); - } catch (RuntimeException runtimeexception) { - field_147635_d.error("Unable to parse metadata from {}", resourcelocation, runtimeexception); diff --git a/patches/minecraft/net/minecraft/client/renderer/texture/NativeImage.java.patch b/patches/minecraft/net/minecraft/client/renderer/texture/NativeImage.java.patch deleted file mode 100644 index efe902042a..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/texture/NativeImage.java.patch +++ /dev/null @@ -1,29 +0,0 @@ ---- a/net/minecraft/client/renderer/texture/NativeImage.java -+++ b/net/minecraft/client/renderer/texture/NativeImage.java -@@ -180,7 +_,7 @@ - public int func_195709_a(int p_195709_1_, int p_195709_2_) { - if (this.field_211680_b != NativeImage.PixelFormat.RGBA) { - throw new IllegalArgumentException(String.format("getPixelRGBA only works on RGBA images; have %s", this.field_211680_b)); -- } else if (p_195709_1_ <= this.field_195719_a && p_195709_2_ <= this.field_195720_b) { -+ } else if (p_195709_1_ >= 0 && p_195709_2_ >= 0 && p_195709_1_ < this.field_195719_a && p_195709_2_ < this.field_195720_b) { //Fix MC-162953 bounds checks in `NativeImage` - this.func_195696_g(); - long i = (long)((p_195709_1_ + p_195709_2_ * this.field_195719_a) * 4); - return MemoryUtil.memGetInt(this.field_195722_d + i); -@@ -192,7 +_,7 @@ - public void func_195700_a(int p_195700_1_, int p_195700_2_, int p_195700_3_) { - if (this.field_211680_b != NativeImage.PixelFormat.RGBA) { - throw new IllegalArgumentException(String.format("getPixelRGBA only works on RGBA images; have %s", this.field_211680_b)); -- } else if (p_195700_1_ <= this.field_195719_a && p_195700_2_ <= this.field_195720_b) { -+ } else if (p_195700_1_ >= 0 && p_195700_2_ >= 0 && p_195700_1_ < this.field_195719_a && p_195700_2_ < this.field_195720_b) { //Fix MC-162953 bounds checks in `NativeImage` - this.func_195696_g(); - long i = (long)((p_195700_1_ + p_195700_2_ * this.field_195719_a) * 4); - MemoryUtil.memPutInt(this.field_195722_d + i, p_195700_3_); -@@ -204,7 +_,7 @@ - public byte func_211675_e(int p_211675_1_, int p_211675_2_) { - if (!this.field_211680_b.func_211653_r()) { - throw new IllegalArgumentException(String.format("no luminance or alpha in %s", this.field_211680_b)); -- } else if (p_211675_1_ <= this.field_195719_a && p_211675_2_ <= this.field_195720_b) { -+ } else if (p_211675_1_ >= 0 && p_211675_2_ >= 0 && p_211675_1_ < this.field_195719_a && p_211675_2_ < this.field_195720_b) { //Fix MC-162953 bounds checks in `NativeImage` - int i = (p_211675_1_ + p_211675_2_ * this.field_195719_a) * this.field_211680_b.func_211651_a() + this.field_211680_b.func_211647_v() / 8; - return MemoryUtil.memGetByte(this.field_195722_d + (long)i); - } else { diff --git a/patches/minecraft/net/minecraft/client/renderer/texture/Stitcher.java.patch b/patches/minecraft/net/minecraft/client/renderer/texture/Stitcher.java.patch index 1514b46184..39a9c4098a 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/Stitcher.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/Stitcher.java.patch @@ -1,28 +1,28 @@ --- a/net/minecraft/client/renderer/texture/Stitcher.java +++ b/net/minecraft/client/renderer/texture/Stitcher.java -@@ -14,6 +_,8 @@ +@@ -13,6 +_,8 @@ @OnlyIn(Dist.CLIENT) public class Stitcher { + private static final org.apache.logging.log4j.Logger LOGGER = org.apache.logging.log4j.LogManager.getLogger(); + - private static final Comparator field_217797_a = Comparator.comparing((p_217793_0_) -> { - return -p_217793_0_.field_94201_d; - }).thenComparing((p_217795_0_) -> { -@@ -54,6 +_,12 @@ + private static final Comparator f_118161_ = Comparator.comparing((p_118201_) -> { + return -p_118201_.f_118204_; + }).thenComparing((p_118199_) -> { +@@ -53,6 +_,12 @@ for(Stitcher.Holder stitcher$holder : list) { - if (!this.func_94310_b(stitcher$holder)) { + if (!this.m_118178_(stitcher$holder)) { + LOGGER.info(new net.minecraftforge.fml.loading.AdvancedLogMessageAdapter(sb->{ -+ sb.append("Unable to fit: ").append(stitcher$holder.field_229213_a_.func_229248_a_()); -+ sb.append(" - size: ").append(stitcher$holder.field_229213_a_.func_229250_b_()).append("x").append(stitcher$holder.field_229213_a_.func_229252_c_()); ++ sb.append("Unable to fit: ").append(stitcher$holder.f_118202_.m_118431_()); ++ sb.append(" - size: ").append(stitcher$holder.f_118202_.m_118434_()).append("x").append(stitcher$holder.f_118202_.m_118437_()); + sb.append(" - Maybe try a lower resolution resourcepack?\n"); + list.forEach(h-> sb.append("\t").append(h).append("\n")); + })); - throw new StitcherException(stitcher$holder.field_229213_a_, list.stream().map((p_229212_0_) -> { - return p_229212_0_.field_229213_a_; + throw new StitcherException(stitcher$holder.f_118202_, list.stream().map((p_118195_) -> { + return p_118195_.f_118202_; }).collect(ImmutableList.toImmutableList())); -@@ -103,7 +_,7 @@ +@@ -102,7 +_,7 @@ boolean flag4 = flag2 && j != l; boolean flag; if (flag3 ^ flag4) { @@ -31,12 +31,12 @@ } else { flag = flag1 && i <= j; } -@@ -140,7 +_,7 @@ +@@ -139,7 +_,7 @@ } public String toString() { -- return "Holder{width=" + this.field_94204_c + ", height=" + this.field_94201_d + '}'; -+ return "Holder{width=" + this.field_94204_c + ", height=" + this.field_94201_d + ", name=" + this.field_229213_a_.func_229248_a_() + '}'; +- return "Holder{width=" + this.f_118203_ + ", height=" + this.f_118204_ + "}"; ++ return "Holder{width=" + this.f_118203_ + ", height=" + this.f_118204_ + ", name=" + this.f_118202_.m_118431_() + '}'; } } diff --git a/patches/minecraft/net/minecraft/client/renderer/texture/Texture.java.patch b/patches/minecraft/net/minecraft/client/renderer/texture/Texture.java.patch deleted file mode 100644 index 1c984d8568..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/texture/Texture.java.patch +++ /dev/null @@ -1,23 +0,0 @@ ---- a/net/minecraft/client/renderer/texture/Texture.java -+++ b/net/minecraft/client/renderer/texture/Texture.java -@@ -33,6 +_,20 @@ - GlStateManager.func_227677_b_(3553, 10240, j); - } - -+ // FORGE: This seems to have been stripped out, but we need it -+ private boolean lastBlur; -+ private boolean lastMipmap; -+ -+ public void setBlurMipmap(boolean blur, boolean mipmap) { -+ this.lastBlur = this.field_174940_b; -+ this.lastMipmap = this.field_174941_c; -+ func_174937_a(blur, mipmap); -+ } -+ -+ public void restoreLastBlurMipmap() { -+ func_174937_a(this.lastBlur, this.lastMipmap); -+ } -+ - public int func_110552_b() { - RenderSystem.assertThread(RenderSystem::isOnRenderThreadOrInit); - if (this.field_110553_a == -1) { diff --git a/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlas.java.patch b/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlas.java.patch new file mode 100644 index 0000000000..1947ab1ae2 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlas.java.patch @@ -0,0 +1,37 @@ +--- a/net/minecraft/client/renderer/texture/TextureAtlas.java ++++ b/net/minecraft/client/renderer/texture/TextureAtlas.java +@@ -83,6 +_,7 @@ + } + } + ++ net.minecraftforge.client.ForgeHooksClient.onTextureStitchedPost(this); + } + + public TextureAtlas.Preparations m_118307_(ResourceManager p_118308_, Stream p_118309_, ProfilerFiller p_118310_, int p_118311_) { +@@ -97,6 +_,7 @@ + int j = Integer.MAX_VALUE; + int k = 1 << p_118311_; + p_118310_.m_6182_("extracting_frames"); ++ net.minecraftforge.client.ForgeHooksClient.onTextureStitchedPre(this, set); + + for(TextureAtlasSprite.Info textureatlassprite$info : this.m_118304_(p_118308_, set)) { + j = Math.min(j, Math.min(textureatlassprite$info.m_118434_(), textureatlassprite$info.m_118437_())); +@@ -111,7 +_,8 @@ + + int i1 = Math.min(j, k); + int j1 = Mth.m_14173_(i1); +- int k1; ++ int k1 = p_118311_; ++ if (false) // FORGE: do not lower the mipmap level + if (j1 < p_118311_) { + f_118261_.warn("{}: dropping miplevel from {} to {}, because of minimum power of two: {}", this.f_118265_, p_118311_, j1, i1); + k1 = j1; +@@ -227,6 +_,8 @@ + TextureAtlasSprite textureatlassprite; + try { + NativeImage nativeimage = NativeImage.m_85058_(resource.m_6679_()); ++ textureatlassprite = net.minecraftforge.client.ForgeHooksClient.loadTextureAtlasSprite(this, p_118288_, p_118289_, resource, p_118290_, p_118291_, p_118293_, p_118294_, p_118292_, nativeimage); ++ if (textureatlassprite == null) + textureatlassprite = new TextureAtlasSprite(this, p_118289_, p_118292_, p_118290_, p_118291_, p_118293_, p_118294_, nativeimage); + } catch (Throwable throwable1) { + if (resource != null) { diff --git a/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlasSprite.java.patch b/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlasSprite.java.patch index eed3bcf8e4..91beaf4752 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlasSprite.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlasSprite.java.patch @@ -1,23 +1,23 @@ --- a/net/minecraft/client/renderer/texture/TextureAtlasSprite.java +++ b/net/minecraft/client/renderer/texture/TextureAtlasSprite.java -@@ -17,7 +_,7 @@ - import net.minecraftforge.api.distmarker.OnlyIn; +@@ -24,7 +_,7 @@ + import org.apache.logging.log4j.Logger; @OnlyIn(Dist.CLIENT) -public class TextureAtlasSprite implements AutoCloseable { +public class TextureAtlasSprite implements AutoCloseable, net.minecraftforge.client.extensions.IForgeTextureAtlasSprite { - private final AtlasTexture field_229225_b_; - private final TextureAtlasSprite.Info field_229226_c_; - private final AnimationMetadataSection field_110982_k; -@@ -135,6 +_,7 @@ + private static final Logger f_174721_ = LogManager.getLogger(); + private final TextureAtlas f_118343_; + private final ResourceLocation f_174722_; +@@ -145,6 +_,7 @@ - private void func_195667_a(int p_195667_1_, int p_195667_2_, NativeImage[] p_195667_3_) { - for(int i = 0; i < this.field_195670_c.length; ++i) { -+ if ((this.field_229226_c_.field_229245_b_ >> i <= 0) || (this.field_229226_c_.field_229246_c_ >> i <= 0)) break; - p_195667_3_[i].func_227788_a_(i, this.field_110975_c >> i, this.field_110974_d >> i, p_195667_1_ >> i, p_195667_2_ >> i, this.field_229226_c_.field_229245_b_ >> i, this.field_229226_c_.field_229246_c_ >> i, this.field_195670_c.length > 1, false); + void m_118375_(int p_118376_, int p_118377_, NativeImage[] p_118378_) { + for(int i = 0; i < this.f_118342_.length; ++i) { ++ if ((this.f_174723_ >> i <= 0) || (this.f_174724_ >> i <= 0)) break; + p_118378_[i].m_85003_(i, this.f_118349_ >> i, this.f_118350_ >> i, p_118376_ >> i, p_118377_ >> i, this.f_174723_ >> i, this.f_174724_ >> i, this.f_118342_.length > 1, false); } -@@ -340,5 +_,10 @@ +@@ -438,5 +_,15 @@ } } @@ -25,6 +25,11 @@ + + // Forge Start + public int getPixelRGBA(int frameIndex, int x, int y) { -+ return this.field_195670_c[0].func_195709_a(x + this.field_195671_d[frameIndex] * func_94211_a(), y + this.field_195672_e[frameIndex] * func_94216_b()); ++ if (this.f_174725_ != null) { ++ x += this.f_174725_.m_174759_(frameIndex) * this.f_174723_; ++ y += this.f_174725_.m_174764_(frameIndex) * this.f_174724_; ++ } ++ ++ return this.f_118342_[0].m_84985_(x, y); } } 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 da101b2413..a46ecc889f 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/TextureManager.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/TextureManager.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/client/renderer/texture/TextureManager.java +++ b/net/minecraft/client/renderer/texture/TextureManager.java -@@ -157,6 +_,7 @@ - public void func_147645_c(ResourceLocation p_147645_1_) { - Texture texture = this.func_229267_b_(p_147645_1_); - if (texture != null) { -+ this.field_110585_a.remove(p_147645_1_); // Forge: fix MC-98707 - TextureUtil.func_225679_a_(texture.func_110552_b()); +@@ -167,6 +_,7 @@ + public void m_118513_(ResourceLocation p_118514_) { + AbstractTexture abstracttexture = this.m_174786_(p_118514_, MissingTextureAtlasSprite.m_118080_()); + if (abstracttexture != MissingTextureAtlasSprite.m_118080_()) { ++ this.f_118468_.remove(p_118514_); // Forge: fix MC-98707 + TextureUtil.m_85281_(abstracttexture.m_117963_()); } diff --git a/patches/minecraft/net/minecraft/client/renderer/tileentity/ChestTileEntityRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/tileentity/ChestTileEntityRenderer.java.patch deleted file mode 100644 index 66f6cfad8b..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/tileentity/ChestTileEntityRenderer.java.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- a/net/minecraft/client/renderer/tileentity/ChestTileEntityRenderer.java -+++ b/net/minecraft/client/renderer/tileentity/ChestTileEntityRenderer.java -@@ -100,7 +_,7 @@ - f1 = 1.0F - f1; - f1 = 1.0F - f1 * f1 * f1; - int i = icallbackwrapper.apply(new DualBrightnessCallback<>()).applyAsInt(p_225616_5_); -- RenderMaterial rendermaterial = Atlases.func_228771_a_(p_225616_1_, chesttype, this.field_147509_j); -+ RenderMaterial rendermaterial = this.getMaterial(p_225616_1_, chesttype); - IVertexBuilder ivertexbuilder = rendermaterial.func_229311_a_(p_225616_4_, RenderType::func_228638_b_); - if (flag1) { - if (chesttype == ChestType.LEFT) { -@@ -122,5 +_,9 @@ - p_228871_3_.func_228308_a_(p_228871_1_, p_228871_2_, p_228871_7_, p_228871_8_); - p_228871_4_.func_228308_a_(p_228871_1_, p_228871_2_, p_228871_7_, p_228871_8_); - p_228871_5_.func_228308_a_(p_228871_1_, p_228871_2_, p_228871_7_, p_228871_8_); -+ } -+ -+ protected RenderMaterial getMaterial(T tileEntity, ChestType chestType) { -+ return Atlases.func_228771_a_(tileEntity, chestType, this.field_147509_j); - } - } diff --git a/patches/minecraft/net/minecraft/client/renderer/tileentity/PistonTileEntityRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/tileentity/PistonTileEntityRenderer.java.patch deleted file mode 100644 index a083d777f4..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/tileentity/PistonTileEntityRenderer.java.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/net/minecraft/client/renderer/tileentity/PistonTileEntityRenderer.java -+++ b/net/minecraft/client/renderer/tileentity/PistonTileEntityRenderer.java -@@ -61,8 +_,11 @@ - } - - private void func_228876_a_(BlockPos p_228876_1_, BlockState p_228876_2_, MatrixStack p_228876_3_, IRenderTypeBuffer p_228876_4_, World p_228876_5_, boolean p_228876_6_, int p_228876_7_) { -+ net.minecraftforge.client.ForgeHooksClient.renderPistonMovedBlocks(p_228876_1_, p_228876_2_, p_228876_3_, p_228876_4_, p_228876_5_, p_228876_6_, p_228876_7_, field_178462_c == null ? field_178462_c = Minecraft.func_71410_x().func_175602_ab() : field_178462_c); -+ if(false) { - RenderType rendertype = RenderTypeLookup.func_239221_b_(p_228876_2_); - IVertexBuilder ivertexbuilder = p_228876_4_.getBuffer(rendertype); - this.field_178462_c.func_175019_b().func_228802_a_(p_228876_5_, this.field_178462_c.func_184389_a(p_228876_2_), p_228876_2_, p_228876_1_, p_228876_3_, ivertexbuilder, p_228876_6_, new Random(), p_228876_2_.func_209533_a(p_228876_1_), p_228876_7_); -+ } - } - } diff --git a/patches/minecraft/net/minecraft/client/renderer/tileentity/SignTileEntityRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/tileentity/SignTileEntityRenderer.java.patch deleted file mode 100644 index 8d3d701a96..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/tileentity/SignTileEntityRenderer.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/renderer/tileentity/SignTileEntityRenderer.java -+++ b/net/minecraft/client/renderer/tileentity/SignTileEntityRenderer.java -@@ -89,7 +_,7 @@ - woodtype = WoodType.field_227038_a_; - } - -- return Atlases.func_228773_a_(woodtype); -+ return Atlases.field_228750_i_.get(woodtype); - } - - @OnlyIn(Dist.CLIENT) diff --git a/patches/minecraft/net/minecraft/client/renderer/tileentity/TileEntityRendererDispatcher.java.patch b/patches/minecraft/net/minecraft/client/renderer/tileentity/TileEntityRendererDispatcher.java.patch deleted file mode 100644 index 830b85f814..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/tileentity/TileEntityRendererDispatcher.java.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/net/minecraft/client/renderer/tileentity/TileEntityRendererDispatcher.java -+++ b/net/minecraft/client/renderer/tileentity/TileEntityRendererDispatcher.java -@@ -135,4 +_,9 @@ - public FontRenderer func_147548_a() { - return this.field_147557_n; - } -+ -+ //Internal, Do not call Use ClientRegistry. -+ public synchronized void setSpecialRendererInternal(TileEntityType tileEntityType, TileEntityRenderer specialRenderer) { -+ this.field_147559_m.put(tileEntityType, specialRenderer); -+ } - } diff --git a/patches/minecraft/net/minecraft/client/renderer/vertex/VertexFormat.java.patch b/patches/minecraft/net/minecraft/client/renderer/vertex/VertexFormat.java.patch deleted file mode 100644 index 21b3a66fb4..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/vertex/VertexFormat.java.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/net/minecraft/client/renderer/vertex/VertexFormat.java -+++ b/net/minecraft/client/renderer/vertex/VertexFormat.java -@@ -84,4 +_,11 @@ - - } - } -+ -+ // Forge start -+ public int getOffset(int index) { return field_177356_c.getInt(index); } -+ public boolean hasPosition() { return field_177355_b.stream().anyMatch(e -> e.func_177375_c() == VertexFormatElement.Usage.POSITION); } -+ public boolean hasNormal() { return field_177355_b.stream().anyMatch(e -> e.func_177375_c() == VertexFormatElement.Usage.NORMAL); } -+ public boolean hasColor() { return field_177355_b.stream().anyMatch(e -> e.func_177375_c() == VertexFormatElement.Usage.COLOR); } -+ public boolean hasUV(int which) { return field_177355_b.stream().anyMatch(e -> e.func_177375_c() == VertexFormatElement.Usage.UV && e.func_177369_e() == which); } - } diff --git a/patches/minecraft/net/minecraft/client/renderer/vertex/VertexFormatElement.java.patch b/patches/minecraft/net/minecraft/client/renderer/vertex/VertexFormatElement.java.patch deleted file mode 100644 index fc3172d78e..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/vertex/VertexFormatElement.java.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- a/net/minecraft/client/renderer/vertex/VertexFormatElement.java -+++ b/net/minecraft/client/renderer/vertex/VertexFormatElement.java -@@ -88,6 +_,12 @@ - this.field_177380_c.func_227901_a_(this.field_177377_d); - } - -+ //Forge Start -+ public int getElementCount() { -+ return field_177378_e; -+ } -+ //Forge End -+ - @OnlyIn(Dist.CLIENT) - public static enum Type { - FLOAT(4, "Float", 5126), diff --git a/patches/minecraft/net/minecraft/client/resources/ClientLanguageMap.java.patch b/patches/minecraft/net/minecraft/client/resources/ClientLanguageMap.java.patch deleted file mode 100644 index c434417ba1..0000000000 --- a/patches/minecraft/net/minecraft/client/resources/ClientLanguageMap.java.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/net/minecraft/client/resources/ClientLanguageMap.java -+++ b/net/minecraft/client/resources/ClientLanguageMap.java -@@ -78,4 +_,9 @@ - public IReorderingProcessor func_241870_a(ITextProperties p_241870_1_) { - return BidiReorderer.func_243508_a(p_241870_1_, this.field_239496_d_); - } -+ -+ @Override -+ public Map getLanguageData() { -+ return field_239495_c_; -+ } - } diff --git a/patches/minecraft/net/minecraft/client/resources/FoliageColorReloadListener.java.patch b/patches/minecraft/net/minecraft/client/resources/FoliageColorReloadListener.java.patch deleted file mode 100644 index 041ab490e8..0000000000 --- a/patches/minecraft/net/minecraft/client/resources/FoliageColorReloadListener.java.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/net/minecraft/client/resources/FoliageColorReloadListener.java -+++ b/net/minecraft/client/resources/FoliageColorReloadListener.java -@@ -23,4 +_,9 @@ - protected void func_212853_a_(int[] p_212853_1_, IResourceManager p_212853_2_, IProfiler p_212853_3_) { - FoliageColors.func_77467_a(p_212853_1_); - } -+ -+ //@Override //Forge: TODO: Filtered resource reloading -+ public net.minecraftforge.resource.IResourceType getResourceType() { -+ return net.minecraftforge.resource.VanillaResourceType.TEXTURES; -+ } - } diff --git a/patches/minecraft/net/minecraft/client/resources/GrassColorReloadListener.java.patch b/patches/minecraft/net/minecraft/client/resources/GrassColorReloadListener.java.patch deleted file mode 100644 index c97f584313..0000000000 --- a/patches/minecraft/net/minecraft/client/resources/GrassColorReloadListener.java.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/net/minecraft/client/resources/GrassColorReloadListener.java -+++ b/net/minecraft/client/resources/GrassColorReloadListener.java -@@ -23,4 +_,9 @@ - protected void func_212853_a_(int[] p_212853_1_, IResourceManager p_212853_2_, IProfiler p_212853_3_) { - GrassColors.func_77479_a(p_212853_1_); - } -+ -+ //@Override //Forge: TODO: Filtered resource reloading -+ public net.minecraftforge.resource.IResourceType getResourceType() { -+ return net.minecraftforge.resource.VanillaResourceType.TEXTURES; -+ } - } diff --git a/patches/minecraft/net/minecraft/client/resources/I18n.java.patch b/patches/minecraft/net/minecraft/client/resources/I18n.java.patch deleted file mode 100644 index 5dd3696c78..0000000000 --- a/patches/minecraft/net/minecraft/client/resources/I18n.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/client/resources/I18n.java -+++ b/net/minecraft/client/resources/I18n.java -@@ -11,6 +_,7 @@ - - static void func_239502_a_(LanguageMap p_239502_0_) { - field_239501_a_ = p_239502_0_; -+ net.minecraftforge.fml.ForgeI18n.loadLanguageData(p_239502_0_.getLanguageData()); - } - - public static String func_135052_a(String p_135052_0_, Object... p_135052_1_) { diff --git a/patches/minecraft/net/minecraft/client/resources/JsonReloadListener.java.patch b/patches/minecraft/net/minecraft/client/resources/JsonReloadListener.java.patch deleted file mode 100644 index 6a47a9bf27..0000000000 --- a/patches/minecraft/net/minecraft/client/resources/JsonReloadListener.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/resources/JsonReloadListener.java -+++ b/net/minecraft/client/resources/JsonReloadListener.java -@@ -61,4 +_,8 @@ - - return map; - } -+ -+ protected ResourceLocation getPreparedPath(ResourceLocation rl) { -+ return new ResourceLocation(rl.func_110624_b(), this.field_223383_d + "/" + rl.func_110623_a() + ".json"); -+ } - } diff --git a/patches/minecraft/net/minecraft/client/resources/Language.java.patch b/patches/minecraft/net/minecraft/client/resources/Language.java.patch deleted file mode 100644 index 26c3435886..0000000000 --- a/patches/minecraft/net/minecraft/client/resources/Language.java.patch +++ /dev/null @@ -1,24 +0,0 @@ ---- a/net/minecraft/client/resources/Language.java -+++ b/net/minecraft/client/resources/Language.java -@@ -15,6 +_,12 @@ - this.field_135037_b = p_i1303_2_; - this.field_135038_c = p_i1303_3_; - this.field_135036_d = p_i1303_4_; -+ String[] splitLangCode = field_135039_a.split("_", 2); -+ if (splitLangCode.length == 1) { // Vanilla has some languages without underscores -+ this.javaLocale = new java.util.Locale(field_135039_a); -+ } else { -+ this.javaLocale = new java.util.Locale(splitLangCode[0], splitLangCode[1]); -+ } - } - - public String getCode() { -@@ -52,4 +_,8 @@ - public int compareTo(Language p_compareTo_1_) { - return this.field_135039_a.compareTo(p_compareTo_1_.field_135039_a); - } -+ -+ // Forge: add access to Locale so modders can create correct string and number formatters -+ private final java.util.Locale javaLocale; -+ public java.util.Locale getJavaLocale() { return javaLocale; } - } diff --git a/patches/minecraft/net/minecraft/client/resources/LanguageManager.java.patch b/patches/minecraft/net/minecraft/client/resources/LanguageManager.java.patch deleted file mode 100644 index d70771bb14..0000000000 --- a/patches/minecraft/net/minecraft/client/resources/LanguageManager.java.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/net/minecraft/client/resources/LanguageManager.java -+++ b/net/minecraft/client/resources/LanguageManager.java -@@ -79,4 +_,9 @@ - public Language func_191960_a(String p_191960_1_) { - return this.field_135046_d.get(p_191960_1_); - } -+ -+ @Override -+ public net.minecraftforge.resource.IResourceType getResourceType() { -+ return net.minecraftforge.resource.VanillaResourceType.LANGUAGES; -+ } - } diff --git a/patches/minecraft/net/minecraft/client/resources/language/ClientLanguage.java.patch b/patches/minecraft/net/minecraft/client/resources/language/ClientLanguage.java.patch new file mode 100644 index 0000000000..09faaacf22 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/resources/language/ClientLanguage.java.patch @@ -0,0 +1,12 @@ +--- a/net/minecraft/client/resources/language/ClientLanguage.java ++++ b/net/minecraft/client/resources/language/ClientLanguage.java +@@ -95,4 +_,9 @@ + public FormattedCharSequence m_5536_(FormattedText p_118925_) { + return FormattedBidiReorder.m_118931_(p_118925_, this.f_118911_); + } ++ ++ @Override ++ public Map getLanguageData() { ++ return f_118910_; ++ } + } diff --git a/patches/minecraft/net/minecraft/client/resources/language/I18n.java.patch b/patches/minecraft/net/minecraft/client/resources/language/I18n.java.patch new file mode 100644 index 0000000000..ab211c7e1f --- /dev/null +++ b/patches/minecraft/net/minecraft/client/resources/language/I18n.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/client/resources/language/I18n.java ++++ b/net/minecraft/client/resources/language/I18n.java +@@ -14,6 +_,7 @@ + + static void m_118941_(Language p_118942_) { + f_118934_ = p_118942_; ++ net.minecraftforge.fmllegacy.ForgeI18n.loadLanguageData(p_118942_.getLanguageData()); + } + + public static String m_118938_(String p_118939_, Object... p_118940_) { diff --git a/patches/minecraft/net/minecraft/client/resources/language/LanguageInfo.java.patch b/patches/minecraft/net/minecraft/client/resources/language/LanguageInfo.java.patch new file mode 100644 index 0000000000..a3ad670591 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/resources/language/LanguageInfo.java.patch @@ -0,0 +1,24 @@ +--- a/net/minecraft/client/resources/language/LanguageInfo.java ++++ b/net/minecraft/client/resources/language/LanguageInfo.java +@@ -16,6 +_,12 @@ + this.f_118944_ = p_118949_; + this.f_118945_ = p_118950_; + this.f_118946_ = p_118951_; ++ String[] splitLangCode = f_118943_.split("_", 2); ++ if (splitLangCode.length == 1) { // Vanilla has some languages without underscores ++ this.javaLocale = new java.util.Locale(f_118943_); ++ } else { ++ this.javaLocale = new java.util.Locale(splitLangCode[0], splitLangCode[1]); ++ } + } + + public String getCode() { +@@ -53,4 +_,8 @@ + public int compareTo(LanguageInfo p_118954_) { + return this.f_118943_.compareTo(p_118954_.f_118943_); + } ++ ++ // Forge: add access to Locale so modders can create correct string and number formatters ++ private final java.util.Locale javaLocale; ++ public java.util.Locale getJavaLocale() { return javaLocale; } + } diff --git a/patches/minecraft/net/minecraft/client/resources/language/LanguageManager.java.patch b/patches/minecraft/net/minecraft/client/resources/language/LanguageManager.java.patch new file mode 100644 index 0000000000..39db884608 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/resources/language/LanguageManager.java.patch @@ -0,0 +1,12 @@ +--- a/net/minecraft/client/resources/language/LanguageManager.java ++++ b/net/minecraft/client/resources/language/LanguageManager.java +@@ -80,4 +_,9 @@ + public LanguageInfo m_118976_(String p_118977_) { + return this.f_118966_.get(p_118977_); + } ++ ++ @Override ++ public net.minecraftforge.resource.IResourceType getResourceType() { ++ return net.minecraftforge.resource.VanillaResourceType.LANGUAGES; ++ } + } diff --git a/patches/minecraft/net/minecraft/client/resources/model/BakedModel.java.patch b/patches/minecraft/net/minecraft/client/resources/model/BakedModel.java.patch new file mode 100644 index 0000000000..f70f6d8eba --- /dev/null +++ b/patches/minecraft/net/minecraft/client/resources/model/BakedModel.java.patch @@ -0,0 +1,28 @@ +--- a/net/minecraft/client/resources/model/BakedModel.java ++++ b/net/minecraft/client/resources/model/BakedModel.java +@@ -13,7 +_,9 @@ + import net.minecraftforge.api.distmarker.OnlyIn; + + @OnlyIn(Dist.CLIENT) +-public interface BakedModel { ++public interface BakedModel extends net.minecraftforge.client.extensions.IForgeBakedModel { ++ /**@deprecated Forge: Use {@link net.minecraftforge.client.extensions.IForgeBakedModel#getQuads(BlockState, Direction, Random, net.minecraftforge.client.model.data.IModelData)}*/ ++ @Deprecated + List m_6840_(@Nullable BlockState p_119123_, @Nullable Direction p_119124_, Random p_119125_); + + boolean m_7541_(); +@@ -24,9 +_,13 @@ + + boolean m_7521_(); + ++ /**@deprecated Forge: Use {@link net.minecraftforge.client.extensions.IForgeBakedModel#getParticleIcon(net.minecraftforge.client.model.data.IModelData)}*/ ++ @Deprecated + TextureAtlasSprite m_6160_(); + +- ItemTransforms m_7442_(); ++ /**@deprecated Forge: Use {@link net.minecraftforge.client.extensions.IForgeBakedModel#handlePerspective(ItemTransforms.TransformType, com.mojang.blaze3d.vertex.PoseStack)} instead */ ++ @Deprecated ++ default ItemTransforms m_7442_() { return ItemTransforms.f_111786_; } + + ItemOverrides m_7343_(); + } diff --git a/patches/minecraft/net/minecraft/client/resources/model/ModelBakery.java.patch b/patches/minecraft/net/minecraft/client/resources/model/ModelBakery.java.patch new file mode 100644 index 0000000000..8c199591fc --- /dev/null +++ b/patches/minecraft/net/minecraft/client/resources/model/ModelBakery.java.patch @@ -0,0 +1,107 @@ +--- a/net/minecraft/client/resources/model/ModelBakery.java ++++ b/net/minecraft/client/resources/model/ModelBakery.java +@@ -156,8 +_,17 @@ + }); + + public ModelBakery(ResourceManager p_119247_, BlockColors p_119248_, ProfilerFiller p_119249_, int p_119250_) { ++ this(p_119247_, p_119248_, true); ++ processLoading(p_119249_, p_119250_); ++ } ++ ++ protected ModelBakery(ResourceManager p_119247_, BlockColors p_119248_, boolean vanillaBakery) { + this.f_119243_ = p_119247_; + this.f_119209_ = p_119248_; ++ } ++ ++ protected void processLoading(ProfilerFiller p_119249_, int p_119250_) { ++ net.minecraftforge.client.model.ModelLoaderRegistry.onModelLoadingStart(); + p_119249_.m_6180_("missing_model"); + + try { +@@ -191,12 +_,16 @@ + p_119249_.m_6182_("special"); + this.m_119306_(new ModelResourceLocation("minecraft:trident_in_hand#inventory")); + this.m_119306_(new ModelResourceLocation("minecraft:spyglass_in_hand#inventory")); ++ for (ResourceLocation rl : getSpecialModels()) { ++ addModelToCache(rl); ++ } + p_119249_.m_6182_("textures"); + Set> set = Sets.newLinkedHashSet(); + Set set1 = this.f_119214_.values().stream().flatMap((p_119340_) -> { + return p_119340_.m_5500_(this::m_119341_, set).stream(); + }).collect(Collectors.toSet()); + set1.addAll(f_119234_); ++ net.minecraftforge.client.ForgeHooksClient.gatherFluidTextures(set1); + set.stream().filter((p_119357_) -> { + return !p_119357_.getSecond().equals(f_119236_); + }).forEach((p_119292_) -> { +@@ -235,6 +_,7 @@ + try { + bakedmodel = this.m_119349_(p_119369_, BlockModelRotation.X0_Y0); + } catch (Exception exception) { ++ exception.printStackTrace(); + f_119235_.warn("Unable to bake model: '{}': {}", p_119369_, exception); + } + +@@ -474,6 +_,13 @@ + this.f_119210_.addAll(p_119354_.m_7970_()); + } + ++ // Same as loadTopLevel but without restricting to MRL's ++ private void addModelToCache(ResourceLocation p_217843_1_) { ++ UnbakedModel unbakedmodel = this.m_119341_(p_217843_1_); ++ this.f_119212_.put(p_217843_1_, unbakedmodel); ++ this.f_119214_.put(p_217843_1_, unbakedmodel); ++ } ++ + private void m_119306_(ModelResourceLocation p_119307_) { + UnbakedModel unbakedmodel = this.m_119341_(p_119307_); + this.f_119212_.put(p_119307_, unbakedmodel); +@@ -488,7 +_,13 @@ + } + + @Nullable ++ @Deprecated + public BakedModel m_119349_(ResourceLocation p_119350_, ModelState p_119351_) { ++ return bake(p_119350_, p_119351_, this.f_119244_::m_117971_); ++ } ++ ++ @Nullable ++ public BakedModel bake(ResourceLocation p_119350_, ModelState p_119351_, java.util.function.Function sprites) { + Triple triple = Triple.of(p_119350_, p_119351_.m_6189_(), p_119351_.m_7538_()); + if (this.f_119213_.containsKey(triple)) { + return this.f_119213_.get(triple); +@@ -499,11 +_,11 @@ + if (unbakedmodel instanceof BlockModel) { + BlockModel blockmodel = (BlockModel)unbakedmodel; + if (blockmodel.m_111490_() == f_119232_) { +- return f_119241_.m_111670_(this.f_119244_::m_117971_, blockmodel).m_111449_(this, blockmodel, this.f_119244_::m_117971_, p_119351_, p_119350_, false); ++ return f_119241_.m_111670_(sprites, blockmodel).m_111449_(this, blockmodel, this.f_119244_::m_117971_, p_119351_, p_119350_, false); + } + } + +- BakedModel bakedmodel = unbakedmodel.m_7611_(this, this.f_119244_::m_117971_, p_119351_, p_119350_); ++ BakedModel bakedmodel = unbakedmodel.m_7611_(this, sprites, p_119351_, p_119350_); + this.f_119213_.put(triple, bakedmodel); + return bakedmodel; + } +@@ -556,11 +_,19 @@ + return this.f_119218_; + } + ++ public Set getSpecialModels() { ++ return java.util.Collections.emptySet(); ++ } ++ + @OnlyIn(Dist.CLIENT) + static class BlockStateDefinitionException extends RuntimeException { + public BlockStateDefinitionException(String p_119373_) { + super(p_119373_); + } ++ } ++ ++ public AtlasSet getSpriteMap() { ++ return this.f_119244_; + } + + @OnlyIn(Dist.CLIENT) diff --git a/patches/minecraft/net/minecraft/client/resources/model/ModelManager.java.patch b/patches/minecraft/net/minecraft/client/resources/model/ModelManager.java.patch new file mode 100644 index 0000000000..e397af71df --- /dev/null +++ b/patches/minecraft/net/minecraft/client/resources/model/ModelManager.java.patch @@ -0,0 +1,47 @@ +--- a/net/minecraft/client/resources/model/ModelManager.java ++++ b/net/minecraft/client/resources/model/ModelManager.java +@@ -19,7 +_,7 @@ + + @OnlyIn(Dist.CLIENT) + public class ModelManager extends SimplePreparableReloadListener implements AutoCloseable { +- private Map f_119397_; ++ private Map f_119397_ = new java.util.HashMap<>(); + @Nullable + private AtlasSet f_119398_; + private final BlockModelShaper f_119399_; +@@ -36,6 +_,10 @@ + this.f_119399_ = new BlockModelShaper(this); + } + ++ public BakedModel getModel(ResourceLocation modelLocation) { ++ return this.f_119397_.getOrDefault(modelLocation, this.f_119403_); ++ } ++ + public BakedModel m_119422_(ModelResourceLocation p_119423_) { + return this.f_119397_.getOrDefault(p_119423_, this.f_119403_); + } +@@ -50,7 +_,7 @@ + + protected ModelBakery m_5944_(ResourceManager p_119413_, ProfilerFiller p_119414_) { + p_119414_.m_7242_(); +- ModelBakery modelbakery = new ModelBakery(p_119413_, this.f_119401_, p_119414_, this.f_119402_); ++ net.minecraftforge.client.model.ModelLoader modelbakery = new net.minecraftforge.client.model.ModelLoader(p_119413_, this.f_119401_, p_119414_, this.f_119402_); + p_119414_.m_7241_(); + return modelbakery; + } +@@ -66,6 +_,7 @@ + this.f_119397_ = p_119419_.m_119251_(); + this.f_119404_ = p_119419_.m_119355_(); + this.f_119403_ = this.f_119397_.get(ModelBakery.f_119230_); ++ net.minecraftforge.client.ForgeHooksClient.onModelBake(this, this.f_119397_, (net.minecraftforge.client.model.ModelLoader) p_119419_); + p_119421_.m_6182_("cache"); + this.f_119399_.m_110892_(); + p_119421_.m_7238_(); +@@ -91,6 +_,7 @@ + } + + public TextureAtlas m_119428_(ResourceLocation p_119429_) { ++ if (this.f_119398_ == null) throw new RuntimeException("getAtlasTexture called too early!"); + return this.f_119398_.m_117973_(p_119429_); + } + diff --git a/patches/minecraft/net/minecraft/client/resources/model/ModelState.java.patch b/patches/minecraft/net/minecraft/client/resources/model/ModelState.java.patch new file mode 100644 index 0000000000..d3aebed4bd --- /dev/null +++ b/patches/minecraft/net/minecraft/client/resources/model/ModelState.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/client/resources/model/ModelState.java ++++ b/net/minecraft/client/resources/model/ModelState.java +@@ -5,7 +_,7 @@ + import net.minecraftforge.api.distmarker.OnlyIn; + + @OnlyIn(Dist.CLIENT) +-public interface ModelState { ++public interface ModelState extends net.minecraftforge.client.extensions.IForgeModelState { + default Transformation m_6189_() { + return Transformation.m_121093_(); + } diff --git a/patches/minecraft/net/minecraft/client/resources/model/MultiPartBakedModel.java.patch b/patches/minecraft/net/minecraft/client/resources/model/MultiPartBakedModel.java.patch new file mode 100644 index 0000000000..8c418e8104 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/resources/model/MultiPartBakedModel.java.patch @@ -0,0 +1,86 @@ +--- a/net/minecraft/client/resources/model/MultiPartBakedModel.java ++++ b/net/minecraft/client/resources/model/MultiPartBakedModel.java +@@ -21,7 +_,7 @@ + import org.apache.commons.lang3.tuple.Pair; + + @OnlyIn(Dist.CLIENT) +-public class MultiPartBakedModel implements BakedModel { ++public class MultiPartBakedModel implements net.minecraftforge.client.model.data.IDynamicBakedModel { + private final List, BakedModel>> f_119459_; + protected final boolean f_119453_; + protected final boolean f_119454_; +@@ -30,10 +_,12 @@ + protected final ItemTransforms f_119457_; + protected final ItemOverrides f_119458_; + private final Map f_119460_ = new Object2ObjectOpenCustomHashMap<>(Util.m_137583_()); ++ private final BakedModel defaultModel; + + public MultiPartBakedModel(List, BakedModel>> p_119462_) { + this.f_119459_ = p_119462_; + BakedModel bakedmodel = p_119462_.iterator().next().getRight(); ++ this.defaultModel = bakedmodel; + this.f_119453_ = bakedmodel.m_7541_(); + this.f_119454_ = bakedmodel.m_7539_(); + this.f_119455_ = bakedmodel.m_7547_(); +@@ -42,7 +_,8 @@ + this.f_119458_ = bakedmodel.m_7343_(); + } + +- public List m_6840_(@Nullable BlockState p_119465_, @Nullable Direction p_119466_, Random p_119467_) { ++ // FORGE: Implement our overloads (here and below) so child models can have custom logic ++ public List getQuads(@Nullable BlockState p_119465_, @Nullable Direction p_119466_, Random p_119467_, net.minecraftforge.client.model.data.IModelData modelData) { + if (p_119465_ == null) { + return Collections.emptyList(); + } else { +@@ -65,7 +_,7 @@ + + for(int j = 0; j < bitset.length(); ++j) { + if (bitset.get(j)) { +- list.addAll(this.f_119459_.get(j).getRight().m_6840_(p_119465_, p_119466_, new Random(k))); ++ list.addAll(this.f_119459_.get(j).getRight().getQuads(p_119465_, p_119466_, new Random(k), net.minecraftforge.client.model.data.MultipartModelData.resolve(this.f_119459_.get(j).getRight(), modelData))); + } + } + +@@ -77,6 +_,10 @@ + return this.f_119453_; + } + ++ public boolean isAmbientOcclusion(BlockState state) { ++ return this.defaultModel.isAmbientOcclusion(state); ++ } ++ + public boolean m_7539_() { + return this.f_119454_; + } +@@ -89,16 +_,31 @@ + return false; + } + ++ @Deprecated + public TextureAtlasSprite m_6160_() { + return this.f_119456_; + } + ++ public TextureAtlasSprite getParticleIcon(net.minecraftforge.client.model.data.IModelData modelData) { ++ return this.defaultModel.getParticleIcon(modelData); ++ } ++ ++ @Deprecated + public ItemTransforms m_7442_() { + return this.f_119457_; + } + ++ public BakedModel handlePerspective(net.minecraft.client.renderer.block.model.ItemTransforms.TransformType transformType, com.mojang.blaze3d.vertex.PoseStack poseStack) { ++ return this.defaultModel.handlePerspective(transformType, poseStack); ++ } ++ + public ItemOverrides m_7343_() { + return this.f_119458_; ++ } ++ ++ @Override ++ public net.minecraftforge.client.model.data.IModelData getModelData(net.minecraft.world.level.BlockAndTintGetter world, net.minecraft.core.BlockPos pos, BlockState state, net.minecraftforge.client.model.data.IModelData tileData) { ++ return net.minecraftforge.client.model.data.MultipartModelData.create(f_119459_, world, pos, state, tileData); + } + + @OnlyIn(Dist.CLIENT) diff --git a/patches/minecraft/net/minecraft/client/resources/model/SimpleBakedModel.java.patch b/patches/minecraft/net/minecraft/client/resources/model/SimpleBakedModel.java.patch new file mode 100644 index 0000000000..7a9bad2fc9 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/resources/model/SimpleBakedModel.java.patch @@ -0,0 +1,13 @@ +--- a/net/minecraft/client/resources/model/SimpleBakedModel.java ++++ b/net/minecraft/client/resources/model/SimpleBakedModel.java +@@ -81,6 +_,10 @@ + private final boolean f_119514_; + private final ItemTransforms f_119515_; + ++ public Builder(net.minecraftforge.client.model.IModelConfiguration model, ItemOverrides overrides) { ++ this(model.useSmoothLighting(), model.isSideLit(), model.isShadedInGui(), model.getCameraTransforms(), overrides); ++ } ++ + public Builder(BlockModel p_119517_, ItemOverrides p_119518_, boolean p_119519_) { + this(p_119517_.m_111476_(), p_119517_.m_111479_().m_111526_(), p_119519_, p_119517_.m_111491_(), p_119518_); + } diff --git a/patches/minecraft/net/minecraft/client/resources/model/UnbakedModel.java.patch b/patches/minecraft/net/minecraft/client/resources/model/UnbakedModel.java.patch new file mode 100644 index 0000000000..dd44a1f937 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/resources/model/UnbakedModel.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/client/resources/model/UnbakedModel.java ++++ b/net/minecraft/client/resources/model/UnbakedModel.java +@@ -11,7 +_,7 @@ + import net.minecraftforge.api.distmarker.OnlyIn; + + @OnlyIn(Dist.CLIENT) +-public interface UnbakedModel { ++public interface UnbakedModel extends net.minecraftforge.client.extensions.IForgeUnbakedModel { + Collection m_7970_(); + + Collection m_5500_(Function p_119538_, Set> p_119539_); diff --git a/patches/minecraft/net/minecraft/client/resources/model/WeightedBakedModel.java.patch b/patches/minecraft/net/minecraft/client/resources/model/WeightedBakedModel.java.patch new file mode 100644 index 0000000000..8ca8326696 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/resources/model/WeightedBakedModel.java.patch @@ -0,0 +1,55 @@ +--- a/net/minecraft/client/resources/model/WeightedBakedModel.java ++++ b/net/minecraft/client/resources/model/WeightedBakedModel.java +@@ -17,7 +_,7 @@ + import net.minecraftforge.api.distmarker.OnlyIn; + + @OnlyIn(Dist.CLIENT) +-public class WeightedBakedModel implements BakedModel { ++public class WeightedBakedModel implements net.minecraftforge.client.model.data.IDynamicBakedModel { + private final int f_119540_; + private final List> f_119541_; + private final BakedModel f_119542_; +@@ -28,16 +_,22 @@ + this.f_119542_ = p_119544_.get(0).m_146310_(); + } + +- public List m_6840_(@Nullable BlockState p_119547_, @Nullable Direction p_119548_, Random p_119549_) { +- return WeightedRandom.m_146314_(this.f_119541_, Math.abs((int)p_119549_.nextLong()) % this.f_119540_).map((p_174916_) -> { +- return p_174916_.m_146310_().m_6840_(p_119547_, p_119548_, p_119549_); +- }).orElse(Collections.emptyList()); ++ // FORGE: Implement our overloads (here and below) so child models can have custom logic ++ public List getQuads(@Nullable BlockState p_119547_, @Nullable Direction p_119548_, Random p_119549_, net.minecraftforge.client.model.data.IModelData modelData) { ++ return WeightedRandom.m_146314_(this.f_119541_, Math.abs((int)p_119549_.nextLong()) % this.f_119540_).map((p_174916_) -> { ++ return p_174916_.m_146310_().getQuads(p_119547_, p_119548_, p_119549_, modelData); ++ }).orElse(Collections.emptyList()); + } + + public boolean m_7541_() { + return this.f_119542_.m_7541_(); + } + ++ @Override ++ public boolean isAmbientOcclusion(BlockState state) { ++ return this.f_119542_.isAmbientOcclusion(state); ++ } ++ + public boolean m_7539_() { + return this.f_119542_.m_7539_(); + } +@@ -54,8 +_,16 @@ + return this.f_119542_.m_6160_(); + } + ++ public TextureAtlasSprite getParticleIcon(net.minecraftforge.client.model.data.IModelData modelData) { ++ return this.f_119542_.getParticleIcon(modelData); ++ } ++ + public ItemTransforms m_7442_() { + return this.f_119542_.m_7442_(); ++ } ++ ++ public BakedModel handlePerspective(net.minecraft.client.renderer.block.model.ItemTransforms.TransformType transformType, com.mojang.blaze3d.vertex.PoseStack poseStack) { ++ return this.f_119542_.handlePerspective(transformType, poseStack); + } + + public ItemOverrides m_7343_() { diff --git a/patches/minecraft/net/minecraft/client/util/SearchTreeManager.java.patch b/patches/minecraft/net/minecraft/client/searchtree/SearchRegistry.java.patch similarity index 58% rename from patches/minecraft/net/minecraft/client/util/SearchTreeManager.java.patch rename to patches/minecraft/net/minecraft/client/searchtree/SearchRegistry.java.patch index a658e36deb..0d2b47e05b 100644 --- a/patches/minecraft/net/minecraft/client/util/SearchTreeManager.java.patch +++ b/patches/minecraft/net/minecraft/client/searchtree/SearchRegistry.java.patch @@ -1,7 +1,7 @@ ---- a/net/minecraft/client/util/SearchTreeManager.java -+++ b/net/minecraft/client/util/SearchTreeManager.java +--- a/net/minecraft/client/searchtree/SearchRegistry.java ++++ b/net/minecraft/client/searchtree/SearchRegistry.java @@ -31,6 +_,11 @@ - return (IMutableSearchTree)this.field_194013_c.get(p_215358_1_); + return (MutableSearchTree)this.f_119944_.get(p_119950_); } + @Override diff --git a/patches/minecraft/net/minecraft/client/server/IntegratedServer.java.patch b/patches/minecraft/net/minecraft/client/server/IntegratedServer.java.patch new file mode 100644 index 0000000000..e4b13b0ff1 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/server/IntegratedServer.java.patch @@ -0,0 +1,22 @@ +--- a/net/minecraft/client/server/IntegratedServer.java ++++ b/net/minecraft/client/server/IntegratedServer.java +@@ -61,9 +_,10 @@ + this.m_129997_(true); + this.m_129999_(true); + this.m_129793_(); ++ if (!net.minecraftforge.fmllegacy.server.ServerLifecycleHooks.handleServerAboutToStart(this)) return false; + this.m_130006_(); + this.m_129989_(this.m_129791_() + " - " + this.m_129910_().m_5462_()); +- return true; ++ return net.minecraftforge.fmllegacy.server.ServerLifecycleHooks.handleServerStarting(this); + } + + public void m_5705_(BooleanSupplier p_120049_) { +@@ -189,6 +_,7 @@ + } + + public void m_7570_(boolean p_120053_) { ++ if (m_130010_()) + this.m_18709_(() -> { + for(ServerPlayer serverplayer : Lists.newArrayList(this.m_6846_().m_11314_())) { + if (!serverplayer.m_142081_().equals(this.f_120019_)) { diff --git a/patches/minecraft/net/minecraft/client/settings/KeyBinding.java.patch b/patches/minecraft/net/minecraft/client/settings/KeyBinding.java.patch deleted file mode 100644 index 9a6d9cb9e7..0000000000 --- a/patches/minecraft/net/minecraft/client/settings/KeyBinding.java.patch +++ /dev/null @@ -1,196 +0,0 @@ ---- a/net/minecraft/client/settings/KeyBinding.java -+++ b/net/minecraft/client/settings/KeyBinding.java -@@ -15,9 +_,9 @@ - import net.minecraftforge.api.distmarker.OnlyIn; - - @OnlyIn(Dist.CLIENT) --public class KeyBinding implements Comparable { -+public class KeyBinding implements Comparable, net.minecraftforge.client.extensions.IForgeKeybinding { - private static final Map field_74516_a = Maps.newHashMap(); -- private static final Map field_74514_b = Maps.newHashMap(); -+ private static final net.minecraftforge.client.settings.KeyBindingMap field_74514_b = new net.minecraftforge.client.settings.KeyBindingMap(); - private static final Set field_151473_c = Sets.newHashSet(); - private static final Map field_193627_d = Util.func_200696_a(Maps.newHashMap(), (p_205215_0_) -> { - p_205215_0_.put("key.categories.movement", 1); -@@ -36,7 +_,7 @@ - private int field_151474_i; - - public static void func_197981_a(InputMappings.Input p_197981_0_) { -- KeyBinding keybinding = field_74514_b.get(p_197981_0_); -+ KeyBinding keybinding = field_74514_b.lookupActive(p_197981_0_); - if (keybinding != null) { - ++keybinding.field_151474_i; - } -@@ -44,7 +_,7 @@ - } - - public static void func_197980_a(InputMappings.Input p_197980_0_, boolean p_197980_1_) { -- KeyBinding keybinding = field_74514_b.get(p_197980_0_); -+ for (KeyBinding keybinding : field_74514_b.lookupAll(p_197980_0_)) - if (keybinding != null) { - keybinding.func_225593_a_(p_197980_1_); - } -@@ -68,10 +_,10 @@ - } - - public static void func_74508_b() { -- field_74514_b.clear(); -+ field_74514_b.clearMap(); - - for(KeyBinding keybinding : field_74516_a.values()) { -- field_74514_b.put(keybinding.field_74512_d, keybinding); -+ field_74514_b.addKey(keybinding.field_74512_d, keybinding); - } - - } -@@ -86,12 +_,12 @@ - this.field_151472_e = this.field_74512_d; - this.field_151471_f = p_i47675_4_; - field_74516_a.put(p_i47675_1_, this); -- field_74514_b.put(this.field_74512_d, this); -+ field_74514_b.addKey(this.field_74512_d, this); - field_151473_c.add(p_i47675_4_); - } - - public boolean func_151470_d() { -- return this.field_74513_e; -+ return this.field_74513_e && isConflictContextAndModifierActive(); - } - - public String func_151466_e() { -@@ -125,7 +_,13 @@ - } - - public int compareTo(KeyBinding p_compareTo_1_) { -- return this.field_151471_f.equals(p_compareTo_1_.field_151471_f) ? I18n.func_135052_a(this.field_74515_c).compareTo(I18n.func_135052_a(p_compareTo_1_.field_74515_c)) : field_193627_d.get(this.field_151471_f).compareTo(field_193627_d.get(p_compareTo_1_.field_151471_f)); -+ if (this.field_151471_f.equals(p_compareTo_1_.field_151471_f)) return I18n.func_135052_a(this.field_74515_c).compareTo(I18n.func_135052_a(p_compareTo_1_.field_74515_c)); -+ Integer tCat = field_193627_d.get(this.field_151471_f); -+ Integer oCat = field_193627_d.get(p_compareTo_1_.field_151471_f); -+ if (tCat == null && oCat != null) return 1; -+ if (tCat != null && oCat == null) return -1; -+ if (tCat == null && oCat == null) return I18n.func_135052_a(this.field_151471_f).compareTo(I18n.func_135052_a(p_compareTo_1_.field_151471_f)); -+ return tCat.compareTo(oCat); - } - - public static Supplier func_193626_b(String p_193626_0_) { -@@ -136,6 +_,20 @@ - } - - public boolean func_197983_b(KeyBinding p_197983_1_) { -+ if (getKeyConflictContext().conflicts(p_197983_1_.getKeyConflictContext()) || p_197983_1_.getKeyConflictContext().conflicts(getKeyConflictContext())) { -+ net.minecraftforge.client.settings.KeyModifier keyModifier = getKeyModifier(); -+ net.minecraftforge.client.settings.KeyModifier otherKeyModifier = p_197983_1_.getKeyModifier(); -+ if (keyModifier.matches(p_197983_1_.getKey()) || otherKeyModifier.matches(getKey())) { -+ return true; -+ } else if (getKey().equals(p_197983_1_.getKey())) { -+ // IN_GAME key contexts have a conflict when at least one modifier is NONE. -+ // For example: If you hold shift to crouch, you can still press E to open your inventory. This means that a Shift+E hotkey is in conflict with E. -+ // GUI and other key contexts do not have this limitation. -+ return keyModifier == otherKeyModifier || -+ (getKeyConflictContext().conflicts(net.minecraftforge.client.settings.KeyConflictContext.IN_GAME) && -+ (keyModifier == net.minecraftforge.client.settings.KeyModifier.NONE || otherKeyModifier == net.minecraftforge.client.settings.KeyModifier.NONE)); -+ } -+ } - return this.field_74512_d.equals(p_197983_1_.field_74512_d); - } - -@@ -156,11 +_,13 @@ - } - - public ITextComponent func_238171_j_() { -+ return getKeyModifier().getCombinedName(field_74512_d, () -> { - return this.field_74512_d.func_237520_d_(); -+ }); - } - - public boolean func_197985_l() { -- return this.field_74512_d.equals(this.field_151472_e); -+ return this.field_74512_d.equals(this.field_151472_e) && getKeyModifier() == getKeyModifierDefault(); - } - - public String func_197982_m() { -@@ -170,4 +_,84 @@ - public void func_225593_a_(boolean p_225593_1_) { - this.field_74513_e = p_225593_1_; - } -+ -+ /****************** Forge Start *****************************/ -+ private net.minecraftforge.client.settings.KeyModifier keyModifierDefault = net.minecraftforge.client.settings.KeyModifier.NONE; -+ private net.minecraftforge.client.settings.KeyModifier keyModifier = net.minecraftforge.client.settings.KeyModifier.NONE; -+ private net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext = net.minecraftforge.client.settings.KeyConflictContext.UNIVERSAL; -+ -+ /** -+ * Convenience constructor for creating KeyBindings with keyConflictContext set. -+ */ -+ public KeyBinding(String description, net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext, final InputMappings.Type inputType, final int keyCode, String category) { -+ this(description, keyConflictContext, inputType.func_197944_a(keyCode), category); -+ } -+ -+ /** -+ * Convenience constructor for creating KeyBindings with keyConflictContext set. -+ */ -+ public KeyBinding(String description, net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext, InputMappings.Input keyCode, String category) { -+ this(description, keyConflictContext, net.minecraftforge.client.settings.KeyModifier.NONE, keyCode, category); -+ } -+ -+ /** -+ * Convenience constructor for creating KeyBindings with keyConflictContext and keyModifier set. -+ */ -+ public KeyBinding(String description, net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext, net.minecraftforge.client.settings.KeyModifier keyModifier, final InputMappings.Type inputType, final int keyCode, String category) { -+ this(description, keyConflictContext, keyModifier, inputType.func_197944_a(keyCode), category); -+ } -+ -+ /** -+ * Convenience constructor for creating KeyBindings with keyConflictContext and keyModifier set. -+ */ -+ public KeyBinding(String description, net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext, net.minecraftforge.client.settings.KeyModifier keyModifier, InputMappings.Input keyCode, String category) { -+ this.field_74515_c = description; -+ this.field_74512_d = keyCode; -+ this.field_151472_e = keyCode; -+ this.field_151471_f = category; -+ this.keyConflictContext = keyConflictContext; -+ this.keyModifier = keyModifier; -+ this.keyModifierDefault = keyModifier; -+ if (this.keyModifier.matches(keyCode)) -+ this.keyModifier = net.minecraftforge.client.settings.KeyModifier.NONE; -+ field_74516_a.put(description, this); -+ field_74514_b.addKey(keyCode, this); -+ field_151473_c.add(category); -+ } -+ -+ @Override -+ public InputMappings.Input getKey() { -+ return this.field_74512_d; -+ } -+ -+ @Override -+ public void setKeyConflictContext(net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext) { -+ this.keyConflictContext = keyConflictContext; -+ } -+ -+ @Override -+ public net.minecraftforge.client.settings.IKeyConflictContext getKeyConflictContext() { -+ return keyConflictContext; -+ } -+ -+ @Override -+ public net.minecraftforge.client.settings.KeyModifier getKeyModifierDefault() { -+ return keyModifierDefault; -+ } -+ -+ @Override -+ public net.minecraftforge.client.settings.KeyModifier getKeyModifier() { -+ return keyModifier; -+ } -+ -+ @Override -+ public void setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier keyModifier, InputMappings.Input keyCode) { -+ this.field_74512_d = keyCode; -+ if (keyModifier.matches(keyCode)) -+ keyModifier = net.minecraftforge.client.settings.KeyModifier.NONE; -+ field_74514_b.removeKey(this); -+ this.keyModifier = keyModifier; -+ field_74514_b.addKey(keyCode, this); -+ } -+ /****************** Forge End *****************************/ - } diff --git a/patches/minecraft/net/minecraft/client/settings/ToggleableKeyBinding.java.patch b/patches/minecraft/net/minecraft/client/settings/ToggleableKeyBinding.java.patch deleted file mode 100644 index 2490362ac9..0000000000 --- a/patches/minecraft/net/minecraft/client/settings/ToggleableKeyBinding.java.patch +++ /dev/null @@ -1,17 +0,0 @@ ---- a/net/minecraft/client/settings/ToggleableKeyBinding.java -+++ b/net/minecraft/client/settings/ToggleableKeyBinding.java -@@ -16,7 +_,7 @@ - - public void func_225593_a_(boolean p_225593_1_) { - if (this.field_228053_a_.getAsBoolean()) { -- if (p_225593_1_) { -+ if (p_225593_1_ && isConflictContextAndModifierActive()) { - super.func_225593_a_(!this.func_151470_d()); - } - } else { -@@ -24,4 +_,5 @@ - } - - } -+ @Override public boolean func_151470_d() { return this.field_74513_e && (isConflictContextAndModifierActive() || field_228053_a_.getAsBoolean()); } - } diff --git a/patches/minecraft/net/minecraft/client/shader/Framebuffer.java.patch b/patches/minecraft/net/minecraft/client/shader/Framebuffer.java.patch deleted file mode 100644 index cdaab7c312..0000000000 --- a/patches/minecraft/net/minecraft/client/shader/Framebuffer.java.patch +++ /dev/null @@ -1,61 +0,0 @@ ---- a/net/minecraft/client/shader/Framebuffer.java -+++ b/net/minecraft/client/shader/Framebuffer.java -@@ -118,7 +_,10 @@ - GlStateManager.func_227677_b_(3553, 10242, 10496); - GlStateManager.func_227677_b_(3553, 10243, 10496); - GlStateManager.func_227677_b_(3553, 34892, 0); -+ if (!stencilEnabled) - GlStateManager.func_227647_a_(3553, 0, 6402, this.field_147622_a, this.field_147620_b, 0, 6402, 5126, (IntBuffer)null); -+ else -+ GlStateManager.func_227647_a_(3553, 0, org.lwjgl.opengl.GL30.GL_DEPTH32F_STENCIL8, this.field_147622_a, this.field_147620_b, 0, org.lwjgl.opengl.GL30.GL_DEPTH_STENCIL, org.lwjgl.opengl.GL30.GL_FLOAT_32_UNSIGNED_INT_24_8_REV, null); - } - - this.func_147607_a(9728); -@@ -127,7 +_,14 @@ - GlStateManager.func_227727_h_(FramebufferConstants.field_227592_a_, this.field_147616_f); - GlStateManager.func_227645_a_(FramebufferConstants.field_227592_a_, FramebufferConstants.field_227594_c_, 3553, this.field_147617_g, 0); - if (this.field_147619_e) { -+ if(!stencilEnabled) - GlStateManager.func_227645_a_(FramebufferConstants.field_227592_a_, FramebufferConstants.field_227595_d_, 3553, this.field_147624_h, 0); -+ else if(net.minecraftforge.common.ForgeConfig.CLIENT.useCombinedDepthStencilAttachment.get()) { -+ GlStateManager.func_227645_a_(FramebufferConstants.field_227592_a_, org.lwjgl.opengl.GL30.GL_DEPTH_STENCIL_ATTACHMENT, 3553, this.field_147624_h, 0); -+ } else { -+ GlStateManager.func_227645_a_(FramebufferConstants.field_227592_a_, org.lwjgl.opengl.GL30.GL_DEPTH_ATTACHMENT, 3553, this.field_147624_h, 0); -+ GlStateManager.func_227645_a_(FramebufferConstants.field_227592_a_, org.lwjgl.opengl.GL30.GL_STENCIL_ATTACHMENT, 3553, this.field_147624_h, 0); -+ } - } - - this.func_147611_b(); -@@ -280,6 +_,32 @@ - GlStateManager.func_227658_a_(i, p_216493_1_); - this.func_147609_e(); - } -+ -+ -+ /*================================ FORGE START ================================================*/ -+ private boolean stencilEnabled = false; -+ /** -+ * Attempts to enable 8 bits of stencil buffer on this FrameBuffer. -+ * Modders must call this directly to set things up. -+ * This is to prevent the default cause where graphics cards do not support stencil bits. -+ * Make sure to call this on the main render thread! -+ */ -+ public void enableStencil() -+ { -+ if(stencilEnabled) return; -+ stencilEnabled = true; -+ this.func_216491_a(field_147621_c, field_147618_d, net.minecraft.client.Minecraft.field_142025_a); -+ } -+ -+ /** -+ * Returns wither or not this FBO has been successfully initialized with stencil bits. -+ * If not, and a modder wishes it to be, they must call enableStencil. -+ */ -+ public boolean isStencilEnabled() -+ { -+ return this.stencilEnabled; -+ } -+ /*================================ FORGE END ================================================*/ - - public int func_242996_f() { - return this.field_147617_g; diff --git a/patches/minecraft/net/minecraft/client/shader/ShaderGroup.java.patch b/patches/minecraft/net/minecraft/client/shader/ShaderGroup.java.patch deleted file mode 100644 index fa07e94242..0000000000 --- a/patches/minecraft/net/minecraft/client/shader/ShaderGroup.java.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/net/minecraft/client/shader/ShaderGroup.java -+++ b/net/minecraft/client/shader/ShaderGroup.java -@@ -164,7 +_,8 @@ - throw new JSONException("Render target '" + s4 + "' can't be used as depth buffer"); - } - -- ResourceLocation resourcelocation = new ResourceLocation("textures/effect/" + s4 + ".png"); -+ ResourceLocation rl = ResourceLocation.func_208304_a(s4); -+ ResourceLocation resourcelocation = new ResourceLocation(rl.func_110624_b(), "textures/effect/" + rl.func_110623_a() + ".png"); - IResource iresource = null; - - try { diff --git a/patches/minecraft/net/minecraft/client/shader/ShaderInstance.java.patch b/patches/minecraft/net/minecraft/client/shader/ShaderInstance.java.patch deleted file mode 100644 index e15b693e17..0000000000 --- a/patches/minecraft/net/minecraft/client/shader/ShaderInstance.java.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- a/net/minecraft/client/shader/ShaderInstance.java -+++ b/net/minecraft/client/shader/ShaderInstance.java -@@ -51,7 +_,8 @@ - private final ShaderLoader field_216563_s; - - public ShaderInstance(IResourceManager p_i50988_1_, String p_i50988_2_) throws IOException { -- ResourceLocation resourcelocation = new ResourceLocation("shaders/program/" + p_i50988_2_ + ".json"); -+ ResourceLocation rl = ResourceLocation.func_208304_a(p_i50988_2_); -+ ResourceLocation resourcelocation = new ResourceLocation(rl.func_110624_b(), "shaders/program/" + rl.func_110623_a() + ".json"); - this.field_216556_l = p_i50988_2_; - IResource iresource = null; - -@@ -149,7 +_,8 @@ - public static ShaderLoader func_216542_a(IResourceManager p_216542_0_, ShaderLoader.ShaderType p_216542_1_, String p_216542_2_) throws IOException { - ShaderLoader shaderloader = p_216542_1_.func_148064_d().get(p_216542_2_); - if (shaderloader == null) { -- ResourceLocation resourcelocation = new ResourceLocation("shaders/program/" + p_216542_2_ + p_216542_1_.func_148063_b()); -+ ResourceLocation rl = ResourceLocation.func_208304_a(p_216542_2_); -+ ResourceLocation resourcelocation = new ResourceLocation(rl.func_110624_b(), "shaders/program/" + rl.func_110623_a() + p_216542_1_.func_148063_b()); - IResource iresource = p_216542_0_.func_199002_a(resourcelocation); - - try { diff --git a/patches/minecraft/net/minecraft/client/sounds/SoundEngine.java.patch b/patches/minecraft/net/minecraft/client/sounds/SoundEngine.java.patch new file mode 100644 index 0000000000..ca26623c22 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/sounds/SoundEngine.java.patch @@ -0,0 +1,50 @@ +--- a/net/minecraft/client/sounds/SoundEngine.java ++++ b/net/minecraft/client/sounds/SoundEngine.java +@@ -68,6 +_,7 @@ + this.f_120217_ = p_120236_; + this.f_120218_ = p_120237_; + this.f_120222_ = new SoundBufferLibrary(p_120238_); ++ net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.client.event.sound.SoundLoadEvent(this)); + } + + public void m_120239_() { +@@ -83,6 +_,7 @@ + + this.m_120304_(); + this.m_120323_(); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.sound.SoundLoadEvent(this)); + } + + private synchronized void m_120323_() { +@@ -278,7 +_,8 @@ + + public void m_120312_(SoundInstance p_120313_) { + if (this.f_120219_) { +- if (p_120313_.m_7767_()) { ++ p_120313_ = net.minecraftforge.client.ForgeHooksClient.playSound(this, p_120313_); ++ if (p_120313_ != null && p_120313_.m_7767_()) { + WeighedSoundEvents weighedsoundevents = p_120313_.m_6775_(this.f_120217_); + ResourceLocation resourcelocation = p_120313_.m_7904_(); + if (weighedsoundevents == null) { +@@ -343,11 +_,13 @@ + p_120254_.m_83654_(vec3); + p_120254_.m_83670_(flag); + }); ++ final SoundInstance soundinstance = p_120313_; + if (!flag3) { + this.f_120222_.m_120202_(sound.m_119790_()).thenAccept((p_120291_) -> { + channelaccess$channelhandle.m_120154_((p_174993_) -> { + p_174993_.m_83656_(p_120291_); + p_174993_.m_83672_(); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.sound.PlaySoundSourceEvent(this, soundinstance, p_174993_)); + }); + }); + } else { +@@ -355,6 +_,7 @@ + channelaccess$channelhandle.m_120154_((p_174996_) -> { + p_174996_.m_83658_(p_120294_); + p_174996_.m_83672_(); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.sound.PlayStreamingSourceEvent(this, soundinstance, p_174996_)); + }); + }); + } diff --git a/patches/minecraft/net/minecraft/client/world/ClientWorld.java.patch b/patches/minecraft/net/minecraft/client/world/ClientWorld.java.patch deleted file mode 100644 index 441f0b5bbc..0000000000 --- a/patches/minecraft/net/minecraft/client/world/ClientWorld.java.patch +++ /dev/null @@ -1,72 +0,0 @@ ---- a/net/minecraft/client/world/ClientWorld.java -+++ b/net/minecraft/client/world/ClientWorld.java -@@ -104,6 +_,8 @@ - this.func_239136_a_(new BlockPos(8, 64, 8), 0.0F); - this.func_72966_v(); - this.func_72947_a(); -+ this.gatherCapabilities(); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Load(this)); - } - - public DimensionRenderInfo func_239132_a_() { -@@ -186,6 +_,7 @@ - this.func_217381_Z().func_194340_a(() -> { - return Registry.field_212629_r.func_177774_c(p_217418_1_.func_200600_R()).toString(); - }); -+ if (p_217418_1_.canUpdate()) - p_217418_1_.func_70071_h_(); - this.func_217381_Z().func_76319_b(); - } -@@ -285,9 +_,11 @@ - } - - private void func_217424_b(int p_217424_1_, Entity p_217424_2_) { -+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityJoinWorldEvent(p_217424_2_, this))) return; - this.func_217413_d(p_217424_1_); - this.field_217429_b.put(p_217424_1_, p_217424_2_); - this.func_72863_F().func_212849_a_(MathHelper.func_76128_c(p_217424_2_.func_226277_ct_() / 16.0D), MathHelper.func_76128_c(p_217424_2_.func_226281_cx_() / 16.0D), ChunkStatus.field_222617_m, true).func_76612_a(p_217424_2_); -+ p_217424_2_.onAddedToWorld(); - } - - public void func_217413_d(int p_217413_1_) { -@@ -306,6 +_,8 @@ - } - - this.field_217431_w.remove(p_217414_1_); -+ p_217414_1_.onRemovedFromWorld(); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityLeaveWorldEvent(p_217414_1_, this)); - } - - public void func_217417_b(Chunk p_217417_1_) { -@@ -448,6 +_,11 @@ - } - - public void func_184148_a(@Nullable PlayerEntity p_184148_1_, double p_184148_2_, double p_184148_4_, double p_184148_6_, SoundEvent p_184148_8_, SoundCategory p_184148_9_, float p_184148_10_, float p_184148_11_) { -+ net.minecraftforge.event.entity.PlaySoundAtEntityEvent event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtEntity(p_184148_1_, p_184148_8_, p_184148_9_, p_184148_10_, p_184148_11_); -+ if (event.isCanceled() || event.getSound() == null) return; -+ p_184148_8_ = event.getSound(); -+ p_184148_9_ = event.getCategory(); -+ p_184148_10_ = event.getVolume(); - if (p_184148_1_ == this.field_73037_M.field_71439_g) { - this.func_184134_a(p_184148_2_, p_184148_4_, p_184148_6_, p_184148_8_, p_184148_9_, p_184148_10_, p_184148_11_, false); - } -@@ -455,6 +_,11 @@ - } - - public void func_217384_a(@Nullable PlayerEntity p_217384_1_, Entity p_217384_2_, SoundEvent p_217384_3_, SoundCategory p_217384_4_, float p_217384_5_, float p_217384_6_) { -+ net.minecraftforge.event.entity.PlaySoundAtEntityEvent event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtEntity(p_217384_1_, p_217384_3_, p_217384_4_, p_217384_5_, p_217384_6_); -+ if (event.isCanceled() || event.getSound() == null) return; -+ p_217384_3_ = event.getSound(); -+ p_217384_4_ = event.getCategory(); -+ p_217384_5_ = event.getVolume(); - if (p_217384_1_ == this.field_73037_M.field_71439_g) { - this.field_73037_M.func_147118_V().func_147682_a(new EntityTickableSound(p_217384_3_, p_217384_4_, p_217384_2_)); - } -@@ -876,6 +_,7 @@ - } - - public void func_239156_a_(Difficulty p_239156_1_) { -+ net.minecraftforge.common.ForgeHooks.onDifficultyChange(p_239156_1_, this.field_239153_j_); - this.field_239153_j_ = p_239156_1_; - } - diff --git a/patches/minecraft/net/minecraft/command/Commands.java.patch b/patches/minecraft/net/minecraft/command/Commands.java.patch deleted file mode 100644 index 2c08f0ca61..0000000000 --- a/patches/minecraft/net/minecraft/command/Commands.java.patch +++ /dev/null @@ -1,27 +0,0 @@ ---- a/net/minecraft/command/Commands.java -+++ b/net/minecraft/command/Commands.java -@@ -186,6 +_,7 @@ - if (p_i232148_1_.field_237219_d_) { - PublishCommand.func_198581_a(this.field_197062_b); - } -+ net.minecraftforge.event.ForgeEventFactory.onCommandRegister(this.field_197062_b, p_i232148_1_); - - this.field_197062_b.findAmbiguities((p_201302_1_, p_201302_2_, p_201302_3_, p_201302_4_) -> { - field_197061_a.warn("Ambiguity between arguments {} and {} with inputs: {}", this.field_197062_b.getPath(p_201302_2_), this.field_197062_b.getPath(p_201302_3_), p_201302_4_); -@@ -205,7 +_,15 @@ - - try { - try { -- return this.field_197062_b.execute(stringreader, p_197059_1_); -+ ParseResults parse = this.field_197062_b.parse(stringreader, p_197059_1_); -+ net.minecraftforge.event.CommandEvent event = new net.minecraftforge.event.CommandEvent(parse); -+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) { -+ if (event.getException() != null) { -+ com.google.common.base.Throwables.throwIfUnchecked(event.getException()); -+ } -+ return 1; -+ } -+ return this.field_197062_b.execute(event.getParseResults()); - } catch (CommandException commandexception) { - p_197059_1_.func_197021_a(commandexception.func_197003_a()); - return 0; diff --git a/patches/minecraft/net/minecraft/command/arguments/ArgumentTypes.java.patch b/patches/minecraft/net/minecraft/command/arguments/ArgumentTypes.java.patch deleted file mode 100644 index 2991a1e760..0000000000 --- a/patches/minecraft/net/minecraft/command/arguments/ArgumentTypes.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/command/arguments/ArgumentTypes.java -+++ b/net/minecraft/command/arguments/ArgumentTypes.java -@@ -220,4 +_,8 @@ - this.field_197481_c = p_i48088_3_; - } - } -+ @javax.annotation.Nullable public static ResourceLocation getId(ArgumentType type) { -+ Entry entry = func_201040_a(type); -+ return entry == null ? null : entry.field_197481_c; -+ } - } diff --git a/patches/minecraft/net/minecraft/command/arguments/BlockStateParser.java.patch b/patches/minecraft/net/minecraft/command/arguments/BlockStateParser.java.patch deleted file mode 100644 index 6eea99958b..0000000000 --- a/patches/minecraft/net/minecraft/command/arguments/BlockStateParser.java.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/command/arguments/BlockStateParser.java -+++ b/net/minecraft/command/arguments/BlockStateParser.java -@@ -169,7 +_,7 @@ - - private boolean func_212598_k(ITagCollection p_212598_1_) { - if (this.field_197270_l != null) { -- return this.field_197270_l.func_177230_c().func_235695_q_(); -+ return this.field_197270_l.hasTileEntity(); - } else { - if (this.field_199833_p != null) { - ITag itag = p_212598_1_.func_199910_a(this.field_199833_p); -@@ -283,7 +_,7 @@ - p_197255_1_.suggest(String.valueOf('[')); - } - -- if (this.field_197270_l.func_177230_c().func_235695_q_()) { -+ if (this.field_197270_l.hasTileEntity()) { - p_197255_1_.suggest(String.valueOf('{')); - } - } diff --git a/patches/minecraft/net/minecraft/command/arguments/EntitySelectorParser.java.patch b/patches/minecraft/net/minecraft/command/arguments/EntitySelectorParser.java.patch deleted file mode 100644 index 720da88a5b..0000000000 --- a/patches/minecraft/net/minecraft/command/arguments/EntitySelectorParser.java.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/command/arguments/EntitySelectorParser.java -+++ b/net/minecraft/command/arguments/EntitySelectorParser.java -@@ -448,6 +_,9 @@ - } - - this.field_197417_j.skip(); -+ EntitySelector forgeSelector = net.minecraftforge.common.command.EntitySelectorManager.parseSelector(this); -+ if (forgeSelector != null) -+ return forgeSelector; - this.func_197403_b(); - } else { - this.func_197382_c(); -@@ -463,6 +_,7 @@ - p_210326_0_.suggest("@r", new TranslationTextComponent("argument.entity.selector.randomPlayer")); - p_210326_0_.suggest("@s", new TranslationTextComponent("argument.entity.selector.self")); - p_210326_0_.suggest("@e", new TranslationTextComponent("argument.entity.selector.allEntities")); -+ net.minecraftforge.common.command.EntitySelectorManager.fillSelectorSuggestions(p_210326_0_); - } - - private CompletableFuture func_201981_b(SuggestionsBuilder p_201981_1_, Consumer p_201981_2_) { diff --git a/patches/minecraft/net/minecraft/command/impl/LocateCommand.java.patch b/patches/minecraft/net/minecraft/command/impl/LocateCommand.java.patch deleted file mode 100644 index d9bd5fa43f..0000000000 --- a/patches/minecraft/net/minecraft/command/impl/LocateCommand.java.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- a/net/minecraft/command/impl/LocateCommand.java -+++ b/net/minecraft/command/impl/LocateCommand.java -@@ -25,11 +_,18 @@ - return p_198533_0_.func_197034_c(2); - }); - -+ if (false) - for(Entry> entry : Structure.field_236365_a_.entrySet()) { - literalargumentbuilder = literalargumentbuilder.then(Commands.func_197057_a(entry.getKey()).executes((p_241056_1_) -> { - return func_241053_a_(p_241056_1_.getSource(), entry.getValue()); - })); - } -+ else { -+ for (Structure structureFeature : net.minecraftforge.registries.ForgeRegistries.STRUCTURE_FEATURES) { -+ String name = structureFeature.getRegistryName().toString().replace("minecraft:", ""); -+ literalargumentbuilder = literalargumentbuilder.then(Commands.func_197057_a(name) -+ .executes(ctx -> func_241053_a_(ctx.getSource(), structureFeature))); -+ }} - - p_198528_0_.register(literalargumentbuilder); - } diff --git a/patches/minecraft/net/minecraft/command/impl/SpreadPlayersCommand.java.patch b/patches/minecraft/net/minecraft/command/impl/SpreadPlayersCommand.java.patch deleted file mode 100644 index ad41620595..0000000000 --- a/patches/minecraft/net/minecraft/command/impl/SpreadPlayersCommand.java.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/net/minecraft/command/impl/SpreadPlayersCommand.java -+++ b/net/minecraft/command/impl/SpreadPlayersCommand.java -@@ -162,7 +_,8 @@ - spreadplayerscommand$position = p_241072_2_[i++]; - } - -- entity.func_223102_j((double)MathHelper.func_76128_c(spreadplayerscommand$position.field_198713_a) + 0.5D, (double)spreadplayerscommand$position.func_198710_a(p_241072_1_, p_241072_3_), (double)MathHelper.func_76128_c(spreadplayerscommand$position.field_198714_b) + 0.5D); -+ net.minecraftforge.event.entity.living.EntityTeleportEvent.SpreadPlayersCommand event = net.minecraftforge.event.ForgeEventFactory.onEntityTeleportSpreadPlayersCommand(entity, (double)MathHelper.func_76128_c(spreadplayerscommand$position.field_198713_a) + 0.5D, (double)spreadplayerscommand$position.func_198710_a(p_241072_1_, p_241072_3_), (double)MathHelper.func_76128_c(spreadplayerscommand$position.field_198714_b) + 0.5D); -+ if (!event.isCanceled()) entity.func_223102_j(event.getTargetX(), event.getTargetY(), event.getTargetZ()); - double d2 = Double.MAX_VALUE; - - for(SpreadPlayersCommand.Position spreadplayerscommand$position1 : p_241072_2_) { diff --git a/patches/minecraft/net/minecraft/command/impl/TeleportCommand.java.patch b/patches/minecraft/net/minecraft/command/impl/TeleportCommand.java.patch deleted file mode 100644 index e1e7468893..0000000000 --- a/patches/minecraft/net/minecraft/command/impl/TeleportCommand.java.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/command/impl/TeleportCommand.java -+++ b/net/minecraft/command/impl/TeleportCommand.java -@@ -121,6 +_,9 @@ - } - - private static void func_201127_a(CommandSource p_201127_0_, Entity p_201127_1_, ServerWorld p_201127_2_, double p_201127_3_, double p_201127_5_, double p_201127_7_, Set p_201127_9_, float p_201127_10_, float p_201127_11_, @Nullable TeleportCommand.Facing p_201127_12_) throws CommandSyntaxException { -+ net.minecraftforge.event.entity.living.EntityTeleportEvent.TeleportCommand event = net.minecraftforge.event.ForgeEventFactory.onEntityTeleportCommand(p_201127_1_, p_201127_3_, p_201127_5_, p_201127_7_); -+ if (event.isCanceled()) return; -+ p_201127_3_ = event.getTargetX(); p_201127_5_ = event.getTargetY(); p_201127_7_ = event.getTargetZ(); - BlockPos blockpos = new BlockPos(p_201127_3_, p_201127_5_, p_201127_7_); - if (!World.func_234935_k_(blockpos)) { - throw field_241077_a_.create(); -@@ -159,7 +_,6 @@ - p_201127_1_.func_70012_b(p_201127_3_, p_201127_5_, p_201127_7_, f1, f); - p_201127_1_.func_70034_d(f1); - p_201127_2_.func_217460_e(p_201127_1_); -- entity.field_70128_L = true; - } - } - diff --git a/patches/minecraft/net/minecraft/commands/Commands.java.patch b/patches/minecraft/net/minecraft/commands/Commands.java.patch new file mode 100644 index 0000000000..dbf46d6ee1 --- /dev/null +++ b/patches/minecraft/net/minecraft/commands/Commands.java.patch @@ -0,0 +1,27 @@ +--- a/net/minecraft/commands/Commands.java ++++ b/net/minecraft/commands/Commands.java +@@ -193,6 +_,7 @@ + if (p_82093_.f_82144_) { + PublishCommand.m_138184_(this.f_82090_); + } ++ net.minecraftforge.event.ForgeEventFactory.onCommandRegister(this.f_82090_, p_82093_); + + this.f_82090_.findAmbiguities((p_82108_, p_82109_, p_82110_, p_82111_) -> { + f_82089_.warn("Ambiguity between arguments {} and {} with inputs: {}", this.f_82090_.getPath(p_82109_), this.f_82090_.getPath(p_82110_), p_82111_); +@@ -212,7 +_,15 @@ + + try { + try { +- return this.f_82090_.execute(stringreader, p_82118_); ++ ParseResults parse = this.f_82090_.parse(stringreader, p_82118_); ++ net.minecraftforge.event.CommandEvent event = new net.minecraftforge.event.CommandEvent(parse); ++ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) { ++ if (event.getException() != null) { ++ com.google.common.base.Throwables.throwIfUnchecked(event.getException()); ++ } ++ return 1; ++ } ++ return this.f_82090_.execute(event.getParseResults()); + } catch (CommandRuntimeException commandruntimeexception) { + p_82118_.m_81352_(commandruntimeexception.m_79226_()); + return 0; diff --git a/patches/minecraft/net/minecraft/commands/arguments/selector/EntitySelectorParser.java.patch b/patches/minecraft/net/minecraft/commands/arguments/selector/EntitySelectorParser.java.patch new file mode 100644 index 0000000000..48f0f7e802 --- /dev/null +++ b/patches/minecraft/net/minecraft/commands/arguments/selector/EntitySelectorParser.java.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/commands/arguments/selector/EntitySelectorParser.java ++++ b/net/minecraft/commands/arguments/selector/EntitySelectorParser.java +@@ -461,6 +_,9 @@ + } + + this.f_121201_.skip(); ++ EntitySelector forgeSelector = net.minecraftforge.common.command.EntitySelectorManager.parseSelector(this); ++ if (forgeSelector != null) ++ return forgeSelector; + this.m_121281_(); + } else { + this.m_121304_(); +@@ -476,6 +_,7 @@ + p_121248_.suggest("@r", new TranslatableComponent("argument.entity.selector.randomPlayer")); + p_121248_.suggest("@s", new TranslatableComponent("argument.entity.selector.self")); + p_121248_.suggest("@e", new TranslatableComponent("argument.entity.selector.allEntities")); ++ net.minecraftforge.common.command.EntitySelectorManager.fillSelectorSuggestions(p_121248_); + } + + private CompletableFuture m_121286_(SuggestionsBuilder p_121287_, Consumer p_121288_) { diff --git a/patches/minecraft/net/minecraft/commands/synchronization/ArgumentTypes.java.patch b/patches/minecraft/net/minecraft/commands/synchronization/ArgumentTypes.java.patch new file mode 100644 index 0000000000..f4bbb6c7d4 --- /dev/null +++ b/patches/minecraft/net/minecraft/commands/synchronization/ArgumentTypes.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/commands/synchronization/ArgumentTypes.java ++++ b/net/minecraft/commands/synchronization/ArgumentTypes.java +@@ -257,4 +_,8 @@ + this.f_121620_ = p_121624_; + } + } ++ @javax.annotation.Nullable public static ResourceLocation getId(ArgumentType type) { ++ Entry entry = m_121616_(type); ++ return entry == null ? null : entry.f_121620_; ++ } + } diff --git a/patches/minecraft/net/minecraft/core/MappedRegistry.java.patch b/patches/minecraft/net/minecraft/core/MappedRegistry.java.patch new file mode 100644 index 0000000000..efc8d5733a --- /dev/null +++ b/patches/minecraft/net/minecraft/core/MappedRegistry.java.patch @@ -0,0 +1,12 @@ +--- a/net/minecraft/core/MappedRegistry.java ++++ b/net/minecraft/core/MappedRegistry.java +@@ -219,7 +_,8 @@ + } + + public static Codec> m_122756_(ResourceKey> p_122757_, Lifecycle p_122758_, Codec p_122759_) { +- return Codec.unboundedMap(ResourceLocation.f_135803_.xmap(ResourceKey.m_135797_(p_122757_), ResourceKey::m_135782_), p_122759_).xmap((p_122726_) -> { ++ // FORGE: Fix MC-197860 ++ return new net.minecraftforge.common.LenientUnboundedMapCodec<>(ResourceLocation.f_135803_.xmap(ResourceKey.m_135797_(p_122757_), ResourceKey::m_135782_), p_122759_).xmap((p_122726_) -> { + MappedRegistry mappedregistry = new MappedRegistry<>(p_122757_, p_122758_); + p_122726_.forEach((p_175387_, p_175388_) -> { + mappedregistry.m_7135_(p_175387_, p_175388_, p_122758_); diff --git a/patches/minecraft/net/minecraft/core/Registry.java.patch b/patches/minecraft/net/minecraft/core/Registry.java.patch new file mode 100644 index 0000000000..c9489bce69 --- /dev/null +++ b/patches/minecraft/net/minecraft/core/Registry.java.patch @@ -0,0 +1,213 @@ +--- a/net/minecraft/core/Registry.java ++++ b/net/minecraft/core/Registry.java +@@ -105,6 +_,10 @@ + import org.apache.logging.log4j.LogManager; + import org.apache.logging.log4j.Logger; + ++/* ++ * Attention Modders: This SHOULD NOT be used, you should use ForgeRegistries instead. As it has a cleaner modder facing API. ++ * We will be wrapping all of these in our API as necessary for syncing and management. ++ */ + public abstract class Registry implements Codec, Keyable, IdMap { + protected static final Logger f_122894_ = LogManager.getLogger(); + private static final Map> f_122834_ = Maps.newLinkedHashMap(); +@@ -152,43 +_,43 @@ + public static final DefaultedRegistry f_175412_ = m_122995_(f_175423_, "step", () -> { + return GameEvent.f_157785_; + }); +- public static final Registry f_122821_ = m_122999_(f_122898_, () -> { ++ @Deprecated public static final Registry f_122821_ = forge(f_122898_, () -> { + return SoundEvents.f_12019_; + }); +- public static final DefaultedRegistry f_122822_ = m_122995_(f_122899_, "empty", () -> { ++ @Deprecated public static final DefaultedRegistry f_122822_ = forge(f_122899_, "empty", () -> { + return Fluids.f_76191_; + }); +- public static final Registry f_122823_ = m_122999_(f_122900_, () -> { ++ @Deprecated public static final Registry f_122823_ = forge(f_122900_, () -> { + return MobEffects.f_19621_; + }); +- public static final DefaultedRegistry f_122824_ = m_122995_(f_122901_, "air", () -> { ++ @Deprecated public static final DefaultedRegistry f_122824_ = forge(f_122901_, "air", () -> { + return Blocks.f_50016_; + }); +- public static final Registry f_122825_ = m_122999_(f_122902_, () -> { ++ @Deprecated public static final Registry f_122825_ = forge(f_122902_, () -> { + return Enchantments.f_44987_; + }); +- public static final DefaultedRegistry> f_122826_ = m_122995_(f_122903_, "pig", () -> { ++ @Deprecated public static final DefaultedRegistry> f_122826_ = forge(f_122903_, "pig", () -> { + return EntityType.f_20510_; + }); +- public static final DefaultedRegistry f_122827_ = m_122995_(f_122904_, "air", () -> { ++ @Deprecated public static final DefaultedRegistry f_122827_ = forge(f_122904_, "air", () -> { + return Items.f_41852_; + }); +- public static final DefaultedRegistry f_122828_ = m_122995_(f_122905_, "empty", () -> { ++ @Deprecated public static final DefaultedRegistry f_122828_ = forge(f_122905_, "empty", () -> { + return Potions.f_43598_; + }); +- public static final Registry> f_122829_ = m_122999_(f_122906_, () -> { ++ @Deprecated public static final Registry> f_122829_ = forge(f_122906_, () -> { + return ParticleTypes.f_123794_; + }); +- public static final Registry> f_122830_ = m_122999_(f_122907_, () -> { ++ @Deprecated public static final Registry> f_122830_ = forge(f_122907_, () -> { + return BlockEntityType.f_58917_; + }); +- public static final DefaultedRegistry f_122831_ = m_122995_(f_122908_, "kebab", () -> { ++ @Deprecated public static final DefaultedRegistry f_122831_ = forge(f_122908_, "kebab", () -> { + return Motive.f_31866_; + }); + public static final Registry f_122832_ = m_122999_(f_122909_, () -> { + return Stats.f_12926_; + }); +- public static final DefaultedRegistry f_122833_ = m_122995_(f_122910_, "empty", () -> { ++ @Deprecated public static final DefaultedRegistry f_122833_ = forge(f_122910_, "empty", () -> { + return ChunkStatus.f_62314_; + }); + public static final Registry> f_122861_ = m_122999_(f_122911_, () -> { +@@ -197,43 +_,43 @@ + public static final Registry> f_122862_ = m_122999_(f_122912_, () -> { + return PosRuleTestType.f_74205_; + }); +- public static final Registry> f_122863_ = m_122999_(f_122913_, () -> { ++ @Deprecated public static final Registry> f_122863_ = forge(f_122913_, () -> { + return MenuType.f_39964_; + }); + public static final Registry> f_122864_ = m_122999_(f_122914_, () -> { + return RecipeType.f_44107_; + }); +- public static final Registry> f_122865_ = m_122999_(f_122915_, () -> { ++ @Deprecated public static final Registry> f_122865_ = forge(f_122915_, () -> { + return RecipeSerializer.f_44077_; + }); +- public static final Registry f_122866_ = m_122999_(f_122916_, () -> { ++ @Deprecated public static final Registry f_122866_ = forge(f_122916_, () -> { + return Attributes.f_22286_; + }); + public static final Registry> f_175420_ = m_122999_(f_175408_, () -> { + return PositionSourceType.f_157871_; + }); +- public static final Registry> f_122867_ = m_122999_(f_122917_, () -> { ++ @Deprecated public static final Registry> f_122867_ = forge(f_122917_, () -> { + return Stats.f_12982_; + }); + public static final DefaultedRegistry f_122868_ = m_122995_(f_122808_, "plains", () -> { + return VillagerType.f_35821_; + }); +- public static final DefaultedRegistry f_122869_ = m_122995_(f_122809_, "none", () -> { ++ @Deprecated public static final DefaultedRegistry f_122869_ = forge(f_122809_, "none", () -> { + return VillagerProfession.f_35585_; + }); +- public static final DefaultedRegistry f_122870_ = m_122995_(f_122810_, "unemployed", () -> { ++ @Deprecated public static final DefaultedRegistry f_122870_ = forge(f_122810_, "unemployed", () -> { + return PoiType.f_27331_; + }); +- public static final DefaultedRegistry> f_122871_ = m_122995_(f_122811_, "dummy", () -> { ++ @Deprecated public static final DefaultedRegistry> f_122871_ = forge(f_122811_, "dummy", () -> { + return MemoryModuleType.f_26349_; + }); +- public static final DefaultedRegistry> f_122872_ = m_122995_(f_122812_, "dummy", () -> { ++ @Deprecated public static final DefaultedRegistry> f_122872_ = forge(f_122812_, "dummy", () -> { + return SensorType.f_26809_; + }); +- public static final Registry f_122873_ = m_122999_(f_122813_, () -> { ++ @Deprecated public static final Registry f_122873_ = forge(f_122813_, () -> { + return Schedule.f_38012_; + }); +- public static final Registry f_122874_ = m_122999_(f_122814_, () -> { ++ @Deprecated public static final Registry f_122874_ = forge(f_122814_, () -> { + return Activity.f_37979_; + }); + public static final Registry f_122875_ = m_122999_(f_122815_, () -> { +@@ -275,19 +_,19 @@ + public static final ResourceKey> f_122884_ = m_122978_("worldgen/template_pool"); + public static final ResourceKey> f_122885_ = m_122978_("worldgen/biome"); + public static final ResourceKey>> f_122886_ = m_122978_("worldgen/surface_builder"); +- public static final Registry> f_122835_ = m_122999_(f_122886_, () -> { ++ @Deprecated public static final Registry> f_122835_ = forge(f_122886_, () -> { + return SurfaceBuilder.f_75214_; + }); + public static final ResourceKey>> f_122836_ = m_122978_("worldgen/carver"); +- public static final Registry> f_122837_ = m_122999_(f_122836_, () -> { ++ @Deprecated public static final Registry> f_122837_ = forge(f_122836_, () -> { + return WorldCarver.f_64974_; + }); + public static final ResourceKey>> f_122838_ = m_122978_("worldgen/feature"); +- public static final Registry> f_122839_ = m_122999_(f_122838_, () -> { ++ @Deprecated public static final Registry> f_122839_ = forge(f_122838_, () -> { + return Feature.f_65731_; + }); + public static final ResourceKey>> f_122840_ = m_122978_("worldgen/structure_feature"); +- public static final Registry> f_122841_ = m_122999_(f_122840_, () -> { ++ @Deprecated public static final Registry> f_122841_ = forge(f_122840_, () -> { + return StructureFeature.f_67014_; + }); + public static final ResourceKey> f_122842_ = m_122978_("worldgen/structure_piece"); +@@ -295,7 +_,7 @@ + return StructurePieceType.f_67138_; + }); + public static final ResourceKey>> f_122844_ = m_122978_("worldgen/decorator"); +- public static final Registry> f_122845_ = m_122999_(f_122844_, () -> { ++ @Deprecated public static final Registry> f_122845_ = forge(f_122844_, () -> { + return FeatureDecorator.f_70681_; + }); + public static final ResourceKey>> f_122846_ = m_122978_("worldgen/block_state_provider_type"); +@@ -308,19 +_,19 @@ + public static final ResourceKey>> f_122853_ = m_122978_("worldgen/chunk_generator"); + public static final ResourceKey>> f_122854_ = m_122978_("worldgen/structure_processor"); + public static final ResourceKey>> f_122855_ = m_122978_("worldgen/structure_pool_element"); +- public static final Registry> f_122856_ = m_122999_(f_122846_, () -> { ++ @Deprecated public static final Registry> f_122856_ = forge(f_122846_, () -> { + return BlockStateProviderType.f_68752_; + }); +- public static final Registry> f_122857_ = m_122999_(f_122847_, () -> { ++ @Deprecated public static final Registry> f_122857_ = forge(f_122847_, () -> { + return BlockPlacerType.f_67487_; + }); +- public static final Registry> f_122858_ = m_122999_(f_122848_, () -> { ++ @Deprecated public static final Registry> f_122858_ = forge(f_122848_, () -> { + return FoliagePlacerType.f_68591_; + }); + public static final Registry> f_122859_ = m_122999_(f_122849_, () -> { + return TrunkPlacerType.f_70315_; + }); +- public static final Registry> f_122860_ = m_122999_(f_122850_, () -> { ++ @Deprecated public static final Registry> f_122860_ = forge(f_122850_, () -> { + return TreeDecoratorType.f_70043_; + }); + public static final Registry> f_122888_ = m_122999_(f_122851_, () -> { +@@ -363,16 +_,32 @@ + return m_122981_(p_123000_, Lifecycle.experimental(), p_123001_); + } + ++ private static > Registry forge(ResourceKey> key, Supplier def) { ++ return forge(key, Lifecycle.experimental(), def); ++ } ++ + private static DefaultedRegistry m_122995_(ResourceKey> p_122996_, String p_122997_, Supplier p_122998_) { + return m_122990_(p_122996_, p_122997_, Lifecycle.experimental(), p_122998_); + } + ++ private static > DefaultedRegistry forge(ResourceKey> key, String defKey, Supplier def) { ++ return forge(key, defKey, Lifecycle.experimental(), def); ++ } ++ + private static Registry m_122981_(ResourceKey> p_122982_, Lifecycle p_122983_, Supplier p_122984_) { + return m_122985_(p_122982_, new MappedRegistry<>(p_122982_, p_122983_), p_122984_, p_122983_); + } + ++ private static > Registry forge(ResourceKey> key, Lifecycle cycle, Supplier def) { ++ return m_122985_(key, net.minecraftforge.registries.GameData.getWrapper(key, cycle), def, cycle); ++ } ++ + private static DefaultedRegistry m_122990_(ResourceKey> p_122991_, String p_122992_, Lifecycle p_122993_, Supplier p_122994_) { + return m_122985_(p_122991_, new DefaultedRegistry<>(p_122992_, p_122991_, p_122993_), p_122994_, p_122993_); ++ } ++ ++ private static > DefaultedRegistry forge(ResourceKey> key, String defKey, Lifecycle cycle, Supplier def) { ++ return m_122985_(key, net.minecraftforge.registries.GameData.getWrapper(key, cycle, defKey), def, cycle); + } + + private static > R m_122985_(ResourceKey> p_122986_, R p_122987_, Supplier p_122988_, Lifecycle p_122989_) { diff --git a/patches/minecraft/net/minecraft/core/RegistryAccess.java.patch b/patches/minecraft/net/minecraft/core/RegistryAccess.java.patch new file mode 100644 index 0000000000..e712cd89d2 --- /dev/null +++ b/patches/minecraft/net/minecraft/core/RegistryAccess.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/core/RegistryAccess.java ++++ b/net/minecraft/core/RegistryAccess.java +@@ -100,6 +_,8 @@ + ResourceKey> resourcekey = p_123074_.m_123108_(); + boolean flag = !resourcekey.equals(Registry.f_122878_) && !resourcekey.equals(Registry.f_122818_); + Registry registry = f_123049_.m_175515_(resourcekey); ++ if (!resourcekey.equals(Registry.f_122818_)) ++ registry = ((Registry>)BuiltinRegistries.f_123858_).m_6246_((ResourceKey>)resourcekey); + WritableRegistry writableregistry = p_123072_.m_175512_(resourcekey); + + for(Entry, E> entry : registry.m_6579_()) { diff --git a/patches/minecraft/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch b/patches/minecraft/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch new file mode 100644 index 0000000000..0cc4d29d67 --- /dev/null +++ b/patches/minecraft/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch @@ -0,0 +1,16 @@ +--- a/net/minecraft/core/dispenser/DispenseItemBehavior.java ++++ b/net/minecraft/core/dispenser/DispenseItemBehavior.java +@@ -393,9 +_,10 @@ + level.m_46597_(blockpos, BaseFireBlock.m_49245_(level, blockpos)); + level.m_142346_((Entity)null, GameEvent.f_157797_, blockpos); + } else if (!CampfireBlock.m_51321_(blockstate) && !CandleBlock.m_152845_(blockstate) && !CandleCakeBlock.m_152910_(blockstate)) { +- if (blockstate.m_60734_() instanceof TntBlock) { +- TntBlock.m_57433_(level, blockpos); +- level.m_7471_(blockpos, false); ++ if (blockstate.isFlammable(level, blockpos, p_123412_.m_6414_().m_61143_(DispenserBlock.f_52659_).m_122424_())) { ++ blockstate.catchFire(level, blockpos, p_123412_.m_6414_().m_61143_(DispenserBlock.f_52659_).m_122424_(), null); ++ if (blockstate.m_60734_() instanceof TntBlock) ++ level.m_7471_(blockpos, false); + } else { + this.m_123573_(false); + } diff --git a/patches/minecraft/net/minecraft/core/particles/BlockParticleOption.java.patch b/patches/minecraft/net/minecraft/core/particles/BlockParticleOption.java.patch new file mode 100644 index 0000000000..8fa603e125 --- /dev/null +++ b/patches/minecraft/net/minecraft/core/particles/BlockParticleOption.java.patch @@ -0,0 +1,18 @@ +--- a/net/minecraft/core/particles/BlockParticleOption.java ++++ b/net/minecraft/core/particles/BlockParticleOption.java +@@ -51,4 +_,15 @@ + public BlockState m_123642_() { + return this.f_123626_; + } ++ ++ //FORGE: Add a source pos property, so we can provide models with additional model data ++ private net.minecraft.core.BlockPos pos; ++ public BlockParticleOption setPos(net.minecraft.core.BlockPos pos) { ++ this.pos = pos; ++ return this; ++ } ++ ++ public net.minecraft.core.BlockPos getPos() { ++ return pos; ++ } + } diff --git a/patches/minecraft/net/minecraft/core/particles/ItemParticleOption.java.patch b/patches/minecraft/net/minecraft/core/particles/ItemParticleOption.java.patch new file mode 100644 index 0000000000..18398e3f78 --- /dev/null +++ b/patches/minecraft/net/minecraft/core/particles/ItemParticleOption.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/core/particles/ItemParticleOption.java ++++ b/net/minecraft/core/particles/ItemParticleOption.java +@@ -35,7 +_,7 @@ + + public ItemParticleOption(ParticleType p_123705_, ItemStack p_123706_) { + this.f_123701_ = p_123705_; +- this.f_123702_ = p_123706_; ++ this.f_123702_ = p_123706_.m_41777_(); //Forge: Fix stack updating after the fact causing particle changes. + } + + public void m_7711_(FriendlyByteBuf p_123716_) { diff --git a/patches/minecraft/net/minecraft/core/particles/ParticleType.java.patch b/patches/minecraft/net/minecraft/core/particles/ParticleType.java.patch new file mode 100644 index 0000000000..f024cbd6ff --- /dev/null +++ b/patches/minecraft/net/minecraft/core/particles/ParticleType.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/core/particles/ParticleType.java ++++ b/net/minecraft/core/particles/ParticleType.java +@@ -2,7 +_,7 @@ + + import com.mojang.serialization.Codec; + +-public abstract class ParticleType { ++public abstract class ParticleType extends net.minecraftforge.registries.ForgeRegistryEntry> { + private final boolean f_123737_; + private final ParticleOptions.Deserializer f_123738_; + diff --git a/patches/minecraft/net/minecraft/core/particles/ParticleTypes.java.patch b/patches/minecraft/net/minecraft/core/particles/ParticleTypes.java.patch new file mode 100644 index 0000000000..870126e6f1 --- /dev/null +++ b/patches/minecraft/net/minecraft/core/particles/ParticleTypes.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/core/particles/ParticleTypes.java ++++ b/net/minecraft/core/particles/ParticleTypes.java +@@ -4,6 +_,7 @@ + import java.util.function.Function; + import net.minecraft.core.Registry; + ++@net.minecraftforge.registries.ObjectHolder("minecraft") + public class ParticleTypes { + public static final SimpleParticleType f_123770_ = m_123824_("ambient_entity_effect", false); + public static final SimpleParticleType f_123792_ = m_123824_("angry_villager", false); diff --git a/patches/minecraft/net/minecraft/crash/CrashReport.java.patch b/patches/minecraft/net/minecraft/crash/CrashReport.java.patch deleted file mode 100644 index 7937c3b293..0000000000 --- a/patches/minecraft/net/minecraft/crash/CrashReport.java.patch +++ /dev/null @@ -1,53 +0,0 @@ ---- a/net/minecraft/crash/CrashReport.java -+++ b/net/minecraft/crash/CrashReport.java -@@ -69,6 +_,7 @@ - List list = Util.func_211565_f().collect(Collectors.toList()); - return String.format("%d total; %s", list.size(), list.stream().collect(Collectors.joining(" "))); - }); -+ net.minecraftforge.fml.CrashReportExtender.enhanceCrashReport(this, this.field_85061_c); - } - - public String func_71501_a() { -@@ -87,14 +_,8 @@ - if (this.field_85060_g != null && this.field_85060_g.length > 0) { - p_71506_1_.append("-- Head --\n"); - p_71506_1_.append("Thread: ").append(Thread.currentThread().getName()).append("\n"); -- p_71506_1_.append("Stacktrace:\n"); -- -- for(StackTraceElement stacktraceelement : this.field_85060_g) { -- p_71506_1_.append("\t").append("at ").append((Object)stacktraceelement); -- p_71506_1_.append("\n"); -- } -- -- p_71506_1_.append("\n"); -+ p_71506_1_.append("Stacktrace:"); -+ p_71506_1_.append(net.minecraftforge.fml.CrashReportExtender.generateEnhancedStackTrace(this.field_85060_g)); - } - - for(CrashReportCategory crashreportcategory : this.field_71512_c) { -@@ -121,23 +_,13 @@ - throwable.setStackTrace(this.field_71511_b.getStackTrace()); - } - -- String s; -- try { -- stringwriter = new StringWriter(); -- printwriter = new PrintWriter(stringwriter); -- throwable.printStackTrace(printwriter); -- s = stringwriter.toString(); -- } finally { -- IOUtils.closeQuietly((Writer)stringwriter); -- IOUtils.closeQuietly((Writer)printwriter); -- } -- -- return s; -+ return net.minecraftforge.fml.CrashReportExtender.generateEnhancedStackTrace(throwable); - } - - public String func_71502_e() { - StringBuilder stringbuilder = new StringBuilder(); - stringbuilder.append("---- Minecraft Crash Report ----\n"); -+ net.minecraftforge.fml.CrashReportExtender.addCrashReportHeader(stringbuilder, this); - stringbuilder.append("// "); - stringbuilder.append(func_71503_h()); - stringbuilder.append("\n\n"); diff --git a/patches/minecraft/net/minecraft/crash/CrashReportCategory.java.patch b/patches/minecraft/net/minecraft/crash/CrashReportCategory.java.patch deleted file mode 100644 index e52687e8b0..0000000000 --- a/patches/minecraft/net/minecraft/crash/CrashReportCategory.java.patch +++ /dev/null @@ -1,38 +0,0 @@ ---- a/net/minecraft/crash/CrashReportCategory.java -+++ b/net/minecraft/crash/CrashReportCategory.java -@@ -100,8 +_,10 @@ - if (astacktraceelement.length <= 0) { - return 0; - } else { -- this.field_85075_d = new StackTraceElement[astacktraceelement.length - 3 - p_85073_1_]; -- System.arraycopy(astacktraceelement, 3 + p_85073_1_, this.field_85075_d, 0, this.field_85075_d.length); -+ int len = astacktraceelement.length - 3 - p_85073_1_; -+ if (len <= 0) len = astacktraceelement.length; -+ this.field_85075_d = new StackTraceElement[len]; -+ System.arraycopy(astacktraceelement, astacktraceelement.length - len, this.field_85075_d, 0, this.field_85075_d.length); - return this.field_85075_d.length; - } - } -@@ -145,17 +_,17 @@ - - if (this.field_85075_d != null && this.field_85075_d.length > 0) { - p_85072_1_.append("\nStacktrace:"); -- -- for(StackTraceElement stacktraceelement : this.field_85075_d) { -- p_85072_1_.append("\n\tat "); -- p_85072_1_.append((Object)stacktraceelement); -- } -+ p_85072_1_.append(net.minecraftforge.fml.CrashReportExtender.generateEnhancedStackTrace(this.field_85075_d)); - } - - } - - public StackTraceElement[] func_147152_a() { - return this.field_85075_d; -+ } -+ -+ public void applyStackTrace(Throwable t) { -+ this.field_85075_d = t.getStackTrace(); - } - - public static void func_175750_a(CrashReportCategory p_175750_0_, BlockPos p_175750_1_, @Nullable BlockState p_175750_2_) { diff --git a/patches/minecraft/net/minecraft/data/BlockTagsProvider.java.patch b/patches/minecraft/net/minecraft/data/BlockTagsProvider.java.patch deleted file mode 100644 index d1c1772b4c..0000000000 --- a/patches/minecraft/net/minecraft/data/BlockTagsProvider.java.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- a/net/minecraft/data/BlockTagsProvider.java -+++ b/net/minecraft/data/BlockTagsProvider.java -@@ -8,8 +_,12 @@ - import net.minecraft.util.registry.Registry; - - public class BlockTagsProvider extends TagsProvider { -+ @Deprecated - public BlockTagsProvider(DataGenerator p_i48256_1_) { - super(p_i48256_1_, Registry.field_212618_g); -+ } -+ public BlockTagsProvider(DataGenerator p_i48256_1_, String modId, @javax.annotation.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { -+ super(p_i48256_1_, Registry.field_212618_g, modId, existingFileHelper); - } - - protected void func_200432_c() { diff --git a/patches/minecraft/net/minecraft/data/BuiltinRegistries.java.patch b/patches/minecraft/net/minecraft/data/BuiltinRegistries.java.patch new file mode 100644 index 0000000000..802b074e12 --- /dev/null +++ b/patches/minecraft/net/minecraft/data/BuiltinRegistries.java.patch @@ -0,0 +1,21 @@ +--- a/net/minecraft/data/BuiltinRegistries.java ++++ b/net/minecraft/data/BuiltinRegistries.java +@@ -48,13 +_,17 @@ + return ProcessorLists.f_127199_; + }); + public static final Registry f_123864_ = m_123893_(Registry.f_122884_, Pools::m_127189_); +- public static final Registry f_123865_ = m_123893_(Registry.f_122885_, () -> { ++ @Deprecated public static final Registry f_123865_ = forge(Registry.f_122885_, () -> { + return Biomes.f_127321_; + }); + public static final Registry f_123866_ = m_123893_(Registry.f_122878_, NoiseGeneratorSettings::m_64488_); + + private static Registry m_123893_(ResourceKey> p_123894_, Supplier p_123895_) { + return m_123884_(p_123894_, Lifecycle.stable(), p_123895_); ++ } ++ ++ private static > Registry forge(ResourceKey> key, Supplier def) { ++ return m_123888_(key, net.minecraftforge.registries.GameData.getWrapper(key, Lifecycle.stable()), def, Lifecycle.stable()); + } + + private static Registry m_123884_(ResourceKey> p_123885_, Lifecycle p_123886_, Supplier p_123887_) { diff --git a/patches/minecraft/net/minecraft/data/DataGenerator.java.patch b/patches/minecraft/net/minecraft/data/DataGenerator.java.patch index 8ef33b7978..3c3f36951e 100644 --- a/patches/minecraft/net/minecraft/data/DataGenerator.java.patch +++ b/patches/minecraft/net/minecraft/data/DataGenerator.java.patch @@ -1,38 +1,38 @@ --- a/net/minecraft/data/DataGenerator.java +++ b/net/minecraft/data/DataGenerator.java @@ -16,10 +_,11 @@ - private final Collection field_200394_b; - private final Path field_200395_c; - private final List field_200396_d = Lists.newArrayList(); -+ private final List providerView = java.util.Collections.unmodifiableList(field_200396_d); + private final Collection f_123906_; + private final Path f_123907_; + private final List f_123908_ = Lists.newArrayList(); ++ private final List providerView = java.util.Collections.unmodifiableList(f_123908_); - public DataGenerator(Path p_i48266_1_, Collection p_i48266_2_) { - this.field_200395_c = p_i48266_1_; -- this.field_200394_b = p_i48266_2_; -+ this.field_200394_b = Lists.newArrayList(p_i48266_2_); + public DataGenerator(Path p_123911_, Collection p_123912_) { + this.f_123907_ = p_123911_; +- this.f_123906_ = p_123912_; ++ this.f_123906_ = Lists.newArrayList(p_123912_); } - public Collection func_200389_a() { + public Collection m_123913_() { @@ -38,6 +_,7 @@ - for(IDataProvider idataprovider : this.field_200396_d) { - field_200393_a.info("Starting provider: {}", (Object)idataprovider.func_200397_b()); -+ net.minecraftforge.fml.StartupMessageManager.addModMessage("Generating: " + idataprovider.func_200397_b()); + for(DataProvider dataprovider : this.f_123908_) { + f_123905_.info("Starting provider: {}", (Object)dataprovider.m_6055_()); ++ net.minecraftforge.fml.StartupMessageManager.addModMessage("Generating: " + dataprovider.m_6055_()); stopwatch1.start(); - idataprovider.func_200398_a(directorycache); + dataprovider.m_6865_(hashcache); stopwatch1.stop(); @@ -51,6 +_,14 @@ - public void func_200390_a(IDataProvider p_200390_1_) { - this.field_200396_d.add(p_200390_1_); + public void m_123914_(DataProvider p_123915_) { + this.f_123908_.add(p_123915_); + } + -+ public List getProviders() { ++ public List getProviders() { + return this.providerView; + } + + public void addInput(Path value) { -+ this.field_200394_b.add(value); ++ this.f_123906_.add(value); } static { diff --git a/patches/minecraft/net/minecraft/data/DirectoryCache.java.patch b/patches/minecraft/net/minecraft/data/DirectoryCache.java.patch deleted file mode 100644 index cb1563fc3a..0000000000 --- a/patches/minecraft/net/minecraft/data/DirectoryCache.java.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/net/minecraft/data/DirectoryCache.java -+++ b/net/minecraft/data/DirectoryCache.java -@@ -55,8 +_,8 @@ - } - - IOUtils.writeLines(this.field_208329_f.entrySet().stream().map((p_208319_1_) -> { -- return (String)p_208319_1_.getValue() + ' ' + this.field_208325_b.relativize(p_208319_1_.getKey()); -- }).collect(Collectors.toList()), System.lineSeparator(), writer); -+ return (String)p_208319_1_.getValue() + ' ' + this.field_208325_b.relativize(p_208319_1_.getKey()).toString().replace('\\', '/'); //Forge: Standardize file paths. -+ }).sorted(java.util.Comparator.comparing(a -> a.split(" ")[1])).collect(Collectors.toList()), System.lineSeparator(), writer); - writer.close(); - field_208324_a.debug("Caching: cache hits: {}, created: {} removed: {}", this.field_208327_d, this.field_208329_f.size() - this.field_208327_d, this.field_208328_e.size()); - } diff --git a/patches/minecraft/net/minecraft/data/EntityTypeTagsProvider.java.patch b/patches/minecraft/net/minecraft/data/EntityTypeTagsProvider.java.patch deleted file mode 100644 index 5d51019dce..0000000000 --- a/patches/minecraft/net/minecraft/data/EntityTypeTagsProvider.java.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- a/net/minecraft/data/EntityTypeTagsProvider.java -+++ b/net/minecraft/data/EntityTypeTagsProvider.java -@@ -7,8 +_,12 @@ - import net.minecraft.util.registry.Registry; - - public class EntityTypeTagsProvider extends TagsProvider> { -+ @Deprecated - public EntityTypeTagsProvider(DataGenerator p_i50784_1_) { - super(p_i50784_1_, Registry.field_212629_r); -+ } -+ public EntityTypeTagsProvider(DataGenerator p_i50784_1_, String modId, @javax.annotation.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { -+ super(p_i50784_1_, Registry.field_212629_r, modId, existingFileHelper); - } - - protected void func_200432_c() { diff --git a/patches/minecraft/net/minecraft/data/FluidTagsProvider.java.patch b/patches/minecraft/net/minecraft/data/FluidTagsProvider.java.patch deleted file mode 100644 index f0b17cd0e8..0000000000 --- a/patches/minecraft/net/minecraft/data/FluidTagsProvider.java.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- a/net/minecraft/data/FluidTagsProvider.java -+++ b/net/minecraft/data/FluidTagsProvider.java -@@ -8,8 +_,12 @@ - import net.minecraft.util.registry.Registry; - - public class FluidTagsProvider extends TagsProvider { -+ @Deprecated - public FluidTagsProvider(DataGenerator p_i49156_1_) { - super(p_i49156_1_, Registry.field_212619_h); -+ } -+ public FluidTagsProvider(DataGenerator p_i49156_1_, String modId, @javax.annotation.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { -+ super(p_i49156_1_, Registry.field_212619_h, modId, existingFileHelper); - } - - protected void func_200432_c() { diff --git a/patches/minecraft/net/minecraft/data/HashCache.java.patch b/patches/minecraft/net/minecraft/data/HashCache.java.patch new file mode 100644 index 0000000000..b17977f01b --- /dev/null +++ b/patches/minecraft/net/minecraft/data/HashCache.java.patch @@ -0,0 +1,13 @@ +--- a/net/minecraft/data/HashCache.java ++++ b/net/minecraft/data/HashCache.java +@@ -55,8 +_,8 @@ + } + + IOUtils.writeLines(this.f_123931_.entrySet().stream().map((p_123944_) -> { +- return (String)p_123944_.getValue() + " " + this.f_123927_.relativize(p_123944_.getKey()); +- }).collect(Collectors.toList()), System.lineSeparator(), writer); ++ return (String)p_123944_.getValue() + ' ' + this.f_123927_.relativize(p_123944_.getKey()).toString().replace('\\', '/'); //Forge: Standardize file paths. ++ }).sorted(java.util.Comparator.comparing(a -> a.split(" ")[1])).collect(Collectors.toList()), System.lineSeparator(), writer); + writer.close(); + f_123926_.debug("Caching: cache hits: {}, created: {} removed: {}", this.f_123929_, this.f_123931_.size() - this.f_123929_, this.f_123930_.size()); + } diff --git a/patches/minecraft/net/minecraft/data/ItemTagsProvider.java.patch b/patches/minecraft/net/minecraft/data/ItemTagsProvider.java.patch deleted file mode 100644 index 104d543c35..0000000000 --- a/patches/minecraft/net/minecraft/data/ItemTagsProvider.java.patch +++ /dev/null @@ -1,16 +0,0 @@ ---- a/net/minecraft/data/ItemTagsProvider.java -+++ b/net/minecraft/data/ItemTagsProvider.java -@@ -14,8 +_,13 @@ - public class ItemTagsProvider extends TagsProvider { - private final Function, ITag.Builder> field_240520_d_; - -+ @Deprecated - public ItemTagsProvider(DataGenerator p_i232552_1_, BlockTagsProvider p_i232552_2_) { - super(p_i232552_1_, Registry.field_212630_s); -+ this.field_240520_d_ = p_i232552_2_::func_240525_b_; -+ } -+ public ItemTagsProvider(DataGenerator p_i232552_1_, BlockTagsProvider p_i232552_2_, String modId, @javax.annotation.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { -+ super(p_i232552_1_, Registry.field_212630_s, modId, existingFileHelper); - this.field_240520_d_ = p_i232552_2_::func_240525_b_; - } - diff --git a/patches/minecraft/net/minecraft/data/LootTableProvider.java.patch b/patches/minecraft/net/minecraft/data/LootTableProvider.java.patch deleted file mode 100644 index 12e4e44205..0000000000 --- a/patches/minecraft/net/minecraft/data/LootTableProvider.java.patch +++ /dev/null @@ -1,47 +0,0 @@ ---- a/net/minecraft/data/LootTableProvider.java -+++ b/net/minecraft/data/LootTableProvider.java -@@ -43,7 +_,7 @@ - public void func_200398_a(DirectoryCache p_200398_1_) { - Path path = this.field_218443_d.func_200391_b(); - Map map = Maps.newHashMap(); -- this.field_218444_e.forEach((p_218438_1_) -> { -+ this.getTables().forEach((p_218438_1_) -> { - p_218438_1_.getFirst().get().accept((p_218437_2_, p_218437_3_) -> { - if (map.put(p_218437_2_, p_218437_3_.func_216039_a(p_218438_1_.getSecond()).func_216038_b()) != null) { - throw new IllegalStateException("Duplicate loot table " + p_218437_2_); -@@ -54,13 +_,8 @@ - return null; - }, map::get); - -- for(ResourceLocation resourcelocation : Sets.difference(LootTables.func_215796_a(), map.keySet())) { -- validationtracker.func_227530_a_("Missing built-in table: " + resourcelocation); -- } -+ validate(map, validationtracker); - -- map.forEach((p_229439_1_, p_229439_2_) -> { -- LootTableManager.func_227508_a_(validationtracker, p_229439_1_, p_229439_2_); -- }); - Multimap multimap = validationtracker.func_227527_a_(); - if (!multimap.isEmpty()) { - multimap.forEach((p_229440_0_, p_229440_1_) -> { -@@ -79,6 +_,20 @@ - - }); - } -+ } -+ -+ protected List>>, LootParameterSet>> getTables() { -+ return field_218444_e; -+ } -+ -+ protected void validate(Map map, ValidationTracker validationtracker) { -+ for(ResourceLocation resourcelocation : Sets.difference(LootTables.func_215796_a(), map.keySet())) { -+ validationtracker.func_227530_a_("Missing built-in table: " + resourcelocation); -+ } -+ -+ map.forEach((p_218436_2_, p_218436_3_) -> { -+ LootTableManager.func_227508_a_(validationtracker, p_218436_2_, p_218436_3_); -+ }); - } - - private static Path func_218439_a(Path p_218439_0_, ResourceLocation p_218439_1_) { diff --git a/patches/minecraft/net/minecraft/data/Main.java.patch b/patches/minecraft/net/minecraft/data/Main.java.patch index 44642ad784..1ceecd41c7 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 -@@ -21,8 +_,15 @@ +@@ -41,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(); @@ -11,28 +11,28 @@ + OptionSpec flat = optionparser.accepts("flat", "Do not append modid prefix to output directory when generating for multiple mods"); + OptionSpec assetIndex = optionparser.accepts("assetIndex").withRequiredArg(); + OptionSpec assetsDir = optionparser.accepts("assetsDir").withRequiredArg().ofType(java.io.File.class); - OptionSet optionset = optionparser.parse(p_main_0_); + OptionSet optionset = optionparser.parse(p_129669_); - if (!optionset.has(optionspec) && optionset.hasOptions()) { + if (!optionset.has(optionspec) && optionset.hasOptions() && !(optionset.specs().size() == 1 && optionset.has(gameDir))) { Path path = Paths.get(optionspec7.value(optionset)); boolean flag = optionset.has(optionspec6); boolean flag1 = flag || optionset.has(optionspec2); -@@ -30,10 +_,14 @@ +@@ -50,10 +_,14 @@ boolean flag3 = flag || optionset.has(optionspec3); boolean flag4 = flag || optionset.has(optionspec4); boolean flag5 = flag || optionset.has(optionspec5); -- DataGenerator datagenerator = func_200264_a(path, optionset.valuesOf(optionspec8).stream().map((p_200263_0_) -> { -- return Paths.get(p_200263_0_); +- DataGenerator datagenerator = m_129660_(path, optionset.valuesOf(optionspec8).stream().map((p_129659_) -> { +- return Paths.get(p_129659_); - }).collect(Collectors.toList()), flag1, flag2, flag3, flag4, flag5); -- datagenerator.func_200392_c(); +- datagenerator.m_123917_(); + Collection inputs = optionset.valuesOf(optionspec8).stream().map(Paths::get).collect(Collectors.toList()); + Collection existingPacks = optionset.valuesOf(existing).stream().map(Paths::get).collect(Collectors.toList()); + java.util.Set existingMods = new java.util.HashSet<>(optionset.valuesOf(existingMod)); + java.util.Set mods = new java.util.HashSet<>(optionset.valuesOf(mod)); + boolean isFlat = mods.isEmpty() || optionset.has(flat); -+ net.minecraftforge.fml.DatagenModLoader.begin(mods, path, inputs, existingPacks, existingMods, flag2, flag1, flag3, flag4, flag5, isFlat, optionset.valueOf(assetIndex), optionset.valueOf(assetsDir)); ++ net.minecraftforge.fmllegacy.DatagenModLoader.begin(mods, path, inputs, existingPacks, existingMods, flag2, flag1, flag3, flag4, flag5, isFlat, optionset.valueOf(assetIndex), optionset.valueOf(assetsDir)); + if (mods.contains("minecraft") || mods.isEmpty()) -+ func_200264_a(isFlat ? path : path.resolve("minecraft"), inputs, flag1, flag2, flag3, flag4, flag5).func_200392_c(); ++ m_129660_(isFlat ? path : path.resolve("minecraft"), inputs, flag1, flag2, flag3, flag4, flag5).m_123917_(); } else { optionparser.printHelpOn(System.out); } diff --git a/patches/minecraft/net/minecraft/data/RecipeProvider.java.patch b/patches/minecraft/net/minecraft/data/RecipeProvider.java.patch deleted file mode 100644 index db4071b6c4..0000000000 --- a/patches/minecraft/net/minecraft/data/RecipeProvider.java.patch +++ /dev/null @@ -1,28 +0,0 @@ ---- a/net/minecraft/data/RecipeProvider.java -+++ b/net/minecraft/data/RecipeProvider.java -@@ -59,6 +_,7 @@ - - } - }); -+ if (this.getClass() == RecipeProvider.class) //Forge: Subclasses don't need this. - func_208310_b(p_200398_1_, Advancement.Builder.func_200278_a().func_200275_a("impossible", new ImpossibleTrigger.Instance()).func_200273_b(), path.resolve("data/minecraft/advancements/recipes/root.json")); - } - -@@ -81,7 +_,7 @@ - - } - -- protected static void func_208310_b(DirectoryCache p_208310_0_, JsonObject p_208310_1_, Path p_208310_2_) { -+ protected void func_208310_b(DirectoryCache p_208310_0_, JsonObject p_208310_1_, Path p_208310_2_) { - try { - String s = field_200412_b.toJson((JsonElement)p_208310_1_); - String s1 = field_208307_a.hashUnencodedChars(s).toString(); -@@ -100,7 +_,7 @@ - - } - -- protected static void func_200404_a(Consumer p_200404_0_) { -+ protected void func_200404_a(Consumer p_200404_0_) { - func_240470_a_(p_200404_0_, Blocks.field_196670_r, ItemTags.field_203297_q); - func_240472_b_(p_200404_0_, Blocks.field_196666_p, ItemTags.field_203296_p); - func_240472_b_(p_200404_0_, Blocks.field_235344_mC_, ItemTags.field_232913_w_); diff --git a/patches/minecraft/net/minecraft/data/TagsProvider.java.patch b/patches/minecraft/net/minecraft/data/TagsProvider.java.patch deleted file mode 100644 index d4250c786e..0000000000 --- a/patches/minecraft/net/minecraft/data/TagsProvider.java.patch +++ /dev/null @@ -1,106 +0,0 @@ ---- a/net/minecraft/data/TagsProvider.java -+++ b/net/minecraft/data/TagsProvider.java -@@ -28,10 +_,28 @@ - protected final DataGenerator field_200433_a; - protected final Registry field_200435_c; - protected final Map field_200434_b = Maps.newLinkedHashMap(); -+ protected final String modId; -+ protected final String folder; -+ protected final net.minecraftforge.common.data.ExistingFileHelper existingFileHelper; -+ private final net.minecraftforge.common.data.ExistingFileHelper.IResourceType resourceType; - -+ @Deprecated//Forge, Use ModID version. - protected TagsProvider(DataGenerator p_i49827_1_, Registry p_i49827_2_) { -+ this(p_i49827_1_, p_i49827_2_, "vanilla", null); -+ } -+ protected TagsProvider(DataGenerator p_i49827_1_, Registry p_i49827_2_, String modId, @javax.annotation.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { -+ this(p_i49827_1_, p_i49827_2_, modId, existingFileHelper, null); -+ } -+ protected TagsProvider(DataGenerator p_i49827_1_, Registry p_i49827_2_, String modId, @javax.annotation.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper, @javax.annotation.Nullable String folder) { - this.field_200433_a = p_i49827_1_; - this.field_200435_c = p_i49827_2_; -+ this.modId = modId; -+ this.existingFileHelper = existingFileHelper; -+ if (folder == null) {//TODO - 1.17: Remove getTagFolder as a method, and inline the default implementation here -+ folder = getTagFolder(); -+ } -+ this.folder = folder; -+ this.resourceType = new net.minecraftforge.common.data.ExistingFileHelper.ResourceType(net.minecraft.resources.ResourcePackType.SERVER_DATA, ".json", "tags/" + this.folder); - } - - protected abstract void func_200432_c(); -@@ -47,12 +_,14 @@ - return this.field_200435_c.func_241873_b(p_240527_1_).orElse((T)null); - }; - this.field_200434_b.forEach((p_240524_4_, p_240524_5_) -> { -- List list = p_240524_5_.func_232963_b_(function, function1).collect(Collectors.toList()); -+ // FORGE: Add validation via existing resources -+ List list = p_240524_5_.func_232963_b_(function, function1).filter(this::missing).collect(Collectors.toList()); - if (!list.isEmpty()) { - throw new IllegalArgumentException(String.format("Couldn't define tag %s as it is missing following references: %s", p_240524_4_, list.stream().map(Objects::toString).collect(Collectors.joining(",")))); - } else { - JsonObject jsonobject = p_240524_5_.func_232965_c_(); - Path path = this.func_200431_a(p_240524_4_); -+ if (path == null) return; //Forge: Allow running this data provider without writing it. Recipe provider needs valid tags. - - try { - String s = field_200437_e.toJson((JsonElement)jsonobject); -@@ -74,20 +_,36 @@ - }); - } - -+ private boolean missing(ITag.Proxy reference) { -+ ITag.ITagEntry entry = reference.func_232968_a_(); -+ // We only care about non-optional tag entries, this is the only type that can reference a resource and needs validation -+ // Optional tags should not be validated -+ if (entry instanceof ITag.TagEntry) { -+ return existingFileHelper == null || !existingFileHelper.exists(((ITag.TagEntry)entry).getId(), resourceType); -+ } -+ return false; -+ } -+ -+ @SuppressWarnings({ "unchecked", "rawtypes" }) -+ protected String getTagFolder() { -+ return ((Registry)Registry.field_212617_f).func_177774_c(field_200435_c).func_110623_a() + "s"; -+ } -+ - protected abstract Path func_200431_a(ResourceLocation p_200431_1_); - - protected TagsProvider.Builder func_240522_a_(ITag.INamedTag p_240522_1_) { - ITag.Builder itag$builder = this.func_240525_b_(p_240522_1_); -- return new TagsProvider.Builder<>(itag$builder, this.field_200435_c, "vanilla"); -+ return new TagsProvider.Builder<>(itag$builder, this.field_200435_c, modId); - } - - protected ITag.Builder func_240525_b_(ITag.INamedTag p_240525_1_) { - return this.field_200434_b.computeIfAbsent(p_240525_1_.func_230234_a_(), (p_240526_0_) -> { -+ existingFileHelper.trackGenerated(p_240526_0_, resourceType); - return new ITag.Builder(); - }); - } - -- public static class Builder { -+ public static class Builder implements net.minecraftforge.common.extensions.IForgeTagBuilder { - private final ITag.Builder field_240528_a_; - private final Registry field_240529_b_; - private final String field_240530_c_; -@@ -114,6 +_,19 @@ - this.field_240528_a_.func_232961_a_(p_240533_1_, this.field_240530_c_); - }); - return this; -+ } -+ -+ public TagsProvider.Builder add(ITag.ITagEntry tag) { -+ field_240528_a_.func_232955_a_(tag, field_240530_c_); -+ return this; -+ } -+ -+ public ITag.Builder getInternalBuilder() { -+ return field_240528_a_; -+ } -+ -+ public String getModID() { -+ return field_240530_c_; - } - } - } diff --git a/patches/minecraft/net/minecraft/data/loot/BlockLoot.java.patch b/patches/minecraft/net/minecraft/data/loot/BlockLoot.java.patch new file mode 100644 index 0000000000..5f1a1b4ca3 --- /dev/null +++ b/patches/minecraft/net/minecraft/data/loot/BlockLoot.java.patch @@ -0,0 +1,37 @@ +--- a/net/minecraft/data/loot/BlockLoot.java ++++ b/net/minecraft/data/loot/BlockLoot.java +@@ -249,7 +_,7 @@ + return LootTable.m_79147_(); + } + +- public void accept(BiConsumer p_124179_) { ++ protected void addTables() { + this.m_124288_(Blocks.f_50122_); + this.m_124288_(Blocks.f_50175_); + this.m_124288_(Blocks.f_50228_); +@@ -1251,9 +_,13 @@ + this.m_124165_(Blocks.f_50142_, m_124125_()); + this.m_124165_(Blocks.f_152491_, m_124125_()); + this.m_124165_(Blocks.f_152499_, m_124125_()); ++ } ++ ++ public void accept(BiConsumer p_124179_) { ++ this.addTables(); + Set set = Sets.newHashSet(); + +- for(Block block : Registry.f_122824_) { ++ for(Block block : getKnownBlocks()) { + ResourceLocation resourcelocation = block.m_60589_(); + if (resourcelocation != BuiltInLootTables.f_78712_ && set.add(resourcelocation)) { + LootTable.Builder loottable$builder = this.f_124070_.remove(resourcelocation); +@@ -1278,6 +_,10 @@ + + public static LootTable.Builder m_124137_(Block p_124138_) { + return m_124161_(p_124138_, DoorBlock.f_52730_, DoubleBlockHalf.LOWER); ++ } ++ ++ protected Iterable getKnownBlocks() { ++ return Registry.f_122824_; + } + + public void m_124252_(Block p_124253_) { diff --git a/patches/minecraft/net/minecraft/data/loot/BlockLootTables.java.patch b/patches/minecraft/net/minecraft/data/loot/BlockLootTables.java.patch deleted file mode 100644 index 6bb1c87d71..0000000000 --- a/patches/minecraft/net/minecraft/data/loot/BlockLootTables.java.patch +++ /dev/null @@ -1,37 +0,0 @@ ---- a/net/minecraft/data/loot/BlockLootTables.java -+++ b/net/minecraft/data/loot/BlockLootTables.java -@@ -216,7 +_,7 @@ - return LootTable.func_216119_b(); - } - -- public void accept(BiConsumer p_accept_1_) { -+ protected void addTables() { - this.func_218492_c(Blocks.field_196650_c); - this.func_218492_c(Blocks.field_196652_d); - this.func_218492_c(Blocks.field_196654_e); -@@ -1066,9 +_,13 @@ - this.func_218507_a(Blocks.field_150480_ab, func_218482_a()); - this.func_218507_a(Blocks.field_235335_bO_, func_218482_a()); - this.func_218507_a(Blocks.field_150427_aO, func_218482_a()); -+ } -+ -+ public void accept(BiConsumer p_accept_1_) { -+ this.addTables(); - Set set = Sets.newHashSet(); - -- for(Block block : Registry.field_212618_g) { -+ for(Block block : getKnownBlocks()) { - ResourceLocation resourcelocation = block.func_220068_i(); - if (resourcelocation != LootTables.field_186419_a && set.add(resourcelocation)) { - LootTable.Builder loottable$builder = this.field_218581_i.remove(resourcelocation); -@@ -1093,6 +_,10 @@ - - public static LootTable.Builder func_239829_a_(Block p_239829_0_) { - return func_218562_a(p_239829_0_, DoorBlock.field_176523_O, DoubleBlockHalf.LOWER); -+ } -+ -+ protected Iterable getKnownBlocks() { -+ return Registry.field_212618_g; - } - - public void func_218547_a(Block p_218547_1_) { diff --git a/patches/minecraft/net/minecraft/data/loot/EntityLoot.java.patch b/patches/minecraft/net/minecraft/data/loot/EntityLoot.java.patch new file mode 100644 index 0000000000..3e4d9c8c49 --- /dev/null +++ b/patches/minecraft/net/minecraft/data/loot/EntityLoot.java.patch @@ -0,0 +1,44 @@ +--- a/net/minecraft/data/loot/EntityLoot.java ++++ b/net/minecraft/data/loot/EntityLoot.java +@@ -50,7 +_,7 @@ + return LootTable.m_79147_().m_79161_(LootPool.m_79043_().m_165133_(ConstantValue.m_165692_(1.0F)).m_79076_(LootItem.m_79579_(p_124375_))).m_79161_(LootPool.m_79043_().m_165133_(ConstantValue.m_165692_(1.0F)).m_79076_(LootTableReference.m_79776_(EntityType.f_20520_.m_20677_()))); + } + +- public void accept(BiConsumer p_124377_) { ++ protected void addTables() { + this.m_124371_(EntityType.f_20529_, LootTable.m_79147_()); + this.m_124371_(EntityType.f_147039_, LootTable.m_79147_()); + this.m_124371_(EntityType.f_20549_, LootTable.m_79147_()); +@@ -144,11 +_,15 @@ + this.m_124371_(EntityType.f_20511_, LootTable.m_79147_()); + this.m_124371_(EntityType.f_20512_, LootTable.m_79147_()); + this.m_124371_(EntityType.f_20530_, LootTable.m_79147_().m_79161_(LootPool.m_79043_().m_165133_(ConstantValue.m_165692_(1.0F)).m_79076_(LootItem.m_79579_(Items.f_42583_).m_5577_(SetItemCountFunction.m_165412_(UniformGenerator.m_165780_(0.0F, 2.0F))).m_5577_(LootingEnchantFunction.m_165229_(UniformGenerator.m_165780_(0.0F, 1.0F))))).m_79161_(LootPool.m_79043_().m_165133_(ConstantValue.m_165692_(1.0F)).m_79076_(LootItem.m_79579_(Items.f_42416_)).m_79076_(LootItem.m_79579_(Items.f_42619_)).m_79076_(LootItem.m_79579_(Items.f_42620_).m_5577_(SmeltItemFunction.m_81271_().m_6509_(LootItemEntityPropertyCondition.m_81864_(LootContext.EntityTarget.THIS, f_124366_)))).m_6509_(LootItemKilledByPlayerCondition.m_81901_()).m_6509_(LootItemRandomChanceWithLootingCondition.m_81963_(0.025F, 0.01F)))); ++ } ++ ++ public void accept(BiConsumer p_124377_) { ++ this.addTables(); + Set set = Sets.newHashSet(); + +- for(EntityType entitytype : Registry.f_122826_) { ++ for(EntityType entitytype : getKnownEntities()) { + ResourceLocation resourcelocation = entitytype.m_20677_(); +- if (!f_124367_.contains(entitytype) && entitytype.m_20674_() == MobCategory.MISC) { ++ if (isNonLiving(entitytype)) { + if (resourcelocation != BuiltInLootTables.f_78712_ && this.f_124368_.remove(resourcelocation) != null) { + throw new IllegalStateException(String.format("Weird loottable '%s' for '%s', not a LivingEntity so should not have loot", resourcelocation, Registry.f_122826_.m_7981_(entitytype))); + } +@@ -163,6 +_,14 @@ + } + + this.f_124368_.forEach(p_124377_::accept); ++ } ++ ++ protected Iterable> getKnownEntities() { ++ return Registry.f_122826_; ++ } ++ ++ protected boolean isNonLiving(EntityType entitytype) { ++ return !f_124367_.contains(entitytype) && entitytype.m_20674_() == MobCategory.MISC; + } + + protected void m_124371_(EntityType p_124372_, LootTable.Builder p_124373_) { diff --git a/patches/minecraft/net/minecraft/data/loot/EntityLootTables.java.patch b/patches/minecraft/net/minecraft/data/loot/EntityLootTables.java.patch deleted file mode 100644 index dfcfd949a5..0000000000 --- a/patches/minecraft/net/minecraft/data/loot/EntityLootTables.java.patch +++ /dev/null @@ -1,44 +0,0 @@ ---- a/net/minecraft/data/loot/EntityLootTables.java -+++ b/net/minecraft/data/loot/EntityLootTables.java -@@ -50,7 +_,7 @@ - return LootTable.func_216119_b().func_216040_a(LootPool.func_216096_a().func_216046_a(ConstantRange.func_215835_a(1)).func_216045_a(ItemLootEntry.func_216168_a(p_218583_0_))).func_216040_a(LootPool.func_216096_a().func_216046_a(ConstantRange.func_215835_a(1)).func_216045_a(TableLootEntry.func_216171_a(EntityType.field_200737_ac.func_220348_g()))); - } - -- public void accept(BiConsumer p_accept_1_) { -+ protected void addTables() { - this.func_218582_a(EntityType.field_200789_c, LootTable.func_216119_b()); - this.func_218582_a(EntityType.field_200791_e, LootTable.func_216119_b()); - this.func_218582_a(EntityType.field_226289_e_, LootTable.func_216119_b()); -@@ -141,11 +_,15 @@ - this.func_218582_a(EntityType.field_233591_ai_, LootTable.func_216119_b()); - this.func_218582_a(EntityType.field_242287_aj, LootTable.func_216119_b()); - this.func_218582_a(EntityType.field_200727_aF, LootTable.func_216119_b().func_216040_a(LootPool.func_216096_a().func_216046_a(ConstantRange.func_215835_a(1)).func_216045_a(ItemLootEntry.func_216168_a(Items.field_151078_bh).func_212841_b_(SetCount.func_215932_a(RandomValueRange.func_215837_a(0.0F, 2.0F))).func_212841_b_(LootingEnchantBonus.func_215915_a(RandomValueRange.func_215837_a(0.0F, 1.0F))))).func_216040_a(LootPool.func_216096_a().func_216046_a(ConstantRange.func_215835_a(1)).func_216045_a(ItemLootEntry.func_216168_a(Items.field_151042_j)).func_216045_a(ItemLootEntry.func_216168_a(Items.field_151172_bF)).func_216045_a(ItemLootEntry.func_216168_a(Items.field_151174_bG)).func_212840_b_(KilledByPlayer.func_215994_b()).func_212840_b_(RandomChanceWithLooting.func_216003_a(0.025F, 0.01F)))); -+ } -+ -+ public void accept(BiConsumer p_accept_1_) { -+ this.addTables(); - Set set = Sets.newHashSet(); - -- for(EntityType entitytype : Registry.field_212629_r) { -+ for(EntityType entitytype : getKnownEntities()) { - ResourceLocation resourcelocation = entitytype.func_220348_g(); -- if (!field_222944_b.contains(entitytype) && entitytype.func_220339_d() == EntityClassification.MISC) { -+ if (isNonLiving(entitytype)) { - if (resourcelocation != LootTables.field_186419_a && this.field_218587_b.remove(resourcelocation) != null) { - throw new IllegalStateException(String.format("Weird loottable '%s' for '%s', not a LivingEntity so should not have loot", resourcelocation, Registry.field_212629_r.func_177774_c(entitytype))); - } -@@ -160,6 +_,14 @@ - } - - this.field_218587_b.forEach(p_accept_1_::accept); -+ } -+ -+ protected Iterable> getKnownEntities() { -+ return Registry.field_212629_r; -+ } -+ -+ protected boolean isNonLiving(EntityType entitytype) { -+ return !field_222944_b.contains(entitytype) && entitytype.func_220339_d() == EntityClassification.MISC; - } - - protected void func_218582_a(EntityType p_218582_1_, LootTable.Builder p_218582_2_) { diff --git a/patches/minecraft/net/minecraft/data/loot/LootTableProvider.java.patch b/patches/minecraft/net/minecraft/data/loot/LootTableProvider.java.patch new file mode 100644 index 0000000000..a65a7b5f6b --- /dev/null +++ b/patches/minecraft/net/minecraft/data/loot/LootTableProvider.java.patch @@ -0,0 +1,47 @@ +--- a/net/minecraft/data/loot/LootTableProvider.java ++++ b/net/minecraft/data/loot/LootTableProvider.java +@@ -40,7 +_,7 @@ + public void m_6865_(HashCache p_124444_) { + Path path = this.f_124433_.m_123916_(); + Map map = Maps.newHashMap(); +- this.f_124434_.forEach((p_124458_) -> { ++ this.getTables().forEach((p_124458_) -> { + p_124458_.getFirst().get().accept((p_176077_, p_176078_) -> { + if (map.put(p_176077_, p_176078_.m_79165_(p_124458_.getSecond()).m_79167_()) != null) { + throw new IllegalStateException("Duplicate loot table " + p_176077_); +@@ -51,13 +_,8 @@ + return null; + }, map::get); + +- for(ResourceLocation resourcelocation : Sets.difference(BuiltInLootTables.m_78766_(), map.keySet())) { +- validationcontext.m_79357_("Missing built-in table: " + resourcelocation); +- } ++ validate(map, validationcontext); + +- map.forEach((p_124441_, p_124442_) -> { +- LootTables.m_79202_(validationcontext, p_124441_, p_124442_); +- }); + Multimap multimap = validationcontext.m_79352_(); + if (!multimap.isEmpty()) { + multimap.forEach((p_124446_, p_124447_) -> { +@@ -76,6 +_,20 @@ + + }); + } ++ } ++ ++ protected List>>, LootContextParamSet>> getTables() { ++ return f_124434_; ++ } ++ ++ protected void validate(Map map, ValidationContext validationtracker) { ++ for(ResourceLocation resourcelocation : Sets.difference(BuiltInLootTables.m_78766_(), map.keySet())) { ++ validationtracker.m_79357_("Missing built-in table: " + resourcelocation); ++ } ++ ++ map.forEach((p_218436_2_, p_218436_3_) -> { ++ LootTables.m_79202_(validationtracker, p_218436_2_, p_218436_3_); ++ }); + } + + private static Path m_124453_(Path p_124454_, ResourceLocation p_124455_) { diff --git a/patches/minecraft/net/minecraft/data/recipes/RecipeProvider.java.patch b/patches/minecraft/net/minecraft/data/recipes/RecipeProvider.java.patch new file mode 100644 index 0000000000..e2b07c3ea8 --- /dev/null +++ b/patches/minecraft/net/minecraft/data/recipes/RecipeProvider.java.patch @@ -0,0 +1,28 @@ +--- a/net/minecraft/data/recipes/RecipeProvider.java ++++ b/net/minecraft/data/recipes/RecipeProvider.java +@@ -106,6 +_,7 @@ + + } + }); ++ if (this.getClass() == RecipeProvider.class) //Forge: Subclasses don't need this. + m_126013_(p_125982_, Advancement.Builder.m_138353_().m_138386_("impossible", new ImpossibleTrigger.TriggerInstance()).m_138400_(), path.resolve("data/minecraft/advancements/recipes/root.json")); + } + +@@ -143,7 +_,7 @@ + + } + +- protected static void m_126013_(HashCache p_126014_, JsonObject p_126015_, Path p_126016_) { ++ protected void m_126013_(HashCache p_126014_, JsonObject p_126015_, Path p_126016_) { + try { + String s = f_125969_.toJson((JsonElement)p_126015_); + String s1 = f_123918_.hashUnencodedChars(s).toString(); +@@ -177,7 +_,7 @@ + + } + +- protected static void m_176531_(Consumer p_176532_) { ++ protected void m_176531_(Consumer p_176532_) { + BlockFamilies.m_175934_().filter(BlockFamily::m_175956_).forEach((p_176624_) -> { + m_176580_(p_176532_, p_176624_); + }); diff --git a/patches/minecraft/net/minecraft/data/tags/BlockTagsProvider.java.patch b/patches/minecraft/net/minecraft/data/tags/BlockTagsProvider.java.patch new file mode 100644 index 0000000000..e9c41c8774 --- /dev/null +++ b/patches/minecraft/net/minecraft/data/tags/BlockTagsProvider.java.patch @@ -0,0 +1,15 @@ +--- a/net/minecraft/data/tags/BlockTagsProvider.java ++++ b/net/minecraft/data/tags/BlockTagsProvider.java +@@ -9,8 +_,12 @@ + import net.minecraft.world.level.block.Blocks; + + public class BlockTagsProvider extends TagsProvider { ++ @Deprecated + public BlockTagsProvider(DataGenerator p_126511_) { + super(p_126511_, Registry.f_122824_); ++ } ++ public BlockTagsProvider(DataGenerator p_126511_, String modId, @javax.annotation.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { ++ super(p_126511_, Registry.f_122824_, modId, existingFileHelper); + } + + protected void m_6577_() { diff --git a/patches/minecraft/net/minecraft/data/tags/EntityTypeTagsProvider.java.patch b/patches/minecraft/net/minecraft/data/tags/EntityTypeTagsProvider.java.patch new file mode 100644 index 0000000000..c0c6b50559 --- /dev/null +++ b/patches/minecraft/net/minecraft/data/tags/EntityTypeTagsProvider.java.patch @@ -0,0 +1,15 @@ +--- a/net/minecraft/data/tags/EntityTypeTagsProvider.java ++++ b/net/minecraft/data/tags/EntityTypeTagsProvider.java +@@ -8,8 +_,12 @@ + import net.minecraft.world.entity.EntityType; + + public class EntityTypeTagsProvider extends TagsProvider> { ++ @Deprecated + public EntityTypeTagsProvider(DataGenerator p_126517_) { + super(p_126517_, Registry.f_122826_); ++ } ++ public EntityTypeTagsProvider(DataGenerator p_126517_, String modId, @javax.annotation.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { ++ super(p_126517_, Registry.f_122826_, modId, existingFileHelper); + } + + protected void m_6577_() { diff --git a/patches/minecraft/net/minecraft/data/tags/FluidTagsProvider.java.patch b/patches/minecraft/net/minecraft/data/tags/FluidTagsProvider.java.patch new file mode 100644 index 0000000000..ba31267ce7 --- /dev/null +++ b/patches/minecraft/net/minecraft/data/tags/FluidTagsProvider.java.patch @@ -0,0 +1,15 @@ +--- a/net/minecraft/data/tags/FluidTagsProvider.java ++++ b/net/minecraft/data/tags/FluidTagsProvider.java +@@ -9,8 +_,12 @@ + import net.minecraft.world.level.material.Fluids; + + public class FluidTagsProvider extends TagsProvider { ++ @Deprecated + public FluidTagsProvider(DataGenerator p_126523_) { + super(p_126523_, Registry.f_122822_); ++ } ++ public FluidTagsProvider(DataGenerator p_126523_, String modId, @javax.annotation.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { ++ super(p_126523_, Registry.f_122822_, modId, existingFileHelper); + } + + protected void m_6577_() { diff --git a/patches/minecraft/net/minecraft/data/tags/ItemTagsProvider.java.patch b/patches/minecraft/net/minecraft/data/tags/ItemTagsProvider.java.patch new file mode 100644 index 0000000000..f600a55238 --- /dev/null +++ b/patches/minecraft/net/minecraft/data/tags/ItemTagsProvider.java.patch @@ -0,0 +1,16 @@ +--- a/net/minecraft/data/tags/ItemTagsProvider.java ++++ b/net/minecraft/data/tags/ItemTagsProvider.java +@@ -15,8 +_,13 @@ + public class ItemTagsProvider extends TagsProvider { + private final Function, Tag.Builder> f_126528_; + ++ @Deprecated + public ItemTagsProvider(DataGenerator p_126530_, BlockTagsProvider p_126531_) { + super(p_126530_, Registry.f_122827_); ++ this.f_126528_ = p_126531_::m_126562_; ++ } ++ public ItemTagsProvider(DataGenerator p_126530_, BlockTagsProvider p_126531_, String modId, @javax.annotation.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { ++ super(p_126530_, Registry.f_122827_, modId, existingFileHelper); + this.f_126528_ = p_126531_::m_126562_; + } + diff --git a/patches/minecraft/net/minecraft/data/tags/TagsProvider.java.patch b/patches/minecraft/net/minecraft/data/tags/TagsProvider.java.patch new file mode 100644 index 0000000000..1493618546 --- /dev/null +++ b/patches/minecraft/net/minecraft/data/tags/TagsProvider.java.patch @@ -0,0 +1,119 @@ +--- a/net/minecraft/data/tags/TagsProvider.java ++++ b/net/minecraft/data/tags/TagsProvider.java +@@ -29,10 +_,29 @@ + protected final DataGenerator f_126539_; + protected final Registry f_126540_; + protected final Map f_126543_ = Maps.newLinkedHashMap(); ++ protected final String modId; ++ protected final String folder; ++ protected final net.minecraftforge.common.data.ExistingFileHelper existingFileHelper; ++ private final net.minecraftforge.common.data.ExistingFileHelper.IResourceType resourceType; + ++ /**@deprecated Forge: Use the ModID version**/ @Deprecated + protected TagsProvider(DataGenerator p_126546_, Registry p_126547_) { ++ this(p_126546_, p_126547_, "vanilla", null); ++ } ++ protected TagsProvider(DataGenerator p_126546_, Registry p_126547_, String modId, @javax.annotation.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { ++ this(p_126546_, p_126547_, modId, existingFileHelper, null); ++ } ++ protected TagsProvider(DataGenerator p_126546_, Registry p_126547_, String modId, @javax.annotation.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper, @javax.annotation.Nullable String folder) { + this.f_126539_ = p_126546_; + this.f_126540_ = p_126547_; ++ this.modId = modId; ++ this.existingFileHelper = existingFileHelper; ++ if (folder == null) { ++ //noinspection unchecked,rawtypes ++ folder = ((Registry) Registry.f_122897_).m_7981_(f_126540_).m_135815_() + "s"; ++ } ++ this.folder = folder; ++ this.resourceType = new net.minecraftforge.common.data.ExistingFileHelper.ResourceType(net.minecraft.server.packs.PackType.SERVER_DATA, ".json", "tags/" + this.folder); + } + + protected abstract void m_6577_(); +@@ -43,12 +_,13 @@ + this.f_126543_.forEach((p_176835_, p_176836_) -> { + List list = p_176836_.m_13330_().filter((p_176832_) -> { + return !p_176832_.m_13347_().m_142746_(this.f_126540_::m_7804_, this.f_126543_::containsKey); +- }).collect(Collectors.toList()); ++ }).filter(this::missing).collect(Collectors.toList()); // Forge: Add validation via existing resources + if (!list.isEmpty()) { + throw new IllegalArgumentException(String.format("Couldn't define tag %s as it is missing following references: %s", p_176835_, list.stream().map(Objects::toString).collect(Collectors.joining(",")))); + } else { + JsonObject jsonobject = p_176836_.m_13334_(); + Path path = this.m_6648_(p_176835_); ++ if (path == null) return; // Forge: Allow running this data provider without writing it. Recipe provider needs valid tags. + + try { + String s = f_126542_.toJson((JsonElement)jsonobject); +@@ -85,20 +_,31 @@ + }); + } + ++ private boolean missing(Tag.BuilderEntry reference) { ++ Tag.Entry entry = reference.m_13347_(); ++ // We only care about non-optional tag entries, this is the only type that can reference a resource and needs validation ++ // Optional tags should not be validated ++ if (entry instanceof Tag.TagEntry) { ++ return existingFileHelper == null || !existingFileHelper.exists(((Tag.TagEntry)entry).getId(), resourceType); ++ } ++ return false; ++ } ++ + protected abstract Path m_6648_(ResourceLocation p_126561_); + + protected TagsProvider.TagAppender m_126548_(Tag.Named p_126549_) { + Tag.Builder tag$builder = this.m_126562_(p_126549_); +- return new TagsProvider.TagAppender<>(tag$builder, this.f_126540_, "vanilla"); ++ return new TagsProvider.TagAppender<>(tag$builder, this.f_126540_, modId); + } + + protected Tag.Builder m_126562_(Tag.Named p_126563_) { + return this.f_126543_.computeIfAbsent(p_126563_.m_6979_(), (p_176838_) -> { ++ existingFileHelper.trackGenerated(p_176838_, resourceType); + return new Tag.Builder(); + }); + } + +- protected static class TagAppender { ++ public static class TagAppender implements net.minecraftforge.common.extensions.IForgeTagAppender { + private final Tag.Builder f_126568_; + private final Registry f_126569_; + private final String f_126570_; +@@ -114,7 +_,7 @@ + return this; + } + +- public TagsProvider.TagAppender m_176839_(ResourceLocation p_176840_) { ++ public TagsProvider.TagAppender addOptional(ResourceLocation p_176840_) { + this.f_126568_.m_144379_(p_176840_, this.f_126570_); + return this; + } +@@ -124,7 +_,7 @@ + return this; + } + +- public TagsProvider.TagAppender m_176841_(ResourceLocation p_176842_) { ++ public TagsProvider.TagAppender addOptionalTag(ResourceLocation p_176842_) { + this.f_126568_.m_144382_(p_176842_, this.f_126570_); + return this; + } +@@ -135,6 +_,19 @@ + this.f_126568_.m_13327_(p_126587_, this.f_126570_); + }); + return this; ++ } ++ ++ public TagsProvider.TagAppender add(Tag.Entry tag) { ++ f_126568_.m_13307_(tag, f_126570_); ++ return this; ++ } ++ ++ public Tag.Builder getInternalBuilder() { ++ return f_126568_; ++ } ++ ++ public String getModID() { ++ return f_126570_; + } + } + } diff --git a/patches/minecraft/net/minecraft/data/worldgen/biome/Biomes.java.patch b/patches/minecraft/net/minecraft/data/worldgen/biome/Biomes.java.patch new file mode 100644 index 0000000000..9392e95283 --- /dev/null +++ b/patches/minecraft/net/minecraft/data/worldgen/biome/Biomes.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/data/worldgen/biome/Biomes.java ++++ b/net/minecraft/data/worldgen/biome/Biomes.java +@@ -18,7 +_,7 @@ + } + + public static ResourceKey m_127325_(int p_127326_) { +- return f_127323_.get(p_127326_); ++ return ((net.minecraftforge.registries.ForgeRegistry)net.minecraftforge.registries.ForgeRegistries.BIOMES).getKey(p_127326_); + } + + static { diff --git a/patches/minecraft/net/minecraft/dispenser/IDispenseItemBehavior.java.patch b/patches/minecraft/net/minecraft/dispenser/IDispenseItemBehavior.java.patch deleted file mode 100644 index 2415601caf..0000000000 --- a/patches/minecraft/net/minecraft/dispenser/IDispenseItemBehavior.java.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/net/minecraft/dispenser/IDispenseItemBehavior.java -+++ b/net/minecraft/dispenser/IDispenseItemBehavior.java -@@ -373,8 +_,9 @@ - world.func_175656_a(blockpos, AbstractFireBlock.func_235326_a_(world, blockpos)); - } else if (CampfireBlock.func_241470_h_(blockstate)) { - world.func_175656_a(blockpos, blockstate.func_206870_a(BlockStateProperties.field_208190_q, Boolean.valueOf(true))); -- } else if (blockstate.func_177230_c() instanceof TNTBlock) { -- TNTBlock.func_196534_a(world, blockpos); -+ } else if (blockstate.isFlammable(world, blockpos, p_82487_1_.func_189992_e().func_177229_b(DispenserBlock.field_176441_a).func_176734_d())) { -+ blockstate.catchFire(world, blockpos, p_82487_1_.func_189992_e().func_177229_b(DispenserBlock.field_176441_a).func_176734_d(), null); -+ if (blockstate.func_177230_c() instanceof TNTBlock) - world.func_217377_a(blockpos, false); - } else { - this.func_239796_a_(false); diff --git a/patches/minecraft/net/minecraft/enchantment/Enchantment.java.patch b/patches/minecraft/net/minecraft/enchantment/Enchantment.java.patch deleted file mode 100644 index c9f257faf8..0000000000 --- a/patches/minecraft/net/minecraft/enchantment/Enchantment.java.patch +++ /dev/null @@ -1,61 +0,0 @@ ---- a/net/minecraft/enchantment/Enchantment.java -+++ b/net/minecraft/enchantment/Enchantment.java -@@ -18,7 +_,8 @@ - import net.minecraftforge.api.distmarker.Dist; - import net.minecraftforge.api.distmarker.OnlyIn; - --public abstract class Enchantment { -+public abstract class Enchantment extends net.minecraftforge.registries.ForgeRegistryEntry { -+ private final net.minecraftforge.common.util.ReverseTagWrapper reverseTags = new net.minecraftforge.common.util.ReverseTagWrapper<>(this, () -> net.minecraft.tags.TagCollectionManager.func_242178_a().getCustomTypeCollection(net.minecraftforge.registries.ForgeRegistries.ENCHANTMENTS)); - private final EquipmentSlotType[] field_185263_a; - private final Enchantment.Rarity field_77333_a; - public final EnchantmentType field_77351_y; -@@ -37,6 +_,14 @@ - this.field_185263_a = p_i46731_3_; - } - -+ public java.util.Set getTags() { -+ return reverseTags.getTagNames(); -+ } -+ -+ public boolean isIn(net.minecraft.tags.ITag tag) { -+ return tag.func_230235_a_(this); -+ } -+ - public Map func_222181_a(LivingEntity p_222181_1_) { - Map map = Maps.newEnumMap(EquipmentSlotType.class); - -@@ -114,7 +_,7 @@ - } - - public boolean func_92089_a(ItemStack p_92089_1_) { -- return this.field_77351_y.func_77557_a(p_92089_1_.func_77973_b()); -+ return canApplyAtEnchantingTable(p_92089_1_); - } - - public void func_151368_a(LivingEntity p_151368_1_, Entity p_151368_2_, int p_151368_3_) { -@@ -136,6 +_,24 @@ - } - - public boolean func_230310_i_() { -+ return true; -+ } -+ -+ /** -+ * This applies specifically to applying at the enchanting table. The other method {@link #canApply(ItemStack)} -+ * applies for all possible enchantments. -+ * @param stack -+ * @return -+ */ -+ public boolean canApplyAtEnchantingTable(ItemStack stack) { -+ return stack.canApplyAtEnchantingTable(this); -+ } -+ -+ /** -+ * Is this enchantment allowed to be enchanted on books via Enchantment Table -+ * @return false to disable the vanilla feature -+ */ -+ public boolean isAllowedOnBooks() { - return true; - } - diff --git a/patches/minecraft/net/minecraft/enchantment/EnchantmentHelper.java.patch b/patches/minecraft/net/minecraft/enchantment/EnchantmentHelper.java.patch deleted file mode 100644 index d752315bd8..0000000000 --- a/patches/minecraft/net/minecraft/enchantment/EnchantmentHelper.java.patch +++ /dev/null @@ -1,29 +0,0 @@ ---- a/net/minecraft/enchantment/EnchantmentHelper.java -+++ b/net/minecraft/enchantment/EnchantmentHelper.java -@@ -274,7 +_,7 @@ - - public static int func_77514_a(Random p_77514_0_, int p_77514_1_, int p_77514_2_, ItemStack p_77514_3_) { - Item item = p_77514_3_.func_77973_b(); -- int i = item.func_77619_b(); -+ int i = p_77514_3_.getItemEnchantability(); - if (i <= 0) { - return 0; - } else { -@@ -312,7 +_,7 @@ - public static List func_77513_b(Random p_77513_0_, ItemStack p_77513_1_, int p_77513_2_, boolean p_77513_3_) { - List list = Lists.newArrayList(); - Item item = p_77513_1_.func_77973_b(); -- int i = item.func_77619_b(); -+ int i = p_77513_1_.getItemEnchantability(); - if (i <= 0) { - return list; - } else { -@@ -365,7 +_,7 @@ - boolean flag = p_185291_1_.func_77973_b() == Items.field_151122_aG; - - for(Enchantment enchantment : Registry.field_212628_q) { -- if ((!enchantment.func_185261_e() || p_185291_2_) && enchantment.func_230310_i_() && (enchantment.field_77351_y.func_77557_a(item) || flag)) { -+ if ((!enchantment.func_185261_e() || p_185291_2_) && enchantment.func_230310_i_() && (enchantment.canApplyAtEnchantingTable(p_185291_1_) || (flag && enchantment.isAllowedOnBooks()))) { - for(int i = enchantment.func_77325_b(); i > enchantment.func_77319_d() - 1; --i) { - if (p_185291_0_ >= enchantment.func_77321_a(i) && p_185291_0_ <= enchantment.func_223551_b(i)) { - list.add(new EnchantmentData(enchantment, i)); diff --git a/patches/minecraft/net/minecraft/enchantment/EnchantmentType.java.patch b/patches/minecraft/net/minecraft/enchantment/EnchantmentType.java.patch deleted file mode 100644 index 6691ea30c3..0000000000 --- a/patches/minecraft/net/minecraft/enchantment/EnchantmentType.java.patch +++ /dev/null @@ -1,29 +0,0 @@ ---- a/net/minecraft/enchantment/EnchantmentType.java -+++ b/net/minecraft/enchantment/EnchantmentType.java -@@ -11,7 +_,7 @@ - import net.minecraft.item.ToolItem; - import net.minecraft.item.TridentItem; - --public enum EnchantmentType { -+public enum EnchantmentType implements net.minecraftforge.common.IExtensibleEnum { - ARMOR { - public boolean func_77557_a(Item p_77557_1_) { - return p_77557_1_ instanceof ArmorItem; -@@ -86,5 +_,16 @@ - private EnchantmentType() { - } - -- public abstract boolean func_77557_a(Item p_77557_1_); -+ private java.util.function.Predicate delegate; -+ private EnchantmentType(java.util.function.Predicate delegate) { -+ this.delegate = delegate; -+ } -+ -+ public static EnchantmentType create(String name, java.util.function.Predicate delegate) { -+ throw new IllegalStateException("Enum not extended"); -+ } -+ -+ public boolean func_77557_a(Item p_77557_1_) { -+ return this.delegate == null ? false : this.delegate.test(p_77557_1_); -+ } - } diff --git a/patches/minecraft/net/minecraft/enchantment/Enchantments.java.patch b/patches/minecraft/net/minecraft/enchantment/Enchantments.java.patch deleted file mode 100644 index c6a22a2b7b..0000000000 --- a/patches/minecraft/net/minecraft/enchantment/Enchantments.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/enchantment/Enchantments.java -+++ b/net/minecraft/enchantment/Enchantments.java -@@ -3,6 +_,7 @@ - import net.minecraft.inventory.EquipmentSlotType; - import net.minecraft.util.registry.Registry; - -+@net.minecraftforge.registries.ObjectHolder("minecraft") - public class Enchantments { - private static final EquipmentSlotType[] field_222195_L = new EquipmentSlotType[]{EquipmentSlotType.HEAD, EquipmentSlotType.CHEST, EquipmentSlotType.LEGS, EquipmentSlotType.FEET}; - public static final Enchantment field_180310_c = func_222191_a("protection", new ProtectionEnchantment(Enchantment.Rarity.COMMON, ProtectionEnchantment.Type.ALL, field_222195_L)); diff --git a/patches/minecraft/net/minecraft/enchantment/FrostWalkerEnchantment.java.patch b/patches/minecraft/net/minecraft/enchantment/FrostWalkerEnchantment.java.patch deleted file mode 100644 index e93f81db7e..0000000000 --- a/patches/minecraft/net/minecraft/enchantment/FrostWalkerEnchantment.java.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- a/net/minecraft/enchantment/FrostWalkerEnchantment.java -+++ b/net/minecraft/enchantment/FrostWalkerEnchantment.java -@@ -42,9 +_,10 @@ - if (blockpos.func_218137_a(p_185266_0_.func_213303_ch(), (double)f)) { - blockpos$mutable.func_181079_c(blockpos.func_177958_n(), blockpos.func_177956_o() + 1, blockpos.func_177952_p()); - BlockState blockstate1 = p_185266_1_.func_180495_p(blockpos$mutable); -- if (blockstate1.func_196958_f()) { -+ if (blockstate1.isAir(p_185266_1_, blockpos$mutable)) { - BlockState blockstate2 = p_185266_1_.func_180495_p(blockpos); -- if (blockstate2.func_185904_a() == Material.field_151586_h && blockstate2.func_177229_b(FlowingFluidBlock.field_176367_b) == 0 && blockstate.func_196955_c(p_185266_1_, blockpos) && p_185266_1_.func_226663_a_(blockstate, blockpos, ISelectionContext.func_216377_a())) { -+ boolean isFull = blockstate2.func_177230_c() == Blocks.field_150355_j && blockstate2.func_177229_b(FlowingFluidBlock.field_176367_b) == 0; //TODO: Forge, modded waters? -+ if (blockstate2.func_185904_a() == Material.field_151586_h && isFull && blockstate.func_196955_c(p_185266_1_, blockpos) && p_185266_1_.func_226663_a_(blockstate, blockpos, ISelectionContext.func_216377_a()) && !net.minecraftforge.event.ForgeEventFactory.onBlockPlace(p_185266_0_, net.minecraftforge.common.util.BlockSnapshot.create(p_185266_1_.func_234923_W_(), p_185266_1_, blockpos), net.minecraft.util.Direction.UP)) { - p_185266_1_.func_175656_a(blockpos, blockstate); - p_185266_1_.func_205220_G_().func_205360_a(blockpos, Blocks.field_185778_de, MathHelper.func_76136_a(p_185266_0_.func_70681_au(), 60, 120)); - } diff --git a/patches/minecraft/net/minecraft/entity/Entity.java.patch b/patches/minecraft/net/minecraft/entity/Entity.java.patch deleted file mode 100644 index d50bcf6cce..0000000000 --- a/patches/minecraft/net/minecraft/entity/Entity.java.patch +++ /dev/null @@ -1,357 +0,0 @@ ---- a/net/minecraft/entity/Entity.java -+++ b/net/minecraft/entity/Entity.java -@@ -109,12 +_,13 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; - --public abstract class Entity implements INameable, ICommandSource { -+public abstract class Entity extends net.minecraftforge.common.capabilities.CapabilityProvider implements INameable, ICommandSource, net.minecraftforge.common.extensions.IForgeEntity { - protected static final Logger field_184243_a = LogManager.getLogger(); - private static final AtomicInteger field_213331_b = new AtomicInteger(); - private static final List field_190535_b = Collections.emptyList(); - private static final AxisAlignedBB field_174836_a = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D); - private static double field_70155_l = 1.0D; -+ @Deprecated // Forge: Use the getter to allow overriding in mods - private final EntityType field_200606_g; - private int field_145783_c = field_213331_b.incrementAndGet(); - public boolean field_70156_m; -@@ -140,6 +_,7 @@ - public boolean field_70124_G; - public boolean field_70133_I; - protected Vector3d field_213328_B = Vector3d.field_186680_a; -+ @Deprecated //Forge: Use isAlive, remove(boolean) and revive() instead of directly accessing this field. To allow the entity to react to and better control this information. - public boolean field_70128_L; - public float field_70141_P; - public float field_70140_Q; -@@ -195,6 +_,7 @@ - private float field_213326_aJ; - - public Entity(EntityType p_i48580_1_, World p_i48580_2_) { -+ super(Entity.class); - this.field_200606_g = p_i48580_1_; - this.field_70170_p = p_i48580_2_; - this.field_213325_aI = p_i48580_1_.func_220334_j(); -@@ -211,7 +_,11 @@ - this.field_70180_af.func_187214_a(field_189655_aD, false); - this.field_70180_af.func_187214_a(field_213330_X, Pose.STANDING); - this.func_70088_a(); -- this.field_213326_aJ = this.func_213316_a(Pose.STANDING, this.field_213325_aI); -+ net.minecraftforge.event.entity.EntityEvent.Size sizeEvent = net.minecraftforge.event.ForgeEventFactory.getEntitySizeForge(this, Pose.STANDING, this.field_213325_aI, this.func_213316_a(Pose.STANDING, this.field_213325_aI)); -+ this.field_213325_aI = sizeEvent.getNewSize(); -+ this.field_213326_aJ = sizeEvent.getNewEyeHeight(); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityEvent.EntityConstructing(this)); -+ this.gatherCapabilities(); - } - - @OnlyIn(Dist.CLIENT) -@@ -317,7 +_,13 @@ - } - - public void func_70106_y() { -+ this.remove(false); -+ } -+ -+ public void remove(boolean keepData) { - this.field_70128_L = true; -+ if (!keepData) -+ this.invalidateCaps(); - } - - public void func_213301_b(Pose p_213301_1_) { -@@ -560,7 +_,7 @@ - - this.field_70140_Q = (float)((double)this.field_70140_Q + (double)MathHelper.func_76133_a(func_213296_b(vector3d)) * 0.6D); - this.field_82151_R = (float)((double)this.field_82151_R + (double)MathHelper.func_76133_a(d0 * d0 + d1 * d1 + d2 * d2) * 0.6D); -- if (this.field_82151_R > this.field_70150_b && !blockstate.func_196958_f()) { -+ if (this.field_82151_R > this.field_70150_b && !blockstate.isAir(this.field_70170_p, blockpos)) { - this.field_70150_b = this.func_203009_ad(); - if (this.func_70090_H()) { - Entity entity = this.func_184207_aI() && this.func_184179_bs() != null ? this.func_184179_bs() : this; -@@ -575,7 +_,7 @@ - } else { - this.func_180429_a(blockpos, blockstate); - } -- } else if (this.field_82151_R > this.field_191959_ay && this.func_191957_ae() && blockstate.func_196958_f()) { -+ } else if (this.field_82151_R > this.field_191959_ay && this.func_191957_ae() && blockstate.isAir(this.field_70170_p, blockpos)) { - this.field_191959_ay = this.func_191954_d(this.field_82151_R); - } - } -@@ -591,8 +_,9 @@ - - float f2 = this.func_225515_ai_(); - this.func_213317_d(this.func_213322_ci().func_216372_d((double)f2, 1.0D, (double)f2)); -- if (this.field_70170_p.func_234939_c_(this.func_174813_aQ().func_186664_h(0.001D)).noneMatch((p_233572_0_) -> { -- return p_233572_0_.func_235714_a_(BlockTags.field_232872_am_) || p_233572_0_.func_203425_a(Blocks.field_150353_l); -+ if (BlockPos.func_239581_a_(this.func_174813_aQ().func_186664_h(0.001D)).noneMatch((p_233572_0_) -> { -+ BlockState state = field_70170_p.func_180495_p(p_233572_0_); -+ return state.func_235714_a_(BlockTags.field_232872_am_) || state.func_203425_a(Blocks.field_150353_l) || state.isBurning(field_70170_p, p_233572_0_); - }) && this.field_190534_ay <= 0) { - this.func_241209_g_(-this.func_190531_bD()); - } -@@ -611,11 +_,10 @@ - int j = MathHelper.func_76128_c(this.field_233557_ao_.field_72448_b - (double)0.2F); - int k = MathHelper.func_76128_c(this.field_233557_ao_.field_72449_c); - BlockPos blockpos = new BlockPos(i, j, k); -- if (this.field_70170_p.func_180495_p(blockpos).func_196958_f()) { -+ if (this.field_70170_p.func_175623_d(blockpos)) { - BlockPos blockpos1 = blockpos.func_177977_b(); - BlockState blockstate = this.field_70170_p.func_180495_p(blockpos1); -- Block block = blockstate.func_177230_c(); -- if (block.func_203417_a(BlockTags.field_219748_G) || block.func_203417_a(BlockTags.field_219757_z) || block instanceof FenceGateBlock) { -+ if (blockstate.collisionExtendsVertically(this.field_70170_p, blockpos1, this)) { - return blockpos1; - } - } -@@ -801,6 +_,7 @@ - public void func_174829_m() { - AxisAlignedBB axisalignedbb = this.func_174813_aQ(); - this.func_226288_n_((axisalignedbb.field_72340_a + axisalignedbb.field_72336_d) / 2.0D, axisalignedbb.field_72338_b, (axisalignedbb.field_72339_c + axisalignedbb.field_72334_f) / 2.0D); -+ if (this.isAddedToWorld() && !this.field_70170_p.field_72995_K && field_70170_p instanceof ServerWorld) ((ServerWorld)this.field_70170_p).func_217464_b(this); // Forge - Process chunk registration after moving. - } - - protected SoundEvent func_184184_Z() { -@@ -849,7 +_,7 @@ - protected void func_180429_a(BlockPos p_180429_1_, BlockState p_180429_2_) { - if (!p_180429_2_.func_185904_a().func_76224_d()) { - BlockState blockstate = this.field_70170_p.func_180495_p(p_180429_1_.func_177984_a()); -- SoundType soundtype = blockstate.func_203425_a(Blocks.field_150433_aE) ? blockstate.func_215695_r() : p_180429_2_.func_215695_r(); -+ SoundType soundtype = blockstate.func_203425_a(Blocks.field_150433_aE) ? blockstate.getSoundType(field_70170_p, p_180429_1_, this) : p_180429_2_.getSoundType(field_70170_p, p_180429_1_, this); - this.func_184185_a(soundtype.func_185844_d(), soundtype.func_185843_a() * 0.15F, soundtype.func_185847_b()); - } - } -@@ -1056,9 +_,10 @@ - int k = MathHelper.func_76128_c(this.func_226281_cx_()); - BlockPos blockpos = new BlockPos(i, j, k); - BlockState blockstate = this.field_70170_p.func_180495_p(blockpos); -+ if(!blockstate.addRunningEffects(field_70170_p, blockpos, this)) - if (blockstate.func_185901_i() != BlockRenderType.INVISIBLE) { - Vector3d vector3d = this.func_213322_ci(); -- this.field_70170_p.func_195594_a(new BlockParticleData(ParticleTypes.field_197611_d, blockstate), this.func_226277_ct_() + (this.field_70146_Z.nextDouble() - 0.5D) * (double)this.field_213325_aI.field_220315_a, this.func_226278_cu_() + 0.1D, this.func_226281_cx_() + (this.field_70146_Z.nextDouble() - 0.5D) * (double)this.field_213325_aI.field_220315_a, vector3d.field_72450_a * -4.0D, 1.5D, vector3d.field_72449_c * -4.0D); -+ this.field_70170_p.func_195594_a(new BlockParticleData(ParticleTypes.field_197611_d, blockstate).setPos(blockpos), this.func_226277_ct_() + (this.field_70146_Z.nextDouble() - 0.5D) * (double)this.field_213325_aI.field_220315_a, this.func_226278_cu_() + 0.1D, this.func_226281_cx_() + (this.field_70146_Z.nextDouble() - 0.5D) * (double)this.field_213325_aI.field_220315_a, vector3d.field_72450_a * -4.0D, 1.5D, vector3d.field_72449_c * -4.0D); - } - - } -@@ -1377,6 +_,7 @@ - if (this.field_184238_ar) { - p_189511_1_.func_74757_a("Glowing", this.field_184238_ar); - } -+ p_189511_1_.func_74757_a("CanUpdate", canUpdate); - - if (!this.field_184236_aF.isEmpty()) { - ListNBT listnbt = new ListNBT(); -@@ -1388,6 +_,10 @@ - p_189511_1_.func_218657_a("Tags", listnbt); - } - -+ CompoundNBT caps = serializeCaps(); -+ if (caps != null) p_189511_1_.func_218657_a("ForgeCaps", caps); -+ if (persistentData != null) p_189511_1_.func_218657_a("ForgeData", persistentData); -+ - this.func_213281_b(p_189511_1_); - if (this.func_184207_aI()) { - ListNBT listnbt1 = new ListNBT(); -@@ -1458,6 +_,9 @@ - this.func_174810_b(p_70020_1_.func_74767_n("Silent")); - this.func_189654_d(p_70020_1_.func_74767_n("NoGravity")); - this.func_184195_f(p_70020_1_.func_74767_n("Glowing")); -+ if (p_70020_1_.func_150297_b("ForgeData", 10)) persistentData = p_70020_1_.func_74775_l("ForgeData"); -+ if (p_70020_1_.func_150297_b("CanUpdate", 99)) this.canUpdate(p_70020_1_.func_74767_n("CanUpdate")); -+ if (p_70020_1_.func_150297_b("ForgeCaps", 10)) deserializeCaps(p_70020_1_.func_74775_l("ForgeCaps")); - if (p_70020_1_.func_150297_b("Tags", 9)) { - this.field_184236_aF.clear(); - ListNBT listnbt3 = p_70020_1_.func_150295_c("Tags", 8); -@@ -1546,6 +_,8 @@ - } else { - ItemEntity itementity = new ItemEntity(this.field_70170_p, this.func_226277_ct_(), this.func_226278_cu_() + (double)p_70099_2_, this.func_226281_cx_(), p_70099_1_); - itementity.func_174869_p(); -+ if (captureDrops() != null) captureDrops().add(itementity); -+ else - this.field_70170_p.func_217376_c(itementity); - return itementity; - } -@@ -1582,6 +_,7 @@ - - public void func_70098_U() { - this.func_213317_d(Vector3d.field_186680_a); -+ if (canUpdate()) - this.func_70071_h_(); - if (this.func_184218_aH()) { - this.func_184187_bx().func_184232_k(this); -@@ -1627,6 +_,7 @@ - } - } - -+ if (!net.minecraftforge.event.ForgeEventFactory.canMountEntity(this, p_184205_1_, true)) return false; - if (p_184205_2_ || this.func_184228_n(p_184205_1_) && p_184205_1_.func_184219_q(this)) { - if (this.func_184218_aH()) { - this.func_184210_p(); -@@ -1659,6 +_,7 @@ - public void func_233575_bb_() { - if (this.field_184239_as != null) { - Entity entity = this.field_184239_as; -+ if (!net.minecraftforge.event.ForgeEventFactory.canMountEntity(this, entity, false)) return; - this.field_184239_as = null; - entity.func_184225_p(this); - } -@@ -1816,6 +_,7 @@ - return !this.func_184188_bt().isEmpty(); - } - -+ @Deprecated //Forge: Use rider sensitive version - public boolean func_205710_ba() { - return true; - } -@@ -1948,7 +_,7 @@ - this.func_70015_d(8); - } - -- this.func_70097_a(DamageSource.field_180137_b, 5.0F); -+ this.func_70097_a(DamageSource.field_180137_b, p_241841_2_.getDamage()); - } - - public void func_203002_i(boolean p_203002_1_) { -@@ -2032,7 +_,7 @@ - } - - protected ITextComponent func_225513_by_() { -- return this.field_200606_g.func_212546_e(); -+ return this.func_200600_R().func_212546_e(); // Forge: Use getter to allow overriding by mods - } - - public boolean func_70028_i(Entity p_70028_1_) { -@@ -2087,14 +_,19 @@ - - @Nullable - public Entity func_241206_a_(ServerWorld p_241206_1_) { -+ return this.changeDimension(p_241206_1_, p_241206_1_.func_85176_s()); -+ } -+ @Nullable -+ public Entity changeDimension(ServerWorld p_241206_1_, net.minecraftforge.common.util.ITeleporter teleporter) { - if (this.field_70170_p instanceof ServerWorld && !this.field_70128_L) { - this.field_70170_p.func_217381_Z().func_76320_a("changeDimension"); - this.func_213319_R(); - this.field_70170_p.func_217381_Z().func_76320_a("reposition"); -- PortalInfo portalinfo = this.func_241829_a(p_241206_1_); -+ PortalInfo portalinfo = teleporter.getPortalInfo(this, p_241206_1_, this::func_241829_a); - if (portalinfo == null) { - return null; - } else { -+ Entity transportedEntity = teleporter.placeEntity(this, (ServerWorld) this.field_70170_p, p_241206_1_, this.field_70177_z, spawnPortal -> { //Forge: Start vanilla logic - this.field_70170_p.func_217381_Z().func_219895_b("reloading"); - Entity entity = this.func_200600_R().func_200721_a(p_241206_1_); - if (entity != null) { -@@ -2102,17 +_,19 @@ - entity.func_70012_b(portalinfo.field_222505_a.field_72450_a, portalinfo.field_222505_a.field_72448_b, portalinfo.field_222505_a.field_72449_c, portalinfo.field_242960_c, entity.field_70125_A); - entity.func_213317_d(portalinfo.field_222506_b); - p_241206_1_.func_217460_e(entity); -- if (p_241206_1_.func_234923_W_() == World.field_234920_i_) { -+ if (spawnPortal && p_241206_1_.func_234923_W_() == World.field_234920_i_) { - ServerWorld.func_241121_a_(p_241206_1_); - } - } -+ return entity; -+ }); //Forge: End vanilla logic - - this.func_241204_bJ_(); - this.field_70170_p.func_217381_Z().func_76319_b(); - ((ServerWorld)this.field_70170_p).func_82742_i(); - p_241206_1_.func_82742_i(); - this.field_70170_p.func_217381_Z().func_76319_b(); -- return entity; -+ return transportedEntity; - } - } else { - return null; -@@ -2321,8 +_,10 @@ - EntitySize entitysize = this.field_213325_aI; - Pose pose = this.func_213283_Z(); - EntitySize entitysize1 = this.func_213305_a(pose); -+ net.minecraftforge.event.entity.EntityEvent.Size sizeEvent = net.minecraftforge.event.ForgeEventFactory.getEntitySizeForge(this, pose, entitysize, entitysize1, this.func_213316_a(pose, entitysize1)); -+ entitysize1 = sizeEvent.getNewSize(); - this.field_213325_aI = entitysize1; -- this.field_213326_aJ = this.func_213316_a(pose, entitysize1); -+ this.field_213326_aJ = sizeEvent.getNewEyeHeight(); - if (entitysize1.field_220315_a < entitysize.field_220315_a) { - double d0 = (double)entitysize1.field_220315_a / 2.0D; - this.func_174826_a(new AxisAlignedBB(this.func_226277_ct_() - d0, this.func_226278_cu_(), this.func_226281_cx_() - d0, this.func_226277_ct_() + d0, this.func_226278_cu_() + (double)entitysize1.field_220316_b, this.func_226281_cx_() + d0)); -@@ -2796,6 +_,7 @@ - - this.field_233555_aA_ = true; - } -+ if (this.isAddedToWorld() && !this.field_70170_p.field_72995_K && !this.field_70128_L) this.field_70170_p.func_212866_a_((int) Math.floor(p_226288_1_) >> 4, (int) Math.floor(p_226288_5_) >> 4); // Forge - ensure target chunk is loaded. - - } - -@@ -2810,5 +_,72 @@ - @FunctionalInterface - public interface IMoveCallback { - void accept(Entity p_accept_1_, double p_accept_2_, double p_accept_4_, double p_accept_6_); -+ } -+ -+ /* ================================== Forge Start =====================================*/ -+ -+ private boolean canUpdate = true; -+ @Override -+ public void canUpdate(boolean value) { -+ this.canUpdate = value; -+ } -+ @Override -+ public boolean canUpdate() { -+ return this.canUpdate; -+ } -+ private Collection captureDrops = null; -+ @Override -+ public Collection captureDrops() { -+ return captureDrops; -+ } -+ @Override -+ public Collection captureDrops(Collection value) { -+ Collection ret = captureDrops; -+ this.captureDrops = value; -+ return ret; -+ } -+ private CompoundNBT persistentData; -+ @Override -+ public CompoundNBT getPersistentData() { -+ if (persistentData == null) -+ persistentData = new CompoundNBT(); -+ return persistentData; -+ } -+ @Override -+ public boolean canTrample(BlockState state, BlockPos pos, float fallDistance) { -+ return field_70170_p.field_73012_v.nextFloat() < fallDistance - 0.5F -+ && this instanceof LivingEntity -+ && (this instanceof PlayerEntity || net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(field_70170_p, this)) -+ && this.func_213311_cf() * this.func_213311_cf() * this.func_213302_cg() > 0.512F; -+ } -+ -+ /** -+ * Internal use for keeping track of entities that are tracked by a world, to -+ * allow guarantees that entity position changes will force a chunk load, avoiding -+ * potential issues with entity desyncing and bad chunk data. -+ */ -+ private boolean isAddedToWorld; -+ -+ @Override -+ public final boolean isAddedToWorld() { return this.isAddedToWorld; } -+ -+ @Override -+ public void onAddedToWorld() { this.isAddedToWorld = true; } -+ -+ @Override -+ public void onRemovedFromWorld() { this.isAddedToWorld = false; } -+ -+ @Override -+ public void revive() { -+ this.field_70128_L = false; -+ this.reviveCaps(); -+ } -+ -+ // no AT because of overrides -+ /** -+ * Accessor method for {@link #getEyeHeight(Pose, EntitySize)} -+ */ -+ public float getEyeHeightAccess(Pose pose, EntitySize size) { -+ return this.func_213316_a(pose, size); - } - } diff --git a/patches/minecraft/net/minecraft/entity/EntityClassification.java.patch b/patches/minecraft/net/minecraft/entity/EntityClassification.java.patch deleted file mode 100644 index 28beae1fc6..0000000000 --- a/patches/minecraft/net/minecraft/entity/EntityClassification.java.patch +++ /dev/null @@ -1,37 +0,0 @@ ---- a/net/minecraft/entity/EntityClassification.java -+++ b/net/minecraft/entity/EntityClassification.java -@@ -6,7 +_,7 @@ - import java.util.stream.Collectors; - import net.minecraft.util.IStringSerializable; - --public enum EntityClassification implements IStringSerializable { -+public enum EntityClassification implements IStringSerializable, net.minecraftforge.common.IExtensibleEnum { - MONSTER("monster", 70, false, false, 128), - CREATURE("creature", 10, true, true, 128), - AMBIENT("ambient", 15, true, false, 128), -@@ -14,7 +_,7 @@ - WATER_AMBIENT("water_ambient", 20, true, false, 64), - MISC("misc", -1, true, true, 128); - -- public static final Codec field_233667_g_ = IStringSerializable.func_233023_a_(EntityClassification::values, EntityClassification::func_233670_a_); -+ public static final Codec field_233667_g_ = net.minecraftforge.common.IExtensibleEnum.createCodecForExtensibleEnum(EntityClassification::values, EntityClassification::func_233670_a_); - private static final Map field_220364_f = Arrays.stream(values()).collect(Collectors.toMap(EntityClassification::func_220363_a, (p_220362_0_) -> { - return p_220362_0_; - })); -@@ -55,6 +_,16 @@ - - public boolean func_82705_e() { - return this.field_82707_i; -+ } -+ -+ public static EntityClassification create(String name, String id, int maxNumberOfCreatureIn, boolean isPeacefulCreatureIn, boolean isAnimalIn, int despawnDistance) { -+ throw new IllegalStateException("Enum not extended"); -+ } -+ -+ @Override -+ @Deprecated -+ public void init() { -+ field_220364_f.put(this.func_220363_a(), this); - } - - public int func_233671_f_() { diff --git a/patches/minecraft/net/minecraft/entity/EntitySpawnPlacementRegistry.java.patch b/patches/minecraft/net/minecraft/entity/EntitySpawnPlacementRegistry.java.patch deleted file mode 100644 index 54f00ad48e..0000000000 --- a/patches/minecraft/net/minecraft/entity/EntitySpawnPlacementRegistry.java.patch +++ /dev/null @@ -1,30 +0,0 @@ ---- a/net/minecraft/entity/EntitySpawnPlacementRegistry.java -+++ b/net/minecraft/entity/EntitySpawnPlacementRegistry.java -@@ -147,10 +_,26 @@ - boolean test(EntityType p_test_1_, IServerWorld p_test_2_, SpawnReason p_test_3_, BlockPos p_test_4_, Random p_test_5_); - } - -- public static enum PlacementType { -+ public static enum PlacementType implements net.minecraftforge.common.IExtensibleEnum { - ON_GROUND, - IN_WATER, - NO_RESTRICTIONS, - IN_LAVA; -+ -+ public static PlacementType create(String name, net.minecraftforge.common.util.TriPredicate> predicate) { -+ throw new IllegalStateException("Enum not extended"); -+ } -+ -+ private net.minecraftforge.common.util.TriPredicate> predicate; -+ private PlacementType() { this(null); } -+ private PlacementType(net.minecraftforge.common.util.TriPredicate> predicate) { -+ this.predicate = predicate; -+ } -+ -+ public boolean canSpawnAt(net.minecraft.world.IWorldReader world, BlockPos pos, EntityType type) { -+ if (this == NO_RESTRICTIONS) return true; -+ if (predicate == null) return net.minecraft.world.spawner.WorldEntitySpawner.canSpawnAtBody(this, world, pos, type); -+ return predicate.test(world, pos, type); -+ } - } - } diff --git a/patches/minecraft/net/minecraft/entity/EntityType.java.patch b/patches/minecraft/net/minecraft/entity/EntityType.java.patch deleted file mode 100644 index 69e9c0d5af..0000000000 --- a/patches/minecraft/net/minecraft/entity/EntityType.java.patch +++ /dev/null @@ -1,147 +0,0 @@ ---- a/net/minecraft/entity/EntityType.java -+++ b/net/minecraft/entity/EntityType.java -@@ -143,7 +_,7 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; - --public class EntityType { -+public class EntityType extends net.minecraftforge.registries.ForgeRegistryEntry> { - private static final Logger field_200731_aJ = LogManager.getLogger(); - public static final EntityType field_200788_b = func_200712_a("area_effect_cloud", EntityType.Builder.func_220322_a(AreaEffectCloudEntity::new, EntityClassification.MISC).func_220320_c().func_220321_a(6.0F, 0.5F).func_233606_a_(10).func_233608_b_(Integer.MAX_VALUE)); - public static final EntityType field_200789_c = func_200712_a("armor_stand", EntityType.Builder.func_220322_a(ArmorStandEntity::new, EntityClassification.MISC).func_220321_a(0.5F, 1.975F).func_233606_a_(10)); -@@ -270,6 +_,12 @@ - private ResourceLocation field_220358_bg; - private final EntitySize field_220359_bi; - -+ private final java.util.function.Predicate> velocityUpdateSupplier; -+ private final java.util.function.ToIntFunction> trackingRangeSupplier; -+ private final java.util.function.ToIntFunction> updateIntervalSupplier; -+ private final java.util.function.BiFunction customClientFactory; -+ private final net.minecraftforge.common.util.ReverseTagWrapper> reverseTags = new net.minecraftforge.common.util.ReverseTagWrapper<>(this, net.minecraft.tags.EntityTypeTags::func_219762_a); -+ - private static EntityType func_200712_a(String p_200712_0_, EntityType.Builder p_200712_1_) { - return Registry.func_218325_a(Registry.field_212629_r, p_200712_0_, p_200712_1_.func_206830_a(p_200712_0_)); - } -@@ -283,6 +_,9 @@ - } - - public EntityType(EntityType.IFactory p_i231489_1_, EntityClassification p_i231489_2_, boolean p_i231489_3_, boolean p_i231489_4_, boolean p_i231489_5_, boolean p_i231489_6_, ImmutableSet p_i231489_7_, EntitySize p_i231489_8_, int p_i231489_9_, int p_i231489_10_) { -+ this(p_i231489_1_, p_i231489_2_, p_i231489_3_, p_i231489_4_, p_i231489_5_, p_i231489_6_, p_i231489_7_, p_i231489_8_, p_i231489_9_, p_i231489_10_, EntityType::defaultVelocitySupplier, EntityType::defaultTrackingRangeSupplier, EntityType::defaultUpdateIntervalSupplier, null); -+ } -+ public EntityType(EntityType.IFactory p_i231489_1_, EntityClassification p_i231489_2_, boolean p_i231489_3_, boolean p_i231489_4_, boolean p_i231489_5_, boolean p_i231489_6_, ImmutableSet p_i231489_7_, EntitySize p_i231489_8_, int p_i231489_9_, int p_i231489_10_, final java.util.function.Predicate> velocityUpdateSupplier, final java.util.function.ToIntFunction> trackingRangeSupplier, final java.util.function.ToIntFunction> updateIntervalSupplier, final java.util.function.BiFunction customClientFactory) { - this.field_200732_aK = p_i231489_1_; - this.field_220355_ba = p_i231489_2_; - this.field_225438_be = p_i231489_6_; -@@ -293,6 +_,10 @@ - this.field_220359_bi = p_i231489_8_; - this.field_233594_bl_ = p_i231489_9_; - this.field_233595_bm_ = p_i231489_10_; -+ this.velocityUpdateSupplier = velocityUpdateSupplier; -+ this.trackingRangeSupplier = trackingRangeSupplier; -+ this.updateIntervalSupplier = updateIntervalSupplier; -+ this.customClientFactory = customClientFactory; - } - - @Nullable -@@ -304,6 +_,7 @@ - public T func_220342_a(ServerWorld p_220342_1_, @Nullable CompoundNBT p_220342_2_, @Nullable ITextComponent p_220342_3_, @Nullable PlayerEntity p_220342_4_, BlockPos p_220342_5_, SpawnReason p_220342_6_, boolean p_220342_7_, boolean p_220342_8_) { - T t = this.func_220349_b(p_220342_1_, p_220342_2_, p_220342_3_, p_220342_4_, p_220342_5_, p_220342_6_, p_220342_7_, p_220342_8_); - if (t != null) { -+ if (t instanceof net.minecraft.entity.MobEntity && net.minecraftforge.event.ForgeEventFactory.doSpecialSpawn((net.minecraft.entity.MobEntity) t, p_220342_1_, p_220342_5_.func_177958_n(), p_220342_5_.func_177956_o(), p_220342_5_.func_177952_p(), null, p_220342_6_)) return null; - p_220342_1_.func_242417_l(t); - } - -@@ -504,14 +_,23 @@ - } - - public int func_233602_m_() { -+ return trackingRangeSupplier.applyAsInt(this); -+ } -+ private int defaultTrackingRangeSupplier() { - return this.field_233594_bl_; - } - - public int func_220332_l() { -+ return updateIntervalSupplier.applyAsInt(this); -+ } -+ private int defaultUpdateIntervalSupplier() { - return this.field_233595_bm_; - } - - public boolean func_220340_m() { -+ return velocityUpdateSupplier.test(this); -+ } -+ private boolean defaultVelocitySupplier() { - return this != field_200729_aH && this != field_200770_J && this != field_200760_az && this != field_200791_e && this != field_200766_F && this != field_200768_H && this != field_200782_V && this != field_200801_o && this != field_200805_s; - } - -@@ -519,6 +_,19 @@ - return p_220341_1_.func_230235_a_(this); - } - -+ public T customClientSpawn(net.minecraftforge.fml.network.FMLPlayMessages.SpawnEntity packet, World world) { -+ if (customClientFactory == null) return this.func_200721_a(world); -+ return customClientFactory.apply(packet, world); -+ } -+ -+ /** -+ * Retrieves a list of tags names this is known to be associated with. -+ * This should be used in favor of TagCollection.getOwningTags, as this caches the result and automatically updates when the TagCollection changes. -+ */ -+ public java.util.Set getTags() { -+ return reverseTags.getTagNames(); -+ } -+ - public static class Builder { - private final EntityType.IFactory field_200709_a; - private final EntityClassification field_220324_b; -@@ -531,6 +_,11 @@ - private int field_233605_i_ = 3; - private EntitySize field_220326_f = EntitySize.func_220314_b(0.6F, 1.8F); - -+ private java.util.function.Predicate> velocityUpdateSupplier = EntityType::defaultVelocitySupplier; -+ private java.util.function.ToIntFunction> trackingRangeSupplier = EntityType::defaultTrackingRangeSupplier; -+ private java.util.function.ToIntFunction> updateIntervalSupplier = EntityType::defaultUpdateIntervalSupplier; -+ private java.util.function.BiFunction customClientFactory; -+ - private Builder(EntityType.IFactory p_i50479_1_, EntityClassification p_i50479_2_) { - this.field_200709_a = p_i50479_1_; - this.field_220324_b = p_i50479_2_; -@@ -587,12 +_,36 @@ - return this; - } - -+ public EntityType.Builder setUpdateInterval(int interval) { -+ this.updateIntervalSupplier = t->interval; -+ return this; -+ } -+ -+ public EntityType.Builder setTrackingRange(int range) { -+ this.trackingRangeSupplier = t->range; -+ return this; -+ } -+ -+ public EntityType.Builder setShouldReceiveVelocityUpdates(boolean value) { -+ this.velocityUpdateSupplier = t->value; -+ return this; -+ } -+ -+ /** -+ * By default, entities are spawned clientside via {@link EntityType#create(World)}. -+ * If you need finer control over the spawning process, use this to get read access to the spawn packet. -+ */ -+ public EntityType.Builder setCustomClientFactory(java.util.function.BiFunction customClientFactory) { -+ this.customClientFactory = customClientFactory; -+ return this; -+ } -+ - public EntityType func_206830_a(String p_206830_1_) { - if (this.field_200710_b) { - Util.func_240976_a_(TypeReferences.field_211298_n, p_206830_1_); - } - -- return new EntityType<>(this.field_200709_a, this.field_220324_b, this.field_200710_b, this.field_200711_c, this.field_220325_e, this.field_225436_f, this.field_233603_c_, this.field_220326_f, this.field_233604_h_, this.field_233605_i_); -+ return new EntityType<>(this.field_200709_a, this.field_220324_b, this.field_200710_b, this.field_200711_c, this.field_220325_e, this.field_225436_f, this.field_233603_c_, this.field_220326_f, this.field_233604_h_, this.field_233605_i_, velocityUpdateSupplier, trackingRangeSupplier, updateIntervalSupplier, customClientFactory); - } - } - diff --git a/patches/minecraft/net/minecraft/entity/FlyingEntity.java.patch b/patches/minecraft/net/minecraft/entity/FlyingEntity.java.patch deleted file mode 100644 index bebdcc7724..0000000000 --- a/patches/minecraft/net/minecraft/entity/FlyingEntity.java.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- a/net/minecraft/entity/FlyingEntity.java -+++ b/net/minecraft/entity/FlyingEntity.java -@@ -27,15 +_,16 @@ - this.func_213315_a(MoverType.SELF, this.func_213322_ci()); - this.func_213317_d(this.func_213322_ci().func_186678_a(0.5D)); - } else { -+ BlockPos ground = new BlockPos(this.func_226277_ct_(), this.func_226278_cu_() - 1.0D, this.func_226281_cx_()); - float f = 0.91F; - if (this.field_70122_E) { -- f = this.field_70170_p.func_180495_p(new BlockPos(this.func_226277_ct_(), this.func_226278_cu_() - 1.0D, this.func_226281_cx_())).func_177230_c().func_208618_m() * 0.91F; -+ f = this.field_70170_p.func_180495_p(ground).getSlipperiness(this.field_70170_p, ground, this) * 0.91F; - } - - float f1 = 0.16277137F / (f * f * f); - f = 0.91F; - if (this.field_70122_E) { -- f = this.field_70170_p.func_180495_p(new BlockPos(this.func_226277_ct_(), this.func_226278_cu_() - 1.0D, this.func_226281_cx_())).func_177230_c().func_208618_m() * 0.91F; -+ f = this.field_70170_p.func_180495_p(ground).getSlipperiness(this.field_70170_p, ground, this) * 0.91F; - } - - this.func_213309_a(this.field_70122_E ? 0.1F * f1 : 0.02F, p_213352_1_); diff --git a/patches/minecraft/net/minecraft/entity/ICrossbowUser.java.patch b/patches/minecraft/net/minecraft/entity/ICrossbowUser.java.patch deleted file mode 100644 index 5c75034132..0000000000 --- a/patches/minecraft/net/minecraft/entity/ICrossbowUser.java.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/net/minecraft/entity/ICrossbowUser.java -+++ b/net/minecraft/entity/ICrossbowUser.java -@@ -24,9 +_,9 @@ - void func_230283_U__(); - - default void func_234281_b_(LivingEntity p_234281_1_, float p_234281_2_) { -- Hand hand = ProjectileHelper.func_221274_a(p_234281_1_, Items.field_222114_py); -+ Hand hand = ProjectileHelper.getWeaponHoldingHand(p_234281_1_, item -> item instanceof CrossbowItem); - ItemStack itemstack = p_234281_1_.func_184586_b(hand); -- if (p_234281_1_.func_233631_a_(Items.field_222114_py)) { -+ if (p_234281_1_.func_233634_a_(item -> item instanceof CrossbowItem)) { - CrossbowItem.func_220014_a(p_234281_1_.field_70170_p, p_234281_1_, hand, itemstack, p_234281_2_, (float)(14 - p_234281_1_.field_70170_p.func_175659_aa().func_151525_a() * 4)); - } - diff --git a/patches/minecraft/net/minecraft/entity/IShearable.java.patch b/patches/minecraft/net/minecraft/entity/IShearable.java.patch deleted file mode 100644 index 892f08b095..0000000000 --- a/patches/minecraft/net/minecraft/entity/IShearable.java.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/net/minecraft/entity/IShearable.java -+++ b/net/minecraft/entity/IShearable.java -@@ -2,8 +_,11 @@ - - import net.minecraft.util.SoundCategory; - -+@Deprecated // Forge: Use IForgeShearable - public interface IShearable { -+ @Deprecated // Forge: Use IForgeShearable - void func_230263_a_(SoundCategory p_230263_1_); - -+ @Deprecated // Forge: Use IForgeShearable - boolean func_230262_K__(); - } diff --git a/patches/minecraft/net/minecraft/entity/LivingEntity.java.patch b/patches/minecraft/net/minecraft/entity/LivingEntity.java.patch deleted file mode 100644 index eb01fad115..0000000000 --- a/patches/minecraft/net/minecraft/entity/LivingEntity.java.patch +++ /dev/null @@ -1,552 +0,0 @@ ---- a/net/minecraft/entity/LivingEntity.java -+++ b/net/minecraft/entity/LivingEntity.java -@@ -117,7 +_,9 @@ - public abstract class LivingEntity extends Entity { - private static final UUID field_110156_b = UUID.fromString("662A6B8D-DA3E-4C1C-8813-96EA6097278D"); - private static final UUID field_233625_c_ = UUID.fromString("87f46a96-686f-4796-b035-22e16ee9e038"); -+ private static final UUID SLOW_FALLING_ID = UUID.fromString("A5B6CF2A-2F7C-31EF-9022-7C3E7D5E6ABA"); - private static final AttributeModifier field_110157_c = new AttributeModifier(field_110156_b, "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 - protected static final DataParameter field_184621_as = EntityDataManager.func_187226_a(LivingEntity.class, DataSerializers.field_187191_a); - private static final DataParameter field_184632_c = EntityDataManager.func_187226_a(LivingEntity.class, DataSerializers.field_187193_c); - private static final DataParameter field_184633_f = EntityDataManager.func_187226_a(LivingEntity.class, DataSerializers.field_187192_b); -@@ -245,7 +_,7 @@ - } - - public static AttributeModifierMap.MutableAttribute func_233639_cI_() { -- return AttributeModifierMap.func_233803_a_().func_233814_a_(Attributes.field_233818_a_).func_233814_a_(Attributes.field_233820_c_).func_233814_a_(Attributes.field_233821_d_).func_233814_a_(Attributes.field_233826_i_).func_233814_a_(Attributes.field_233827_j_); -+ return AttributeModifierMap.func_233803_a_().func_233814_a_(Attributes.field_233818_a_).func_233814_a_(Attributes.field_233820_c_).func_233814_a_(Attributes.field_233821_d_).func_233814_a_(Attributes.field_233826_i_).func_233814_a_(Attributes.field_233827_j_).func_233814_a_(net.minecraftforge.common.ForgeMod.SWIM_SPEED.get()).func_233814_a_(net.minecraftforge.common.ForgeMod.NAMETAG_DISTANCE.get()).func_233814_a_(net.minecraftforge.common.ForgeMod.ENTITY_GRAVITY.get()); - } - - protected void func_184231_a(double p_184231_1_, boolean p_184231_3_, BlockState p_184231_4_, BlockPos p_184231_5_) { -@@ -260,10 +_,11 @@ - - if (!this.field_70170_p.field_72995_K && this.field_70143_R > 3.0F && p_184231_3_) { - float f = (float)MathHelper.func_76123_f(this.field_70143_R - 3.0F); -- if (!p_184231_4_.func_196958_f()) { -+ if (!p_184231_4_.isAir(field_70170_p, p_184231_5_)) { - double d0 = Math.min((double)(0.2F + f / 15.0F), 2.5D); - int i = (int)(150.0D * d0); -- ((ServerWorld)this.field_70170_p).func_195598_a(new BlockParticleData(ParticleTypes.field_197611_d, p_184231_4_), this.func_226277_ct_(), this.func_226278_cu_(), this.func_226281_cx_(), i, 0.0D, 0.0D, 0.0D, (double)0.15F); -+ if (!p_184231_4_.addLandingEffects((ServerWorld)this.field_70170_p, p_184231_5_, p_184231_4_, this, i)) -+ ((ServerWorld)this.field_70170_p).func_195598_a(new BlockParticleData(ParticleTypes.field_197611_d, p_184231_4_).setPos(p_184231_5_), this.func_226277_ct_(), this.func_226278_cu_(), this.func_226281_cx_(), i, 0.0D, 0.0D, 0.0D, (double)0.15F); - } - } - -@@ -330,7 +_,7 @@ - } - } - -- if (!this.field_70170_p.field_72995_K && this.func_184218_aH() && this.func_184187_bx() != null && !this.func_184187_bx().func_205710_ba()) { -+ if (!this.field_70170_p.field_72995_K && this.func_184218_aH() && this.func_184187_bx() != null && !this.func_184187_bx().canBeRiddenInWater(this)) { - this.func_184210_p(); - } - } else if (this.func_70086_ai() < this.func_205010_bg()) { -@@ -475,7 +_,7 @@ - protected void func_70609_aI() { - ++this.field_70725_aQ; - if (this.field_70725_aQ == 20) { -- this.func_70106_y(); -+ this.remove(this instanceof net.minecraft.entity.player.ServerPlayerEntity); //Forge keep data until we revive player - - for(int i = 0; i < 20; ++i) { - double d0 = this.field_70146_Z.nextGaussian() * 0.02D; -@@ -668,7 +_,7 @@ - if (!effectinstance.func_76455_a(this, () -> { - this.func_70695_b(effectinstance, true); - })) { -- if (!this.field_70170_p.field_72995_K) { -+ if (!this.field_70170_p.field_72995_K && !net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.living.PotionEvent.PotionExpiryEvent(this, effectinstance))) { - iterator.remove(); - this.func_70688_c(effectinstance); - } -@@ -717,8 +_,10 @@ - this.func_82142_c(false); - } else { - Collection collection = this.field_70713_bf.values(); -- this.field_70180_af.func_187227_b(field_184634_g, func_184593_a(collection)); -- this.field_70180_af.func_187227_b(field_184633_f, PotionUtils.func_185181_a(collection)); -+ net.minecraftforge.event.entity.living.PotionColorCalculationEvent event = new net.minecraftforge.event.entity.living.PotionColorCalculationEvent(this, PotionUtils.func_185181_a(collection), func_184593_a(collection), collection); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); -+ this.field_70180_af.func_187227_b(field_184634_g, event.areParticlesHidden()); -+ this.field_70180_af.func_187227_b(field_184633_f, event.getColor()); - this.func_82142_c(this.func_70644_a(Effects.field_76441_p)); - } - -@@ -747,7 +_,7 @@ - d0 *= 0.5D; - } - } -- -+ d0 = net.minecraftforge.common.ForgeHooks.getEntityVisibilityMultiplier(this, p_213340_1_, d0); - return d0; - } - -@@ -782,7 +_,9 @@ - - boolean flag; - for(flag = false; iterator.hasNext(); flag = true) { -- this.func_70688_c(iterator.next()); -+ EffectInstance effect = iterator.next(); -+ if(net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.living.PotionEvent.PotionRemoveEvent(this, effect))) continue; -+ this.func_70688_c(effect); - iterator.remove(); - } - -@@ -812,6 +_,7 @@ - return false; - } else { - EffectInstance effectinstance = this.field_70713_bf.get(p_195064_1_.func_188419_a()); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.living.PotionEvent.PotionAddedEvent(this, effectinstance, p_195064_1_)); - if (effectinstance == null) { - this.field_70713_bf.put(p_195064_1_.func_188419_a(), p_195064_1_); - this.func_70670_a(p_195064_1_); -@@ -826,6 +_,9 @@ - } - - public boolean func_70687_e(EffectInstance p_70687_1_) { -+ net.minecraftforge.event.entity.living.PotionEvent.PotionApplicableEvent event = new net.minecraftforge.event.entity.living.PotionEvent.PotionApplicableEvent(this, p_70687_1_); -+ 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.func_70668_bt() == CreatureAttribute.field_223223_b_) { - Effect effect = p_70687_1_.func_188419_a(); - if (effect == Effects.field_76428_l || effect == Effects.field_76436_u) { -@@ -859,6 +_,7 @@ - } - - public boolean func_195063_d(Effect p_195063_1_) { -+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.living.PotionEvent.PotionRemoveEvent(this, p_195063_1_))) return false; - EffectInstance effectinstance = this.func_184596_c(p_195063_1_); - if (effectinstance != null) { - this.func_70688_c(effectinstance); -@@ -895,6 +_,8 @@ - } - - public void func_70691_i(float p_70691_1_) { -+ p_70691_1_ = net.minecraftforge.event.ForgeEventFactory.onLivingHeal(this, p_70691_1_); -+ if (p_70691_1_ <= 0) return; - float f = this.func_110143_aJ(); - if (f > 0.0F) { - this.func_70606_j(f + p_70691_1_); -@@ -915,6 +_,7 @@ - } - - public boolean func_70097_a(DamageSource p_70097_1_, float p_70097_2_) { -+ if (!net.minecraftforge.common.ForgeHooks.onLivingAttack(this, p_70097_1_, p_70097_2_)) return false; - if (this.func_180431_b(p_70097_1_)) { - return false; - } else if (this.field_70170_p.field_72995_K) { -@@ -981,8 +_,8 @@ - if (entity1 instanceof PlayerEntity) { - this.field_70718_bc = 100; - this.field_70717_bb = (PlayerEntity)entity1; -- } else if (entity1 instanceof WolfEntity) { -- WolfEntity wolfentity = (WolfEntity)entity1; -+ } else if (entity1 instanceof net.minecraft.entity.passive.TameableEntity) { -+ net.minecraft.entity.passive.TameableEntity wolfentity = (net.minecraft.entity.passive.TameableEntity)entity1; - if (wolfentity.func_70909_n()) { - this.field_70718_bc = 100; - LivingEntity livingentity = wolfentity.func_70902_q(); -@@ -1165,6 +_,7 @@ - } - - public void func_70645_a(DamageSource p_70645_1_) { -+ if (net.minecraftforge.common.ForgeHooks.onLivingDeath(this, p_70645_1_)) return; - if (!this.field_70128_L && !this.field_70729_aU) { - Entity entity = p_70645_1_.func_76346_g(); - LivingEntity livingentity = this.func_94060_bK(); -@@ -1196,10 +_,10 @@ - if (!this.field_70170_p.field_72995_K) { - boolean flag = false; - if (p_226298_1_ instanceof WitherEntity) { -- if (this.field_70170_p.func_82736_K().func_223586_b(GameRules.field_223599_b)) { -+ if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.field_70170_p, this)) { - BlockPos blockpos = this.func_233580_cy_(); - BlockState blockstate = Blocks.field_222388_bz.func_176223_P(); -- if (this.field_70170_p.func_180495_p(blockpos).func_196958_f() && blockstate.func_196955_c(this.field_70170_p, blockpos)) { -+ if (this.field_70170_p.func_175623_d(blockpos) && blockstate.func_196955_c(this.field_70170_p, blockpos)) { - this.field_70170_p.func_180501_a(blockpos, blockstate, 3); - flag = true; - } -@@ -1216,12 +_,9 @@ - - protected void func_213345_d(DamageSource p_213345_1_) { - Entity entity = p_213345_1_.func_76346_g(); -- int i; -- if (entity instanceof PlayerEntity) { -- i = EnchantmentHelper.func_185283_h((LivingEntity)entity); -- } else { -- i = 0; -- } -+ -+ int i = net.minecraftforge.common.ForgeHooks.getLootingLevel(this, entity, p_213345_1_); -+ this.captureDrops(new java.util.ArrayList<>()); - - boolean flag = this.field_70718_bc > 0; - if (this.func_230282_cS_() && this.field_70170_p.func_82736_K().func_223586_b(GameRules.field_223602_e)) { -@@ -1231,6 +_,10 @@ - - this.func_213337_cE(); - this.func_226294_cV_(); -+ -+ Collection drops = captureDrops(null); -+ if (!net.minecraftforge.common.ForgeHooks.onLivingDrops(this, p_213345_1_, drops, i, field_70718_bc > 0)) -+ drops.forEach(e -> field_70170_p.func_217376_c(e)); - } - - protected void func_213337_cE() { -@@ -1240,6 +_,7 @@ - if (!this.field_70170_p.field_72995_K && (this.func_70684_aJ() || this.field_70718_bc > 0 && this.func_146066_aG() && this.field_70170_p.func_82736_K().func_223586_b(GameRules.field_223602_e))) { - int i = this.func_70693_a(this.field_70717_bb); - -+ i = net.minecraftforge.event.ForgeEventFactory.getExperienceDrop(this, this.field_70717_bb, i); - while(i > 0) { - int j = ExperienceOrbEntity.func_70527_a(i); - i -= j; -@@ -1260,7 +_,8 @@ - ResourceLocation resourcelocation = this.func_213346_cF(); - LootTable loottable = this.field_70170_p.func_73046_m().func_200249_aQ().func_186521_a(resourcelocation); - LootContext.Builder lootcontext$builder = this.func_213363_a(p_213354_2_, p_213354_1_); -- loottable.func_216120_b(lootcontext$builder.func_216022_a(LootParameterSets.field_216263_d), this::func_199701_a_); -+ LootContext ctx = lootcontext$builder.func_216022_a(LootParameterSets.field_216263_d); -+ loottable.func_216113_a(ctx).forEach(this::func_199701_a_); - } - - protected LootContext.Builder func_213363_a(boolean p_213363_1_, DamageSource p_213363_2_) { -@@ -1273,6 +_,11 @@ - } - - public void func_233627_a_(float p_233627_1_, double p_233627_2_, double p_233627_4_) { -+ net.minecraftforge.event.entity.living.LivingKnockBackEvent event = net.minecraftforge.common.ForgeHooks.onLivingKnockBack(this, p_233627_1_, p_233627_2_, p_233627_4_); -+ if(event.isCanceled()) return; -+ p_233627_1_ = event.getStrength(); -+ p_233627_2_ = event.getRatioX(); -+ p_233627_4_ = event.getRatioZ(); - p_233627_1_ = (float)((double)p_233627_1_ * (1.0D - this.func_233637_b_(Attributes.field_233820_c_))); - if (!(p_233627_1_ <= 0.0F)) { - this.field_70160_al = true; -@@ -1322,16 +_,7 @@ - } else { - BlockPos blockpos = this.func_233580_cy_(); - BlockState blockstate = this.func_213339_cH(); -- Block block = blockstate.func_177230_c(); -- if (block.func_203417_a(BlockTags.field_232878_as_)) { -- this.field_233624_bE_ = Optional.of(blockpos); -- return true; -- } else if (block instanceof TrapDoorBlock && this.func_184604_a(blockpos, blockstate)) { -- this.field_233624_bE_ = Optional.of(blockpos); -- return true; -- } else { -- return false; -- } -+ return net.minecraftforge.common.ForgeHooks.isLivingOnLadder(blockstate, field_70170_p, blockpos, this); - } - } - -@@ -1355,6 +_,11 @@ - } - - public boolean func_225503_b_(float p_225503_1_, float p_225503_2_) { -+ float[] ret = net.minecraftforge.common.ForgeHooks.onLivingFall(this, p_225503_1_, p_225503_2_); -+ if (ret == null) return false; -+ p_225503_1_ = ret[0]; -+ p_225503_2_ = ret[1]; -+ - boolean flag = super.func_225503_b_(p_225503_1_, p_225503_2_); - int i = this.func_225508_e_(p_225503_1_, p_225503_2_); - if (i > 0) { -@@ -1378,9 +_,10 @@ - int i = MathHelper.func_76128_c(this.func_226277_ct_()); - int j = MathHelper.func_76128_c(this.func_226278_cu_() - (double)0.2F); - int k = MathHelper.func_76128_c(this.func_226281_cx_()); -- BlockState blockstate = this.field_70170_p.func_180495_p(new BlockPos(i, j, k)); -- if (!blockstate.func_196958_f()) { -- SoundType soundtype = blockstate.func_215695_r(); -+ BlockPos pos = new BlockPos(i, j, k); -+ BlockState blockstate = this.field_70170_p.func_180495_p(pos); -+ if (!blockstate.isAir(this.field_70170_p, pos)) { -+ SoundType soundtype = blockstate.getSoundType(field_70170_p, pos, this); - this.func_184185_a(soundtype.func_185842_g(), soundtype.func_185843_a() * 0.5F, soundtype.func_185847_b() * 0.75F); - } - -@@ -1448,6 +_,8 @@ - - protected void func_70665_d(DamageSource p_70665_1_, float p_70665_2_) { - if (!this.func_180431_b(p_70665_1_)) { -+ p_70665_2_ = net.minecraftforge.common.ForgeHooks.onLivingHurt(this, p_70665_1_, p_70665_2_); -+ if (p_70665_2_ <= 0) return; - p_70665_2_ = this.func_70655_b(p_70665_1_, p_70665_2_); - p_70665_2_ = this.func_70672_c(p_70665_1_, p_70665_2_); - float f2 = Math.max(p_70665_2_ - this.func_110139_bj(), 0.0F); -@@ -1457,10 +_,11 @@ - ((ServerPlayerEntity)p_70665_1_.func_76346_g()).func_195067_a(Stats.field_212735_F, Math.round(f * 10.0F)); - } - -+ f2 = net.minecraftforge.common.ForgeHooks.onLivingDamage(this, p_70665_1_, f2); - if (f2 != 0.0F) { - float f1 = this.func_110143_aJ(); -- this.func_70606_j(f1 - f2); - this.func_110142_aN().func_94547_a(p_70665_1_, f1, f2); -+ this.func_70606_j(f1 - f2); // Forge: moved to fix MC-121048 - this.func_110149_m(this.func_110139_bj() - f2); - } - } -@@ -1514,6 +_,8 @@ - } - - public void func_226292_a_(Hand p_226292_1_, boolean p_226292_2_) { -+ ItemStack stack = this.func_184586_b(p_226292_1_); -+ if (!stack.func_190926_b() && stack.onEntitySwing(this)) return; - if (!this.field_82175_bq || this.field_110158_av >= this.func_82166_i() / 2 || this.field_110158_av < 0) { - this.field_110158_av = -1; - this.field_82175_bq = true; -@@ -1848,15 +_,16 @@ - } - - this.field_70160_al = true; -+ net.minecraftforge.common.ForgeHooks.onLivingJump(this); - } - - @OnlyIn(Dist.CLIENT) - protected void func_203010_cG() { -- this.func_213317_d(this.func_213322_ci().func_72441_c(0.0D, (double)-0.04F, 0.0D)); -+ this.func_213317_d(this.func_213322_ci().func_72441_c(0.0D, (double)-0.04F * this.func_110148_a(net.minecraftforge.common.ForgeMod.SWIM_SPEED.get()).func_111126_e(), 0.0D)); - } - - protected void func_180466_bG(ITag p_180466_1_) { -- this.func_213317_d(this.func_213322_ci().func_72441_c(0.0D, (double)0.04F, 0.0D)); -+ this.func_213317_d(this.func_213322_ci().func_72441_c(0.0D, (double)0.04F * this.func_110148_a(net.minecraftforge.common.ForgeMod.SWIM_SPEED.get()).func_111126_e(), 0.0D)); - } - - protected float func_189749_co() { -@@ -1870,11 +_,15 @@ - public void func_213352_e(Vector3d p_213352_1_) { - if (this.func_70613_aW() || this.func_184186_bw()) { - double d0 = 0.08D; -+ ModifiableAttributeInstance gravity = this.func_110148_a(net.minecraftforge.common.ForgeMod.ENTITY_GRAVITY.get()); - boolean flag = this.func_213322_ci().field_72448_b <= 0.0D; - if (flag && this.func_70644_a(Effects.field_204839_B)) { -- d0 = 0.01D; -+ if (!gravity.func_180374_a(SLOW_FALLING)) gravity.func_233767_b_(SLOW_FALLING); - this.field_70143_R = 0.0F; -+ } else if (gravity.func_180374_a(SLOW_FALLING)) { -+ gravity.func_111124_b(SLOW_FALLING); - } -+ d0 = gravity.func_111126_e(); - - FluidState fluidstate = this.field_70170_p.func_204610_c(this.func_233580_cy_()); - if (this.func_70090_H() && this.func_241208_cS_() && !this.func_230285_a_(fluidstate.func_206886_c())) { -@@ -1899,6 +_,7 @@ - f5 = 0.96F; - } - -+ f6 *= (float)this.func_110148_a(net.minecraftforge.common.ForgeMod.SWIM_SPEED.get()).func_111126_e(); - this.func_213309_a(f6, p_213352_1_); - this.func_213315_a(MoverType.SELF, this.func_213322_ci()); - Vector3d vector3d6 = this.func_213322_ci(); -@@ -1977,7 +_,7 @@ - } - } else { - BlockPos blockpos = this.func_226270_aj_(); -- float f3 = this.field_70170_p.func_180495_p(blockpos).func_177230_c().func_208618_m(); -+ float f3 = this.field_70170_p.func_180495_p(this.func_226270_aj_()).getSlipperiness(field_70170_p, this.func_226270_aj_(), this); - float f4 = this.field_70122_E ? f3 * 0.91F : 0.91F; - Vector3d vector3d5 = this.func_233633_a_(p_213352_1_, f3); - double d2 = vector3d5.field_72448_b; -@@ -2049,7 +_,7 @@ - double d0 = MathHelper.func_151237_a(p_213362_1_.field_72450_a, (double)-0.15F, (double)0.15F); - double d1 = MathHelper.func_151237_a(p_213362_1_.field_72449_c, (double)-0.15F, (double)0.15F); - double d2 = Math.max(p_213362_1_.field_72448_b, (double)-0.15F); -- if (d2 < 0.0D && !this.func_213339_cH().func_203425_a(Blocks.field_222420_lI) && this.func_230491_ea_() && this instanceof PlayerEntity) { -+ if (d2 < 0.0D && !this.func_213339_cH().isScaffolding(this) && this.func_230491_ea_() && this instanceof PlayerEntity) { - d2 = 0.0D; - } - -@@ -2077,6 +_,7 @@ - } - - public void func_70071_h_() { -+ if (net.minecraftforge.common.ForgeHooks.onLivingUpdate(this)) return; - super.func_70071_h_(); - this.func_184608_ct(); - this.func_205014_p(); -@@ -2232,6 +_,7 @@ - - ItemStack itemstack1 = this.func_184582_a(equipmentslottype); - if (!ItemStack.func_77989_b(itemstack1, itemstack)) { -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.living.LivingEquipmentChangeEvent(this, equipmentslottype, itemstack, itemstack1)); - if (map == null) { - map = Maps.newEnumMap(EquipmentSlotType.class); - } -@@ -2436,6 +_,8 @@ - boolean flag = this.func_70083_f(7); - if (flag && !this.field_70122_E && !this.func_184218_aH() && !this.func_70644_a(Effects.field_188424_y)) { - ItemStack itemstack = this.func_184582_a(EquipmentSlotType.CHEST); -+ flag = itemstack.canElytraFly(this) && itemstack.elytraFlightTick(this, this.field_184629_bo); -+ if (false) //Forge: Moved to ElytraItem - if (itemstack.func_77973_b() == Items.field_185160_cR && ElytraItem.func_185069_d(itemstack)) { - flag = true; - if (!this.field_70170_p.field_72995_K && (this.field_184629_bo + 1) % 20 == 0) { -@@ -2668,8 +_,16 @@ - - private void func_184608_ct() { - if (this.func_184587_cr()) { -- if (ItemStack.func_185132_d(this.func_184586_b(this.func_184600_cs()), this.field_184627_bm)) { -- this.field_184627_bm = this.func_184586_b(this.func_184600_cs()); -+ ItemStack itemStack = this.func_184586_b(this.func_184600_cs()); -+ if (net.minecraftforge.common.ForgeHooks.canContinueUsing(this.field_184627_bm, itemStack)) this.field_184627_bm = itemStack; -+ if (itemStack == this.field_184627_bm) { -+ -+ if (!this.field_184627_bm.func_190926_b()) { -+ field_184628_bn = net.minecraftforge.event.ForgeEventFactory.onItemUseTick(this, field_184627_bm, field_184628_bn); -+ if (field_184628_bn > 0) -+ field_184627_bm.onUsingTick(this, field_184628_bn); -+ } -+ - this.field_184627_bm.func_222121_b(this.field_70170_p, this, this.func_184605_cv()); - if (this.func_226299_p_()) { - this.func_226293_b_(this.field_184627_bm, 5); -@@ -2717,8 +_,10 @@ - public void func_184598_c(Hand p_184598_1_) { - ItemStack itemstack = this.func_184586_b(p_184598_1_); - if (!itemstack.func_190926_b() && !this.func_184587_cr()) { -+ int duration = net.minecraftforge.event.ForgeEventFactory.onItemUseStart(this, itemstack, itemstack.func_77988_m()); -+ if (duration <= 0) return; - this.field_184627_bm = itemstack; -- this.field_184628_bn = itemstack.func_77988_m(); -+ this.field_184628_bn = duration; - if (!this.field_70170_p.field_72995_K) { - this.func_204802_c(1, true); - this.func_204802_c(2, p_184598_1_ == Hand.OFF_HAND); -@@ -2778,6 +_,9 @@ - vector3d1 = vector3d1.func_178789_a(-this.field_70125_A * ((float)Math.PI / 180F)); - vector3d1 = vector3d1.func_178785_b(-this.field_70177_z * ((float)Math.PI / 180F)); - vector3d1 = vector3d1.func_72441_c(this.func_226277_ct_(), this.func_226280_cw_(), this.func_226281_cx_()); -+ if (this.field_70170_p instanceof ServerWorld) //Forge: Fix MC-2518 spawnParticle is nooped on server, need to use server specific variant -+ ((ServerWorld)this.field_70170_p).func_195598_a(new ItemParticleData(ParticleTypes.field_197591_B, p_195062_1_), vector3d1.field_72450_a, vector3d1.field_72448_b, vector3d1.field_72449_c, 1, vector3d.field_72450_a, vector3d.field_72448_b + 0.05D, vector3d.field_72449_c, 0.0D); -+ else - this.field_70170_p.func_195594_a(new ItemParticleData(ParticleTypes.field_197591_B, p_195062_1_), vector3d1.field_72450_a, vector3d1.field_72448_b, vector3d1.field_72449_c, vector3d.field_72450_a, vector3d.field_72448_b + 0.05D, vector3d.field_72449_c); - } - -@@ -2790,7 +_,8 @@ - } else { - if (!this.field_184627_bm.func_190926_b() && this.func_184587_cr()) { - this.func_226293_b_(this.field_184627_bm, 16); -- ItemStack itemstack = this.field_184627_bm.func_77950_b(this.field_70170_p, this); -+ ItemStack copy = this.field_184627_bm.func_77946_l(); -+ ItemStack itemstack = net.minecraftforge.event.ForgeEventFactory.onItemUseFinish(this, copy, func_184605_cv(), this.field_184627_bm.func_77950_b(this.field_70170_p, this)); - if (itemstack != this.field_184627_bm) { - this.func_184611_a(hand, itemstack); - } -@@ -2815,7 +_,11 @@ - - public void func_184597_cx() { - if (!this.field_184627_bm.func_190926_b()) { -+ if (!net.minecraftforge.event.ForgeEventFactory.onUseItemStop(this, field_184627_bm, this.func_184605_cv())) { -+ ItemStack copy = this instanceof PlayerEntity ? field_184627_bm.func_77946_l() : null; - this.field_184627_bm.func_77974_b(this.field_70170_p, this, this.func_184605_cv()); -+ if (copy != null && field_184627_bm.func_190926_b()) net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem((PlayerEntity)this, copy, func_184600_cs()); -+ } - if (this.field_184627_bm.func_222122_m()) { - this.func_184608_ct(); - } -@@ -2964,8 +_,8 @@ - } - - BlockState blockstate = this.field_70170_p.func_180495_p(p_213342_1_); -- if (blockstate.func_177230_c() instanceof BedBlock) { -- this.field_70170_p.func_180501_a(p_213342_1_, blockstate.func_206870_a(BedBlock.field_176471_b, Boolean.valueOf(true)), 3); -+ if (blockstate.isBed(field_70170_p, p_213342_1_, this)) { -+ blockstate.setBedOccupied(field_70170_p, p_213342_1_, this, true); - } - - this.func_213301_b(Pose.SLEEPING); -@@ -2981,15 +_,15 @@ - - private boolean func_213359_p() { - return this.func_213374_dv().map((p_241350_1_) -> { -- return this.field_70170_p.func_180495_p(p_241350_1_).func_177230_c() instanceof BedBlock; -+ return net.minecraftforge.event.ForgeEventFactory.fireSleepingLocationCheck(this, p_241350_1_); - }).orElse(false); - } - - public void func_213366_dy() { - this.func_213374_dv().filter(this.field_70170_p::func_175667_e).ifPresent((p_241348_1_) -> { - BlockState blockstate = this.field_70170_p.func_180495_p(p_241348_1_); -- if (blockstate.func_177230_c() instanceof BedBlock) { -- this.field_70170_p.func_180501_a(p_241348_1_, blockstate.func_206870_a(BedBlock.field_176471_b, Boolean.valueOf(false)), 3); -+ if (blockstate.isBed(field_70170_p, p_241348_1_, this)) { -+ blockstate.setBedOccupied(field_70170_p, p_241348_1_, this, false); - Vector3d vector3d1 = BedBlock.func_242652_a(this.func_200600_R(), this.field_70170_p, p_241348_1_, this.field_70177_z).orElseGet(() -> { - BlockPos blockpos = p_241348_1_.func_177984_a(); - return new Vector3d((double)blockpos.func_177958_n() + 0.5D, (double)blockpos.func_177956_o() + 0.1D, (double)blockpos.func_177952_p() + 0.5D); -@@ -3012,7 +_,9 @@ - @OnlyIn(Dist.CLIENT) - public Direction func_213376_dz() { - BlockPos blockpos = this.func_213374_dv().orElse((BlockPos)null); -- return blockpos != null ? BedBlock.func_220174_a(this.field_70170_p, blockpos) : null; -+ if (blockpos == null) return Direction.UP; -+ BlockState state = this.field_70170_p.func_180495_p(blockpos); -+ return !state.isBed(field_70170_p, blockpos, this) ? Direction.UP : state.getBedDirection(field_70170_p, blockpos); - } - - public boolean func_70094_T() { -@@ -3080,6 +_,58 @@ - - public void func_213334_d(Hand p_213334_1_) { - this.func_213361_c(p_213334_1_ == Hand.MAIN_HAND ? EquipmentSlotType.MAINHAND : EquipmentSlotType.OFFHAND); -+ } -+ -+ /* ==== FORGE START ==== */ -+ /*** -+ * Removes all potion effects that have curativeItem as a curative item for its effect -+ * @param curativeItem The itemstack we are using to cure potion effects -+ */ -+ public boolean curePotionEffects(ItemStack curativeItem) { -+ if (this.field_70170_p.field_72995_K) -+ return false; -+ boolean ret = false; -+ Iterator itr = this.field_70713_bf.values().iterator(); -+ while (itr.hasNext()) { -+ EffectInstance effect = itr.next(); -+ if (effect.isCurativeItem(curativeItem) && !net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.living.PotionEvent.PotionRemoveEvent(this, effect))) { -+ this.func_70688_c(effect); -+ itr.remove(); -+ ret = true; -+ this.field_70752_e = true; -+ } -+ } -+ return ret; -+ } -+ -+ /** -+ * Returns true if the entity's rider (EntityPlayer) should face forward when mounted. -+ * currently only used in vanilla code by pigs. -+ * -+ * @param player The player who is riding the entity. -+ * @return If the player should orient the same direction as this entity. -+ */ -+ public boolean shouldRiderFaceForward(PlayerEntity player) { -+ return this instanceof net.minecraft.entity.passive.PigEntity; -+ } -+ -+ private final net.minecraftforge.common.util.LazyOptional[] handlers = net.minecraftforge.items.wrapper.EntityEquipmentInvWrapper.create(this); -+ -+ @Override -+ public net.minecraftforge.common.util.LazyOptional getCapability(net.minecraftforge.common.capabilities.Capability capability, @Nullable Direction facing) { -+ if (this.func_70089_S() && capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { -+ if (facing == null) return handlers[2].cast(); -+ else if (facing.func_176740_k().func_200128_b()) return handlers[0].cast(); -+ else if (facing.func_176740_k().func_176722_c()) return handlers[1].cast(); -+ } -+ return super.getCapability(capability, facing); -+ } -+ -+ @Override -+ protected void invalidateCaps() { -+ super.invalidateCaps(); -+ for (int x = 0; x < handlers.length; x++) -+ handlers[x].invalidate(); - } - - @OnlyIn(Dist.CLIENT) diff --git a/patches/minecraft/net/minecraft/entity/MobEntity.java.patch b/patches/minecraft/net/minecraft/entity/MobEntity.java.patch deleted file mode 100644 index 802b557c05..0000000000 --- a/patches/minecraft/net/minecraft/entity/MobEntity.java.patch +++ /dev/null @@ -1,52 +0,0 @@ ---- a/net/minecraft/entity/MobEntity.java -+++ b/net/minecraft/entity/MobEntity.java -@@ -198,6 +_,7 @@ - - public void func_70624_b(@Nullable LivingEntity p_70624_1_) { - this.field_70696_bz = p_70624_1_; -+ net.minecraftforge.common.ForgeHooks.onLivingSetAttackTarget(this, p_70624_1_); - } - - public boolean func_213358_a(EntityType p_213358_1_) { -@@ -486,7 +_,7 @@ - public void func_70636_d() { - super.func_70636_d(); - this.field_70170_p.func_217381_Z().func_76320_a("looting"); -- if (!this.field_70170_p.field_72995_K && this.func_98052_bS() && this.func_70089_S() && !this.field_70729_aU && this.field_70170_p.func_82736_K().func_223586_b(GameRules.field_223599_b)) { -+ if (!this.field_70170_p.field_72995_K && this.func_98052_bS() && this.func_70089_S() && !this.field_70729_aU && net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.field_70170_p, this)) { - for(ItemEntity itementity : this.field_70170_p.func_217357_a(ItemEntity.class, this.func_174813_aQ().func_72314_b(1.0D, 0.0D, 1.0D))) { - if (!itementity.field_70128_L && !itementity.func_92059_d().func_190926_b() && !itementity.func_174874_s() && this.func_230293_i_(itementity.func_92059_d())) { - this.func_175445_a(itementity); -@@ -639,6 +_,14 @@ - this.func_70106_y(); - } else if (!this.func_104002_bU() && !this.func_213392_I()) { - Entity entity = this.field_70170_p.func_217362_a(this, -1.0D); -+ net.minecraftforge.eventbus.api.Event.Result result = net.minecraftforge.event.ForgeEventFactory.canEntityDespawn(this); -+ if (result == net.minecraftforge.eventbus.api.Event.Result.DENY) { -+ field_70708_bq = 0; -+ entity = null; -+ } else if (result == net.minecraftforge.eventbus.api.Event.Result.ALLOW) { -+ this.func_70106_y(); -+ entity = null; -+ } - if (entity != null) { - double d0 = entity.func_70068_e(this); - int i = this.func_200600_R().func_220339_d().func_233671_f_(); -@@ -879,6 +_,8 @@ - } - - public static EquipmentSlotType func_184640_d(ItemStack p_184640_0_) { -+ final EquipmentSlotType slot = p_184640_0_.getEquipmentSlot(); -+ if (slot != null) return slot; // FORGE: Allow modders to set a non-default equipment slot for a stack; e.g. a non-armor chestplate-slot item - Item item = p_184640_0_.func_77973_b(); - if (item != Blocks.field_196625_cS.func_199767_j() && (!(item instanceof BlockItem) || !(((BlockItem)item).func_179223_d() instanceof AbstractSkullBlock))) { - if (item instanceof ArmorItem) { -@@ -886,7 +_,7 @@ - } else if (item == Items.field_185160_cR) { - return EquipmentSlotType.CHEST; - } else { -- return item == Items.field_185159_cQ ? EquipmentSlotType.OFFHAND : EquipmentSlotType.MAINHAND; -+ return p_184640_0_.isShield(null) ? EquipmentSlotType.OFFHAND : EquipmentSlotType.MAINHAND; - } - } else { - return EquipmentSlotType.HEAD; diff --git a/patches/minecraft/net/minecraft/entity/ai/attributes/Attribute.java.patch b/patches/minecraft/net/minecraft/entity/ai/attributes/Attribute.java.patch deleted file mode 100644 index 3042cce5c6..0000000000 --- a/patches/minecraft/net/minecraft/entity/ai/attributes/Attribute.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/entity/ai/attributes/Attribute.java -+++ b/net/minecraft/entity/ai/attributes/Attribute.java -@@ -1,6 +_,6 @@ - package net.minecraft.entity.ai.attributes; - --public class Attribute { -+public class Attribute extends net.minecraftforge.registries.ForgeRegistryEntry { - private final double field_233750_a_; - private boolean field_233751_b_; - private final String field_233752_c_; diff --git a/patches/minecraft/net/minecraft/entity/ai/attributes/AttributeModifierMap.java.patch b/patches/minecraft/net/minecraft/entity/ai/attributes/AttributeModifierMap.java.patch deleted file mode 100644 index 38956c2b48..0000000000 --- a/patches/minecraft/net/minecraft/entity/ai/attributes/AttributeModifierMap.java.patch +++ /dev/null @@ -1,33 +0,0 @@ ---- a/net/minecraft/entity/ai/attributes/AttributeModifierMap.java -+++ b/net/minecraft/entity/ai/attributes/AttributeModifierMap.java -@@ -69,6 +_,22 @@ - public static class MutableAttribute { - private final Map field_233811_a_ = Maps.newHashMap(); - private boolean field_233812_b_; -+ private final java.util.List others = new java.util.ArrayList<>(); -+ -+ public MutableAttribute() { } -+ -+ public MutableAttribute(AttributeModifierMap attributeMap) { -+ this.field_233811_a_.putAll(attributeMap.field_233802_a_); -+ } -+ -+ public void combine(MutableAttribute other) { -+ this.field_233811_a_.putAll(other.field_233811_a_); -+ others.add(other); -+ } -+ -+ public boolean hasAttribute(Attribute attribute) { -+ return this.field_233811_a_.containsKey(attribute); -+ } - - private ModifiableAttributeInstance func_233817_b_(Attribute p_233817_1_) { - ModifiableAttributeInstance modifiableattributeinstance = new ModifiableAttributeInstance(p_233817_1_, (p_233816_2_) -> { -@@ -93,6 +_,7 @@ - - public AttributeModifierMap func_233813_a_() { - this.field_233812_b_ = true; -+ others.forEach(o -> o.field_233812_b_ = true); - return new AttributeModifierMap(this.field_233811_a_); - } - } diff --git a/patches/minecraft/net/minecraft/entity/ai/attributes/GlobalEntityTypeAttributes.java.patch b/patches/minecraft/net/minecraft/entity/ai/attributes/GlobalEntityTypeAttributes.java.patch deleted file mode 100644 index 492ca2c665..0000000000 --- a/patches/minecraft/net/minecraft/entity/ai/attributes/GlobalEntityTypeAttributes.java.patch +++ /dev/null @@ -1,27 +0,0 @@ ---- a/net/minecraft/entity/ai/attributes/GlobalEntityTypeAttributes.java -+++ b/net/minecraft/entity/ai/attributes/GlobalEntityTypeAttributes.java -@@ -72,13 +_,22 @@ - public class GlobalEntityTypeAttributes { - private static final Logger field_233832_a_ = LogManager.getLogger(); - private static final Map, AttributeModifierMap> field_233833_b_ = ImmutableMap., AttributeModifierMap>builder().put(EntityType.field_200789_c, LivingEntity.func_233639_cI_().func_233813_a_()).put(EntityType.field_200791_e, BatEntity.func_234175_m_().func_233813_a_()).put(EntityType.field_226289_e_, BeeEntity.func_234182_eX_().func_233813_a_()).put(EntityType.field_200792_f, BlazeEntity.func_234276_m_().func_233813_a_()).put(EntityType.field_220360_g, CatEntity.func_234184_eY_().func_233813_a_()).put(EntityType.field_200794_h, CaveSpiderEntity.func_234277_m_().func_233813_a_()).put(EntityType.field_200795_i, ChickenEntity.func_234187_eI_().func_233813_a_()).put(EntityType.field_203780_j, AbstractFishEntity.func_234176_m_().func_233813_a_()).put(EntityType.field_200796_j, CowEntity.func_234188_eI_().func_233813_a_()).put(EntityType.field_200797_k, CreeperEntity.func_234278_m_().func_233813_a_()).put(EntityType.field_205137_n, DolphinEntity.func_234190_eK_().func_233813_a_()).put(EntityType.field_200798_l, AbstractChestedHorseEntity.func_234234_eJ_().func_233813_a_()).put(EntityType.field_204724_o, ZombieEntity.func_234342_eQ_().func_233813_a_()).put(EntityType.field_200800_n, ElderGuardianEntity.func_234283_m_().func_233813_a_()).put(EntityType.field_200803_q, EndermanEntity.func_234287_m_().func_233813_a_()).put(EntityType.field_200804_r, EndermiteEntity.func_234288_m_().func_233813_a_()).put(EntityType.field_200802_p, EnderDragonEntity.func_234257_m_().func_233813_a_()).put(EntityType.field_200806_t, EvokerEntity.func_234289_eI_().func_233813_a_()).put(EntityType.field_220356_B, FoxEntity.func_234192_eI_().func_233813_a_()).put(EntityType.field_200811_y, GhastEntity.func_234290_eH_().func_233813_a_()).put(EntityType.field_200812_z, GiantEntity.func_234291_m_().func_233813_a_()).put(EntityType.field_200761_A, GuardianEntity.func_234292_eK_().func_233813_a_()).put(EntityType.field_233588_G_, HoglinEntity.func_234362_eI_().func_233813_a_()).put(EntityType.field_200762_B, AbstractHorseEntity.func_234237_fg_().func_233813_a_()).put(EntityType.field_200763_C, ZombieEntity.func_234342_eQ_().func_233813_a_()).put(EntityType.field_200764_D, IllusionerEntity.func_234293_eI_().func_233813_a_()).put(EntityType.field_200757_aw, IronGolemEntity.func_234200_m_().func_233813_a_()).put(EntityType.field_200769_I, LlamaEntity.func_234244_fu_().func_233813_a_()).put(EntityType.field_200771_K, MagmaCubeEntity.func_234294_m_().func_233813_a_()).put(EntityType.field_200780_T, CowEntity.func_234188_eI_().func_233813_a_()).put(EntityType.field_200779_S, AbstractChestedHorseEntity.func_234234_eJ_().func_233813_a_()).put(EntityType.field_200781_U, OcelotEntity.func_234201_eI_().func_233813_a_()).put(EntityType.field_220353_aa, PandaEntity.func_234204_eW_().func_233813_a_()).put(EntityType.field_200783_W, ParrotEntity.func_234213_eS_().func_233813_a_()).put(EntityType.field_203097_aH, MonsterEntity.func_234295_eP_().func_233813_a_()).put(EntityType.field_200784_X, PigEntity.func_234215_eI_().func_233813_a_()).put(EntityType.field_233591_ai_, PiglinEntity.func_234420_eI_().func_233813_a_()).put(EntityType.field_242287_aj, PiglinBruteEntity.func_242344_eS().func_233813_a_()).put(EntityType.field_220350_aJ, PillagerEntity.func_234296_eI_().func_233813_a_()).put(EntityType.field_200729_aH, PlayerEntity.func_234570_el_().func_233813_a_()).put(EntityType.field_200786_Z, PolarBearEntity.func_234219_eI_().func_233813_a_()).put(EntityType.field_203779_Z, AbstractFishEntity.func_234176_m_().func_233813_a_()).put(EntityType.field_200736_ab, RabbitEntity.func_234224_eJ_().func_233813_a_()).put(EntityType.field_220352_aU, RavagerEntity.func_234297_m_().func_233813_a_()).put(EntityType.field_203778_ae, AbstractFishEntity.func_234176_m_().func_233813_a_()).put(EntityType.field_200737_ac, SheepEntity.func_234225_eI_().func_233813_a_()).put(EntityType.field_200738_ad, ShulkerEntity.func_234300_m_().func_233813_a_()).put(EntityType.field_200740_af, SilverfishEntity.func_234301_m_().func_233813_a_()).put(EntityType.field_200741_ag, AbstractSkeletonEntity.func_234275_m_().func_233813_a_()).put(EntityType.field_200742_ah, SkeletonHorseEntity.func_234250_eJ_().func_233813_a_()).put(EntityType.field_200743_ai, MonsterEntity.func_234295_eP_().func_233813_a_()).put(EntityType.field_200745_ak, SnowGolemEntity.func_234226_m_().func_233813_a_()).put(EntityType.field_200748_an, SpiderEntity.func_234305_eI_().func_233813_a_()).put(EntityType.field_200749_ao, SquidEntity.func_234227_m_().func_233813_a_()).put(EntityType.field_200750_ap, AbstractSkeletonEntity.func_234275_m_().func_233813_a_()).put(EntityType.field_233589_aE_, StriderEntity.func_234317_eK_().func_233813_a_()).put(EntityType.field_220354_ax, LlamaEntity.func_234244_fu_().func_233813_a_()).put(EntityType.field_204262_at, AbstractFishEntity.func_234176_m_().func_233813_a_()).put(EntityType.field_203099_aq, TurtleEntity.func_234228_eK_().func_233813_a_()).put(EntityType.field_200755_au, VexEntity.func_234321_m_().func_233813_a_()).put(EntityType.field_200756_av, VillagerEntity.func_234551_eU_().func_233813_a_()).put(EntityType.field_200758_ax, VindicatorEntity.func_234322_eI_().func_233813_a_()).put(EntityType.field_220351_aK, MobEntity.func_233666_p_().func_233813_a_()).put(EntityType.field_200759_ay, WitchEntity.func_234323_eI_().func_233813_a_()).put(EntityType.field_200760_az, WitherEntity.func_234258_eI_().func_233813_a_()).put(EntityType.field_200722_aA, AbstractSkeletonEntity.func_234275_m_().func_233813_a_()).put(EntityType.field_200724_aC, WolfEntity.func_234233_eS_().func_233813_a_()).put(EntityType.field_233590_aW_, ZoglinEntity.func_234339_m_().func_233813_a_()).put(EntityType.field_200725_aD, ZombieEntity.func_234342_eQ_().func_233813_a_()).put(EntityType.field_200726_aE, ZombieHorseEntity.func_234256_eJ_().func_233813_a_()).put(EntityType.field_200727_aF, ZombieEntity.func_234342_eQ_().func_233813_a_()).put(EntityType.field_233592_ba_, ZombifiedPiglinEntity.func_234352_eU_().func_233813_a_()).build(); -+ @Deprecated // Remove in 1.17 -+ private static final Map, AttributeModifierMap> FORGE_ATTRIBUTES = net.minecraftforge.common.ForgeHooks.getAttributesView(); -+ -+ /** FORGE: Use net.minecraftforge.event.entity.EntityAttributeCreationEvent#put To be removed in 1.17 */ -+ @Deprecated -+ public static AttributeModifierMap put(EntityType type, AttributeModifierMap map) { -+ return net.minecraftforge.common.ForgeHooks.putAttributesOld(type, map); -+ } - - public static AttributeModifierMap func_233835_a_(EntityType p_233835_0_) { -- return field_233833_b_.get(p_233835_0_); -+ AttributeModifierMap map = FORGE_ATTRIBUTES.get(p_233835_0_); -+ return map != null ? map : field_233833_b_.get(p_233835_0_); - } - - public static boolean func_233837_b_(EntityType p_233837_0_) { -- return field_233833_b_.containsKey(p_233837_0_); -+ return field_233833_b_.containsKey(p_233837_0_) || FORGE_ATTRIBUTES.containsKey(p_233837_0_); - } - - public static void func_233834_a_() { diff --git a/patches/minecraft/net/minecraft/entity/ai/brain/memory/MemoryModuleType.java.patch b/patches/minecraft/net/minecraft/entity/ai/brain/memory/MemoryModuleType.java.patch deleted file mode 100644 index 89f2f6ad11..0000000000 --- a/patches/minecraft/net/minecraft/entity/ai/brain/memory/MemoryModuleType.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/entity/ai/brain/memory/MemoryModuleType.java -+++ b/net/minecraft/entity/ai/brain/memory/MemoryModuleType.java -@@ -23,7 +_,7 @@ - import net.minecraft.util.math.IPosWrapper; - import net.minecraft.util.registry.Registry; - --public class MemoryModuleType { -+public class MemoryModuleType extends net.minecraftforge.registries.ForgeRegistryEntry> { - public static final MemoryModuleType field_220940_a = func_223541_a("dummy"); - public static final MemoryModuleType field_220941_b = func_234108_a_("home", GlobalPos.field_239645_a_); - public static final MemoryModuleType field_220942_c = func_234108_a_("job_site", GlobalPos.field_239645_a_); diff --git a/patches/minecraft/net/minecraft/entity/ai/brain/schedule/Activity.java.patch b/patches/minecraft/net/minecraft/entity/ai/brain/schedule/Activity.java.patch deleted file mode 100644 index de3e2c57cd..0000000000 --- a/patches/minecraft/net/minecraft/entity/ai/brain/schedule/Activity.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/entity/ai/brain/schedule/Activity.java -+++ b/net/minecraft/entity/ai/brain/schedule/Activity.java -@@ -2,7 +_,7 @@ - - import net.minecraft.util.registry.Registry; - --public class Activity { -+public class Activity extends net.minecraftforge.registries.ForgeRegistryEntry { - public static final Activity field_221365_a = func_221363_a("core"); - public static final Activity field_221366_b = func_221363_a("idle"); - public static final Activity field_221367_c = func_221363_a("work"); diff --git a/patches/minecraft/net/minecraft/entity/ai/brain/schedule/Schedule.java.patch b/patches/minecraft/net/minecraft/entity/ai/brain/schedule/Schedule.java.patch deleted file mode 100644 index 384dc76096..0000000000 --- a/patches/minecraft/net/minecraft/entity/ai/brain/schedule/Schedule.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/entity/ai/brain/schedule/Schedule.java -+++ b/net/minecraft/entity/ai/brain/schedule/Schedule.java -@@ -8,7 +_,7 @@ - import java.util.stream.Collectors; - import net.minecraft.util.registry.Registry; - --public class Schedule { -+public class Schedule extends net.minecraftforge.registries.ForgeRegistryEntry { - public static final Schedule field_221383_a = func_221380_a("empty").func_221402_a(0, Activity.field_221366_b).func_221404_a(); - public static final Schedule field_221384_b = func_221380_a("simple").func_221402_a(5000, Activity.field_221367_c).func_221402_a(11000, Activity.field_221369_e).func_221404_a(); - public static final Schedule field_221385_c = func_221380_a("villager_baby").func_221402_a(10, Activity.field_221366_b).func_221402_a(3000, Activity.field_221368_d).func_221402_a(6000, Activity.field_221366_b).func_221402_a(10000, Activity.field_221368_d).func_221402_a(12000, Activity.field_221369_e).func_221404_a(); diff --git a/patches/minecraft/net/minecraft/entity/ai/brain/sensor/SensorType.java.patch b/patches/minecraft/net/minecraft/entity/ai/brain/sensor/SensorType.java.patch deleted file mode 100644 index 8280c61ac4..0000000000 --- a/patches/minecraft/net/minecraft/entity/ai/brain/sensor/SensorType.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/entity/ai/brain/sensor/SensorType.java -+++ b/net/minecraft/entity/ai/brain/sensor/SensorType.java -@@ -4,7 +_,7 @@ - import net.minecraft.util.ResourceLocation; - import net.minecraft.util.registry.Registry; - --public class SensorType> { -+public class SensorType> extends net.minecraftforge.registries.ForgeRegistryEntry> { - public static final SensorType field_220997_a = func_220996_a("dummy", DummySensor::new); - public static final SensorType field_234129_b_ = func_220996_a("nearest_items", WantedItemsSensor::new); - public static final SensorType field_220998_b = func_220996_a("nearest_living_entities", NearestLivingEntitiesSensor::new); diff --git a/patches/minecraft/net/minecraft/entity/ai/brain/task/FarmTask.java.patch b/patches/minecraft/net/minecraft/entity/ai/brain/task/FarmTask.java.patch deleted file mode 100644 index 68130768a3..0000000000 --- a/patches/minecraft/net/minecraft/entity/ai/brain/task/FarmTask.java.patch +++ /dev/null @@ -1,23 +0,0 @@ ---- a/net/minecraft/entity/ai/brain/task/FarmTask.java -+++ b/net/minecraft/entity/ai/brain/task/FarmTask.java -@@ -37,7 +_,7 @@ - } - - protected boolean func_212832_a_(ServerWorld p_212832_1_, VillagerEntity p_212832_2_) { -- if (!p_212832_1_.func_82736_K().func_223586_b(GameRules.field_223599_b)) { -+ if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(p_212832_1_, p_212832_2_)) { - return false; - } else if (p_212832_2_.func_213700_eh().func_221130_b() != VillagerProfession.field_221156_f) { - return false; -@@ -117,6 +_,11 @@ - } else if (itemstack.func_77973_b() == Items.field_185163_cU) { - p_212833_1_.func_180501_a(this.field_220422_a, Blocks.field_185773_cZ.func_176223_P(), 3); - flag = true; -+ } else if (itemstack.func_77973_b() instanceof net.minecraftforge.common.IPlantable) { -+ if (((net.minecraftforge.common.IPlantable)itemstack.func_77973_b()).getPlantType(p_212833_1_, field_220422_a) == net.minecraftforge.common.PlantType.CROP) { -+ p_212833_1_.func_180501_a(field_220422_a, ((net.minecraftforge.common.IPlantable)itemstack.func_77973_b()).getPlant(p_212833_1_, field_220422_a), 3); -+ flag = true; -+ } - } - } - diff --git a/patches/minecraft/net/minecraft/entity/ai/brain/task/ShootTargetTask.java.patch b/patches/minecraft/net/minecraft/entity/ai/brain/task/ShootTargetTask.java.patch deleted file mode 100644 index a46ebf6d71..0000000000 --- a/patches/minecraft/net/minecraft/entity/ai/brain/task/ShootTargetTask.java.patch +++ /dev/null @@ -1,38 +0,0 @@ ---- a/net/minecraft/entity/ai/brain/task/ShootTargetTask.java -+++ b/net/minecraft/entity/ai/brain/task/ShootTargetTask.java -@@ -24,7 +_,7 @@ - - protected boolean func_212832_a_(ServerWorld p_212832_1_, E p_212832_2_) { - LivingEntity livingentity = func_233887_a_(p_212832_2_); -- return p_212832_2_.func_233631_a_(Items.field_222114_py) && BrainUtil.func_233876_c_(p_212832_2_, livingentity) && BrainUtil.func_233869_a_(p_212832_2_, livingentity, 0); -+ return p_212832_2_.func_233634_a_(item -> item instanceof CrossbowItem) && BrainUtil.func_233876_c_(p_212832_2_, livingentity) && BrainUtil.func_233869_a_(p_212832_2_, livingentity, 0); - } - - protected boolean func_212834_g_(ServerWorld p_212834_1_, E p_212834_2_, long p_212834_3_) { -@@ -42,7 +_,7 @@ - p_212835_2_.func_184602_cy(); - } - -- if (p_212835_2_.func_233631_a_(Items.field_222114_py)) { -+ if (p_212835_2_.func_233634_a_(item -> item instanceof CrossbowItem)) { - p_212835_2_.func_213671_a(false); - CrossbowItem.func_220011_a(p_212835_2_.func_184607_cu(), false); - } -@@ -51,7 +_,7 @@ - - private void func_233888_a_(E p_233888_1_, LivingEntity p_233888_2_) { - if (this.field_233886_c_ == ShootTargetTask.Status.UNCHARGED) { -- p_233888_1_.func_184598_c(ProjectileHelper.func_221274_a(p_233888_1_, Items.field_222114_py)); -+ p_233888_1_.func_184598_c(ProjectileHelper.getWeaponHoldingHand(p_233888_1_, item -> item instanceof CrossbowItem)); - this.field_233886_c_ = ShootTargetTask.Status.CHARGING; - p_233888_1_.func_213671_a(true); - } else if (this.field_233886_c_ == ShootTargetTask.Status.CHARGING) { -@@ -74,7 +_,7 @@ - } - } else if (this.field_233886_c_ == ShootTargetTask.Status.READY_TO_ATTACK) { - p_233888_1_.func_82196_d(p_233888_2_, 1.0F); -- ItemStack itemstack1 = p_233888_1_.func_184586_b(ProjectileHelper.func_221274_a(p_233888_1_, Items.field_222114_py)); -+ ItemStack itemstack1 = p_233888_1_.func_184586_b(ProjectileHelper.getWeaponHoldingHand(p_233888_1_, item -> item instanceof CrossbowItem)); - CrossbowItem.func_220011_a(itemstack1, false); - this.field_233886_c_ = ShootTargetTask.Status.UNCHARGED; - } diff --git a/patches/minecraft/net/minecraft/entity/ai/goal/BreakBlockGoal.java.patch b/patches/minecraft/net/minecraft/entity/ai/goal/BreakBlockGoal.java.patch deleted file mode 100644 index 54789a6b2a..0000000000 --- a/patches/minecraft/net/minecraft/entity/ai/goal/BreakBlockGoal.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/entity/ai/goal/BreakBlockGoal.java -+++ b/net/minecraft/entity/ai/goal/BreakBlockGoal.java -@@ -32,7 +_,7 @@ - } - - public boolean func_75250_a() { -- if (!this.field_203118_g.field_70170_p.func_82736_K().func_223586_b(GameRules.field_223599_b)) { -+ if (!net.minecraftforge.common.ForgeHooks.canEntityDestroy(this.field_203118_g.field_70170_p, this.field_179494_b, this.field_203118_g)) { - return false; - } else if (this.field_179496_a > 0) { - --this.field_179496_a; diff --git a/patches/minecraft/net/minecraft/entity/ai/goal/BreakDoorGoal.java.patch b/patches/minecraft/net/minecraft/entity/ai/goal/BreakDoorGoal.java.patch deleted file mode 100644 index 5fd9a00631..0000000000 --- a/patches/minecraft/net/minecraft/entity/ai/goal/BreakDoorGoal.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/entity/ai/goal/BreakDoorGoal.java -+++ b/net/minecraft/entity/ai/goal/BreakDoorGoal.java -@@ -29,7 +_,7 @@ - public boolean func_75250_a() { - if (!super.func_75250_a()) { - return false; -- } else if (!this.field_75356_a.field_70170_p.func_82736_K().func_223586_b(GameRules.field_223599_b)) { -+ } else if (!net.minecraftforge.common.ForgeHooks.canEntityDestroy(this.field_75356_a.field_70170_p, this.field_179507_b, this.field_75356_a)) { - return false; - } else { - return this.func_220696_a(this.field_75356_a.field_70170_p.func_175659_aa()) && !this.func_195922_f(); diff --git a/patches/minecraft/net/minecraft/entity/ai/goal/EatGrassGoal.java.patch b/patches/minecraft/net/minecraft/entity/ai/goal/EatGrassGoal.java.patch deleted file mode 100644 index e29be99b32..0000000000 --- a/patches/minecraft/net/minecraft/entity/ai/goal/EatGrassGoal.java.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/entity/ai/goal/EatGrassGoal.java -+++ b/net/minecraft/entity/ai/goal/EatGrassGoal.java -@@ -59,7 +_,7 @@ - if (this.field_151502_a == 4) { - BlockPos blockpos = this.field_151500_b.func_233580_cy_(); - if (field_179505_b.test(this.field_151501_c.func_180495_p(blockpos))) { -- if (this.field_151501_c.func_82736_K().func_223586_b(GameRules.field_223599_b)) { -+ if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.field_151501_c, this.field_151500_b)) { - this.field_151501_c.func_175655_b(blockpos, false); - } - -@@ -67,7 +_,7 @@ - } else { - BlockPos blockpos1 = blockpos.func_177977_b(); - if (this.field_151501_c.func_180495_p(blockpos1).func_203425_a(Blocks.field_196658_i)) { -- if (this.field_151501_c.func_82736_K().func_223586_b(GameRules.field_223599_b)) { -+ if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.field_151501_c, this.field_151500_b)) { - this.field_151501_c.func_217379_c(2001, blockpos1, Block.func_196246_j(Blocks.field_196658_i.func_176223_P())); - this.field_151501_c.func_180501_a(blockpos1, Blocks.field_150346_d.func_176223_P(), 2); - } diff --git a/patches/minecraft/net/minecraft/entity/ai/goal/MeleeAttackGoal.java.patch b/patches/minecraft/net/minecraft/entity/ai/goal/MeleeAttackGoal.java.patch deleted file mode 100644 index 3b3982b173..0000000000 --- a/patches/minecraft/net/minecraft/entity/ai/goal/MeleeAttackGoal.java.patch +++ /dev/null @@ -1,46 +0,0 @@ ---- a/net/minecraft/entity/ai/goal/MeleeAttackGoal.java -+++ b/net/minecraft/entity/ai/goal/MeleeAttackGoal.java -@@ -20,6 +_,8 @@ - private int field_234037_i_; - private final int field_188493_g = 20; - private long field_220720_k; -+ private int failedPathFindingPenalty = 0; -+ private boolean canPenalize = false; - - public MeleeAttackGoal(CreatureEntity p_i1636_1_, double p_i1636_2_, boolean p_i1636_4_) { - this.field_75441_b = p_i1636_1_; -@@ -40,6 +_,15 @@ - } else if (!livingentity.func_70089_S()) { - return false; - } else { -+ if (canPenalize) { -+ if (--this.field_75445_i <= 0) { -+ this.field_75438_g = this.field_75441_b.func_70661_as().func_75494_a(livingentity, 0); -+ this.field_75445_i = 4 + this.field_75441_b.func_70681_au().nextInt(7); -+ return this.field_75438_g != null; -+ } else { -+ return true; -+ } -+ } - this.field_75438_g = this.field_75441_b.func_70661_as().func_75494_a(livingentity, 0); - if (this.field_75438_g != null) { - return true; -@@ -92,6 +_,18 @@ - this.field_151495_j = livingentity.func_226278_cu_(); - this.field_151496_k = livingentity.func_226281_cx_(); - this.field_75445_i = 4 + this.field_75441_b.func_70681_au().nextInt(7); -+ if (this.canPenalize) { -+ this.field_75445_i += failedPathFindingPenalty; -+ if (this.field_75441_b.func_70661_as().func_75505_d() != null) { -+ net.minecraft.pathfinding.PathPoint finalPathPoint = this.field_75441_b.func_70661_as().func_75505_d().func_75870_c(); -+ if (finalPathPoint != null && livingentity.func_70092_e(finalPathPoint.field_75839_a, finalPathPoint.field_75837_b, finalPathPoint.field_75838_c) < 1) -+ failedPathFindingPenalty = 0; -+ else -+ failedPathFindingPenalty += 10; -+ } else { -+ failedPathFindingPenalty += 10; -+ } -+ } - if (d0 > 1024.0D) { - this.field_75445_i += 10; - } else if (d0 > 256.0D) { diff --git a/patches/minecraft/net/minecraft/entity/ai/goal/RangedBowAttackGoal.java.patch b/patches/minecraft/net/minecraft/entity/ai/goal/RangedBowAttackGoal.java.patch deleted file mode 100644 index 0b60b1a185..0000000000 --- a/patches/minecraft/net/minecraft/entity/ai/goal/RangedBowAttackGoal.java.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/entity/ai/goal/RangedBowAttackGoal.java -+++ b/net/minecraft/entity/ai/goal/RangedBowAttackGoal.java -@@ -36,7 +_,7 @@ - } - - protected boolean func_188498_f() { -- return this.field_188499_a.func_233631_a_(Items.field_151031_f); -+ return this.field_188499_a.func_233634_a_(item -> item instanceof BowItem); - } - - public boolean func_75253_b() { -@@ -117,7 +_,7 @@ - } - } - } else if (--this.field_188503_e <= 0 && this.field_188504_f >= -60) { -- this.field_188499_a.func_184598_c(ProjectileHelper.func_221274_a(this.field_188499_a, Items.field_151031_f)); -+ this.field_188499_a.func_184598_c(ProjectileHelper.getWeaponHoldingHand(this.field_188499_a, item -> item instanceof BowItem)); - } - - } diff --git a/patches/minecraft/net/minecraft/entity/ai/goal/RangedCrossbowAttackGoal.java.patch b/patches/minecraft/net/minecraft/entity/ai/goal/RangedCrossbowAttackGoal.java.patch deleted file mode 100644 index e4ab4aa729..0000000000 --- a/patches/minecraft/net/minecraft/entity/ai/goal/RangedCrossbowAttackGoal.java.patch +++ /dev/null @@ -1,29 +0,0 @@ ---- a/net/minecraft/entity/ai/goal/RangedCrossbowAttackGoal.java -+++ b/net/minecraft/entity/ai/goal/RangedCrossbowAttackGoal.java -@@ -33,7 +_,7 @@ - } - - private boolean func_220745_g() { -- return this.field_220748_a.func_233631_a_(Items.field_222114_py); -+ return this.field_220748_a.func_233634_a_(item -> item instanceof CrossbowItem); - } - - public boolean func_75253_b() { -@@ -88,7 +_,7 @@ - this.field_220748_a.func_70671_ap().func_75651_a(livingentity, 30.0F, 30.0F); - if (this.field_220749_b == RangedCrossbowAttackGoal.CrossbowState.UNCHARGED) { - if (!flag2) { -- this.field_220748_a.func_184598_c(ProjectileHelper.func_221274_a(this.field_220748_a, Items.field_222114_py)); -+ this.field_220748_a.func_184598_c(ProjectileHelper.getWeaponHoldingHand(this.field_220748_a, item -> item instanceof CrossbowItem)); - this.field_220749_b = RangedCrossbowAttackGoal.CrossbowState.CHARGING; - this.field_220748_a.func_213671_a(true); - } -@@ -112,7 +_,7 @@ - } - } else if (this.field_220749_b == RangedCrossbowAttackGoal.CrossbowState.READY_TO_ATTACK && flag) { - this.field_220748_a.func_82196_d(livingentity, 1.0F); -- ItemStack itemstack1 = this.field_220748_a.func_184586_b(ProjectileHelper.func_221274_a(this.field_220748_a, Items.field_222114_py)); -+ ItemStack itemstack1 = this.field_220748_a.func_184586_b(ProjectileHelper.getWeaponHoldingHand(this.field_220748_a, item -> item instanceof CrossbowItem)); - CrossbowItem.func_220011_a(itemstack1, false); - this.field_220749_b = RangedCrossbowAttackGoal.CrossbowState.UNCHARGED; - } diff --git a/patches/minecraft/net/minecraft/entity/ai/goal/RunAroundLikeCrazyGoal.java.patch b/patches/minecraft/net/minecraft/entity/ai/goal/RunAroundLikeCrazyGoal.java.patch deleted file mode 100644 index 228c1c6f12..0000000000 --- a/patches/minecraft/net/minecraft/entity/ai/goal/RunAroundLikeCrazyGoal.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/entity/ai/goal/RunAroundLikeCrazyGoal.java -+++ b/net/minecraft/entity/ai/goal/RunAroundLikeCrazyGoal.java -@@ -54,7 +_,7 @@ - if (entity instanceof PlayerEntity) { - int i = this.field_111180_a.func_110252_cg(); - int j = this.field_111180_a.func_190676_dC(); -- if (j > 0 && this.field_111180_a.func_70681_au().nextInt(j) < i) { -+ if (j > 0 && this.field_111180_a.func_70681_au().nextInt(j) < i && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(field_111180_a, (PlayerEntity)entity)) { - this.field_111180_a.func_110263_g((PlayerEntity)entity); - return; - } diff --git a/patches/minecraft/net/minecraft/entity/ai/goal/TriggerSkeletonTrapGoal.java.patch b/patches/minecraft/net/minecraft/entity/ai/goal/TriggerSkeletonTrapGoal.java.patch deleted file mode 100644 index de3d151304..0000000000 --- a/patches/minecraft/net/minecraft/entity/ai/goal/TriggerSkeletonTrapGoal.java.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- a/net/minecraft/entity/ai/goal/TriggerSkeletonTrapGoal.java -+++ b/net/minecraft/entity/ai/goal/TriggerSkeletonTrapGoal.java -@@ -28,6 +_,10 @@ - - public void func_75246_d() { - ServerWorld serverworld = (ServerWorld)this.field_188516_a.field_70170_p; -+ // Forge: Trigger the trap in a tick task to avoid crashes when mods add goals to skeleton horses -+ // (MC-206338/Forge PR #7509) -+ serverworld.func_73046_m().func_212871_a_(new net.minecraft.util.concurrent.TickDelayedTask(serverworld.func_73046_m().func_71259_af(), () -> { -+ if (!this.field_188516_a.func_70089_S()) return; - DifficultyInstance difficultyinstance = serverworld.func_175649_E(this.field_188516_a.func_233580_cy_()); - this.field_188516_a.func_190691_p(false); - this.field_188516_a.func_110234_j(true); -@@ -47,7 +_,7 @@ - abstracthorseentity.func_70024_g(this.field_188516_a.func_70681_au().nextGaussian() * 0.5D, 0.0D, this.field_188516_a.func_70681_au().nextGaussian() * 0.5D); - serverworld.func_242417_l(abstracthorseentity); - } -- -+ })); - } - - private AbstractHorseEntity func_188515_a(DifficultyInstance p_188515_1_) { diff --git a/patches/minecraft/net/minecraft/entity/boss/WitherEntity.java.patch b/patches/minecraft/net/minecraft/entity/boss/WitherEntity.java.patch deleted file mode 100644 index 10f2ff820c..0000000000 --- a/patches/minecraft/net/minecraft/entity/boss/WitherEntity.java.patch +++ /dev/null @@ -1,37 +0,0 @@ ---- a/net/minecraft/entity/boss/WitherEntity.java -+++ b/net/minecraft/entity/boss/WitherEntity.java -@@ -213,7 +_,7 @@ - if (this.func_82212_n() > 0) { - int j1 = this.func_82212_n() - 1; - if (j1 <= 0) { -- Explosion.Mode explosion$mode = this.field_70170_p.func_82736_K().func_223586_b(GameRules.field_223599_b) ? Explosion.Mode.DESTROY : Explosion.Mode.NONE; -+ Explosion.Mode explosion$mode = net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.field_70170_p, this) ? Explosion.Mode.DESTROY : Explosion.Mode.NONE; - this.field_70170_p.func_217398_a(this, this.func_226277_ct_(), this.func_226280_cw_(), this.func_226281_cx_(), 7.0F, false, explosion$mode); - if (!this.func_174814_R()) { - this.field_70170_p.func_175669_a(1023, this.func_233580_cy_(), 0); -@@ -290,7 +_,7 @@ - - if (this.field_82222_j > 0) { - --this.field_82222_j; -- if (this.field_82222_j == 0 && this.field_70170_p.func_82736_K().func_223586_b(GameRules.field_223599_b)) { -+ if (this.field_82222_j == 0 && net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.field_70170_p, this)) { - int i1 = MathHelper.func_76128_c(this.func_226278_cu_()); - int l1 = MathHelper.func_76128_c(this.func_226277_ct_()); - int i2 = MathHelper.func_76128_c(this.func_226281_cx_()); -@@ -304,7 +_,7 @@ - int l = i2 + l2; - BlockPos blockpos = new BlockPos(i3, k, l); - BlockState blockstate = this.field_70170_p.func_180495_p(blockpos); -- if (func_181033_a(blockstate)) { -+ if (blockstate.canEntityDestroy(this.field_70170_p, blockpos, this) && net.minecraftforge.event.ForgeEventFactory.onEntityDestroyBlock(this, blockpos, blockstate)) { - flag = this.field_70170_p.func_225521_a_(blockpos, true, this) || flag; - } - } -@@ -325,6 +_,7 @@ - } - } - -+ @Deprecated //Forge: DO NOT USE use BlockState.canEntityDestroy - public static boolean func_181033_a(BlockState p_181033_0_) { - return !p_181033_0_.func_196958_f() && !BlockTags.field_219755_X.func_230235_a_(p_181033_0_.func_177230_c()); - } diff --git a/patches/minecraft/net/minecraft/entity/boss/dragon/EnderDragonEntity.java.patch b/patches/minecraft/net/minecraft/entity/boss/dragon/EnderDragonEntity.java.patch deleted file mode 100644 index 55172aa742..0000000000 --- a/patches/minecraft/net/minecraft/entity/boss/dragon/EnderDragonEntity.java.patch +++ /dev/null @@ -1,29 +0,0 @@ ---- a/net/minecraft/entity/boss/dragon/EnderDragonEntity.java -+++ b/net/minecraft/entity/boss/dragon/EnderDragonEntity.java -@@ -408,8 +_,8 @@ - BlockPos blockpos = new BlockPos(k1, l1, i2); - BlockState blockstate = this.field_70170_p.func_180495_p(blockpos); - Block block = blockstate.func_177230_c(); -- if (!blockstate.func_196958_f() && blockstate.func_185904_a() != Material.field_151581_o) { -- if (this.field_70170_p.func_82736_K().func_223586_b(GameRules.field_223599_b) && !BlockTags.field_219754_W.func_230235_a_(block)) { -+ if (!blockstate.isAir(this.field_70170_p, blockpos) && blockstate.func_185904_a() != Material.field_151581_o) { -+ if (net.minecraftforge.common.ForgeHooks.canEntityDestroy(this.field_70170_p, blockpos, this) && !BlockTags.field_219754_W.func_230235_a_(block)) { - flag1 = this.field_70170_p.func_217377_a(blockpos, false) || flag1; - } else { - flag = true; -@@ -841,5 +_,15 @@ - - public boolean func_184222_aU() { - return false; -+ } -+ -+ @Override -+ public boolean isMultipartEntity() { -+ return true; -+ } -+ -+ @Override -+ public net.minecraftforge.entity.PartEntity[] getParts() { -+ return this.field_70977_g; - } - } diff --git a/patches/minecraft/net/minecraft/entity/boss/dragon/EnderDragonPartEntity.java.patch b/patches/minecraft/net/minecraft/entity/boss/dragon/EnderDragonPartEntity.java.patch deleted file mode 100644 index 075ddd6c98..0000000000 --- a/patches/minecraft/net/minecraft/entity/boss/dragon/EnderDragonPartEntity.java.patch +++ /dev/null @@ -1,18 +0,0 @@ ---- a/net/minecraft/entity/boss/dragon/EnderDragonPartEntity.java -+++ b/net/minecraft/entity/boss/dragon/EnderDragonPartEntity.java -@@ -7,13 +_,13 @@ - import net.minecraft.network.IPacket; - import net.minecraft.util.DamageSource; - --public class EnderDragonPartEntity extends Entity { -+public class EnderDragonPartEntity extends net.minecraftforge.entity.PartEntity { - public final EnderDragonEntity field_213852_b; - public final String field_213853_c; - private final EntitySize field_213854_d; - - public EnderDragonPartEntity(EnderDragonEntity p_i50232_1_, String p_i50232_2_, float p_i50232_3_, float p_i50232_4_) { -- super(p_i50232_1_.func_200600_R(), p_i50232_1_.field_70170_p); -+ super(p_i50232_1_); - this.field_213854_d = EntitySize.func_220314_b(p_i50232_3_, p_i50232_4_); - this.func_213323_x_(); - this.field_213852_b = p_i50232_1_; diff --git a/patches/minecraft/net/minecraft/entity/effect/LightningBoltEntity.java.patch b/patches/minecraft/net/minecraft/entity/effect/LightningBoltEntity.java.patch deleted file mode 100644 index cc17ac45e0..0000000000 --- a/patches/minecraft/net/minecraft/entity/effect/LightningBoltEntity.java.patch +++ /dev/null @@ -1,33 +0,0 @@ ---- a/net/minecraft/entity/effect/LightningBoltEntity.java -+++ b/net/minecraft/entity/effect/LightningBoltEntity.java -@@ -30,6 +_,7 @@ - private boolean field_184529_d; - @Nullable - private ServerPlayerEntity field_204810_e; -+ private float damage = 5.0F; - - public LightningBoltEntity(EntityType p_i231491_1_, World p_i231491_2_) { - super(p_i231491_1_, p_i231491_2_); -@@ -51,6 +_,14 @@ - this.field_204810_e = p_204809_1_; - } - -+ public void setDamage(float damage){ -+ this.damage = damage; -+ } -+ -+ public float getDamage(){ -+ return this.damage; -+ } -+ - public void func_70071_h_() { - super.func_70071_h_(); - if (this.field_70262_b == 2) { -@@ -83,6 +_,7 @@ - List list = this.field_70170_p.func_175674_a(this, new AxisAlignedBB(this.func_226277_ct_() - 3.0D, this.func_226278_cu_() - 3.0D, this.func_226281_cx_() - 3.0D, this.func_226277_ct_() + 3.0D, this.func_226278_cu_() + 6.0D + 3.0D, this.func_226281_cx_() + 3.0D), Entity::func_70089_S); - - for(Entity entity : list) { -+ if (!net.minecraftforge.event.ForgeEventFactory.onEntityStruckByLightning(entity, this)) - entity.func_241841_a((ServerWorld)this.field_70170_p, this); - } - diff --git a/patches/minecraft/net/minecraft/entity/item/ArmorStandEntity.java.patch b/patches/minecraft/net/minecraft/entity/item/ArmorStandEntity.java.patch deleted file mode 100644 index caab0abc23..0000000000 --- a/patches/minecraft/net/minecraft/entity/item/ArmorStandEntity.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/entity/item/ArmorStandEntity.java -+++ b/net/minecraft/entity/item/ArmorStandEntity.java -@@ -60,7 +_,7 @@ - public static final DataParameter field_184806_f = EntityDataManager.func_187226_a(ArmorStandEntity.class, DataSerializers.field_187199_i); - public static final DataParameter field_184807_g = EntityDataManager.func_187226_a(ArmorStandEntity.class, DataSerializers.field_187199_i); - private static final Predicate field_184798_bv = (p_200617_0_) -> { -- return p_200617_0_ instanceof AbstractMinecartEntity && ((AbstractMinecartEntity)p_200617_0_).func_184264_v() == AbstractMinecartEntity.Type.RIDEABLE; -+ return p_200617_0_ instanceof AbstractMinecartEntity && ((AbstractMinecartEntity)p_200617_0_).canBeRidden(); - }; - private final NonNullList field_184799_bw = NonNullList.func_191197_a(2, ItemStack.field_190927_a); - private final NonNullList field_184800_bx = NonNullList.func_191197_a(4, ItemStack.field_190927_a); diff --git a/patches/minecraft/net/minecraft/entity/item/BoatEntity.java.patch b/patches/minecraft/net/minecraft/entity/item/BoatEntity.java.patch deleted file mode 100644 index 8c81273185..0000000000 --- a/patches/minecraft/net/minecraft/entity/item/BoatEntity.java.patch +++ /dev/null @@ -1,28 +0,0 @@ ---- a/net/minecraft/entity/item/BoatEntity.java -+++ b/net/minecraft/entity/item/BoatEntity.java -@@ -468,7 +_,7 @@ - blockpos$mutable.func_181079_c(l1, k2, i2); - BlockState blockstate = this.field_70170_p.func_180495_p(blockpos$mutable); - if (!(blockstate.func_177230_c() instanceof LilyPadBlock) && VoxelShapes.func_197879_c(blockstate.func_196952_d(this.field_70170_p, blockpos$mutable).func_197751_a((double)l1, (double)k2, (double)i2), voxelshape, IBooleanFunction.field_223238_i_)) { -- f += blockstate.func_177230_c().func_208618_m(); -+ f += blockstate.getSlipperiness(this.field_70170_p, blockpos$mutable, this); - ++k1; - } - } -@@ -815,6 +_,16 @@ - - public boolean func_204231_K() { - return this.field_184469_aF == BoatEntity.Status.UNDER_WATER || this.field_184469_aF == BoatEntity.Status.UNDER_FLOWING_WATER; -+ } -+ -+ // Forge: Fix MC-119811 by instantly completing lerp on board -+ @Override -+ protected void func_184200_o(Entity passenger) { -+ super.func_184200_o(passenger); -+ if (this.func_184186_bw() && this.field_184476_at > 0) { -+ this.field_184476_at = 0; -+ this.func_70080_a(this.field_70281_h, this.field_184477_av, this.field_184478_aw, (float)this.field_70273_g, (float)this.field_184479_ay); -+ } - } - - public static enum Status { diff --git a/patches/minecraft/net/minecraft/entity/item/EnderPearlEntity.java.patch b/patches/minecraft/net/minecraft/entity/item/EnderPearlEntity.java.patch deleted file mode 100644 index ec67b5bfec..0000000000 --- a/patches/minecraft/net/minecraft/entity/item/EnderPearlEntity.java.patch +++ /dev/null @@ -1,39 +0,0 @@ ---- a/net/minecraft/entity/item/EnderPearlEntity.java -+++ b/net/minecraft/entity/item/EnderPearlEntity.java -@@ -55,6 +_,8 @@ - if (entity instanceof ServerPlayerEntity) { - ServerPlayerEntity serverplayerentity = (ServerPlayerEntity)entity; - if (serverplayerentity.field_71135_a.func_147298_b().func_150724_d() && serverplayerentity.field_70170_p == this.field_70170_p && !serverplayerentity.func_70608_bn()) { -+ net.minecraftforge.event.entity.living.EntityTeleportEvent.EnderPearl event = net.minecraftforge.event.ForgeEventFactory.onEnderPearlLand(serverplayerentity, this.func_226277_ct_(), this.func_226278_cu_(), this.func_226281_cx_(), this, 5.0F); -+ if (!event.isCanceled()) { // Don't indent to lower patch size - if (this.field_70146_Z.nextFloat() < 0.05F && this.field_70170_p.func_82736_K().func_223586_b(GameRules.field_223601_d)) { - EndermiteEntity endermiteentity = EntityType.field_200804_r.func_200721_a(this.field_70170_p); - endermiteentity.func_175496_a(true); -@@ -66,9 +_,10 @@ - entity.func_184210_p(); - } - -- entity.func_70634_a(this.func_226277_ct_(), this.func_226278_cu_(), this.func_226281_cx_()); -+ entity.func_70634_a(event.getTargetX(), event.getTargetY(), event.getTargetZ()); - entity.field_70143_R = 0.0F; -- entity.func_70097_a(DamageSource.field_76379_h, 5.0F); -+ entity.func_70097_a(DamageSource.field_76379_h, event.getAttackDamage()); -+ } //Forge: End - } - } else if (entity != null) { - entity.func_70634_a(this.func_226277_ct_(), this.func_226278_cu_(), this.func_226281_cx_()); -@@ -91,12 +_,12 @@ - } - - @Nullable -- public Entity func_241206_a_(ServerWorld p_241206_1_) { -+ public Entity changeDimension(ServerWorld p_241206_1_, net.minecraftforge.common.util.ITeleporter teleporter) { - Entity entity = this.func_234616_v_(); - if (entity != null && entity.field_70170_p.func_234923_W_() != p_241206_1_.func_234923_W_()) { - this.func_212361_a((Entity)null); - } - -- return super.func_241206_a_(p_241206_1_); -+ return super.changeDimension(p_241206_1_, teleporter); - } - } diff --git a/patches/minecraft/net/minecraft/entity/item/ExperienceOrbEntity.java.patch b/patches/minecraft/net/minecraft/entity/item/ExperienceOrbEntity.java.patch deleted file mode 100644 index 0d078dbb4c..0000000000 --- a/patches/minecraft/net/minecraft/entity/item/ExperienceOrbEntity.java.patch +++ /dev/null @@ -1,36 +0,0 @@ ---- a/net/minecraft/entity/item/ExperienceOrbEntity.java -+++ b/net/minecraft/entity/item/ExperienceOrbEntity.java -@@ -98,7 +_,8 @@ - this.func_213315_a(MoverType.SELF, this.func_213322_ci()); - float f = 0.98F; - if (this.field_70122_E) { -- f = this.field_70170_p.func_180495_p(new BlockPos(this.func_226277_ct_(), this.func_226278_cu_() - 1.0D, this.func_226281_cx_())).func_177230_c().func_208618_m() * 0.98F; -+ BlockPos pos =new BlockPos(this.func_226277_ct_(), this.func_226278_cu_() - 1.0D, this.func_226281_cx_()); -+ f = this.field_70170_p.func_180495_p(pos).getSlipperiness(this.field_70170_p, pos, this) * 0.98F; - } - - this.func_213317_d(this.func_213322_ci().func_216372_d((double)f, 0.98D, (double)f)); -@@ -123,6 +_,7 @@ - } - - public boolean func_70097_a(DamageSource p_70097_1_, float p_70097_2_) { -+ if (this.field_70170_p.field_72995_K || this.field_70128_L) return false; //Forge: Fixes MC-53850 - if (this.func_180431_b(p_70097_1_)) { - return false; - } else { -@@ -151,13 +_,14 @@ - public void func_70100_b_(PlayerEntity p_70100_1_) { - if (!this.field_70170_p.field_72995_K) { - if (this.field_70532_c == 0 && p_70100_1_.field_71090_bL == 0) { -+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerXpEvent.PickupXp(p_70100_1_, this))) return; - p_70100_1_.field_71090_bL = 2; - p_70100_1_.func_71001_a(this, 1); - Entry entry = EnchantmentHelper.func_234844_a_(Enchantments.field_185296_A, p_70100_1_, ItemStack::func_77951_h); - if (entry != null) { - ItemStack itemstack = entry.getValue(); - if (!itemstack.func_190926_b() && itemstack.func_77951_h()) { -- int i = Math.min(this.func_184514_c(this.field_70530_e), itemstack.func_77952_i()); -+ int i = Math.min((int)(this.field_70530_e * itemstack.getXpRepairRatio()), itemstack.func_77952_i()); - this.field_70530_e -= this.func_184515_b(i); - itemstack.func_196085_b(itemstack.func_77952_i() - i); - } diff --git a/patches/minecraft/net/minecraft/entity/item/FallingBlockEntity.java.patch b/patches/minecraft/net/minecraft/entity/item/FallingBlockEntity.java.patch deleted file mode 100644 index 66f3e0d635..0000000000 --- a/patches/minecraft/net/minecraft/entity/item/FallingBlockEntity.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/entity/item/FallingBlockEntity.java -+++ b/net/minecraft/entity/item/FallingBlockEntity.java -@@ -153,7 +_,7 @@ - ((FallingBlock)block).func_176502_a_(this.field_70170_p, blockpos1, this.field_175132_d, blockstate, this); - } - -- if (this.field_145810_d != null && block instanceof ITileEntityProvider) { -+ if (this.field_145810_d != null && this.field_175132_d.hasTileEntity()) { - TileEntity tileentity = this.field_70170_p.func_175625_s(blockpos1); - if (tileentity != null) { - CompoundNBT compoundnbt = tileentity.func_189515_b(new CompoundNBT()); diff --git a/patches/minecraft/net/minecraft/entity/item/HangingEntity.java.patch b/patches/minecraft/net/minecraft/entity/item/HangingEntity.java.patch deleted file mode 100644 index 24ded1f632..0000000000 --- a/patches/minecraft/net/minecraft/entity/item/HangingEntity.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/entity/item/HangingEntity.java -+++ b/net/minecraft/entity/item/HangingEntity.java -@@ -120,6 +_,8 @@ - int j1 = (j - 1) / -2; - blockpos$mutable.func_189533_g(blockpos).func_189534_c(direction, k + i1).func_189534_c(Direction.UP, l + j1); - BlockState blockstate = this.field_70170_p.func_180495_p(blockpos$mutable); -+ if (net.minecraft.block.Block.func_220055_a(this.field_70170_p, blockpos$mutable, this.field_174860_b)) -+ continue; - if (!blockstate.func_185904_a().func_76220_a() && !RedstoneDiodeBlock.func_185546_B(blockstate)) { - return false; - } diff --git a/patches/minecraft/net/minecraft/entity/item/ItemEntity.java.patch b/patches/minecraft/net/minecraft/entity/item/ItemEntity.java.patch deleted file mode 100644 index f79af27bf2..0000000000 --- a/patches/minecraft/net/minecraft/entity/item/ItemEntity.java.patch +++ /dev/null @@ -1,127 +0,0 @@ ---- a/net/minecraft/entity/item/ItemEntity.java -+++ b/net/minecraft/entity/item/ItemEntity.java -@@ -38,6 +_,10 @@ - private UUID field_145801_f; - private UUID field_145802_g; - public final float field_70290_d; -+ /** -+ * The maximum age of this EntityItem. The item is expired once this is reached. -+ */ -+ public int lifespan = 6000; - - public ItemEntity(EntityType p_i50217_1_, World p_i50217_2_) { - super(p_i50217_1_, p_i50217_2_); -@@ -54,6 +_,7 @@ - public ItemEntity(World p_i1710_1_, double p_i1710_2_, double p_i1710_4_, double p_i1710_6_, ItemStack p_i1710_8_) { - this(p_i1710_1_, p_i1710_2_, p_i1710_4_, p_i1710_6_); - this.func_92058_a(p_i1710_8_); -+ this.lifespan = (p_i1710_8_.func_77973_b() == null ? 6000 : p_i1710_8_.getEntityLifespan(p_i1710_1_)); - } - - @OnlyIn(Dist.CLIENT) -@@ -74,6 +_,7 @@ - } - - public void func_70071_h_() { -+ if (func_92059_d().onEntityItemUpdate(this)) return; - if (this.func_92059_d().func_190926_b()) { - this.func_70106_y(); - } else { -@@ -108,7 +_,7 @@ - this.func_213315_a(MoverType.SELF, this.func_213322_ci()); - float f1 = 0.98F; - if (this.field_70122_E) { -- f1 = this.field_70170_p.func_180495_p(new BlockPos(this.func_226277_ct_(), this.func_226278_cu_() - 1.0D, this.func_226281_cx_())).func_177230_c().func_208618_m() * 0.98F; -+ f1 = this.field_70170_p.func_180495_p(new BlockPos(this.func_226277_ct_(), this.func_226278_cu_() - 1.0D, this.func_226281_cx_())).getSlipperiness(field_70170_p, new BlockPos(this.func_226277_ct_(), this.func_226278_cu_() - 1.0D, this.func_226281_cx_()), this) * 0.98F; - } - - this.func_213317_d(this.func_213322_ci().func_216372_d((double)f1, 0.98D, (double)f1)); -@@ -144,7 +_,14 @@ - } - } - -- if (!this.field_70170_p.field_72995_K && this.field_70292_b >= 6000) { -+ ItemStack item = this.func_92059_d(); -+ if (!this.field_70170_p.field_72995_K && this.field_70292_b >= lifespan) { -+ int hook = net.minecraftforge.event.ForgeEventFactory.onItemExpire(this, item); -+ if (hook < 0) this.func_70106_y(); -+ else this.lifespan += hook; -+ } -+ -+ if (item.func_190926_b()) { - this.func_70106_y(); - } - -@@ -202,6 +_,8 @@ - return false; - } else if (p_226532_1_.func_77942_o() ^ p_226532_0_.func_77942_o()) { - return false; -+ } else if (!p_226532_0_.areCapsCompatible(p_226532_1_)) { -+ return false; - } else { - return !p_226532_1_.func_77942_o() || p_226532_1_.func_77978_p().equals(p_226532_0_.func_77978_p()); - } -@@ -235,6 +_,7 @@ - } - - public boolean func_70097_a(DamageSource p_70097_1_, float p_70097_2_) { -+ if (this.field_70170_p.field_72995_K || this.field_70128_L) return false; //Forge: Fixes MC-53850 - if (this.func_180431_b(p_70097_1_)) { - return false; - } else if (!this.func_92059_d().func_190926_b() && this.func_92059_d().func_77973_b() == Items.field_151156_bN && p_70097_1_.func_94541_c()) { -@@ -256,6 +_,7 @@ - p_213281_1_.func_74777_a("Health", (short)this.field_70291_e); - p_213281_1_.func_74777_a("Age", (short)this.field_70292_b); - p_213281_1_.func_74777_a("PickupDelay", (short)this.field_145804_b); -+ p_213281_1_.func_74768_a("Lifespan", lifespan); - if (this.func_200214_m() != null) { - p_213281_1_.func_186854_a("Thrower", this.func_200214_m()); - } -@@ -276,6 +_,7 @@ - if (p_70037_1_.func_74764_b("PickupDelay")) { - this.field_145804_b = p_70037_1_.func_74765_d("PickupDelay"); - } -+ if (p_70037_1_.func_74764_b("Lifespan")) lifespan = p_70037_1_.func_74762_e("Lifespan"); - - if (p_70037_1_.func_186855_b("Owner")) { - this.field_145802_g = p_70037_1_.func_186857_a("Owner"); -@@ -295,10 +_,18 @@ - - public void func_70100_b_(PlayerEntity p_70100_1_) { - if (!this.field_70170_p.field_72995_K) { -+ if (this.field_145804_b > 0) return; - ItemStack itemstack = this.func_92059_d(); - Item item = itemstack.func_77973_b(); - int i = itemstack.func_190916_E(); -- if (this.field_145804_b == 0 && (this.field_145802_g == null || this.field_145802_g.equals(p_70100_1_.func_110124_au())) && p_70100_1_.field_71071_by.func_70441_a(itemstack)) { -+ -+ int hook = net.minecraftforge.event.ForgeEventFactory.onItemPickup(this, p_70100_1_); -+ if (hook < 0) return; -+ -+ ItemStack copy = itemstack.func_77946_l(); -+ if (this.field_145804_b == 0 && (this.field_145802_g == null || lifespan - this.field_70292_b <= 200 || this.field_145802_g.equals(p_70100_1_.func_110124_au())) && (hook == 1 || i <= 0 || p_70100_1_.field_71071_by.func_70441_a(itemstack))) { -+ copy.func_190920_e(copy.func_190916_E() - func_92059_d().func_190916_E()); -+ net.minecraftforge.fml.hooks.BasicEventHooks.firePlayerItemPickupEvent(p_70100_1_, this, copy); - p_70100_1_.func_71001_a(this, i); - if (itemstack.func_190926_b()) { - this.func_70106_y(); -@@ -322,8 +_,8 @@ - } - - @Nullable -- public Entity func_241206_a_(ServerWorld p_241206_1_) { -- Entity entity = super.func_241206_a_(p_241206_1_); -+ public Entity changeDimension(ServerWorld p_241206_1_, net.minecraftforge.common.util.ITeleporter teleporter) { -+ Entity entity = super.changeDimension(p_241206_1_, teleporter); - if (!this.field_70170_p.field_72995_K && entity instanceof ItemEntity) { - ((ItemEntity)entity).func_85054_d(); - } -@@ -396,7 +_,7 @@ - - public void func_174870_v() { - this.func_174871_r(); -- this.field_70292_b = 5999; -+ this.field_70292_b = func_92059_d().getEntityLifespan(field_70170_p) - 1; - } - - @OnlyIn(Dist.CLIENT) diff --git a/patches/minecraft/net/minecraft/entity/item/LeashKnotEntity.java.patch b/patches/minecraft/net/minecraft/entity/item/LeashKnotEntity.java.patch deleted file mode 100644 index 4408a50f04..0000000000 --- a/patches/minecraft/net/minecraft/entity/item/LeashKnotEntity.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/entity/item/LeashKnotEntity.java -+++ b/net/minecraft/entity/item/LeashKnotEntity.java -@@ -45,6 +_,7 @@ - - protected void func_174856_o() { - this.func_226288_n_((double)this.field_174861_a.func_177958_n() + 0.5D, (double)this.field_174861_a.func_177956_o() + 0.5D, (double)this.field_174861_a.func_177952_p() + 0.5D); -+ if (this.isAddedToWorld() && this.field_70170_p instanceof net.minecraft.world.server.ServerWorld) ((net.minecraft.world.server.ServerWorld)this.field_70170_p).func_217464_b(this); // Forge - Process chunk registration after moving. - } - - public void func_174859_a(Direction p_174859_1_) { diff --git a/patches/minecraft/net/minecraft/entity/item/PaintingType.java.patch b/patches/minecraft/net/minecraft/entity/item/PaintingType.java.patch deleted file mode 100644 index 82b1735919..0000000000 --- a/patches/minecraft/net/minecraft/entity/item/PaintingType.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/entity/item/PaintingType.java -+++ b/net/minecraft/entity/item/PaintingType.java -@@ -2,7 +_,7 @@ - - import net.minecraft.util.registry.Registry; - --public class PaintingType { -+public class PaintingType extends net.minecraftforge.registries.ForgeRegistryEntry { - public static final PaintingType field_200843_b = func_221119_a("kebab", 16, 16); - public static final PaintingType field_200844_c = func_221119_a("aztec", 16, 16); - public static final PaintingType field_200845_d = func_221119_a("alban", 16, 16); diff --git a/patches/minecraft/net/minecraft/entity/item/minecart/AbstractMinecartEntity.java.patch b/patches/minecraft/net/minecraft/entity/item/minecart/AbstractMinecartEntity.java.patch deleted file mode 100644 index 641082f16d..0000000000 --- a/patches/minecraft/net/minecraft/entity/item/minecart/AbstractMinecartEntity.java.patch +++ /dev/null @@ -1,266 +0,0 @@ ---- a/net/minecraft/entity/item/minecart/AbstractMinecartEntity.java -+++ b/net/minecraft/entity/item/minecart/AbstractMinecartEntity.java -@@ -48,7 +_,7 @@ - import net.minecraftforge.api.distmarker.Dist; - import net.minecraftforge.api.distmarker.OnlyIn; - --public abstract class AbstractMinecartEntity extends Entity { -+public abstract class AbstractMinecartEntity extends Entity implements net.minecraftforge.common.extensions.IForgeEntityMinecart { - private static final DataParameter field_184265_a = EntityDataManager.func_187226_a(AbstractMinecartEntity.class, DataSerializers.field_187192_b); - private static final DataParameter field_184266_b = EntityDataManager.func_187226_a(AbstractMinecartEntity.class, DataSerializers.field_187192_b); - private static final DataParameter field_184267_c = EntityDataManager.func_187226_a(AbstractMinecartEntity.class, DataSerializers.field_187193_c); -@@ -77,6 +_,7 @@ - p_226574_0_.put(RailShape.NORTH_WEST, Pair.of(vector3i2, vector3i)); - p_226574_0_.put(RailShape.NORTH_EAST, Pair.of(vector3i2, vector3i1)); - }); -+ private static net.minecraftforge.common.IMinecartCollisionHandler COLLISIONS = null; - private int field_70510_h; - private double field_70511_i; - private double field_70509_j; -@@ -89,6 +_,7 @@ - private double field_70507_ar; - @OnlyIn(Dist.CLIENT) - private double field_70506_as; -+ private boolean canBePushed = true; - - protected AbstractMinecartEntity(EntityType p_i48538_1_, World p_i48538_2_) { - super(p_i48538_1_, p_i48538_2_); -@@ -103,6 +_,14 @@ - this.field_70167_r = p_i48539_5_; - this.field_70166_s = p_i48539_7_; - } -+ -+ public net.minecraftforge.common.IMinecartCollisionHandler getCollisionHandler() { -+ return COLLISIONS; -+ } -+ -+ public static void registerCollisionHandler(@Nullable net.minecraftforge.common.IMinecartCollisionHandler handler) { -+ COLLISIONS = handler; -+ } - - public static AbstractMinecartEntity func_184263_a(World p_184263_0_, double p_184263_1_, double p_184263_3_, double p_184263_5_, AbstractMinecartEntity.Type p_184263_7_) { - if (p_184263_7_ == AbstractMinecartEntity.Type.CHEST) { -@@ -138,7 +_,7 @@ - } - - public boolean func_70104_M() { -- return true; -+ return canBePushed; - } - - protected Vector3d func_241839_a(Direction.Axis p_241839_1_, TeleportationRepositioner.Result p_241839_2_) { -@@ -307,9 +_,9 @@ - - BlockPos blockpos = new BlockPos(i, j, k); - BlockState blockstate = this.field_70170_p.func_180495_p(blockpos); -- if (AbstractRailBlock.func_208487_j(blockstate)) { -+ if (canUseRail() && AbstractRailBlock.func_208487_j(blockstate)) { - this.func_180460_a(blockpos, blockstate); -- if (blockstate.func_203425_a(Blocks.field_150408_cc)) { -+ if (blockstate.func_177230_c() instanceof PoweredRailBlock && ((PoweredRailBlock) blockstate.func_177230_c()).isActivatorRail()) { - this.func_96095_a(i, j, k, blockstate.func_177229_b(PoweredRailBlock.field_176569_M)); - } - } else { -@@ -334,8 +_,11 @@ - } - - this.func_70101_b(this.field_70177_z, this.field_70125_A); -- if (this.func_184264_v() == AbstractMinecartEntity.Type.RIDEABLE && func_213296_b(this.func_213322_ci()) > 0.01D) { -- List list = this.field_70170_p.func_175674_a(this, this.func_174813_aQ().func_72314_b((double)0.2F, 0.0D, (double)0.2F), EntityPredicates.func_200823_a(this)); -+ AxisAlignedBB box; -+ if (getCollisionHandler() != null) box = getCollisionHandler().getMinecartCollisionBox(this); -+ else box = this.func_174813_aQ().func_72314_b(0.2F, 0.0D, 0.2F); -+ if (canBeRidden() && func_213296_b(this.func_213322_ci()) > 0.01D) { -+ List list = this.field_70170_p.func_175674_a(this, box, EntityPredicates.func_200823_a(this)); - if (!list.isEmpty()) { - for(int l = 0; l < list.size(); ++l) { - Entity entity1 = list.get(l); -@@ -347,7 +_,7 @@ - } - } - } else { -- for(Entity entity : this.field_70170_p.func_72839_b(this, this.func_174813_aQ().func_72314_b((double)0.2F, 0.0D, (double)0.2F))) { -+ for(Entity entity : this.field_70170_p.func_72839_b(this, box)) { - if (!this.func_184196_w(entity) && entity.func_70104_M() && entity instanceof AbstractMinecartEntity) { - entity.func_70108_f(this); - } -@@ -372,16 +_,23 @@ - } - - protected void func_180459_n() { -- double d0 = this.func_174898_m(); -+ double d0 = field_70122_E ? this.func_174898_m() : getMaxSpeedAirLateral(); - Vector3d vector3d = this.func_213322_ci(); - this.func_213293_j(MathHelper.func_151237_a(vector3d.field_72450_a, -d0, d0), vector3d.field_72448_b, MathHelper.func_151237_a(vector3d.field_72449_c, -d0, d0)); - if (this.field_70122_E) { - this.func_213317_d(this.func_213322_ci().func_186678_a(0.5D)); - } - -+ if (getMaxSpeedAirVertical() > 0 && func_213322_ci().field_72448_b > getMaxSpeedAirVertical()) { -+ if(Math.abs(func_213322_ci().field_72450_a) < 0.3f && Math.abs(func_213322_ci().field_72449_c) < 0.3f) -+ func_213317_d(new Vector3d(func_213322_ci().field_72450_a, 0.15f, func_213322_ci().field_72449_c)); -+ else -+ func_213317_d(new Vector3d(func_213322_ci().field_72450_a, getMaxSpeedAirVertical(), func_213322_ci().field_72449_c)); -+ } -+ - this.func_213315_a(MoverType.SELF, this.func_213322_ci()); - if (!this.field_70122_E) { -- this.func_213317_d(this.func_213322_ci().func_186678_a(0.95D)); -+ this.func_213317_d(this.func_213322_ci().func_186678_a(getDragAir())); - } - - } -@@ -396,29 +_,29 @@ - boolean flag = false; - boolean flag1 = false; - AbstractRailBlock abstractrailblock = (AbstractRailBlock)p_180460_2_.func_177230_c(); -- if (abstractrailblock == Blocks.field_196552_aC) { -+ if (abstractrailblock instanceof PoweredRailBlock && !((PoweredRailBlock) abstractrailblock).isActivatorRail()) { - flag = p_180460_2_.func_177229_b(PoweredRailBlock.field_176569_M); - flag1 = !flag; - } - - double d3 = 0.0078125D; - Vector3d vector3d1 = this.func_213322_ci(); -- RailShape railshape = p_180460_2_.func_177229_b(abstractrailblock.func_176560_l()); -+ RailShape railshape = ((AbstractRailBlock)p_180460_2_.func_177230_c()).getRailDirection(p_180460_2_, this.field_70170_p, p_180460_1_, this); - switch(railshape) { - case ASCENDING_EAST: -- this.func_213317_d(vector3d1.func_72441_c(-0.0078125D, 0.0D, 0.0D)); -+ this.func_213317_d(vector3d1.func_72441_c(-1 * getSlopeAdjustment(), 0.0D, 0.0D)); - ++d1; - break; - case ASCENDING_WEST: -- this.func_213317_d(vector3d1.func_72441_c(0.0078125D, 0.0D, 0.0D)); -+ this.func_213317_d(vector3d1.func_72441_c(getSlopeAdjustment(), 0.0D, 0.0D)); - ++d1; - break; - case ASCENDING_NORTH: -- this.func_213317_d(vector3d1.func_72441_c(0.0D, 0.0D, 0.0078125D)); -+ this.func_213317_d(vector3d1.func_72441_c(0.0D, 0.0D, getSlopeAdjustment())); - ++d1; - break; - case ASCENDING_SOUTH: -- this.func_213317_d(vector3d1.func_72441_c(0.0D, 0.0D, -0.0078125D)); -+ this.func_213317_d(vector3d1.func_72441_c(0.0D, 0.0D, -1 * getSlopeAdjustment())); - ++d1; - } - -@@ -449,7 +_,7 @@ - } - } - -- if (flag1) { -+ if (flag1 && shouldDoRailFunctions()) { - double d22 = Math.sqrt(func_213296_b(this.func_213322_ci())); - if (d22 < 0.03D) { - this.func_213317_d(Vector3d.field_186680_a); -@@ -478,10 +_,7 @@ - d0 = d23 + d4 * d14; - d2 = d10 + d5 * d14; - this.func_70107_b(d0, d1, d2); -- double d24 = this.func_184207_aI() ? 0.75D : 1.0D; -- double d25 = this.func_174898_m(); -- vector3d1 = this.func_213322_ci(); -- this.func_213315_a(MoverType.SELF, new Vector3d(MathHelper.func_151237_a(d24 * vector3d1.field_72450_a, -d25, d25), 0.0D, MathHelper.func_151237_a(d24 * vector3d1.field_72449_c, -d25, d25))); -+ this.moveMinecartOnRail(p_180460_1_); - if (vector3i.func_177956_o() != 0 && MathHelper.func_76128_c(this.func_226277_ct_()) - p_180460_1_.func_177958_n() == vector3i.func_177958_n() && MathHelper.func_76128_c(this.func_226281_cx_()) - p_180460_1_.func_177952_p() == vector3i.func_177952_p()) { - this.func_70107_b(this.func_226277_ct_(), this.func_226278_cu_() + (double)vector3i.func_177956_o(), this.func_226281_cx_()); - } else if (vector3i1.func_177956_o() != 0 && MathHelper.func_76128_c(this.func_226277_ct_()) - p_180460_1_.func_177958_n() == vector3i1.func_177958_n() && MathHelper.func_76128_c(this.func_226281_cx_()) - p_180460_1_.func_177952_p() == vector3i1.func_177952_p()) { -@@ -509,7 +_,10 @@ - this.func_213293_j(d26 * (double)(j - p_180460_1_.func_177958_n()), vector3d5.field_72448_b, d26 * (double)(i - p_180460_1_.func_177952_p())); - } - -- if (flag) { -+ if (shouldDoRailFunctions()) -+ ((AbstractRailBlock)p_180460_2_.func_177230_c()).onMinecartPass(p_180460_2_, field_70170_p, p_180460_1_, this); -+ -+ if (flag && shouldDoRailFunctions()) { - Vector3d vector3d6 = this.func_213322_ci(); - double d27 = Math.sqrt(func_213296_b(vector3d6)); - if (d27 > 0.01D) { -@@ -564,7 +_,7 @@ - - BlockState blockstate = this.field_70170_p.func_180495_p(new BlockPos(i, j, k)); - if (AbstractRailBlock.func_208487_j(blockstate)) { -- RailShape railshape = blockstate.func_177229_b(((AbstractRailBlock)blockstate.func_177230_c()).func_176560_l()); -+ RailShape railshape = ((AbstractRailBlock)blockstate.func_177230_c()).getRailDirection(blockstate, this.field_70170_p, new BlockPos(i, j, k), this); - p_70495_3_ = (double)j; - if (railshape.func_208092_c()) { - p_70495_3_ = (double)(j + 1); -@@ -603,7 +_,7 @@ - - BlockState blockstate = this.field_70170_p.func_180495_p(new BlockPos(i, j, k)); - if (AbstractRailBlock.func_208487_j(blockstate)) { -- RailShape railshape = blockstate.func_177229_b(((AbstractRailBlock)blockstate.func_177230_c()).func_176560_l()); -+ RailShape railshape = ((AbstractRailBlock)blockstate.func_177230_c()).getRailDirection(blockstate, this.field_70170_p, new BlockPos(i, j, k), this); - Pair pair = func_226573_a_(railshape); - Vector3i vector3i = pair.getFirst(); - Vector3i vector3i1 = pair.getSecond(); -@@ -666,6 +_,11 @@ - } - - public void func_70108_f(Entity p_70108_1_) { -+ //net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.minecart.MinecartCollisionEvent(this, entityIn)); -+ if (getCollisionHandler() != null) { -+ getCollisionHandler().onEntityCollision(this, p_70108_1_); -+ return; -+ } - if (!this.field_70170_p.field_72995_K) { - if (!p_70108_1_.field_70145_X && !this.field_70145_X) { - if (!this.func_184196_w(p_70108_1_)) { -@@ -701,11 +_,11 @@ - - Vector3d vector3d2 = this.func_213322_ci(); - Vector3d vector3d3 = p_70108_1_.func_213322_ci(); -- if (((AbstractMinecartEntity)p_70108_1_).func_184264_v() == AbstractMinecartEntity.Type.FURNACE && this.func_184264_v() != AbstractMinecartEntity.Type.FURNACE) { -+ if (((AbstractMinecartEntity)p_70108_1_).isPoweredCart() && !this.isPoweredCart()) { - this.func_213317_d(vector3d2.func_216372_d(0.2D, 1.0D, 0.2D)); - this.func_70024_g(vector3d3.field_72450_a - d0, 0.0D, vector3d3.field_72449_c - d1); - p_70108_1_.func_213317_d(vector3d3.func_216372_d(0.95D, 1.0D, 0.95D)); -- } else if (((AbstractMinecartEntity)p_70108_1_).func_184264_v() != AbstractMinecartEntity.Type.FURNACE && this.func_184264_v() == AbstractMinecartEntity.Type.FURNACE) { -+ } else if (!((AbstractMinecartEntity)p_70108_1_).isPoweredCart() && this.isPoweredCart()) { - p_70108_1_.func_213317_d(vector3d3.func_216372_d(0.2D, 1.0D, 0.2D)); - p_70108_1_.func_70024_g(vector3d2.field_72450_a + d0, 0.0D, vector3d2.field_72449_c + d1); - this.func_213317_d(vector3d2.func_216372_d(0.95D, 1.0D, 0.95D)); -@@ -809,6 +_,40 @@ - - public IPacket func_213297_N() { - return new SSpawnObjectPacket(this); -+ } -+ -+ private boolean canUseRail = true; -+ @Override public boolean canUseRail() { return canUseRail; } -+ @Override public void setCanUseRail(boolean value) { this.canUseRail = value; } -+ private float currentSpeedCapOnRail = getMaxCartSpeedOnRail(); -+ @Override public float getCurrentCartSpeedCapOnRail() { return currentSpeedCapOnRail; } -+ @Override public void setCurrentCartSpeedCapOnRail(float value) { currentSpeedCapOnRail = Math.min(value, getMaxCartSpeedOnRail()); } -+ private float maxSpeedAirLateral = DEFAULT_MAX_SPEED_AIR_LATERAL; -+ @Override public float getMaxSpeedAirLateral() { return maxSpeedAirLateral; } -+ @Override public void setMaxSpeedAirLateral(float value) { maxSpeedAirLateral = value; } -+ private float maxSpeedAirVertical = DEFAULT_MAX_SPEED_AIR_VERTICAL; -+ @Override public float getMaxSpeedAirVertical() { return maxSpeedAirVertical; } -+ @Override public void setMaxSpeedAirVertical(float value) { maxSpeedAirVertical = value; } -+ private double dragAir = DEFAULT_AIR_DRAG; -+ @Override public double getDragAir() { return dragAir; } -+ @Override public void setDragAir(double value) { dragAir = value; } -+ @Override -+ public double getMaxSpeedWithRail() { //Non-default because getMaximumSpeed is protected -+ if (!canUseRail()) return func_174898_m(); -+ BlockPos pos = this.getCurrentRailPosition(); -+ BlockState state = getMinecart().field_70170_p.func_180495_p(pos); -+ if (!state.func_235714_a_(BlockTags.field_203437_y)) return func_174898_m(); -+ -+ float railMaxSpeed = ((AbstractRailBlock)state.func_177230_c()).getRailMaxSpeed(state, getMinecart().field_70170_p, pos, getMinecart()); -+ return Math.min(railMaxSpeed, getCurrentCartSpeedCapOnRail()); -+ } -+ @Override -+ public void moveMinecartOnRail(BlockPos pos) { //Non-default because getMaximumSpeed is protected -+ AbstractMinecartEntity mc = getMinecart(); -+ double d24 = mc.func_184207_aI() ? 0.75D : 1.0D; -+ double d25 = mc.getMaxSpeedWithRail(); -+ Vector3d vec3d1 = mc.func_213322_ci(); -+ mc.func_213315_a(MoverType.SELF, new Vector3d(MathHelper.func_151237_a(d24 * vec3d1.field_72450_a, -d25, d25), 0.0D, MathHelper.func_151237_a(d24 * vec3d1.field_72449_c, -d25, d25))); - } - - public static enum Type { diff --git a/patches/minecraft/net/minecraft/entity/item/minecart/CommandBlockMinecartEntity.java.patch b/patches/minecraft/net/minecraft/entity/item/minecart/CommandBlockMinecartEntity.java.patch deleted file mode 100644 index abdd64a648..0000000000 --- a/patches/minecraft/net/minecraft/entity/item/minecart/CommandBlockMinecartEntity.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/entity/item/minecart/CommandBlockMinecartEntity.java -+++ b/net/minecraft/entity/item/minecart/CommandBlockMinecartEntity.java -@@ -73,6 +_,8 @@ - } - - public ActionResultType func_184230_a(PlayerEntity p_184230_1_, Hand p_184230_2_) { -+ ActionResultType ret = super.func_184230_a(p_184230_1_, p_184230_2_); -+ if (ret.func_226246_a_()) return ret; - return this.field_145824_a.func_175574_a(p_184230_1_); - } - diff --git a/patches/minecraft/net/minecraft/entity/item/minecart/ContainerMinecartEntity.java.patch b/patches/minecraft/net/minecraft/entity/item/minecart/ContainerMinecartEntity.java.patch deleted file mode 100644 index 305afe5021..0000000000 --- a/patches/minecraft/net/minecraft/entity/item/minecart/ContainerMinecartEntity.java.patch +++ /dev/null @@ -1,67 +0,0 @@ ---- a/net/minecraft/entity/item/minecart/ContainerMinecartEntity.java -+++ b/net/minecraft/entity/item/minecart/ContainerMinecartEntity.java -@@ -118,17 +_,18 @@ - } - - @Nullable -- public Entity func_241206_a_(ServerWorld p_241206_1_) { -+ public Entity changeDimension(ServerWorld p_241206_1_, net.minecraftforge.common.util.ITeleporter teleporter) { - this.field_94112_b = false; -- return super.func_241206_a_(p_241206_1_); -+ return super.changeDimension(p_241206_1_, teleporter); - } - -- public void func_70106_y() { -+ @Override -+ public void remove(boolean keepData) { - if (!this.field_70170_p.field_72995_K && this.field_94112_b) { - InventoryHelper.func_180176_a(this.field_70170_p, this, this); - } - -- super.func_70106_y(); -+ super.remove(keepData); - } - - protected void func_213281_b(CompoundNBT p_213281_1_) { -@@ -157,6 +_,8 @@ - } - - public ActionResultType func_184230_a(PlayerEntity p_184230_1_, Hand p_184230_2_) { -+ ActionResultType ret = super.func_184230_a(p_184230_1_, p_184230_2_); -+ if (ret.func_226246_a_()) return ret; - p_184230_1_.func_213829_a(this); - if (!p_184230_1_.field_70170_p.field_72995_K) { - PiglinTasks.func_234478_a_(p_184230_1_, true); -@@ -185,6 +_,8 @@ - - this.field_184290_c = null; - LootContext.Builder lootcontext$builder = (new LootContext.Builder((ServerWorld)this.field_70170_p)).func_216015_a(LootParameters.field_237457_g_, this.func_213303_ch()).func_216016_a(this.field_184291_d); -+ // Forge: add this entity to loot context, however, currently Vanilla uses 'this' for the player creating the chests. So we take over 'killer_entity' for this. -+ lootcontext$builder.func_216015_a(LootParameters.field_216284_d, this); - if (p_184288_1_ != null) { - lootcontext$builder.func_186469_a(p_184288_1_.func_184817_da()).func_216015_a(LootParameters.field_216281_a, p_184288_1_); - } -@@ -215,4 +_,23 @@ - } - - protected abstract Container func_213968_a(int p_213968_1_, PlayerInventory p_213968_2_); -+ -+ private net.minecraftforge.common.util.LazyOptional itemHandler = net.minecraftforge.common.util.LazyOptional.of(() -> new net.minecraftforge.items.wrapper.InvWrapper(this)); -+ -+ @Override -+ public net.minecraftforge.common.util.LazyOptional getCapability(net.minecraftforge.common.capabilities.Capability capability, @Nullable net.minecraft.util.Direction facing) { -+ if (this.func_70089_S() && capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) -+ return itemHandler.cast(); -+ return super.getCapability(capability, facing); -+ } -+ -+ @Override -+ protected void invalidateCaps() { -+ super.invalidateCaps(); -+ itemHandler.invalidate(); -+ } -+ -+ public void dropContentsWhenDead(boolean value) { -+ this.field_94112_b = value; -+ } - } diff --git a/patches/minecraft/net/minecraft/entity/item/minecart/FurnaceMinecartEntity.java.patch b/patches/minecraft/net/minecraft/entity/item/minecart/FurnaceMinecartEntity.java.patch deleted file mode 100644 index 4bf7fa2de5..0000000000 --- a/patches/minecraft/net/minecraft/entity/item/minecart/FurnaceMinecartEntity.java.patch +++ /dev/null @@ -1,23 +0,0 @@ ---- a/net/minecraft/entity/item/minecart/FurnaceMinecartEntity.java -+++ b/net/minecraft/entity/item/minecart/FurnaceMinecartEntity.java -@@ -72,6 +_,11 @@ - return 0.2D; - } - -+ @Override -+ public float getMaxCartSpeedOnRail() { -+ return 0.2f; -+ } -+ - public void func_94095_a(DamageSource p_94095_1_) { - super.func_94095_a(p_94095_1_); - if (!p_94095_1_.func_94541_c() && this.field_70170_p.func_82736_K().func_223586_b(GameRules.field_223604_g)) { -@@ -111,6 +_,8 @@ - } - - public ActionResultType func_184230_a(PlayerEntity p_184230_1_, Hand p_184230_2_) { -+ ActionResultType ret = super.func_184230_a(p_184230_1_, p_184230_2_); -+ if (ret.func_226246_a_()) return ret; - ItemStack itemstack = p_184230_1_.func_184586_b(p_184230_2_); - if (field_195407_e.test(itemstack) && this.field_94110_c + 3600 <= 32000) { - if (!p_184230_1_.field_71075_bZ.field_75098_d) { diff --git a/patches/minecraft/net/minecraft/entity/item/minecart/MinecartEntity.java.patch b/patches/minecraft/net/minecraft/entity/item/minecart/MinecartEntity.java.patch deleted file mode 100644 index d504b01258..0000000000 --- a/patches/minecraft/net/minecraft/entity/item/minecart/MinecartEntity.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/entity/item/minecart/MinecartEntity.java -+++ b/net/minecraft/entity/item/minecart/MinecartEntity.java -@@ -16,6 +_,8 @@ - } - - public ActionResultType func_184230_a(PlayerEntity p_184230_1_, Hand p_184230_2_) { -+ ActionResultType ret = super.func_184230_a(p_184230_1_, p_184230_2_); -+ if (ret.func_226246_a_()) return ret; - if (p_184230_1_.func_226563_dT_()) { - return ActionResultType.PASS; - } else if (this.func_184207_aI()) { diff --git a/patches/minecraft/net/minecraft/entity/item/minecart/SpawnerMinecartEntity.java.patch b/patches/minecraft/net/minecraft/entity/item/minecart/SpawnerMinecartEntity.java.patch deleted file mode 100644 index 3739623ebc..0000000000 --- a/patches/minecraft/net/minecraft/entity/item/minecart/SpawnerMinecartEntity.java.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- a/net/minecraft/entity/item/minecart/SpawnerMinecartEntity.java -+++ b/net/minecraft/entity/item/minecart/SpawnerMinecartEntity.java -@@ -23,6 +_,12 @@ - public BlockPos func_177221_b() { - return SpawnerMinecartEntity.this.func_233580_cy_(); - } -+ -+ @Override -+ @javax.annotation.Nullable -+ public net.minecraft.entity.Entity getSpawnerEntity() { -+ return SpawnerMinecartEntity.this; -+ } - }; - - public SpawnerMinecartEntity(EntityType p_i50114_1_, World p_i50114_2_) { diff --git a/patches/minecraft/net/minecraft/entity/merchant/villager/AbstractVillagerEntity.java.patch b/patches/minecraft/net/minecraft/entity/merchant/villager/AbstractVillagerEntity.java.patch deleted file mode 100644 index 47ecb8c35b..0000000000 --- a/patches/minecraft/net/minecraft/entity/merchant/villager/AbstractVillagerEntity.java.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/net/minecraft/entity/merchant/villager/AbstractVillagerEntity.java -+++ b/net/minecraft/entity/merchant/villager/AbstractVillagerEntity.java -@@ -165,9 +_,9 @@ - } - - @Nullable -- public Entity func_241206_a_(ServerWorld p_241206_1_) { -+ public Entity changeDimension(ServerWorld p_241206_1_, net.minecraftforge.common.util.ITeleporter teleporter) { - this.func_213750_eg(); -- return super.func_241206_a_(p_241206_1_); -+ return super.changeDimension(p_241206_1_, teleporter); - } - - protected void func_213750_eg() { diff --git a/patches/minecraft/net/minecraft/entity/merchant/villager/VillagerEntity.java.patch b/patches/minecraft/net/minecraft/entity/merchant/villager/VillagerEntity.java.patch deleted file mode 100644 index a320d2afe1..0000000000 --- a/patches/minecraft/net/minecraft/entity/merchant/villager/VillagerEntity.java.patch +++ /dev/null @@ -1,38 +0,0 @@ ---- a/net/minecraft/entity/merchant/villager/VillagerEntity.java -+++ b/net/minecraft/entity/merchant/villager/VillagerEntity.java -@@ -241,7 +_,7 @@ - - public ActionResultType func_230254_b_(PlayerEntity p_230254_1_, Hand p_230254_2_) { - ItemStack itemstack = p_230254_1_.func_184586_b(p_230254_2_); -- if (itemstack.func_77973_b() != Items.field_196172_da && this.func_70089_S() && !this.func_213716_dX() && !this.func_70608_bn()) { -+ if (itemstack.func_77973_b() != Items.field_196172_da && this.func_70089_S() && !this.func_213716_dX() && !this.func_70608_bn() && !p_230254_1_.func_226563_dT_()) { - if (this.func_70631_g_()) { - this.func_213756_es(); - return ActionResultType.func_233537_a_(this.field_70170_p.field_72995_K); -@@ -634,7 +_,8 @@ - } - - protected ITextComponent func_225513_by_() { -- return new TranslationTextComponent(this.func_200600_R().func_210760_d() + '.' + Registry.field_218370_L.func_177774_c(this.func_213700_eh().func_221130_b()).func_110623_a()); -+ net.minecraft.util.ResourceLocation profName = this.func_213700_eh().func_221130_b().getRegistryName(); -+ return new TranslationTextComponent(this.func_200600_R().func_210760_d() + '.' + (!"minecraft".equals(profName.func_110624_b()) ? profName.func_110624_b() + '.' : "") + profName.func_110623_a()); - } - - @OnlyIn(Dist.CLIENT) -@@ -687,7 +_,7 @@ - } - - public void func_241841_a(ServerWorld p_241841_1_, LightningBoltEntity p_241841_2_) { -- if (p_241841_1_.func_175659_aa() != Difficulty.PEACEFUL) { -+ if (p_241841_1_.func_175659_aa() != Difficulty.PEACEFUL && net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, EntityType.field_200759_ay, (timer) -> {})) { - field_184243_a.info("Villager {} was struck by lightning {}.", this, p_241841_2_); - WitchEntity witchentity = EntityType.field_200759_ay.func_200721_a(p_241841_1_); - witchentity.func_70012_b(this.func_226277_ct_(), this.func_226278_cu_(), this.func_226281_cx_(), this.field_70177_z, this.field_70125_A); -@@ -699,6 +_,7 @@ - } - - witchentity.func_110163_bv(); -+ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, witchentity); - p_241841_1_.func_242417_l(witchentity); - this.func_242369_fq(); - this.func_70106_y(); diff --git a/patches/minecraft/net/minecraft/entity/merchant/villager/VillagerProfession.java.patch b/patches/minecraft/net/minecraft/entity/merchant/villager/VillagerProfession.java.patch deleted file mode 100644 index f6888e9c1d..0000000000 --- a/patches/minecraft/net/minecraft/entity/merchant/villager/VillagerProfession.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/entity/merchant/villager/VillagerProfession.java -+++ b/net/minecraft/entity/merchant/villager/VillagerProfession.java -@@ -12,7 +_,7 @@ - import net.minecraft.util.registry.Registry; - import net.minecraft.village.PointOfInterestType; - --public class VillagerProfession { -+public class VillagerProfession extends net.minecraftforge.registries.ForgeRegistryEntry { - public static final VillagerProfession field_221151_a = func_226556_a_("none", PointOfInterestType.field_221054_b, (SoundEvent)null); - public static final VillagerProfession field_221152_b = func_226556_a_("armorer", PointOfInterestType.field_221055_c, SoundEvents.field_219694_mB); - public static final VillagerProfession field_221153_c = func_226556_a_("butcher", PointOfInterestType.field_221056_d, SoundEvents.field_219695_mC); diff --git a/patches/minecraft/net/minecraft/entity/monster/AbstractSkeletonEntity.java.patch b/patches/minecraft/net/minecraft/entity/monster/AbstractSkeletonEntity.java.patch deleted file mode 100644 index 7ddec472b4..0000000000 --- a/patches/minecraft/net/minecraft/entity/monster/AbstractSkeletonEntity.java.patch +++ /dev/null @@ -1,23 +0,0 @@ ---- a/net/minecraft/entity/monster/AbstractSkeletonEntity.java -+++ b/net/minecraft/entity/monster/AbstractSkeletonEntity.java -@@ -154,7 +_,7 @@ - if (this.field_70170_p != null && !this.field_70170_p.field_72995_K) { - this.field_70714_bg.func_85156_a(this.field_85038_e); - this.field_70714_bg.func_85156_a(this.field_85037_d); -- ItemStack itemstack = this.func_184586_b(ProjectileHelper.func_221274_a(this, Items.field_151031_f)); -+ ItemStack itemstack = this.func_184586_b(ProjectileHelper.getWeaponHoldingHand(this, item -> item instanceof net.minecraft.item.BowItem)); - if (itemstack.func_77973_b() == Items.field_151031_f) { - int i = 20; - if (this.field_70170_p.func_175659_aa() != Difficulty.HARD) { -@@ -171,8 +_,10 @@ - } - - public void func_82196_d(LivingEntity p_82196_1_, float p_82196_2_) { -- ItemStack itemstack = this.func_213356_f(this.func_184586_b(ProjectileHelper.func_221274_a(this, Items.field_151031_f))); -+ ItemStack itemstack = this.func_213356_f(this.func_184586_b(ProjectileHelper.getWeaponHoldingHand(this, item -> item instanceof net.minecraft.item.BowItem))); - AbstractArrowEntity abstractarrowentity = this.func_213624_b(itemstack, p_82196_2_); -+ if (this.func_184614_ca().func_77973_b() instanceof net.minecraft.item.BowItem) -+ abstractarrowentity = ((net.minecraft.item.BowItem)this.func_184614_ca().func_77973_b()).customArrow(abstractarrowentity); - double d0 = p_82196_1_.func_226277_ct_() - this.func_226277_ct_(); - double d1 = p_82196_1_.func_226283_e_(0.3333333333333333D) - abstractarrowentity.func_226278_cu_(); - double d2 = p_82196_1_.func_226281_cx_() - this.func_226281_cx_(); diff --git a/patches/minecraft/net/minecraft/entity/monster/CreeperEntity.java.patch b/patches/minecraft/net/minecraft/entity/monster/CreeperEntity.java.patch deleted file mode 100644 index 2144655ba5..0000000000 --- a/patches/minecraft/net/minecraft/entity/monster/CreeperEntity.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/entity/monster/CreeperEntity.java -+++ b/net/minecraft/entity/monster/CreeperEntity.java -@@ -216,7 +_,7 @@ - - private void func_146077_cc() { - if (!this.field_70170_p.field_72995_K) { -- Explosion.Mode explosion$mode = this.field_70170_p.func_82736_K().func_223586_b(GameRules.field_223599_b) ? Explosion.Mode.DESTROY : Explosion.Mode.NONE; -+ Explosion.Mode explosion$mode = net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.field_70170_p, this) ? Explosion.Mode.DESTROY : Explosion.Mode.NONE; - float f = this.func_225509_J__() ? 2.0F : 1.0F; - this.field_70729_aU = true; - this.field_70170_p.func_217385_a(this, this.func_226277_ct_(), this.func_226278_cu_(), this.func_226281_cx_(), (float)this.field_82226_g * f, explosion$mode); diff --git a/patches/minecraft/net/minecraft/entity/monster/EndermanEntity.java.patch b/patches/minecraft/net/minecraft/entity/monster/EndermanEntity.java.patch deleted file mode 100644 index 3026d27854..0000000000 --- a/patches/minecraft/net/minecraft/entity/monster/EndermanEntity.java.patch +++ /dev/null @@ -1,80 +0,0 @@ ---- a/net/minecraft/entity/monster/EndermanEntity.java -+++ b/net/minecraft/entity/monster/EndermanEntity.java -@@ -98,7 +_,6 @@ - } - - public void func_70624_b(@Nullable LivingEntity p_70624_1_) { -- super.func_70624_b(p_70624_1_); - ModifiableAttributeInstance modifiableattributeinstance = this.func_110148_a(Attributes.field_233821_d_); - if (p_70624_1_ == null) { - this.field_184721_by = 0; -@@ -113,6 +_,7 @@ - } - } - -+ super.func_70624_b(p_70624_1_); //Forge: Moved down to allow event handlers to write data manager values. - } - - protected void func_70088_a() { -@@ -181,12 +_,13 @@ - } - - this.func_195406_b(blockstate); -+ if(!field_70170_p.field_72995_K) //FORGE: allow this entity to be read from nbt on client. (Fixes MC-189565) - this.func_241358_a_((ServerWorld)this.field_70170_p, p_70037_1_); - } - - private boolean func_70821_d(PlayerEntity p_70821_1_) { - ItemStack itemstack = p_70821_1_.field_71071_by.field_70460_b.get(3); -- if (itemstack.func_77973_b() == Blocks.field_196625_cS.func_199767_j()) { -+ if (itemstack.isEnderMask(p_70821_1_, this)) { - return false; - } else { - Vector3d vector3d = p_70821_1_.func_70676_i(1.0F).func_72432_b(); -@@ -265,7 +_,9 @@ - boolean flag = blockstate.func_185904_a().func_76230_c(); - boolean flag1 = blockstate.func_204520_s().func_206884_a(FluidTags.field_206959_a); - if (flag && !flag1) { -- boolean flag2 = this.func_213373_a(p_70825_1_, p_70825_3_, p_70825_5_, true); -+ net.minecraftforge.event.entity.living.EntityTeleportEvent.EnderEntity event = net.minecraftforge.event.ForgeEventFactory.onEnderTeleport(this, p_70825_1_, p_70825_3_, p_70825_5_); -+ if (event.isCanceled()) return false; -+ boolean flag2 = this.func_213373_a(event.getTargetX(), event.getTargetY(), event.getTargetZ(), true); - if (flag2 && !this.func_174814_R()) { - this.field_70170_p.func_184148_a((PlayerEntity)null, this.field_70169_q, this.field_70167_r, this.field_70166_s, SoundEvents.field_187534_aX, this.func_184176_by(), 1.0F, 1.0F); - this.func_184185_a(SoundEvents.field_187534_aX, 1.0F, 1.0F); -@@ -429,7 +_,7 @@ - public boolean func_75250_a() { - if (this.field_179475_a.func_195405_dq() == null) { - return false; -- } else if (!this.field_179475_a.field_70170_p.func_82736_K().func_223586_b(GameRules.field_223599_b)) { -+ } else if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.field_179475_a.field_70170_p, this.field_179475_a)) { - return false; - } else { - return this.field_179475_a.func_70681_au().nextInt(2000) == 0; -@@ -449,7 +_,7 @@ - BlockState blockstate2 = this.field_179475_a.func_195405_dq(); - if (blockstate2 != null) { - blockstate2 = Block.func_199770_b(blockstate2, this.field_179475_a.field_70170_p, blockpos); -- if (this.func_220836_a(world, blockpos, blockstate2, blockstate, blockstate1, blockpos1)) { -+ if (this.func_220836_a(world, blockpos, blockstate2, blockstate, blockstate1, blockpos1) && !net.minecraftforge.event.ForgeEventFactory.onBlockPlace(field_179475_a, net.minecraftforge.common.util.BlockSnapshot.create(world.func_234923_W_(), world, blockpos1), net.minecraft.util.Direction.UP)) { - world.func_180501_a(blockpos, blockstate2, 3); - this.field_179475_a.func_195406_b((BlockState)null); - } -@@ -458,7 +_,7 @@ - } - - private boolean func_220836_a(World p_220836_1_, BlockPos p_220836_2_, BlockState p_220836_3_, BlockState p_220836_4_, BlockState p_220836_5_, BlockPos p_220836_6_) { -- return p_220836_4_.func_196958_f() && !p_220836_5_.func_196958_f() && !p_220836_5_.func_203425_a(Blocks.field_150357_h) && p_220836_5_.func_235785_r_(p_220836_1_, p_220836_6_) && p_220836_3_.func_196955_c(p_220836_1_, p_220836_2_) && p_220836_1_.func_72839_b(this.field_179475_a, AxisAlignedBB.func_241549_a_(Vector3d.func_237491_b_(p_220836_2_))).isEmpty(); -+ return p_220836_4_.isAir(p_220836_1_, p_220836_2_) && !p_220836_5_.isAir(p_220836_1_, p_220836_6_) && !p_220836_5_.func_203425_a(Blocks.field_150357_h) && !p_220836_5_.func_235714_a_(net.minecraftforge.common.Tags.Blocks.ENDERMAN_PLACE_ON_BLACKLIST) && p_220836_5_.func_235785_r_(p_220836_1_, p_220836_6_) && p_220836_3_.func_196955_c(p_220836_1_, p_220836_2_) && p_220836_1_.func_72839_b(this.field_179475_a, AxisAlignedBB.func_241549_a_(Vector3d.func_237491_b_(p_220836_2_))).isEmpty(); - } - } - -@@ -500,7 +_,7 @@ - public boolean func_75250_a() { - if (this.field_179473_a.func_195405_dq() != null) { - return false; -- } else if (!this.field_179473_a.field_70170_p.func_82736_K().func_223586_b(GameRules.field_223599_b)) { -+ } else if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.field_179473_a.field_70170_p, this.field_179473_a)) { - return false; - } else { - return this.field_179473_a.func_70681_au().nextInt(20) == 0; diff --git a/patches/minecraft/net/minecraft/entity/monster/EvokerEntity.java.patch b/patches/minecraft/net/minecraft/entity/monster/EvokerEntity.java.patch deleted file mode 100644 index 94297ba162..0000000000 --- a/patches/minecraft/net/minecraft/entity/monster/EvokerEntity.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/entity/monster/EvokerEntity.java -+++ b/net/minecraft/entity/monster/EvokerEntity.java -@@ -280,7 +_,7 @@ - return false; - } else if (EvokerEntity.this.field_70173_aa < this.field_193322_d) { - return false; -- } else if (!EvokerEntity.this.field_70170_p.func_82736_K().func_223586_b(GameRules.field_223599_b)) { -+ } else if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(EvokerEntity.this.field_70170_p, EvokerEntity.this)) { - return false; - } else { - List list = EvokerEntity.this.field_70170_p.func_217374_a(SheepEntity.class, this.field_220845_e, EvokerEntity.this, EvokerEntity.this.func_174813_aQ().func_72314_b(16.0D, 4.0D, 16.0D)); diff --git a/patches/minecraft/net/minecraft/entity/monster/HoglinEntity.java.patch b/patches/minecraft/net/minecraft/entity/monster/HoglinEntity.java.patch deleted file mode 100644 index 3e8998c34a..0000000000 --- a/patches/minecraft/net/minecraft/entity/monster/HoglinEntity.java.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- a/net/minecraft/entity/monster/HoglinEntity.java -+++ b/net/minecraft/entity/monster/HoglinEntity.java -@@ -117,7 +_,7 @@ - HoglinTasks.func_234377_a_(this); - if (this.func_234364_eK_()) { - ++this.field_234358_by_; -- if (this.field_234358_by_ > 300) { -+ if (this.field_234358_by_ > 300 && net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, EntityType.field_233590_aW_, (timer) -> this.field_234358_by_ = timer)) { - this.func_241412_a_(SoundEvents.field_232715_fE_); - this.func_234360_a_((ServerWorld)this.field_70170_p); - } -@@ -212,6 +_,7 @@ - ZoglinEntity zoglinentity = this.func_233656_b_(EntityType.field_233590_aW_, true); - if (zoglinentity != null) { - zoglinentity.func_195064_c(new EffectInstance(Effects.field_76431_k, 200, 0)); -+ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, zoglinentity); - } - - } diff --git a/patches/minecraft/net/minecraft/entity/monster/IllusionerEntity.java.patch b/patches/minecraft/net/minecraft/entity/monster/IllusionerEntity.java.patch deleted file mode 100644 index 59fce1d051..0000000000 --- a/patches/minecraft/net/minecraft/entity/monster/IllusionerEntity.java.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/net/minecraft/entity/monster/IllusionerEntity.java -+++ b/net/minecraft/entity/monster/IllusionerEntity.java -@@ -180,8 +_,10 @@ - } - - public void func_82196_d(LivingEntity p_82196_1_, float p_82196_2_) { -- ItemStack itemstack = this.func_213356_f(this.func_184586_b(ProjectileHelper.func_221274_a(this, Items.field_151031_f))); -+ ItemStack itemstack = this.func_213356_f(this.func_184586_b(ProjectileHelper.getWeaponHoldingHand(this, item -> item instanceof net.minecraft.item.BowItem))); - AbstractArrowEntity abstractarrowentity = ProjectileHelper.func_221272_a(this, itemstack, p_82196_2_); -+ if (this.func_184614_ca().func_77973_b() instanceof net.minecraft.item.BowItem) -+ abstractarrowentity = ((net.minecraft.item.BowItem)this.func_184614_ca().func_77973_b()).customArrow(abstractarrowentity); - double d0 = p_82196_1_.func_226277_ct_() - this.func_226277_ct_(); - double d1 = p_82196_1_.func_226283_e_(0.3333333333333333D) - abstractarrowentity.func_226278_cu_(); - double d2 = p_82196_1_.func_226281_cx_() - this.func_226281_cx_(); diff --git a/patches/minecraft/net/minecraft/entity/monster/MagmaCubeEntity.java.patch b/patches/minecraft/net/minecraft/entity/monster/MagmaCubeEntity.java.patch deleted file mode 100644 index 331816bec0..0000000000 --- a/patches/minecraft/net/minecraft/entity/monster/MagmaCubeEntity.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/entity/monster/MagmaCubeEntity.java -+++ b/net/minecraft/entity/monster/MagmaCubeEntity.java -@@ -72,6 +_,7 @@ - Vector3d vector3d = this.func_213322_ci(); - this.func_213293_j(vector3d.field_72450_a, (double)(this.func_175134_bD() + (float)this.func_70809_q() * 0.1F), vector3d.field_72449_c); - this.field_70160_al = true; -+ net.minecraftforge.common.ForgeHooks.onLivingJump(this); - } - - protected void func_180466_bG(ITag p_180466_1_) { diff --git a/patches/minecraft/net/minecraft/entity/monster/PillagerEntity.java.patch b/patches/minecraft/net/minecraft/entity/monster/PillagerEntity.java.patch deleted file mode 100644 index 5368b225bf..0000000000 --- a/patches/minecraft/net/minecraft/entity/monster/PillagerEntity.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/entity/monster/PillagerEntity.java -+++ b/net/minecraft/entity/monster/PillagerEntity.java -@@ -120,7 +_,7 @@ - public AbstractIllagerEntity.ArmPose func_193077_p() { - if (this.func_213675_dX()) { - return AbstractIllagerEntity.ArmPose.CROSSBOW_CHARGE; -- } else if (this.func_233631_a_(Items.field_222114_py)) { -+ } else if (this.func_233634_a_(item -> item instanceof net.minecraft.item.CrossbowItem)) { - return AbstractIllagerEntity.ArmPose.CROSSBOW_HOLD; - } else { - return this.func_213398_dR() ? AbstractIllagerEntity.ArmPose.ATTACKING : AbstractIllagerEntity.ArmPose.NEUTRAL; diff --git a/patches/minecraft/net/minecraft/entity/monster/RavagerEntity.java.patch b/patches/minecraft/net/minecraft/entity/monster/RavagerEntity.java.patch deleted file mode 100644 index 726c1ebda5..0000000000 --- a/patches/minecraft/net/minecraft/entity/monster/RavagerEntity.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/entity/monster/RavagerEntity.java -+++ b/net/minecraft/entity/monster/RavagerEntity.java -@@ -134,7 +_,7 @@ - this.func_110148_a(Attributes.field_233821_d_).func_111128_a(MathHelper.func_219803_d(0.1D, d1, d0)); - } - -- if (this.field_70123_F && this.field_70170_p.func_82736_K().func_223586_b(GameRules.field_223599_b)) { -+ if (this.field_70123_F && net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.field_70170_p, this)) { - boolean flag = false; - AxisAlignedBB axisalignedbb = this.func_174813_aQ().func_186662_g(0.2D); - diff --git a/patches/minecraft/net/minecraft/entity/monster/ShulkerEntity.java.patch b/patches/minecraft/net/minecraft/entity/monster/ShulkerEntity.java.patch deleted file mode 100644 index 33a52e268d..0000000000 --- a/patches/minecraft/net/minecraft/entity/monster/ShulkerEntity.java.patch +++ /dev/null @@ -1,40 +0,0 @@ ---- a/net/minecraft/entity/monster/ShulkerEntity.java -+++ b/net/minecraft/entity/monster/ShulkerEntity.java -@@ -166,7 +_,7 @@ - this.field_184708_bA = 0; - } else if (!this.field_70170_p.field_72995_K) { - BlockState blockstate = this.field_70170_p.func_180495_p(blockpos); -- if (!blockstate.func_196958_f()) { -+ if (!blockstate.isAir(this.field_70170_p, blockpos)) { - if (blockstate.func_203425_a(Blocks.field_196603_bb)) { - Direction direction = blockstate.func_177229_b(PistonBlock.field_176387_N); - if (this.field_70170_p.func_175623_d(blockpos.func_177972_a(direction))) { -@@ -219,6 +_,7 @@ - this.func_226286_f_((double)blockpos.func_177958_n() + 0.5D, (double)blockpos.func_177956_o(), (double)blockpos.func_177952_p() + 0.5D); - double d2 = 0.5D - (double)MathHelper.func_76126_a((0.5F + this.field_184706_by) * (float)Math.PI) * 0.5D; - double d0 = 0.5D - (double)MathHelper.func_76126_a((0.5F + this.field_184705_bx) * (float)Math.PI) * 0.5D; -+ if (this.isAddedToWorld() && this.field_70170_p instanceof net.minecraft.world.server.ServerWorld) ((net.minecraft.world.server.ServerWorld)this.field_70170_p).func_217464_b(this); // Forge - Process chunk registration after moving. - Direction direction2 = this.func_184696_cZ().func_176734_d(); - this.func_174826_a((new AxisAlignedBB(this.func_226277_ct_() - 0.5D, this.func_226278_cu_(), this.func_226281_cx_() - 0.5D, this.func_226277_ct_() + 0.5D, this.func_226278_cu_() + 1.0D, this.func_226281_cx_() + 0.5D)).func_72321_a((double)direction2.func_82601_c() * d2, (double)direction2.func_96559_d() * d2, (double)direction2.func_82599_e() * d2)); - double d1 = d2 - d0; -@@ -249,6 +_,7 @@ - super.func_70107_b(p_70107_1_, p_70107_3_, p_70107_5_); - if (this.field_70180_af != null && this.field_70173_aa != 0) { - Optional optional = this.field_70180_af.func_187225_a(field_184701_b); -+ if (this.isAddedToWorld() && this.field_70170_p instanceof net.minecraft.world.server.ServerWorld) ((net.minecraft.world.server.ServerWorld)this.field_70170_p).func_217464_b(this); // Forge - Process chunk registration after moving. - Optional optional1 = Optional.of(new BlockPos(p_70107_1_, p_70107_3_, p_70107_5_)); - if (!optional1.equals(optional)) { - this.field_70180_af.func_187227_b(field_184701_b, optional1); -@@ -282,6 +_,12 @@ - BlockPos blockpos1 = blockpos.func_177982_a(8 - this.field_70146_Z.nextInt(17), 8 - this.field_70146_Z.nextInt(17), 8 - this.field_70146_Z.nextInt(17)); - if (blockpos1.func_177956_o() > 0 && this.field_70170_p.func_175623_d(blockpos1) && this.field_70170_p.func_175723_af().func_177746_a(blockpos1) && this.field_70170_p.func_226665_a__(this, new AxisAlignedBB(blockpos1))) { - Direction direction = this.func_234299_g_(blockpos1); -+ if (direction != null) { -+ net.minecraftforge.event.entity.living.EntityTeleportEvent.EnderEntity event = net.minecraftforge.event.ForgeEventFactory.onEnderTeleport(this, blockpos1.func_177958_n(), blockpos1.func_177956_o(), blockpos1.func_177952_p()); -+ if (event.isCanceled()) direction = null; -+ blockpos1 = new BlockPos(event.getTargetX(), event.getTargetY(), event.getTargetZ()); -+ } -+ - if (direction != null) { - this.field_70180_af.func_187227_b(field_184700_a, direction); - this.func_184185_a(SoundEvents.field_187791_eX, 1.0F, 1.0F); diff --git a/patches/minecraft/net/minecraft/entity/monster/SilverfishEntity.java.patch b/patches/minecraft/net/minecraft/entity/monster/SilverfishEntity.java.patch deleted file mode 100644 index e019c5ef50..0000000000 --- a/patches/minecraft/net/minecraft/entity/monster/SilverfishEntity.java.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/entity/monster/SilverfishEntity.java -+++ b/net/minecraft/entity/monster/SilverfishEntity.java -@@ -134,7 +_,7 @@ - return false; - } else { - Random random = this.field_75457_a.func_70681_au(); -- if (this.field_75457_a.field_70170_p.func_82736_K().func_223586_b(GameRules.field_223599_b) && random.nextInt(10) == 0) { -+ if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.field_75457_a.field_70170_p, this.field_75457_a) && random.nextInt(10) == 0) { - this.field_179483_b = Direction.func_239631_a_(random); - BlockPos blockpos = (new BlockPos(this.field_75457_a.func_226277_ct_(), this.field_75457_a.func_226278_cu_() + 0.5D, this.field_75457_a.func_226281_cx_())).func_177972_a(this.field_179483_b); - BlockState blockstate = this.field_75457_a.field_70170_p.func_180495_p(blockpos); -@@ -203,7 +_,7 @@ - BlockState blockstate = world.func_180495_p(blockpos1); - Block block = blockstate.func_177230_c(); - if (block instanceof SilverfishBlock) { -- if (world.func_82736_K().func_223586_b(GameRules.field_223599_b)) { -+ if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(world, this.field_179464_a)) { - world.func_225521_a_(blockpos1, true, this.field_179464_a); - } else { - world.func_180501_a(blockpos1, ((SilverfishBlock)block).func_196468_d().func_176223_P(), 3); diff --git a/patches/minecraft/net/minecraft/entity/monster/SlimeEntity.java.patch b/patches/minecraft/net/minecraft/entity/monster/SlimeEntity.java.patch deleted file mode 100644 index 688030b0cc..0000000000 --- a/patches/minecraft/net/minecraft/entity/monster/SlimeEntity.java.patch +++ /dev/null @@ -1,45 +0,0 @@ ---- a/net/minecraft/entity/monster/SlimeEntity.java -+++ b/net/minecraft/entity/monster/SlimeEntity.java -@@ -127,6 +_,7 @@ - if (this.field_70122_E && !this.field_175452_bi) { - int i = this.func_70809_q(); - -+ if (spawnCustomParticles()) i = 0; // don't spawn particles if it's handled by the implementation itself - for(int j = 0; j < i * 8; ++j) { - float f = this.field_70146_Z.nextFloat() * ((float)Math.PI * 2F); - float f1 = this.field_70146_Z.nextFloat() * 0.5F + 0.5F; -@@ -178,9 +_,10 @@ - return (EntityType)super.func_200600_R(); - } - -- public void func_70106_y() { -+ @Override -+ public void remove(boolean keepData) { - int i = this.func_70809_q(); -- if (!this.field_70170_p.field_72995_K && i > 1 && this.func_233643_dh_()) { -+ if (!this.field_70170_p.field_72995_K && i > 1 && this.func_233643_dh_() && !this.field_70128_L) { - ITextComponent itextcomponent = this.func_200201_e(); - boolean flag = this.func_175446_cd(); - float f = (float)i / 4.0F; -@@ -204,7 +_,7 @@ - } - } - -- super.func_70106_y(); -+ super.remove(keepData); - } - - public void func_70108_f(Entity p_70108_1_) { -@@ -323,6 +_,12 @@ - public EntitySize func_213305_a(Pose p_213305_1_) { - return super.func_213305_a(p_213305_1_).func_220313_a(0.255F * (float)this.func_70809_q()); - } -+ -+ /** -+ * Called when the slime spawns particles on landing, see onUpdate. -+ * Return true to prevent the spawning of the default particles. -+ */ -+ protected boolean spawnCustomParticles() { return false; } - - static class AttackGoal extends Goal { - private final SlimeEntity field_179466_a; diff --git a/patches/minecraft/net/minecraft/entity/monster/SpiderEntity.java.patch b/patches/minecraft/net/minecraft/entity/monster/SpiderEntity.java.patch deleted file mode 100644 index 5f697312aa..0000000000 --- a/patches/minecraft/net/minecraft/entity/monster/SpiderEntity.java.patch +++ /dev/null @@ -1,16 +0,0 @@ ---- a/net/minecraft/entity/monster/SpiderEntity.java -+++ b/net/minecraft/entity/monster/SpiderEntity.java -@@ -118,7 +_,12 @@ - } - - public boolean func_70687_e(EffectInstance p_70687_1_) { -- return p_70687_1_.func_188419_a() == Effects.field_76436_u ? false : super.func_70687_e(p_70687_1_); -+ if (p_70687_1_.func_188419_a() == Effects.field_76436_u) { -+ net.minecraftforge.event.entity.living.PotionEvent.PotionApplicableEvent event = new net.minecraftforge.event.entity.living.PotionEvent.PotionApplicableEvent(this, p_70687_1_); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); -+ return event.getResult() == net.minecraftforge.eventbus.api.Event.Result.ALLOW; -+ } -+ return super.func_70687_e(p_70687_1_); - } - - public boolean func_70841_p() { diff --git a/patches/minecraft/net/minecraft/entity/monster/ZombieEntity.java.patch b/patches/minecraft/net/minecraft/entity/monster/ZombieEntity.java.patch deleted file mode 100644 index ceb1dcce8e..0000000000 --- a/patches/minecraft/net/minecraft/entity/monster/ZombieEntity.java.patch +++ /dev/null @@ -1,81 +0,0 @@ ---- a/net/minecraft/entity/monster/ZombieEntity.java -+++ b/net/minecraft/entity/monster/ZombieEntity.java -@@ -186,7 +_,8 @@ - if (!this.field_70170_p.field_72995_K && this.func_70089_S() && !this.func_175446_cd()) { - if (this.func_204706_dD()) { - --this.field_204708_bE; -- if (this.field_204708_bE < 0) { -+ -+ if (this.field_204708_bE < 0 && net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, EntityType.field_200725_aD, (timer) -> this.field_204708_bE = timer)) { - this.func_207302_dI(); - } - } else if (this.func_204703_dA()) { -@@ -248,6 +_,7 @@ - if (zombieentity != null) { - zombieentity.func_207304_a(zombieentity.field_70170_p.func_175649_E(zombieentity.func_233580_cy_()).func_180170_c()); - zombieentity.func_146070_a(zombieentity.func_204900_dz() && this.func_146072_bX()); -+ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, zombieentity); - } - - } -@@ -268,11 +_,15 @@ - livingentity = (LivingEntity)p_70097_1_.func_76346_g(); - } - -- if (livingentity != null && this.field_70170_p.func_175659_aa() == Difficulty.HARD && (double)this.field_70146_Z.nextFloat() < this.func_233637_b_(Attributes.field_233829_l_) && this.field_70170_p.func_82736_K().func_223586_b(GameRules.field_223601_d)) { - int i = MathHelper.func_76128_c(this.func_226277_ct_()); - int j = MathHelper.func_76128_c(this.func_226278_cu_()); - int k = MathHelper.func_76128_c(this.func_226281_cx_()); -- ZombieEntity zombieentity = new ZombieEntity(this.field_70170_p); -+ -+ net.minecraftforge.event.entity.living.ZombieEvent.SummonAidEvent event = net.minecraftforge.event.ForgeEventFactory.fireZombieSummonAid(this, field_70170_p, i, j, k, livingentity, this.func_110148_a(Attributes.field_233829_l_).func_111126_e()); -+ if (event.getResult() == net.minecraftforge.eventbus.api.Event.Result.DENY) return true; -+ if (event.getResult() == net.minecraftforge.eventbus.api.Event.Result.ALLOW || -+ livingentity != null && this.field_70170_p.func_175659_aa() == Difficulty.HARD && (double)this.field_70146_Z.nextFloat() < this.func_110148_a(Attributes.field_233829_l_).func_111126_e() && this.field_70170_p.func_82736_K().func_223586_b(GameRules.field_223601_d)) { -+ ZombieEntity zombieentity = event.getCustomSummonedAid() != null && event.getResult() == net.minecraftforge.eventbus.api.Event.Result.ALLOW ? event.getCustomSummonedAid() : EntityType.field_200725_aD.func_200721_a(this.field_70170_p); - - for(int l = 0; l < 50; ++l) { - int i1 = i + MathHelper.func_76136_a(this.field_70146_Z, 7, 40) * MathHelper.func_76136_a(this.field_70146_Z, -1, 1); -@@ -284,6 +_,7 @@ - if (WorldEntitySpawner.func_209382_a(entityspawnplacementregistry$placementtype, this.field_70170_p, blockpos, entitytype) && EntitySpawnPlacementRegistry.func_223515_a(entitytype, serverworld, SpawnReason.REINFORCEMENT, blockpos, this.field_70170_p.field_73012_v)) { - zombieentity.func_70107_b((double)i1, (double)j1, (double)k1); - if (!this.field_70170_p.func_217358_a((double)i1, (double)j1, (double)k1, 7.0D) && this.field_70170_p.func_226668_i_(zombieentity) && this.field_70170_p.func_226669_j_(zombieentity) && !this.field_70170_p.func_72953_d(zombieentity.func_174813_aQ())) { -+ if (livingentity != null) - zombieentity.func_70624_b(livingentity); - zombieentity.func_213386_a(serverworld, this.field_70170_p.func_175649_E(zombieentity.func_233580_cy_()), SpawnReason.REINFORCEMENT, (ILivingEntityData)null, (CompoundNBT)null); - serverworld.func_242417_l(zombieentity); -@@ -369,7 +_,7 @@ - - public void func_241847_a(ServerWorld p_241847_1_, LivingEntity p_241847_2_) { - super.func_241847_a(p_241847_1_, p_241847_2_); -- if ((p_241847_1_.func_175659_aa() == Difficulty.NORMAL || p_241847_1_.func_175659_aa() == Difficulty.HARD) && p_241847_2_ instanceof VillagerEntity) { -+ if ((p_241847_1_.func_175659_aa() == Difficulty.NORMAL || p_241847_1_.func_175659_aa() == Difficulty.HARD) && p_241847_2_ instanceof VillagerEntity && net.minecraftforge.event.ForgeEventFactory.canLivingConvert(p_241847_2_, EntityType.field_200727_aF, (timer) -> {})) { - if (p_241847_1_.func_175659_aa() != Difficulty.HARD && this.field_70146_Z.nextBoolean()) { - return; - } -@@ -381,6 +_,7 @@ - zombievillagerentity.func_223727_a(villagerentity.func_223722_es().func_234058_a_(NBTDynamicOps.field_210820_a).getValue()); - zombievillagerentity.func_213790_g(villagerentity.func_213706_dY().func_222199_a()); - zombievillagerentity.func_213789_a(villagerentity.func_213708_dV()); -+ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(p_241847_2_, zombievillagerentity); - if (!this.func_174814_R()) { - p_241847_1_.func_217378_a((PlayerEntity)null, 1026, this.func_233580_cy_(), 0); - } -@@ -448,7 +_,7 @@ - } - - public static boolean func_241399_a_(Random p_241399_0_) { -- return p_241399_0_.nextFloat() < 0.05F; -+ return p_241399_0_.nextFloat() < net.minecraftforge.common.ForgeConfig.SERVER.zombieBabyChance.get(); - } - - protected void func_207304_a(float p_207304_1_) { -@@ -468,7 +_,7 @@ - } - - protected void func_230291_eT_() { -- this.func_110148_a(Attributes.field_233829_l_).func_111128_a(this.field_70146_Z.nextDouble() * (double)0.1F); -+ this.func_110148_a(Attributes.field_233829_l_).func_111128_a(this.field_70146_Z.nextDouble() * net.minecraftforge.common.ForgeConfig.SERVER.zombieBaseSummonChance.get()); - } - - public double func_70033_W() { diff --git a/patches/minecraft/net/minecraft/entity/monster/ZombieVillagerEntity.java.patch b/patches/minecraft/net/minecraft/entity/monster/ZombieVillagerEntity.java.patch deleted file mode 100644 index 7d9ba90d3d..0000000000 --- a/patches/minecraft/net/minecraft/entity/monster/ZombieVillagerEntity.java.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/entity/monster/ZombieVillagerEntity.java -+++ b/net/minecraft/entity/monster/ZombieVillagerEntity.java -@@ -116,7 +_,7 @@ - if (!this.field_70170_p.field_72995_K && this.func_70089_S() && this.func_82230_o()) { - int i = this.func_190735_dq(); - this.field_82234_d -= i; -- if (this.field_82234_d <= 0) { -+ if (this.field_82234_d <= 0 && net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, EntityType.field_200756_av, (timer) -> this.field_82234_d = timer)) { - this.func_213791_a((ServerWorld)this.field_70170_p); - } - } -@@ -218,7 +_,7 @@ - if (!this.func_174814_R()) { - p_213791_1_.func_217378_a((PlayerEntity)null, 1027, this.func_233580_cy_(), 0); - } -- -+ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, villagerentity); - } - - private int func_190735_dq() { diff --git a/patches/minecraft/net/minecraft/entity/monster/ZombifiedPiglinEntity.java.patch b/patches/minecraft/net/minecraft/entity/monster/ZombifiedPiglinEntity.java.patch deleted file mode 100644 index 1899b89daf..0000000000 --- a/patches/minecraft/net/minecraft/entity/monster/ZombifiedPiglinEntity.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/entity/monster/ZombifiedPiglinEntity.java -+++ b/net/minecraft/entity/monster/ZombifiedPiglinEntity.java -@@ -173,6 +_,7 @@ - - public void func_70037_a(CompoundNBT p_70037_1_) { - super.func_70037_a(p_70037_1_); -+ if(!field_70170_p.field_72995_K) //FORGE: allow this entity to be read from nbt on client. (Fixes MC-189565) - this.func_241358_a_((ServerWorld)this.field_70170_p, p_70037_1_); - } - diff --git a/patches/minecraft/net/minecraft/entity/monster/piglin/AbstractPiglinEntity.java.patch b/patches/minecraft/net/minecraft/entity/monster/piglin/AbstractPiglinEntity.java.patch deleted file mode 100644 index f62c0641a9..0000000000 --- a/patches/minecraft/net/minecraft/entity/monster/piglin/AbstractPiglinEntity.java.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- a/net/minecraft/entity/monster/piglin/AbstractPiglinEntity.java -+++ b/net/minecraft/entity/monster/piglin/AbstractPiglinEntity.java -@@ -83,7 +_,7 @@ - this.field_242334_c = 0; - } - -- if (this.field_242334_c > 300) { -+ if (this.field_242334_c > 300 && net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, EntityType.field_233592_ba_, (timer) -> this.field_242334_c = timer)) { - this.func_241848_eP(); - this.func_234416_a_((ServerWorld)this.field_70170_p); - } -@@ -98,6 +_,7 @@ - ZombifiedPiglinEntity zombifiedpiglinentity = this.func_233656_b_(EntityType.field_233592_ba_, true); - if (zombifiedpiglinentity != null) { - zombifiedpiglinentity.func_195064_c(new EffectInstance(Effects.field_76431_k, 200, 0)); -+ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, zombifiedpiglinentity); - } - - } diff --git a/patches/minecraft/net/minecraft/entity/monster/piglin/PiglinEntity.java.patch b/patches/minecraft/net/minecraft/entity/monster/piglin/PiglinEntity.java.patch deleted file mode 100644 index 2e2630647f..0000000000 --- a/patches/minecraft/net/minecraft/entity/monster/piglin/PiglinEntity.java.patch +++ /dev/null @@ -1,29 +0,0 @@ ---- a/net/minecraft/entity/monster/piglin/PiglinEntity.java -+++ b/net/minecraft/entity/monster/piglin/PiglinEntity.java -@@ -265,7 +_,7 @@ - } else if (this.func_234433_eX_()) { - return PiglinAction.CROSSBOW_CHARGE; - } else { -- return this.func_213398_dR() && this.func_233631_a_(Items.field_222114_py) ? PiglinAction.CROSSBOW_HOLD : PiglinAction.DEFAULT; -+ return this.func_213398_dR() && this.func_233634_a_(item -> item instanceof net.minecraft.item.CrossbowItem) ? PiglinAction.CROSSBOW_HOLD : PiglinAction.DEFAULT; - } - } - -@@ -307,7 +_,7 @@ - } - - protected void func_234439_n_(ItemStack p_234439_1_) { -- if (p_234439_1_.func_77973_b() == PiglinTasks.field_234444_a_) { -+ if (p_234439_1_.isPiglinCurrency()) { - this.func_184201_a(EquipmentSlotType.OFFHAND, p_234439_1_); - this.func_233663_d_(EquipmentSlotType.OFFHAND); - } else { -@@ -317,7 +_,7 @@ - } - - public boolean func_230293_i_(ItemStack p_230293_1_) { -- return this.field_70170_p.func_82736_K().func_223586_b(GameRules.field_223599_b) && this.func_98052_bS() && PiglinTasks.func_234474_a_(this, p_230293_1_); -+ return net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.field_70170_p, this) && this.func_98052_bS() && PiglinTasks.func_234474_a_(this, p_230293_1_); - } - - protected boolean func_234440_o_(ItemStack p_234440_1_) { diff --git a/patches/minecraft/net/minecraft/entity/monster/piglin/PiglinTasks.java.patch b/patches/minecraft/net/minecraft/entity/monster/piglin/PiglinTasks.java.patch deleted file mode 100644 index 27afcaeb04..0000000000 --- a/patches/minecraft/net/minecraft/entity/monster/piglin/PiglinTasks.java.patch +++ /dev/null @@ -1,47 +0,0 @@ ---- a/net/minecraft/entity/monster/piglin/PiglinTasks.java -+++ b/net/minecraft/entity/monster/piglin/PiglinTasks.java -@@ -232,7 +_,7 @@ - ItemStack itemstack = p_234477_0_.func_184586_b(Hand.OFF_HAND); - p_234477_0_.func_184611_a(Hand.OFF_HAND, ItemStack.field_190927_a); - if (p_234477_0_.func_242337_eM()) { -- boolean flag = func_234492_b_(itemstack.func_77973_b()); -+ boolean flag = itemstack.isPiglinCurrency(); - if (p_234477_1_ && flag) { - func_234475_a_(p_234477_0_, func_234524_k_(p_234477_0_)); - } else if (!flag) { -@@ -318,7 +_,7 @@ - return false; - } else if (func_234453_C_(p_234474_0_) && p_234474_0_.func_213375_cj().func_218191_a(MemoryModuleType.field_234103_o_)) { - return false; -- } else if (func_234492_b_(item)) { -+ } else if (p_234474_1_.isPiglinCurrency()) { - return func_234455_E_(p_234474_0_); - } else { - boolean flag = p_234474_0_.func_234437_l_(p_234474_1_); -@@ -418,7 +_,7 @@ - } - - protected static boolean func_234489_b_(PiglinEntity p_234489_0_, ItemStack p_234489_1_) { -- return !func_234453_C_(p_234489_0_) && !func_234451_A_(p_234489_0_) && p_234489_0_.func_242337_eM() && func_234492_b_(p_234489_1_.func_77973_b()); -+ return !func_234453_C_(p_234489_0_) && !func_234451_A_(p_234489_0_) && p_234489_0_.func_242337_eM() && p_234489_1_.isPiglinCurrency(); - } - - protected static void func_234468_a_(PiglinEntity p_234468_0_, LivingEntity p_234468_1_) { -@@ -519,7 +_,7 @@ - public static boolean func_234460_a_(LivingEntity p_234460_0_) { - for(ItemStack itemstack : p_234460_0_.func_184193_aE()) { - Item item = itemstack.func_77973_b(); -- if (item instanceof ArmorItem && ((ArmorItem)item).func_200880_d() == ArmorMaterial.GOLD) { -+ if (itemstack.makesPiglinsNeutral(p_234460_0_)) { - return true; - } - } -@@ -673,7 +_,7 @@ - } - - private static boolean func_234494_c_(LivingEntity p_234494_0_) { -- return p_234494_0_.func_233631_a_(Items.field_222114_py); -+ return p_234494_0_.func_233634_a_(item -> item instanceof net.minecraft.item.CrossbowItem); - } - - private static void func_234501_d_(LivingEntity p_234501_0_) { diff --git a/patches/minecraft/net/minecraft/entity/monster/piglin/StartAdmiringItemTask.java.patch b/patches/minecraft/net/minecraft/entity/monster/piglin/StartAdmiringItemTask.java.patch deleted file mode 100644 index 851382e656..0000000000 --- a/patches/minecraft/net/minecraft/entity/monster/piglin/StartAdmiringItemTask.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/entity/monster/piglin/StartAdmiringItemTask.java -+++ b/net/minecraft/entity/monster/piglin/StartAdmiringItemTask.java -@@ -13,7 +_,7 @@ - } - - protected boolean func_212832_a_(ServerWorld p_212832_1_, E p_212832_2_) { -- return !p_212832_2_.func_184592_cb().func_190926_b() && p_212832_2_.func_184592_cb().func_77973_b() != Items.field_185159_cQ; -+ return !p_212832_2_.func_184592_cb().func_190926_b() && !p_212832_2_.func_184592_cb().isShield(p_212832_2_); - } - - protected void func_212831_a_(ServerWorld p_212831_1_, E p_212831_2_, long p_212831_3_) { diff --git a/patches/minecraft/net/minecraft/entity/passive/AnimalEntity.java.patch b/patches/minecraft/net/minecraft/entity/passive/AnimalEntity.java.patch deleted file mode 100644 index 0d75d1b8d1..0000000000 --- a/patches/minecraft/net/minecraft/entity/passive/AnimalEntity.java.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/entity/passive/AnimalEntity.java -+++ b/net/minecraft/entity/passive/AnimalEntity.java -@@ -199,6 +_,17 @@ - - public void func_234177_a_(ServerWorld p_234177_1_, AnimalEntity p_234177_2_) { - AgeableEntity ageableentity = this.func_241840_a(p_234177_1_, p_234177_2_); -+ final net.minecraftforge.event.entity.living.BabyEntitySpawnEvent event = new net.minecraftforge.event.entity.living.BabyEntitySpawnEvent(this, p_234177_2_, ageableentity); -+ final boolean cancelled = net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); -+ ageableentity = event.getChild(); -+ if (cancelled) { -+ //Reset the "inLove" state for the animals -+ this.func_70873_a(6000); -+ p_234177_2_.func_70873_a(6000); -+ this.func_70875_t(); -+ p_234177_2_.func_70875_t(); -+ return; -+ } - if (ageableentity != null) { - ServerPlayerEntity serverplayerentity = this.func_191993_do(); - if (serverplayerentity == null && p_234177_2_.func_191993_do() != null) { diff --git a/patches/minecraft/net/minecraft/entity/passive/BeeEntity.java.patch b/patches/minecraft/net/minecraft/entity/passive/BeeEntity.java.patch deleted file mode 100644 index f913410adf..0000000000 --- a/patches/minecraft/net/minecraft/entity/passive/BeeEntity.java.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- a/net/minecraft/entity/passive/BeeEntity.java -+++ b/net/minecraft/entity/passive/BeeEntity.java -@@ -184,6 +_,7 @@ - this.field_226363_bC_ = p_70037_1_.func_74762_e("TicksSincePollination"); - this.field_226364_bD_ = p_70037_1_.func_74762_e("CannotEnterHiveTicks"); - this.field_226365_bE_ = p_70037_1_.func_74762_e("CropsGrownSincePollination"); -+ if(!field_70170_p.field_72995_K) //FORGE: allow this entity to be read from nbt on client. (Fixes MC-189565) - this.func_241358_a_((ServerWorld)this.field_70170_p, p_70037_1_); - } - -@@ -425,7 +_,7 @@ - return false; - } else { - TileEntity tileentity = this.field_70170_p.func_175625_s(this.field_226369_bI_); -- return tileentity != null && tileentity.func_200662_C() == TileEntityType.field_226985_G_; -+ return tileentity instanceof BeehiveTileEntity; - } - } - diff --git a/patches/minecraft/net/minecraft/entity/passive/CatEntity.java.patch b/patches/minecraft/net/minecraft/entity/passive/CatEntity.java.patch deleted file mode 100644 index 1cb7c4b961..0000000000 --- a/patches/minecraft/net/minecraft/entity/passive/CatEntity.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/entity/passive/CatEntity.java -+++ b/net/minecraft/entity/passive/CatEntity.java -@@ -402,7 +_,7 @@ - } - } else if (this.func_70877_b(itemstack)) { - this.func_175505_a(p_230254_1_, itemstack); -- if (this.field_70146_Z.nextInt(3) == 0) { -+ if (this.field_70146_Z.nextInt(3) == 0 && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(this, p_230254_1_)) { - this.func_193101_c(p_230254_1_); - this.func_233687_w_(true); - this.field_70170_p.func_72960_a(this, (byte)7); diff --git a/patches/minecraft/net/minecraft/entity/passive/FoxEntity.java.patch b/patches/minecraft/net/minecraft/entity/passive/FoxEntity.java.patch deleted file mode 100644 index 1863fc14a8..0000000000 --- a/patches/minecraft/net/minecraft/entity/passive/FoxEntity.java.patch +++ /dev/null @@ -1,29 +0,0 @@ ---- a/net/minecraft/entity/passive/FoxEntity.java -+++ b/net/minecraft/entity/passive/FoxEntity.java -@@ -761,7 +_,7 @@ - } - - protected void func_220730_m() { -- if (FoxEntity.this.field_70170_p.func_82736_K().func_223586_b(GameRules.field_223599_b)) { -+ if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(FoxEntity.this.field_70170_p, FoxEntity.this)) { - BlockState blockstate = FoxEntity.this.field_70170_p.func_180495_p(this.field_179494_b); - if (blockstate.func_203425_a(Blocks.field_222434_lW)) { - int i = blockstate.func_177229_b(SweetBerryBushBlock.field_220125_a); -@@ -1001,6 +_,17 @@ - protected void func_75388_i() { - ServerWorld serverworld = (ServerWorld)this.field_75394_a; - FoxEntity foxentity = (FoxEntity)this.field_75390_d.func_241840_a(serverworld, this.field_75391_e); -+ final net.minecraftforge.event.entity.living.BabyEntitySpawnEvent event = new net.minecraftforge.event.entity.living.BabyEntitySpawnEvent(field_75390_d, field_75391_e, foxentity); -+ final boolean cancelled = net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); -+ foxentity = (FoxEntity) event.getChild(); -+ if (cancelled) { -+ //Reset the "inLove" state for the animals -+ this.field_75390_d.func_70873_a(6000); -+ this.field_75391_e.func_70873_a(6000); -+ this.field_75390_d.func_70875_t(); -+ this.field_75391_e.func_70875_t(); -+ return; -+ } - if (foxentity != null) { - ServerPlayerEntity serverplayerentity = this.field_75390_d.func_191993_do(); - ServerPlayerEntity serverplayerentity1 = this.field_75391_e.func_191993_do(); diff --git a/patches/minecraft/net/minecraft/entity/passive/IronGolemEntity.java.patch b/patches/minecraft/net/minecraft/entity/passive/IronGolemEntity.java.patch deleted file mode 100644 index df48a617e8..0000000000 --- a/patches/minecraft/net/minecraft/entity/passive/IronGolemEntity.java.patch +++ /dev/null @@ -1,24 +0,0 @@ ---- a/net/minecraft/entity/passive/IronGolemEntity.java -+++ b/net/minecraft/entity/passive/IronGolemEntity.java -@@ -120,9 +_,10 @@ - int i = MathHelper.func_76128_c(this.func_226277_ct_()); - int j = MathHelper.func_76128_c(this.func_226278_cu_() - (double)0.2F); - int k = MathHelper.func_76128_c(this.func_226281_cx_()); -- BlockState blockstate = this.field_70170_p.func_180495_p(new BlockPos(i, j, k)); -- if (!blockstate.func_196958_f()) { -- this.field_70170_p.func_195594_a(new BlockParticleData(ParticleTypes.field_197611_d, blockstate), this.func_226277_ct_() + ((double)this.field_70146_Z.nextFloat() - 0.5D) * (double)this.func_213311_cf(), this.func_226278_cu_() + 0.1D, this.func_226281_cx_() + ((double)this.field_70146_Z.nextFloat() - 0.5D) * (double)this.func_213311_cf(), 4.0D * ((double)this.field_70146_Z.nextFloat() - 0.5D), 0.5D, ((double)this.field_70146_Z.nextFloat() - 0.5D) * 4.0D); -+ BlockPos pos = new BlockPos(i, j, k); -+ BlockState blockstate = this.field_70170_p.func_180495_p(pos); -+ if (!blockstate.isAir(this.field_70170_p, pos)) { -+ this.field_70170_p.func_195594_a(new BlockParticleData(ParticleTypes.field_197611_d, blockstate).setPos(pos), this.func_226277_ct_() + ((double)this.field_70146_Z.nextFloat() - 0.5D) * (double)this.func_213311_cf(), this.func_226278_cu_() + 0.1D, this.func_226281_cx_() + ((double)this.field_70146_Z.nextFloat() - 0.5D) * (double)this.func_213311_cf(), 4.0D * ((double)this.field_70146_Z.nextFloat() - 0.5D), 0.5D, ((double)this.field_70146_Z.nextFloat() - 0.5D) * 4.0D); - } - } - -@@ -149,6 +_,7 @@ - public void func_70037_a(CompoundNBT p_70037_1_) { - super.func_70037_a(p_70037_1_); - this.func_70849_f(p_70037_1_.func_74767_n("PlayerCreated")); -+ if(!field_70170_p.field_72995_K) //FORGE: allow this entity to be read from nbt on client. (Fixes MC-189565) - this.func_241358_a_((ServerWorld)this.field_70170_p, p_70037_1_); - } - diff --git a/patches/minecraft/net/minecraft/entity/passive/MooshroomEntity.java.patch b/patches/minecraft/net/minecraft/entity/passive/MooshroomEntity.java.patch deleted file mode 100644 index 2b7e0b0663..0000000000 --- a/patches/minecraft/net/minecraft/entity/passive/MooshroomEntity.java.patch +++ /dev/null @@ -1,66 +0,0 @@ ---- a/net/minecraft/entity/passive/MooshroomEntity.java -+++ b/net/minecraft/entity/passive/MooshroomEntity.java -@@ -41,7 +_,7 @@ - import net.minecraftforge.api.distmarker.OnlyIn; - import org.apache.commons.lang3.tuple.Pair; - --public class MooshroomEntity extends CowEntity implements IShearable { -+public class MooshroomEntity extends CowEntity implements IShearable, net.minecraftforge.common.IForgeShearable { - private static final DataParameter field_213449_bz = EntityDataManager.func_187226_a(MooshroomEntity.class, DataSerializers.field_187194_d); - private Effect field_213450_bA; - private int field_213447_bB; -@@ -100,7 +_,7 @@ - - this.func_184185_a(soundevent, 1.0F, 1.0F); - return ActionResultType.func_233537_a_(this.field_70170_p.field_72995_K); -- } else if (itemstack.func_77973_b() == Items.field_151097_aZ && this.func_230262_K__()) { -+ } else if (false && itemstack.func_77973_b() == Items.field_151097_aZ && this.func_230262_K__()) { //Forge: Moved to onSheared - this.func_230263_a_(SoundCategory.PLAYERS); - if (!this.field_70170_p.field_72995_K) { - itemstack.func_222118_a(1, p_230254_1_, (p_213442_1_) -> { -@@ -234,6 +_,45 @@ - - return mooshroomentity$type2; - } -+ -+ @Override -+ public boolean isShearable(@javax.annotation.Nonnull ItemStack item, World world, BlockPos pos) { -+ return func_230262_K__(); -+ } -+ -+ @javax.annotation.Nonnull -+ @Override -+ public java.util.List onSheared(@javax.annotation.Nullable PlayerEntity player, @javax.annotation.Nonnull ItemStack item, World world, BlockPos pos, int fortune) { -+ world.func_217384_a(null, this, SoundEvents.field_187784_dt, player == null ? SoundCategory.BLOCKS : SoundCategory.PLAYERS, 1.0F, 1.0F); -+ if (!world.func_201670_d()) { -+ ((ServerWorld)this.field_70170_p).func_195598_a(ParticleTypes.field_197627_t, this.func_226277_ct_(), this.func_226283_e_(0.5D), this.func_226281_cx_(), 1, 0.0D, 0.0D, 0.0D, 0.0D); -+ this.func_70106_y(); -+ CowEntity cowentity = EntityType.field_200796_j.func_200721_a(this.field_70170_p); -+ cowentity.func_70012_b(this.func_226277_ct_(), this.func_226278_cu_(), this.func_226281_cx_(), this.field_70177_z, this.field_70125_A); -+ cowentity.func_70606_j(this.func_110143_aJ()); -+ cowentity.field_70761_aq = this.field_70761_aq; -+ if (this.func_145818_k_()) { -+ cowentity.func_200203_b(this.func_200201_e()); -+ cowentity.func_174805_g(this.func_174833_aM()); -+ } -+ -+ if (this.func_104002_bU()) { -+ cowentity.func_110163_bv(); -+ } -+ -+ cowentity.func_184224_h(this.func_190530_aW()); -+ this.field_70170_p.func_217376_c(cowentity); -+ -+ java.util.List items = new java.util.ArrayList<>(); -+ for (int i = 0; i < 5; ++i) { -+ items.add(new ItemStack(this.func_213444_dV().field_221099_d.func_177230_c())); -+ } -+ -+ return items; -+ } -+ return java.util.Collections.emptyList(); -+ } -+ - - public static enum Type { - RED("red", Blocks.field_150337_Q.func_176223_P()), diff --git a/patches/minecraft/net/minecraft/entity/passive/OcelotEntity.java.patch b/patches/minecraft/net/minecraft/entity/passive/OcelotEntity.java.patch deleted file mode 100644 index 92325163ae..0000000000 --- a/patches/minecraft/net/minecraft/entity/passive/OcelotEntity.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/entity/passive/OcelotEntity.java -+++ b/net/minecraft/entity/passive/OcelotEntity.java -@@ -163,7 +_,7 @@ - if ((this.field_70914_e == null || this.field_70914_e.func_75277_f()) && !this.func_213530_dX() && this.func_70877_b(itemstack) && p_230254_1_.func_70068_e(this) < 9.0D) { - this.func_175505_a(p_230254_1_, itemstack); - if (!this.field_70170_p.field_72995_K) { -- if (this.field_70146_Z.nextInt(3) == 0) { -+ if (this.field_70146_Z.nextInt(3) == 0 && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(this, p_230254_1_)) { - this.func_213528_r(true); - this.func_213527_s(true); - this.field_70170_p.func_72960_a(this, (byte)41); diff --git a/patches/minecraft/net/minecraft/entity/passive/ParrotEntity.java.patch b/patches/minecraft/net/minecraft/entity/passive/ParrotEntity.java.patch deleted file mode 100644 index b3d906b96a..0000000000 --- a/patches/minecraft/net/minecraft/entity/passive/ParrotEntity.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/entity/passive/ParrotEntity.java -+++ b/net/minecraft/entity/passive/ParrotEntity.java -@@ -237,7 +_,7 @@ - } - - if (!this.field_70170_p.field_72995_K) { -- if (this.field_70146_Z.nextInt(10) == 0) { -+ if (this.field_70146_Z.nextInt(10) == 0 && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(this, p_230254_1_)) { - this.func_193101_c(p_230254_1_); - this.field_70170_p.func_72960_a(this, (byte)7); - } else { diff --git a/patches/minecraft/net/minecraft/entity/passive/PigEntity.java.patch b/patches/minecraft/net/minecraft/entity/passive/PigEntity.java.patch deleted file mode 100644 index 67b028fc3a..0000000000 --- a/patches/minecraft/net/minecraft/entity/passive/PigEntity.java.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- a/net/minecraft/entity/passive/PigEntity.java -+++ b/net/minecraft/entity/passive/PigEntity.java -@@ -203,7 +_,7 @@ - } - - public void func_241841_a(ServerWorld p_241841_1_, LightningBoltEntity p_241841_2_) { -- if (p_241841_1_.func_175659_aa() != Difficulty.PEACEFUL) { -+ if (p_241841_1_.func_175659_aa() != Difficulty.PEACEFUL && net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, EntityType.field_233592_ba_, (timer) -> {})) { - ZombifiedPiglinEntity zombifiedpiglinentity = EntityType.field_233592_ba_.func_200721_a(p_241841_1_); - zombifiedpiglinentity.func_184201_a(EquipmentSlotType.MAINHAND, new ItemStack(Items.field_151010_B)); - zombifiedpiglinentity.func_70012_b(this.func_226277_ct_(), this.func_226278_cu_(), this.func_226281_cx_(), this.field_70177_z, this.field_70125_A); -@@ -215,6 +_,7 @@ - } - - zombifiedpiglinentity.func_110163_bv(); -+ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, zombifiedpiglinentity); - p_241841_1_.func_217376_c(zombifiedpiglinentity); - this.func_70106_y(); - } else { diff --git a/patches/minecraft/net/minecraft/entity/passive/PolarBearEntity.java.patch b/patches/minecraft/net/minecraft/entity/passive/PolarBearEntity.java.patch deleted file mode 100644 index 22a283dd86..0000000000 --- a/patches/minecraft/net/minecraft/entity/passive/PolarBearEntity.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/entity/passive/PolarBearEntity.java -+++ b/net/minecraft/entity/passive/PolarBearEntity.java -@@ -103,6 +_,7 @@ - - public void func_70037_a(CompoundNBT p_70037_1_) { - super.func_70037_a(p_70037_1_); -+ if(!field_70170_p.field_72995_K) //FORGE: allow this entity to be read from nbt on client. (Fixes MC-189565) - this.func_241358_a_((ServerWorld)this.field_70170_p, p_70037_1_); - } - diff --git a/patches/minecraft/net/minecraft/entity/passive/RabbitEntity.java.patch b/patches/minecraft/net/minecraft/entity/passive/RabbitEntity.java.patch deleted file mode 100644 index 940026f84a..0000000000 --- a/patches/minecraft/net/minecraft/entity/passive/RabbitEntity.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/entity/passive/RabbitEntity.java -+++ b/net/minecraft/entity/passive/RabbitEntity.java -@@ -500,7 +_,7 @@ - - public boolean func_75250_a() { - if (this.field_179496_a <= 0) { -- if (!this.field_179500_c.field_70170_p.func_82736_K().func_223586_b(GameRules.field_223599_b)) { -+ if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.field_179500_c.field_70170_p, this.field_179500_c)) { - return false; - } - diff --git a/patches/minecraft/net/minecraft/entity/passive/SheepEntity.java.patch b/patches/minecraft/net/minecraft/entity/passive/SheepEntity.java.patch deleted file mode 100644 index ad28093068..0000000000 --- a/patches/minecraft/net/minecraft/entity/passive/SheepEntity.java.patch +++ /dev/null @@ -1,48 +0,0 @@ ---- a/net/minecraft/entity/passive/SheepEntity.java -+++ b/net/minecraft/entity/passive/SheepEntity.java -@@ -61,7 +_,7 @@ - import net.minecraftforge.api.distmarker.Dist; - import net.minecraftforge.api.distmarker.OnlyIn; - --public class SheepEntity extends AnimalEntity implements IShearable { -+public class SheepEntity extends AnimalEntity implements IShearable, net.minecraftforge.common.IForgeShearable { - private static final DataParameter field_184774_bv = EntityDataManager.func_187226_a(SheepEntity.class, DataSerializers.field_187191_a); - private static final Map field_200206_bz = Util.func_200696_a(Maps.newEnumMap(DyeColor.class), (p_203402_0_) -> { - p_203402_0_.put(DyeColor.WHITE, Blocks.field_196556_aL); -@@ -216,7 +_,7 @@ - - public ActionResultType func_230254_b_(PlayerEntity p_230254_1_, Hand p_230254_2_) { - ItemStack itemstack = p_230254_1_.func_184586_b(p_230254_2_); -- if (itemstack.func_77973_b() == Items.field_151097_aZ) { -+ if (false && itemstack.func_77973_b() == Items.field_151097_aZ) { //Forge: Moved to onSheared - if (!this.field_70170_p.field_72995_K && this.func_230262_K__()) { - this.func_230263_a_(SoundCategory.PLAYERS); - itemstack.func_222118_a(1, p_230254_1_, (p_213613_1_) -> { -@@ -360,5 +_,27 @@ - - protected float func_213348_b(Pose p_213348_1_, EntitySize p_213348_2_) { - return 0.95F * p_213348_2_.field_220316_b; -+ } -+ -+ @Override -+ public boolean isShearable(@javax.annotation.Nonnull ItemStack item, World world, BlockPos pos) { -+ return func_230262_K__(); -+ } -+ -+ @javax.annotation.Nonnull -+ @Override -+ public java.util.List onSheared(@Nullable PlayerEntity player, @javax.annotation.Nonnull ItemStack item, World world, BlockPos pos, int fortune) { -+ world.func_217384_a(null, this, SoundEvents.field_187763_eJ, player == null ? SoundCategory.BLOCKS : SoundCategory.PLAYERS, 1.0F, 1.0F); -+ if (!world.field_72995_K) { -+ this.func_70893_e(true); -+ int i = 1 + this.field_70146_Z.nextInt(3); -+ -+ java.util.List items = new java.util.ArrayList<>(); -+ for (int j = 0; j < i; ++j) { -+ items.add(new ItemStack(field_200206_bz.get(this.func_175509_cj()))); -+ } -+ return items; -+ } -+ return java.util.Collections.emptyList(); - } - } diff --git a/patches/minecraft/net/minecraft/entity/passive/SnowGolemEntity.java.patch b/patches/minecraft/net/minecraft/entity/passive/SnowGolemEntity.java.patch deleted file mode 100644 index 29d6ae7e77..0000000000 --- a/patches/minecraft/net/minecraft/entity/passive/SnowGolemEntity.java.patch +++ /dev/null @@ -1,60 +0,0 @@ ---- a/net/minecraft/entity/passive/SnowGolemEntity.java -+++ b/net/minecraft/entity/passive/SnowGolemEntity.java -@@ -40,7 +_,7 @@ - import net.minecraftforge.api.distmarker.Dist; - import net.minecraftforge.api.distmarker.OnlyIn; - --public class SnowGolemEntity extends GolemEntity implements IShearable, IRangedAttackMob { -+public class SnowGolemEntity extends GolemEntity implements IShearable, IRangedAttackMob, net.minecraftforge.common.IForgeShearable { - private static final DataParameter field_184749_a = EntityDataManager.func_187226_a(SnowGolemEntity.class, DataSerializers.field_187191_a); - - public SnowGolemEntity(EntityType p_i50244_1_, World p_i50244_2_) { -@@ -93,7 +_,7 @@ - this.func_70097_a(DamageSource.field_76370_b, 1.0F); - } - -- if (!this.field_70170_p.func_82736_K().func_223586_b(GameRules.field_223599_b)) { -+ if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.field_70170_p, this)) { - return; - } - -@@ -104,7 +_,7 @@ - j = MathHelper.func_76128_c(this.func_226278_cu_()); - k = MathHelper.func_76128_c(this.func_226281_cx_() + (double)((float)(l / 2 % 2 * 2 - 1) * 0.25F)); - BlockPos blockpos = new BlockPos(i, j, k); -- if (this.field_70170_p.func_180495_p(blockpos).func_196958_f() && this.field_70170_p.func_226691_t_(blockpos).func_225486_c(blockpos) < 0.8F && blockstate.func_196955_c(this.field_70170_p, blockpos)) { -+ if (this.field_70170_p.func_175623_d(blockpos) && this.field_70170_p.func_226691_t_(blockpos).func_225486_c(blockpos) < 0.8F && blockstate.func_196955_c(this.field_70170_p, blockpos)) { - this.field_70170_p.func_175656_a(blockpos, blockstate); - } - } -@@ -130,7 +_,7 @@ - - protected ActionResultType func_230254_b_(PlayerEntity p_230254_1_, Hand p_230254_2_) { - ItemStack itemstack = p_230254_1_.func_184586_b(p_230254_2_); -- if (itemstack.func_77973_b() == Items.field_151097_aZ && this.func_230262_K__()) { -+ if (false && itemstack.func_77973_b() == Items.field_151097_aZ && this.func_230262_K__()) { //Forge: Moved to onSheared - this.func_230263_a_(SoundCategory.PLAYERS); - if (!this.field_70170_p.field_72995_K) { - itemstack.func_222118_a(1, p_230254_1_, (p_213622_1_) -> { -@@ -189,5 +_,21 @@ - @OnlyIn(Dist.CLIENT) - public Vector3d func_241205_ce_() { - return new Vector3d(0.0D, (double)(0.75F * this.func_70047_e()), (double)(this.func_213311_cf() * 0.4F)); -+ } -+ -+ @Override -+ public boolean isShearable(@javax.annotation.Nonnull ItemStack item, World world, BlockPos pos) { -+ return func_230262_K__(); -+ } -+ -+ @javax.annotation.Nonnull -+ @Override -+ public java.util.List onSheared(@Nullable PlayerEntity player, @javax.annotation.Nonnull ItemStack item, World world, BlockPos pos, int fortune) { -+ world.func_217384_a(null, this, SoundEvents.field_232843_op_, player == null ? SoundCategory.BLOCKS : SoundCategory.PLAYERS, 1.0F, 1.0F); -+ if (!world.func_201670_d()) { -+ func_184747_a(false); -+ return java.util.Collections.singletonList(new ItemStack(Items.field_221689_cG)); -+ } -+ return java.util.Collections.emptyList(); - } - } diff --git a/patches/minecraft/net/minecraft/entity/passive/WolfEntity.java.patch b/patches/minecraft/net/minecraft/entity/passive/WolfEntity.java.patch deleted file mode 100644 index 8ed2119483..0000000000 --- a/patches/minecraft/net/minecraft/entity/passive/WolfEntity.java.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- a/net/minecraft/entity/passive/WolfEntity.java -+++ b/net/minecraft/entity/passive/WolfEntity.java -@@ -133,6 +_,7 @@ - this.func_175547_a(DyeColor.func_196056_a(p_70037_1_.func_74762_e("CollarColor"))); - } - -+ if(!field_70170_p.field_72995_K) //FORGE: allow this entity to be read from nbt on client. (Fixes MC-189565) - this.func_241358_a_((ServerWorld)this.field_70170_p, p_70037_1_); - } - -@@ -347,7 +_,7 @@ - itemstack.func_190918_g(1); - } - -- if (this.field_70146_Z.nextInt(3) == 0) { -+ if (this.field_70146_Z.nextInt(3) == 0 && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(this, p_230254_1_)) { - this.func_193101_c(p_230254_1_); - this.field_70699_by.func_75499_g(); - this.func_70624_b((LivingEntity)null); diff --git a/patches/minecraft/net/minecraft/entity/passive/horse/AbstractHorseEntity.java.patch b/patches/minecraft/net/minecraft/entity/passive/horse/AbstractHorseEntity.java.patch deleted file mode 100644 index 3abd48c5de..0000000000 --- a/patches/minecraft/net/minecraft/entity/passive/horse/AbstractHorseEntity.java.patch +++ /dev/null @@ -1,55 +0,0 @@ ---- a/net/minecraft/entity/passive/horse/AbstractHorseEntity.java -+++ b/net/minecraft/entity/passive/horse/AbstractHorseEntity.java -@@ -276,6 +_,7 @@ - - this.field_110296_bG.func_110134_a(this); - this.func_230275_fc_(); -+ this.itemHandler = net.minecraftforge.common.util.LazyOptional.of(() -> new net.minecraftforge.items.wrapper.InvWrapper(this.field_110296_bG)); - } - - protected void func_230275_fc_() { -@@ -334,9 +_,9 @@ - protected void func_180429_a(BlockPos p_180429_1_, BlockState p_180429_2_) { - if (!p_180429_2_.func_185904_a().func_76224_d()) { - BlockState blockstate = this.field_70170_p.func_180495_p(p_180429_1_.func_177984_a()); -- SoundType soundtype = p_180429_2_.func_215695_r(); -+ SoundType soundtype = p_180429_2_.getSoundType(field_70170_p, p_180429_1_, this); - if (blockstate.func_203425_a(Blocks.field_150433_aE)) { -- soundtype = blockstate.func_215695_r(); -+ soundtype = blockstate.getSoundType(field_70170_p, p_180429_1_, this); - } - - if (this.func_184207_aI() && this.field_190688_bE) { -@@ -694,6 +_,7 @@ - this.func_213293_j(vector3d.field_72450_a, d1, vector3d.field_72449_c); - this.func_110255_k(true); - this.field_70160_al = true; -+ net.minecraftforge.common.ForgeHooks.onLivingJump(this); - if (f1 > 0.0F) { - float f2 = MathHelper.func_76126_a(this.field_70177_z * ((float)Math.PI / 180F)); - float f3 = MathHelper.func_76134_b(this.field_70177_z * ((float)Math.PI / 180F)); -@@ -1009,5 +_,24 @@ - - this.func_230273_eI_(); - return super.func_213386_a(p_213386_1_, p_213386_2_, p_213386_3_, p_213386_4_, p_213386_5_); -+ } -+ -+ private net.minecraftforge.common.util.LazyOptional itemHandler = null; -+ -+ @Override -+ public net.minecraftforge.common.util.LazyOptional getCapability(net.minecraftforge.common.capabilities.Capability capability, @Nullable net.minecraft.util.Direction facing) { -+ if (this.func_70089_S() && capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY && itemHandler != null) -+ return itemHandler.cast(); -+ return super.getCapability(capability, facing); -+ } -+ -+ @Override -+ protected void invalidateCaps() { -+ super.invalidateCaps(); -+ if (itemHandler != null) { -+ net.minecraftforge.common.util.LazyOptional oldHandler = itemHandler; -+ itemHandler = null; -+ oldHandler.invalidate(); -+ } - } - } diff --git a/patches/minecraft/net/minecraft/entity/passive/horse/HorseEntity.java.patch b/patches/minecraft/net/minecraft/entity/passive/horse/HorseEntity.java.patch deleted file mode 100644 index 13849e8b68..0000000000 --- a/patches/minecraft/net/minecraft/entity/passive/horse/HorseEntity.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/entity/passive/horse/HorseEntity.java -+++ b/net/minecraft/entity/passive/horse/HorseEntity.java -@@ -139,6 +_,8 @@ - this.func_184185_a(SoundEvents.field_187705_cn, p_190680_1_.func_185843_a() * 0.6F, p_190680_1_.func_185847_b()); - } - -+ ItemStack stack = this.field_110296_bG.func_70301_a(1); -+ if (func_190682_f(stack)) stack.onHorseArmorTick(field_70170_p, this); - } - - protected SoundEvent func_184639_G() { diff --git a/patches/minecraft/net/minecraft/entity/player/PlayerEntity.java.patch b/patches/minecraft/net/minecraft/entity/player/PlayerEntity.java.patch deleted file mode 100644 index 27a4e6f0ce..0000000000 --- a/patches/minecraft/net/minecraft/entity/player/PlayerEntity.java.patch +++ /dev/null @@ -1,412 +0,0 @@ ---- a/net/minecraft/entity/player/PlayerEntity.java -+++ b/net/minecraft/entity/player/PlayerEntity.java -@@ -110,6 +_,7 @@ - import net.minecraftforge.api.distmarker.OnlyIn; - - public abstract class PlayerEntity extends LivingEntity { -+ public static final String PERSISTED_NBT_TAG = "PlayerPersisted"; - public static final EntitySize field_213835_bs = EntitySize.func_220314_b(0.6F, 1.8F); - private static final Map field_213836_b = ImmutableMap.builder().put(Pose.STANDING, field_213835_bs).put(Pose.SLEEPING, field_213377_as).put(Pose.FALL_FLYING, EntitySize.func_220314_b(0.6F, 0.6F)).put(Pose.SWIMMING, EntitySize.func_220314_b(0.6F, 0.6F)).put(Pose.SPIN_ATTACK, EntitySize.func_220314_b(0.6F, 0.6F)).put(Pose.CROUCHING, EntitySize.func_220314_b(0.6F, 1.5F)).put(Pose.DYING, EntitySize.func_220311_c(0.2F, 0.2F)).build(); - private static final DataParameter field_184829_a = EntityDataManager.func_187226_a(PlayerEntity.class, DataSerializers.field_187193_c); -@@ -150,6 +_,9 @@ - private final CooldownTracker field_184832_bU = this.func_184815_l(); - @Nullable - public FishingBobberEntity field_71104_cf; -+ private final java.util.Collection prefixes = new java.util.LinkedList<>(); -+ private final java.util.Collection suffixes = new java.util.LinkedList<>(); -+ @Nullable private Pose forcedPose; - - public PlayerEntity(World p_i241920_1_, BlockPos p_i241920_2_, float p_i241920_3_, GameProfile p_i241920_4_) { - super(EntityType.field_200729_aH, p_i241920_1_); -@@ -175,7 +_,7 @@ - } - - public static AttributeModifierMap.MutableAttribute func_234570_el_() { -- return LivingEntity.func_233639_cI_().func_233815_a_(Attributes.field_233823_f_, 1.0D).func_233815_a_(Attributes.field_233821_d_, (double)0.1F).func_233814_a_(Attributes.field_233825_h_).func_233814_a_(Attributes.field_233828_k_); -+ return LivingEntity.func_233639_cI_().func_233815_a_(Attributes.field_233823_f_, 1.0D).func_233815_a_(Attributes.field_233821_d_, (double)0.1F).func_233814_a_(Attributes.field_233825_h_).func_233814_a_(Attributes.field_233828_k_).func_233814_a_(net.minecraftforge.common.ForgeMod.REACH_DISTANCE.get()).func_233814_a_(Attributes.field_233824_g_); - } - - protected void func_70088_a() { -@@ -189,6 +_,7 @@ - } - - public void func_70071_h_() { -+ net.minecraftforge.fml.hooks.BasicEventHooks.onPlayerPreTick(this); - this.field_70145_X = this.func_175149_v(); - if (this.func_175149_v()) { - this.field_70122_E = false; -@@ -204,7 +_,7 @@ - this.field_71076_b = 100; - } - -- if (!this.field_70170_p.field_72995_K && this.field_70170_p.func_72935_r()) { -+ if (!this.field_70170_p.field_72995_K && !net.minecraftforge.event.ForgeEventFactory.fireSleepingTimeCheck(this, func_213374_dv())) { - this.func_225652_a_(false, true); - } - } else if (this.field_71076_b > 0) { -@@ -258,6 +_,7 @@ - this.func_203041_m(); - this.field_184832_bU.func_185144_a(); - this.func_213832_dB(); -+ net.minecraftforge.fml.hooks.BasicEventHooks.onPlayerPostTick(this); - } - - public boolean func_226563_dT_() { -@@ -333,6 +_,10 @@ - } - - protected void func_213832_dB() { -+ if(forcedPose != null) { -+ this.func_213301_b(forcedPose); -+ return; -+ } - if (this.func_213298_c(Pose.SWIMMING)) { - Pose pose; - if (this.func_184613_cA()) { -@@ -550,6 +_,7 @@ - } - - public void func_70645_a(DamageSource p_70645_1_) { -+ if (net.minecraftforge.common.ForgeHooks.onLivingDeath(this, p_70645_1_)) return; - super.func_70645_a(p_70645_1_); - this.func_226264_Z_(); - if (!this.func_175149_v()) { -@@ -603,12 +_,14 @@ - } - - public boolean func_225609_n_(boolean p_225609_1_) { -- return this.func_146097_a(this.field_71071_by.func_70298_a(this.field_71071_by.field_70461_c, p_225609_1_ && !this.field_71071_by.func_70448_g().func_190926_b() ? this.field_71071_by.func_70448_g().func_190916_E() : 1), false, true) != null; -+ ItemStack stack = field_71071_by.func_70448_g(); -+ if (stack.func_190926_b() || !stack.onDroppedByPlayer(this)) return false; -+ return net.minecraftforge.common.ForgeHooks.onPlayerTossEvent(this, this.field_71071_by.func_70298_a(this.field_71071_by.field_70461_c, p_225609_1_ && !this.field_71071_by.func_70448_g().func_190926_b() ? this.field_71071_by.func_70448_g().func_190916_E() : 1), true) != null; - } - - @Nullable - public ItemEntity func_71019_a(ItemStack p_71019_1_, boolean p_71019_2_) { -- return this.func_146097_a(p_71019_1_, false, p_71019_2_); -+ return net.minecraftforge.common.ForgeHooks.onPlayerTossEvent(this, p_71019_1_, false); - } - - @Nullable -@@ -646,7 +_,12 @@ - } - } - -+ @Deprecated //Use location sensitive version below - public float func_184813_a(BlockState p_184813_1_) { -+ return getDigSpeed(p_184813_1_, null); -+ } -+ -+ public float getDigSpeed(BlockState p_184813_1_, @Nullable BlockPos pos) { - float f = this.field_71071_by.func_184438_a(p_184813_1_); - if (f > 1.0F) { - int i = EnchantmentHelper.func_185293_e(this); -@@ -688,11 +_,12 @@ - f /= 5.0F; - } - -+ f = net.minecraftforge.event.ForgeEventFactory.getBreakSpeed(this, p_184813_1_, f, pos); - return f; - } - - public boolean func_234569_d_(BlockState p_234569_1_) { -- return !p_234569_1_.func_235783_q_() || this.field_71071_by.func_70448_g().func_150998_b(p_234569_1_); -+ return net.minecraftforge.event.ForgeEventFactory.doPlayerHarvestCheck(this, p_234569_1_, !p_234569_1_.func_235783_q_() || this.field_71071_by.func_70448_g().func_150998_b(p_234569_1_)); - } - - public void func_70037_a(CompoundNBT p_70037_1_) { -@@ -767,6 +_,7 @@ - } - - public boolean func_70097_a(DamageSource p_70097_1_, float p_70097_2_) { -+ if (!net.minecraftforge.common.ForgeHooks.onPlayerAttack(this, p_70097_1_, p_70097_2_)) return false; - if (this.func_180431_b(p_70097_1_)) { - return false; - } else if (this.field_71075_bZ.field_75102_a && !p_70097_1_.func_76357_e()) { -@@ -798,7 +_,7 @@ - - protected void func_190629_c(LivingEntity p_190629_1_) { - super.func_190629_c(p_190629_1_); -- if (p_190629_1_.func_184614_ca().func_77973_b() instanceof AxeItem) { -+ if (p_190629_1_.func_184614_ca().canDisableShield(this.field_184627_bm, this, p_190629_1_)) { - this.func_190777_m(true); - } - -@@ -819,7 +_,7 @@ - } - - protected void func_184590_k(float p_184590_1_) { -- if (this.field_184627_bm.func_77973_b() == Items.field_185159_cQ) { -+ if (this.field_184627_bm.isShield(this)) { - if (!this.field_70170_p.field_72995_K) { - this.func_71029_a(Stats.field_75929_E.func_199076_b(this.field_184627_bm.func_77973_b())); - } -@@ -829,6 +_,7 @@ - Hand hand = this.func_184600_cs(); - this.field_184627_bm.func_222118_a(i, this, (p_213833_1_) -> { - p_213833_1_.func_213334_d(hand); -+ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this, this.field_184627_bm, hand); - }); - if (this.field_184627_bm.func_190926_b()) { - if (hand == Hand.MAIN_HAND) { -@@ -847,10 +_,13 @@ - - protected void func_70665_d(DamageSource p_70665_1_, float p_70665_2_) { - if (!this.func_180431_b(p_70665_1_)) { -+ p_70665_2_ = net.minecraftforge.common.ForgeHooks.onLivingHurt(this, p_70665_1_, p_70665_2_); -+ if (p_70665_2_ <= 0) return; - p_70665_2_ = this.func_70655_b(p_70665_1_, p_70665_2_); - p_70665_2_ = this.func_70672_c(p_70665_1_, p_70665_2_); - float f2 = Math.max(p_70665_2_ - this.func_110139_bj(), 0.0F); - this.func_110149_m(this.func_110139_bj() - (p_70665_2_ - f2)); -+ f2 = net.minecraftforge.common.ForgeHooks.onLivingDamage(this, p_70665_1_, f2); - float f = p_70665_2_ - f2; - if (f > 0.0F && f < 3.4028235E37F) { - this.func_195067_a(Stats.field_212738_J, Math.round(f * 10.0F)); -@@ -859,8 +_,8 @@ - if (f2 != 0.0F) { - this.func_71020_j(p_70665_1_.func_76345_d()); - float f1 = this.func_110143_aJ(); -- this.func_70606_j(this.func_110143_aJ() - f2); - this.func_110142_aN().func_94547_a(p_70665_1_, f1, f2); -+ this.func_70606_j(f1 - f2); // Forge: moved to fix MC-121048 - if (f2 < 3.4028235E37F) { - this.func_195067_a(Stats.field_188112_z, Math.round(f2 * 10.0F)); - } -@@ -909,6 +_,8 @@ - - return ActionResultType.PASS; - } else { -+ ActionResultType cancelResult = net.minecraftforge.common.ForgeHooks.onInteractEntity(this, p_190775_1_, p_190775_2_); -+ if (cancelResult != null) return cancelResult; - ItemStack itemstack = this.func_184586_b(p_190775_2_); - ItemStack itemstack1 = itemstack.func_77946_l(); - ActionResultType actionresulttype = p_190775_1_.func_184230_a(this, p_190775_2_); -@@ -917,6 +_,9 @@ - itemstack.func_190920_e(itemstack1.func_190916_E()); - } - -+ if (!this.field_71075_bZ.field_75098_d && itemstack.func_190926_b()) { -+ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this, itemstack1, p_190775_2_); -+ } - return actionresulttype; - } else { - if (!itemstack.func_190926_b() && p_190775_1_ instanceof LivingEntity) { -@@ -927,6 +_,7 @@ - ActionResultType actionresulttype1 = itemstack.func_111282_a_(this, (LivingEntity)p_190775_1_, p_190775_2_); - if (actionresulttype1.func_226246_a_()) { - if (itemstack.func_190926_b() && !this.field_71075_bZ.field_75098_d) { -+ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this, itemstack1, p_190775_2_); - this.func_184611_a(p_190775_2_, ItemStack.field_190927_a); - } - -@@ -1011,6 +_,7 @@ - } - - public void func_71059_n(Entity p_71059_1_) { -+ if (!net.minecraftforge.common.ForgeHooks.onPlayerAttackTarget(this, p_71059_1_)) return; - if (p_71059_1_.func_70075_an()) { - if (!p_71059_1_.func_85031_j(this)) { - float f = (float)this.func_233637_b_(Attributes.field_233823_f_); -@@ -1028,7 +_,7 @@ - if (f > 0.0F || f1 > 0.0F) { - boolean flag = f2 > 0.9F; - boolean flag1 = false; -- int i = 0; -+ float i = (float)this.func_233637_b_(Attributes.field_233824_g_); // Forge: Initialize this value to the attack knockback attribute of the player, which is by default 0 - i = i + EnchantmentHelper.func_77501_a(this); - if (this.func_70051_ag() && flag) { - this.field_70170_p.func_184148_a((PlayerEntity)null, this.func_226277_ct_(), this.func_226278_cu_(), this.func_226281_cx_(), SoundEvents.field_187721_dT, this.func_184176_by(), 1.0F, 1.0F); -@@ -1038,8 +_,10 @@ - - boolean flag2 = flag && this.field_70143_R > 0.0F && !this.field_70122_E && !this.func_70617_f_() && !this.func_70090_H() && !this.func_70644_a(Effects.field_76440_q) && !this.func_184218_aH() && p_71059_1_ instanceof LivingEntity; - flag2 = flag2 && !this.func_70051_ag(); -+ net.minecraftforge.event.entity.player.CriticalHitEvent hitResult = net.minecraftforge.common.ForgeHooks.getCriticalHit(this, p_71059_1_, flag2, flag2 ? 1.5F : 1.0F); -+ flag2 = hitResult != null; - if (flag2) { -- f *= 1.5F; -+ f *= hitResult.getDamageModifier(); - } - - f = f + f1; -@@ -1122,13 +_,15 @@ - EnchantmentHelper.func_151385_b(this, p_71059_1_); - ItemStack itemstack1 = this.func_184614_ca(); - Entity entity = p_71059_1_; -- if (p_71059_1_ instanceof EnderDragonPartEntity) { -- entity = ((EnderDragonPartEntity)p_71059_1_).field_213852_b; -+ if (p_71059_1_ instanceof net.minecraftforge.entity.PartEntity) { -+ entity = ((net.minecraftforge.entity.PartEntity) p_71059_1_).getParent(); - } - - if (!this.field_70170_p.field_72995_K && !itemstack1.func_190926_b() && entity instanceof LivingEntity) { -+ ItemStack copy = itemstack1.func_77946_l(); - itemstack1.func_77961_a((LivingEntity)entity, this); - if (itemstack1.func_190926_b()) { -+ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this, copy, Hand.MAIN_HAND); - this.func_184611_a(Hand.MAIN_HAND, ItemStack.field_190927_a); - } - } -@@ -1170,7 +_,7 @@ - } - - if (this.field_70146_Z.nextFloat() < f) { -- this.func_184811_cZ().func_185145_a(Items.field_185159_cQ, 100); -+ this.func_184811_cZ().func_185145_a(this.func_184607_cu().func_77973_b(), 100); - this.func_184602_cy(); - this.field_70170_p.func_72960_a(this, (byte)30); - } -@@ -1196,8 +_,9 @@ - public void func_71004_bE() { - } - -- public void func_70106_y() { -- super.func_70106_y(); -+ @Override -+ public void remove(boolean keepData) { -+ super.remove(keepData); - this.field_71069_bz.func_75134_a(this); - if (this.field_71070_bA != null) { - this.field_71070_bA.func_75134_a(this); -@@ -1220,6 +_,7 @@ - } - - public void func_225652_a_(boolean p_225652_1_, boolean p_225652_2_) { -+ net.minecraftforge.event.ForgeEventFactory.onPlayerWakeup(this, p_225652_1_, p_225652_2_); - super.func_213366_dy(); - if (this.field_70170_p instanceof ServerWorld && p_225652_2_) { - ((ServerWorld)this.field_70170_p).func_72854_c(); -@@ -1245,7 +_,7 @@ - } else if (block instanceof BedBlock && BedBlock.func_235330_a_(p_242374_0_)) { - return BedBlock.func_242652_a(EntityType.field_200729_aH, p_242374_0_, p_242374_1_, p_242374_2_); - } else if (!p_242374_3_) { -- return Optional.empty(); -+ return blockstate.getRespawnPosition(EntityType.field_200729_aH, p_242374_0_, p_242374_1_, p_242374_2_, null); - } else { - boolean flag = block.func_181623_g(); - boolean flag1 = p_242374_0_.func_180495_p(p_242374_1_.func_177984_a()).func_177230_c().func_181623_g(); -@@ -1425,6 +_,7 @@ - - public boolean func_225503_b_(float p_225503_1_, float p_225503_2_) { - if (this.field_71075_bZ.field_75101_c) { -+ net.minecraftforge.event.ForgeEventFactory.onPlayerFall(this, p_225503_1_, p_225503_2_); - return false; - } else { - if (p_225503_1_ >= 2.0F) { -@@ -1438,7 +_,7 @@ - public boolean func_226566_ei_() { - if (!this.field_70122_E && !this.func_184613_cA() && !this.func_70090_H() && !this.func_70644_a(Effects.field_188424_y)) { - ItemStack itemstack = this.func_184582_a(EquipmentSlotType.CHEST); -- if (itemstack.func_77973_b() == Items.field_185160_cR && ElytraItem.func_185069_d(itemstack)) { -+ if (itemstack.canElytraFly(this)) { - this.func_226567_ej_(); - return true; - } -@@ -1479,6 +_,10 @@ - } - - public void func_195068_e(int p_195068_1_) { -+ net.minecraftforge.event.entity.player.PlayerXpEvent.XpChange event = new net.minecraftforge.event.entity.player.PlayerXpEvent.XpChange(this, p_195068_1_); -+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) return; -+ p_195068_1_ = event.getAmount(); -+ - this.func_85039_t(p_195068_1_); - this.field_71106_cc += (float)p_195068_1_ / (float)this.func_71050_bK(); - this.field_71067_cb = MathHelper.func_76125_a(this.field_71067_cb + p_195068_1_, 0, Integer.MAX_VALUE); -@@ -1507,7 +_,7 @@ - } - - public void func_192024_a(ItemStack p_192024_1_, int p_192024_2_) { -- this.field_71068_ca -= p_192024_2_; -+ func_82242_a(-p_192024_2_); - if (this.field_71068_ca < 0) { - this.field_71068_ca = 0; - this.field_71106_cc = 0.0F; -@@ -1518,6 +_,10 @@ - } - - public void func_82242_a(int p_82242_1_) { -+ net.minecraftforge.event.entity.player.PlayerXpEvent.LevelChange event = new net.minecraftforge.event.entity.player.PlayerXpEvent.LevelChange(this, p_82242_1_); -+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) return; -+ p_82242_1_ = event.getLevels(); -+ - this.field_71068_ca += p_82242_1_; - if (this.field_71068_ca < 0) { - this.field_71068_ca = 0; -@@ -1708,7 +_,11 @@ - } - - public ITextComponent func_145748_c_() { -- IFormattableTextComponent iformattabletextcomponent = ScorePlayerTeam.func_237500_a_(this.func_96124_cp(), this.func_200200_C_()); -+ if (this.displayname == null) this.displayname = net.minecraftforge.event.ForgeEventFactory.getPlayerDisplayName(this, this.func_200200_C_()); -+ IFormattableTextComponent iformattabletextcomponent = new StringTextComponent(""); -+ iformattabletextcomponent = prefixes.stream().reduce(iformattabletextcomponent, IFormattableTextComponent::func_230529_a_); -+ iformattabletextcomponent = iformattabletextcomponent.func_230529_a_(ScorePlayerTeam.func_237500_a_(this.func_96124_cp(), this.displayname)); -+ iformattabletextcomponent = suffixes.stream().reduce(iformattabletextcomponent, IFormattableTextComponent::func_230529_a_); - return this.func_208016_c(iformattabletextcomponent); - } - -@@ -1986,5 +_,63 @@ - public ITextComponent func_221259_a() { - return this.field_221260_g; - } -+ } -+ -+ // =========== FORGE START ==============// -+ public Collection getPrefixes() { -+ return this.prefixes; -+ } -+ -+ public Collection getSuffixes() { -+ return this.suffixes; -+ } -+ -+ private ITextComponent displayname = null; -+ /** -+ * Force the displayed name to refresh, by firing {@link net.minecraftforge.event.entity.player.PlayerEvent.NameFormat}, using the real player name as event parameter. -+ */ -+ public void refreshDisplayName() { -+ this.displayname = net.minecraftforge.event.ForgeEventFactory.getPlayerDisplayName(this, this.func_200200_C_()); -+ } -+ -+ private final net.minecraftforge.common.util.LazyOptional -+ playerMainHandler = net.minecraftforge.common.util.LazyOptional.of( -+ () -> new net.minecraftforge.items.wrapper.PlayerMainInvWrapper(field_71071_by)); -+ -+ private final net.minecraftforge.common.util.LazyOptional -+ playerEquipmentHandler = net.minecraftforge.common.util.LazyOptional.of( -+ () -> new net.minecraftforge.items.wrapper.CombinedInvWrapper( -+ new net.minecraftforge.items.wrapper.PlayerArmorInvWrapper(field_71071_by), -+ new net.minecraftforge.items.wrapper.PlayerOffhandInvWrapper(field_71071_by))); -+ -+ private final net.minecraftforge.common.util.LazyOptional -+ playerJoinedHandler = net.minecraftforge.common.util.LazyOptional.of( -+ () -> new net.minecraftforge.items.wrapper.PlayerInvWrapper(field_71071_by)); -+ -+ @Override -+ public net.minecraftforge.common.util.LazyOptional getCapability(net.minecraftforge.common.capabilities.Capability capability, @Nullable Direction facing) { -+ if (this.func_70089_S() && capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { -+ if (facing == null) return playerJoinedHandler.cast(); -+ else if (facing.func_176740_k().func_200128_b()) return playerMainHandler.cast(); -+ else if (facing.func_176740_k().func_176722_c()) return playerEquipmentHandler.cast(); -+ } -+ return super.getCapability(capability, facing); -+ } -+ -+ /** -+ * Force a pose for the player. If set, the vanilla pose determination and clearance check is skipped. Make sure the pose is clear yourself (e.g. in PlayerTick). -+ * This has to be set just once, do not set it every tick. -+ * Make sure to clear (null) the pose if not required anymore and only use if necessary. -+ */ -+ public void setForcedPose(@Nullable Pose pose) { -+ this.forcedPose = pose; -+ } -+ -+ /** -+ * @return The forced pose if set, null otherwise -+ */ -+ @Nullable -+ public Pose getForcedPose() { -+ return this.forcedPose; - } - } diff --git a/patches/minecraft/net/minecraft/entity/player/PlayerInventory.java.patch b/patches/minecraft/net/minecraft/entity/player/PlayerInventory.java.patch deleted file mode 100644 index 06061c7b6f..0000000000 --- a/patches/minecraft/net/minecraft/entity/player/PlayerInventory.java.patch +++ /dev/null @@ -1,30 +0,0 @@ ---- a/net/minecraft/entity/player/PlayerInventory.java -+++ b/net/minecraft/entity/player/PlayerInventory.java -@@ -187,7 +_,8 @@ - int i = p_191973_2_.func_190916_E(); - ItemStack itemstack = this.func_70301_a(p_191973_1_); - if (itemstack.func_190926_b()) { -- itemstack = new ItemStack(item, 0); -+ itemstack = p_191973_2_.func_77946_l(); // Forge: Replace Item clone above to preserve item capabilities when picking the item up. -+ itemstack.func_190920_e(0); - if (p_191973_2_.func_77942_o()) { - itemstack.func_77982_d(p_191973_2_.func_77978_p().func_74737_b()); - } -@@ -238,7 +_,7 @@ - } - } - } -- -+ field_70460_b.forEach(e -> e.onArmorTick(field_70458_d.field_70170_p, field_70458_d)); - } - - public boolean func_70441_a(ItemStack p_70441_1_) { -@@ -287,6 +_,8 @@ - } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.func_85055_a(throwable, "Adding item to inventory"); - CrashReportCategory crashreportcategory = crashreport.func_85058_a("Item being added"); -+ crashreportcategory.func_189529_a("Registry Name", () -> String.valueOf(p_191971_2_.func_77973_b().getRegistryName())); -+ crashreportcategory.func_189529_a("Item Class", () -> p_191971_2_.func_77973_b().getClass().getName()); - crashreportcategory.func_71507_a("Item ID", Item.func_150891_b(p_191971_2_.func_77973_b())); - crashreportcategory.func_71507_a("Item data", p_191971_2_.func_77952_i()); - crashreportcategory.func_189529_a("Item name", () -> { diff --git a/patches/minecraft/net/minecraft/entity/player/ServerPlayerEntity.java.patch b/patches/minecraft/net/minecraft/entity/player/ServerPlayerEntity.java.patch deleted file mode 100644 index 8be7855290..0000000000 --- a/patches/minecraft/net/minecraft/entity/player/ServerPlayerEntity.java.patch +++ /dev/null @@ -1,238 +0,0 @@ ---- a/net/minecraft/entity/player/ServerPlayerEntity.java -+++ b/net/minecraft/entity/player/ServerPlayerEntity.java -@@ -475,6 +_,7 @@ - } - - public void func_70645_a(DamageSource p_70645_1_) { -+ if (net.minecraftforge.common.ForgeHooks.onLivingDeath(this, p_70645_1_)) return; - boolean flag = this.field_70170_p.func_82736_K().func_223586_b(GameRules.field_223609_l); - if (flag) { - ITextComponent itextcomponent = this.func_110142_aN().func_151521_b(); -@@ -618,13 +_,14 @@ - } - - @Nullable -- public Entity func_241206_a_(ServerWorld p_241206_1_) { -+ public Entity changeDimension(ServerWorld p_241206_1_, net.minecraftforge.common.util.ITeleporter teleporter) { -+ if (!net.minecraftforge.common.ForgeHooks.onTravelToDimension(this, p_241206_1_.func_234923_W_())) return null; - this.field_184851_cj = true; - ServerWorld serverworld = this.func_71121_q(); - RegistryKey registrykey = serverworld.func_234923_W_(); -- if (registrykey == World.field_234920_i_ && p_241206_1_.func_234923_W_() == World.field_234918_g_) { -+ if (registrykey == World.field_234920_i_ && p_241206_1_.func_234923_W_() == World.field_234918_g_ && teleporter.isVanilla()) { //Forge: Fix non-vanilla teleporters triggering end credits - this.func_213319_R(); -- this.func_71121_q().func_217434_e(this); -+ this.func_71121_q().removePlayer(this, true); //Forge: The player entity is cloned so keep the data until after cloning calls copyFrom - if (!this.field_71136_j) { - this.field_71136_j = true; - this.field_71135_a.func_147359_a(new SChangeGameStatePacket(SChangeGameStatePacket.field_241768_e_, this.field_192040_cp ? 0.0F : 1.0F)); -@@ -638,14 +_,15 @@ - this.field_71135_a.func_147359_a(new SServerDifficultyPacket(iworldinfo.func_176130_y(), iworldinfo.func_176123_z())); - PlayerList playerlist = this.field_71133_b.func_184103_al(); - playerlist.func_187243_f(this); -- serverworld.func_217434_e(this); -- this.field_70128_L = false; -- PortalInfo portalinfo = this.func_241829_a(p_241206_1_); -+ serverworld.removeEntity(this, true); //Forge: the player entity is moved to the new world, NOT cloned. So keep the data alive with no matching invalidate call. -+ this.revive(); -+ PortalInfo portalinfo = teleporter.getPortalInfo(this, p_241206_1_, this::func_241829_a); - if (portalinfo != null) { -+ Entity e = teleporter.placeEntity(this, serverworld, p_241206_1_, this.field_70177_z, spawnPortal -> {//Forge: Start vanilla logic - serverworld.func_217381_Z().func_76320_a("moving"); - if (registrykey == World.field_234918_g_ && p_241206_1_.func_234923_W_() == World.field_234919_h_) { - this.field_193110_cw = this.func_213303_ch(); -- } else if (p_241206_1_.func_234923_W_() == World.field_234920_i_) { -+ } else if (spawnPortal && p_241206_1_.func_234923_W_() == World.field_234920_i_) { - this.func_242110_a(p_241206_1_, new BlockPos(portalinfo.field_222505_a)); - } - -@@ -657,6 +_,9 @@ - this.func_225653_b_(portalinfo.field_222505_a.field_72450_a, portalinfo.field_222505_a.field_72448_b, portalinfo.field_222505_a.field_72449_c); - serverworld.func_217381_Z().func_76319_b(); - this.func_213846_b(serverworld); -+ return this;//forge: this is part of the ITeleporter patch -+ });//Forge: End vanilla logic -+ if (e != this) throw new java.lang.IllegalArgumentException(String.format("Teleporter %s returned not the player entity but instead %s, expected PlayerEntity %s", teleporter, e, this)); - this.field_71134_c.func_73080_a(p_241206_1_); - this.field_71135_a.func_147359_a(new SPlayerAbilitiesPacket(this.field_71075_bZ)); - playerlist.func_72354_b(this, p_241206_1_); -@@ -666,10 +_,12 @@ - this.field_71135_a.func_147359_a(new SPlayEntityEffectPacket(this.func_145782_y(), effectinstance)); - } - -+ if (teleporter.playTeleportSound(this, serverworld, p_241206_1_)) - this.field_71135_a.func_147359_a(new SPlaySoundEventPacket(1032, BlockPos.field_177992_a, 0, false)); - this.field_71144_ck = -1; - this.field_71149_ch = -1.0F; - this.field_71146_ci = -1; -+ net.minecraftforge.fml.hooks.BasicEventHooks.firePlayerChangedDimensionEvent(this, registrykey, p_241206_1_.func_234923_W_()); - } - - return this; -@@ -743,6 +_,9 @@ - } - - public Either func_213819_a(BlockPos p_213819_1_) { -+ java.util.Optional optAt = java.util.Optional.of(p_213819_1_); -+ PlayerEntity.SleepResult ret = net.minecraftforge.event.ForgeEventFactory.onPlayerSleepInBed(this, optAt); -+ if (ret != null) return Either.left(ret); - Direction direction = this.field_70170_p.func_180495_p(p_213819_1_).func_177229_b(HorizontalBlock.field_185512_D); - if (!this.func_70608_bn() && this.func_70089_S()) { - if (!this.field_70170_p.func_230315_m_().func_236043_f_()) { -@@ -753,7 +_,7 @@ - return Either.left(PlayerEntity.SleepResult.OBSTRUCTED); - } else { - this.func_242111_a(this.field_70170_p.func_234923_W_(), p_213819_1_, this.field_70177_z, false, true); -- if (this.field_70170_p.func_72935_r()) { -+ if (!net.minecraftforge.event.ForgeEventFactory.fireSleepingTimeCheck(this, optAt)) { - return Either.left(PlayerEntity.SleepResult.NOT_POSSIBLE_NOW); - } else { - if (!this.func_184812_l_()) { -@@ -787,6 +_,7 @@ - } - - private boolean func_241147_a_(BlockPos p_241147_1_, Direction p_241147_2_) { -+ if (p_241147_2_ == null) return false; - return this.func_241158_g_(p_241147_1_) || this.func_241158_g_(p_241147_1_.func_177972_a(p_241147_2_.func_176734_d())); - } - -@@ -886,6 +_,7 @@ - this.field_71135_a.func_147359_a(new SOpenWindowPacket(container.field_75152_c, container.func_216957_a(), p_213829_1_.func_145748_c_())); - container.func_75132_a(this); - this.field_71070_bA = container; -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerContainerEvent.Open(this, this.field_71070_bA)); - return OptionalInt.of(this.field_71139_cq); - } - } -@@ -904,6 +_,7 @@ - this.field_71135_a.func_147359_a(new SOpenHorseWindowPacket(this.field_71139_cq, p_184826_2_.func_70302_i_(), p_184826_1_.func_145782_y())); - this.field_71070_bA = new HorseInventoryContainer(this.field_71139_cq, this.field_71071_by, p_184826_2_, p_184826_1_); - this.field_71070_bA.func_75132_a(this); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerContainerEvent.Open(this, this.field_71070_bA)); - } - - public void func_184814_a(ItemStack p_184814_1_, Hand p_184814_2_) { -@@ -961,6 +_,7 @@ - - public void func_71128_l() { - this.field_71070_bA.func_75134_a(this); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerContainerEvent.Close(this, this.field_71070_bA)); - this.field_71070_bA = this.field_71069_bz; - } - -@@ -1085,6 +_,13 @@ - this.field_193110_cw = p_193104_1_.field_193110_cw; - this.func_192029_h(p_193104_1_.func_192023_dk()); - this.func_192031_i(p_193104_1_.func_192025_dl()); -+ -+ //Copy over a section of the Entity Data from the old player. -+ //Allows mods to specify data that persists after players respawn. -+ CompoundNBT old = p_193104_1_.getPersistentData(); -+ if (old.func_74764_b(PERSISTED_NBT_TAG)) -+ getPersistentData().func_218657_a(PERSISTED_NBT_TAG, old.func_74781_a(PERSISTED_NBT_TAG)); -+ net.minecraftforge.event.ForgeEventFactory.onPlayerClone(this, p_193104_1_, !p_193104_2_); - } - - protected void func_70670_a(EffectInstance p_70670_1_) { -@@ -1143,6 +_,7 @@ - } - - public void func_71033_a(GameType p_71033_1_) { -+ if (!net.minecraftforge.common.ForgeHooks.onChangeGameMode(this, this.field_71134_c.func_73081_b(), p_71033_1_)) return; - this.field_71134_c.func_73076_a(p_71033_1_); - this.field_71135_a.func_147359_a(new SChangeGameStatePacket(SChangeGameStatePacket.field_241767_d_, (float)p_71033_1_.func_77148_a())); - if (p_71033_1_ == GameType.SPECTATOR) { -@@ -1191,6 +_,7 @@ - this.field_71140_co = p_147100_1_.func_149520_f(); - this.func_184212_Q().func_187227_b(field_184827_bp, (byte)p_147100_1_.func_149521_d()); - this.func_184212_Q().func_187227_b(field_184828_bq, (byte)(p_147100_1_.func_186991_f() == HandSide.LEFT ? 0 : 1)); -+ this.language = p_147100_1_.func_149524_c(); - } - - public ChatVisibility func_147096_v() { -@@ -1276,7 +_,11 @@ - - @Nullable - public ITextComponent func_175396_E() { -- return null; -+ if (!this.hasTabListName) { -+ this.tabListDisplayName = net.minecraftforge.event.ForgeEventFactory.getPlayerTabListDisplayName(this); -+ this.hasTabListName = true; -+ } -+ return this.tabListDisplayName; - } - - public void func_184609_a(Hand p_184609_1_) { -@@ -1301,14 +_,14 @@ - this.func_184210_p(); - if (p_200619_1_ == this.field_70170_p) { - this.field_71135_a.func_147364_a(p_200619_2_, p_200619_4_, p_200619_6_, p_200619_8_, p_200619_9_); -- } else { -+ } else if (net.minecraftforge.common.ForgeHooks.onTravelToDimension(this, p_200619_1_.func_234923_W_())) { - ServerWorld serverworld = this.func_71121_q(); - IWorldInfo iworldinfo = p_200619_1_.func_72912_H(); - this.field_71135_a.func_147359_a(new SRespawnPacket(p_200619_1_.func_230315_m_(), p_200619_1_.func_234923_W_(), BiomeManager.func_235200_a_(p_200619_1_.func_72905_C()), this.field_71134_c.func_73081_b(), this.field_71134_c.func_241815_c_(), p_200619_1_.func_234925_Z_(), p_200619_1_.func_241109_A_(), true)); - this.field_71135_a.func_147359_a(new SServerDifficultyPacket(iworldinfo.func_176130_y(), iworldinfo.func_176123_z())); - this.field_71133_b.func_184103_al().func_187243_f(this); -- serverworld.func_217434_e(this); -- this.field_70128_L = false; -+ serverworld.removePlayer(this, true); //Forge: The player entity itself is moved, and not cloned. So we need to keep the data alive with no matching invalidate call later. -+ this.revive(); - this.func_70012_b(p_200619_2_, p_200619_4_, p_200619_6_, p_200619_8_, p_200619_9_); - this.func_70029_a(p_200619_1_); - p_200619_1_.func_217446_a(this); -@@ -1317,6 +_,7 @@ - this.field_71134_c.func_73080_a(p_200619_1_); - this.field_71133_b.func_184103_al().func_72354_b(this, p_200619_1_); - this.field_71133_b.func_184103_al().func_72385_f(this); -+ net.minecraftforge.fml.hooks.BasicEventHooks.firePlayerChangedDimensionEvent(this, serverworld.func_234923_W_(), p_200619_1_.func_234923_W_()); - } - - } -@@ -1339,6 +_,7 @@ - } - - public void func_242111_a(RegistryKey p_242111_1_, @Nullable BlockPos p_242111_2_, float p_242111_3_, boolean p_242111_4_, boolean p_242111_5_) { -+ if (net.minecraftforge.event.ForgeEventFactory.onPlayerSpawnSet(this, p_242111_2_ == null ? World.field_234918_g_ : p_242111_1_, p_242111_2_, p_242111_4_)) return; - if (p_242111_2_ != null) { - boolean flag = p_242111_2_.equals(this.field_241138_cr_) && p_242111_1_.equals(this.field_241137_cq_); - if (p_242111_5_ && !flag) { -@@ -1391,6 +_,8 @@ - if (itementity == null) { - return null; - } else { -+ if (captureDrops() != null) captureDrops().add(itementity); -+ else - this.field_70170_p.func_217376_c(itementity); - ItemStack itemstack = itementity.func_92059_d(); - if (p_146097_3_) { -@@ -1402,6 +_,29 @@ - } - - return itementity; -+ } -+ } -+ -+ 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; -+ } -+ -+ // We need this as tablistDisplayname may be null even if the the event was fired. -+ private boolean hasTabListName = false; -+ private ITextComponent tabListDisplayName = null; -+ /** -+ * Force the name displayed in the tab list to refresh, by firing {@link net.minecraftforge.event.entity.player.PlayerEvent.TabListNameFormat}. -+ */ -+ public void refreshTabListName() { -+ ITextComponent oldName = this.tabListDisplayName; -+ this.tabListDisplayName = net.minecraftforge.event.ForgeEventFactory.getPlayerTabListDisplayName(this); -+ if (!java.util.Objects.equals(oldName, this.tabListDisplayName)) { -+ this.func_184102_h().func_184103_al().func_148540_a(new net.minecraft.network.play.server.SPlayerListItemPacket(net.minecraft.network.play.server.SPlayerListItemPacket.Action.UPDATE_DISPLAY_NAME, this)); - } - } - diff --git a/patches/minecraft/net/minecraft/entity/projectile/AbstractArrowEntity.java.patch b/patches/minecraft/net/minecraft/entity/projectile/AbstractArrowEntity.java.patch deleted file mode 100644 index 0673d08cbf..0000000000 --- a/patches/minecraft/net/minecraft/entity/projectile/AbstractArrowEntity.java.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/entity/projectile/AbstractArrowEntity.java -+++ b/net/minecraft/entity/projectile/AbstractArrowEntity.java -@@ -130,7 +_,7 @@ - - BlockPos blockpos = this.func_233580_cy_(); - BlockState blockstate = this.field_70170_p.func_180495_p(blockpos); -- if (!blockstate.func_196958_f() && !flag) { -+ if (!blockstate.isAir(this.field_70170_p, blockpos) && !flag) { - VoxelShape voxelshape = blockstate.func_196952_d(this.field_70170_p, blockpos); - if (!voxelshape.func_197766_b()) { - Vector3d vector3d1 = this.func_213303_ch(); -@@ -184,7 +_,7 @@ - } - } - -- if (raytraceresult != null && !flag) { -+ if (raytraceresult != null && raytraceresult.func_216346_c() != RayTraceResult.Type.MISS && !flag && !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, raytraceresult)) { - this.func_70227_a(raytraceresult); - this.field_70160_al = true; - } diff --git a/patches/minecraft/net/minecraft/entity/projectile/DamagingProjectileEntity.java.patch b/patches/minecraft/net/minecraft/entity/projectile/DamagingProjectileEntity.java.patch deleted file mode 100644 index b74745ae7a..0000000000 --- a/patches/minecraft/net/minecraft/entity/projectile/DamagingProjectileEntity.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/entity/projectile/DamagingProjectileEntity.java -+++ b/net/minecraft/entity/projectile/DamagingProjectileEntity.java -@@ -68,7 +_,7 @@ - } - - RayTraceResult raytraceresult = ProjectileHelper.func_234618_a_(this, this::func_230298_a_); -- if (raytraceresult.func_216346_c() != RayTraceResult.Type.MISS) { -+ if (raytraceresult.func_216346_c() != RayTraceResult.Type.MISS && !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, raytraceresult)) { - this.func_70227_a(raytraceresult); - } - diff --git a/patches/minecraft/net/minecraft/entity/projectile/FireballEntity.java.patch b/patches/minecraft/net/minecraft/entity/projectile/FireballEntity.java.patch deleted file mode 100644 index 6c0a59a6d9..0000000000 --- a/patches/minecraft/net/minecraft/entity/projectile/FireballEntity.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/entity/projectile/FireballEntity.java -+++ b/net/minecraft/entity/projectile/FireballEntity.java -@@ -32,7 +_,7 @@ - protected void func_70227_a(RayTraceResult p_70227_1_) { - super.func_70227_a(p_70227_1_); - if (!this.field_70170_p.field_72995_K) { -- boolean flag = this.field_70170_p.func_82736_K().func_223586_b(GameRules.field_223599_b); -+ boolean flag = net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.field_70170_p, this.func_234616_v_()); - this.field_70170_p.func_217398_a((Entity)null, this.func_226277_ct_(), this.func_226278_cu_(), this.func_226281_cx_(), (float)this.field_92057_e, flag, flag ? Explosion.Mode.DESTROY : Explosion.Mode.NONE); - this.func_70106_y(); - } diff --git a/patches/minecraft/net/minecraft/entity/projectile/FireworkRocketEntity.java.patch b/patches/minecraft/net/minecraft/entity/projectile/FireworkRocketEntity.java.patch deleted file mode 100644 index 984c43e959..0000000000 --- a/patches/minecraft/net/minecraft/entity/projectile/FireworkRocketEntity.java.patch +++ /dev/null @@ -1,16 +0,0 @@ ---- a/net/minecraft/entity/projectile/FireworkRocketEntity.java -+++ b/net/minecraft/entity/projectile/FireworkRocketEntity.java -@@ -156,6 +_,13 @@ - - } - -+ @Override -+ protected void func_70227_a(RayTraceResult result) { -+ if (result.func_216346_c() == RayTraceResult.Type.MISS || !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, result)) { -+ super.func_70227_a(result); -+ } -+ } -+ - private void func_213893_k() { - this.field_70170_p.func_72960_a(this, (byte)17); - this.func_191510_k(); diff --git a/patches/minecraft/net/minecraft/entity/projectile/FishingBobberEntity.java.patch b/patches/minecraft/net/minecraft/entity/projectile/FishingBobberEntity.java.patch deleted file mode 100644 index a8bd1667fa..0000000000 --- a/patches/minecraft/net/minecraft/entity/projectile/FishingBobberEntity.java.patch +++ /dev/null @@ -1,74 +0,0 @@ ---- a/net/minecraft/entity/projectile/FishingBobberEntity.java -+++ b/net/minecraft/entity/projectile/FishingBobberEntity.java -@@ -245,7 +_,7 @@ - - private void func_190624_r() { - RayTraceResult raytraceresult = ProjectileHelper.func_234618_a_(this, this::func_230298_a_); -- this.func_70227_a(raytraceresult); -+ if (raytraceresult.func_216346_c() == RayTraceResult.Type.MISS || !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, raytraceresult)) this.func_70227_a(raytraceresult); - } - - protected boolean func_230298_a_(Entity p_230298_1_) { -@@ -300,7 +_,7 @@ - double d1 = (double)((float)MathHelper.func_76128_c(this.func_226278_cu_()) + 1.0F); - double d2 = this.func_226281_cx_() + (double)(f2 * (float)this.field_146038_az * 0.1F); - BlockState blockstate = serverworld.func_180495_p(new BlockPos(d0, d1 - 1.0D, d2)); -- if (blockstate.func_203425_a(Blocks.field_150355_j)) { -+ if (serverworld.func_180495_p(new BlockPos((int)d0, (int)d1 - 1, (int)d2)).func_185904_a() == net.minecraft.block.material.Material.field_151586_h) { - if (this.field_70146_Z.nextFloat() < 0.15F) { - serverworld.func_195598_a(ParticleTypes.field_197612_e, d0, d1 - (double)0.1F, d2, 1, (double)f1, 0.1D, (double)f2, 0.0D); - } -@@ -336,7 +_,7 @@ - double d5 = (double)((float)MathHelper.func_76128_c(this.func_226278_cu_()) + 1.0F); - double d6 = this.func_226281_cx_() + (double)(MathHelper.func_76134_b(f6) * f7 * 0.1F); - BlockState blockstate1 = serverworld.func_180495_p(new BlockPos(d4, d5 - 1.0D, d6)); -- if (blockstate1.func_203425_a(Blocks.field_150355_j)) { -+ if (serverworld.func_180495_p(new BlockPos(d4, d5 - 1.0D, d6)).func_185904_a() == net.minecraft.block.material.Material.field_151586_h) { - serverworld.func_195598_a(ParticleTypes.field_218422_X, d4, d5, d6, 2 + this.field_70146_Z.nextInt(2), (double)0.1F, 0.0D, (double)0.1F, 0.0D); - } - } -@@ -407,6 +_,7 @@ - PlayerEntity playerentity = this.func_234606_i_(); - if (!this.field_70170_p.field_72995_K && playerentity != null) { - int i = 0; -+ net.minecraftforge.event.entity.player.ItemFishedEvent event = null; - if (this.field_146043_c != null) { - this.func_184527_k(); - CriteriaTriggers.field_204811_D.func_204820_a((ServerPlayerEntity)playerentity, p_146034_1_, this, Collections.emptyList()); -@@ -414,8 +_,15 @@ - i = this.field_146043_c instanceof ItemEntity ? 3 : 5; - } else if (this.field_146045_ax > 0) { - LootContext.Builder lootcontext$builder = (new LootContext.Builder((ServerWorld)this.field_70170_p)).func_216015_a(LootParameters.field_237457_g_, this.func_213303_ch()).func_216015_a(LootParameters.field_216289_i, p_146034_1_).func_216015_a(LootParameters.field_216281_a, this).func_216023_a(this.field_70146_Z).func_186469_a((float)this.field_191518_aw + playerentity.func_184817_da()); -+ lootcontext$builder.func_216015_a(LootParameters.field_216284_d, this.func_234616_v_()).func_216015_a(LootParameters.field_216281_a, this); - LootTable loottable = this.field_70170_p.func_73046_m().func_200249_aQ().func_186521_a(LootTables.field_186387_al); - List list = loottable.func_216113_a(lootcontext$builder.func_216022_a(LootParameterSets.field_216262_c)); -+ event = new net.minecraftforge.event.entity.player.ItemFishedEvent(list, this.field_70122_E ? 2 : 1, this); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); -+ if (event.isCanceled()) { -+ this.func_70106_y(); -+ return event.getRodDamage(); -+ } - CriteriaTriggers.field_204811_D.func_204820_a((ServerPlayerEntity)playerentity, p_146034_1_, this, list); - - for(ItemStack itemstack : list) { -@@ -440,7 +_,7 @@ - } - - this.func_70106_y(); -- return i; -+ return event == null ? i : event.getRodDamage(); - } else { - return 0; - } -@@ -467,8 +_,9 @@ - return false; - } - -- public void func_70106_y() { -- super.func_70106_y(); -+ @Override -+ public void remove(boolean keepData) { -+ super.remove(keepData); - PlayerEntity playerentity = this.func_234606_i_(); - if (playerentity != null) { - playerentity.field_71104_cf = null; diff --git a/patches/minecraft/net/minecraft/entity/projectile/LlamaSpitEntity.java.patch b/patches/minecraft/net/minecraft/entity/projectile/LlamaSpitEntity.java.patch deleted file mode 100644 index 2796a5f539..0000000000 --- a/patches/minecraft/net/minecraft/entity/projectile/LlamaSpitEntity.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/entity/projectile/LlamaSpitEntity.java -+++ b/net/minecraft/entity/projectile/LlamaSpitEntity.java -@@ -46,7 +_,7 @@ - super.func_70071_h_(); - Vector3d vector3d = this.func_213322_ci(); - RayTraceResult raytraceresult = ProjectileHelper.func_234618_a_(this, this::func_230298_a_); -- if (raytraceresult != null) { -+ if (raytraceresult != null && raytraceresult.func_216346_c() != RayTraceResult.Type.MISS && !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, raytraceresult)) { - this.func_70227_a(raytraceresult); - } - diff --git a/patches/minecraft/net/minecraft/entity/projectile/ProjectileHelper.java.patch b/patches/minecraft/net/minecraft/entity/projectile/ProjectileHelper.java.patch deleted file mode 100644 index 2305e72540..0000000000 --- a/patches/minecraft/net/minecraft/entity/projectile/ProjectileHelper.java.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- a/net/minecraft/entity/projectile/ProjectileHelper.java -+++ b/net/minecraft/entity/projectile/ProjectileHelper.java -@@ -60,7 +_,7 @@ - Vector3d vector3d1 = optional.get(); - double d1 = p_221273_1_.func_72436_e(vector3d1); - if (d1 < d0 || d0 == 0.0D) { -- if (entity1.func_184208_bv() == p_221273_0_.func_184208_bv()) { -+ if (entity1.func_184208_bv() == p_221273_0_.func_184208_bv() && !entity1.canRiderInteract()) { - if (d0 == 0.0D) { - entity = entity1; - vector3d = vector3d1; -@@ -123,8 +_,14 @@ - } - } - -+ @Deprecated // Forge: Use the version below that takes in a Predicate instead of an Item - public static Hand func_221274_a(LivingEntity p_221274_0_, Item p_221274_1_) { - return p_221274_0_.func_184614_ca().func_77973_b() == p_221274_1_ ? Hand.MAIN_HAND : Hand.OFF_HAND; -+ } -+ -+ public static Hand getWeaponHoldingHand(LivingEntity livingEntity, Predicate itemPredicate) -+ { -+ return itemPredicate.test(livingEntity.func_184614_ca().func_77973_b()) ? Hand.MAIN_HAND : Hand.OFF_HAND; - } - - public static AbstractArrowEntity func_221272_a(LivingEntity p_221272_0_, ItemStack p_221272_1_, float p_221272_2_) { diff --git a/patches/minecraft/net/minecraft/entity/projectile/ShulkerBulletEntity.java.patch b/patches/minecraft/net/minecraft/entity/projectile/ShulkerBulletEntity.java.patch deleted file mode 100644 index c66ab3fc9b..0000000000 --- a/patches/minecraft/net/minecraft/entity/projectile/ShulkerBulletEntity.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/entity/projectile/ShulkerBulletEntity.java -+++ b/net/minecraft/entity/projectile/ShulkerBulletEntity.java -@@ -213,7 +_,7 @@ - } - - RayTraceResult raytraceresult = ProjectileHelper.func_234618_a_(this, this::func_230298_a_); -- if (raytraceresult.func_216346_c() != RayTraceResult.Type.MISS) { -+ if (raytraceresult.func_216346_c() != RayTraceResult.Type.MISS && !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, raytraceresult)) { - this.func_70227_a(raytraceresult); - } - } diff --git a/patches/minecraft/net/minecraft/entity/projectile/SmallFireballEntity.java.patch b/patches/minecraft/net/minecraft/entity/projectile/SmallFireballEntity.java.patch deleted file mode 100644 index 8bf349562f..0000000000 --- a/patches/minecraft/net/minecraft/entity/projectile/SmallFireballEntity.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/entity/projectile/SmallFireballEntity.java -+++ b/net/minecraft/entity/projectile/SmallFireballEntity.java -@@ -49,7 +_,7 @@ - super.func_230299_a_(p_230299_1_); - if (!this.field_70170_p.field_72995_K) { - Entity entity = this.func_234616_v_(); -- if (entity == null || !(entity instanceof MobEntity) || this.field_70170_p.func_82736_K().func_223586_b(GameRules.field_223599_b)) { -+ if (entity == null || !(entity instanceof MobEntity) || net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.field_70170_p, this.getEntity())) { - BlockPos blockpos = p_230299_1_.func_216350_a().func_177972_a(p_230299_1_.func_216354_b()); - if (this.field_70170_p.func_175623_d(blockpos)) { - this.field_70170_p.func_175656_a(blockpos, AbstractFireBlock.func_235326_a_(this.field_70170_p, blockpos)); diff --git a/patches/minecraft/net/minecraft/entity/projectile/ThrowableEntity.java.patch b/patches/minecraft/net/minecraft/entity/projectile/ThrowableEntity.java.patch deleted file mode 100644 index 523023ab00..0000000000 --- a/patches/minecraft/net/minecraft/entity/projectile/ThrowableEntity.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/entity/projectile/ThrowableEntity.java -+++ b/net/minecraft/entity/projectile/ThrowableEntity.java -@@ -63,7 +_,7 @@ - } - } - -- if (raytraceresult.func_216346_c() != RayTraceResult.Type.MISS && !flag) { -+ if (raytraceresult.func_216346_c() != RayTraceResult.Type.MISS && !flag && !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, raytraceresult)) { - this.func_70227_a(raytraceresult); - } - diff --git a/patches/minecraft/net/minecraft/entity/projectile/WitherSkullEntity.java.patch b/patches/minecraft/net/minecraft/entity/projectile/WitherSkullEntity.java.patch deleted file mode 100644 index 18f799c607..0000000000 --- a/patches/minecraft/net/minecraft/entity/projectile/WitherSkullEntity.java.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/entity/projectile/WitherSkullEntity.java -+++ b/net/minecraft/entity/projectile/WitherSkullEntity.java -@@ -48,7 +_,7 @@ - } - - public float func_180428_a(Explosion p_180428_1_, IBlockReader p_180428_2_, BlockPos p_180428_3_, BlockState p_180428_4_, FluidState p_180428_5_, float p_180428_6_) { -- return this.func_82342_d() && WitherEntity.func_181033_a(p_180428_4_) ? Math.min(0.8F, p_180428_6_) : p_180428_6_; -+ return this.func_82342_d() && p_180428_4_.canEntityDestroy(p_180428_2_, p_180428_3_, this) ? Math.min(0.8F, p_180428_6_) : p_180428_6_; - } - - protected void func_213868_a(EntityRayTraceResult p_213868_1_) { -@@ -90,7 +_,7 @@ - protected void func_70227_a(RayTraceResult p_70227_1_) { - super.func_70227_a(p_70227_1_); - if (!this.field_70170_p.field_72995_K) { -- Explosion.Mode explosion$mode = this.field_70170_p.func_82736_K().func_223586_b(GameRules.field_223599_b) ? Explosion.Mode.DESTROY : Explosion.Mode.NONE; -+ Explosion.Mode explosion$mode = net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.field_70170_p, this.func_234616_v_()) ? Explosion.Mode.DESTROY : Explosion.Mode.NONE; - this.field_70170_p.func_217398_a(this, this.func_226277_ct_(), this.func_226278_cu_(), this.func_226281_cx_(), 1.0F, false, explosion$mode); - this.func_70106_y(); - } diff --git a/patches/minecraft/net/minecraft/fluid/FlowingFluid.java.patch b/patches/minecraft/net/minecraft/fluid/FlowingFluid.java.patch deleted file mode 100644 index d286905959..0000000000 --- a/patches/minecraft/net/minecraft/fluid/FlowingFluid.java.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/fluid/FlowingFluid.java -+++ b/net/minecraft/fluid/FlowingFluid.java -@@ -159,7 +_,7 @@ - BlockState blockstate = p_205576_1_.func_180495_p(blockpos); - FluidState fluidstate = blockstate.func_204520_s(); - if (fluidstate.func_206886_c().func_207187_a(this) && this.func_212751_a(direction, p_205576_1_, p_205576_2_, p_205576_3_, blockpos, blockstate)) { -- if (fluidstate.func_206889_d()) { -+ if (fluidstate.func_206889_d() && net.minecraftforge.event.ForgeEventFactory.canCreateFluidSource(p_205576_1_, blockpos, blockstate, this.func_205579_d())) { - ++j; - } - -@@ -167,7 +_,7 @@ - } - } - -- if (this.func_205579_d() && j >= 2) { -+ if (j >= 2) { - BlockState blockstate1 = p_205576_1_.func_180495_p(p_205576_2_.func_177977_b()); - FluidState fluidstate1 = blockstate1.func_204520_s(); - if (blockstate1.func_185904_a().func_76220_a() || this.func_211758_g(fluidstate1)) { diff --git a/patches/minecraft/net/minecraft/fluid/FluidState.java.patch b/patches/minecraft/net/minecraft/fluid/FluidState.java.patch deleted file mode 100644 index 7b81d2f34c..0000000000 --- a/patches/minecraft/net/minecraft/fluid/FluidState.java.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- a/net/minecraft/fluid/FluidState.java -+++ b/net/minecraft/fluid/FluidState.java -@@ -20,7 +_,7 @@ - import net.minecraftforge.api.distmarker.Dist; - import net.minecraftforge.api.distmarker.OnlyIn; - --public final class FluidState extends StateHolder { -+public final class FluidState extends StateHolder implements net.minecraftforge.common.extensions.IForgeFluidState { - public static final Codec field_237213_a_ = func_235897_a_(Registry.field_212619_h, Fluid::func_207188_f).stable(); - - public FluidState(Fluid p_i232145_1_, ImmutableMap, Comparable> p_i232145_2_, MapCodec p_i232145_3_) { -@@ -101,6 +_,7 @@ - return this.func_206886_c().func_207185_a(p_206884_1_); - } - -+ @Deprecated //Forge: Use more sensitive version - public float func_210200_l() { - return this.func_206886_c().func_210195_d(); - } diff --git a/patches/minecraft/net/minecraft/fluid/LavaFluid.java.patch b/patches/minecraft/net/minecraft/fluid/LavaFluid.java.patch deleted file mode 100644 index cb5fe89770..0000000000 --- a/patches/minecraft/net/minecraft/fluid/LavaFluid.java.patch +++ /dev/null @@ -1,29 +0,0 @@ ---- a/net/minecraft/fluid/LavaFluid.java -+++ b/net/minecraft/fluid/LavaFluid.java -@@ -71,7 +_,7 @@ - BlockState blockstate = p_207186_1_.func_180495_p(blockpos); - if (blockstate.func_196958_f()) { - if (this.func_176369_e(p_207186_1_, blockpos)) { -- p_207186_1_.func_175656_a(blockpos, AbstractFireBlock.func_235326_a_(p_207186_1_, blockpos)); -+ p_207186_1_.func_175656_a(blockpos, net.minecraftforge.event.ForgeEventFactory.fireFluidPlaceBlockEvent(p_207186_1_, blockpos, p_207186_2_, Blocks.field_150480_ab.func_176223_P())); - return; - } - } else if (blockstate.func_185904_a().func_76230_c()) { -@@ -86,7 +_,7 @@ - } - - if (p_207186_1_.func_175623_d(blockpos1.func_177984_a()) && this.func_176368_m(p_207186_1_, blockpos1)) { -- p_207186_1_.func_175656_a(blockpos1.func_177984_a(), AbstractFireBlock.func_235326_a_(p_207186_1_, blockpos1)); -+ p_207186_1_.func_175656_a(blockpos1.func_177984_a(), net.minecraftforge.event.ForgeEventFactory.fireFluidPlaceBlockEvent(p_207186_1_, blockpos1.func_177984_a(), p_207186_2_, Blocks.field_150480_ab.func_176223_P())); - } - } - } -@@ -164,7 +_,7 @@ - FluidState fluidstate = p_205574_1_.func_204610_c(p_205574_2_); - if (this.func_207185_a(FluidTags.field_206960_b) && fluidstate.func_206884_a(FluidTags.field_206959_a)) { - if (p_205574_3_.func_177230_c() instanceof FlowingFluidBlock) { -- p_205574_1_.func_180501_a(p_205574_2_, Blocks.field_150348_b.func_176223_P(), 3); -+ p_205574_1_.func_180501_a(p_205574_2_, net.minecraftforge.event.ForgeEventFactory.fireFluidPlaceBlockEvent(p_205574_1_, p_205574_2_, p_205574_2_, Blocks.field_150348_b.func_176223_P()), 3); - } - - this.func_205581_a(p_205574_1_, p_205574_2_); diff --git a/patches/minecraft/net/minecraft/fluid/WaterFluid.java.patch b/patches/minecraft/net/minecraft/fluid/WaterFluid.java.patch deleted file mode 100644 index a6db9d5e5e..0000000000 --- a/patches/minecraft/net/minecraft/fluid/WaterFluid.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/fluid/WaterFluid.java -+++ b/net/minecraft/fluid/WaterFluid.java -@@ -60,7 +_,7 @@ - } - - protected void func_205580_a(IWorld p_205580_1_, BlockPos p_205580_2_, BlockState p_205580_3_) { -- TileEntity tileentity = p_205580_3_.func_177230_c().func_235695_q_() ? p_205580_1_.func_175625_s(p_205580_2_) : null; -+ TileEntity tileentity = p_205580_3_.hasTileEntity() ? p_205580_1_.func_175625_s(p_205580_2_) : null; - Block.func_220059_a(p_205580_3_, p_205580_1_, p_205580_2_, tileentity); - } - diff --git a/patches/minecraft/net/minecraft/inventory/container/AbstractFurnaceContainer.java.patch b/patches/minecraft/net/minecraft/inventory/container/AbstractFurnaceContainer.java.patch deleted file mode 100644 index 19c9211b93..0000000000 --- a/patches/minecraft/net/minecraft/inventory/container/AbstractFurnaceContainer.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/inventory/container/AbstractFurnaceContainer.java -+++ b/net/minecraft/inventory/container/AbstractFurnaceContainer.java -@@ -150,7 +_,7 @@ - } - - protected boolean func_217058_b(ItemStack p_217058_1_) { -- return AbstractFurnaceTileEntity.func_213991_b(p_217058_1_); -+ return net.minecraftforge.common.ForgeHooks.getBurnTime(p_217058_1_, this.field_217065_f) > 0; - } - - @OnlyIn(Dist.CLIENT) diff --git a/patches/minecraft/net/minecraft/inventory/container/BeaconContainer.java.patch b/patches/minecraft/net/minecraft/inventory/container/BeaconContainer.java.patch deleted file mode 100644 index c0c592d0c8..0000000000 --- a/patches/minecraft/net/minecraft/inventory/container/BeaconContainer.java.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- a/net/minecraft/inventory/container/BeaconContainer.java -+++ b/net/minecraft/inventory/container/BeaconContainer.java -@@ -87,10 +_,8 @@ - } - - slot.func_75220_a(itemstack1, itemstack); -- } else if (!this.field_82864_f.func_75216_d() && this.field_82864_f.func_75214_a(itemstack1) && itemstack1.func_190916_E() == 1) { -- if (!this.func_75135_a(itemstack1, 0, 1, false)) { -- return ItemStack.field_190927_a; -- } -+ } else if (this.func_75135_a(itemstack1, 0, 1, false)) { //Forge Fix Shift Clicking in beacons with stacks larger then 1. -+ return ItemStack.field_190927_a; - } else if (p_82846_2_ >= 1 && p_82846_2_ < 28) { - if (!this.func_75135_a(itemstack1, 28, 37, false)) { - return ItemStack.field_190927_a; diff --git a/patches/minecraft/net/minecraft/inventory/container/BrewingStandContainer.java.patch b/patches/minecraft/net/minecraft/inventory/container/BrewingStandContainer.java.patch deleted file mode 100644 index 2fca0ebca5..0000000000 --- a/patches/minecraft/net/minecraft/inventory/container/BrewingStandContainer.java.patch +++ /dev/null @@ -1,29 +0,0 @@ ---- a/net/minecraft/inventory/container/BrewingStandContainer.java -+++ b/net/minecraft/inventory/container/BrewingStandContainer.java -@@ -143,7 +_,7 @@ - } - - public boolean func_75214_a(ItemStack p_75214_1_) { -- return PotionBrewing.func_185205_a(p_75214_1_); -+ return net.minecraftforge.common.brewing.BrewingRecipeRegistry.isValidIngredient(p_75214_1_); - } - - public int func_75219_a() { -@@ -167,6 +_,7 @@ - public ItemStack func_190901_a(PlayerEntity p_190901_1_, ItemStack p_190901_2_) { - Potion potion = PotionUtils.func_185191_c(p_190901_2_); - if (p_190901_1_ instanceof ServerPlayerEntity) { -+ net.minecraftforge.event.ForgeEventFactory.onPlayerBrewedPotion(p_190901_1_, p_190901_2_); - CriteriaTriggers.field_192130_j.func_192173_a((ServerPlayerEntity)p_190901_1_, potion); - } - -@@ -175,8 +_,7 @@ - } - - public static boolean func_75243_a_(ItemStack p_75243_0_) { -- Item item = p_75243_0_.func_77973_b(); -- return item == Items.field_151068_bn || item == Items.field_185155_bH || item == Items.field_185156_bI || item == Items.field_151069_bo; -+ return net.minecraftforge.common.brewing.BrewingRecipeRegistry.isValidInput(p_75243_0_); - } - } - } diff --git a/patches/minecraft/net/minecraft/inventory/container/Container.java.patch b/patches/minecraft/net/minecraft/inventory/container/Container.java.patch deleted file mode 100644 index 203131ecb0..0000000000 --- a/patches/minecraft/net/minecraft/inventory/container/Container.java.patch +++ /dev/null @@ -1,43 +0,0 @@ ---- a/net/minecraft/inventory/container/Container.java -+++ b/net/minecraft/inventory/container/Container.java -@@ -120,9 +_,11 @@ - ItemStack itemstack = this.field_75151_b.get(i).func_75211_c(); - ItemStack itemstack1 = this.field_75153_a.get(i); - if (!ItemStack.func_77989_b(itemstack1, itemstack)) { -+ boolean clientStackChanged = !itemstack1.equals(itemstack, true); - ItemStack itemstack2 = itemstack.func_77946_l(); - this.field_75153_a.set(i, itemstack2); - -+ if (clientStackChanged) - for(IContainerListener icontainerlistener : this.field_75149_d) { - icontainerlistener.func_71111_a(this, i, itemstack2); - } -@@ -500,14 +_,15 @@ - ItemStack itemstack = slot.func_75211_c(); - if (!itemstack.func_190926_b() && func_195929_a(p_75135_1_, itemstack)) { - int j = itemstack.func_190916_E() + p_75135_1_.func_190916_E(); -- if (j <= p_75135_1_.func_77976_d()) { -+ int maxSize = Math.min(slot.func_75219_a(), p_75135_1_.func_77976_d()); -+ if (j <= maxSize) { - p_75135_1_.func_190920_e(0); - itemstack.func_190920_e(j); - slot.func_75218_e(); - flag = true; -- } else if (itemstack.func_190916_E() < p_75135_1_.func_77976_d()) { -- p_75135_1_.func_190918_g(p_75135_1_.func_77976_d() - itemstack.func_190916_E()); -- itemstack.func_190920_e(p_75135_1_.func_77976_d()); -+ } else if (itemstack.func_190916_E() < maxSize) { -+ p_75135_1_.func_190918_g(maxSize - itemstack.func_190916_E()); -+ itemstack.func_190920_e(maxSize); - slot.func_75218_e(); - flag = true; - } -@@ -608,7 +_,7 @@ - p_94525_2_.func_190920_e(1); - break; - case 2: -- p_94525_2_.func_190920_e(p_94525_2_.func_77973_b().func_77639_j()); -+ p_94525_2_.func_190920_e(p_94525_2_.func_77976_d()); - } - - p_94525_2_.func_190917_f(p_94525_3_); diff --git a/patches/minecraft/net/minecraft/inventory/container/ContainerType.java.patch b/patches/minecraft/net/minecraft/inventory/container/ContainerType.java.patch deleted file mode 100644 index 006a2c89cb..0000000000 --- a/patches/minecraft/net/minecraft/inventory/container/ContainerType.java.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- a/net/minecraft/inventory/container/ContainerType.java -+++ b/net/minecraft/inventory/container/ContainerType.java -@@ -5,7 +_,7 @@ - import net.minecraftforge.api.distmarker.Dist; - import net.minecraftforge.api.distmarker.OnlyIn; - --public class ContainerType { -+public class ContainerType extends net.minecraftforge.registries.ForgeRegistryEntry> implements net.minecraftforge.common.extensions.IForgeContainerType { - public static final ContainerType field_221507_a = func_221505_a("generic_9x1", ChestContainer::func_216986_a); - public static final ContainerType field_221508_b = func_221505_a("generic_9x2", ChestContainer::func_216987_b); - public static final ContainerType field_221509_c = func_221505_a("generic_9x3", ChestContainer::func_216988_c); -@@ -45,6 +_,14 @@ - @OnlyIn(Dist.CLIENT) - public T func_221506_a(int p_221506_1_, PlayerInventory p_221506_2_) { - return this.field_221530_x.create(p_221506_1_, p_221506_2_); -+ } -+ -+ @Override -+ public T create(int windowId, PlayerInventory playerInv, net.minecraft.network.PacketBuffer extraData) { -+ if (this.field_221530_x instanceof net.minecraftforge.fml.network.IContainerFactory) { -+ return ((net.minecraftforge.fml.network.IContainerFactory) this.field_221530_x).create(windowId, playerInv, extraData); -+ } -+ return func_221506_a(windowId, playerInv); - } - - public interface IFactory { diff --git a/patches/minecraft/net/minecraft/inventory/container/CraftingResultSlot.java.patch b/patches/minecraft/net/minecraft/inventory/container/CraftingResultSlot.java.patch deleted file mode 100644 index 776bc764f9..0000000000 --- a/patches/minecraft/net/minecraft/inventory/container/CraftingResultSlot.java.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- a/net/minecraft/inventory/container/CraftingResultSlot.java -+++ b/net/minecraft/inventory/container/CraftingResultSlot.java -@@ -43,6 +_,7 @@ - protected void func_75208_c(ItemStack p_75208_1_) { - if (this.field_75237_g > 0) { - p_75208_1_.func_77980_a(this.field_75238_b.field_70170_p, this.field_75238_b, this.field_75237_g); -+ net.minecraftforge.fml.hooks.BasicEventHooks.firePlayerCraftingEvent(this.field_75238_b, p_75208_1_, this.field_75239_a); - } - - if (this.field_75224_c instanceof IRecipeHolder) { -@@ -54,8 +_,9 @@ - - public ItemStack func_190901_a(PlayerEntity p_190901_1_, ItemStack p_190901_2_) { - this.func_75208_c(p_190901_2_); -+ net.minecraftforge.common.ForgeHooks.setCraftingPlayer(p_190901_1_); - NonNullList nonnulllist = p_190901_1_.field_70170_p.func_199532_z().func_215369_c(IRecipeType.field_222149_a, this.field_75239_a, p_190901_1_.field_70170_p); -- -+ net.minecraftforge.common.ForgeHooks.setCraftingPlayer(null); - for(int i = 0; i < nonnulllist.size(); ++i) { - ItemStack itemstack = this.field_75239_a.func_70301_a(i); - ItemStack itemstack1 = nonnulllist.get(i); diff --git a/patches/minecraft/net/minecraft/inventory/container/EnchantmentContainer.java.patch b/patches/minecraft/net/minecraft/inventory/container/EnchantmentContainer.java.patch deleted file mode 100644 index 02e21577f6..0000000000 --- a/patches/minecraft/net/minecraft/inventory/container/EnchantmentContainer.java.patch +++ /dev/null @@ -1,78 +0,0 @@ ---- a/net/minecraft/inventory/container/EnchantmentContainer.java -+++ b/net/minecraft/inventory/container/EnchantmentContainer.java -@@ -56,7 +_,7 @@ - }); - this.func_75146_a(new Slot(this.field_75168_e, 1, 35, 47) { - public boolean func_75214_a(ItemStack p_75214_1_) { -- return p_75214_1_.func_77973_b() == Items.field_196128_bn; -+ return net.minecraftforge.common.Tags.Items.GEMS_LAPIS.func_230235_a_(p_75214_1_.func_77973_b()); - } - }); - -@@ -82,40 +_,28 @@ - this.func_216958_a(IntReferenceHolder.func_221497_a(this.field_185002_i, 2)); - } - -+ private float getPower(net.minecraft.world.World world, net.minecraft.util.math.BlockPos pos) { -+ return world.func_180495_p(pos).getEnchantPowerBonus(world, pos); -+ } -+ - public void func_75130_a(IInventory p_75130_1_) { - if (p_75130_1_ == this.field_75168_e) { - ItemStack itemstack = p_75130_1_.func_70301_a(0); - if (!itemstack.func_190926_b() && itemstack.func_77956_u()) { - this.field_217006_g.func_221486_a((p_217002_2_, p_217002_3_) -> { -- int j = 0; -+ int power = 0; - - for(int k = -1; k <= 1; ++k) { - for(int l = -1; l <= 1; ++l) { - if ((k != 0 || l != 0) && p_217002_2_.func_175623_d(p_217002_3_.func_177982_a(l, 0, k)) && p_217002_2_.func_175623_d(p_217002_3_.func_177982_a(l, 1, k))) { -- if (p_217002_2_.func_180495_p(p_217002_3_.func_177982_a(l * 2, 0, k * 2)).func_203425_a(Blocks.field_150342_X)) { -- ++j; -- } -- -- if (p_217002_2_.func_180495_p(p_217002_3_.func_177982_a(l * 2, 1, k * 2)).func_203425_a(Blocks.field_150342_X)) { -- ++j; -- } -+ power += getPower(p_217002_2_, p_217002_3_.func_177982_a(l * 2, 0, k * 2)); -+ power += getPower(p_217002_2_, p_217002_3_.func_177982_a(l * 2, 1, k * 2)); - - if (l != 0 && k != 0) { -- if (p_217002_2_.func_180495_p(p_217002_3_.func_177982_a(l * 2, 0, k)).func_203425_a(Blocks.field_150342_X)) { -- ++j; -- } -- -- if (p_217002_2_.func_180495_p(p_217002_3_.func_177982_a(l * 2, 1, k)).func_203425_a(Blocks.field_150342_X)) { -- ++j; -- } -- -- if (p_217002_2_.func_180495_p(p_217002_3_.func_177982_a(l, 0, k * 2)).func_203425_a(Blocks.field_150342_X)) { -- ++j; -- } -- -- if (p_217002_2_.func_180495_p(p_217002_3_.func_177982_a(l, 1, k * 2)).func_203425_a(Blocks.field_150342_X)) { -- ++j; -- } -+ power += getPower(p_217002_2_, p_217002_3_.func_177982_a(l * 2, 0, k)); -+ power += getPower(p_217002_2_, p_217002_3_.func_177982_a(l * 2, 1, k)); -+ power += getPower(p_217002_2_, p_217002_3_.func_177982_a(l, 0, k * 2)); -+ power += getPower(p_217002_2_, p_217002_3_.func_177982_a(l, 1, k * 2)); - } - } - } -@@ -124,12 +_,13 @@ - this.field_75169_l.setSeed((long)this.field_178149_f.func_221495_b()); - - for(int i1 = 0; i1 < 3; ++i1) { -- this.field_75167_g[i1] = EnchantmentHelper.func_77514_a(this.field_75169_l, i1, j, itemstack); -+ this.field_75167_g[i1] = EnchantmentHelper.func_77514_a(this.field_75169_l, i1, (int)power, itemstack); - this.field_185001_h[i1] = -1; - this.field_185002_i[i1] = -1; - if (this.field_75167_g[i1] < i1 + 1) { - this.field_75167_g[i1] = 0; - } -+ this.field_75167_g[i1] = net.minecraftforge.event.ForgeEventFactory.onEnchantmentLevelSet(p_217002_2_, p_217002_3_, i1, (int)power, itemstack, field_75167_g[i1]); - } - - for(int j1 = 0; j1 < 3; ++j1) { diff --git a/patches/minecraft/net/minecraft/inventory/container/FurnaceResultSlot.java.patch b/patches/minecraft/net/minecraft/inventory/container/FurnaceResultSlot.java.patch deleted file mode 100644 index 5bdac36112..0000000000 --- a/patches/minecraft/net/minecraft/inventory/container/FurnaceResultSlot.java.patch +++ /dev/null @@ -1,9 +0,0 @@ ---- a/net/minecraft/inventory/container/FurnaceResultSlot.java -+++ b/net/minecraft/inventory/container/FurnaceResultSlot.java -@@ -44,5 +_,6 @@ - } - - this.field_75228_b = 0; -+ net.minecraftforge.fml.hooks.BasicEventHooks.firePlayerSmeltedEvent(this.field_75229_a, p_75208_1_); - } - } diff --git a/patches/minecraft/net/minecraft/inventory/container/GrindstoneContainer.java.patch b/patches/minecraft/net/minecraft/inventory/container/GrindstoneContainer.java.patch deleted file mode 100644 index aa98eda958..0000000000 --- a/patches/minecraft/net/minecraft/inventory/container/GrindstoneContainer.java.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- a/net/minecraft/inventory/container/GrindstoneContainer.java -+++ b/net/minecraft/inventory/container/GrindstoneContainer.java -@@ -141,12 +_,13 @@ - } - - Item item = itemstack.func_77973_b(); -- int k = item.func_77612_l() - itemstack.func_77952_i(); -- int l = item.func_77612_l() - itemstack1.func_77952_i(); -- int i1 = k + l + item.func_77612_l() * 5 / 100; -- i = Math.max(item.func_77612_l() - i1, 0); -+ int k = itemstack.func_77958_k() - itemstack.func_77952_i(); -+ int l = itemstack.func_77958_k() - itemstack1.func_77952_i(); -+ int i1 = k + l + itemstack.func_77958_k() * 5 / 100; -+ i = Math.max(itemstack.func_77958_k() - i1, 0); - itemstack2 = this.func_217011_b(itemstack, itemstack1); -- if (!itemstack2.func_77984_f()) { -+ if (!itemstack2.isRepairable()) i = itemstack.func_77952_i(); -+ if (!itemstack2.func_77984_f() || !itemstack2.isRepairable()) { - if (!ItemStack.func_77989_b(itemstack, itemstack1)) { - this.field_217013_c.func_70299_a(0, ItemStack.field_190927_a); - this.func_75142_b(); diff --git a/patches/minecraft/net/minecraft/inventory/container/PlayerContainer.java.patch b/patches/minecraft/net/minecraft/inventory/container/PlayerContainer.java.patch deleted file mode 100644 index 2e6f887221..0000000000 --- a/patches/minecraft/net/minecraft/inventory/container/PlayerContainer.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/inventory/container/PlayerContainer.java -+++ b/net/minecraft/inventory/container/PlayerContainer.java -@@ -51,7 +_,7 @@ - } - - public boolean func_75214_a(ItemStack p_75214_1_) { -- return equipmentslottype == MobEntity.func_184640_d(p_75214_1_); -+ return p_75214_1_.canEquip(equipmentslottype, field_82862_h); - } - - public boolean func_82869_a(PlayerEntity p_82869_1_) { diff --git a/patches/minecraft/net/minecraft/inventory/container/RecipeBookContainer.java.patch b/patches/minecraft/net/minecraft/inventory/container/RecipeBookContainer.java.patch deleted file mode 100644 index a9a43056c4..0000000000 --- a/patches/minecraft/net/minecraft/inventory/container/RecipeBookContainer.java.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/net/minecraft/inventory/container/RecipeBookContainer.java -+++ b/net/minecraft/inventory/container/RecipeBookContainer.java -@@ -33,6 +_,10 @@ - @OnlyIn(Dist.CLIENT) - public abstract int func_203721_h(); - -+ public java.util.List getRecipeBookCategories() { -+ return net.minecraft.client.util.RecipeBookCategories.func_243236_a(this.func_241850_m()); -+ } -+ - @OnlyIn(Dist.CLIENT) - public abstract RecipeBookCategory func_241850_m(); - } diff --git a/patches/minecraft/net/minecraft/inventory/container/RepairContainer.java.patch b/patches/minecraft/net/minecraft/inventory/container/RepairContainer.java.patch deleted file mode 100644 index dfaf29eeb3..0000000000 --- a/patches/minecraft/net/minecraft/inventory/container/RepairContainer.java.patch +++ /dev/null @@ -1,51 +0,0 @@ ---- a/net/minecraft/inventory/container/RepairContainer.java -+++ b/net/minecraft/inventory/container/RepairContainer.java -@@ -48,6 +_,8 @@ - p_230301_1_.func_82242_a(-this.field_82854_e.func_221495_b()); - } - -+ float breakChance = net.minecraftforge.common.ForgeHooks.onAnvilRepair(p_230301_1_, p_230301_2_, RepairContainer.this.field_234643_d_.func_70301_a(0), RepairContainer.this.field_234643_d_.func_70301_a(1)); -+ - this.field_234643_d_.func_70299_a(0, ItemStack.field_190927_a); - if (this.field_82856_l > 0) { - ItemStack itemstack = this.field_234643_d_.func_70301_a(1); -@@ -64,7 +_,7 @@ - this.field_82854_e.func_221494_a(0); - this.field_234644_e_.func_221486_a((p_234633_1_, p_234633_2_) -> { - BlockState blockstate = p_234633_1_.func_180495_p(p_234633_2_); -- if (!p_230301_1_.field_71075_bZ.field_75098_d && blockstate.func_235714_a_(BlockTags.field_200572_k) && p_230301_1_.func_70681_au().nextFloat() < 0.12F) { -+ if (!p_230301_1_.field_71075_bZ.field_75098_d && blockstate.func_235714_a_(BlockTags.field_200572_k) && p_230301_1_.func_70681_au().nextFloat() < breakChance) { - BlockState blockstate1 = AnvilBlock.func_196433_f(blockstate); - if (blockstate1 == null) { - p_234633_1_.func_217377_a(p_234633_2_, false); -@@ -96,8 +_,11 @@ - Map map = EnchantmentHelper.func_82781_a(itemstack1); - j = j + itemstack.func_82838_A() + (itemstack2.func_190926_b() ? 0 : itemstack2.func_82838_A()); - this.field_82856_l = 0; -+ boolean flag = false; -+ - if (!itemstack2.func_190926_b()) { -- boolean flag = itemstack2.func_77973_b() == Items.field_151134_bR && !EnchantedBookItem.func_92110_g(itemstack2).isEmpty(); -+ if (!net.minecraftforge.common.ForgeHooks.onAnvilChange(this, itemstack, itemstack2, field_234642_c_, field_82857_m, j, this.field_234645_f_)) return; -+ flag = itemstack2.func_77973_b() == Items.field_151134_bR && !EnchantedBookItem.func_92110_g(itemstack2).isEmpty(); - if (itemstack1.func_77984_f() && itemstack1.func_77973_b().func_82789_a(itemstack, itemstack2)) { - int l2 = Math.min(itemstack1.func_77952_i(), itemstack1.func_77958_k() / 4); - if (l2 <= 0) { -@@ -214,6 +_,7 @@ - i += k; - itemstack1.func_200302_a(new StringTextComponent(this.field_82857_m)); - } -+ if (flag && !itemstack1.isBookEnchantable(itemstack2)) itemstack1 = ItemStack.field_190927_a; - - this.field_82854_e.func_221494_a(j + i); - if (i <= 0) { -@@ -268,5 +_,9 @@ - @OnlyIn(Dist.CLIENT) - public int func_216976_f() { - return this.field_82854_e.func_221495_b(); -+ } -+ -+ public void setMaximumCost(int value) { -+ this.field_82854_e.func_221494_a(value); - } - } diff --git a/patches/minecraft/net/minecraft/item/ArmorItem.java.patch b/patches/minecraft/net/minecraft/item/ArmorItem.java.patch deleted file mode 100644 index 3233ca862b..0000000000 --- a/patches/minecraft/net/minecraft/item/ArmorItem.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/item/ArmorItem.java -+++ b/net/minecraft/item/ArmorItem.java -@@ -69,7 +_,7 @@ - UUID uuid = field_185084_n[p_i48534_2_.func_188454_b()]; - builder.put(Attributes.field_233826_i_, new AttributeModifier(uuid, "Armor modifier", (double)this.field_77879_b, AttributeModifier.Operation.ADDITION)); - builder.put(Attributes.field_233827_j_, new AttributeModifier(uuid, "Armor toughness", (double)this.field_189415_e, AttributeModifier.Operation.ADDITION)); -- if (p_i48534_1_ == ArmorMaterial.NETHERITE) { -+ if (this.field_234655_c_ > 0) { - builder.put(Attributes.field_233820_c_, new AttributeModifier(uuid, "Armor knockback resistance", (double)this.field_234655_c_, AttributeModifier.Operation.ADDITION)); - } - diff --git a/patches/minecraft/net/minecraft/item/ArrowItem.java.patch b/patches/minecraft/net/minecraft/item/ArrowItem.java.patch deleted file mode 100644 index fd842aed71..0000000000 --- a/patches/minecraft/net/minecraft/item/ArrowItem.java.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/net/minecraft/item/ArrowItem.java -+++ b/net/minecraft/item/ArrowItem.java -@@ -15,4 +_,9 @@ - arrowentity.func_184555_a(p_200887_2_); - return arrowentity; - } -+ -+ public boolean isInfinite(ItemStack stack, ItemStack bow, net.minecraft.entity.player.PlayerEntity player) { -+ int enchant = net.minecraft.enchantment.EnchantmentHelper.func_77506_a(net.minecraft.enchantment.Enchantments.field_185312_x, bow); -+ return enchant <= 0 ? false : this.getClass() == ArrowItem.class; -+ } - } diff --git a/patches/minecraft/net/minecraft/item/AxeItem.java.patch b/patches/minecraft/net/minecraft/item/AxeItem.java.patch deleted file mode 100644 index 21dc3f76e0..0000000000 --- a/patches/minecraft/net/minecraft/item/AxeItem.java.patch +++ /dev/null @@ -1,38 +0,0 @@ ---- a/net/minecraft/item/AxeItem.java -+++ b/net/minecraft/item/AxeItem.java -@@ -22,7 +_,7 @@ - protected static final Map field_203176_a = (new Builder()).put(Blocks.field_196626_Q, Blocks.field_209389_ab).put(Blocks.field_196617_K, Blocks.field_203204_R).put(Blocks.field_196639_V, Blocks.field_209394_ag).put(Blocks.field_196623_P, Blocks.field_203209_W).put(Blocks.field_196637_U, Blocks.field_209393_af).put(Blocks.field_196621_O, Blocks.field_203208_V).put(Blocks.field_196631_S, Blocks.field_209391_ad).put(Blocks.field_196619_M, Blocks.field_203206_T).put(Blocks.field_196634_T, Blocks.field_209392_ae).put(Blocks.field_196620_N, Blocks.field_203207_U).put(Blocks.field_196629_R, Blocks.field_209390_ac).put(Blocks.field_196618_L, Blocks.field_203205_S).put(Blocks.field_235368_mh_, Blocks.field_235369_mi_).put(Blocks.field_235370_mj_, Blocks.field_235371_mk_).put(Blocks.field_235377_mq_, Blocks.field_235378_mr_).put(Blocks.field_235379_ms_, Blocks.field_235380_mt_).build(); - - public AxeItem(IItemTier p_i48530_1_, float p_i48530_2_, float p_i48530_3_, Item.Properties p_i48530_4_) { -- super(p_i48530_2_, p_i48530_3_, p_i48530_1_, field_150917_d_, p_i48530_4_); -+ super(p_i48530_2_, p_i48530_3_, p_i48530_1_, field_150917_d_, p_i48530_4_.addToolType(net.minecraftforge.common.ToolType.AXE, p_i48530_1_.func_200925_d())); - } - - public float func_150893_a(ItemStack p_150893_1_, BlockState p_150893_2_) { -@@ -34,12 +_,12 @@ - World world = p_195939_1_.func_195991_k(); - BlockPos blockpos = p_195939_1_.func_195995_a(); - BlockState blockstate = world.func_180495_p(blockpos); -- Block block = field_203176_a.get(blockstate.func_177230_c()); -+ BlockState block = blockstate.getToolModifiedState(world, blockpos, p_195939_1_.func_195999_j(), p_195939_1_.func_195996_i(), net.minecraftforge.common.ToolType.AXE); - if (block != null) { - PlayerEntity playerentity = p_195939_1_.func_195999_j(); - world.func_184133_a(playerentity, blockpos, SoundEvents.field_203255_y, SoundCategory.BLOCKS, 1.0F, 1.0F); - if (!world.field_72995_K) { -- world.func_180501_a(blockpos, block.func_176223_P().func_206870_a(RotatedPillarBlock.field_176298_M, blockstate.func_177229_b(RotatedPillarBlock.field_176298_M)), 11); -+ world.func_180501_a(blockpos, block, 11); - if (playerentity != null) { - p_195939_1_.func_195996_i().func_222118_a(1, playerentity, (p_220040_1_) -> { - p_220040_1_.func_213334_d(p_195939_1_.func_221531_n()); -@@ -51,5 +_,11 @@ - } else { - return ActionResultType.PASS; - } -+ } -+ -+ @javax.annotation.Nullable -+ public static BlockState getAxeStrippingState(BlockState originalState) { -+ Block block = field_203176_a.get(originalState.func_177230_c()); -+ return block != null ? block.func_176223_P().func_206870_a(RotatedPillarBlock.field_176298_M, originalState.func_177229_b(RotatedPillarBlock.field_176298_M)) : null; - } - } diff --git a/patches/minecraft/net/minecraft/item/BlockItem.java.patch b/patches/minecraft/net/minecraft/item/BlockItem.java.patch deleted file mode 100644 index 2348e787f2..0000000000 --- a/patches/minecraft/net/minecraft/item/BlockItem.java.patch +++ /dev/null @@ -1,49 +0,0 @@ ---- a/net/minecraft/item/BlockItem.java -+++ b/net/minecraft/item/BlockItem.java -@@ -69,8 +_,8 @@ - } - } - -- SoundType soundtype = blockstate1.func_215695_r(); -- world.func_184133_a(playerentity, blockpos, this.func_219983_a(blockstate1), SoundCategory.BLOCKS, (soundtype.func_185843_a() + 1.0F) / 2.0F, soundtype.func_185847_b() * 0.8F); -+ SoundType soundtype = blockstate1.getSoundType(world, blockpos, p_195942_1_.func_195999_j()); -+ world.func_184133_a(playerentity, blockpos, this.getPlaceSound(blockstate1, world, blockpos, p_195942_1_.func_195999_j()), SoundCategory.BLOCKS, (soundtype.func_185843_a() + 1.0F) / 2.0F, soundtype.func_185847_b() * 0.8F); - if (playerentity == null || !playerentity.field_71075_bZ.field_75098_d) { - itemstack.func_190918_g(1); - } -@@ -81,10 +_,16 @@ - } - } - -+ @Deprecated //Forge: Use more sensitive version {@link BlockItem#getPlaceSound(BlockState, IBlockReader, BlockPos, Entity) } - protected SoundEvent func_219983_a(BlockState p_219983_1_) { - return p_219983_1_.func_215695_r().func_185841_e(); - } - -+ //Forge: Sensitive version of BlockItem#getPlaceSound -+ protected SoundEvent getPlaceSound(BlockState state, World world, BlockPos pos, PlayerEntity entity) { -+ return state.getSoundType(world, pos, entity).func_185841_e(); -+ } -+ - @Nullable - public BlockItemUseContext func_219984_b(BlockItemUseContext p_219984_1_) { - return p_219984_1_; -@@ -192,10 +_,18 @@ - } - - public Block func_179223_d() { -+ return this.getBlockRaw() == null ? null : this.getBlockRaw().delegate.get(); -+ } -+ -+ private Block getBlockRaw() { - return this.field_150939_a; - } - - public void func_195946_a(Map p_195946_1_, Item p_195946_2_) { - p_195946_1_.put(this.func_179223_d(), p_195946_2_); -+ } -+ -+ public void removeFromBlockToItemMap(Map blockToItemMap, Item itemIn) { -+ blockToItemMap.remove(this.func_179223_d()); - } - } diff --git a/patches/minecraft/net/minecraft/item/BoneMealItem.java.patch b/patches/minecraft/net/minecraft/item/BoneMealItem.java.patch deleted file mode 100644 index 23b72c81a3..0000000000 --- a/patches/minecraft/net/minecraft/item/BoneMealItem.java.patch +++ /dev/null @@ -1,38 +0,0 @@ ---- a/net/minecraft/item/BoneMealItem.java -+++ b/net/minecraft/item/BoneMealItem.java -@@ -30,7 +_,7 @@ - World world = p_195939_1_.func_195991_k(); - BlockPos blockpos = p_195939_1_.func_195995_a(); - BlockPos blockpos1 = blockpos.func_177972_a(p_195939_1_.func_196000_l()); -- if (func_195966_a(p_195939_1_.func_195996_i(), world, blockpos)) { -+ if (applyBonemeal(p_195939_1_.func_195996_i(), world, blockpos, p_195939_1_.func_195999_j())) { - if (!world.field_72995_K) { - world.func_217379_c(2005, blockpos, 0); - } -@@ -51,8 +_,17 @@ - } - } - -+ @Deprecated //Forge: Use Player/Hand version - public static boolean func_195966_a(ItemStack p_195966_0_, World p_195966_1_, BlockPos p_195966_2_) { -+ if (p_195966_1_ instanceof net.minecraft.world.server.ServerWorld) -+ return applyBonemeal(p_195966_0_, p_195966_1_, p_195966_2_, net.minecraftforge.common.util.FakePlayerFactory.getMinecraft((net.minecraft.world.server.ServerWorld)p_195966_1_)); -+ return false; -+ } -+ -+ public static boolean applyBonemeal(ItemStack p_195966_0_, World p_195966_1_, BlockPos p_195966_2_, net.minecraft.entity.player.PlayerEntity player) { - BlockState blockstate = p_195966_1_.func_180495_p(p_195966_2_); -+ int hook = net.minecraftforge.event.ForgeEventFactory.onApplyBonemeal(player, p_195966_1_, p_195966_2_, blockstate, p_195966_0_); -+ if (hook != 0) return hook > 0; - if (blockstate.func_177230_c() instanceof IGrowable) { - IGrowable igrowable = (IGrowable)blockstate.func_177230_c(); - if (igrowable.func_176473_a(p_195966_1_, p_195966_2_, blockstate, p_195966_1_.field_72995_K)) { -@@ -128,7 +_,7 @@ - } - - BlockState blockstate = p_195965_0_.func_180495_p(p_195965_1_); -- if (!blockstate.func_196958_f()) { -+ if (!blockstate.isAir(p_195965_0_, p_195965_1_)) { - double d0 = 0.5D; - double d1; - if (blockstate.func_203425_a(Blocks.field_150355_j)) { diff --git a/patches/minecraft/net/minecraft/item/BowItem.java.patch b/patches/minecraft/net/minecraft/item/BowItem.java.patch deleted file mode 100644 index 086c9c57ac..0000000000 --- a/patches/minecraft/net/minecraft/item/BowItem.java.patch +++ /dev/null @@ -1,50 +0,0 @@ ---- a/net/minecraft/item/BowItem.java -+++ b/net/minecraft/item/BowItem.java -@@ -24,18 +_,23 @@ - PlayerEntity playerentity = (PlayerEntity)p_77615_3_; - boolean flag = playerentity.field_71075_bZ.field_75098_d || EnchantmentHelper.func_77506_a(Enchantments.field_185312_x, p_77615_1_) > 0; - ItemStack itemstack = playerentity.func_213356_f(p_77615_1_); -+ -+ int i = this.func_77626_a(p_77615_1_) - p_77615_4_; -+ i = net.minecraftforge.event.ForgeEventFactory.onArrowLoose(p_77615_1_, p_77615_2_, playerentity, i, !itemstack.func_190926_b() || flag); -+ if (i < 0) return; -+ - if (!itemstack.func_190926_b() || flag) { - if (itemstack.func_190926_b()) { - itemstack = new ItemStack(Items.field_151032_g); - } - -- int i = this.func_77626_a(p_77615_1_) - p_77615_4_; - float f = func_185059_b(i); - if (!((double)f < 0.1D)) { -- boolean flag1 = flag && itemstack.func_77973_b() == Items.field_151032_g; -+ boolean flag1 = playerentity.field_71075_bZ.field_75098_d || (itemstack.func_77973_b() instanceof ArrowItem && ((ArrowItem)itemstack.func_77973_b()).isInfinite(itemstack, p_77615_1_, playerentity)); - if (!p_77615_2_.field_72995_K) { - ArrowItem arrowitem = (ArrowItem)(itemstack.func_77973_b() instanceof ArrowItem ? itemstack.func_77973_b() : Items.field_151032_g); - AbstractArrowEntity abstractarrowentity = arrowitem.func_200887_a(p_77615_2_, itemstack, playerentity); -+ abstractarrowentity = customArrow(abstractarrowentity); - abstractarrowentity.func_234612_a_(playerentity, playerentity.field_70125_A, playerentity.field_70177_z, 0.0F, f * 3.0F, 1.0F); - if (f == 1.0F) { - abstractarrowentity.func_70243_d(true); -@@ -100,6 +_,10 @@ - public ActionResult func_77659_a(World p_77659_1_, PlayerEntity p_77659_2_, Hand p_77659_3_) { - ItemStack itemstack = p_77659_2_.func_184586_b(p_77659_3_); - boolean flag = !p_77659_2_.func_213356_f(itemstack).func_190926_b(); -+ -+ ActionResult ret = net.minecraftforge.event.ForgeEventFactory.onArrowNock(itemstack, p_77659_1_, p_77659_2_, p_77659_3_, flag); -+ if (ret != null) return ret; -+ - if (!p_77659_2_.field_71075_bZ.field_75098_d && !flag) { - return ActionResult.func_226251_d_(itemstack); - } else { -@@ -110,6 +_,10 @@ - - public Predicate func_220004_b() { - return field_220007_a; -+ } -+ -+ public AbstractArrowEntity customArrow(AbstractArrowEntity arrow) { -+ return arrow; - } - - public int func_230305_d_() { diff --git a/patches/minecraft/net/minecraft/item/BucketItem.java.patch b/patches/minecraft/net/minecraft/item/BucketItem.java.patch deleted file mode 100644 index b352028d79..0000000000 --- a/patches/minecraft/net/minecraft/item/BucketItem.java.patch +++ /dev/null @@ -1,87 +0,0 @@ ---- a/net/minecraft/item/BucketItem.java -+++ b/net/minecraft/item/BucketItem.java -@@ -32,14 +_,28 @@ - public class BucketItem extends Item { - private final Fluid field_77876_a; - -+ // Forge: Use the other constructor that takes a Supplier -+ @Deprecated - public BucketItem(Fluid p_i49025_1_, Item.Properties p_i49025_2_) { - super(p_i49025_2_); - this.field_77876_a = p_i49025_1_; -+ this.fluidSupplier = p_i49025_1_.delegate; -+ } -+ -+ /** -+ * @param supplier A fluid supplier such as {@link net.minecraftforge.fml.RegistryObject} -+ */ -+ public BucketItem(java.util.function.Supplier supplier, Item.Properties builder) { -+ super(builder); -+ this.field_77876_a = null; -+ this.fluidSupplier = supplier; - } - - public ActionResult func_77659_a(World p_77659_1_, PlayerEntity p_77659_2_, Hand p_77659_3_) { - ItemStack itemstack = p_77659_2_.func_184586_b(p_77659_3_); - RayTraceResult raytraceresult = func_219968_a(p_77659_1_, p_77659_2_, this.field_77876_a == Fluids.field_204541_a ? RayTraceContext.FluidMode.SOURCE_ONLY : RayTraceContext.FluidMode.NONE); -+ ActionResult ret = net.minecraftforge.event.ForgeEventFactory.onBucketUse(p_77659_2_, p_77659_1_, itemstack, raytraceresult); -+ if (ret != null) return ret; - if (raytraceresult.func_216346_c() == RayTraceResult.Type.MISS) { - return ActionResult.func_226250_c_(itemstack); - } else if (raytraceresult.func_216346_c() != RayTraceResult.Type.BLOCK) { -@@ -56,7 +_,10 @@ - Fluid fluid = ((IBucketPickupHandler)blockstate1.func_177230_c()).func_204508_a(p_77659_1_, blockpos, blockstate1); - if (fluid != Fluids.field_204541_a) { - p_77659_2_.func_71029_a(Stats.field_75929_E.func_199076_b(this)); -- p_77659_2_.func_184185_a(fluid.func_207185_a(FluidTags.field_206960_b) ? SoundEvents.field_187633_N : SoundEvents.field_187630_M, 1.0F, 1.0F); -+ -+ SoundEvent soundevent = this.field_77876_a.getAttributes().getFillSound(); -+ if (soundevent == null) soundevent = fluid.func_207185_a(FluidTags.field_206960_b) ? SoundEvents.field_187633_N : SoundEvents.field_187630_M; -+ p_77659_2_.func_184185_a(soundevent, 1.0F, 1.0F); - ItemStack itemstack1 = DrinkHelper.func_242398_a(itemstack, p_77659_2_, new ItemStack(fluid.func_204524_b())); - if (!p_77659_1_.field_72995_K) { - CriteriaTriggers.field_204813_j.func_204817_a((ServerPlayerEntity)p_77659_2_, new ItemStack(fluid.func_204524_b())); -@@ -69,7 +_,7 @@ - return ActionResult.func_226251_d_(itemstack); - } else { - BlockState blockstate = p_77659_1_.func_180495_p(blockpos); -- BlockPos blockpos2 = blockstate.func_177230_c() instanceof ILiquidContainer && this.field_77876_a == Fluids.field_204546_a ? blockpos : blockpos1; -+ BlockPos blockpos2 = canBlockContainFluid(p_77659_1_, blockpos, blockstate) ? blockpos : blockpos1; - if (this.func_180616_a(p_77659_2_, p_77659_1_, blockpos2, blockraytraceresult)) { - this.func_203792_a(p_77659_1_, itemstack, blockpos2); - if (p_77659_2_ instanceof ServerPlayerEntity) { -@@ -117,7 +_,7 @@ - } - - return true; -- } else if (block instanceof ILiquidContainer && this.field_77876_a == Fluids.field_204546_a) { -+ } else if (block instanceof ILiquidContainer && ((ILiquidContainer)block).func_204510_a(p_180616_2_,p_180616_3_,blockstate,field_77876_a)) { - ((ILiquidContainer)block).func_204509_a(p_180616_2_, p_180616_3_, blockstate, ((FlowingFluid)this.field_77876_a).func_207204_a(false)); - this.func_203791_b(p_180616_1_, p_180616_2_, p_180616_3_); - return true; -@@ -137,7 +_,24 @@ - } - - protected void func_203791_b(@Nullable PlayerEntity p_203791_1_, IWorld p_203791_2_, BlockPos p_203791_3_) { -- SoundEvent soundevent = this.field_77876_a.func_207185_a(FluidTags.field_206960_b) ? SoundEvents.field_187627_L : SoundEvents.field_187624_K; -+ SoundEvent soundevent = this.field_77876_a.getAttributes().getEmptySound(); -+ if(soundevent == null) soundevent = this.field_77876_a.func_207185_a(FluidTags.field_206960_b) ? SoundEvents.field_187627_L : SoundEvents.field_187624_K; - p_203791_2_.func_184133_a(p_203791_1_, p_203791_3_, soundevent, SoundCategory.BLOCKS, 1.0F, 1.0F); -+ } -+ -+ @Override -+ public net.minecraftforge.common.capabilities.ICapabilityProvider initCapabilities(ItemStack stack, @Nullable net.minecraft.nbt.CompoundNBT nbt) { -+ if (this.getClass() == BucketItem.class) -+ return new net.minecraftforge.fluids.capability.wrappers.FluidBucketWrapper(stack); -+ else -+ return super.initCapabilities(stack, nbt); -+ } -+ -+ private final java.util.function.Supplier fluidSupplier; -+ public Fluid getFluid() { return fluidSupplier.get(); } -+ -+ private boolean canBlockContainFluid(World worldIn, BlockPos posIn, BlockState blockstate) -+ { -+ return blockstate.func_177230_c() instanceof ILiquidContainer && ((ILiquidContainer)blockstate.func_177230_c()).func_204510_a(worldIn, posIn, blockstate, this.field_77876_a); - } - } diff --git a/patches/minecraft/net/minecraft/item/ChorusFruitItem.java.patch b/patches/minecraft/net/minecraft/item/ChorusFruitItem.java.patch deleted file mode 100644 index 8ee9db06ba..0000000000 --- a/patches/minecraft/net/minecraft/item/ChorusFruitItem.java.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/net/minecraft/item/ChorusFruitItem.java -+++ b/net/minecraft/item/ChorusFruitItem.java -@@ -29,7 +_,9 @@ - p_77654_3_.func_184210_p(); - } - -- if (p_77654_3_.func_213373_a(d3, d4, d5, true)) { -+ net.minecraftforge.event.entity.living.EntityTeleportEvent.ChorusFruit event = net.minecraftforge.event.ForgeEventFactory.onChorusFruitTeleport(p_77654_3_, d3, d4, d5); -+ if (event.isCanceled()) return itemstack; -+ if (p_77654_3_.func_213373_a(event.getTargetX(), event.getTargetY(), event.getTargetZ(), true)) { - SoundEvent soundevent = p_77654_3_ instanceof FoxEntity ? SoundEvents.field_232710_ez_ : SoundEvents.field_187544_ad; - p_77654_2_.func_184148_a((PlayerEntity)null, d0, d1, d2, soundevent, SoundCategory.PLAYERS, 1.0F, 1.0F); - p_77654_3_.func_184185_a(soundevent, 1.0F, 1.0F); diff --git a/patches/minecraft/net/minecraft/item/DyeColor.java.patch b/patches/minecraft/net/minecraft/item/DyeColor.java.patch deleted file mode 100644 index 0d66c222ed..0000000000 --- a/patches/minecraft/net/minecraft/item/DyeColor.java.patch +++ /dev/null @@ -1,45 +0,0 @@ ---- a/net/minecraft/item/DyeColor.java -+++ b/net/minecraft/item/DyeColor.java -@@ -41,6 +_,7 @@ - private final int field_196066_w; - private final float[] field_193352_x; - private final int field_196067_y; -+ private final net.minecraftforge.common.Tags.IOptionalNamedTag tag; - private final int field_218390_z; - - private DyeColor(int p_i50049_3_, String p_i50049_4_, int p_i50049_5_, MaterialColor p_i50049_6_, int p_i50049_7_, int p_i50049_8_) { -@@ -53,6 +_,7 @@ - int j = (p_i50049_5_ & '\uff00') >> 8; - int k = (p_i50049_5_ & 255) >> 0; - this.field_196066_w = k << 16 | j << 8 | i << 0; -+ this.tag = net.minecraft.tags.ItemTags.createOptional(new net.minecraft.util.ResourceLocation("forge", "dyes/" + p_i50049_4_)); - this.field_193352_x = new float[]{(float)i / 255.0F, (float)j / 255.0F, (float)k / 255.0F}; - this.field_196067_y = p_i50049_7_; - } -@@ -110,5 +_,26 @@ - - public String func_176610_l() { - return this.field_176785_v; -+ } -+ -+ public int getColorValue() { -+ return field_193351_w; -+ } -+ -+ public net.minecraftforge.common.Tags.IOptionalNamedTag getTag() { -+ return tag; -+ } -+ -+ @Nullable -+ public static DyeColor getColor(ItemStack stack) { -+ if (stack.func_77973_b() instanceof DyeItem) -+ return ((DyeItem)stack.func_77973_b()).func_195962_g(); -+ -+ for (DyeColor color : field_196062_q) { -+ if (stack.func_77973_b().func_206844_a(color.getTag())) -+ return color; -+ } -+ -+ return null; - } - } diff --git a/patches/minecraft/net/minecraft/item/DyeableHorseArmorItem.java.patch b/patches/minecraft/net/minecraft/item/DyeableHorseArmorItem.java.patch deleted file mode 100644 index 7b90311f89..0000000000 --- a/patches/minecraft/net/minecraft/item/DyeableHorseArmorItem.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/item/DyeableHorseArmorItem.java -+++ b/net/minecraft/item/DyeableHorseArmorItem.java -@@ -4,4 +_,7 @@ - public DyeableHorseArmorItem(int p_i50047_1_, String p_i50047_2_, Item.Properties p_i50047_3_) { - super(p_i50047_1_, p_i50047_2_, p_i50047_3_); - } -+ public DyeableHorseArmorItem(int p_i50047_1_, net.minecraft.util.ResourceLocation texture, Item.Properties p_i50047_3_) { -+ super(p_i50047_1_, texture, p_i50047_3_); -+ } - } diff --git a/patches/minecraft/net/minecraft/item/ElytraItem.java.patch b/patches/minecraft/net/minecraft/item/ElytraItem.java.patch deleted file mode 100644 index 0962ccf458..0000000000 --- a/patches/minecraft/net/minecraft/item/ElytraItem.java.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/item/ElytraItem.java -+++ b/net/minecraft/item/ElytraItem.java -@@ -35,4 +_,17 @@ - return ActionResult.func_226251_d_(itemstack); - } - } -+ -+ @Override -+ public boolean canElytraFly(ItemStack stack, net.minecraft.entity.LivingEntity entity) { -+ return ElytraItem.func_185069_d(stack); -+ } -+ -+ @Override -+ public boolean elytraFlightTick(ItemStack stack, net.minecraft.entity.LivingEntity entity, int flightTicks) { -+ if (!entity.field_70170_p.field_72995_K && (flightTicks + 1) % 20 == 0) { -+ stack.func_222118_a(1, entity, e -> e.func_213361_c(net.minecraft.inventory.EquipmentSlotType.CHEST)); -+ } -+ return true; -+ } - } diff --git a/patches/minecraft/net/minecraft/item/FilledMapItem.java.patch b/patches/minecraft/net/minecraft/item/FilledMapItem.java.patch deleted file mode 100644 index 9356ddf469..0000000000 --- a/patches/minecraft/net/minecraft/item/FilledMapItem.java.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- a/net/minecraft/item/FilledMapItem.java -+++ b/net/minecraft/item/FilledMapItem.java -@@ -52,6 +_,16 @@ - - @Nullable - public static MapData func_195950_a(ItemStack p_195950_0_, World p_195950_1_) { -+ // FORGE: Add instance method for mods to override -+ Item map = p_195950_0_.func_77973_b(); -+ if (map instanceof FilledMapItem) { -+ return ((FilledMapItem)map).getCustomMapData(p_195950_0_, p_195950_1_); -+ } -+ return null; -+ } -+ -+ @Nullable -+ protected MapData getCustomMapData(ItemStack p_195950_0_, World p_195950_1_) { - MapData mapdata = func_219994_a(p_195950_0_, p_195950_1_); - if (mapdata == null && p_195950_1_ instanceof ServerWorld) { - mapdata = func_195951_a(p_195950_0_, p_195950_1_, p_195950_1_.func_72912_H().func_76079_c(), p_195950_1_.func_72912_H().func_76074_e(), 3, false, false, p_195950_1_.func_234923_W_()); diff --git a/patches/minecraft/net/minecraft/item/FishBucketItem.java.patch b/patches/minecraft/net/minecraft/item/FishBucketItem.java.patch deleted file mode 100644 index 7f8aaaa63a..0000000000 --- a/patches/minecraft/net/minecraft/item/FishBucketItem.java.patch +++ /dev/null @@ -1,31 +0,0 @@ ---- a/net/minecraft/item/FishBucketItem.java -+++ b/net/minecraft/item/FishBucketItem.java -@@ -27,9 +_,17 @@ - public class FishBucketItem extends BucketItem { - private final EntityType field_203794_a; - -+ @Deprecated - public FishBucketItem(EntityType p_i49022_1_, Fluid p_i49022_2_, Item.Properties p_i49022_3_) { - super(p_i49022_2_, p_i49022_3_); - this.field_203794_a = p_i49022_1_; -+ this.fishTypeSupplier = () -> p_i49022_1_; -+ } -+ -+ public FishBucketItem(java.util.function.Supplier> fishTypeIn, java.util.function.Supplier p_i49022_2_, Item.Properties builder) { -+ super(p_i49022_2_, builder); -+ this.field_203794_a = null; -+ this.fishTypeSupplier = fishTypeIn; - } - - public void func_203792_a(World p_203792_1_, ItemStack p_203792_2_, BlockPos p_203792_3_) { -@@ -79,5 +_,10 @@ - } - } - -+ } -+ -+ private final java.util.function.Supplier> fishTypeSupplier; -+ protected EntityType getFishType() { -+ return fishTypeSupplier.get(); - } - } diff --git a/patches/minecraft/net/minecraft/item/Food.java.patch b/patches/minecraft/net/minecraft/item/Food.java.patch deleted file mode 100644 index 85ae4920cb..0000000000 --- a/patches/minecraft/net/minecraft/item/Food.java.patch +++ /dev/null @@ -1,73 +0,0 @@ ---- a/net/minecraft/item/Food.java -+++ b/net/minecraft/item/Food.java -@@ -11,15 +_,26 @@ - private final boolean field_221472_c; - private final boolean field_221473_d; - private final boolean field_221474_e; -- private final List> field_221475_f; -- -+ private final List, Float>> field_221475_f; -+ -+ private Food(Food.Builder builder) { -+ this.field_221470_a = builder.field_221458_a; -+ this.field_221471_b = builder.field_221459_b; -+ this.field_221472_c = builder.field_221460_c; -+ this.field_221473_d = builder.field_221461_d; -+ this.field_221474_e = builder.field_221462_e; -+ this.field_221475_f = builder.field_221463_f; -+ } -+ -+ // Forge: Use builder method instead -+ @Deprecated - private Food(int p_i50106_1_, float p_i50106_2_, boolean p_i50106_3_, boolean p_i50106_4_, boolean p_i50106_5_, List> p_i50106_6_) { - this.field_221470_a = p_i50106_1_; - this.field_221471_b = p_i50106_2_; - this.field_221472_c = p_i50106_3_; - this.field_221473_d = p_i50106_4_; - this.field_221474_e = p_i50106_5_; -- this.field_221475_f = p_i50106_6_; -+ this.field_221475_f = p_i50106_6_.stream().map(pair -> Pair., Float>of(pair::getFirst, pair.getSecond())).collect(java.util.stream.Collectors.toList()); - } - - public int func_221466_a() { -@@ -43,7 +_,7 @@ - } - - public List> func_221464_f() { -- return this.field_221475_f; -+ return this.field_221475_f.stream().map(pair -> Pair.of(pair.getFirst() != null ? pair.getFirst().get() : null, pair.getSecond())).collect(java.util.stream.Collectors.toList()); - } - - public static class Builder { -@@ -52,7 +_,7 @@ - private boolean field_221460_c; - private boolean field_221461_d; - private boolean field_221462_e; -- private final List> field_221463_f = Lists.newArrayList(); -+ private final List, Float>> field_221463_f = Lists.newArrayList(); - - public Food.Builder func_221456_a(int p_221456_1_) { - this.field_221458_a = p_221456_1_; -@@ -79,13 +_,20 @@ - return this; - } - -+ public Food.Builder effect(java.util.function.Supplier effectIn, float probability) { -+ this.field_221463_f.add(Pair.of(effectIn, probability)); -+ return this; -+ } -+ -+ // Forge: Use supplier method instead -+ @Deprecated - public Food.Builder func_221452_a(EffectInstance p_221452_1_, float p_221452_2_) { -- this.field_221463_f.add(Pair.of(p_221452_1_, p_221452_2_)); -+ this.field_221463_f.add(Pair.of(() -> p_221452_1_, p_221452_2_)); - return this; - } - - public Food func_221453_d() { -- return new Food(this.field_221458_a, this.field_221459_b, this.field_221460_c, this.field_221461_d, this.field_221462_e, this.field_221463_f); -+ return new Food(this); - } - } - } diff --git a/patches/minecraft/net/minecraft/item/HoeItem.java.patch b/patches/minecraft/net/minecraft/item/HoeItem.java.patch deleted file mode 100644 index 8a5b881a49..0000000000 --- a/patches/minecraft/net/minecraft/item/HoeItem.java.patch +++ /dev/null @@ -1,33 +0,0 @@ ---- a/net/minecraft/item/HoeItem.java -+++ b/net/minecraft/item/HoeItem.java -@@ -21,14 +_,16 @@ - protected static final Map field_195973_b = Maps.newHashMap(ImmutableMap.of(Blocks.field_196658_i, Blocks.field_150458_ak.func_176223_P(), Blocks.field_185774_da, Blocks.field_150458_ak.func_176223_P(), Blocks.field_150346_d, Blocks.field_150458_ak.func_176223_P(), Blocks.field_196660_k, Blocks.field_150346_d.func_176223_P())); - - public HoeItem(IItemTier p_i231595_1_, int p_i231595_2_, float p_i231595_3_, Item.Properties p_i231595_4_) { -- super((float)p_i231595_2_, p_i231595_3_, p_i231595_1_, field_234683_c_, p_i231595_4_); -+ super((float)p_i231595_2_, p_i231595_3_, p_i231595_1_, field_234683_c_, p_i231595_4_.addToolType(net.minecraftforge.common.ToolType.HOE, p_i231595_1_.func_200925_d())); - } - - public ActionResultType func_195939_a(ItemUseContext p_195939_1_) { - World world = p_195939_1_.func_195991_k(); - BlockPos blockpos = p_195939_1_.func_195995_a(); -- if (p_195939_1_.func_196000_l() != Direction.DOWN && world.func_180495_p(blockpos.func_177984_a()).func_196958_f()) { -- BlockState blockstate = field_195973_b.get(world.func_180495_p(blockpos).func_177230_c()); -+ int hook = net.minecraftforge.event.ForgeEventFactory.onHoeUse(p_195939_1_); -+ if (hook != 0) return hook > 0 ? ActionResultType.SUCCESS : ActionResultType.FAIL; -+ if (p_195939_1_.func_196000_l() != Direction.DOWN && world.func_175623_d(blockpos.func_177984_a())) { -+ BlockState blockstate = world.func_180495_p(blockpos).getToolModifiedState(world, blockpos, p_195939_1_.func_195999_j(), p_195939_1_.func_195996_i(), net.minecraftforge.common.ToolType.HOE); - if (blockstate != null) { - PlayerEntity playerentity = p_195939_1_.func_195999_j(); - world.func_184133_a(playerentity, blockpos, SoundEvents.field_187693_cj, SoundCategory.BLOCKS, 1.0F, 1.0F); -@@ -46,5 +_,10 @@ - } - - return ActionResultType.PASS; -+ } -+ -+ @javax.annotation.Nullable -+ public static BlockState getHoeTillingState(BlockState originalState) { -+ return field_195973_b.get(originalState.func_177230_c()); - } - } diff --git a/patches/minecraft/net/minecraft/item/HorseArmorItem.java.patch b/patches/minecraft/net/minecraft/item/HorseArmorItem.java.patch deleted file mode 100644 index 92db15755d..0000000000 --- a/patches/minecraft/net/minecraft/item/HorseArmorItem.java.patch +++ /dev/null @@ -1,27 +0,0 @@ ---- a/net/minecraft/item/HorseArmorItem.java -+++ b/net/minecraft/item/HorseArmorItem.java -@@ -6,17 +_,21 @@ - - public class HorseArmorItem extends Item { - private final int field_219978_a; -- private final String field_219979_b; -+ private final ResourceLocation field_219979_b; - - public HorseArmorItem(int p_i50042_1_, String p_i50042_2_, Item.Properties p_i50042_3_) { -+ this(p_i50042_1_, new ResourceLocation("textures/entity/horse/armor/horse_armor_" + p_i50042_2_ + ".png"), p_i50042_3_); -+ } -+ -+ public HorseArmorItem(int p_i50042_1_, ResourceLocation texture, Item.Properties p_i50042_3_) { - super(p_i50042_3_); - this.field_219978_a = p_i50042_1_; -- this.field_219979_b = "textures/entity/horse/armor/horse_armor_" + p_i50042_2_ + ".png"; -+ this.field_219979_b = texture; - } - - @OnlyIn(Dist.CLIENT) - public ResourceLocation func_219976_d() { -- return new ResourceLocation(this.field_219979_b); -+ return field_219979_b; - } - - public int func_219977_e() { diff --git a/patches/minecraft/net/minecraft/item/Item.java.patch b/patches/minecraft/net/minecraft/item/Item.java.patch deleted file mode 100644 index c8313ddb88..0000000000 --- a/patches/minecraft/net/minecraft/item/Item.java.patch +++ /dev/null @@ -1,155 +0,0 @@ ---- a/net/minecraft/item/Item.java -+++ b/net/minecraft/item/Item.java -@@ -40,8 +_,8 @@ - import net.minecraftforge.api.distmarker.Dist; - import net.minecraftforge.api.distmarker.OnlyIn; - --public class Item implements IItemProvider { -- public static final Map field_179220_a = Maps.newHashMap(); -+public class Item extends net.minecraftforge.registries.ForgeRegistryEntry implements IItemProvider, net.minecraftforge.common.extensions.IForgeItem { -+ public static final Map field_179220_a = net.minecraftforge.registries.GameData.getBlockItemMap(); - protected static final UUID field_111210_e = UUID.fromString("CB3F55D3-645C-4F38-A497-9C13A33DB5CF"); - protected static final UUID field_185050_h = UUID.fromString("FA233E1C-4180-4865-B01B-BCCE9785ACA3"); - protected static final Random field_77697_d = new Random(); -@@ -77,6 +_,10 @@ - this.field_77777_bU = p_i48487_1_.field_200920_a; - this.field_219974_q = p_i48487_1_.field_221541_f; - this.field_234684_d_ = p_i48487_1_.field_234688_g_; -+ this.canRepair = p_i48487_1_.canRepair; -+ this.toolClasses.putAll(p_i48487_1_.toolClasses); -+ Object tmp = p_i48487_1_.ister == null ? null : net.minecraftforge.fml.DistExecutor.callWhenOn(Dist.CLIENT, p_i48487_1_.ister); -+ this.ister = tmp == null ? null : () -> (net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer) tmp; - } - - public void func_219972_a(World p_219972_1_, LivingEntity p_219972_2_, ItemStack p_219972_3_, int p_219972_4_) { -@@ -120,10 +_,12 @@ - return this.func_219971_r() ? p_77654_3_.func_213357_a(p_77654_2_, p_77654_1_) : p_77654_1_; - } - -+ @Deprecated // Use ItemStack sensitive version. - public final int func_77639_j() { - return this.field_77777_bU; - } - -+ @Deprecated // Use ItemStack sensitive version. - public final int func_77612_l() { - return this.field_77699_b; - } -@@ -178,10 +_,12 @@ - } - - @Nullable -+ @Deprecated // Use ItemStack sensitive version. - public final Item func_77668_q() { - return this.field_77700_c; - } - -+ @Deprecated // Use ItemStack sensitive version. - public boolean func_77634_r() { - return this.field_77700_c != null; - } -@@ -241,7 +_,7 @@ - } - - public boolean func_77616_k(ItemStack p_77616_1_) { -- return this.func_77639_j() == 1 && this.func_77645_m(); -+ return this.getItemStackLimit(p_77616_1_) == 1 && this.isDamageable(p_77616_1_); - } - - protected static BlockRayTraceResult func_219968_a(World p_219968_0_, PlayerEntity p_219968_1_, RayTraceContext.FluidMode p_219968_2_) { -@@ -254,8 +_,8 @@ - float f5 = MathHelper.func_76126_a(-f * ((float)Math.PI / 180F)); - float f6 = f3 * f4; - float f7 = f2 * f4; -- double d0 = 5.0D; -- Vector3d vector3d1 = vector3d.func_72441_c((double)f6 * 5.0D, (double)f5 * 5.0D, (double)f7 * 5.0D); -+ double d0 = p_219968_1_.func_110148_a(net.minecraftforge.common.ForgeMod.REACH_DISTANCE.get()).func_111126_e();; -+ Vector3d vector3d1 = vector3d.func_72441_c((double)f6 * d0, (double)f5 * d0, (double)f7 * d0); - return p_219968_0_.func_217299_a(new RayTraceContext(vector3d, vector3d1, RayTraceContext.BlockMode.OUTLINE, p_219968_2_, p_219968_1_)); - } - -@@ -271,6 +_,7 @@ - } - - protected boolean func_194125_a(ItemGroup p_194125_1_) { -+ if (getCreativeTabs().stream().anyMatch(tab -> tab == p_194125_1_)) return true; - ItemGroup itemgroup = this.func_77640_w(); - return itemgroup != null && (p_194125_1_ == ItemGroup.field_78027_g || p_194125_1_ == itemgroup); - } -@@ -284,10 +_,44 @@ - return false; - } - -+ @Deprecated // Use ItemStack sensitive version. - public Multimap func_111205_h(EquipmentSlotType p_111205_1_) { - return ImmutableMultimap.of(); - } - -+ @Nullable -+ private final java.util.function.Supplier ister; -+ private final java.util.Map toolClasses = Maps.newHashMap(); -+ private final net.minecraftforge.common.util.ReverseTagWrapper reverseTags = new net.minecraftforge.common.util.ReverseTagWrapper<>(this, net.minecraft.tags.ItemTags::func_199903_a); -+ protected final boolean canRepair; -+ -+ @Override -+ public boolean isRepairable(ItemStack stack) { -+ return canRepair && isDamageable(stack); -+ } -+ -+ @Override -+ public java.util.Set getToolTypes(ItemStack stack) { -+ return toolClasses.keySet(); -+ } -+ -+ @Override -+ public int getHarvestLevel(ItemStack stack, net.minecraftforge.common.ToolType tool, @Nullable PlayerEntity player, @Nullable BlockState blockState) { -+ return toolClasses.getOrDefault(tool, -1); -+ } -+ -+ @OnlyIn(Dist.CLIENT) -+ @Override -+ public final net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer getItemStackTileEntityRenderer() { -+ net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer renderer = ister != null ? ister.get() : null; -+ return renderer != null ? renderer : net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer.field_147719_a; -+ } -+ -+ @Override -+ public java.util.Set getTags() { -+ return reverseTags.getTagNames(); -+ } -+ - public boolean func_219970_i(ItemStack p_219970_1_) { - return p_219970_1_.func_77973_b() == Items.field_222114_py; - } -@@ -333,6 +_,9 @@ - private Rarity field_208104_e = Rarity.COMMON; - private Food field_221541_f; - private boolean field_234688_g_; -+ private boolean canRepair = true; -+ private java.util.Map toolClasses = Maps.newHashMap(); -+ private java.util.function.Supplier> ister; - - public Item.Properties func_221540_a(Food p_221540_1_) { - this.field_221541_f = p_221540_1_; -@@ -375,6 +_,21 @@ - - public Item.Properties func_234689_a_() { - this.field_234688_g_ = true; -+ return this; -+ } -+ -+ public Item.Properties setNoRepair() { -+ canRepair = false; -+ return this; -+ } -+ -+ public Item.Properties addToolType(net.minecraftforge.common.ToolType type, int level) { -+ toolClasses.put(type, level); -+ return this; -+ } -+ -+ public Item.Properties setISTER(java.util.function.Supplier> ister) { -+ this.ister = ister; - return this; - } - } diff --git a/patches/minecraft/net/minecraft/item/ItemGroup.java.patch b/patches/minecraft/net/minecraft/item/ItemGroup.java.patch deleted file mode 100644 index f0ca3d2fdd..0000000000 --- a/patches/minecraft/net/minecraft/item/ItemGroup.java.patch +++ /dev/null @@ -1,133 +0,0 @@ ---- a/net/minecraft/item/ItemGroup.java -+++ b/net/minecraft/item/ItemGroup.java -@@ -101,18 +_,23 @@ - private final String field_78034_o; - private final ITextComponent field_242391_q; - private String field_199784_q; -+ @Deprecated - private String field_78043_p = "items.png"; -+ private net.minecraft.util.ResourceLocation backgroundLocation; - private boolean field_78042_q = true; - private boolean field_78041_r = true; - private EnchantmentType[] field_111230_s = new EnchantmentType[0]; - private ItemStack field_151245_t; - -+ public ItemGroup(String label) { -+ this(-1, label); -+ } -+ - public ItemGroup(int p_i1853_1_, String p_i1853_2_) { -- this.field_78033_n = p_i1853_1_; - this.field_78034_o = p_i1853_2_; - this.field_242391_q = new TranslationTextComponent("itemGroup." + p_i1853_2_); - this.field_151245_t = ItemStack.field_190927_a; -- field_78032_a[p_i1853_1_] = this; -+ this.field_78033_n = addGroupSafe(p_i1853_1_, this); - } - - @OnlyIn(Dist.CLIENT) -@@ -141,16 +_,29 @@ - @OnlyIn(Dist.CLIENT) - public abstract ItemStack func_78016_d(); - -+ /** -+ * @deprecated Forge use {@link #getBackgroundImage()} instead -+ */ - @OnlyIn(Dist.CLIENT) -+ @Deprecated - public String func_78015_f() { - return this.field_78043_p; - } - -+ /** -+ * @deprecated Forge: use {@link #setBackgroundImage(net.minecraft.util.ResourceLocation)} instead -+ */ -+ @Deprecated - public ItemGroup func_78025_a(String p_78025_1_) { - this.field_78043_p = p_78025_1_; - return this; - } - -+ public ItemGroup setBackgroundImage(net.minecraft.util.ResourceLocation texture) { -+ this.backgroundLocation = texture; -+ return this; -+ } -+ - public ItemGroup func_199783_b(String p_199783_1_) { - this.field_199784_q = p_199783_1_; - return this; -@@ -178,11 +_,13 @@ - - @OnlyIn(Dist.CLIENT) - public int func_78020_k() { -+ if (field_78033_n > 11) return ((field_78033_n - 12) % 10) % 5; - return this.field_78033_n % 6; - } - - @OnlyIn(Dist.CLIENT) - public boolean func_78023_l() { -+ if (field_78033_n > 11) return ((field_78033_n - 12) % 10) < 5; - return this.field_78033_n < 6; - } - -@@ -218,5 +_,60 @@ - item.func_150895_a(this, p_78018_1_); - } - -+ } -+ -+ public int getTabPage() { -+ return field_78033_n < 12 ? 0 : ((field_78033_n - 12) / 10) + 1; -+ } -+ -+ public boolean hasSearchBar() { -+ return field_78033_n == field_78027_g.field_78033_n; -+ } -+ -+ /** -+ * Gets the width of the search bar of the creative tab, use this if your -+ * creative tab name overflows together with a custom texture. -+ * -+ * @return The width of the search bar, 89 by default -+ */ -+ public int getSearchbarWidth() { -+ return 89; -+ } -+ -+ @OnlyIn(Dist.CLIENT) -+ public net.minecraft.util.ResourceLocation getBackgroundImage() { -+ if (backgroundLocation != null) return backgroundLocation; //FORGE: allow custom namespace -+ return new net.minecraft.util.ResourceLocation("textures/gui/container/creative_inventory/tab_" + this.func_78015_f()); -+ } -+ -+ private static final net.minecraft.util.ResourceLocation CREATIVE_INVENTORY_TABS = new net.minecraft.util.ResourceLocation("textures/gui/container/creative_inventory/tabs.png"); -+ @OnlyIn(Dist.CLIENT) -+ public net.minecraft.util.ResourceLocation getTabsImage() { -+ return CREATIVE_INVENTORY_TABS; -+ } -+ -+ public int getLabelColor() { -+ return 4210752; -+ } -+ -+ public int getSlotColor() { -+ return -2130706433; -+ } -+ -+ public static synchronized int getGroupCountSafe() { -+ return ItemGroup.field_78032_a.length; -+ } -+ -+ private static synchronized int addGroupSafe(int index, ItemGroup newGroup) { -+ if(index == -1) { -+ index = field_78032_a.length; -+ } -+ if (index >= field_78032_a.length) { -+ ItemGroup[] tmp = new ItemGroup[index + 1]; -+ System.arraycopy(field_78032_a, 0, tmp, 0, field_78032_a.length); -+ field_78032_a = tmp; -+ } -+ field_78032_a[index] = newGroup; -+ return index; - } - } diff --git a/patches/minecraft/net/minecraft/item/ItemStack.java.patch b/patches/minecraft/net/minecraft/item/ItemStack.java.patch deleted file mode 100644 index f71324d267..0000000000 --- a/patches/minecraft/net/minecraft/item/ItemStack.java.patch +++ /dev/null @@ -1,247 +0,0 @@ ---- a/net/minecraft/item/ItemStack.java -+++ b/net/minecraft/item/ItemStack.java -@@ -72,7 +_,7 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; - --public final class ItemStack { -+public final class ItemStack extends net.minecraftforge.common.capabilities.CapabilityProvider implements net.minecraftforge.common.extensions.IForgeItemStack { - public static final Codec field_234691_a_ = RecordCodecBuilder.create((p_234698_0_) -> { - return p_234698_0_.group(Registry.field_212630_s.fieldOf("id").forGetter((p_234706_0_) -> { - return p_234706_0_.field_151002_e; -@@ -82,6 +_,9 @@ - return Optional.ofNullable(p_234704_0_.field_77990_d); - })).apply(p_234698_0_, ItemStack::new); - }); -+ private final net.minecraftforge.registries.IRegistryDelegate delegate; -+ private CompoundNBT capNBT; -+ - private static final Logger field_199558_c = LogManager.getLogger(); - public static final ItemStack field_190927_a = new ItemStack((Item)null); - public static final DecimalFormat field_111284_a = Util.func_200696_a(new DecimalFormat("#.##"), (p_234699_0_) -> { -@@ -109,14 +_,19 @@ - p_i231596_3_.ifPresent(this::func_77982_d); - } - -- public ItemStack(IItemProvider p_i48204_1_, int p_i48204_2_) { -+ public ItemStack(IItemProvider p_i48204_1_, int p_i48204_2_) { this(p_i48204_1_, p_i48204_2_, (CompoundNBT) null); } -+ public ItemStack(IItemProvider p_i48204_1_, int p_i48204_2_, @Nullable CompoundNBT capNBT) { -+ super(ItemStack.class); -+ this.capNBT = capNBT; - this.field_151002_e = p_i48204_1_ == null ? null : p_i48204_1_.func_199767_j(); -+ this.delegate = p_i48204_1_ == null ? null : p_i48204_1_.func_199767_j().delegate; - this.field_77994_a = p_i48204_2_; -- if (this.field_151002_e != null && this.field_151002_e.func_77645_m()) { -+ if (this.field_151002_e != null && this.field_151002_e.isDamageable(this)) { - this.func_196085_b(this.func_77952_i()); - } - - this.func_190923_F(); -+ this.forgeInit(); - } - - private void func_190923_F() { -@@ -125,18 +_,23 @@ - } - - private ItemStack(CompoundNBT p_i47263_1_) { -+ super(ItemStack.class); -+ this.capNBT = p_i47263_1_.func_74764_b("ForgeCaps") ? p_i47263_1_.func_74775_l("ForgeCaps") : null; -+ Item rawItem = - this.field_151002_e = Registry.field_212630_s.func_82594_a(new ResourceLocation(p_i47263_1_.func_74779_i("id"))); -+ this.delegate = rawItem.delegate; - this.field_77994_a = p_i47263_1_.func_74771_c("Count"); - if (p_i47263_1_.func_150297_b("tag", 10)) { - this.field_77990_d = p_i47263_1_.func_74775_l("tag"); - this.func_77973_b().func_179215_a(p_i47263_1_); - } - -- if (this.func_77973_b().func_77645_m()) { -+ if (this.func_77973_b().isDamageable(this)) { - this.func_196085_b(this.func_77952_i()); - } - - this.func_190923_F(); -+ this.forgeInit(); - } - - public static ItemStack func_199557_a(CompoundNBT p_199557_0_) { -@@ -167,10 +_,19 @@ - } - - public Item func_77973_b() { -- return this.field_190928_g ? Items.field_190931_a : this.field_151002_e; -+ return this.field_190928_g || this.delegate == null ? Items.field_190931_a : this.delegate.get(); - } - - public ActionResultType func_196084_a(ItemUseContext p_196084_1_) { -+ if (!p_196084_1_.func_195991_k().field_72995_K) return net.minecraftforge.common.ForgeHooks.onPlaceItemIntoWorld(p_196084_1_); -+ return onItemUse(p_196084_1_, (c) -> func_77973_b().func_195939_a(p_196084_1_)); -+ } -+ -+ public ActionResultType onItemUseFirst(ItemUseContext p_196084_1_) { -+ return onItemUse(p_196084_1_, (c) -> func_77973_b().onItemUseFirst(this, p_196084_1_)); -+ } -+ -+ private ActionResultType onItemUse(ItemUseContext p_196084_1_, java.util.function.Function callback) { - PlayerEntity playerentity = p_196084_1_.func_195999_j(); - BlockPos blockpos = p_196084_1_.func_195995_a(); - CachedBlockInfo cachedblockinfo = new CachedBlockInfo(p_196084_1_.func_195991_k(), blockpos, false); -@@ -178,7 +_,7 @@ - return ActionResultType.PASS; - } else { - Item item = this.func_77973_b(); -- ActionResultType actionresulttype = item.func_195939_a(p_196084_1_); -+ ActionResultType actionresulttype = callback.apply(p_196084_1_); - if (playerentity != null && actionresulttype.func_226246_a_()) { - playerentity.func_71029_a(Stats.field_75929_E.func_199076_b(item)); - } -@@ -206,12 +_,15 @@ - if (this.field_77990_d != null) { - p_77955_1_.func_218657_a("tag", this.field_77990_d.func_74737_b()); - } -- -+ CompoundNBT cnbt = this.serializeCaps(); -+ if (cnbt != null && !cnbt.isEmpty()) { -+ p_77955_1_.func_218657_a("ForgeCaps", cnbt); -+ } - return p_77955_1_; - } - - public int func_77976_d() { -- return this.func_77973_b().func_77639_j(); -+ return this.func_77973_b().getItemStackLimit(this); - } - - public boolean func_77985_e() { -@@ -219,7 +_,7 @@ - } - - public boolean func_77984_f() { -- if (!this.field_190928_g && this.func_77973_b().func_77612_l() > 0) { -+ if (!this.field_190928_g && this.func_77973_b().isDamageable(this)) { - CompoundNBT compoundnbt = this.func_77978_p(); - return compoundnbt == null || !compoundnbt.func_74767_n("Unbreakable"); - } else { -@@ -228,19 +_,19 @@ - } - - public boolean func_77951_h() { -- return this.func_77984_f() && this.func_77952_i() > 0; -+ return this.func_77984_f() && func_77973_b().isDamaged(this); - } - - public int func_77952_i() { -- return this.field_77990_d == null ? 0 : this.field_77990_d.func_74762_e("Damage"); -+ return this.func_77973_b().getDamage(this); - } - - public void func_196085_b(int p_196085_1_) { -- this.func_196082_o().func_74768_a("Damage", Math.max(0, p_196085_1_)); -+ this.func_77973_b().setDamage(this, p_196085_1_); - } - - public int func_77958_k() { -- return this.func_77973_b().func_77612_l(); -+ return this.func_77973_b().getMaxDamage(this); - } - - public boolean func_96631_a(int p_96631_1_, Random p_96631_2_, @Nullable ServerPlayerEntity p_96631_3_) { -@@ -276,6 +_,7 @@ - public void func_222118_a(int p_222118_1_, T p_222118_2_, Consumer p_222118_3_) { - if (!p_222118_2_.field_70170_p.field_72995_K && (!(p_222118_2_ instanceof PlayerEntity) || !((PlayerEntity)p_222118_2_).field_71075_bZ.field_75098_d)) { - if (this.func_77984_f()) { -+ p_222118_1_ = this.func_77973_b().damageItem(this, p_222118_1_, p_222118_2_, p_222118_3_); - if (this.func_96631_a(p_222118_1_, p_222118_2_.func_70681_au(), p_222118_2_ instanceof ServerPlayerEntity ? (ServerPlayerEntity)p_222118_2_ : null)) { - p_222118_3_.accept(p_222118_2_); - Item item = this.func_77973_b(); -@@ -308,7 +_,7 @@ - } - - public boolean func_150998_b(BlockState p_150998_1_) { -- return this.func_77973_b().func_150897_b(p_150998_1_); -+ return this.func_77973_b().canHarvestBlock(this, p_150998_1_); - } - - public ActionResultType func_111282_a_(PlayerEntity p_111282_1_, LivingEntity p_111282_2_, Hand p_111282_3_) { -@@ -319,7 +_,7 @@ - if (this.func_190926_b()) { - return field_190927_a; - } else { -- ItemStack itemstack = new ItemStack(this.func_77973_b(), this.field_77994_a); -+ ItemStack itemstack = new ItemStack(this.func_77973_b(), this.field_77994_a, this.serializeCaps()); - itemstack.func_190915_d(this.func_190921_D()); - if (this.field_77990_d != null) { - itemstack.field_77990_d = this.field_77990_d.func_74737_b(); -@@ -336,7 +_,7 @@ - if (p_77970_0_.field_77990_d == null && p_77970_1_.field_77990_d != null) { - return false; - } else { -- return p_77970_0_.field_77990_d == null || p_77970_0_.field_77990_d.equals(p_77970_1_.field_77990_d); -+ return (p_77970_0_.field_77990_d == null || p_77970_0_.field_77990_d.equals(p_77970_1_.field_77990_d)) && p_77970_0_.areCapsCompatible(p_77970_1_); - } - } else { - return false; -@@ -359,7 +_,7 @@ - } else if (this.field_77990_d == null && p_77959_1_.field_77990_d != null) { - return false; - } else { -- return this.field_77990_d == null || this.field_77990_d.equals(p_77959_1_.field_77990_d); -+ return (this.field_77990_d == null || this.field_77990_d.equals(p_77959_1_.field_77990_d)) && this.areCapsCompatible(p_77959_1_); - } - } - -@@ -479,7 +_,7 @@ - - public void func_77982_d(@Nullable CompoundNBT p_77982_1_) { - this.field_77990_d = p_77982_1_; -- if (this.func_77973_b().func_77645_m()) { -+ if (this.func_77973_b().isDamageable(this)) { - this.func_196085_b(this.func_77952_i()); - } - -@@ -673,6 +_,7 @@ - } - } - -+ net.minecraftforge.event.ForgeEventFactory.onItemTooltip(this, p_82840_1_, list, p_82840_2_); - return list; - } - -@@ -817,9 +_,10 @@ - } - } - } else { -- multimap = this.func_77973_b().func_111205_h(p_111283_1_); -+ multimap = this.func_77973_b().getAttributeModifiers(p_111283_1_, this); - } - -+ multimap = net.minecraftforge.common.ForgeHooks.getAttributeModifiers(this, p_111283_1_, multimap); - return multimap; - } - -@@ -952,6 +_,24 @@ - - public boolean func_222117_E() { - return this.func_77973_b().func_219971_r(); -+ } -+ -+ // FORGE START -+ public void deserializeNBT(CompoundNBT nbt) { -+ final ItemStack itemStack = ItemStack.func_199557_a(nbt); -+ getStack().func_77982_d(itemStack.func_77978_p()); -+ if (itemStack.capNBT != null) deserializeCaps(itemStack.capNBT); -+ } -+ -+ /** -+ * Set up forge's ItemStack additions. -+ */ -+ private void forgeInit() { -+ if (this.delegate != null) { -+ net.minecraftforge.common.capabilities.ICapabilityProvider provider = field_151002_e.initCapabilities(this, this.capNBT); -+ this.gatherCapabilities(provider); -+ if (this.capNBT != null) deserializeCaps(this.capNBT); -+ } - } - - public SoundEvent func_226629_F_() { diff --git a/patches/minecraft/net/minecraft/item/Items.java.patch b/patches/minecraft/net/minecraft/item/Items.java.patch deleted file mode 100644 index ae9b605329..0000000000 --- a/patches/minecraft/net/minecraft/item/Items.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/item/Items.java -+++ b/net/minecraft/item/Items.java -@@ -12,6 +_,7 @@ - import net.minecraft.util.SoundEvents; - import net.minecraft.util.registry.Registry; - -+@net.minecraftforge.registries.ObjectHolder("minecraft") - public class Items { - public static final Item field_190931_a = func_221546_a(Blocks.field_150350_a, new AirItem(Blocks.field_150350_a, new Item.Properties())); - public static final Item field_221574_b = func_221542_a(Blocks.field_150348_b, ItemGroup.field_78030_b); diff --git a/patches/minecraft/net/minecraft/item/MerchantOffer.java.patch b/patches/minecraft/net/minecraft/item/MerchantOffer.java.patch deleted file mode 100644 index f65fdb132c..0000000000 --- a/patches/minecraft/net/minecraft/item/MerchantOffer.java.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/item/MerchantOffer.java -+++ b/net/minecraft/item/MerchantOffer.java -@@ -74,7 +_,7 @@ - int i = this.field_222223_a.func_190916_E(); - ItemStack itemstack = this.field_222223_a.func_77946_l(); - int j = Math.max(0, MathHelper.func_76141_d((float)(i * this.field_222230_h) * this.field_222231_i)); -- itemstack.func_190920_e(MathHelper.func_76125_a(i + j + this.field_222229_g, 1, this.field_222223_a.func_77973_b().func_77639_j())); -+ itemstack.func_190920_e(MathHelper.func_76125_a(i + j + this.field_222229_g, 1, this.field_222223_a.func_77976_d())); - return itemstack; - } - -@@ -178,7 +_,7 @@ - return true; - } else { - ItemStack itemstack = p_222201_1_.func_77946_l(); -- if (itemstack.func_77973_b().func_77645_m()) { -+ if (itemstack.func_77973_b().isDamageable(itemstack)) { - itemstack.func_196085_b(itemstack.func_77952_i()); - } - diff --git a/patches/minecraft/net/minecraft/item/MilkBucketItem.java.patch b/patches/minecraft/net/minecraft/item/MilkBucketItem.java.patch deleted file mode 100644 index b6248d2897..0000000000 --- a/patches/minecraft/net/minecraft/item/MilkBucketItem.java.patch +++ /dev/null @@ -1,33 +0,0 @@ ---- a/net/minecraft/item/MilkBucketItem.java -+++ b/net/minecraft/item/MilkBucketItem.java -@@ -16,6 +_,8 @@ - } - - public ItemStack func_77654_b(ItemStack p_77654_1_, World p_77654_2_, LivingEntity p_77654_3_) { -+ if (!p_77654_2_.field_72995_K) p_77654_3_.curePotionEffects(p_77654_1_); // FORGE - move up so stack.shrink does not turn stack into air -+ - if (p_77654_3_ instanceof ServerPlayerEntity) { - ServerPlayerEntity serverplayerentity = (ServerPlayerEntity)p_77654_3_; - CriteriaTriggers.field_193138_y.func_193148_a(serverplayerentity, p_77654_1_); -@@ -26,10 +_,6 @@ - p_77654_1_.func_190918_g(1); - } - -- if (!p_77654_2_.field_72995_K) { -- p_77654_3_.func_195061_cb(); -- } -- - return p_77654_1_.func_190926_b() ? new ItemStack(Items.field_151133_ar) : p_77654_1_; - } - -@@ -43,5 +_,10 @@ - - public ActionResult func_77659_a(World p_77659_1_, PlayerEntity p_77659_2_, Hand p_77659_3_) { - return DrinkHelper.func_234707_a_(p_77659_1_, p_77659_2_, p_77659_3_); -+ } -+ -+ @Override -+ public net.minecraftforge.common.capabilities.ICapabilityProvider initCapabilities(ItemStack stack, @javax.annotation.Nullable net.minecraft.nbt.CompoundNBT nbt) { -+ return new net.minecraftforge.fluids.capability.wrappers.FluidBucketWrapper(stack); - } - } diff --git a/patches/minecraft/net/minecraft/item/MinecartItem.java.patch b/patches/minecraft/net/minecraft/item/MinecartItem.java.patch deleted file mode 100644 index 06a4f97435..0000000000 --- a/patches/minecraft/net/minecraft/item/MinecartItem.java.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/item/MinecartItem.java -+++ b/net/minecraft/item/MinecartItem.java -@@ -26,7 +_,7 @@ - double d2 = p_82487_1_.func_82616_c() + (double)direction.func_82599_e() * 1.125D; - BlockPos blockpos = p_82487_1_.func_180699_d().func_177972_a(direction); - BlockState blockstate = world.func_180495_p(blockpos); -- RailShape railshape = blockstate.func_177230_c() instanceof AbstractRailBlock ? blockstate.func_177229_b(((AbstractRailBlock)blockstate.func_177230_c()).func_176560_l()) : RailShape.NORTH_SOUTH; -+ RailShape railshape = blockstate.func_177230_c() instanceof AbstractRailBlock ? ((AbstractRailBlock)blockstate.func_177230_c()).getRailDirection(blockstate, world, blockpos, null) : RailShape.NORTH_SOUTH; - double d3; - if (blockstate.func_235714_a_(BlockTags.field_203437_y)) { - if (railshape.func_208092_c()) { -@@ -79,7 +_,7 @@ - } else { - ItemStack itemstack = p_195939_1_.func_195996_i(); - if (!world.field_72995_K) { -- RailShape railshape = blockstate.func_177230_c() instanceof AbstractRailBlock ? blockstate.func_177229_b(((AbstractRailBlock)blockstate.func_177230_c()).func_176560_l()) : RailShape.NORTH_SOUTH; -+ RailShape railshape = blockstate.func_177230_c() instanceof AbstractRailBlock ? ((AbstractRailBlock)blockstate.func_177230_c()).getRailDirection(blockstate, world, blockpos, null) : RailShape.NORTH_SOUTH; - double d0 = 0.0D; - if (railshape.func_208092_c()) { - d0 = 0.5D; diff --git a/patches/minecraft/net/minecraft/item/MusicDiscItem.java.patch b/patches/minecraft/net/minecraft/item/MusicDiscItem.java.patch deleted file mode 100644 index cb1f977324..0000000000 --- a/patches/minecraft/net/minecraft/item/MusicDiscItem.java.patch +++ /dev/null @@ -1,49 +0,0 @@ ---- a/net/minecraft/item/MusicDiscItem.java -+++ b/net/minecraft/item/MusicDiscItem.java -@@ -22,15 +_,38 @@ - import net.minecraftforge.api.distmarker.OnlyIn; - - public class MusicDiscItem extends Item { -+ @Deprecated // Forge: refer to WorldRender#playRecord. Modders: there's no need to reflectively modify this map! - private static final Map field_150928_b = Maps.newHashMap(); - private final int field_195977_c; -+ @Deprecated // Forge: refer to soundSupplier - private final SoundEvent field_185076_b; -+ private final java.util.function.Supplier soundSupplier; - -+ @Deprecated // Forge: Use the constructor that takes a supplier instead - public MusicDiscItem(int p_i48475_1_, SoundEvent p_i48475_2_, Item.Properties p_i48475_3_) { - super(p_i48475_3_); - this.field_195977_c = p_i48475_1_; - this.field_185076_b = p_i48475_2_; - field_150928_b.put(this.field_185076_b, this); -+ this.soundSupplier = this.field_185076_b.delegate; -+ } -+ -+ /** -+ * For mod use, allows to create a music disc without having to create a new -+ * SoundEvent before their registry event is fired. -+ * -+ * @param comparatorValue The value this music disc should output on the comparator. Must be between 0 and 15. -+ * @param soundSupplier A supplier that provides the sound that should be played. Use a -+ * {@link net.minecraftforge.fml.RegistryObject}{@code } or a -+ * {@link net.minecraftforge.registries.IRegistryDelegate} for this parameter. -+ * @param builder A set of {@link Item.Properties} that describe this item. -+ */ -+ public MusicDiscItem(int comparatorValue, java.util.function.Supplier soundSupplier, Item.Properties builder) -+ { -+ super(builder); -+ this.field_195977_c = comparatorValue; -+ this.field_185076_b = null; -+ this.soundSupplier = soundSupplier; - } - - public ActionResultType func_195939_a(ItemUseContext p_195939_1_) { -@@ -77,6 +_,6 @@ - - @OnlyIn(Dist.CLIENT) - public SoundEvent func_185075_h() { -- return this.field_185076_b; -+ return this.soundSupplier.get(); - } - } diff --git a/patches/minecraft/net/minecraft/item/PickaxeItem.java.patch b/patches/minecraft/net/minecraft/item/PickaxeItem.java.patch deleted file mode 100644 index e47c4aacad..0000000000 --- a/patches/minecraft/net/minecraft/item/PickaxeItem.java.patch +++ /dev/null @@ -1,33 +0,0 @@ ---- a/net/minecraft/item/PickaxeItem.java -+++ b/net/minecraft/item/PickaxeItem.java -@@ -11,25 +_,16 @@ - private static final Set field_150915_c = ImmutableSet.of(Blocks.field_150408_cc, Blocks.field_150365_q, Blocks.field_150347_e, Blocks.field_150319_E, Blocks.field_150484_ah, Blocks.field_150482_ag, Blocks.field_196552_aC, Blocks.field_150340_R, Blocks.field_150352_o, Blocks.field_235334_I_, Blocks.field_150432_aD, Blocks.field_150339_S, Blocks.field_150366_p, Blocks.field_150368_y, Blocks.field_150369_x, Blocks.field_150341_Y, Blocks.field_150424_aL, Blocks.field_150403_cj, Blocks.field_205164_gk, Blocks.field_150448_aq, Blocks.field_150450_ax, Blocks.field_150322_A, Blocks.field_196583_aj, Blocks.field_196585_ak, Blocks.field_196798_hA, Blocks.field_196799_hB, Blocks.field_180395_cM, Blocks.field_150348_b, Blocks.field_196650_c, Blocks.field_196652_d, Blocks.field_196654_e, Blocks.field_196655_f, Blocks.field_196656_g, Blocks.field_196657_h, Blocks.field_150333_U, Blocks.field_222401_hJ, Blocks.field_196640_bx, Blocks.field_196643_by, Blocks.field_196646_bz, Blocks.field_196571_bA, Blocks.field_196573_bB, Blocks.field_196575_bC, Blocks.field_196576_bD, Blocks.field_196578_bE, Blocks.field_185771_cX, Blocks.field_196581_bI, Blocks.field_196582_bJ, Blocks.field_196580_bH, Blocks.field_196579_bG, Blocks.field_150430_aB, Blocks.field_150456_au, Blocks.field_222446_lj, Blocks.field_222447_lk, Blocks.field_222448_ll, Blocks.field_222449_lm, Blocks.field_222450_ln, Blocks.field_222451_lo, Blocks.field_222452_lp, Blocks.field_222453_lq, Blocks.field_222454_lr, Blocks.field_222455_ls, Blocks.field_222456_lt, Blocks.field_222457_lu, Blocks.field_222458_lv, Blocks.field_204409_il, Blocks.field_190975_dA, Blocks.field_190988_dw, Blocks.field_190989_dx, Blocks.field_190986_du, Blocks.field_190984_ds, Blocks.field_190990_dy, Blocks.field_190980_do, Blocks.field_196875_ie, Blocks.field_190982_dq, Blocks.field_190979_dn, Blocks.field_190978_dm, Blocks.field_190983_dr, Blocks.field_190987_dv, Blocks.field_190991_dz, Blocks.field_190977_dl, Blocks.field_190981_dp, Blocks.field_150331_J, Blocks.field_150320_F, Blocks.field_150332_K); - - public PickaxeItem(IItemTier p_i48478_1_, int p_i48478_2_, float p_i48478_3_, Item.Properties p_i48478_4_) { -- super((float)p_i48478_2_, p_i48478_3_, p_i48478_1_, field_150915_c, p_i48478_4_); -+ super((float)p_i48478_2_, p_i48478_3_, p_i48478_1_, field_150915_c, p_i48478_4_.addToolType(net.minecraftforge.common.ToolType.PICKAXE, p_i48478_1_.func_200925_d())); - } - - public boolean func_150897_b(BlockState p_150897_1_) { - int i = this.func_200891_e().func_200925_d(); -- if (!p_150897_1_.func_203425_a(Blocks.field_150343_Z) && !p_150897_1_.func_203425_a(Blocks.field_235399_ni_) && !p_150897_1_.func_203425_a(Blocks.field_235397_ng_) && !p_150897_1_.func_203425_a(Blocks.field_235400_nj_) && !p_150897_1_.func_203425_a(Blocks.field_235398_nh_)) { -- if (!p_150897_1_.func_203425_a(Blocks.field_150484_ah) && !p_150897_1_.func_203425_a(Blocks.field_150482_ag) && !p_150897_1_.func_203425_a(Blocks.field_150412_bA) && !p_150897_1_.func_203425_a(Blocks.field_150475_bE) && !p_150897_1_.func_203425_a(Blocks.field_150340_R) && !p_150897_1_.func_203425_a(Blocks.field_150352_o) && !p_150897_1_.func_203425_a(Blocks.field_150450_ax)) { -- if (!p_150897_1_.func_203425_a(Blocks.field_150339_S) && !p_150897_1_.func_203425_a(Blocks.field_150366_p) && !p_150897_1_.func_203425_a(Blocks.field_150368_y) && !p_150897_1_.func_203425_a(Blocks.field_150369_x)) { -- Material material = p_150897_1_.func_185904_a(); -- return material == Material.field_151576_e || material == Material.field_151573_f || material == Material.field_151574_g || p_150897_1_.func_203425_a(Blocks.field_235334_I_); -- } else { -- return i >= 1; -- } -- } else { -- return i >= 2; -- } -- } else { -- return i >= 3; -+ if (p_150897_1_.getHarvestTool() == net.minecraftforge.common.ToolType.PICKAXE) { -+ return i >= p_150897_1_.getHarvestLevel(); - } -+ Material material = p_150897_1_.func_185904_a(); -+ return material == Material.field_151576_e || material == Material.field_151573_f || material == Material.field_151574_g; - } - - public float func_150893_a(ItemStack p_150893_1_, BlockState p_150893_2_) { diff --git a/patches/minecraft/net/minecraft/item/Rarity.java.patch b/patches/minecraft/net/minecraft/item/Rarity.java.patch deleted file mode 100644 index 9565b68918..0000000000 --- a/patches/minecraft/net/minecraft/item/Rarity.java.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- a/net/minecraft/item/Rarity.java -+++ b/net/minecraft/item/Rarity.java -@@ -2,7 +_,7 @@ - - import net.minecraft.util.text.TextFormatting; - --public enum Rarity { -+public enum Rarity implements net.minecraftforge.common.IExtensibleEnum { - COMMON(TextFormatting.WHITE), - UNCOMMON(TextFormatting.YELLOW), - RARE(TextFormatting.AQUA), -@@ -12,5 +_,9 @@ - - private Rarity(TextFormatting p_i48837_3_) { - this.field_77937_e = p_i48837_3_; -+ } -+ -+ public static Rarity create(String name, TextFormatting p_i48837_3_) { -+ throw new IllegalStateException("Enum not extended"); - } - } diff --git a/patches/minecraft/net/minecraft/item/ShearsItem.java.patch b/patches/minecraft/net/minecraft/item/ShearsItem.java.patch deleted file mode 100644 index cb69250577..0000000000 --- a/patches/minecraft/net/minecraft/item/ShearsItem.java.patch +++ /dev/null @@ -1,28 +0,0 @@ ---- a/net/minecraft/item/ShearsItem.java -+++ b/net/minecraft/item/ShearsItem.java -@@ -34,4 +_,25 @@ - return 15.0F; - } - } -+ -+ @Override -+ public net.minecraft.util.ActionResultType func_111207_a(ItemStack stack, net.minecraft.entity.player.PlayerEntity playerIn, LivingEntity entity, net.minecraft.util.Hand hand) { -+ if (entity.field_70170_p.field_72995_K) return net.minecraft.util.ActionResultType.PASS; -+ if (entity instanceof net.minecraftforge.common.IForgeShearable) { -+ net.minecraftforge.common.IForgeShearable target = (net.minecraftforge.common.IForgeShearable)entity; -+ BlockPos pos = new BlockPos(entity.func_226277_ct_(), entity.func_226278_cu_(), entity.func_226281_cx_()); -+ if (target.isShearable(stack, entity.field_70170_p, pos)) { -+ java.util.List drops = target.onSheared(playerIn, stack, entity.field_70170_p, pos, -+ net.minecraft.enchantment.EnchantmentHelper.func_77506_a(net.minecraft.enchantment.Enchantments.field_185308_t, stack)); -+ java.util.Random rand = new java.util.Random(); -+ drops.forEach(d -> { -+ net.minecraft.entity.item.ItemEntity ent = entity.func_70099_a(d, 1.0F); -+ ent.func_213317_d(ent.func_213322_ci().func_72441_c((double)((rand.nextFloat() - rand.nextFloat()) * 0.1F), (double)(rand.nextFloat() * 0.05F), (double)((rand.nextFloat() - rand.nextFloat()) * 0.1F))); -+ }); -+ stack.func_222118_a(1, entity, e -> e.func_213334_d(hand)); -+ } -+ return net.minecraft.util.ActionResultType.SUCCESS; -+ } -+ return net.minecraft.util.ActionResultType.PASS; -+ } - } diff --git a/patches/minecraft/net/minecraft/item/ShovelItem.java.patch b/patches/minecraft/net/minecraft/item/ShovelItem.java.patch deleted file mode 100644 index c43c54fdbb..0000000000 --- a/patches/minecraft/net/minecraft/item/ShovelItem.java.patch +++ /dev/null @@ -1,34 +0,0 @@ ---- a/net/minecraft/item/ShovelItem.java -+++ b/net/minecraft/item/ShovelItem.java -@@ -22,7 +_,7 @@ - protected static final Map field_195955_e = Maps.newHashMap(ImmutableMap.of(Blocks.field_196658_i, Blocks.field_185774_da.func_176223_P())); - - public ShovelItem(IItemTier p_i48469_1_, float p_i48469_2_, float p_i48469_3_, Item.Properties p_i48469_4_) { -- super(p_i48469_2_, p_i48469_3_, p_i48469_1_, field_150916_c, p_i48469_4_); -+ super(p_i48469_2_, p_i48469_3_, p_i48469_1_, field_150916_c, p_i48469_4_.addToolType(net.minecraftforge.common.ToolType.SHOVEL, p_i48469_1_.func_200925_d())); - } - - public boolean func_150897_b(BlockState p_150897_1_) { -@@ -37,9 +_,9 @@ - return ActionResultType.PASS; - } else { - PlayerEntity playerentity = p_195939_1_.func_195999_j(); -- BlockState blockstate1 = field_195955_e.get(blockstate.func_177230_c()); -+ BlockState blockstate1 = blockstate.getToolModifiedState(world, blockpos, playerentity, p_195939_1_.func_195996_i(), net.minecraftforge.common.ToolType.SHOVEL); - BlockState blockstate2 = null; -- if (blockstate1 != null && world.func_180495_p(blockpos.func_177984_a()).func_196958_f()) { -+ if (blockstate1 != null && world.func_175623_d(blockpos.func_177984_a())) { - world.func_184133_a(playerentity, blockpos, SoundEvents.field_187771_eN, SoundCategory.BLOCKS, 1.0F, 1.0F); - blockstate2 = blockstate1; - } else if (blockstate.func_177230_c() instanceof CampfireBlock && blockstate.func_177229_b(CampfireBlock.field_220101_b)) { -@@ -66,5 +_,10 @@ - return ActionResultType.PASS; - } - } -+ } -+ -+ @javax.annotation.Nullable -+ public static BlockState getShovelPathingState(BlockState originalState) { -+ return field_195955_e.get(originalState.func_177230_c()); - } - } diff --git a/patches/minecraft/net/minecraft/item/ToolItem.java.patch b/patches/minecraft/net/minecraft/item/ToolItem.java.patch deleted file mode 100644 index 3551b3acf9..0000000000 --- a/patches/minecraft/net/minecraft/item/ToolItem.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/item/ToolItem.java -+++ b/net/minecraft/item/ToolItem.java -@@ -33,6 +_,7 @@ - } - - public float func_150893_a(ItemStack p_150893_1_, BlockState p_150893_2_) { -+ if (getToolTypes(p_150893_1_).stream().anyMatch(e -> p_150893_2_.isToolEffective(e))) return field_77864_a; - return this.field_150914_c.contains(p_150893_2_.func_177230_c()) ? this.field_77864_a : 1.0F; - } - diff --git a/patches/minecraft/net/minecraft/item/WallOrFloorItem.java.patch b/patches/minecraft/net/minecraft/item/WallOrFloorItem.java.patch deleted file mode 100644 index 49cfa859e6..0000000000 --- a/patches/minecraft/net/minecraft/item/WallOrFloorItem.java.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/net/minecraft/item/WallOrFloorItem.java -+++ b/net/minecraft/item/WallOrFloorItem.java -@@ -41,4 +_,9 @@ - super.func_195946_a(p_195946_1_, p_195946_2_); - p_195946_1_.put(this.field_195947_b, p_195946_2_); - } -+ -+ public void removeFromBlockToItemMap(Map blockToItemMap, Item itemIn) { -+ super.removeFromBlockToItemMap(blockToItemMap, itemIn); -+ blockToItemMap.remove(this.field_195947_b); -+ } - } diff --git a/patches/minecraft/net/minecraft/item/crafting/BannerDuplicateRecipe.java.patch b/patches/minecraft/net/minecraft/item/crafting/BannerDuplicateRecipe.java.patch deleted file mode 100644 index 1b6284a603..0000000000 --- a/patches/minecraft/net/minecraft/item/crafting/BannerDuplicateRecipe.java.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/net/minecraft/item/crafting/BannerDuplicateRecipe.java -+++ b/net/minecraft/item/crafting/BannerDuplicateRecipe.java -@@ -77,8 +_,8 @@ - for(int i = 0; i < nonnulllist.size(); ++i) { - ItemStack itemstack = p_179532_1_.func_70301_a(i); - if (!itemstack.func_190926_b()) { -- if (itemstack.func_77973_b().func_77634_r()) { -- nonnulllist.set(i, new ItemStack(itemstack.func_77973_b().func_77668_q())); -+ if (itemstack.hasContainerItem()) { -+ nonnulllist.set(i, itemstack.getContainerItem()); - } else if (itemstack.func_77942_o() && BannerTileEntity.func_175113_c(itemstack) > 0) { - ItemStack itemstack1 = itemstack.func_77946_l(); - itemstack1.func_190920_e(1); diff --git a/patches/minecraft/net/minecraft/item/crafting/BookCloningRecipe.java.patch b/patches/minecraft/net/minecraft/item/crafting/BookCloningRecipe.java.patch deleted file mode 100644 index f1d3741cc4..0000000000 --- a/patches/minecraft/net/minecraft/item/crafting/BookCloningRecipe.java.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/net/minecraft/item/crafting/BookCloningRecipe.java -+++ b/net/minecraft/item/crafting/BookCloningRecipe.java -@@ -79,8 +_,8 @@ - - for(int i = 0; i < nonnulllist.size(); ++i) { - ItemStack itemstack = p_179532_1_.func_70301_a(i); -- if (itemstack.func_77973_b().func_77634_r()) { -- nonnulllist.set(i, new ItemStack(itemstack.func_77973_b().func_77668_q())); -+ if (itemstack.hasContainerItem()) { -+ nonnulllist.set(i, itemstack.getContainerItem()); - } else if (itemstack.func_77973_b() instanceof WrittenBookItem) { - ItemStack itemstack1 = itemstack.func_77946_l(); - itemstack1.func_190920_e(1); diff --git a/patches/minecraft/net/minecraft/item/crafting/CookingRecipeSerializer.java.patch b/patches/minecraft/net/minecraft/item/crafting/CookingRecipeSerializer.java.patch deleted file mode 100644 index d629985363..0000000000 --- a/patches/minecraft/net/minecraft/item/crafting/CookingRecipeSerializer.java.patch +++ /dev/null @@ -1,30 +0,0 @@ ---- a/net/minecraft/item/crafting/CookingRecipeSerializer.java -+++ b/net/minecraft/item/crafting/CookingRecipeSerializer.java -@@ -8,7 +_,7 @@ - import net.minecraft.util.ResourceLocation; - import net.minecraft.util.registry.Registry; - --public class CookingRecipeSerializer implements IRecipeSerializer { -+public class CookingRecipeSerializer extends net.minecraftforge.registries.ForgeRegistryEntry> implements IRecipeSerializer { - private final int field_222178_t; - private final CookingRecipeSerializer.IFactory field_222179_u; - -@@ -21,11 +_,17 @@ - String s = JSONUtils.func_151219_a(p_199425_2_, "group", ""); - JsonElement jsonelement = (JsonElement)(JSONUtils.func_151202_d(p_199425_2_, "ingredient") ? JSONUtils.func_151214_t(p_199425_2_, "ingredient") : JSONUtils.func_152754_s(p_199425_2_, "ingredient")); - Ingredient ingredient = Ingredient.func_199802_a(jsonelement); -+ //Forge: Check if primitive string to keep vanilla or a object which can contain a count field. -+ if (!p_199425_2_.has("result")) throw new com.google.gson.JsonSyntaxException("Missing result, expected to find a string or object"); -+ ItemStack itemstack; -+ if (p_199425_2_.get("result").isJsonObject()) itemstack = ShapedRecipe.func_199798_a(JSONUtils.func_152754_s(p_199425_2_, "result")); -+ else { - String s1 = JSONUtils.func_151200_h(p_199425_2_, "result"); - ResourceLocation resourcelocation = new ResourceLocation(s1); -- ItemStack itemstack = new ItemStack(Registry.field_212630_s.func_241873_b(resourcelocation).orElseThrow(() -> { -+ itemstack = new ItemStack(Registry.field_212630_s.func_241873_b(resourcelocation).orElseThrow(() -> { - return new IllegalStateException("Item: " + s1 + " does not exist"); - })); -+ } - float f = JSONUtils.func_151221_a(p_199425_2_, "experience", 0.0F); - int i = JSONUtils.func_151208_a(p_199425_2_, "cookingtime", this.field_222178_t); - return this.field_222179_u.create(p_199425_1_, s, ingredient, itemstack, f, i); diff --git a/patches/minecraft/net/minecraft/item/crafting/IRecipe.java.patch b/patches/minecraft/net/minecraft/item/crafting/IRecipe.java.patch deleted file mode 100644 index 0b7a9feeaa..0000000000 --- a/patches/minecraft/net/minecraft/item/crafting/IRecipe.java.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- a/net/minecraft/item/crafting/IRecipe.java -+++ b/net/minecraft/item/crafting/IRecipe.java -@@ -21,9 +_,9 @@ - NonNullList nonnulllist = NonNullList.func_191197_a(p_179532_1_.func_70302_i_(), ItemStack.field_190927_a); - - for(int i = 0; i < nonnulllist.size(); ++i) { -- Item item = p_179532_1_.func_70301_a(i).func_77973_b(); -- if (item.func_77634_r()) { -- nonnulllist.set(i, new ItemStack(item.func_77668_q())); -+ ItemStack item = p_179532_1_.func_70301_a(i); -+ if (item.hasContainerItem()) { -+ nonnulllist.set(i, item.getContainerItem()); - } - } - diff --git a/patches/minecraft/net/minecraft/item/crafting/IRecipePlacer.java.patch b/patches/minecraft/net/minecraft/item/crafting/IRecipePlacer.java.patch deleted file mode 100644 index ef27dea0a2..0000000000 --- a/patches/minecraft/net/minecraft/item/crafting/IRecipePlacer.java.patch +++ /dev/null @@ -1,17 +0,0 @@ ---- a/net/minecraft/item/crafting/IRecipePlacer.java -+++ b/net/minecraft/item/crafting/IRecipePlacer.java -@@ -7,10 +_,10 @@ - default void func_201501_a(int p_201501_1_, int p_201501_2_, int p_201501_3_, IRecipe p_201501_4_, Iterator p_201501_5_, int p_201501_6_) { - int i = p_201501_1_; - int j = p_201501_2_; -- if (p_201501_4_ instanceof ShapedRecipe) { -- ShapedRecipe shapedrecipe = (ShapedRecipe)p_201501_4_; -- i = shapedrecipe.func_192403_f(); -- j = shapedrecipe.func_192404_g(); -+ if (p_201501_4_ instanceof net.minecraftforge.common.crafting.IShapedRecipe) { -+ net.minecraftforge.common.crafting.IShapedRecipe shapedrecipe = (net.minecraftforge.common.crafting.IShapedRecipe)p_201501_4_; -+ i = shapedrecipe.getRecipeWidth(); -+ j = shapedrecipe.getRecipeHeight(); - } - - int k1 = 0; diff --git a/patches/minecraft/net/minecraft/item/crafting/IRecipeSerializer.java.patch b/patches/minecraft/net/minecraft/item/crafting/IRecipeSerializer.java.patch deleted file mode 100644 index 75c16b6924..0000000000 --- a/patches/minecraft/net/minecraft/item/crafting/IRecipeSerializer.java.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- a/net/minecraft/item/crafting/IRecipeSerializer.java -+++ b/net/minecraft/item/crafting/IRecipeSerializer.java -@@ -5,7 +_,7 @@ - import net.minecraft.util.ResourceLocation; - import net.minecraft.util.registry.Registry; - --public interface IRecipeSerializer> { -+public interface IRecipeSerializer> extends net.minecraftforge.registries.IForgeRegistryEntry> { - IRecipeSerializer field_222157_a = func_222156_a("crafting_shaped", new ShapedRecipe.Serializer()); - IRecipeSerializer field_222158_b = func_222156_a("crafting_shapeless", new ShapelessRecipe.Serializer()); - SpecialRecipeSerializer field_222159_c = func_222156_a("crafting_special_armordye", new SpecialRecipeSerializer<>(ArmorDyeRecipe::new)); -@@ -30,6 +_,7 @@ - - T func_199425_a_(ResourceLocation p_199425_1_, JsonObject p_199425_2_); - -+ @javax.annotation.Nullable - T func_199426_a_(ResourceLocation p_199426_1_, PacketBuffer p_199426_2_); - - void func_199427_a_(PacketBuffer p_199427_1_, T p_199427_2_); diff --git a/patches/minecraft/net/minecraft/item/crafting/Ingredient.java.patch b/patches/minecraft/net/minecraft/item/crafting/Ingredient.java.patch deleted file mode 100644 index 1cbd1f824a..0000000000 --- a/patches/minecraft/net/minecraft/item/crafting/Ingredient.java.patch +++ /dev/null @@ -1,106 +0,0 @@ ---- a/net/minecraft/item/crafting/Ingredient.java -+++ b/net/minecraft/item/crafting/Ingredient.java -@@ -28,15 +_,24 @@ - import net.minecraft.util.registry.Registry; - - public class Ingredient implements Predicate { -+ //Because Mojang caches things... we need to invalidate them.. so... here we go.. -+ private static final java.util.Set INSTANCES = java.util.Collections.newSetFromMap(new java.util.WeakHashMap()); -+ public static void invalidateAll() { -+ INSTANCES.stream().filter(e -> e != null).forEach(i -> i.invalidate()); -+ } -+ - public static final Ingredient field_193370_a = new Ingredient(Stream.empty()); - private final Ingredient.IItemList[] field_199807_b; - private ItemStack[] field_193371_b; - private IntList field_194140_c; -+ private final boolean isSimple; - - protected Ingredient(Stream p_i49381_1_) { - this.field_199807_b = p_i49381_1_.toArray((p_209360_0_) -> { - return new Ingredient.IItemList[p_209360_0_]; - }); -+ this.isSimple = !net.minecraftforge.fml.DatagenModLoader.isRunningDataGen() && !Arrays.stream(field_199807_b).anyMatch(list -> list.func_199799_a().stream().anyMatch(stack -> stack.func_77973_b().isDamageable(stack))); -+ Ingredient.INSTANCES.add(this); - } - - public ItemStack[] func_193365_a() { -@@ -91,6 +_,10 @@ - - public final void func_199564_a(PacketBuffer p_199564_1_) { - this.func_199806_d(); -+ if (!this.isVanilla()) { -+ net.minecraftforge.common.crafting.CraftingHelper.write(p_199564_1_, this); -+ return; -+ } - p_199564_1_.func_150787_b(this.field_193371_b.length); - - for(int i = 0; i < this.field_193371_b.length; ++i) { -@@ -117,6 +_,25 @@ - return this.field_199807_b.length == 0 && (this.field_193371_b == null || this.field_193371_b.length == 0) && (this.field_194140_c == null || this.field_194140_c.isEmpty()); - } - -+ protected void invalidate() { -+ this.field_193371_b = null; -+ this.field_194140_c = null; -+ } -+ -+ public boolean isSimple() { -+ return isSimple || this == field_193370_a; -+ } -+ -+ private final boolean isVanilla = this.getClass() == Ingredient.class; -+ public final boolean isVanilla() { -+ 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 func_209357_a(Stream p_209357_0_) { - Ingredient ingredient = new Ingredient(p_209357_0_); - return ingredient.field_199807_b.length == 0 ? field_193370_a : ingredient; -@@ -144,6 +_,9 @@ - - public static Ingredient func_199566_b(PacketBuffer p_199566_0_) { - int i = p_199566_0_.func_150792_a(); -+ if (i == -1) { -+ return net.minecraftforge.common.crafting.CraftingHelper.getIngredient(p_199566_0_.func_192575_l(), p_199566_0_); -+ } - return func_209357_a(Stream.generate(() -> { - return new Ingredient.SingleItemList(p_199566_0_.func_150791_c()); - }).limit((long)i)); -@@ -151,6 +_,8 @@ - - public static Ingredient func_199802_a(@Nullable JsonElement p_199802_0_) { - if (p_199802_0_ != null && !p_199802_0_.isJsonNull()) { -+ Ingredient ret = net.minecraftforge.common.crafting.CraftingHelper.getIngredient(p_199802_0_); -+ if (ret != null) return ret; - if (p_199802_0_.isJsonObject()) { - return func_209357_a(Stream.of(func_199803_a(p_199802_0_.getAsJsonObject()))); - } else if (p_199802_0_.isJsonArray()) { -@@ -192,6 +_,12 @@ - } - } - -+ //Merges several vanilla Ingredients together. As a quirk of how the json is structured, we can't tell if its a single Ingredient type or multiple so we split per item and re-merge here. -+ //Only public for internal use, so we can access a private field in here. -+ public static Ingredient merge(Collection parts) { -+ return func_209357_a(parts.stream().flatMap(i -> Arrays.stream(i.field_199807_b))); -+ } -+ - public interface IItemList { - Collection func_199799_a(); - -@@ -230,6 +_,9 @@ - list.add(new ItemStack(item)); - } - -+ if (list.size() == 0 && !net.minecraftforge.common.ForgeConfig.SERVER.treatEmptyTagsAsAir.get()) { -+ list.add(new ItemStack(net.minecraft.block.Blocks.field_180401_cv).func_200302_a(new net.minecraft.util.text.StringTextComponent("Empty Tag: " + TagCollectionManager.func_242178_a().func_241836_b().func_232975_b_(this.field_199800_a).toString()))); -+ } - return list; - } - diff --git a/patches/minecraft/net/minecraft/item/crafting/RecipeManager.java.patch b/patches/minecraft/net/minecraft/item/crafting/RecipeManager.java.patch deleted file mode 100644 index 43bf8a2d52..0000000000 --- a/patches/minecraft/net/minecraft/item/crafting/RecipeManager.java.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- a/net/minecraft/item/crafting/RecipeManager.java -+++ b/net/minecraft/item/crafting/RecipeManager.java -@@ -51,9 +_,18 @@ - - for(Entry entry : p_212853_1_.entrySet()) { - ResourceLocation resourcelocation = entry.getKey(); -+ if (resourcelocation.func_110623_a().startsWith("_")) continue; //Forge: filter anything beginning with "_" as it's used for metadata. - - try { -+ if (entry.getValue().isJsonObject() && !net.minecraftforge.common.crafting.CraftingHelper.processConditions(entry.getValue().getAsJsonObject(), "conditions")) { -+ field_199521_c.debug("Skipping loading recipe {} as it's conditions were not met", resourcelocation); -+ continue; -+ } - IRecipe irecipe = func_215377_a(resourcelocation, JSONUtils.func_151210_l(entry.getValue(), "top element")); -+ if (irecipe == null) { -+ field_199521_c.info("Skipping loading recipe {} as it's serializer returned null", resourcelocation); -+ continue; -+ } - map.computeIfAbsent(irecipe.func_222127_g(), (p_223391_0_) -> { - return ImmutableMap.builder(); - }).put(resourcelocation, irecipe); diff --git a/patches/minecraft/net/minecraft/item/crafting/RepairItemRecipe.java.patch b/patches/minecraft/net/minecraft/item/crafting/RepairItemRecipe.java.patch deleted file mode 100644 index d99a724046..0000000000 --- a/patches/minecraft/net/minecraft/item/crafting/RepairItemRecipe.java.patch +++ /dev/null @@ -1,38 +0,0 @@ ---- a/net/minecraft/item/crafting/RepairItemRecipe.java -+++ b/net/minecraft/item/crafting/RepairItemRecipe.java -@@ -27,7 +_,7 @@ - list.add(itemstack); - if (list.size() > 1) { - ItemStack itemstack1 = list.get(0); -- if (itemstack.func_77973_b() != itemstack1.func_77973_b() || itemstack1.func_190916_E() != 1 || itemstack.func_190916_E() != 1 || !itemstack1.func_77973_b().func_77645_m()) { -+ if (itemstack.func_77973_b() != itemstack1.func_77973_b() || itemstack1.func_190916_E() != 1 || itemstack.func_190916_E() != 1 || !itemstack1.isRepairable()) { - return false; - } - } -@@ -46,7 +_,7 @@ - list.add(itemstack); - if (list.size() > 1) { - ItemStack itemstack1 = list.get(0); -- if (itemstack.func_77973_b() != itemstack1.func_77973_b() || itemstack1.func_190916_E() != 1 || itemstack.func_190916_E() != 1 || !itemstack1.func_77973_b().func_77645_m()) { -+ if (itemstack.func_77973_b() != itemstack1.func_77973_b() || itemstack1.func_190916_E() != 1 || itemstack.func_190916_E() != 1 || !itemstack1.isRepairable()) { - return ItemStack.field_190927_a; - } - } -@@ -56,12 +_,12 @@ - if (list.size() == 2) { - ItemStack itemstack3 = list.get(0); - ItemStack itemstack4 = list.get(1); -- if (itemstack3.func_77973_b() == itemstack4.func_77973_b() && itemstack3.func_190916_E() == 1 && itemstack4.func_190916_E() == 1 && itemstack3.func_77973_b().func_77645_m()) { -+ if (itemstack3.func_77973_b() == itemstack4.func_77973_b() && itemstack3.func_190916_E() == 1 && itemstack4.func_190916_E() == 1 && itemstack3.isRepairable()) { - Item item = itemstack3.func_77973_b(); -- int j = item.func_77612_l() - itemstack3.func_77952_i(); -- int k = item.func_77612_l() - itemstack4.func_77952_i(); -- int l = j + k + item.func_77612_l() * 5 / 100; -- int i1 = item.func_77612_l() - l; -+ int j = itemstack3.func_77958_k() - itemstack3.func_77952_i(); -+ int k = itemstack3.func_77958_k() - itemstack4.func_77952_i(); -+ int l = j + k + itemstack3.func_77958_k() * 5 / 100; -+ int i1 = itemstack3.func_77958_k() - l; - if (i1 < 0) { - i1 = 0; - } diff --git a/patches/minecraft/net/minecraft/item/crafting/ShapedRecipe.java.patch b/patches/minecraft/net/minecraft/item/crafting/ShapedRecipe.java.patch deleted file mode 100644 index 46aef2bf4e..0000000000 --- a/patches/minecraft/net/minecraft/item/crafting/ShapedRecipe.java.patch +++ /dev/null @@ -1,80 +0,0 @@ ---- a/net/minecraft/item/crafting/ShapedRecipe.java -+++ b/net/minecraft/item/crafting/ShapedRecipe.java -@@ -21,7 +_,20 @@ - import net.minecraft.util.registry.Registry; - import net.minecraft.world.World; - --public class ShapedRecipe implements ICraftingRecipe { -+public class ShapedRecipe implements ICraftingRecipe, net.minecraftforge.common.crafting.IShapedRecipe { -+ static int MAX_WIDTH = 3; -+ static int MAX_HEIGHT = 3; -+ /** -+ * Expand the max width and height allowed in the deserializer. -+ * This should be called by modders who add custom crafting tables that are larger than the vanilla 3x3. -+ * @param width your max recipe width -+ * @param height your max recipe height -+ */ -+ public static void setCraftingSize(int width, int height) { -+ if (MAX_WIDTH < width) MAX_WIDTH = width; -+ if (MAX_HEIGHT < height) MAX_HEIGHT = height; -+ } -+ - private final int field_77576_b; - private final int field_77577_c; - private final NonNullList field_77574_d; -@@ -109,10 +_,20 @@ - return this.field_77576_b; - } - -+ @Override -+ public int getRecipeWidth() { -+ return func_192403_f(); -+ } -+ - public int func_192404_g() { - return this.field_77577_c; - } - -+ @Override -+ public int getRecipeHeight() { -+ return func_192404_g(); -+ } -+ - private static NonNullList func_192402_a(String[] p_192402_0_, Map p_192402_1_, int p_192402_2_, int p_192402_3_) { - NonNullList nonnulllist = NonNullList.func_191197_a(p_192402_2_ * p_192402_3_, Ingredient.field_193370_a); - Set set = Sets.newHashSet(p_192402_1_.keySet()); -@@ -192,15 +_,15 @@ - - private static String[] func_192407_a(JsonArray p_192407_0_) { - String[] astring = new String[p_192407_0_.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 = JSONUtils.func_151206_a(p_192407_0_.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()) { -@@ -242,11 +_,12 @@ - throw new JsonParseException("Disallowed data tag found"); - } else { - int i = JSONUtils.func_151208_a(p_199798_0_, "count", 1); -- return new ItemStack(item, i); -+ return net.minecraftforge.common.crafting.CraftingHelper.getItemStack(p_199798_0_, true); - } - } - -- public static class Serializer implements IRecipeSerializer { -+ public static class Serializer extends net.minecraftforge.registries.ForgeRegistryEntry> implements IRecipeSerializer { -+ private static final ResourceLocation NAME = new ResourceLocation("minecraft", "crafting_shaped"); - public ShapedRecipe func_199425_a_(ResourceLocation p_199425_1_, JsonObject p_199425_2_) { - String s = JSONUtils.func_151219_a(p_199425_2_, "group", ""); - Map map = ShapedRecipe.func_192408_a(JSONUtils.func_152754_s(p_199425_2_, "key")); diff --git a/patches/minecraft/net/minecraft/item/crafting/ShapelessRecipe.java.patch b/patches/minecraft/net/minecraft/item/crafting/ShapelessRecipe.java.patch deleted file mode 100644 index 82815f5b69..0000000000 --- a/patches/minecraft/net/minecraft/item/crafting/ShapelessRecipe.java.patch +++ /dev/null @@ -1,58 +0,0 @@ ---- a/net/minecraft/item/crafting/ShapelessRecipe.java -+++ b/net/minecraft/item/crafting/ShapelessRecipe.java -@@ -17,12 +_,14 @@ - private final String field_194138_c; - private final ItemStack field_77580_a; - private final NonNullList field_77579_b; -+ private final boolean isSimple; - - public ShapelessRecipe(ResourceLocation p_i48161_1_, String p_i48161_2_, ItemStack p_i48161_3_, NonNullList p_i48161_4_) { - this.field_199562_a = p_i48161_1_; - this.field_194138_c = p_i48161_2_; - this.field_77580_a = p_i48161_3_; - this.field_77579_b = p_i48161_4_; -+ this.isSimple = p_i48161_4_.stream().allMatch(Ingredient::isSimple); - } - - public ResourceLocation func_199560_c() { -@@ -47,17 +_,20 @@ - - public boolean func_77569_a(CraftingInventory p_77569_1_, World p_77569_2_) { - RecipeItemHelper recipeitemhelper = new RecipeItemHelper(); -+ java.util.List inputs = new java.util.ArrayList<>(); - int i = 0; - - for(int j = 0; j < p_77569_1_.func_70302_i_(); ++j) { - ItemStack itemstack = p_77569_1_.func_70301_a(j); - if (!itemstack.func_190926_b()) { - ++i; -+ if (isSimple) - recipeitemhelper.func_221264_a(itemstack, 1); -+ else inputs.add(itemstack); - } - } - -- return i == this.field_77579_b.size() && recipeitemhelper.func_194116_a(this, (IntList)null); -+ return i == this.field_77579_b.size() && (isSimple ? recipeitemhelper.func_194116_a(this, (IntList)null) : net.minecraftforge.common.util.RecipeMatcher.findMatches(inputs, this.field_77579_b) != null); - } - - public ItemStack func_77572_b(CraftingInventory p_77572_1_) { -@@ -68,14 +_,15 @@ - return p_194133_1_ * p_194133_2_ >= this.field_77579_b.size(); - } - -- public static class Serializer implements IRecipeSerializer { -+ public static class Serializer extends net.minecraftforge.registries.ForgeRegistryEntry> implements IRecipeSerializer { -+ private static final ResourceLocation NAME = new ResourceLocation("minecraft", "crafting_shapeless"); - public ShapelessRecipe func_199425_a_(ResourceLocation p_199425_1_, JsonObject p_199425_2_) { - String s = JSONUtils.func_151219_a(p_199425_2_, "group", ""); - NonNullList nonnulllist = func_199568_a(JSONUtils.func_151214_t(p_199425_2_, "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 max is " + (ShapedRecipe.MAX_WIDTH * ShapedRecipe.MAX_HEIGHT)); - } else { - ItemStack itemstack = ShapedRecipe.func_199798_a(JSONUtils.func_152754_s(p_199425_2_, "result")); - return new ShapelessRecipe(p_199425_1_, s, itemstack, nonnulllist); diff --git a/patches/minecraft/net/minecraft/item/crafting/ShulkerBoxColoringRecipe.java.patch b/patches/minecraft/net/minecraft/item/crafting/ShulkerBoxColoringRecipe.java.patch deleted file mode 100644 index 773afbfaf9..0000000000 --- a/patches/minecraft/net/minecraft/item/crafting/ShulkerBoxColoringRecipe.java.patch +++ /dev/null @@ -1,38 +0,0 @@ ---- a/net/minecraft/item/crafting/ShulkerBoxColoringRecipe.java -+++ b/net/minecraft/item/crafting/ShulkerBoxColoringRecipe.java -@@ -25,7 +_,7 @@ - if (Block.func_149634_a(itemstack.func_77973_b()) instanceof ShulkerBoxBlock) { - ++i; - } else { -- if (!(itemstack.func_77973_b() instanceof DyeItem)) { -+ if (!itemstack.func_77973_b().func_206844_a(net.minecraftforge.common.Tags.Items.DYES)) { - return false; - } - -@@ -43,7 +_,7 @@ - - public ItemStack func_77572_b(CraftingInventory p_77572_1_) { - ItemStack itemstack = ItemStack.field_190927_a; -- DyeItem dyeitem = (DyeItem)Items.field_222069_lA; -+ net.minecraft.item.DyeColor dyecolor = net.minecraft.item.DyeColor.WHITE; - - for(int i = 0; i < p_77572_1_.func_70302_i_(); ++i) { - ItemStack itemstack1 = p_77572_1_.func_70301_a(i); -@@ -51,13 +_,14 @@ - Item item = itemstack1.func_77973_b(); - if (Block.func_149634_a(item) instanceof ShulkerBoxBlock) { - itemstack = itemstack1; -- } else if (item instanceof DyeItem) { -- dyeitem = (DyeItem)item; -+ } else { -+ net.minecraft.item.DyeColor tmp = net.minecraft.item.DyeColor.getColor(itemstack1); -+ if (tmp != null) dyecolor = tmp; - } - } - } - -- ItemStack itemstack2 = ShulkerBoxBlock.func_190953_b(dyeitem.func_195962_g()); -+ ItemStack itemstack2 = ShulkerBoxBlock.func_190953_b(dyecolor); - if (itemstack.func_77942_o()) { - itemstack2.func_77982_d(itemstack.func_77978_p().func_74737_b()); - } diff --git a/patches/minecraft/net/minecraft/item/crafting/SingleItemRecipe.java.patch b/patches/minecraft/net/minecraft/item/crafting/SingleItemRecipe.java.patch deleted file mode 100644 index 2f630e9743..0000000000 --- a/patches/minecraft/net/minecraft/item/crafting/SingleItemRecipe.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/item/crafting/SingleItemRecipe.java -+++ b/net/minecraft/item/crafting/SingleItemRecipe.java -@@ -60,7 +_,7 @@ - return this.field_222132_b.func_77946_l(); - } - -- public static class Serializer implements IRecipeSerializer { -+ public static class Serializer extends net.minecraftforge.registries.ForgeRegistryEntry> implements IRecipeSerializer { - final SingleItemRecipe.Serializer.IRecipeFactory field_222180_t; - - protected Serializer(SingleItemRecipe.Serializer.IRecipeFactory p_i50146_1_) { diff --git a/patches/minecraft/net/minecraft/item/crafting/SmithingRecipe.java.patch b/patches/minecraft/net/minecraft/item/crafting/SmithingRecipe.java.patch deleted file mode 100644 index ab35ff6c53..0000000000 --- a/patches/minecraft/net/minecraft/item/crafting/SmithingRecipe.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/item/crafting/SmithingRecipe.java -+++ b/net/minecraft/item/crafting/SmithingRecipe.java -@@ -65,7 +_,7 @@ - return IRecipeType.field_234827_g_; - } - -- public static class Serializer implements IRecipeSerializer { -+ public static class Serializer extends net.minecraftforge.registries.ForgeRegistryEntry> implements IRecipeSerializer { - public SmithingRecipe func_199425_a_(ResourceLocation p_199425_1_, JsonObject p_199425_2_) { - Ingredient ingredient = Ingredient.func_199802_a(JSONUtils.func_152754_s(p_199425_2_, "base")); - Ingredient ingredient1 = Ingredient.func_199802_a(JSONUtils.func_152754_s(p_199425_2_, "addition")); diff --git a/patches/minecraft/net/minecraft/item/crafting/SpecialRecipeSerializer.java.patch b/patches/minecraft/net/minecraft/item/crafting/SpecialRecipeSerializer.java.patch deleted file mode 100644 index 7d34609488..0000000000 --- a/patches/minecraft/net/minecraft/item/crafting/SpecialRecipeSerializer.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/item/crafting/SpecialRecipeSerializer.java -+++ b/net/minecraft/item/crafting/SpecialRecipeSerializer.java -@@ -5,7 +_,7 @@ - import net.minecraft.network.PacketBuffer; - import net.minecraft.util.ResourceLocation; - --public class SpecialRecipeSerializer> implements IRecipeSerializer { -+public class SpecialRecipeSerializer> extends net.minecraftforge.registries.ForgeRegistryEntry> implements IRecipeSerializer { - private final Function field_222176_t; - - public SpecialRecipeSerializer(Function p_i50024_1_) { diff --git a/patches/minecraft/net/minecraft/locale/Language.java.patch b/patches/minecraft/net/minecraft/locale/Language.java.patch new file mode 100644 index 0000000000..c82df77f5f --- /dev/null +++ b/patches/minecraft/net/minecraft/locale/Language.java.patch @@ -0,0 +1,34 @@ +--- a/net/minecraft/locale/Language.java ++++ b/net/minecraft/locale/Language.java +@@ -61,7 +_,8 @@ + f_128101_.error("Couldn't read strings from {}", "/assets/minecraft/lang/en_us.json", ioexception); + } + +- final Map map = builder.build(); ++ final Map map = new java.util.HashMap<>(builder.build()); ++ net.minecraftforge.fmllegacy.server.LanguageHook.captureLanguageMap(map); + return new Language() { + public String m_6834_(String p_128127_) { + return map.getOrDefault(p_128127_, p_128127_); +@@ -82,6 +_,11 @@ + }, Style.f_131099_).isPresent(); + }; + } ++ ++ @Override ++ public Map getLanguageData() { ++ return map; ++ } + }; + } + +@@ -102,6 +_,9 @@ + public static void m_128114_(Language p_128115_) { + f_128104_ = p_128115_; + } ++ ++ // FORGE START ++ public Map getLanguageData() { return ImmutableMap.of(); } + + public abstract String m_6834_(String p_128111_); + diff --git a/patches/minecraft/net/minecraft/loot/LootContext.java.patch b/patches/minecraft/net/minecraft/loot/LootContext.java.patch deleted file mode 100644 index 47ef3e7133..0000000000 --- a/patches/minecraft/net/minecraft/loot/LootContext.java.patch +++ /dev/null @@ -1,68 +0,0 @@ ---- a/net/minecraft/loot/LootContext.java -+++ b/net/minecraft/loot/LootContext.java -@@ -94,17 +_,47 @@ - return this.field_186499_b; - } - -+ // ============================== FORGE START ============================== -+ public int getLootingModifier() { -+ return net.minecraftforge.common.ForgeHooks.getLootingLevel(func_216031_c(LootParameters.field_216281_a), func_216031_c(LootParameters.field_216284_d), func_216031_c(LootParameters.field_216283_c)); -+ } -+ -+ private ResourceLocation queriedLootTableId; -+ -+ private LootContext(Random rand, float luckIn, ServerWorld worldIn, Function lootTableManagerIn, Function p_i225885_5_, Map, Object> parametersIn, Map conditionsIn, ResourceLocation queriedLootTableId) { -+ this(rand, luckIn, worldIn, lootTableManagerIn, p_i225885_5_, parametersIn, conditionsIn); -+ if (queriedLootTableId != null) this.queriedLootTableId = queriedLootTableId; -+ } -+ -+ public void setQueriedLootTableId(ResourceLocation queriedLootTableId) { -+ if (this.queriedLootTableId == null && queriedLootTableId != null) this.queriedLootTableId = queriedLootTableId; -+ } -+ public ResourceLocation getQueriedLootTableId() { -+ return this.queriedLootTableId == null? net.minecraftforge.common.loot.LootTableIdCondition.UNKNOWN_LOOT_TABLE : this.queriedLootTableId; -+ } -+ // =============================== FORGE END =============================== -+ - public static class Builder { - private final ServerWorld field_186474_a; - private final Map, Object> field_216025_b = Maps.newIdentityHashMap(); - private final Map field_216026_c = Maps.newHashMap(); - private Random field_216027_d; - private float field_186475_b; -+ private ResourceLocation queriedLootTableId; // Forge: correctly pass around loot table ID with copy constructor - - public Builder(ServerWorld p_i46993_1_) { - this.field_186474_a = p_i46993_1_; - } - -+ public Builder(LootContext context) { -+ this.field_186474_a = context.field_186499_b; -+ this.field_216025_b.putAll(context.field_216036_f); -+ this.field_216026_c.putAll(context.field_216037_g); -+ this.field_216027_d = context.field_216035_a; -+ this.field_186475_b = context.field_186498_a; -+ this.queriedLootTableId = context.queriedLootTableId; -+ } -+ - public LootContext.Builder func_216023_a(Random p_216023_1_) { - this.field_216027_d = p_216023_1_; - return this; -@@ -177,7 +_,7 @@ - - public LootContext func_216022_a(LootParameterSet p_216022_1_) { - Set> set = Sets.difference(this.field_216025_b.keySet(), p_216022_1_.func_216276_b()); -- if (!set.isEmpty()) { -+ if (false && !set.isEmpty()) { // Forge: Allow mods to pass custom loot parameters (not part of the vanilla loot table) to the loot context. - throw new IllegalArgumentException("Parameters not allowed in this parameter set: " + set); - } else { - Set> set1 = Sets.difference(p_216022_1_.func_216277_a(), this.field_216025_b.keySet()); -@@ -190,7 +_,7 @@ - } - - MinecraftServer minecraftserver = this.field_186474_a.func_73046_m(); -- return new LootContext(random, this.field_186475_b, this.field_186474_a, minecraftserver.func_200249_aQ()::func_186521_a, minecraftserver.func_229736_aP_()::func_227517_a_, this.field_216025_b, this.field_216026_c); -+ return new LootContext(random, this.field_186475_b, this.field_186474_a, minecraftserver.func_200249_aQ()::func_186521_a, minecraftserver.func_229736_aP_()::func_227517_a_, this.field_216025_b, this.field_216026_c, this.queriedLootTableId); - } - } - } diff --git a/patches/minecraft/net/minecraft/loot/LootParameterSets.java.patch b/patches/minecraft/net/minecraft/loot/LootParameterSets.java.patch deleted file mode 100644 index 36996187a3..0000000000 --- a/patches/minecraft/net/minecraft/loot/LootParameterSets.java.patch +++ /dev/null @@ -1,18 +0,0 @@ ---- a/net/minecraft/loot/LootParameterSets.java -+++ b/net/minecraft/loot/LootParameterSets.java -@@ -12,6 +_,7 @@ - }); - public static final LootParameterSet field_216261_b = func_216253_a("chest", (p_216259_0_) -> { - p_216259_0_.func_216269_a(LootParameters.field_237457_g_).func_216271_b(LootParameters.field_216281_a); -+ p_216259_0_.func_216271_b(LootParameters.field_216284_d); //Forge: Chest Minecarts can have killers. - }); - public static final LootParameterSet field_227557_c_ = func_216253_a("command", (p_216250_0_) -> { - p_216250_0_.func_216269_a(LootParameters.field_237457_g_).func_216271_b(LootParameters.field_216281_a); -@@ -21,6 +_,7 @@ - }); - public static final LootParameterSet field_216262_c = func_216253_a("fishing", (p_216258_0_) -> { - p_216258_0_.func_216269_a(LootParameters.field_237457_g_).func_216269_a(LootParameters.field_216289_i).func_216271_b(LootParameters.field_216281_a); -+ p_216258_0_.func_216271_b(LootParameters.field_216284_d).func_216271_b(LootParameters.field_216281_a); //Forge: Allow fisher, and bobber - }); - public static final LootParameterSet field_216263_d = func_216253_a("entity", (p_216251_0_) -> { - p_216251_0_.func_216269_a(LootParameters.field_216281_a).func_216269_a(LootParameters.field_237457_g_).func_216269_a(LootParameters.field_216283_c).func_216271_b(LootParameters.field_216284_d).func_216271_b(LootParameters.field_216285_e).func_216271_b(LootParameters.field_216282_b); diff --git a/patches/minecraft/net/minecraft/loot/LootPool.java.patch b/patches/minecraft/net/minecraft/loot/LootPool.java.patch deleted file mode 100644 index 1fb3fcc087..0000000000 --- a/patches/minecraft/net/minecraft/loot/LootPool.java.patch +++ /dev/null @@ -1,119 +0,0 @@ ---- a/net/minecraft/loot/LootPool.java -+++ b/net/minecraft/loot/LootPool.java -@@ -25,17 +_,19 @@ - import org.apache.commons.lang3.mutable.MutableInt; - - public class LootPool { -- private final LootEntry[] field_186453_a; -- private final ILootCondition[] field_186454_b; -+ private final String name; -+ private final List field_186453_a; -+ private final List field_186454_b; - private final Predicate field_216101_c; - private final ILootFunction[] field_216102_d; - private final BiFunction field_216103_e; - private IRandomRange field_186455_c; - private RandomValueRange field_186456_d; - -- private LootPool(LootEntry[] p_i51268_1_, ILootCondition[] p_i51268_2_, ILootFunction[] p_i51268_3_, IRandomRange p_i51268_4_, RandomValueRange p_i51268_5_) { -- this.field_186453_a = p_i51268_1_; -- this.field_186454_b = p_i51268_2_; -+ private LootPool(LootEntry[] p_i51268_1_, ILootCondition[] p_i51268_2_, ILootFunction[] p_i51268_3_, IRandomRange p_i51268_4_, RandomValueRange p_i51268_5_, String name) { -+ this.name = name; -+ this.field_186453_a = Lists.newArrayList(p_i51268_1_); -+ this.field_186454_b = Lists.newArrayList(p_i51268_2_); - this.field_216101_c = LootConditionManager.func_216305_a(p_i51268_2_); - this.field_216102_d = p_i51268_3_; - this.field_216103_e = LootFunctionManager.func_216241_a(p_i51268_3_); -@@ -92,19 +_,33 @@ - } - - public void func_227505_a_(ValidationTracker p_227505_1_) { -- for(int i = 0; i < this.field_186454_b.length; ++i) { -- this.field_186454_b[i].func_225580_a_(p_227505_1_.func_227534_b_(".condition[" + i + "]")); -+ for(int i = 0; i < this.field_186454_b.size(); ++i) { -+ this.field_186454_b.get(i).func_225580_a_(p_227505_1_.func_227534_b_(".condition[" + i + "]")); - } - - for(int j = 0; j < this.field_216102_d.length; ++j) { - this.field_216102_d[j].func_225580_a_(p_227505_1_.func_227534_b_(".functions[" + j + "]")); - } - -- for(int k = 0; k < this.field_186453_a.length; ++k) { -- this.field_186453_a[k].func_225579_a_(p_227505_1_.func_227534_b_(".entries[" + k + "]")); -+ for(int k = 0; k < this.field_186453_a.size(); ++k) { -+ this.field_186453_a.get(k).func_225579_a_(p_227505_1_.func_227534_b_(".entries[" + k + "]")); - } - - } -+ //======================== 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!"); -+ } -+ public String getName(){ return this.name; } -+ public IRandomRange getRolls() { return this.field_186455_c; } -+ public IRandomRange getBonusRolls() { return this.field_186456_d; } -+ public void setRolls (RandomValueRange v){ checkFrozen(); this.field_186455_c = v; } -+ public void setBonusRolls(RandomValueRange v){ checkFrozen(); this.field_186456_d = v; } -+ //======================== FORGE END =============================================== - - public static LootPool.Builder func_216096_a() { - return new LootPool.Builder(); -@@ -116,6 +_,7 @@ - private final List field_216049_c = Lists.newArrayList(); - private IRandomRange field_216050_d = new RandomValueRange(1.0F); - private RandomValueRange field_216051_e = new RandomValueRange(0.0F, 0.0F); -+ private String name; - - public LootPool.Builder func_216046_a(IRandomRange p_216046_1_) { - this.field_216050_d = p_216046_1_; -@@ -141,11 +_,21 @@ - return this; - } - -+ public LootPool.Builder name(String name) { -+ this.name = name; -+ return this; -+ } -+ -+ public LootPool.Builder bonusRolls(float min, float max) { -+ this.field_216051_e = new RandomValueRange(min, max); -+ return this; -+ } -+ - public LootPool func_216044_b() { - if (this.field_216050_d == null) { - throw new IllegalArgumentException("Rolls not set"); - } else { -- return new LootPool(this.field_216047_a.toArray(new LootEntry[0]), this.field_216048_b.toArray(new ILootCondition[0]), this.field_216049_c.toArray(new ILootFunction[0]), this.field_216050_d, this.field_216051_e); -+ return new LootPool(this.field_216047_a.toArray(new LootEntry[0]), this.field_216048_b.toArray(new ILootCondition[0]), this.field_216049_c.toArray(new ILootFunction[0]), this.field_216050_d, this.field_216051_e, name); - } - } - } -@@ -158,18 +_,20 @@ - ILootFunction[] ailootfunction = JSONUtils.func_188177_a(jsonobject, "functions", new ILootFunction[0], p_deserialize_3_, ILootFunction[].class); - IRandomRange irandomrange = RandomRanges.func_216130_a(jsonobject.get("rolls"), p_deserialize_3_); - RandomValueRange randomvaluerange = JSONUtils.func_188177_a(jsonobject, "bonus_rolls", new RandomValueRange(0.0F, 0.0F), p_deserialize_3_, RandomValueRange.class); -- return new LootPool(alootentry, ailootcondition, ailootfunction, irandomrange, randomvaluerange); -+ return new LootPool(alootentry, ailootcondition, ailootfunction, irandomrange, randomvaluerange, net.minecraftforge.common.ForgeHooks.readPoolName(jsonobject)); - } - - public JsonElement serialize(LootPool p_serialize_1_, Type p_serialize_2_, JsonSerializationContext p_serialize_3_) { - JsonObject jsonobject = new JsonObject(); -+ if (p_serialize_1_.name != null && !p_serialize_1_.name.startsWith("custom#")) -+ jsonobject.add("name", p_serialize_3_.serialize(p_serialize_1_.name)); - jsonobject.add("rolls", RandomRanges.func_216131_a(p_serialize_1_.field_186455_c, p_serialize_3_)); - jsonobject.add("entries", p_serialize_3_.serialize(p_serialize_1_.field_186453_a)); - if (p_serialize_1_.field_186456_d.func_186509_a() != 0.0F && p_serialize_1_.field_186456_d.func_186512_b() != 0.0F) { - jsonobject.add("bonus_rolls", p_serialize_3_.serialize(p_serialize_1_.field_186456_d)); - } - -- if (!ArrayUtils.isEmpty((Object[])p_serialize_1_.field_186454_b)) { -+ if (!p_serialize_1_.field_186454_b.isEmpty()) { - jsonobject.add("conditions", p_serialize_3_.serialize(p_serialize_1_.field_186454_b)); - } - diff --git a/patches/minecraft/net/minecraft/loot/LootTable.java.patch b/patches/minecraft/net/minecraft/loot/LootTable.java.patch deleted file mode 100644 index 2262dc77e9..0000000000 --- a/patches/minecraft/net/minecraft/loot/LootTable.java.patch +++ /dev/null @@ -1,103 +0,0 @@ ---- a/net/minecraft/loot/LootTable.java -+++ b/net/minecraft/loot/LootTable.java -@@ -31,13 +_,13 @@ - public static final LootTable field_186464_a = new LootTable(LootParameterSets.field_216260_a, new LootPool[0], new ILootFunction[0]); - public static final LootParameterSet field_216126_b = LootParameterSets.field_216266_g; - private final LootParameterSet field_216127_d; -- private final LootPool[] field_186466_c; -+ private final List field_186466_c; - private final ILootFunction[] field_216128_f; - private final BiFunction field_216129_g; - - private LootTable(LootParameterSet p_i51265_1_, LootPool[] p_i51265_2_, ILootFunction[] p_i51265_3_) { - this.field_216127_d = p_i51265_1_; -- this.field_186466_c = p_i51265_2_; -+ this.field_186466_c = Lists.newArrayList(p_i51265_2_); - this.field_216128_f = p_i51265_3_; - this.field_216129_g = LootFunctionManager.func_216241_a(p_i51265_3_); - } -@@ -75,6 +_,7 @@ - - } - -+ @Deprecated //Use other method or manually call ForgeHooks.modifyLoot - public void func_216120_b(LootContext p_216120_1_, Consumer p_216120_2_) { - this.func_216114_a(p_216120_1_, func_216124_a(p_216120_2_)); - } -@@ -82,6 +_,7 @@ - public List func_216113_a(LootContext p_216113_1_) { - List list = Lists.newArrayList(); - this.func_216120_b(p_216113_1_, list::add); -+ list = net.minecraftforge.common.ForgeHooks.modifyLoot(this.getLootTableId(), list, p_216113_1_); - return list; - } - -@@ -90,8 +_,8 @@ - } - - public void func_227506_a_(ValidationTracker p_227506_1_) { -- for(int i = 0; i < this.field_186466_c.length; ++i) { -- this.field_186466_c[i].func_227505_a_(p_227506_1_.func_227534_b_(".pools[" + i + "]")); -+ for(int i = 0; i < this.field_186466_c.size(); ++i) { -+ this.field_186466_c.get(i).func_227505_a_(p_227506_1_.func_227534_b_(".pools[" + i + "]")); - } - - for(int j = 0; j < this.field_216128_f.length; ++j) { -@@ -173,6 +_,48 @@ - return new LootTable.Builder(); - } - -+ //======================== FORGE START ============================================= -+ private boolean isFrozen = false; -+ public void freeze() { -+ this.isFrozen = true; -+ this.field_186466_c.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"); -+ this.lootTableId = java.util.Objects.requireNonNull(id); -+ } -+ public ResourceLocation getLootTableId() { return this.lootTableId; } -+ -+ public LootPool getPool(String name) { -+ return field_186466_c.stream().filter(e -> name.equals(e.getName())).findFirst().orElse(null); -+ } -+ -+ public LootPool removePool(String name) { -+ checkFrozen(); -+ for (LootPool pool : this.field_186466_c) { -+ if (name.equals(pool.getName())) { -+ this.field_186466_c.remove(pool); -+ return pool; -+ } -+ } -+ return null; -+ } -+ -+ public void addPool(LootPool pool) { -+ checkFrozen(); -+ if (field_186466_c.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()); -+ this.field_186466_c.add(pool); -+ } -+ //======================== FORGE END =============================================== -+ - public static class Builder implements ILootFunctionConsumer { - private final List field_216041_a = Lists.newArrayList(); - private final List field_216042_b = Lists.newArrayList(); -@@ -227,7 +_,7 @@ - } - } - -- if (p_serialize_1_.field_186466_c.length > 0) { -+ if (!p_serialize_1_.field_186466_c.isEmpty()) { - jsonobject.add("pools", p_serialize_3_.serialize(p_serialize_1_.field_186466_c)); - } - diff --git a/patches/minecraft/net/minecraft/loot/LootTableManager.java.patch b/patches/minecraft/net/minecraft/loot/LootTableManager.java.patch deleted file mode 100644 index 15689465fb..0000000000 --- a/patches/minecraft/net/minecraft/loot/LootTableManager.java.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/net/minecraft/loot/LootTableManager.java -+++ b/net/minecraft/loot/LootTableManager.java -@@ -36,8 +_,8 @@ - } - - p_212853_1_.forEach((p_237403_1_, p_237403_2_) -> { -- try { -- LootTable loottable = field_186526_b.fromJson(p_237403_2_, LootTable.class); -+ try (net.minecraft.resources.IResource res = p_212853_2_.func_199002_a(getPreparedPath(p_237403_1_));){ -+ LootTable loottable = net.minecraftforge.common.ForgeHooks.loadLootTable(field_186526_b, p_237403_1_, p_237403_2_, res == null || !res.func_199026_d().equals("Default"), this); - builder.put(p_237403_1_, loottable); - } catch (Exception exception) { - field_186525_a.error("Couldn't parse loot table {}", p_237403_1_, exception); diff --git a/patches/minecraft/net/minecraft/loot/conditions/RandomChanceWithLooting.java.patch b/patches/minecraft/net/minecraft/loot/conditions/RandomChanceWithLooting.java.patch deleted file mode 100644 index dff0cfbca0..0000000000 --- a/patches/minecraft/net/minecraft/loot/conditions/RandomChanceWithLooting.java.patch +++ /dev/null @@ -1,16 +0,0 @@ ---- a/net/minecraft/loot/conditions/RandomChanceWithLooting.java -+++ b/net/minecraft/loot/conditions/RandomChanceWithLooting.java -@@ -33,12 +_,7 @@ - } - - public boolean test(LootContext p_test_1_) { -- Entity entity = p_test_1_.func_216031_c(LootParameters.field_216284_d); -- int i = 0; -- if (entity instanceof LivingEntity) { -- i = EnchantmentHelper.func_185283_h((LivingEntity)entity); -- } -- -+ int i = p_test_1_.getLootingModifier(); - return p_test_1_.func_216032_b().nextFloat() < this.field_186627_a + (float)i * this.field_186628_b; - } - diff --git a/patches/minecraft/net/minecraft/loot/functions/LootingEnchantBonus.java.patch b/patches/minecraft/net/minecraft/loot/functions/LootingEnchantBonus.java.patch deleted file mode 100644 index 1b0f418924..0000000000 --- a/patches/minecraft/net/minecraft/loot/functions/LootingEnchantBonus.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/loot/functions/LootingEnchantBonus.java -+++ b/net/minecraft/loot/functions/LootingEnchantBonus.java -@@ -43,7 +_,7 @@ - public ItemStack func_215859_a(ItemStack p_215859_1_, LootContext p_215859_2_) { - Entity entity = p_215859_2_.func_216031_c(LootParameters.field_216284_d); - if (entity instanceof LivingEntity) { -- int i = EnchantmentHelper.func_185283_h((LivingEntity)entity); -+ int i = p_215859_2_.getLootingModifier(); - if (i == 0) { - return p_215859_1_; - } diff --git a/patches/minecraft/net/minecraft/loot/functions/Smelt.java.patch b/patches/minecraft/net/minecraft/loot/functions/Smelt.java.patch deleted file mode 100644 index 7c1414693a..0000000000 --- a/patches/minecraft/net/minecraft/loot/functions/Smelt.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/loot/functions/Smelt.java -+++ b/net/minecraft/loot/functions/Smelt.java -@@ -34,7 +_,7 @@ - ItemStack itemstack = optional.get().func_77571_b(); - if (!itemstack.func_190926_b()) { - ItemStack itemstack1 = itemstack.func_77946_l(); -- itemstack1.func_190920_e(p_215859_1_.func_190916_E()); -+ itemstack1.func_190920_e(p_215859_1_.func_190916_E() * itemstack.func_190916_E()); //Forge: Support smelting returning multiple - return itemstack1; - } - } diff --git a/patches/minecraft/net/minecraft/nbt/CompoundNBT.java.patch b/patches/minecraft/net/minecraft/nbt/CompoundNBT.java.patch deleted file mode 100644 index 5bb1e9b6d7..0000000000 --- a/patches/minecraft/net/minecraft/nbt/CompoundNBT.java.patch +++ /dev/null @@ -1,32 +0,0 @@ ---- a/net/minecraft/nbt/CompoundNBT.java -+++ b/net/minecraft/nbt/CompoundNBT.java -@@ -49,6 +_,7 @@ - while((b0 = CompoundNBT.func_152447_a(p_225649_1_, p_225649_3_)) != 0) { - String s = CompoundNBT.func_152448_b(p_225649_1_, p_225649_3_); - p_225649_3_.func_152450_a((long)(224 + 16 * s.length())); -+ p_225649_3_.func_152450_a(32); //Forge: 4 extra bytes for the object allocation. - INBT inbt = CompoundNBT.func_229680_b_(NBTTypes.func_229710_a_(b0), s, p_225649_1_, p_225649_2_ + 1, p_225649_3_); - if (map.put(s, inbt) != null) { - p_225649_3_.func_152450_a(288L); -@@ -104,6 +_,7 @@ - - @Nullable - public INBT func_218657_a(String p_218657_1_, INBT p_218657_2_) { -+ if (p_218657_2_ == null) throw new IllegalArgumentException("Invalid null NBT value with key " + p_218657_1_); - return this.field_74784_a.put(p_218657_1_, p_218657_2_); - } - -@@ -408,11 +_,12 @@ - } - - private static byte func_152447_a(DataInput p_152447_0_, NBTSizeTracker p_152447_1_) throws IOException { -+ p_152447_1_.func_152450_a(8); - return p_152447_0_.readByte(); - } - - private static String func_152448_b(DataInput p_152448_0_, NBTSizeTracker p_152448_1_) throws IOException { -- return p_152448_0_.readUTF(); -+ return p_152448_1_.readUTF(p_152448_0_.readUTF()); - } - - private static INBT func_229680_b_(INBTType p_229680_0_, String p_229680_1_, DataInput p_229680_2_, int p_229680_3_, NBTSizeTracker p_229680_4_) { diff --git a/patches/minecraft/net/minecraft/nbt/CompoundTag.java.patch b/patches/minecraft/net/minecraft/nbt/CompoundTag.java.patch new file mode 100644 index 0000000000..e6dc3a137e --- /dev/null +++ b/patches/minecraft/net/minecraft/nbt/CompoundTag.java.patch @@ -0,0 +1,32 @@ +--- a/net/minecraft/nbt/CompoundTag.java ++++ b/net/minecraft/nbt/CompoundTag.java +@@ -39,6 +_,7 @@ + while((b0 = CompoundTag.m_128420_(p_128485_, p_128487_)) != 0) { + String s = CompoundTag.m_128432_(p_128485_, p_128487_); + p_128487_.m_6800_((long)(224 + 16 * s.length())); ++ p_128487_.m_6800_(32); //Forge: 4 extra bytes for the object allocation. + Tag tag = CompoundTag.m_128413_(TagTypes.m_129397_(b0), s, p_128485_, p_128486_ + 1, p_128487_); + if (map.put(s, tag) != null) { + p_128487_.m_6800_(288L); +@@ -94,6 +_,7 @@ + + @Nullable + public Tag m_128365_(String p_128366_, Tag p_128367_) { ++ if (p_128367_ == null) throw new IllegalArgumentException("Invalid null NBT value with key " + p_128366_); + return this.f_128329_.put(p_128366_, p_128367_); + } + +@@ -386,11 +_,12 @@ + } + + static byte m_128420_(DataInput p_128421_, NbtAccounter p_128422_) throws IOException { ++ p_128422_.m_6800_(8); + return p_128421_.readByte(); + } + + static String m_128432_(DataInput p_128433_, NbtAccounter p_128434_) throws IOException { +- return p_128433_.readUTF(); ++ return p_128434_.readUTF(p_128433_.readUTF()); + } + + static Tag m_128413_(TagType p_128414_, String p_128415_, DataInput p_128416_, int p_128417_, NbtAccounter p_128418_) { diff --git a/patches/minecraft/net/minecraft/nbt/CompressedStreamTools.java.patch b/patches/minecraft/net/minecraft/nbt/CompressedStreamTools.java.patch deleted file mode 100644 index b89a4c1ba8..0000000000 --- a/patches/minecraft/net/minecraft/nbt/CompressedStreamTools.java.patch +++ /dev/null @@ -1,16 +0,0 @@ ---- a/net/minecraft/nbt/CompressedStreamTools.java -+++ b/net/minecraft/nbt/CompressedStreamTools.java -@@ -106,10 +_,12 @@ - - private static INBT func_152455_a(DataInput p_152455_0_, int p_152455_1_, NBTSizeTracker p_152455_2_) throws IOException { - byte b0 = p_152455_0_.readByte(); -+ p_152455_2_.func_152450_a(8); // Forge: Count everything! - if (b0 == 0) { - return EndNBT.field_229686_b_; - } else { -- p_152455_0_.readUTF(); -+ p_152455_2_.readUTF(p_152455_0_.readUTF()); //Forge: Count this string. -+ p_152455_2_.func_152450_a(32); //Forge: 4 extra bytes for the object allocation. - - try { - return NBTTypes.func_229710_a_(b0).func_225649_b_(p_152455_0_, p_152455_1_, p_152455_2_); diff --git a/patches/minecraft/net/minecraft/nbt/NBTSizeTracker.java.patch b/patches/minecraft/net/minecraft/nbt/NbtAccounter.java.patch similarity index 79% rename from patches/minecraft/net/minecraft/nbt/NBTSizeTracker.java.patch rename to patches/minecraft/net/minecraft/nbt/NbtAccounter.java.patch index a7527f2b42..8f9fd462f1 100644 --- a/patches/minecraft/net/minecraft/nbt/NBTSizeTracker.java.patch +++ b/patches/minecraft/net/minecraft/nbt/NbtAccounter.java.patch @@ -1,7 +1,7 @@ ---- a/net/minecraft/nbt/NBTSizeTracker.java -+++ b/net/minecraft/nbt/NBTSizeTracker.java +--- a/net/minecraft/nbt/NbtAccounter.java ++++ b/net/minecraft/nbt/NbtAccounter.java @@ -18,4 +_,34 @@ - throw new RuntimeException("Tried to read NBT tag that was too big; tried to allocate: " + this.field_152453_c + "bytes where max allowed: " + this.field_152452_b); + throw new RuntimeException("Tried to read NBT tag that was too big; tried to allocate: " + this.f_128919_ + "bytes where max allowed: " + this.f_128918_); } } + @@ -17,7 +17,7 @@ + * This will accurately count the correct byte length to encode this string, plus the 2 bytes for it's length prefix. + */ + public String readUTF(String data) { -+ func_152450_a(16); //Header length ++ m_6800_(16); //Header length + if (data == null) + return data; + @@ -30,7 +30,7 @@ + else if (c > 0x07FF) utflen += 3; + else utflen += 2; + } -+ func_152450_a(8 * utflen); ++ m_6800_(8 * utflen); + + return data; + } diff --git a/patches/minecraft/net/minecraft/nbt/NbtIo.java.patch b/patches/minecraft/net/minecraft/nbt/NbtIo.java.patch new file mode 100644 index 0000000000..e79d95893e --- /dev/null +++ b/patches/minecraft/net/minecraft/nbt/NbtIo.java.patch @@ -0,0 +1,16 @@ +--- a/net/minecraft/nbt/NbtIo.java ++++ b/net/minecraft/nbt/NbtIo.java +@@ -194,10 +_,12 @@ + + private static Tag m_128930_(DataInput p_128931_, int p_128932_, NbtAccounter p_128933_) throws IOException { + byte b0 = p_128931_.readByte(); ++ p_128933_.m_6800_(8); // Forge: Count everything! + if (b0 == 0) { + return EndTag.f_128534_; + } else { +- p_128931_.readUTF(); ++ p_128933_.readUTF(p_128931_.readUTF()); //Forge: Count this string. ++ p_128933_.m_6800_(32); //Forge: 4 extra bytes for the object allocation. + + try { + return TagTypes.m_129397_(b0).m_7300_(p_128931_, p_128932_, p_128933_); diff --git a/patches/minecraft/net/minecraft/nbt/StringNBT.java.patch b/patches/minecraft/net/minecraft/nbt/StringNBT.java.patch deleted file mode 100644 index 86ea890670..0000000000 --- a/patches/minecraft/net/minecraft/nbt/StringNBT.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/nbt/StringNBT.java -+++ b/net/minecraft/nbt/StringNBT.java -@@ -12,7 +_,7 @@ - public StringNBT func_225649_b_(DataInput p_225649_1_, int p_225649_2_, NBTSizeTracker p_225649_3_) throws IOException { - p_225649_3_.func_152450_a(288L); - String s = p_225649_1_.readUTF(); -- p_225649_3_.func_152450_a((long)(16 * s.length())); -+ p_225649_3_.readUTF(s); - return StringNBT.func_229705_a_(s); - } - diff --git a/patches/minecraft/net/minecraft/nbt/StringTag.java.patch b/patches/minecraft/net/minecraft/nbt/StringTag.java.patch new file mode 100644 index 0000000000..4c3599dffc --- /dev/null +++ b/patches/minecraft/net/minecraft/nbt/StringTag.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/nbt/StringTag.java ++++ b/net/minecraft/nbt/StringTag.java +@@ -11,7 +_,7 @@ + public StringTag m_7300_(DataInput p_129315_, int p_129316_, NbtAccounter p_129317_) throws IOException { + p_129317_.m_6800_(288L); + String s = p_129315_.readUTF(); +- p_129317_.m_6800_((long)(16 * s.length())); ++ p_129317_.readUTF(s); + return StringTag.m_129297_(s); + } + diff --git a/patches/minecraft/net/minecraft/network/CompressionEncoder.java.patch b/patches/minecraft/net/minecraft/network/CompressionEncoder.java.patch new file mode 100644 index 0000000000..702c163528 --- /dev/null +++ b/patches/minecraft/net/minecraft/network/CompressionEncoder.java.patch @@ -0,0 +1,24 @@ +--- a/net/minecraft/network/CompressionEncoder.java ++++ b/net/minecraft/network/CompressionEncoder.java +@@ -9,6 +_,8 @@ + private final byte[] f_129444_ = new byte[8192]; + private final Deflater f_129445_; + private int f_129446_; ++ private static final boolean DISABLE_PACKET_DEBUG = Boolean.parseBoolean(System.getProperty("forge.disablePacketCompressionDebug", "false")); ++ private static final org.apache.logging.log4j.Logger LOGGER = org.apache.logging.log4j.LogManager.getLogger(); + + public CompressionEncoder(int p_129448_) { + this.f_129446_ = p_129448_; +@@ -22,6 +_,12 @@ + friendlybytebuf.m_130130_(0); + friendlybytebuf.writeBytes(p_129453_); + } else { ++ if (!DISABLE_PACKET_DEBUG && i > 2097152) { ++ p_129453_.markReaderIndex(); ++ LOGGER.error("Attempted to send packet over maximum protocol size: {} > 2097152\nData:\n{}", i, ++ net.minecraftforge.fmllegacy.common.network.ByteBufUtils.getContentDump(p_129453_)); ++ p_129453_.resetReaderIndex(); ++ } + byte[] abyte = new byte[i]; + p_129453_.readBytes(abyte); + friendlybytebuf.m_130130_(abyte.length); diff --git a/patches/minecraft/net/minecraft/network/Connection.java.patch b/patches/minecraft/net/minecraft/network/Connection.java.patch new file mode 100644 index 0000000000..52d5751136 --- /dev/null +++ b/patches/minecraft/net/minecraft/network/Connection.java.patch @@ -0,0 +1,60 @@ +--- a/net/minecraft/network/Connection.java ++++ b/net/minecraft/network/Connection.java +@@ -77,6 +_,7 @@ + private float f_129477_; + private int f_129478_; + private boolean f_129479_; ++ private java.util.function.Consumer activationHandler; + + public Connection(PacketFlow p_129482_) { + this.f_129466_ = p_129482_; +@@ -86,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); +@@ -179,7 +_,7 @@ + ++this.f_129475_; + if (connectionprotocol1 != connectionprotocol) { + f_129465_.debug("Disabled auto read"); +- this.f_129468_.config().setAutoRead(false); ++ this.f_129468_.eventLoop().execute(()->this.f_129468_.config().setAutoRead(false)); + } + + if (this.f_129468_.eventLoop().inEventLoop()) { +@@ -277,7 +_,9 @@ + } + + public static Connection m_178300_(InetSocketAddress p_178301_, boolean p_178302_) { ++ if (p_178301_.getAddress() instanceof java.net.Inet6Address) System.setProperty("java.net.preferIPv4Stack", "false"); + final Connection connection = new Connection(PacketFlow.CLIENTBOUND); ++ connection.activationHandler = net.minecraftforge.fmllegacy.network.NetworkHooks::registerClientLoginChannel; + Class oclass; + LazyLoadedValue lazyloadedvalue; + if (Epoll.isAvailable() && p_178302_) { +@@ -303,6 +_,7 @@ + + public static Connection m_129493_(SocketAddress p_129494_) { + final Connection connection = new Connection(PacketFlow.CLIENTBOUND); ++ connection.activationHandler = net.minecraftforge.fmllegacy.network.NetworkHooks::registerClientLoginChannel; + (new Bootstrap()).group(f_129464_.m_13971_()).handler(new ChannelInitializer() { + protected void initChannel(Channel p_129557_) { + p_129557_.pipeline().addLast("packet_handler", connection); +@@ -389,6 +_,14 @@ + + public float m_129543_() { + return this.f_129477_; ++ } ++ ++ public Channel channel() { ++ return f_129468_; ++ } ++ ++ public PacketFlow getDirection() { ++ return this.f_129466_; + } + + static class PacketHolder { diff --git a/patches/minecraft/net/minecraft/network/FriendlyByteBuf.java.patch b/patches/minecraft/net/minecraft/network/FriendlyByteBuf.java.patch new file mode 100644 index 0000000000..0e5a446e26 --- /dev/null +++ b/patches/minecraft/net/minecraft/network/FriendlyByteBuf.java.patch @@ -0,0 +1,47 @@ +--- a/net/minecraft/network/FriendlyByteBuf.java ++++ b/net/minecraft/network/FriendlyByteBuf.java +@@ -52,7 +_,7 @@ + import net.minecraft.world.phys.BlockHitResult; + import net.minecraft.world.phys.Vec3; + +-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; + private static final int f_178337_ = 2097152; +@@ -439,6 +_,15 @@ + } + + public FriendlyByteBuf m_130055_(ItemStack p_130056_) { ++ return writeItemStack(p_130056_, true); ++ } ++ ++ /** ++ * Most ItemStack serialization is Server to Client,and doesn't need to know the FULL tag details. ++ * One exception is items from the creative menu, which must be sent from Client to Server with their full NBT. ++ * If you want to send the FULL tag set limitedTag to false ++ */ ++ public FriendlyByteBuf writeItemStack(ItemStack p_130056_, boolean limitedTag) { + if (p_130056_.m_41619_()) { + this.writeBoolean(false); + } else { +@@ -447,8 +_,8 @@ + this.m_130130_(Item.m_41393_(item)); + this.writeByte(p_130056_.m_41613_()); + CompoundTag compoundtag = null; +- if (item.m_41465_() || item.m_41468_()) { +- compoundtag = p_130056_.m_41783_(); ++ if (item.isDamageable(p_130056_) || item.m_41468_()) { ++ compoundtag = limitedTag ? p_130056_.getShareTag() : p_130056_.m_41783_(); + } + + this.m_130079_(compoundtag); +@@ -464,7 +_,7 @@ + int i = this.m_130242_(); + int j = this.readByte(); + ItemStack itemstack = new ItemStack(Item.m_41445_(i), j); +- itemstack.m_41751_(this.m_130260_()); ++ itemstack.readShareTag(this.m_130260_()); + return itemstack; + } + } diff --git a/patches/minecraft/net/minecraft/network/NettyCompressionEncoder.java.patch b/patches/minecraft/net/minecraft/network/NettyCompressionEncoder.java.patch deleted file mode 100644 index 95f3e54950..0000000000 --- a/patches/minecraft/net/minecraft/network/NettyCompressionEncoder.java.patch +++ /dev/null @@ -1,24 +0,0 @@ ---- a/net/minecraft/network/NettyCompressionEncoder.java -+++ b/net/minecraft/network/NettyCompressionEncoder.java -@@ -9,6 +_,8 @@ - private final byte[] field_179302_a = new byte[8192]; - private final Deflater field_179300_b; - private int field_179301_c; -+ private static final boolean DISABLE_PACKET_DEBUG = Boolean.parseBoolean(System.getProperty("forge.disablePacketCompressionDebug", "false")); -+ private static final org.apache.logging.log4j.Logger LOGGER = org.apache.logging.log4j.LogManager.getLogger(); - - public NettyCompressionEncoder(int p_i46005_1_) { - this.field_179301_c = p_i46005_1_; -@@ -22,6 +_,12 @@ - packetbuffer.func_150787_b(0); - packetbuffer.writeBytes(p_encode_2_); - } else { -+ if (!DISABLE_PACKET_DEBUG && i > 2097152) { -+ p_encode_2_.markReaderIndex(); -+ LOGGER.error("Attempted to send packet over maximum protocol size: {} > 2097152\nData:\n{}", i, -+ net.minecraftforge.fml.common.network.ByteBufUtils.getContentDump(p_encode_2_)); -+ p_encode_2_.resetReaderIndex(); -+ } - byte[] abyte = new byte[i]; - p_encode_2_.readBytes(abyte); - packetbuffer.func_150787_b(abyte.length); diff --git a/patches/minecraft/net/minecraft/network/NettyPacketEncoder.java.patch b/patches/minecraft/net/minecraft/network/NettyPacketEncoder.java.patch deleted file mode 100644 index ef2a515e1d..0000000000 --- a/patches/minecraft/net/minecraft/network/NettyPacketEncoder.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/network/NettyPacketEncoder.java -+++ b/net/minecraft/network/NettyPacketEncoder.java -@@ -37,7 +_,7 @@ - try { - p_encode_2_.func_148840_b(packetbuffer); - } catch (Throwable throwable) { -- field_150798_a.error(throwable); -+ field_150798_a.error("Error encoding packet", throwable); // Forge: Get Minecraft to spit out more information about the Throwable we got. - if (p_encode_2_.func_211402_a()) { - throw new SkipableEncoderException(throwable); - } else { diff --git a/patches/minecraft/net/minecraft/network/NetworkManager.java.patch b/patches/minecraft/net/minecraft/network/NetworkManager.java.patch deleted file mode 100644 index a14b4fe349..0000000000 --- a/patches/minecraft/net/minecraft/network/NetworkManager.java.patch +++ /dev/null @@ -1,60 +0,0 @@ ---- a/net/minecraft/network/NetworkManager.java -+++ b/net/minecraft/network/NetworkManager.java -@@ -74,6 +_,7 @@ - private float field_211397_t; - private int field_211398_u; - private boolean field_211399_v; -+ private java.util.function.Consumer activationHandler; - - public NetworkManager(PacketDirection p_i46004_1_) { - this.field_179294_g = p_i46004_1_; -@@ -83,6 +_,7 @@ - super.channelActive(p_channelActive_1_); - this.field_150746_k = p_channelActive_1_.channel(); - this.field_150743_l = this.field_150746_k.remoteAddress(); -+ if (activationHandler != null) activationHandler.accept(this); - - try { - this.func_150723_a(ProtocolType.HANDSHAKING); -@@ -171,7 +_,7 @@ - ++this.field_211395_r; - if (protocoltype1 != protocoltype) { - field_150735_g.debug("Disabled auto read"); -- this.field_150746_k.config().setAutoRead(false); -+ this.field_150746_k.eventLoop().execute(()->this.field_150746_k.config().setAutoRead(false)); - } - - if (this.field_150746_k.eventLoop().inEventLoop()) { -@@ -259,7 +_,9 @@ - - @OnlyIn(Dist.CLIENT) - public static NetworkManager func_181124_a(InetAddress p_181124_0_, int p_181124_1_, boolean p_181124_2_) { -+ if (p_181124_0_ instanceof java.net.Inet6Address) System.setProperty("java.net.preferIPv4Stack", "false"); - final NetworkManager networkmanager = new NetworkManager(PacketDirection.CLIENTBOUND); -+ networkmanager.activationHandler = net.minecraftforge.fml.network.NetworkHooks::registerClientLoginChannel; - Class oclass; - LazyValue lazyvalue; - if (Epoll.isAvailable() && p_181124_2_) { -@@ -286,6 +_,7 @@ - @OnlyIn(Dist.CLIENT) - public static NetworkManager func_150722_a(SocketAddress p_150722_0_) { - final NetworkManager networkmanager = new NetworkManager(PacketDirection.CLIENTBOUND); -+ networkmanager.activationHandler = net.minecraftforge.fml.network.NetworkHooks::registerClientLoginChannel; - (new Bootstrap()).group(field_179296_e.func_179281_c()).handler(new ChannelInitializer() { - protected void initChannel(Channel p_initChannel_1_) throws Exception { - p_initChannel_1_.pipeline().addLast("packet_handler", networkmanager); -@@ -374,6 +_,14 @@ - @OnlyIn(Dist.CLIENT) - public float func_211390_n() { - return this.field_211397_t; -+ } -+ -+ public Channel channel() { -+ return field_150746_k; -+ } -+ -+ public PacketDirection getDirection() { -+ return this.field_179294_g; - } - - static class QueuedPacket { diff --git a/patches/minecraft/net/minecraft/network/NetworkSystem.java.patch b/patches/minecraft/net/minecraft/network/NetworkSystem.java.patch deleted file mode 100644 index e3ea0b6ddd..0000000000 --- a/patches/minecraft/net/minecraft/network/NetworkSystem.java.patch +++ /dev/null @@ -1,34 +0,0 @@ ---- a/net/minecraft/network/NetworkSystem.java -+++ b/net/minecraft/network/NetworkSystem.java -@@ -41,11 +_,12 @@ - - public class NetworkSystem { - private static final Logger field_151275_b = LogManager.getLogger(); -+ private static final int READ_TIMEOUT = Integer.parseInt(System.getProperty("forge.readTimeout", "30")); - public static final LazyValue field_151276_c = new LazyValue<>(() -> { -- 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.common.thread.SidedThreadGroups.SERVER).build()); - }); - public static final LazyValue field_181141_b = new LazyValue<>(() -> { -- 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.common.thread.SidedThreadGroups.SERVER).build()); - }); - private final MinecraftServer field_151273_d; - public volatile boolean field_151277_a; -@@ -58,6 +_,7 @@ - } - - public void func_151265_a(@Nullable InetAddress p_151265_1_, int p_151265_2_) throws IOException { -+ if (p_151265_1_ instanceof java.net.Inet6Address) System.setProperty("java.net.preferIPv4Stack", "false"); - synchronized(this.field_151274_e) { - Class oclass; - LazyValue lazyvalue; -@@ -78,7 +_,7 @@ - } catch (ChannelException channelexception) { - } - -- p_initChannel_1_.pipeline().addLast("timeout", new ReadTimeoutHandler(30)).addLast("legacy_query", new LegacyPingHandler(NetworkSystem.this)).addLast("splitter", new NettyVarint21FrameDecoder()).addLast("decoder", new NettyPacketDecoder(PacketDirection.SERVERBOUND)).addLast("prepender", new NettyVarint21FrameEncoder()).addLast("encoder", new NettyPacketEncoder(PacketDirection.CLIENTBOUND)); -+ p_initChannel_1_.pipeline().addLast("timeout", new ReadTimeoutHandler(READ_TIMEOUT)).addLast("legacy_query", new LegacyPingHandler(NetworkSystem.this)).addLast("splitter", new NettyVarint21FrameDecoder()).addLast("decoder", new NettyPacketDecoder(PacketDirection.SERVERBOUND)).addLast("prepender", new NettyVarint21FrameEncoder()).addLast("encoder", new NettyPacketEncoder(PacketDirection.CLIENTBOUND)); - int i = NetworkSystem.this.field_151273_d.func_241871_k(); - NetworkManager networkmanager = (NetworkManager)(i > 0 ? new RateLimitedNetworkManager(i) : new NetworkManager(PacketDirection.SERVERBOUND)); - NetworkSystem.this.field_151272_f.add(networkmanager); diff --git a/patches/minecraft/net/minecraft/network/PacketBuffer.java.patch b/patches/minecraft/net/minecraft/network/PacketBuffer.java.patch deleted file mode 100644 index 15d00ed051..0000000000 --- a/patches/minecraft/net/minecraft/network/PacketBuffer.java.patch +++ /dev/null @@ -1,47 +0,0 @@ ---- a/net/minecraft/network/PacketBuffer.java -+++ b/net/minecraft/network/PacketBuffer.java -@@ -37,7 +_,7 @@ - import net.minecraft.util.math.vector.Vector3d; - import net.minecraft.util.text.ITextComponent; - --public class PacketBuffer extends ByteBuf { -+public class PacketBuffer extends ByteBuf implements net.minecraftforge.common.extensions.IForgePacketBuffer { - private final ByteBuf field_150794_a; - - public PacketBuffer(ByteBuf p_i45154_1_) { -@@ -287,6 +_,15 @@ - } - - public PacketBuffer func_150788_a(ItemStack p_150788_1_) { -+ return writeItemStack(p_150788_1_, true); -+ } -+ -+ /** -+ * Most ItemStack serialization is Server to Client,and doesn't need to know the FULL tag details. -+ * One exception is items from the creative menu, which must be sent from Client to Server with their full NBT. -+ * If you want to send the FULL tag set limitedTag to false -+ */ -+ public PacketBuffer writeItemStack(ItemStack p_150788_1_, boolean limitedTag) { - if (p_150788_1_.func_190926_b()) { - this.writeBoolean(false); - } else { -@@ -295,8 +_,8 @@ - this.func_150787_b(Item.func_150891_b(item)); - this.writeByte(p_150788_1_.func_190916_E()); - CompoundNBT compoundnbt = null; -- if (item.func_77645_m() || item.func_77651_p()) { -- compoundnbt = p_150788_1_.func_77978_p(); -+ if (item.isDamageable(p_150788_1_) || item.func_77651_p()) { -+ compoundnbt = limitedTag ? p_150788_1_.getShareTag() : p_150788_1_.func_77978_p(); - } - - this.func_150786_a(compoundnbt); -@@ -312,7 +_,7 @@ - int i = this.func_150792_a(); - int j = this.readByte(); - ItemStack itemstack = new ItemStack(Item.func_150899_d(i), j); -- itemstack.func_77982_d(this.func_150793_b()); -+ itemstack.readShareTag(this.func_150793_b()); - return itemstack; - } - } diff --git a/patches/minecraft/net/minecraft/network/PacketEncoder.java.patch b/patches/minecraft/net/minecraft/network/PacketEncoder.java.patch new file mode 100644 index 0000000000..a82efcce57 --- /dev/null +++ b/patches/minecraft/net/minecraft/network/PacketEncoder.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/network/PacketEncoder.java ++++ b/net/minecraft/network/PacketEncoder.java +@@ -44,7 +_,7 @@ + throw new IllegalArgumentException("Packet too big (is " + j + ", should be less than 8388608): " + p_130546_); + } + } catch (Throwable throwable) { +- f_130538_.error(throwable); ++ f_130538_.error("Error encoding packet", throwable); // Forge: Get Minecraft to spit out more information about the Throwable we got. + if (p_130546_.m_6588_()) { + throw new SkipPacketException(throwable); + } else { diff --git a/patches/minecraft/net/minecraft/network/ServerStatusResponse.java.patch b/patches/minecraft/net/minecraft/network/ServerStatusResponse.java.patch deleted file mode 100644 index 6778b73fe3..0000000000 --- a/patches/minecraft/net/minecraft/network/ServerStatusResponse.java.patch +++ /dev/null @@ -1,109 +0,0 @@ ---- a/net/minecraft/network/ServerStatusResponse.java -+++ b/net/minecraft/network/ServerStatusResponse.java -@@ -19,6 +_,16 @@ - private ServerStatusResponse.Players field_151324_b; - private ServerStatusResponse.Version field_151325_c; - private String field_151323_d; -+ private transient net.minecraftforge.fml.network.FMLStatusPing forgeData; -+ -+ public net.minecraftforge.fml.network.FMLStatusPing getForgeData() { -+ return this.forgeData; -+ } -+ -+ public void setForgeData(net.minecraftforge.fml.network.FMLStatusPing data){ -+ this.forgeData = data; -+ invalidateJson(); -+ } - - public ITextComponent func_151317_a() { - return this.field_151326_a; -@@ -26,6 +_,7 @@ - - public void func_151315_a(ITextComponent p_151315_1_) { - this.field_151326_a = p_151315_1_; -+ invalidateJson(); - } - - public ServerStatusResponse.Players func_151318_b() { -@@ -34,6 +_,7 @@ - - public void func_151319_a(ServerStatusResponse.Players p_151319_1_) { - this.field_151324_b = p_151319_1_; -+ invalidateJson(); - } - - public ServerStatusResponse.Version func_151322_c() { -@@ -42,16 +_,51 @@ - - public void func_151321_a(ServerStatusResponse.Version p_151321_1_) { - this.field_151325_c = p_151321_1_; -+ invalidateJson(); - } - - public void func_151320_a(String p_151320_1_) { - this.field_151323_d = p_151320_1_; -+ invalidateJson(); - } - - public String func_151316_d() { - return this.field_151323_d; - } - -+ private java.util.concurrent.Semaphore mutex = new java.util.concurrent.Semaphore(1); -+ private String json = null; -+ /** -+ * Returns this object as a Json string. -+ * Converting to JSON if a cached version is not available. -+ * -+ * Also to prevent potentially large memory allocations on the server -+ * this is moved from the SPacketServerInfo writePacket function -+ * -+ * As this method is called from the network threads so thread safety is important! -+ */ -+ public String getJson() { -+ String ret = this.json; -+ if (ret == null) { -+ mutex.acquireUninterruptibly(); -+ ret = this.json; -+ if (ret == null) { -+ ret = net.minecraft.network.status.server.SServerInfoPacket.field_149297_a.toJson(this); -+ this.json = ret; -+ } -+ mutex.release(); -+ } -+ return ret; -+ } -+ -+ /** -+ * Invalidates the cached json, causing the next call to getJson to rebuild it. -+ * This is needed externally because PlayerCountData.setPlayer's is public. -+ */ -+ public void invalidateJson() { -+ this.json = null; -+ } -+ - public static class Players { - private final int field_151336_a; - private final int field_151334_b; -@@ -143,6 +_,10 @@ - serverstatusresponse.func_151320_a(JSONUtils.func_151200_h(jsonobject, "favicon")); - } - -+ if (jsonobject.has("forgeData")) { -+ serverstatusresponse.setForgeData(net.minecraftforge.fml.network.FMLStatusPing.Serializer.deserialize(JSONUtils.func_152754_s(jsonobject, "forgeData"), p_deserialize_3_)); -+ } -+ - return serverstatusresponse; - } - -@@ -162,6 +_,10 @@ - - if (p_serialize_1_.func_151316_d() != null) { - jsonobject.addProperty("favicon", p_serialize_1_.func_151316_d()); -+ } -+ -+ if(p_serialize_1_.getForgeData() != null){ -+ jsonobject.add("forgeData", net.minecraftforge.fml.network.FMLStatusPing.Serializer.serialize(p_serialize_1_.getForgeData(), p_serialize_3_)); - } - - return jsonobject; diff --git a/patches/minecraft/net/minecraft/network/chat/Style.java.patch b/patches/minecraft/net/minecraft/network/chat/Style.java.patch new file mode 100644 index 0000000000..dbfb534199 --- /dev/null +++ b/patches/minecraft/net/minecraft/network/chat/Style.java.patch @@ -0,0 +1,21 @@ +--- a/net/minecraft/network/chat/Style.java ++++ b/net/minecraft/network/chat/Style.java +@@ -133,6 +_,18 @@ + return new Style(this.f_131101_, this.f_131102_, this.f_131103_, this.f_131104_, this.f_131105_, p_178525_, this.f_131107_, this.f_131108_, this.f_131109_, this.f_131110_); + } + ++ public Style setUnderlined(@Nullable Boolean underlined) { ++ return new Style(this.f_131101_, this.f_131102_, this.f_131103_, underlined, this.f_131105_, this.f_131106_, this.f_131107_, this.f_131108_, this.f_131109_, this.f_131110_); ++ } ++ ++ public Style setStrikethrough(@Nullable Boolean strikethrough) { ++ return new Style(this.f_131101_, this.f_131102_, this.f_131103_, this.f_131104_, strikethrough, this.f_131106_, this.f_131107_, this.f_131108_, this.f_131109_, this.f_131110_); ++ } ++ ++ public Style setObfuscated(@Nullable Boolean obfuscated) { ++ return new Style(this.f_131101_, this.f_131102_, this.f_131103_, this.f_131104_, this.f_131105_, obfuscated, this.f_131107_, this.f_131108_, this.f_131109_, this.f_131110_); ++ } ++ + public Style m_131142_(@Nullable ClickEvent p_131143_) { + return new Style(this.f_131101_, this.f_131102_, this.f_131103_, this.f_131104_, this.f_131105_, this.f_131106_, p_131143_, this.f_131108_, this.f_131109_, this.f_131110_); + } diff --git a/patches/minecraft/net/minecraft/network/chat/TranslatableComponent.java.patch b/patches/minecraft/net/minecraft/network/chat/TranslatableComponent.java.patch new file mode 100644 index 0000000000..11f8648d10 --- /dev/null +++ b/patches/minecraft/net/minecraft/network/chat/TranslatableComponent.java.patch @@ -0,0 +1,13 @@ +--- a/net/minecraft/network/chat/TranslatableComponent.java ++++ b/net/minecraft/network/chat/TranslatableComponent.java +@@ -87,6 +_,10 @@ + } + } + ++ if (j == 0) { ++ // if we failed to match above, lets try the messageformat handler instead. ++ j = net.minecraftforge.fmllegacy.TextComponentMessageFormatHandler.handle(this, this.f_131301_, this.f_131299_, p_131322_); ++ } + if (j < p_131322_.length()) { + String s3 = p_131322_.substring(j); + if (s3.indexOf(37) != -1) { diff --git a/patches/minecraft/net/minecraft/network/datasync/DataSerializers.java.patch b/patches/minecraft/net/minecraft/network/datasync/DataSerializers.java.patch deleted file mode 100644 index 6f8392de37..0000000000 --- a/patches/minecraft/net/minecraft/network/datasync/DataSerializers.java.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- a/net/minecraft/network/datasync/DataSerializers.java -+++ b/net/minecraft/network/datasync/DataSerializers.java -@@ -301,16 +_,16 @@ - }; - - public static void func_187189_a(IDataSerializer p_187189_0_) { -- field_187204_n.func_186808_c(p_187189_0_); -+ if (field_187204_n.func_186808_c(p_187189_0_) >= 256) throw new RuntimeException("Vanilla DataSerializer ID limit exceeded"); - } - - @Nullable - public static IDataSerializer func_187190_a(int p_187190_0_) { -- return field_187204_n.func_148745_a(p_187190_0_); -+ return net.minecraftforge.common.ForgeHooks.getSerializer(p_187190_0_, field_187204_n); - } - - public static int func_187188_b(IDataSerializer p_187188_0_) { -- return field_187204_n.func_148757_b(p_187188_0_); -+ return net.minecraftforge.common.ForgeHooks.getSerializerId(p_187188_0_, field_187204_n); - } - - static { diff --git a/patches/minecraft/net/minecraft/network/datasync/EntityDataManager.java.patch b/patches/minecraft/net/minecraft/network/datasync/EntityDataManager.java.patch deleted file mode 100644 index eb788a40e9..0000000000 --- a/patches/minecraft/net/minecraft/network/datasync/EntityDataManager.java.patch +++ /dev/null @@ -1,18 +0,0 @@ ---- a/net/minecraft/network/datasync/EntityDataManager.java -+++ b/net/minecraft/network/datasync/EntityDataManager.java -@@ -36,11 +_,13 @@ - } - - public static DataParameter func_187226_a(Class p_187226_0_, IDataSerializer p_187226_1_) { -- if (field_190303_a.isDebugEnabled()) { -+ if (true || field_190303_a.isDebugEnabled()) { // Forge: This is very useful for mods that register keys on classes that are not their own - try { - Class oclass = Class.forName(Thread.currentThread().getStackTrace()[2].getClassName()); - if (!oclass.equals(p_187226_0_)) { -- field_190303_a.debug("defineId called for: {} from {}", p_187226_0_, oclass, new RuntimeException()); -+ // Forge: log at warn, mods should not add to classes that they don't own, and only add stacktrace when in debug is enabled as it is mostly not needed and consumes time -+ if (field_190303_a.isDebugEnabled()) field_190303_a.warn("defineId called for: {} from {}", p_187226_0_, oclass, new RuntimeException()); -+ else field_190303_a.warn("defineId called for: {} from {}", p_187226_0_, oclass); - } - } catch (ClassNotFoundException classnotfoundexception) { - } diff --git a/patches/minecraft/net/minecraft/network/handshake/ServerHandshakeNetHandler.java.patch b/patches/minecraft/net/minecraft/network/handshake/ServerHandshakeNetHandler.java.patch deleted file mode 100644 index 39c1058b2f..0000000000 --- a/patches/minecraft/net/minecraft/network/handshake/ServerHandshakeNetHandler.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/network/handshake/ServerHandshakeNetHandler.java -+++ b/net/minecraft/network/handshake/ServerHandshakeNetHandler.java -@@ -23,6 +_,7 @@ - } - - public void func_147383_a(CHandshakePacket p_147383_1_) { -+ if (!net.minecraftforge.fml.server.ServerLifecycleHooks.handleServerLogin(p_147383_1_, this.field_147386_b)) return; - switch(p_147383_1_.func_149594_c()) { - case LOGIN: - this.field_147386_b.func_150723_a(ProtocolType.LOGIN); diff --git a/patches/minecraft/net/minecraft/network/handshake/client/CHandshakePacket.java.patch b/patches/minecraft/net/minecraft/network/handshake/client/CHandshakePacket.java.patch deleted file mode 100644 index a6ce7e7117..0000000000 --- a/patches/minecraft/net/minecraft/network/handshake/client/CHandshakePacket.java.patch +++ /dev/null @@ -1,35 +0,0 @@ ---- a/net/minecraft/network/handshake/client/CHandshakePacket.java -+++ b/net/minecraft/network/handshake/client/CHandshakePacket.java -@@ -14,6 +_,7 @@ - private String field_149598_b; - private int field_149599_c; - private ProtocolType field_149597_d; -+ private String fmlVersion = net.minecraftforge.fml.network.FMLNetworkConstants.NETVERSION; - - public CHandshakePacket() { - } -@@ -31,11 +_,13 @@ - this.field_149598_b = p_148837_1_.func_150789_c(255); - this.field_149599_c = p_148837_1_.readUnsignedShort(); - this.field_149597_d = ProtocolType.func_150760_a(p_148837_1_.func_150792_a()); -+ this.fmlVersion = net.minecraftforge.fml.network.NetworkHooks.getFMLVersion(this.field_149598_b); -+ this.field_149598_b = this.field_149598_b.split("\0")[0]; - } - - public void func_148840_b(PacketBuffer p_148840_1_) throws IOException { - p_148840_1_.func_150787_b(this.field_149600_a); -- p_148840_1_.func_180714_a(this.field_149598_b); -+ p_148840_1_.func_180714_a(this.field_149598_b + "\0"+net.minecraftforge.fml.network.FMLNetworkConstants.NETVERSION+"\0"); - p_148840_1_.writeShort(this.field_149599_c); - p_148840_1_.func_150787_b(this.field_149597_d.func_150759_c()); - } -@@ -50,5 +_,9 @@ - - public int func_149595_d() { - return this.field_149600_a; -+ } -+ -+ public String getFMLVersion() { -+ return this.fmlVersion; - } - } diff --git a/patches/minecraft/net/minecraft/network/login/ServerLoginNetHandler.java.patch b/patches/minecraft/net/minecraft/network/login/ServerLoginNetHandler.java.patch deleted file mode 100644 index ddf3535398..0000000000 --- a/patches/minecraft/net/minecraft/network/login/ServerLoginNetHandler.java.patch +++ /dev/null @@ -1,66 +0,0 @@ ---- a/net/minecraft/network/login/ServerLoginNetHandler.java -+++ b/net/minecraft/network/login/ServerLoginNetHandler.java -@@ -55,7 +_,13 @@ - } - - public void func_73660_a() { -- if (this.field_147328_g == ServerLoginNetHandler.State.READY_TO_ACCEPT) { -+ if (this.field_147328_g == 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.fml.network.NetworkHooks.tickNegotiation(this, this.field_147333_a, this.field_181025_l); -+ if (negotiationComplete) -+ this.field_147328_g = State.READY_TO_ACCEPT; -+ } else if (this.field_147328_g == ServerLoginNetHandler.State.READY_TO_ACCEPT) { - this.func_147326_c(); - } else if (this.field_147328_g == ServerLoginNetHandler.State.DELAY_ACCEPT) { - ServerPlayerEntity serverplayerentity = this.field_147327_f.func_184103_al().func_177451_a(this.field_147337_i.getId()); -@@ -130,7 +_,7 @@ - this.field_147328_g = ServerLoginNetHandler.State.KEY; - this.field_147333_a.func_179290_a(new SEncryptionRequestPacket("", this.field_147327_f.func_71250_E().getPublic().getEncoded(), this.field_147330_e)); - } else { -- this.field_147328_g = ServerLoginNetHandler.State.READY_TO_ACCEPT; -+ this.field_147328_g = ServerLoginNetHandler.State.NEGOTIATING; - } - - } -@@ -155,7 +_,7 @@ - throw new IllegalStateException("Protocol error", cryptexception); - } - -- Thread thread = new Thread("User Authenticator #" + field_147331_b.incrementAndGet()) { -+ Thread thread = new Thread(net.minecraftforge.fml.common.thread.SidedThreadGroups.SERVER, "User Authenticator #" + field_147331_b.incrementAndGet()) { - public void run() { - GameProfile gameprofile = ServerLoginNetHandler.this.field_147337_i; - -@@ -163,11 +_,11 @@ - ServerLoginNetHandler.this.field_147337_i = ServerLoginNetHandler.this.field_147327_f.func_147130_as().hasJoinedServer(new GameProfile((UUID)null, gameprofile.getName()), s, this.func_191235_a()); - if (ServerLoginNetHandler.this.field_147337_i != null) { - ServerLoginNetHandler.field_147332_c.info("UUID of player {} is {}", ServerLoginNetHandler.this.field_147337_i.getName(), ServerLoginNetHandler.this.field_147337_i.getId()); -- ServerLoginNetHandler.this.field_147328_g = ServerLoginNetHandler.State.READY_TO_ACCEPT; -+ ServerLoginNetHandler.this.field_147328_g = ServerLoginNetHandler.State.NEGOTIATING; - } else if (ServerLoginNetHandler.this.field_147327_f.func_71264_H()) { - ServerLoginNetHandler.field_147332_c.warn("Failed to verify username but will let them in anyway!"); - ServerLoginNetHandler.this.field_147337_i = ServerLoginNetHandler.this.func_152506_a(gameprofile); -- ServerLoginNetHandler.this.field_147328_g = ServerLoginNetHandler.State.READY_TO_ACCEPT; -+ ServerLoginNetHandler.this.field_147328_g = ServerLoginNetHandler.State.NEGOTIATING; - } else { - ServerLoginNetHandler.this.func_194026_b(new TranslationTextComponent("multiplayer.disconnect.unverified_username")); - ServerLoginNetHandler.field_147332_c.error("Username '{}' tried to join with an invalid session", (Object)gameprofile.getName()); -@@ -176,7 +_,7 @@ - if (ServerLoginNetHandler.this.field_147327_f.func_71264_H()) { - ServerLoginNetHandler.field_147332_c.warn("Authentication servers are down but will let them in anyway!"); - ServerLoginNetHandler.this.field_147337_i = ServerLoginNetHandler.this.func_152506_a(gameprofile); -- ServerLoginNetHandler.this.field_147328_g = ServerLoginNetHandler.State.READY_TO_ACCEPT; -+ ServerLoginNetHandler.this.field_147328_g = ServerLoginNetHandler.State.NEGOTIATING; - } else { - ServerLoginNetHandler.this.func_194026_b(new TranslationTextComponent("multiplayer.disconnect.authservers_down")); - ServerLoginNetHandler.field_147332_c.error("Couldn't verify username because servers are unavailable"); -@@ -196,6 +_,7 @@ - } - - public void func_209526_a(CCustomPayloadLoginPacket p_209526_1_) { -+ if (!net.minecraftforge.fml.network.NetworkHooks.onCustomPayload(p_209526_1_, this.field_147333_a)) - this.func_194026_b(new TranslationTextComponent("multiplayer.disconnect.unexpected_query_response")); - } - diff --git a/patches/minecraft/net/minecraft/network/login/client/CCustomPayloadLoginPacket.java.patch b/patches/minecraft/net/minecraft/network/login/client/CCustomPayloadLoginPacket.java.patch deleted file mode 100644 index a0ce1534dd..0000000000 --- a/patches/minecraft/net/minecraft/network/login/client/CCustomPayloadLoginPacket.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/network/login/client/CCustomPayloadLoginPacket.java -+++ b/net/minecraft/network/login/client/CCustomPayloadLoginPacket.java -@@ -8,7 +_,7 @@ - import net.minecraftforge.api.distmarker.Dist; - import net.minecraftforge.api.distmarker.OnlyIn; - --public class CCustomPayloadLoginPacket implements IPacket { -+public class CCustomPayloadLoginPacket implements IPacket, net.minecraftforge.fml.network.ICustomPacket { - private int field_209922_a; - private PacketBuffer field_209923_b; - diff --git a/patches/minecraft/net/minecraft/network/login/server/SCustomPayloadLoginPacket.java.patch b/patches/minecraft/net/minecraft/network/login/server/SCustomPayloadLoginPacket.java.patch deleted file mode 100644 index 69f48902ac..0000000000 --- a/patches/minecraft/net/minecraft/network/login/server/SCustomPayloadLoginPacket.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/network/login/server/SCustomPayloadLoginPacket.java -+++ b/net/minecraft/network/login/server/SCustomPayloadLoginPacket.java -@@ -8,7 +_,7 @@ - import net.minecraftforge.api.distmarker.Dist; - import net.minecraftforge.api.distmarker.OnlyIn; - --public class SCustomPayloadLoginPacket implements IPacket { -+public class SCustomPayloadLoginPacket implements IPacket, net.minecraftforge.fml.network.ICustomPacket { - private int field_209919_a; - private ResourceLocation field_209920_b; - private PacketBuffer field_209921_c; diff --git a/patches/minecraft/net/minecraft/network/play/ServerPlayNetHandler.java.patch b/patches/minecraft/net/minecraft/network/play/ServerPlayNetHandler.java.patch deleted file mode 100644 index 756a30299f..0000000000 --- a/patches/minecraft/net/minecraft/network/play/ServerPlayNetHandler.java.patch +++ /dev/null @@ -1,62 +0,0 @@ ---- a/net/minecraft/network/play/ServerPlayNetHandler.java -+++ b/net/minecraft/network/play/ServerPlayNetHandler.java -@@ -391,9 +_,11 @@ - } - - entity.func_70080_a(d3, d4, d5, f, f1); -+ this.field_147369_b.func_70080_a(d3, d4, d5, this.field_147369_b.field_70177_z, this.field_147369_b.field_70125_A); // Forge - Resync player position on vehicle moving - boolean flag2 = serverworld.func_226665_a__(entity, entity.func_174813_aQ().func_186664_h(0.0625D)); - if (flag && (flag1 || !flag2)) { - entity.func_70080_a(d0, d1, d2, f, f1); -+ this.field_147369_b.func_70080_a(d3, d4, d5, this.field_147369_b.field_70177_z, this.field_147369_b.field_70125_A); // Forge - Resync player position on vehicle moving - this.field_147371_a.func_179290_a(new SMoveVehiclePacket(entity)); - return; - } -@@ -410,7 +_,7 @@ - } - - private boolean func_241162_a_(Entity p_241162_1_) { -- return p_241162_1_.field_70170_p.func_234853_a_(p_241162_1_.func_174813_aQ().func_186662_g(0.0625D).func_72321_a(0.0D, -0.55D, 0.0D)).allMatch(AbstractBlock.AbstractBlockState::func_196958_f); -+ return BlockPos.func_239581_a_(p_241162_1_.func_174813_aQ().func_186662_g(0.0625D).func_72321_a(0.0D, -0.55D, 0.0D)).allMatch(b -> p_241162_1_.field_70170_p.func_180495_p(b).isAir(p_241162_1_.field_70170_p, b)); - } - - public void func_184339_a(CConfirmTeleportPacket p_184339_1_) { -@@ -950,7 +_,9 @@ - Direction direction = blockraytraceresult.func_216354_b(); - this.field_147369_b.func_143004_u(); - if (blockpos.func_177956_o() < this.field_147367_d.func_71207_Z()) { -- if (this.field_184362_y == null && this.field_147369_b.func_70092_e((double)blockpos.func_177958_n() + 0.5D, (double)blockpos.func_177956_o() + 0.5D, (double)blockpos.func_177952_p() + 0.5D) < 64.0D && serverworld.func_175660_a(this.field_147369_b, blockpos)) { -+ double dist = field_147369_b.func_110148_a(net.minecraftforge.common.ForgeMod.REACH_DISTANCE.get()).func_111126_e() + 3; -+ dist *= dist; -+ if (this.field_184362_y == null && this.field_147369_b.func_70092_e((double)blockpos.func_177958_n() + 0.5D, (double)blockpos.func_177956_o() + 0.5D, (double)blockpos.func_177952_p() + 0.5D) < dist && serverworld.func_175660_a(this.field_147369_b, blockpos)) { - ActionResultType actionresulttype = this.field_147369_b.field_71134_c.func_219441_a(this.field_147369_b, serverworld, itemstack, hand, blockraytraceresult); - if (direction == Direction.UP && !actionresulttype.func_226246_a_() && blockpos.func_177956_o() >= this.field_147367_d.func_71207_Z() - 1 && func_241166_a_(this.field_147369_b, itemstack)) { - ITextComponent itextcomponent = (new TranslationTextComponent("build.tooHigh", this.field_147367_d.func_71207_Z())).func_240699_a_(TextFormatting.RED); -@@ -1097,7 +_,9 @@ - if (p_244548_1_.startsWith("/")) { - this.func_147361_d(p_244548_1_); - } else { -- ITextComponent itextcomponent = new TranslationTextComponent("chat.type.text", this.field_147369_b.func_145748_c_(), p_244548_1_); -+ ITextComponent itextcomponent = new TranslationTextComponent("chat.type.text", this.field_147369_b.func_145748_c_(), net.minecraftforge.common.ForgeHooks.newChatWithLinks(p_244548_1_)); -+ itextcomponent = net.minecraftforge.common.ForgeHooks.onServerChatEvent(this, p_244548_1_, itextcomponent); -+ if (itextcomponent == null) return; - this.field_147367_d.func_184103_al().func_232641_a_(itextcomponent, ChatType.CHAT, this.field_147369_b.func_110124_au()); - } - -@@ -1187,6 +_,7 @@ - if (p_147340_1_.func_149565_c() == CUseEntityPacket.Action.INTERACT) { - optional = Optional.of(this.field_147369_b.func_190775_a(entity, hand)); - } else if (p_147340_1_.func_149565_c() == CUseEntityPacket.Action.INTERACT_AT) { -+ if (net.minecraftforge.common.ForgeHooks.onInteractEntityAt(field_147369_b, entity, p_147340_1_.func_179712_b(), hand) != null) return; - optional = Optional.of(entity.func_184199_a(this.field_147369_b, p_147340_1_.func_179712_b(), hand)); - } else if (p_147340_1_.func_149565_c() == CUseEntityPacket.Action.ATTACK) { - if (entity instanceof ItemEntity || entity instanceof ExperienceOrbEntity || entity instanceof AbstractArrowEntity || entity == this.field_147369_b) { -@@ -1402,6 +_,8 @@ - } - - public void func_147349_a(CCustomPayloadPacket p_147349_1_) { -+ PacketThreadUtil.func_218796_a(p_147349_1_, this, this.field_147369_b.func_71121_q()); -+ net.minecraftforge.fml.network.NetworkHooks.onCustomPayload(p_147349_1_, this.field_147371_a); - } - - public void func_217263_a(CSetDifficultyPacket p_217263_1_) { diff --git a/patches/minecraft/net/minecraft/network/play/client/CClickWindowPacket.java.patch b/patches/minecraft/net/minecraft/network/play/client/CClickWindowPacket.java.patch deleted file mode 100644 index 8c87e6baa6..0000000000 --- a/patches/minecraft/net/minecraft/network/play/client/CClickWindowPacket.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/network/play/client/CClickWindowPacket.java -+++ b/net/minecraft/network/play/client/CClickWindowPacket.java -@@ -49,7 +_,7 @@ - p_148840_1_.writeByte(this.field_149553_c); - p_148840_1_.writeShort(this.field_149550_d); - p_148840_1_.func_179249_a(this.field_149549_f); -- p_148840_1_.func_150788_a(this.field_149551_e); -+ p_148840_1_.writeItemStack(this.field_149551_e, false); //Forge: Include full tag for C->S - } - - public int func_149548_c() { diff --git a/patches/minecraft/net/minecraft/network/play/client/CClientSettingsPacket.java.patch b/patches/minecraft/net/minecraft/network/play/client/CClientSettingsPacket.java.patch deleted file mode 100644 index 837f3006de..0000000000 --- a/patches/minecraft/net/minecraft/network/play/client/CClientSettingsPacket.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/network/play/client/CClientSettingsPacket.java -+++ b/net/minecraft/network/play/client/CClientSettingsPacket.java -@@ -67,4 +_,8 @@ - public HandSide func_186991_f() { - return this.field_186992_f; - } -+ -+ public String func_149524_c() { -+ return this.field_149530_a; -+ } - } diff --git a/patches/minecraft/net/minecraft/network/play/client/CCreativeInventoryActionPacket.java.patch b/patches/minecraft/net/minecraft/network/play/client/CCreativeInventoryActionPacket.java.patch deleted file mode 100644 index 50d64ae8f2..0000000000 --- a/patches/minecraft/net/minecraft/network/play/client/CCreativeInventoryActionPacket.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/network/play/client/CCreativeInventoryActionPacket.java -+++ b/net/minecraft/network/play/client/CCreativeInventoryActionPacket.java -@@ -32,7 +_,7 @@ - - public void func_148840_b(PacketBuffer p_148840_1_) throws IOException { - p_148840_1_.writeShort(this.field_149629_a); -- p_148840_1_.func_150788_a(this.field_149628_b); -+ p_148840_1_.writeItemStack(this.field_149628_b, false); //Forge: Include full tag for C->S - } - - public int func_149627_c() { diff --git a/patches/minecraft/net/minecraft/network/play/client/CCustomPayloadPacket.java.patch b/patches/minecraft/net/minecraft/network/play/client/CCustomPayloadPacket.java.patch deleted file mode 100644 index d4720f1ee5..0000000000 --- a/patches/minecraft/net/minecraft/network/play/client/CCustomPayloadPacket.java.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/network/play/client/CCustomPayloadPacket.java -+++ b/net/minecraft/network/play/client/CCustomPayloadPacket.java -@@ -9,7 +_,7 @@ - import net.minecraftforge.api.distmarker.Dist; - import net.minecraftforge.api.distmarker.OnlyIn; - --public class CCustomPayloadPacket implements IPacket { -+public class CCustomPayloadPacket implements IPacket, net.minecraftforge.fml.network.ICustomPacket { - public static final ResourceLocation field_210344_a = new ResourceLocation("brand"); - private ResourceLocation field_149562_a; - private PacketBuffer field_149561_c; -@@ -35,7 +_,7 @@ - - public void func_148840_b(PacketBuffer p_148840_1_) throws IOException { - p_148840_1_.func_192572_a(this.field_149562_a); -- p_148840_1_.writeBytes((ByteBuf)this.field_149561_c); -+ p_148840_1_.writeBytes((ByteBuf)this.field_149561_c.copy()); //This may be access multiple times, from multiple threads, lets be safe like the S->C packet - } - - public void func_148833_a(IServerPlayNetHandler p_148833_1_) { diff --git a/patches/minecraft/net/minecraft/network/play/server/SCustomPayloadPlayPacket.java.patch b/patches/minecraft/net/minecraft/network/play/server/SCustomPayloadPlayPacket.java.patch deleted file mode 100644 index 0e298d41e7..0000000000 --- a/patches/minecraft/net/minecraft/network/play/server/SCustomPayloadPlayPacket.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/network/play/server/SCustomPayloadPlayPacket.java -+++ b/net/minecraft/network/play/server/SCustomPayloadPlayPacket.java -@@ -8,7 +_,7 @@ - import net.minecraftforge.api.distmarker.Dist; - import net.minecraftforge.api.distmarker.OnlyIn; - --public class SCustomPayloadPlayPacket implements IPacket { -+public class SCustomPayloadPlayPacket implements IPacket, net.minecraftforge.fml.network.ICustomPacket { - public static final ResourceLocation field_209911_b = new ResourceLocation("brand"); - public static final ResourceLocation field_209913_d = new ResourceLocation("debug/path"); - public static final ResourceLocation field_209914_e = new ResourceLocation("debug/neighbors_update"); diff --git a/patches/minecraft/net/minecraft/network/protocol/game/ClientboundCustomPayloadPacket.java.patch b/patches/minecraft/net/minecraft/network/protocol/game/ClientboundCustomPayloadPacket.java.patch new file mode 100644 index 0000000000..1465818887 --- /dev/null +++ b/patches/minecraft/net/minecraft/network/protocol/game/ClientboundCustomPayloadPacket.java.patch @@ -0,0 +1,11 @@ +--- 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.fmllegacy.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"); diff --git a/patches/minecraft/net/minecraft/network/protocol/game/ServerboundContainerClickPacket.java.patch b/patches/minecraft/net/minecraft/network/protocol/game/ServerboundContainerClickPacket.java.patch new file mode 100644 index 0000000000..47b2dbd503 --- /dev/null +++ b/patches/minecraft/net/minecraft/network/protocol/game/ServerboundContainerClickPacket.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/network/protocol/game/ServerboundContainerClickPacket.java ++++ b/net/minecraft/network/protocol/game/ServerboundContainerClickPacket.java +@@ -47,7 +_,7 @@ + p_133961_.writeByte(this.f_133941_); + p_133961_.m_130068_(this.f_133944_); + p_133961_.m_178355_(this.f_179569_, FriendlyByteBuf::writeShort, FriendlyByteBuf::m_130055_); +- p_133961_.m_130055_(this.f_179568_); ++ p_133961_.writeItemStack(this.f_179568_, false); //Forge: Include full tag for C->S + } + + public void m_5797_(ServerGamePacketListener p_133958_) { diff --git a/patches/minecraft/net/minecraft/network/protocol/game/ServerboundCustomPayloadPacket.java.patch b/patches/minecraft/net/minecraft/network/protocol/game/ServerboundCustomPayloadPacket.java.patch new file mode 100644 index 0000000000..3f6e1f09c5 --- /dev/null +++ b/patches/minecraft/net/minecraft/network/protocol/game/ServerboundCustomPayloadPacket.java.patch @@ -0,0 +1,20 @@ +--- 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.fmllegacy.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_.copy()); //This may be access multiple times, from multiple threads, lets be safe like the S->C packet + } + + public void m_5797_(ServerGamePacketListener p_133992_) { diff --git a/patches/minecraft/net/minecraft/network/protocol/game/ServerboundSetCreativeModeSlotPacket.java.patch b/patches/minecraft/net/minecraft/network/protocol/game/ServerboundSetCreativeModeSlotPacket.java.patch new file mode 100644 index 0000000000..2c33635a14 --- /dev/null +++ b/patches/minecraft/net/minecraft/network/protocol/game/ServerboundSetCreativeModeSlotPacket.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/network/protocol/game/ServerboundSetCreativeModeSlotPacket.java ++++ b/net/minecraft/network/protocol/game/ServerboundSetCreativeModeSlotPacket.java +@@ -24,7 +_,7 @@ + + public void m_5779_(FriendlyByteBuf p_134563_) { + p_134563_.writeShort(this.f_134549_); +- p_134563_.m_130055_(this.f_134550_); ++ p_134563_.writeItemStack(this.f_134550_, false); //Forge: Include full tag for C->S + } + + public int m_134561_() { diff --git a/patches/minecraft/net/minecraft/network/protocol/handshake/ClientIntentionPacket.java.patch b/patches/minecraft/net/minecraft/network/protocol/handshake/ClientIntentionPacket.java.patch new file mode 100644 index 0000000000..ce38de6a8e --- /dev/null +++ b/patches/minecraft/net/minecraft/network/protocol/handshake/ClientIntentionPacket.java.patch @@ -0,0 +1,39 @@ +--- 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.fmllegacy.network.FMLNetworkConstants.NETVERSION; + + public ClientIntentionPacket(String p_134726_, int p_134727_, ConnectionProtocol p_134728_) { + this.f_134720_ = SharedConstants.m_136187_().getProtocolVersion(); +@@ -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.fmllegacy.network.NetworkHooks.getFMLVersion(hostName); ++ this.f_134721_ = hostName.split("\0")[0]; + } + + 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.fmllegacy.network.FMLNetworkConstants.NETVERSION+"\0"); + p_134737_.writeShort(this.f_134722_); + p_134737_.m_130130_(this.f_134723_.m_129582_()); + } +@@ -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 new file mode 100644 index 0000000000..ad43712c87 --- /dev/null +++ b/patches/minecraft/net/minecraft/network/protocol/login/ClientboundCustomQueryPacket.java.patch @@ -0,0 +1,11 @@ +--- 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; + import net.minecraft.resources.ResourceLocation; + +-public class ClientboundCustomQueryPacket implements Packet { ++public class ClientboundCustomQueryPacket implements Packet, net.minecraftforge.fmllegacy.network.ICustomPacket { + private static final int f_179804_ = 1048576; + private final int f_134745_; + private final ResourceLocation f_134746_; diff --git a/patches/minecraft/net/minecraft/network/protocol/login/ServerboundCustomQueryPacket.java.patch b/patches/minecraft/net/minecraft/network/protocol/login/ServerboundCustomQueryPacket.java.patch new file mode 100644 index 0000000000..ac8eeebd9f --- /dev/null +++ b/patches/minecraft/net/minecraft/network/protocol/login/ServerboundCustomQueryPacket.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/network/protocol/login/ServerboundCustomQueryPacket.java ++++ b/net/minecraft/network/protocol/login/ServerboundCustomQueryPacket.java +@@ -4,7 +_,7 @@ + import net.minecraft.network.FriendlyByteBuf; + import net.minecraft.network.protocol.Packet; + +-public class ServerboundCustomQueryPacket implements Packet { ++public class ServerboundCustomQueryPacket implements Packet, net.minecraftforge.fmllegacy.network.ICustomPacket { + private static final int f_179821_ = 1048576; + private final int f_134825_; + private final FriendlyByteBuf f_134826_; diff --git a/patches/minecraft/net/minecraft/network/protocol/status/ClientboundStatusResponsePacket.java.patch b/patches/minecraft/net/minecraft/network/protocol/status/ClientboundStatusResponsePacket.java.patch new file mode 100644 index 0000000000..6074133519 --- /dev/null +++ b/patches/minecraft/net/minecraft/network/protocol/status/ClientboundStatusResponsePacket.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/network/protocol/status/ClientboundStatusResponsePacket.java ++++ b/net/minecraft/network/protocol/status/ClientboundStatusResponsePacket.java +@@ -22,7 +_,7 @@ + } + + public void m_5779_(FriendlyByteBuf p_134899_) { +- p_134899_.m_130070_(f_134885_.toJson(this.f_134886_)); ++ p_134899_.m_130070_(this.f_134886_.getJson()); //Forge: Let the response cache the JSON + } + + public void m_5797_(ClientStatusPacketListener p_134896_) { diff --git a/patches/minecraft/net/minecraft/network/protocol/status/ServerStatus.java.patch b/patches/minecraft/net/minecraft/network/protocol/status/ServerStatus.java.patch new file mode 100644 index 0000000000..b5d74dbf1c --- /dev/null +++ b/patches/minecraft/net/minecraft/network/protocol/status/ServerStatus.java.patch @@ -0,0 +1,109 @@ +--- a/net/minecraft/network/protocol/status/ServerStatus.java ++++ b/net/minecraft/network/protocol/status/ServerStatus.java +@@ -21,6 +_,16 @@ + private ServerStatus.Players f_134901_; + private ServerStatus.Version f_134902_; + private String f_134903_; ++ private transient net.minecraftforge.fmllegacy.network.FMLStatusPing forgeData; ++ ++ public net.minecraftforge.fmllegacy.network.FMLStatusPing getForgeData() { ++ return this.forgeData; ++ } ++ ++ public void setForgeData(net.minecraftforge.fmllegacy.network.FMLStatusPing data){ ++ this.forgeData = data; ++ invalidateJson(); ++ } + + public Component m_134905_() { + return this.f_134900_; +@@ -28,6 +_,7 @@ + + public void m_134908_(Component p_134909_) { + this.f_134900_ = p_134909_; ++ invalidateJson(); + } + + public ServerStatus.Players m_134914_() { +@@ -36,6 +_,7 @@ + + public void m_134910_(ServerStatus.Players p_134911_) { + this.f_134901_ = p_134911_; ++ invalidateJson(); + } + + public ServerStatus.Version m_134915_() { +@@ -44,16 +_,51 @@ + + public void m_134912_(ServerStatus.Version p_134913_) { + this.f_134902_ = p_134913_; ++ invalidateJson(); + } + + public void m_134906_(String p_134907_) { + this.f_134903_ = p_134907_; ++ invalidateJson(); + } + + public String m_134916_() { + return this.f_134903_; + } + ++ private java.util.concurrent.Semaphore mutex = new java.util.concurrent.Semaphore(1); ++ private String json = null; ++ /** ++ * Returns this object as a Json string. ++ * Converting to JSON if a cached version is not available. ++ * ++ * Also to prevent potentially large memory allocations on the server ++ * this is moved from the SPacketServerInfo writePacket function ++ * ++ * As this method is called from the network threads so thread safety is important! ++ */ ++ public String getJson() { ++ String ret = this.json; ++ if (ret == null) { ++ mutex.acquireUninterruptibly(); ++ ret = this.json; ++ if (ret == null) { ++ ret = net.minecraft.network.protocol.status.ClientboundStatusResponsePacket.f_134885_.toJson(this); ++ this.json = ret; ++ } ++ mutex.release(); ++ } ++ return ret; ++ } ++ ++ /** ++ * Invalidates the cached json, causing the next call to getJson to rebuild it. ++ * This is needed externally because PlayerCountData.setPlayer's is public. ++ */ ++ public void invalidateJson() { ++ this.json = null; ++ } ++ + public static class Players { + private final int f_134917_; + private final int f_134918_; +@@ -145,6 +_,10 @@ + serverstatus.m_134906_(GsonHelper.m_13906_(jsonobject, "favicon")); + } + ++ if (jsonobject.has("forgeData")) { ++ serverstatus.setForgeData(net.minecraftforge.fmllegacy.network.FMLStatusPing.Serializer.deserialize(GsonHelper.m_13930_(jsonobject, "forgeData"), p_134949_)); ++ } ++ + return serverstatus; + } + +@@ -164,6 +_,10 @@ + + if (p_134951_.m_134916_() != null) { + jsonobject.addProperty("favicon", p_134951_.m_134916_()); ++ } ++ ++ if(p_134951_.getForgeData() != null){ ++ jsonobject.add("forgeData", net.minecraftforge.fmllegacy.network.FMLStatusPing.Serializer.serialize(p_134951_.getForgeData(), p_134953_)); + } + + return jsonobject; diff --git a/patches/minecraft/net/minecraft/network/rcon/ClientThread.java.patch b/patches/minecraft/net/minecraft/network/rcon/ClientThread.java.patch deleted file mode 100644 index 3be730acec..0000000000 --- a/patches/minecraft/net/minecraft/network/rcon/ClientThread.java.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- a/net/minecraft/network/rcon/ClientThread.java -+++ b/net/minecraft/network/rcon/ClientThread.java -@@ -116,13 +_,14 @@ - } - - private void func_72655_a(int p_72655_1_, String p_72655_2_) throws IOException { -- int i = p_72655_2_.length(); -- -+ byte[] whole = p_72655_2_.getBytes(StandardCharsets.UTF_8); -+ int i = whole.length; -+ int start = 0; - do { - int j = 4096 <= i ? 4096 : i; -- this.func_72654_a(p_72655_1_, 0, p_72655_2_.substring(0, j)); -- p_72655_2_ = p_72655_2_.substring(j); -- i = p_72655_2_.length(); -+ this.func_72654_a(p_72655_1_, 0, new String(java.util.Arrays.copyOfRange(whole, start, j+start), StandardCharsets.UTF_8)); -+ i -= j; -+ start += j; - } while(0 != i); - - } diff --git a/patches/minecraft/net/minecraft/network/rcon/RConConsoleSource.java.patch b/patches/minecraft/net/minecraft/network/rcon/RConConsoleSource.java.patch deleted file mode 100644 index 352b5c8983..0000000000 --- a/patches/minecraft/net/minecraft/network/rcon/RConConsoleSource.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/network/rcon/RConConsoleSource.java -+++ b/net/minecraft/network/rcon/RConConsoleSource.java -@@ -34,7 +_,7 @@ - } - - public void func_145747_a(ITextComponent p_145747_1_, UUID p_145747_2_) { -- this.field_70009_b.append(p_145747_1_.getString()); -+ this.field_70009_b.append(p_145747_1_.getString()).append("\n"); // FIX MC-7569 - RCON has no newlines in multiline output - } - - public boolean func_195039_a() { diff --git a/patches/minecraft/net/minecraft/network/status/server/SServerInfoPacket.java.patch b/patches/minecraft/net/minecraft/network/status/server/SServerInfoPacket.java.patch deleted file mode 100644 index ff5a7239dc..0000000000 --- a/patches/minecraft/net/minecraft/network/status/server/SServerInfoPacket.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/network/status/server/SServerInfoPacket.java -+++ b/net/minecraft/network/status/server/SServerInfoPacket.java -@@ -30,7 +_,7 @@ - } - - public void func_148840_b(PacketBuffer p_148840_1_) throws IOException { -- p_148840_1_.func_180714_a(field_149297_a.toJson(this.field_149296_b)); -+ p_148840_1_.func_180714_a(this.field_149296_b.getJson()); //Forge: Let the response cache the JSON - } - - public void func_148833_a(IClientStatusNetHandler p_148833_1_) { diff --git a/patches/minecraft/net/minecraft/network/syncher/EntityDataSerializers.java.patch b/patches/minecraft/net/minecraft/network/syncher/EntityDataSerializers.java.patch new file mode 100644 index 0000000000..eb1340bd79 --- /dev/null +++ b/patches/minecraft/net/minecraft/network/syncher/EntityDataSerializers.java.patch @@ -0,0 +1,22 @@ +--- a/net/minecraft/network/syncher/EntityDataSerializers.java ++++ b/net/minecraft/network/syncher/EntityDataSerializers.java +@@ -301,16 +_,16 @@ + }; + + public static void m_135050_(EntityDataSerializer p_135051_) { +- f_135046_.m_13569_(p_135051_); ++ if (f_135046_.m_13569_(p_135051_) >= 256) throw new RuntimeException("Vanilla DataSerializer ID limit exceeded"); + } + + @Nullable + public static EntityDataSerializer m_135048_(int p_135049_) { +- return f_135046_.m_7942_(p_135049_); ++ return net.minecraftforge.common.ForgeHooks.getSerializer(p_135049_, f_135046_); + } + + public static int m_135052_(EntityDataSerializer p_135053_) { +- return f_135046_.m_7447_(p_135053_); ++ return net.minecraftforge.common.ForgeHooks.getSerializerId(p_135053_, f_135046_); + } + + private EntityDataSerializers() { diff --git a/patches/minecraft/net/minecraft/network/syncher/SynchedEntityData.java.patch b/patches/minecraft/net/minecraft/network/syncher/SynchedEntityData.java.patch new file mode 100644 index 0000000000..02b30fbfc6 --- /dev/null +++ b/patches/minecraft/net/minecraft/network/syncher/SynchedEntityData.java.patch @@ -0,0 +1,18 @@ +--- a/net/minecraft/network/syncher/SynchedEntityData.java ++++ b/net/minecraft/network/syncher/SynchedEntityData.java +@@ -37,11 +_,13 @@ + } + + public static EntityDataAccessor m_135353_(Class p_135354_, EntityDataSerializer p_135355_) { +- if (f_135342_.isDebugEnabled()) { ++ if (true || f_135342_.isDebugEnabled()) { // Forge: This is very useful for mods that register keys on classes that are not their own + try { + Class oclass = Class.forName(Thread.currentThread().getStackTrace()[2].getClassName()); + if (!oclass.equals(p_135354_)) { +- f_135342_.debug("defineId called for: {} from {}", p_135354_, oclass, new RuntimeException()); ++ // Forge: log at warn, mods should not add to classes that they don't own, and only add stacktrace when in debug is enabled as it is mostly not needed and consumes time ++ if (f_135342_.isDebugEnabled()) f_135342_.warn("defineId called for: {} from {}", p_135354_, oclass, new RuntimeException()); ++ else f_135342_.warn("defineId called for: {} from {}", p_135354_, oclass); + } + } catch (ClassNotFoundException classnotfoundexception) { + } diff --git a/patches/minecraft/net/minecraft/particles/BlockParticleData.java.patch b/patches/minecraft/net/minecraft/particles/BlockParticleData.java.patch deleted file mode 100644 index 8e9fd2f03b..0000000000 --- a/patches/minecraft/net/minecraft/particles/BlockParticleData.java.patch +++ /dev/null @@ -1,18 +0,0 @@ ---- a/net/minecraft/particles/BlockParticleData.java -+++ b/net/minecraft/particles/BlockParticleData.java -@@ -54,4 +_,15 @@ - public BlockState func_197584_c() { - return this.field_197587_c; - } -+ -+ //FORGE: Add a source pos property, so we can provide models with additional model data -+ private net.minecraft.util.math.BlockPos pos; -+ public BlockParticleData setPos(net.minecraft.util.math.BlockPos pos) { -+ this.pos = pos; -+ return this; -+ } -+ -+ public net.minecraft.util.math.BlockPos getPos() { -+ return pos; -+ } - } diff --git a/patches/minecraft/net/minecraft/particles/ItemParticleData.java.patch b/patches/minecraft/net/minecraft/particles/ItemParticleData.java.patch deleted file mode 100644 index 0bf23847db..0000000000 --- a/patches/minecraft/net/minecraft/particles/ItemParticleData.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/particles/ItemParticleData.java -+++ b/net/minecraft/particles/ItemParticleData.java -@@ -37,7 +_,7 @@ - - public ItemParticleData(ParticleType p_i47952_1_, ItemStack p_i47952_2_) { - this.field_197558_b = p_i47952_1_; -- this.field_197559_c = p_i47952_2_; -+ this.field_197559_c = p_i47952_2_.func_77946_l(); //Forge: Fix stack updating after the fact causing particle changes. - } - - public void func_197553_a(PacketBuffer p_197553_1_) { diff --git a/patches/minecraft/net/minecraft/particles/ParticleType.java.patch b/patches/minecraft/net/minecraft/particles/ParticleType.java.patch deleted file mode 100644 index c01c114c0b..0000000000 --- a/patches/minecraft/net/minecraft/particles/ParticleType.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/particles/ParticleType.java -+++ b/net/minecraft/particles/ParticleType.java -@@ -4,7 +_,7 @@ - import net.minecraftforge.api.distmarker.Dist; - import net.minecraftforge.api.distmarker.OnlyIn; - --public abstract class ParticleType { -+public abstract class ParticleType extends net.minecraftforge.registries.ForgeRegistryEntry>{ - private final boolean field_197581_e; - private final IParticleData.IDeserializer field_197582_f; - diff --git a/patches/minecraft/net/minecraft/particles/ParticleTypes.java.patch b/patches/minecraft/net/minecraft/particles/ParticleTypes.java.patch deleted file mode 100644 index 00b961d798..0000000000 --- a/patches/minecraft/net/minecraft/particles/ParticleTypes.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/particles/ParticleTypes.java -+++ b/net/minecraft/particles/ParticleTypes.java -@@ -4,6 +_,7 @@ - import java.util.function.Function; - import net.minecraft.util.registry.Registry; - -+@net.minecraftforge.registries.ObjectHolder("minecraft") - public class ParticleTypes { - public static final BasicParticleType field_197608_a = func_218415_a("ambient_entity_effect", false); - public static final BasicParticleType field_197609_b = func_218415_a("angry_villager", false); diff --git a/patches/minecraft/net/minecraft/pathfinding/ClimberPathNavigator.java.patch b/patches/minecraft/net/minecraft/pathfinding/ClimberPathNavigator.java.patch deleted file mode 100644 index 92fd1a7913..0000000000 --- a/patches/minecraft/net/minecraft/pathfinding/ClimberPathNavigator.java.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/net/minecraft/pathfinding/ClimberPathNavigator.java -+++ b/net/minecraft/pathfinding/ClimberPathNavigator.java -@@ -38,7 +_,8 @@ - super.func_75501_e(); - } else { - if (this.field_179696_f != null) { -- if (!this.field_179696_f.func_218137_a(this.field_75515_a.func_213303_ch(), (double)this.field_75515_a.func_213311_cf()) && (!(this.field_75515_a.func_226278_cu_() > (double)this.field_179696_f.func_177956_o()) || !(new BlockPos((double)this.field_179696_f.func_177958_n(), this.field_75515_a.func_226278_cu_(), (double)this.field_179696_f.func_177952_p())).func_218137_a(this.field_75515_a.func_213303_ch(), (double)this.field_75515_a.func_213311_cf()))) { -+ // FORGE: Fix MC-94054 -+ if (!this.field_179696_f.func_218137_a(this.field_75515_a.func_213303_ch(), Math.max((double)this.field_75515_a.func_213311_cf(), 1.0D)) && (!(this.field_75515_a.func_226278_cu_() > (double)this.field_179696_f.func_177956_o()) || !(new BlockPos((double)this.field_179696_f.func_177958_n(), this.field_75515_a.func_226278_cu_(), (double)this.field_179696_f.func_177952_p())).func_218137_a(this.field_75515_a.func_213303_ch(), Math.max((double)this.field_75515_a.func_213311_cf(), 1.0D)))) { - this.field_75515_a.func_70605_aq().func_75642_a((double)this.field_179696_f.func_177958_n(), (double)this.field_179696_f.func_177956_o(), (double)this.field_179696_f.func_177952_p(), this.field_75511_d); - } else { - this.field_179696_f = null; diff --git a/patches/minecraft/net/minecraft/pathfinding/PathNavigator.java.patch b/patches/minecraft/net/minecraft/pathfinding/PathNavigator.java.patch deleted file mode 100644 index 9550408308..0000000000 --- a/patches/minecraft/net/minecraft/pathfinding/PathNavigator.java.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/net/minecraft/pathfinding/PathNavigator.java -+++ b/net/minecraft/pathfinding/PathNavigator.java -@@ -208,9 +_,9 @@ - Vector3d vector3d = this.func_75502_i(); - this.field_188561_o = this.field_75515_a.func_213311_cf() > 0.75F ? this.field_75515_a.func_213311_cf() / 2.0F : 0.75F - this.field_75515_a.func_213311_cf() / 2.0F; - Vector3i vector3i = this.field_75514_c.func_242948_g(); -- double d0 = Math.abs(this.field_75515_a.func_226277_ct_() - ((double)vector3i.func_177958_n() + 0.5D)); -+ double d0 = Math.abs(this.field_75515_a.func_226277_ct_() - ((double)vector3i.func_177958_n() + (this.field_75515_a.func_213311_cf() + 1) / 2D)); //Forge: Fix MC-94054 - double d1 = Math.abs(this.field_75515_a.func_226278_cu_() - (double)vector3i.func_177956_o()); -- double d2 = Math.abs(this.field_75515_a.func_226281_cx_() - ((double)vector3i.func_177952_p() + 0.5D)); -+ double d2 = Math.abs(this.field_75515_a.func_226281_cx_() - ((double)vector3i.func_177952_p() + (this.field_75515_a.func_213311_cf() + 1) / 2D)); //Forge: Fix MC-94054 - boolean flag = d0 < (double)this.field_188561_o && d2 < (double)this.field_188561_o && d1 < 1.0D; - if (flag || this.field_75515_a.func_233660_b_(this.field_75514_c.func_237225_h_().field_186287_m) && this.func_234112_b_(vector3d)) { - this.field_75514_c.func_75875_a(); diff --git a/patches/minecraft/net/minecraft/pathfinding/WalkNodeProcessor.java.patch b/patches/minecraft/net/minecraft/pathfinding/WalkNodeProcessor.java.patch deleted file mode 100644 index 44e2e6143f..0000000000 --- a/patches/minecraft/net/minecraft/pathfinding/WalkNodeProcessor.java.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- a/net/minecraft/pathfinding/WalkNodeProcessor.java -+++ b/net/minecraft/pathfinding/WalkNodeProcessor.java -@@ -463,9 +_,11 @@ - - protected static PathNodeType func_237238_b_(IBlockReader p_237238_0_, BlockPos p_237238_1_) { - BlockState blockstate = p_237238_0_.func_180495_p(p_237238_1_); -+ PathNodeType type = blockstate.getAiPathNodeType(p_237238_0_, p_237238_1_); -+ if (type != null) return type; - Block block = blockstate.func_177230_c(); - Material material = blockstate.func_185904_a(); -- if (blockstate.func_196958_f()) { -+ if (blockstate.isAir(p_237238_0_, p_237238_1_)) { - return PathNodeType.OPEN; - } else if (!blockstate.func_235714_a_(BlockTags.field_212185_E) && !blockstate.func_203425_a(Blocks.field_196651_dG)) { - if (blockstate.func_203425_a(Blocks.field_150434_aF)) { diff --git a/patches/minecraft/net/minecraft/potion/Effect.java.patch b/patches/minecraft/net/minecraft/potion/Effect.java.patch deleted file mode 100644 index 0f12fa0b6a..0000000000 --- a/patches/minecraft/net/minecraft/potion/Effect.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/potion/Effect.java -+++ b/net/minecraft/potion/Effect.java -@@ -18,7 +_,7 @@ - import net.minecraft.util.text.ITextComponent; - import net.minecraft.util.text.TranslationTextComponent; - --public class Effect { -+public class Effect extends net.minecraftforge.registries.ForgeRegistryEntry implements net.minecraftforge.common.extensions.IForgeEffect { - private final Map field_111188_I = Maps.newHashMap(); - private final EffectType field_220305_b; - private final int field_76414_N; diff --git a/patches/minecraft/net/minecraft/potion/EffectInstance.java.patch b/patches/minecraft/net/minecraft/potion/EffectInstance.java.patch deleted file mode 100644 index 6b96959a7c..0000000000 --- a/patches/minecraft/net/minecraft/potion/EffectInstance.java.patch +++ /dev/null @@ -1,85 +0,0 @@ ---- a/net/minecraft/potion/EffectInstance.java -+++ b/net/minecraft/potion/EffectInstance.java -@@ -9,7 +_,7 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; - --public class EffectInstance implements Comparable { -+public class EffectInstance implements Comparable, net.minecraftforge.common.extensions.IForgeEffectInstance { - private static final Logger field_180155_a = LogManager.getLogger(); - private final Effect field_188420_b; - private int field_76460_b; -@@ -64,6 +_,7 @@ - this.field_82724_e = p_230117_1_.field_82724_e; - this.field_188421_h = p_230117_1_.field_188421_h; - this.field_205349_i = p_230117_1_.field_205349_i; -+ this.curativeItems = p_230117_1_.curativeItems == null ? null : new java.util.ArrayList(p_230117_1_.curativeItems); - } - - public boolean func_199308_a(EffectInstance p_199308_1_) { -@@ -112,7 +_,7 @@ - } - - public Effect func_188419_a() { -- return this.field_188420_b; -+ return this.field_188420_b == null ? null : this.field_188420_b.delegate.get(); - } - - public int func_76459_b() { -@@ -230,11 +_,12 @@ - this.field_230115_j_.func_82719_a(compoundnbt); - p_230119_1_.func_218657_a("HiddenEffect", compoundnbt); - } -+ writeCurativeItems(p_230119_1_); - - } - - public static EffectInstance func_82722_b(CompoundNBT p_82722_0_) { -- int i = p_82722_0_.func_74771_c("Id"); -+ int i = p_82722_0_.func_74771_c("Id") & 0xFF; - Effect effect = Effect.func_188412_a(i); - return effect == null ? null : func_230116_a_(effect, p_82722_0_); - } -@@ -258,7 +_,7 @@ - effectinstance = func_230116_a_(p_230116_0_, p_230116_1_.func_74775_l("HiddenEffect")); - } - -- return new EffectInstance(p_230116_0_, j, i < 0 ? 0 : i, flag, flag1, flag2, effectinstance); -+ return readCurativeItems(new EffectInstance(p_230116_0_, j, i < 0 ? 0 : i, flag, flag1, flag2, effectinstance), p_230116_1_); - } - - @OnlyIn(Dist.CLIENT) -@@ -273,6 +_,32 @@ - - public int compareTo(EffectInstance p_compareTo_1_) { - int i = 32147; -- return (this.func_76459_b() <= 32147 || p_compareTo_1_.func_76459_b() <= 32147) && (!this.func_82720_e() || !p_compareTo_1_.func_82720_e()) ? ComparisonChain.start().compare(this.func_82720_e(), p_compareTo_1_.func_82720_e()).compare(this.func_76459_b(), p_compareTo_1_.func_76459_b()).compare(this.func_188419_a().func_76401_j(), p_compareTo_1_.func_188419_a().func_76401_j()).result() : ComparisonChain.start().compare(this.func_82720_e(), p_compareTo_1_.func_82720_e()).compare(this.func_188419_a().func_76401_j(), p_compareTo_1_.func_188419_a().func_76401_j()).result(); -+ return (this.func_76459_b() <= 32147 || p_compareTo_1_.func_76459_b() <= 32147) && (!this.func_82720_e() || !p_compareTo_1_.func_82720_e()) ? ComparisonChain.start().compare(this.func_82720_e(), p_compareTo_1_.func_82720_e()).compare(this.func_76459_b(), p_compareTo_1_.func_76459_b()).compare(this.func_188419_a().getGuiSortColor(this), p_compareTo_1_.func_188419_a().getGuiSortColor(this)).result() : ComparisonChain.start().compare(this.func_82720_e(), p_compareTo_1_.func_82720_e()).compare(this.func_188419_a().getGuiSortColor(this), p_compareTo_1_.func_188419_a().getGuiSortColor(this)).result(); -+ } -+ -+ //======================= FORGE START =========================== -+ private java.util.List curativeItems; -+ -+ @Override -+ public java.util.List getCurativeItems() { -+ if (this.curativeItems == null) //Lazy load this so that we don't create a circular dep on Items. -+ this.curativeItems = func_188419_a().getCurativeItems(); -+ return this.curativeItems; -+ } -+ @Override -+ public void setCurativeItems(java.util.List curativeItems) { -+ this.curativeItems = curativeItems; -+ } -+ private static EffectInstance readCurativeItems(EffectInstance effect, CompoundNBT nbt) { -+ if (nbt.func_150297_b("CurativeItems", net.minecraftforge.common.util.Constants.NBT.TAG_LIST)) { -+ java.util.List items = new java.util.ArrayList(); -+ net.minecraft.nbt.ListNBT list = nbt.func_150295_c("CurativeItems", net.minecraftforge.common.util.Constants.NBT.TAG_COMPOUND); -+ for (int i = 0; i < list.size(); i++) { -+ items.add(net.minecraft.item.ItemStack.func_199557_a(list.func_150305_b(i))); -+ } -+ effect.setCurativeItems(items); -+ } -+ -+ return effect; - } - } diff --git a/patches/minecraft/net/minecraft/potion/Effects.java.patch b/patches/minecraft/net/minecraft/potion/Effects.java.patch deleted file mode 100644 index 1018313b8e..0000000000 --- a/patches/minecraft/net/minecraft/potion/Effects.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/potion/Effects.java -+++ b/net/minecraft/potion/Effects.java -@@ -8,6 +_,7 @@ - import net.minecraft.world.Difficulty; - import net.minecraft.world.server.ServerWorld; - -+@net.minecraftforge.registries.ObjectHolder("minecraft") - public class Effects { - public static final Effect field_76424_c = func_220308_a(1, "speed", (new Effect(EffectType.BENEFICIAL, 8171462)).func_220304_a(Attributes.field_233821_d_, "91AEAA56-376B-4498-935B-2F7F68070635", (double)0.2F, AttributeModifier.Operation.MULTIPLY_TOTAL)); - public static final Effect field_76421_d = func_220308_a(2, "slowness", (new Effect(EffectType.HARMFUL, 5926017)).func_220304_a(Attributes.field_233821_d_, "7107DE5E-7CE8-4030-940E-514C1F160890", (double)-0.15F, AttributeModifier.Operation.MULTIPLY_TOTAL)); diff --git a/patches/minecraft/net/minecraft/potion/Potion.java.patch b/patches/minecraft/net/minecraft/potion/Potion.java.patch deleted file mode 100644 index aacc9bb081..0000000000 --- a/patches/minecraft/net/minecraft/potion/Potion.java.patch +++ /dev/null @@ -1,27 +0,0 @@ ---- a/net/minecraft/potion/Potion.java -+++ b/net/minecraft/potion/Potion.java -@@ -6,7 +_,8 @@ - import net.minecraft.util.ResourceLocation; - import net.minecraft.util.registry.Registry; - --public class Potion { -+public class Potion extends net.minecraftforge.registries.ForgeRegistryEntry { -+ private final net.minecraftforge.common.util.ReverseTagWrapper reverseTags = new net.minecraftforge.common.util.ReverseTagWrapper<>(this, () -> net.minecraft.tags.TagCollectionManager.func_242178_a().getCustomTypeCollection(net.minecraftforge.registries.ForgeRegistries.POTION_TYPES)); - private final String field_185179_d; - private final ImmutableList field_185180_e; - -@@ -21,6 +_,14 @@ - public Potion(@Nullable String p_i46740_1_, EffectInstance... p_i46740_2_) { - this.field_185179_d = p_i46740_1_; - this.field_185180_e = ImmutableList.copyOf(p_i46740_2_); -+ } -+ -+ public java.util.Set getTags() { -+ return reverseTags.getTagNames(); -+ } -+ -+ public boolean isIn(net.minecraft.tags.ITag tag) { -+ return tag.func_230235_a_(this); - } - - public String func_185174_b(String p_185174_1_) { diff --git a/patches/minecraft/net/minecraft/potion/PotionBrewing.java.patch b/patches/minecraft/net/minecraft/potion/PotionBrewing.java.patch deleted file mode 100644 index e6a61c49e9..0000000000 --- a/patches/minecraft/net/minecraft/potion/PotionBrewing.java.patch +++ /dev/null @@ -1,72 +0,0 @@ ---- a/net/minecraft/potion/PotionBrewing.java -+++ b/net/minecraft/potion/PotionBrewing.java -@@ -56,7 +_,7 @@ - int i = 0; - - for(int j = field_185213_a.size(); i < j; ++i) { -- if ((field_185213_a.get(i)).field_185200_c == p_222124_0_) { -+ if ((field_185213_a.get(i)).field_185200_c.get() == p_222124_0_) { - return true; - } - } -@@ -78,7 +_,7 @@ - - for(int j = field_185214_b.size(); i < j; ++i) { - PotionBrewing.MixPredicate mixpredicate = field_185214_b.get(i); -- if (mixpredicate.field_185198_a == item && mixpredicate.field_185199_b.test(p_185206_1_)) { -+ if (mixpredicate.field_185198_a.get() == item && mixpredicate.field_185199_b.test(p_185206_1_)) { - return true; - } - } -@@ -92,7 +_,7 @@ - - for(int j = field_185213_a.size(); i < j; ++i) { - PotionBrewing.MixPredicate mixpredicate = field_185213_a.get(i); -- if (mixpredicate.field_185198_a == potion && mixpredicate.field_185199_b.test(p_185209_1_)) { -+ if (mixpredicate.field_185198_a.get() == potion && mixpredicate.field_185199_b.test(p_185209_1_)) { - return true; - } - } -@@ -108,8 +_,8 @@ - - for(int j = field_185214_b.size(); i < j; ++i) { - PotionBrewing.MixPredicate mixpredicate = field_185214_b.get(i); -- if (mixpredicate.field_185198_a == item && mixpredicate.field_185199_b.test(p_185212_0_)) { -- return PotionUtils.func_185188_a(new ItemStack(mixpredicate.field_185200_c), potion); -+ if (mixpredicate.field_185198_a.get() == item && mixpredicate.field_185199_b.test(p_185212_0_)) { -+ return PotionUtils.func_185188_a(new ItemStack(mixpredicate.field_185200_c.get()), potion); - } - } - -@@ -117,8 +_,8 @@ - - for(int k = field_185213_a.size(); i < k; ++i) { - PotionBrewing.MixPredicate mixpredicate1 = field_185213_a.get(i); -- if (mixpredicate1.field_185198_a == potion && mixpredicate1.field_185199_b.test(p_185212_0_)) { -- return PotionUtils.func_185188_a(new ItemStack(item), mixpredicate1.field_185200_c); -+ if (mixpredicate1.field_185198_a.get() == potion && mixpredicate1.field_185199_b.test(p_185212_0_)) { -+ return PotionUtils.func_185188_a(new ItemStack(item), mixpredicate1.field_185200_c.get()); - } - } - } -@@ -211,15 +_,15 @@ - field_185213_a.add(new PotionBrewing.MixPredicate<>(p_193357_0_, Ingredient.func_199804_a(p_193357_1_), p_193357_2_)); - } - -- static class MixPredicate { -- private final T field_185198_a; -+ public static class MixPredicate> { -+ public final net.minecraftforge.registries.IRegistryDelegate field_185198_a; - private final Ingredient field_185199_b; -- private final T field_185200_c; -+ public final net.minecraftforge.registries.IRegistryDelegate field_185200_c; - - public MixPredicate(T p_i47570_1_, Ingredient p_i47570_2_, T p_i47570_3_) { -- this.field_185198_a = p_i47570_1_; -+ this.field_185198_a = p_i47570_1_.delegate; - this.field_185199_b = p_i47570_2_; -- this.field_185200_c = p_i47570_3_; -+ this.field_185200_c = p_i47570_3_.delegate; - } - } - } diff --git a/patches/minecraft/net/minecraft/recipebook/PlaceRecipe.java.patch b/patches/minecraft/net/minecraft/recipebook/PlaceRecipe.java.patch new file mode 100644 index 0000000000..193e21f3c8 --- /dev/null +++ b/patches/minecraft/net/minecraft/recipebook/PlaceRecipe.java.patch @@ -0,0 +1,17 @@ +--- a/net/minecraft/recipebook/PlaceRecipe.java ++++ b/net/minecraft/recipebook/PlaceRecipe.java +@@ -9,10 +_,10 @@ + default void m_135408_(int p_135409_, int p_135410_, int p_135411_, Recipe p_135412_, Iterator p_135413_, int p_135414_) { + int i = p_135409_; + int j = p_135410_; +- if (p_135412_ instanceof ShapedRecipe) { +- ShapedRecipe shapedrecipe = (ShapedRecipe)p_135412_; +- 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_; ++ i = shapedrecipe.getRecipeWidth(); ++ j = shapedrecipe.getRecipeHeight(); + } + + int k1 = 0; diff --git a/patches/minecraft/net/minecraft/resources/DataPackRegistries.java.patch b/patches/minecraft/net/minecraft/resources/DataPackRegistries.java.patch deleted file mode 100644 index 1f22d61d0b..0000000000 --- a/patches/minecraft/net/minecraft/resources/DataPackRegistries.java.patch +++ /dev/null @@ -1,18 +0,0 @@ ---- a/net/minecraft/resources/DataPackRegistries.java -+++ b/net/minecraft/resources/DataPackRegistries.java -@@ -32,6 +_,7 @@ - this.field_240952_b_.func_219534_a(this.field_240957_g_); - this.field_240952_b_.func_219534_a(this.field_240959_i_); - this.field_240952_b_.func_219534_a(this.field_240958_h_); -+ net.minecraftforge.event.ForgeEventFactory.onResourceReload(this).forEach(field_240952_b_::func_219534_a); - } - - public FunctionReloader func_240960_a_() { -@@ -81,6 +_,7 @@ - - public void func_240971_i_() { - this.field_240955_e_.func_242231_a().func_242212_e(); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.TagsUpdatedEvent.CustomTagTypes(field_240955_e_.func_242231_a())); - } - - public void close() { diff --git a/patches/minecraft/net/minecraft/resources/IResourceManagerReloadListener.java.patch b/patches/minecraft/net/minecraft/resources/IResourceManagerReloadListener.java.patch deleted file mode 100644 index 03bde233d9..0000000000 --- a/patches/minecraft/net/minecraft/resources/IResourceManagerReloadListener.java.patch +++ /dev/null @@ -1,24 +0,0 @@ ---- a/net/minecraft/resources/IResourceManagerReloadListener.java -+++ b/net/minecraft/resources/IResourceManagerReloadListener.java -@@ -5,6 +_,11 @@ - import net.minecraft.profiler.IProfiler; - import net.minecraft.util.Unit; - -+/** -+ * @deprecated Forge: {@link net.minecraftforge.resource.ISelectiveResourceReloadListener}, which selectively allows -+ * individual resource types being reloaded should rather be used where possible. -+ */ -+@Deprecated - public interface IResourceManagerReloadListener extends IFutureReloadListener { - default CompletableFuture func_215226_a(IFutureReloadListener.IStage p_215226_1_, IResourceManager p_215226_2_, IProfiler p_215226_3_, IProfiler p_215226_4_, Executor p_215226_5_, Executor p_215226_6_) { - return p_215226_1_.func_216872_a(Unit.INSTANCE).thenRunAsync(() -> { -@@ -17,4 +_,9 @@ - } - - void func_195410_a(IResourceManager p_195410_1_); -+ -+ @javax.annotation.Nullable -+ default net.minecraftforge.resource.IResourceType getResourceType() { -+ return null; -+ } - } diff --git a/patches/minecraft/net/minecraft/resources/IResourcePack.java.patch b/patches/minecraft/net/minecraft/resources/IResourcePack.java.patch deleted file mode 100644 index 072185ad1b..0000000000 --- a/patches/minecraft/net/minecraft/resources/IResourcePack.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/resources/IResourcePack.java -+++ b/net/minecraft/resources/IResourcePack.java -@@ -11,7 +_,7 @@ - import net.minecraftforge.api.distmarker.Dist; - import net.minecraftforge.api.distmarker.OnlyIn; - --public interface IResourcePack extends AutoCloseable { -+public interface IResourcePack extends AutoCloseable, net.minecraftforge.common.extensions.IForgeResourcePack { - @OnlyIn(Dist.CLIENT) - InputStream func_195763_b(String p_195763_1_) throws IOException; - diff --git a/patches/minecraft/net/minecraft/resources/RegistryReadOps.java.patch b/patches/minecraft/net/minecraft/resources/RegistryReadOps.java.patch new file mode 100644 index 0000000000..2a26274cc6 --- /dev/null +++ b/patches/minecraft/net/minecraft/resources/RegistryReadOps.java.patch @@ -0,0 +1,18 @@ +--- a/net/minecraft/resources/RegistryReadOps.java ++++ b/net/minecraft/resources/RegistryReadOps.java +@@ -217,6 +_,7 @@ + try { + JsonParser jsonparser = new JsonParser(); + JsonElement jsonelement = jsonparser.parse(reader); ++ if (jsonelement != null) jsonelement.getAsJsonObject().addProperty("forge:registry_name", p_179899_.m_135782_().toString()); + optional = Optional.of(p_179900_.parse(p_179897_, jsonelement).map((p_135730_) -> { + return Pair.of(p_135730_, OptionalInt.empty()); + })); +@@ -287,6 +_,7 @@ + + public Optional>> m_142701_(DynamicOps p_179902_, ResourceKey> p_179903_, ResourceKey p_179904_, Decoder p_179905_) { + JsonElement jsonelement = this.f_135736_.get(p_179904_); ++ if (jsonelement != null) jsonelement.getAsJsonObject().addProperty("forge:registry_name", p_179904_.m_135782_().toString()); + return jsonelement == null ? Optional.of(DataResult.error("Unknown element: " + p_179904_)) : Optional.of(p_179905_.parse(p_179902_, jsonelement).setLifecycle(this.f_135738_.get(p_179904_)).map((p_135756_) -> { + return Pair.of(p_135756_, OptionalInt.of(this.f_135737_.getInt(p_179904_))); + })); diff --git a/patches/minecraft/net/minecraft/resources/ResourceKey.java.patch b/patches/minecraft/net/minecraft/resources/ResourceKey.java.patch new file mode 100644 index 0000000000..ae573a9c13 --- /dev/null +++ b/patches/minecraft/net/minecraft/resources/ResourceKey.java.patch @@ -0,0 +1,35 @@ +--- a/net/minecraft/resources/ResourceKey.java ++++ b/net/minecraft/resources/ResourceKey.java +@@ -6,7 +_,7 @@ + import java.util.function.Function; + import net.minecraft.core.Registry; + +-public class ResourceKey { ++public class ResourceKey implements Comparable> { + private static final Map> f_135775_ = Collections.synchronizedMap(Maps.newIdentityHashMap()); + private final ResourceLocation f_135776_; + private final ResourceLocation f_135777_; +@@ -47,5 +_,23 @@ + return (p_135801_) -> { + return m_135785_(p_135798_, p_135801_); + }; ++ } ++ ++ public ResourceLocation getRegistryName() { ++ return this.f_135776_; ++ } ++ ++ @Override ++ public boolean equals(Object o) { ++ if (this == o) return true; ++ if (o == null || getClass() != o.getClass()) return false; ++ return f_135776_.equals(((ResourceKey) o).f_135776_) && f_135777_.equals(((ResourceKey) o).f_135777_); ++ } ++ ++ @Override ++ public int compareTo(ResourceKey o) { ++ int ret = this.getRegistryName().compareTo(o.getRegistryName()); ++ if (ret == 0) ret = this.m_135782_().compareTo(o.m_135782_()); ++ return ret; + } + } diff --git a/patches/minecraft/net/minecraft/resources/ResourceLocation.java.patch b/patches/minecraft/net/minecraft/resources/ResourceLocation.java.patch new file mode 100644 index 0000000000..feb2eceae3 --- /dev/null +++ b/patches/minecraft/net/minecraft/resources/ResourceLocation.java.patch @@ -0,0 +1,15 @@ +--- a/net/minecraft/resources/ResourceLocation.java ++++ b/net/minecraft/resources/ResourceLocation.java +@@ -116,6 +_,12 @@ + return i; + } + ++ // Normal compare sorts by path first, this compares namespace first. ++ public int compareNamespaced(ResourceLocation o) { ++ int ret = this.f_135804_.compareTo(o.f_135804_); ++ return ret != 0 ? ret : this.f_135805_.compareTo(o.f_135805_); ++ } ++ + public String m_179910_() { + return this.toString().replace('/', '_').replace(':', '_'); + } diff --git a/patches/minecraft/net/minecraft/resources/ResourcePackInfo.java.patch b/patches/minecraft/net/minecraft/resources/ResourcePackInfo.java.patch deleted file mode 100644 index 9797579a1a..0000000000 --- a/patches/minecraft/net/minecraft/resources/ResourcePackInfo.java.patch +++ /dev/null @@ -1,50 +0,0 @@ ---- a/net/minecraft/resources/ResourcePackInfo.java -+++ b/net/minecraft/resources/ResourcePackInfo.java -@@ -30,6 +_,7 @@ - private final ResourcePackInfo.Priority field_195805_g; - private final boolean field_195806_h; - private final boolean field_195807_i; -+ private final boolean hidden; // Forge: Allow packs to be hidden from the UI entirely - private final IPackNameDecorator field_232611_k_; - - @Nullable -@@ -53,7 +_,12 @@ - return null; - } - -+ @Deprecated - public ResourcePackInfo(String p_i231422_1_, boolean p_i231422_2_, Supplier p_i231422_3_, ITextComponent p_i231422_4_, ITextComponent p_i231422_5_, PackCompatibility p_i231422_6_, ResourcePackInfo.Priority p_i231422_7_, boolean p_i231422_8_, IPackNameDecorator p_i231422_9_) { -+ this(p_i231422_1_, p_i231422_2_, p_i231422_3_, p_i231422_4_, p_i231422_5_, p_i231422_6_, p_i231422_7_, p_i231422_8_, p_i231422_9_, false); -+ } -+ -+ public ResourcePackInfo(String p_i231422_1_, boolean p_i231422_2_, Supplier p_i231422_3_, ITextComponent p_i231422_4_, ITextComponent p_i231422_5_, PackCompatibility p_i231422_6_, ResourcePackInfo.Priority p_i231422_7_, boolean p_i231422_8_, IPackNameDecorator p_i231422_9_, boolean hidden) { - this.field_195800_b = p_i231422_1_; - this.field_195801_c = p_i231422_3_; - this.field_195802_d = p_i231422_4_; -@@ -63,10 +_,16 @@ - this.field_195805_g = p_i231422_7_; - this.field_195807_i = p_i231422_8_; - this.field_232611_k_ = p_i231422_9_; -+ this.hidden = hidden; - } - -+ @Deprecated - public ResourcePackInfo(String p_i231421_1_, boolean p_i231421_2_, Supplier p_i231421_3_, IResourcePack p_i231421_4_, PackMetadataSection p_i231421_5_, ResourcePackInfo.Priority p_i231421_6_, IPackNameDecorator p_i231421_7_) { -- this(p_i231421_1_, p_i231421_2_, p_i231421_3_, new StringTextComponent(p_i231421_4_.func_195762_a()), p_i231421_5_.func_198963_a(), PackCompatibility.func_198969_a(p_i231421_5_.func_198962_b()), p_i231421_6_, false, p_i231421_7_); -+ this(p_i231421_1_, p_i231421_2_, p_i231421_3_, p_i231421_4_, p_i231421_5_, p_i231421_6_, p_i231421_7_, false); -+ } -+ -+ public ResourcePackInfo(String p_i231421_1_, boolean p_i231421_2_, Supplier p_i231421_3_, IResourcePack p_i231421_4_, PackMetadataSection p_i231421_5_, ResourcePackInfo.Priority p_i231421_6_, IPackNameDecorator p_i231421_7_, boolean hidden) { -+ this(p_i231421_1_, p_i231421_2_, p_i231421_3_, new StringTextComponent(p_i231421_4_.func_195762_a()), p_i231421_5_.func_198963_a(), PackCompatibility.func_198969_a(p_i231421_5_.func_198962_b()), p_i231421_6_, false, p_i231421_7_, hidden); - } - - @OnlyIn(Dist.CLIENT) -@@ -113,6 +_,8 @@ - public IPackNameDecorator func_232614_i_() { - return this.field_232611_k_; - } -+ -+ public boolean isHidden() { return hidden; } - - public boolean equals(Object p_equals_1_) { - if (this == p_equals_1_) { diff --git a/patches/minecraft/net/minecraft/resources/ResourcePackList.java.patch b/patches/minecraft/net/minecraft/resources/ResourcePackList.java.patch deleted file mode 100644 index 7ff5a99af8..0000000000 --- a/patches/minecraft/net/minecraft/resources/ResourcePackList.java.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- a/net/minecraft/resources/ResourcePackList.java -+++ b/net/minecraft/resources/ResourcePackList.java -@@ -22,7 +_,7 @@ - - public ResourcePackList(ResourcePackInfo.IFactory p_i231423_1_, IPackFinder... p_i231423_2_) { - this.field_198990_d = p_i231423_1_; -- this.field_198987_a = ImmutableSet.copyOf(p_i231423_2_); -+ this.field_198987_a = new java.util.HashSet<>(java.util.Arrays.asList(p_i231423_2_)); - } - - public ResourcePackList(IPackFinder... p_i241886_1_) { -@@ -87,6 +_,10 @@ - @Nullable - public ResourcePackInfo func_198981_a(String p_198981_1_) { - return this.field_198988_b.get(p_198981_1_); -+ } -+ -+ public synchronized void addPackFinder(IPackFinder packFinder) { -+ this.field_198987_a.add(packFinder); - } - - public void close() { diff --git a/patches/minecraft/net/minecraft/resources/VanillaPack.java.patch b/patches/minecraft/net/minecraft/resources/VanillaPack.java.patch deleted file mode 100644 index 6294faa21e..0000000000 --- a/patches/minecraft/net/minecraft/resources/VanillaPack.java.patch +++ /dev/null @@ -1,40 +0,0 @@ ---- a/net/minecraft/resources/VanillaPack.java -+++ b/net/minecraft/resources/VanillaPack.java -@@ -171,7 +_,7 @@ - - try { - URL url = VanillaPack.class.getResource(s); -- return func_223459_a(s, url) ? url.openStream() : null; -+ return func_223459_a(s, url) ? getExtraInputStream(p_195782_1_, s) : null; - } catch (IOException ioexception) { - return VanillaPack.class.getResourceAsStream(s); - } -@@ -187,7 +_,7 @@ - - @Nullable - protected InputStream func_200010_a(String p_200010_1_) { -- return VanillaPack.class.getResourceAsStream("/" + p_200010_1_); -+ return getExtraInputStream(ResourcePackType.SERVER_DATA, "/" + p_200010_1_); - } - - public boolean func_195764_b(ResourcePackType p_195764_1_, ResourceLocation p_195764_2_) { -@@ -225,5 +_,19 @@ - } - - public void close() { -+ } -+ -+ //Vanilla used to just grab from the classpath, this breaks dev environments, and Forge runtime -+ //as forge ships vanilla assets in an 'extra' jar with no classes. -+ //So find that extra jar using the .mcassetsroot marker. -+ private InputStream getExtraInputStream(ResourcePackType type, String resource) { -+ try { -+ FileSystem fs = field_217810_e.get(type); -+ if (fs != null) -+ return Files.newInputStream(fs.getPath(resource)); -+ return VanillaPack.class.getResourceAsStream(resource); -+ } catch (IOException e) { -+ return VanillaPack.class.getResourceAsStream(resource); -+ } - } - } diff --git a/patches/minecraft/net/minecraft/server/Bootstrap.java.patch b/patches/minecraft/net/minecraft/server/Bootstrap.java.patch new file mode 100644 index 0000000000..48f93a19d3 --- /dev/null +++ b/patches/minecraft/net/minecraft/server/Bootstrap.java.patch @@ -0,0 +1,19 @@ +--- a/net/minecraft/server/Bootstrap.java ++++ b/net/minecraft/server/Bootstrap.java +@@ -50,6 +_,8 @@ + CauldronInteraction.m_175649_(); + ArgumentTypes.m_121586_(); + StaticTags.m_13282_(); ++ net.minecraftforge.registries.GameData.vanillaSnapshot(); ++ if (false) // skip redirectOutputToLog, Forge already redirects stdout and stderr output to log so that they print with more context + m_135890_(); + } + } +@@ -122,7 +_,6 @@ + Commands.m_82138_(); + } + +- DefaultAttributes.m_22296_(); + } + + private static void m_135890_() { diff --git a/patches/minecraft/net/minecraft/server/Main.java.patch b/patches/minecraft/net/minecraft/server/Main.java.patch index 259bbce804..09d315a659 100644 --- a/patches/minecraft/net/minecraft/server/Main.java.patch +++ b/patches/minecraft/net/minecraft/server/Main.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/Main.java +++ b/net/minecraft/server/Main.java -@@ -71,6 +_,8 @@ +@@ -76,6 +_,8 @@ OptionSpec optionspec11 = optionparser.accepts("port").withRequiredArg().ofType(Integer.class).defaultsTo(-1); OptionSpec optionspec12 = optionparser.accepts("serverId").withRequiredArg(); OptionSpec optionspec13 = optionparser.nonOptions(); @@ -8,37 +8,37 @@ + optionparser.accepts("gameDir").withRequiredArg().ofType(File.class).defaultsTo(new File(".")); //Forge: Consume this argument, we use it in the launcher, and the client side. try { - OptionSet optionset = optionparser.parse(p_main_0_); -@@ -78,33 +_,38 @@ + OptionSet optionset = optionparser.parse(p_129699_); +@@ -83,33 +_,38 @@ optionparser.printHelpOn(System.err); return; } + Path path1 = Paths.get("eula.txt"); -+ ServerEula servereula = new ServerEula(path1); ++ Eula eula = new Eula(path1); + -+ if (!servereula.func_154346_a()) { -+ field_240759_a_.info("You need to agree to the EULA in order to run the server. Go to eula.txt for more info."); ++ if (!eula.m_135944_()) { ++ f_129670_.info("You need to agree to the EULA in order to run the server. Go to eula.txt for more info."); + return; + } - CrashReport.func_230188_h_(); - Bootstrap.func_151354_b(); - Bootstrap.func_218821_c(); - Util.func_240994_l_(); -+ if (!optionset.has(optionspec1)) net.minecraftforge.fml.server.ServerModLoader.load(); // Load mods before we load almost anything else anymore. Single spot now. Only loads if they haven't passed the initserver param - DynamicRegistries.Impl dynamicregistries$impl = DynamicRegistries.func_239770_b_(); + CrashReport.m_127529_(); + Bootstrap.m_135870_(); + Bootstrap.m_135889_(); + Util.m_137584_(); ++ if (!optionset.has(optionspec1)) net.minecraftforge.fmllegacy.server.ServerModLoader.load(); // Load mods before we load almost anything else anymore. Single spot now. Only loads if they haven't passed the initserver param + RegistryAccess.RegistryHolder registryaccess$registryholder = RegistryAccess.m_123086_(); Path path = Paths.get("server.properties"); - ServerPropertiesProvider serverpropertiesprovider = new ServerPropertiesProvider(dynamicregistries$impl, path); - serverpropertiesprovider.func_219035_b(); + DedicatedServerSettings dedicatedserversettings = new DedicatedServerSettings(path); + dedicatedserversettings.m_139780_(); - Path path1 = Paths.get("eula.txt"); -- ServerEula servereula = new ServerEula(path1); +- Eula eula = new Eula(path1); if (optionset.has(optionspec1)) { - field_240759_a_.info("Initialized '{}' and '{}'", path.toAbsolutePath(), path1.toAbsolutePath()); + f_129670_.info("Initialized '{}' and '{}'", path.toAbsolutePath(), path1.toAbsolutePath()); return; } -- if (!servereula.func_154346_a()) { -- field_240759_a_.info("You need to agree to the EULA in order to run the server. Go to eula.txt for more info."); +- if (!eula.m_135944_()) { +- f_129670_.info("You need to agree to the EULA in order to run the server. Go to eula.txt for more info."); - return; - } - @@ -46,29 +46,29 @@ YggdrasilAuthenticationService yggdrasilauthenticationservice = new YggdrasilAuthenticationService(Proxy.NO_PROXY); MinecraftSessionService minecraftsessionservice = yggdrasilauthenticationservice.createMinecraftSessionService(); GameProfileRepository gameprofilerepository = yggdrasilauthenticationservice.createProfileRepository(); - PlayerProfileCache playerprofilecache = new PlayerProfileCache(gameprofilerepository, new File(file1, MinecraftServer.field_152367_a.getName())); - String s = Optional.ofNullable(optionset.valueOf(optionspec10)).orElse(serverpropertiesprovider.func_219034_a().field_219021_o); + GameProfileCache gameprofilecache = new GameProfileCache(gameprofilerepository, new File(file1, MinecraftServer.f_129742_.getName())); + String s = Optional.ofNullable(optionset.valueOf(optionspec10)).orElse(dedicatedserversettings.m_139777_().f_139741_); + if (s == null || s.isEmpty() || new File(file1, s).getAbsolutePath().equals(new File(s).getAbsolutePath())) { -+ field_240759_a_.error("Invalid world directory specified, must not be null, empty or the same directory as your universe! " + s); ++ f_129670_.error("Invalid world directory specified, must not be null, empty or the same directory as your universe! " + s); + return; + } - SaveFormat saveformat = SaveFormat.func_237269_a_(file1.toPath()); - SaveFormat.LevelSave saveformat$levelsave = saveformat.func_237274_c_(s); - MinecraftServer.func_240777_a_(saveformat$levelsave); -@@ -142,6 +_,8 @@ - dimensiongeneratorsettings = optionset.has(optionspec3) ? serverproperties.field_241082_U_.func_236230_k_() : serverproperties.field_241082_U_; + LevelStorageSource levelstoragesource = LevelStorageSource.m_78242_(file1.toPath()); + LevelStorageSource.LevelStorageAccess levelstoragesource$levelstorageaccess = levelstoragesource.m_78260_(s); + MinecraftServer.m_129845_(levelstoragesource$levelstorageaccess); +@@ -154,6 +_,8 @@ + worldgensettings = optionset.has(optionspec3) ? dedicatedserverproperties.m_180927_(registryaccess$registryholder).m_64671_() : dedicatedserverproperties.m_180927_(registryaccess$registryholder); } + // Forge: Deserialize the DimensionGeneratorSettings to ensure modded dims are loaded on first server load (see SimpleRegistryCodec#decode). Vanilla behaviour only loads from the server.properties and deserializes only after the 2nd server load. -+ dimensiongeneratorsettings = DimensionGeneratorSettings.field_236201_a_.encodeStart(net.minecraft.util.registry.WorldGenSettingsExport.func_240896_a_(NBTDynamicOps.field_210820_a, dynamicregistries$impl), dimensiongeneratorsettings).flatMap(nbt -> DimensionGeneratorSettings.field_236201_a_.parse(worldsettingsimport, nbt)).getOrThrow(false, errorMsg->{}); - iserverconfiguration = new ServerWorldInfo(worldsettings, dimensiongeneratorsettings, Lifecycle.stable()); ++ worldgensettings = WorldGenSettings.f_64600_.encodeStart(net.minecraft.resources.RegistryWriteOps.m_135767_(NbtOps.f_128958_, registryaccess$registryholder), worldgensettings).flatMap(nbt -> WorldGenSettings.f_64600_.parse(registryreadops, nbt)).getOrThrow(false, errorMsg->{}); + worlddata = new PrimaryLevelData(levelsettings, worldgensettings, Lifecycle.stable()); } -@@ -169,6 +_,7 @@ +@@ -181,6 +_,7 @@ Thread thread = new Thread("Server Shutdown Thread") { public void run() { - dedicatedserver.func_71263_m(true); + dedicatedserver.m_7570_(true); + LogManager.shutdown(); // we're manually managing the logging shutdown on the server. Make sure we do it here at the end. } }; - thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(field_240759_a_)); + thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(f_129670_)); diff --git a/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch b/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch index 473bc5a15e..803b8bb6c9 100644 --- a/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch +++ b/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch @@ -1,224 +1,224 @@ --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -228,7 +_,7 @@ +@@ -254,7 +_,7 @@ - public static S func_240784_a_(Function p_240784_0_) { + public static S m_129872_(Function p_129873_) { AtomicReference atomicreference = new AtomicReference<>(); - Thread thread = new Thread(() -> { -+ Thread thread = new Thread(net.minecraftforge.fml.common.thread.SidedThreadGroups.SERVER, () -> { - atomicreference.get().func_240802_v_(); ++ Thread thread = new Thread(net.minecraftforge.fml.util.thread.SidedThreadGroups.SERVER, () -> { + atomicreference.get().m_130011_(); }, "Server thread"); - thread.setUncaughtExceptionHandler((p_240779_0_, p_240779_1_) -> { -@@ -376,6 +_,7 @@ - worldborder.func_177737_a(new IBorderListener.Impl(serverworld1.func_175723_af())); - this.field_71305_c.put(registrykey1, serverworld1); + thread.setUncaughtExceptionHandler((p_177909_, p_177910_) -> { +@@ -402,6 +_,7 @@ + worldborder.m_61929_(new BorderChangeListener.DelegateBorderChangeListener(serverlevel1.m_6857_())); + this.f_129762_.put(resourcekey1, serverlevel1); } -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Load(field_71305_c.get(registrykey))); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Load(f_129762_.get(resourcekey))); } } -@@ -387,6 +_,7 @@ - } else if (p_240786_3_) { - p_240786_1_.func_176143_a(BlockPos.field_177992_a.func_177984_a(), 0.0F); +@@ -411,6 +_,7 @@ + p_177898_.m_7250_(BlockPos.f_121853_.m_6630_(80), 0.0F); } else { -+ if (net.minecraftforge.event.ForgeEventFactory.onCreateWorldSpawn(p_240786_0_, p_240786_1_)) return; - BiomeProvider biomeprovider = chunkgenerator.func_202090_b(); - Random random = new Random(p_240786_0_.func_72905_C()); - BlockPos blockpos = biomeprovider.func_225531_a_(0, p_240786_0_.func_181545_F(), 0, 256, (p_244265_0_) -> { -@@ -452,6 +_,7 @@ + ChunkGenerator chunkgenerator = p_177897_.m_7726_().m_8481_(); ++ if (net.minecraftforge.event.ForgeEventFactory.onCreateWorldSpawn(p_177897_, p_177898_)) return; + BiomeSource biomesource = chunkgenerator.m_62218_(); + Random random = new Random(p_177897_.m_7328_()); + BlockPos blockpos = biomesource.m_47909_(0, p_177897_.m_5736_(), 0, 256, (p_177905_) -> { +@@ -482,6 +_,7 @@ } - private void func_213186_a(IChunkStatusListener p_213186_1_) { + private void m_129940_(ChunkProgressListener p_129941_) { + net.minecraftforge.common.world.StructureSpawnManager.gatherEntitySpawns(); - ServerWorld serverworld = this.func_241755_D_(); - field_147145_h.info("Preparing start region for dimension {}", (Object)serverworld.func_234923_W_().func_240901_a_()); - BlockPos blockpos = serverworld.func_241135_u_(); -@@ -479,6 +_,7 @@ + ServerLevel serverlevel = this.m_129783_(); + f_129750_.info("Preparing start region for dimension {}", (Object)serverlevel.m_46472_().m_135782_()); + BlockPos blockpos = serverlevel.m_8900_(); +@@ -509,6 +_,7 @@ ChunkPos chunkpos = new ChunkPos(i); - serverworld1.func_72863_F().func_217206_a(chunkpos, true); + serverlevel1.m_7726_().m_6692_(chunkpos, true); } -+ net.minecraftforge.common.world.ForgeChunkManager.reinstatePersistentChunks(serverworld1, forcedchunkssavedata); ++ net.minecraftforge.common.world.ForgeChunkManager.reinstatePersistentChunks(serverlevel1, forcedchunkssaveddata); } } -@@ -566,6 +_,7 @@ - for(ServerWorld serverworld1 : this.func_212370_w()) { - if (serverworld1 != null) { +@@ -604,6 +_,7 @@ + for(ServerLevel serverlevel1 : this.m_129785_()) { + if (serverlevel1 != null) { try { -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Unload(serverworld1)); - serverworld1.close(); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Unload(serverlevel1)); + serverlevel1.close(); } catch (IOException ioexception1) { - field_147145_h.error("Exception closing the level", (Throwable)ioexception1); -@@ -614,6 +_,7 @@ - protected void func_240802_v_() { + f_129750_.error("Exception closing the level", (Throwable)ioexception1); +@@ -652,6 +_,7 @@ + protected void m_130011_() { try { - if (this.func_71197_b()) { -+ net.minecraftforge.fml.server.ServerLifecycleHooks.handleServerStarted(this); - this.field_211151_aa = Util.func_211177_b(); - this.field_147147_p.func_151315_a(new StringTextComponent(this.field_71286_C)); - this.field_147147_p.func_151321_a(new ServerStatusResponse.Version(SharedConstants.func_215069_a().getName(), SharedConstants.func_215069_a().getProtocolVersion())); -@@ -643,7 +_,10 @@ - this.func_240795_b_(longtickdetector); - this.field_71296_Q = true; + if (this.m_7038_()) { ++ net.minecraftforge.fmllegacy.server.ServerLifecycleHooks.handleServerStarted(this); + this.f_129726_ = Util.m_137550_(); + this.f_129757_.m_134908_(new TextComponent(this.f_129709_)); + this.f_129757_.m_134912_(new ServerStatus.Version(SharedConstants.m_136187_().getName(), SharedConstants.m_136187_().getProtocolVersion())); +@@ -683,7 +_,10 @@ + this.m_177946_(); + this.f_129717_ = true; } -+ net.minecraftforge.fml.server.ServerLifecycleHooks.handleServerStopping(this); -+ net.minecraftforge.fml.server.ServerLifecycleHooks.expectServerStopped(); // has to come before finalTick to avoid race conditions ++ net.minecraftforge.fmllegacy.server.ServerLifecycleHooks.handleServerStopping(this); ++ net.minecraftforge.fmllegacy.server.ServerLifecycleHooks.expectServerStopped(); // has to come before finalTick to avoid race conditions } else { -+ net.minecraftforge.fml.server.ServerLifecycleHooks.expectServerStopped(); // has to come before finalTick to avoid race conditions - this.func_71228_a((CrashReport)null); ++ net.minecraftforge.fmllegacy.server.ServerLifecycleHooks.expectServerStopped(); // has to come before finalTick to avoid race conditions + this.m_7268_((CrashReport)null); } } catch (Throwable throwable1) { -@@ -662,6 +_,7 @@ - field_147145_h.error("We were unable to save this crash report to disk."); +@@ -703,6 +_,7 @@ + f_129750_.error("We were unable to save this crash report to disk."); } -+ net.minecraftforge.fml.server.ServerLifecycleHooks.expectServerStopped(); // has to come before finalTick to avoid race conditions - this.func_71228_a(crashreport); ++ net.minecraftforge.fmllegacy.server.ServerLifecycleHooks.expectServerStopped(); // has to come before finalTick to avoid race conditions + this.m_7268_(crashreport); } finally { try { -@@ -670,6 +_,7 @@ +@@ -711,6 +_,7 @@ } catch (Throwable throwable) { - field_147145_h.error("Exception stopping the server", throwable); + f_129750_.error("Exception stopping the server", throwable); } finally { -+ net.minecraftforge.fml.server.ServerLifecycleHooks.handleServerStopped(this); - this.func_71240_o(); ++ net.minecraftforge.fmllegacy.server.ServerLifecycleHooks.handleServerStopped(this); + this.m_6988_(); } -@@ -771,6 +_,7 @@ +@@ -802,6 +_,7 @@ - protected void func_71217_p(BooleanSupplier p_71217_1_) { - long i = Util.func_211178_c(); -+ net.minecraftforge.fml.hooks.BasicEventHooks.onPreServerTick(); - ++this.field_71315_w; - this.func_71190_q(p_71217_1_); - if (i - this.field_147142_T >= 5000000000L) { -@@ -785,6 +_,7 @@ + public void m_5705_(BooleanSupplier p_129871_) { + long i = Util.m_137569_(); ++ net.minecraftforge.fmllegacy.hooks.BasicEventHooks.onPreServerTick(); + ++this.f_129766_; + this.m_5703_(p_129871_); + if (i - this.f_129724_ >= 5000000000L) { +@@ -816,6 +_,7 @@ Collections.shuffle(Arrays.asList(agameprofile)); - this.field_147147_p.func_151318_b().func_151330_a(agameprofile); -+ this.field_147147_p.invalidateJson(); + this.f_129757_.m_134914_().m_134924_(agameprofile); ++ this.f_129757_.invalidateJson(); } - if (this.field_71315_w % 6000 == 0) { -@@ -812,6 +_,7 @@ - long i1 = Util.func_211178_c(); - this.field_213215_ap.func_181747_a(i1 - i); - this.field_71304_b.func_76319_b(); -+ net.minecraftforge.fml.hooks.BasicEventHooks.onPostServerTick(); + if (this.f_129766_ % 6000 == 0) { +@@ -843,6 +_,7 @@ + long i1 = Util.m_137569_(); + this.f_129735_.m_13755_(i1 - i); + this.f_129754_.m_7238_(); ++ net.minecraftforge.fmllegacy.hooks.BasicEventHooks.onPostServerTick(); } - protected void func_71190_q(BooleanSupplier p_71190_1_) { -@@ -819,7 +_,8 @@ - this.func_193030_aL().func_73660_a(); - this.field_71304_b.func_219895_b("levels"); + public void m_5703_(BooleanSupplier p_129954_) { +@@ -850,7 +_,8 @@ + this.m_129890_().m_136128_(); + this.f_129754_.m_6182_("levels"); -- for(ServerWorld serverworld : this.func_212370_w()) { -+ for(ServerWorld serverworld : this.getWorldArray()) { -+ long tickStart = Util.func_211178_c(); - this.field_71304_b.func_194340_a(() -> { - return serverworld + " " + serverworld.func_234923_W_().func_240901_a_(); +- for(ServerLevel serverlevel : this.m_129785_()) { ++ for(ServerLevel serverlevel : this.getWorldArray()) { ++ long tickStart = Util.m_137569_(); + this.f_129754_.m_6521_(() -> { + return serverlevel + " " + serverlevel.m_46472_().m_135782_(); }); -@@ -830,6 +_,7 @@ +@@ -861,6 +_,7 @@ } - this.field_71304_b.func_76320_a("tick"); -+ net.minecraftforge.fml.hooks.BasicEventHooks.onPreWorldTick(serverworld); + this.f_129754_.m_6180_("tick"); ++ net.minecraftforge.fmllegacy.hooks.BasicEventHooks.onPreWorldTick(serverlevel); try { - serverworld.func_72835_b(p_71190_1_); -@@ -838,9 +_,11 @@ - serverworld.func_72914_a(crashreport); + serverlevel.m_8793_(p_129954_); +@@ -869,9 +_,11 @@ + serverlevel.m_6026_(crashreport); throw new ReportedException(crashreport); } -+ net.minecraftforge.fml.hooks.BasicEventHooks.onPostWorldTick(serverworld); ++ net.minecraftforge.fmllegacy.hooks.BasicEventHooks.onPostWorldTick(serverlevel); - this.field_71304_b.func_76319_b(); - this.field_71304_b.func_76319_b(); -+ perWorldTickTimes.computeIfAbsent(serverworld.func_234923_W_(), k -> new long[100])[this.field_71315_w % 100] = Util.func_211178_c() - tickStart; + this.f_129754_.m_7238_(); + this.f_129754_.m_7238_(); ++ perWorldTickTimes.computeIfAbsent(serverlevel.m_46472_(), k -> new long[100])[this.f_129766_ % 100] = Util.m_137569_() - tickStart; } - this.field_71304_b.func_219895_b("connection"); -@@ -915,7 +_,7 @@ - } + this.f_129754_.m_6182_("connection"); +@@ -946,7 +_,7 @@ - public String getServerModName() { + @DontObfuscate + public String m_130001_() { - return "vanilla"; -+ return net.minecraftforge.fml.BrandingControl.getServerBranding(); ++ return net.minecraftforge.fmllegacy.BrandingControl.getServerBranding(); } - public CrashReport func_71230_b(CrashReport p_71230_1_) { -@@ -928,6 +_,7 @@ - p_71230_1_.func_85056_g().func_189529_a("Data Packs", () -> { + public SystemReport m_177935_(SystemReport p_177936_) { +@@ -959,6 +_,7 @@ + p_177936_.m_143522_("Data Packs", () -> { StringBuilder stringbuilder = new StringBuilder(); -+ LogManager.shutdown(); // we're manually managing the logging shutdown on the server. Make sure we do it here at the end. - for(ResourcePackInfo resourcepackinfo : this.field_195577_ad.func_198980_d()) { ++ LogManager.shutdown(); // we're manually managing the logging shutdown on the server. Make sure we do it here at the end. + for(Pack pack : this.f_129730_.m_10524_()) { if (stringbuilder.length() > 0) { stringbuilder.append(", "); -@@ -1280,6 +_,7 @@ - this.func_184103_al().func_193244_w(); - this.field_200258_al.func_240946_a_(this.field_195576_ac.func_240960_a_()); - this.field_240765_ak_.func_195410_a(this.field_195576_ac.func_240970_h_()); -+ this.func_184103_al().func_181057_v().forEach(this.func_184103_al()::func_187243_f); //Forge: Fix newly added/modified commands not being sent to the client when commands reload. +@@ -1312,6 +_,7 @@ + this.m_6846_().m_11315_(); + this.f_129734_.m_136120_(this.f_129740_.m_136157_()); + this.f_129741_.m_74335_(this.f_129740_.m_136178_()); ++ this.m_6846_().m_11314_().forEach(this.m_6846_()::m_11289_); //Forge: Fix newly added/modified commands not being sent to the client when commands reload. }, this); - if (this.func_213162_bc()) { - this.func_213161_c(completablefuture::isDone); -@@ -1289,10 +_,13 @@ + if (this.m_18695_()) { + this.m_18701_(completablefuture::isDone); +@@ -1321,10 +_,13 @@ } - public static DatapackCodec func_240772_a_(ResourcePackList p_240772_0_, DatapackCodec p_240772_1_, boolean p_240772_2_) { -+ net.minecraftforge.fml.packs.ResourcePackLoader.loadResourcePacks(p_240772_0_, net.minecraftforge.fml.server.ServerLifecycleHooks::buildPackFinder); - p_240772_0_.func_198983_a(); -+ DatapackCodec.field_234880_a_.addModPacks(net.minecraftforge.common.ForgeHooks.getModPacks()); -+ p_240772_1_.addModPacks(net.minecraftforge.common.ForgeHooks.getModPacks()); - if (p_240772_2_) { -- p_240772_0_.func_198985_a(Collections.singleton("vanilla")); -- return new DatapackCodec(ImmutableList.of("vanilla"), ImmutableList.of()); -+ p_240772_0_.func_198985_a(net.minecraftforge.common.ForgeHooks.getModPacksWithVanilla()); -+ return new DatapackCodec(net.minecraftforge.common.ForgeHooks.getModPacksWithVanilla(), ImmutableList.of()); + public static DataPackConfig m_129819_(PackRepository p_129820_, DataPackConfig p_129821_, boolean p_129822_) { ++ net.minecraftforge.fmllegacy.packs.ResourcePackLoader.loadResourcePacks(p_129820_, net.minecraftforge.fmllegacy.server.ServerLifecycleHooks::buildPackFinder); + p_129820_.m_10506_(); ++ DataPackConfig.f_45842_.addModPacks(net.minecraftforge.common.ForgeHooks.getModPacks()); ++ p_129821_.addModPacks(net.minecraftforge.common.ForgeHooks.getModPacks()); + if (p_129822_) { +- p_129820_.m_10509_(Collections.singleton("vanilla")); +- return new DataPackConfig(ImmutableList.of("vanilla"), ImmutableList.of()); ++ p_129820_.m_10509_(net.minecraftforge.common.ForgeHooks.getModPacksWithVanilla()); ++ return new DataPackConfig(net.minecraftforge.common.ForgeHooks.getModPacksWithVanilla(), ImmutableList.of()); } else { Set set = Sets.newLinkedHashSet(); -@@ -1442,6 +_,31 @@ +@@ -1479,6 +_,31 @@ - public abstract boolean func_213199_b(GameProfile p_213199_1_); + public abstract boolean m_7779_(GameProfile p_129840_); -+ private Map, long[]> perWorldTickTimes = Maps.newIdentityHashMap(); ++ private Map, long[]> perWorldTickTimes = Maps.newIdentityHashMap(); + @Nullable -+ public long[] getTickTime(RegistryKey dim) { ++ public long[] getTickTime(ResourceKey dim) { + return perWorldTickTimes.get(dim); + } + + @Deprecated //Forge Internal use Only, You can screw up a lot of things if you mess with this map. -+ public synchronized Map, ServerWorld> forgeGetWorldMap() { -+ return this.field_71305_c; ++ public synchronized Map, ServerLevel> forgeGetWorldMap() { ++ return this.f_129762_; + } + private int worldArrayMarker = 0; + private int worldArrayLast = -1; -+ private ServerWorld[] worldArray; ++ private ServerLevel[] worldArray; + @Deprecated //Forge Internal use Only, use to protect against concurrent modifications in the world tick loop. + public synchronized void markWorldsDirty() { + worldArrayMarker++; + } -+ private ServerWorld[] getWorldArray() { ++ private ServerLevel[] getWorldArray() { + if (worldArrayMarker == worldArrayLast && worldArray != null) + return worldArray; -+ worldArray = this.field_71305_c.values().stream().toArray(x -> new ServerWorld[x]); ++ worldArray = this.f_129762_.values().stream().toArray(x -> new ServerLevel[x]); + worldArrayLast = worldArrayMarker; + return worldArray; + } + - public void func_223711_a(Path p_223711_1_) throws IOException { - Path path = p_223711_1_.resolve("levels"); - -@@ -1568,6 +_,10 @@ - - public IServerConfiguration func_240793_aU_() { - return this.field_240768_i_; -+ } -+ -+ public DataPackRegistries getDataPackRegistries() { -+ return field_195576_ac; + public void m_142116_(Path p_177911_) throws IOException { } - public DynamicRegistries func_244267_aX() { +@@ -1677,6 +_,10 @@ + + public WorldData m_129910_() { + return this.f_129749_; ++ } ++ ++ public ServerResources getServerResources() { ++ return f_129740_; + } + + public RegistryAccess m_129911_() { diff --git a/patches/minecraft/net/minecraft/server/PlayerAdvancements.java.patch b/patches/minecraft/net/minecraft/server/PlayerAdvancements.java.patch new file mode 100644 index 0000000000..e3cd7ac0ec --- /dev/null +++ b/patches/minecraft/net/minecraft/server/PlayerAdvancements.java.patch @@ -0,0 +1,30 @@ +--- a/net/minecraft/server/PlayerAdvancements.java ++++ b/net/minecraft/server/PlayerAdvancements.java +@@ -181,6 +_,10 @@ + } + + this.m_136002_(p_136007_); ++ ++ if (net.minecraftforge.common.ForgeConfig.SERVER.fixAdvancementLoading.get()) ++ net.minecraftforge.common.AdvancementLoadFix.loadVisibility(this, this.f_135965_, this.f_135966_, this.f_135964_, this.f_135967_, this::m_136012_); ++ else + this.m_136001_(); + this.m_135994_(p_136007_); + } +@@ -239,6 +_,8 @@ + } + + public boolean m_135988_(Advancement p_135989_, 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_); + boolean flag1 = advancementprogress.m_8193_(); +@@ -251,6 +_,7 @@ + if (p_135989_.m_138320_() != null && p_135989_.m_138320_().m_14996_() && this.f_135968_.f_19853_.m_46469_().m_46207_(GameRules.f_46153_)) { + this.f_135962_.m_11264_(new TranslatableComponent("chat.type.advancement." + p_135989_.m_138320_().m_14992_().m_15548_(), this.f_135968_.m_5446_(), p_135989_.m_138330_()), ChatType.SYSTEM, Util.f_137441_); + } ++ net.minecraftforge.common.ForgeHooks.onAdvancement(this.f_135968_, p_135989_); + } + } + diff --git a/patches/minecraft/net/minecraft/server/ServerAdvancementManager.java.patch b/patches/minecraft/net/minecraft/server/ServerAdvancementManager.java.patch new file mode 100644 index 0000000000..2764339c43 --- /dev/null +++ b/patches/minecraft/net/minecraft/server/ServerAdvancementManager.java.patch @@ -0,0 +1,13 @@ +--- a/net/minecraft/server/ServerAdvancementManager.java ++++ b/net/minecraft/server/ServerAdvancementManager.java +@@ -39,6 +_,10 @@ + try { + JsonObject jsonobject = GsonHelper.m_13918_(p_136040_, "advancement"); + Advancement.Builder advancement$builder = Advancement.Builder.m_138380_(jsonobject, new DeserializationContext(p_136039_, this.f_136024_)); ++ if (advancement$builder == null) { ++ f_136021_.debug("Skipping loading advancement {} as it's conditions were not met", p_136039_); ++ return; ++ } + map.put(p_136039_, advancement$builder); + } catch (IllegalArgumentException | JsonParseException jsonparseexception) { + f_136021_.error("Parsing error loading custom advancement {}: {}", p_136039_, jsonparseexception.getMessage()); diff --git a/patches/minecraft/net/minecraft/server/ServerResources.java.patch b/patches/minecraft/net/minecraft/server/ServerResources.java.patch new file mode 100644 index 0000000000..a44594cf23 --- /dev/null +++ b/patches/minecraft/net/minecraft/server/ServerResources.java.patch @@ -0,0 +1,18 @@ +--- a/net/minecraft/server/ServerResources.java ++++ b/net/minecraft/server/ServerResources.java +@@ -41,6 +_,7 @@ + this.f_136145_.m_7217_(this.f_180000_); + this.f_136145_.m_7217_(this.f_136152_); + this.f_136145_.m_7217_(this.f_136151_); ++ net.minecraftforge.event.ForgeEventFactory.onResourceReload(this).forEach(f_136145_::m_7217_); + } + + public ServerFunctionLibrary m_136157_() { +@@ -94,6 +_,7 @@ + + public void m_136179_() { + this.f_136148_.m_13480_().m_13431_(); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.TagsUpdatedEvent.CustomTagTypes(f_136148_.m_13480_())); + } + + public void close() { diff --git a/patches/minecraft/net/minecraft/server/commands/LocateCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/LocateCommand.java.patch new file mode 100644 index 0000000000..2ec91d1e80 --- /dev/null +++ b/patches/minecraft/net/minecraft/server/commands/LocateCommand.java.patch @@ -0,0 +1,21 @@ +--- a/net/minecraft/server/commands/LocateCommand.java ++++ b/net/minecraft/server/commands/LocateCommand.java +@@ -25,11 +_,18 @@ + return p_137861_.m_6761_(2); + }); + ++ if (false) + for(Entry> entry : StructureFeature.f_67012_.entrySet()) { + literalargumentbuilder = literalargumentbuilder.then(Commands.m_82127_(entry.getKey()).executes((p_137876_) -> { + return m_137862_(p_137876_.getSource(), entry.getValue()); + })); + } ++ else { ++ for (StructureFeature structurefeatureFeature : net.minecraftforge.registries.ForgeRegistries.STRUCTURE_FEATURES) { ++ String name = structurefeatureFeature.getRegistryName().toString().replace("minecraft:", ""); ++ literalargumentbuilder = literalargumentbuilder.then(Commands.m_82127_(name) ++ .executes(ctx -> m_137862_(ctx.getSource(), structurefeatureFeature))); ++ }} + + p_137859_.register(literalargumentbuilder); + } diff --git a/patches/minecraft/net/minecraft/server/commands/SpreadPlayersCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/SpreadPlayersCommand.java.patch new file mode 100644 index 0000000000..382172e7d6 --- /dev/null +++ b/patches/minecraft/net/minecraft/server/commands/SpreadPlayersCommand.java.patch @@ -0,0 +1,12 @@ +--- a/net/minecraft/server/commands/SpreadPlayersCommand.java ++++ b/net/minecraft/server/commands/SpreadPlayersCommand.java +@@ -163,7 +_,8 @@ + spreadplayerscommand$position = p_138732_[i++]; + } + +- entity.m_20324_((double)Mth.m_14107_(spreadplayerscommand$position.f_138749_) + 0.5D, (double)spreadplayerscommand$position.m_138758_(p_138731_, p_138733_), (double)Mth.m_14107_(spreadplayerscommand$position.f_138750_) + 0.5D); ++ net.minecraftforge.event.entity.EntityTeleportEvent.SpreadPlayersCommand event = net.minecraftforge.event.ForgeEventFactory.onEntityTeleportSpreadPlayersCommand(entity, (double)Mth.m_14107_(spreadplayerscommand$position.f_138749_) + 0.5D, (double)spreadplayerscommand$position.m_138758_(p_138731_, p_138733_), (double)Mth.m_14107_(spreadplayerscommand$position.f_138750_) + 0.5D); ++ if (!event.isCanceled()) entity.m_20324_(event.getTargetX(), event.getTargetY(), event.getTargetZ()); + double d2 = Double.MAX_VALUE; + + for(SpreadPlayersCommand.Position spreadplayerscommand$position1 : p_138732_) { diff --git a/patches/minecraft/net/minecraft/server/commands/TeleportCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/TeleportCommand.java.patch new file mode 100644 index 0000000000..347d7a80b0 --- /dev/null +++ b/patches/minecraft/net/minecraft/server/commands/TeleportCommand.java.patch @@ -0,0 +1,12 @@ +--- a/net/minecraft/server/commands/TeleportCommand.java ++++ b/net/minecraft/server/commands/TeleportCommand.java +@@ -126,6 +_,9 @@ + } + + private static void m_139014_(CommandSourceStack p_139015_, Entity p_139016_, ServerLevel p_139017_, double p_139018_, double p_139019_, double p_139020_, Set p_139021_, float p_139022_, float p_139023_, @Nullable TeleportCommand.LookAt p_139024_) throws CommandSyntaxException { ++ net.minecraftforge.event.entity.EntityTeleportEvent.TeleportCommand event = net.minecraftforge.event.ForgeEventFactory.onEntityTeleportCommand(p_139016_, p_139018_, p_139019_, p_139020_); ++ if (event.isCanceled()) return; ++ p_139018_ = event.getTargetX(); p_139019_ = event.getTargetY(); p_139020_ = event.getTargetZ(); + BlockPos blockpos = new BlockPos(p_139018_, p_139019_, p_139020_); + if (!Level.m_46741_(blockpos)) { + throw f_139006_.create(); diff --git a/patches/minecraft/net/minecraft/server/dedicated/DedicatedServer.java.patch b/patches/minecraft/net/minecraft/server/dedicated/DedicatedServer.java.patch index c4e7018c71..4707b4aa0b 100644 --- a/patches/minecraft/net/minecraft/server/dedicated/DedicatedServer.java.patch +++ b/patches/minecraft/net/minecraft/server/dedicated/DedicatedServer.java.patch @@ -1,50 +1,51 @@ --- a/net/minecraft/server/dedicated/DedicatedServer.java +++ b/net/minecraft/server/dedicated/DedicatedServer.java -@@ -81,6 +_,7 @@ - public boolean func_71197_b() throws IOException { +@@ -91,6 +_,7 @@ + public boolean m_7038_() throws IOException { Thread thread = new Thread("Server console handler") { public void run() { + if (net.minecraftforge.server.console.TerminalHandler.handleCommands(DedicatedServer.this)) return; BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8)); String s1; -@@ -162,11 +_,13 @@ - SkullTileEntity.func_184293_a(this.func_152358_ax()); - SkullTileEntity.func_184294_a(this.func_147130_as()); - PlayerProfileCache.func_187320_a(this.func_71266_T()); -+ if (!net.minecraftforge.fml.server.ServerLifecycleHooks.handleServerAboutToStart(this)) return false; - field_155771_h.info("Preparing level \"{}\"", (Object)this.func_230542_k__()); - this.func_240800_l__(); - long j = Util.func_211178_c() - i; +@@ -171,11 +_,13 @@ + SkullBlockEntity.m_59771_(this.m_129925_()); + SkullBlockEntity.m_182462_(this); + GameProfileCache.m_11004_(this.m_129797_()); ++ if (!net.minecraftforge.fmllegacy.server.ServerLifecycleHooks.handleServerAboutToStart(this)) return false; + f_139598_.info("Preparing level \"{}\"", (Object)this.m_7123_()); + this.m_130006_(); + long j = Util.m_137569_() - i; String s = String.format(Locale.ROOT, "%.3fs", (double)j / 1.0E9D); - field_155771_h.info("Done ({})! For help, type \"help\"", (Object)s); -+ this.field_211151_aa = Util.func_211177_b(); //Forge: Update server time to prevent watchdog/spaming during long load. - if (serverproperties.field_219027_u != null) { - this.func_200252_aR().func_223585_a(GameRules.field_223620_w).func_223570_a(serverproperties.field_219027_u, this); + f_139598_.info("Done ({})! For help, type \"help\"", (Object)s); ++ this.f_129726_ = Util.m_137550_(); //Forge: Update server time to prevent watchdog/spaming during long load. + if (dedicatedserverproperties.f_139744_ != null) { + this.m_129900_().m_46170_(GameRules.f_46153_).m_46246_(dedicatedserverproperties.f_139744_, this); } -@@ -190,11 +_,12 @@ +@@ -199,12 +_,13 @@ } - Items.field_190931_a.func_150895_a(ItemGroup.field_78027_g, NonNullList.func_191196_a()); + Items.f_41852_.m_6787_(CreativeModeTab.f_40754_, NonNullList.m_122779_()); + // <3 you Grum for this, saves us ~30 patch files! --^ - if (serverproperties.field_241079_P_) { - ServerInfoMBean.func_233490_a_(this); + if (dedicatedserverproperties.f_139721_) { + MinecraftServerStatistics.m_18328_(this); + f_139598_.info("JMX monitoring enabled"); } - return true; -+ return net.minecraftforge.fml.server.ServerLifecycleHooks.handleServerStarting(this); ++ return net.minecraftforge.fmllegacy.server.ServerLifecycleHooks.handleServerStarting(this); } } -@@ -513,6 +_,11 @@ +@@ -556,6 +_,11 @@ - public boolean func_213199_b(GameProfile p_213199_1_) { + public boolean m_7779_(GameProfile p_139642_) { return false; + } + + @Override //Forge: Enable formated text for colors in console. -+ public void func_145747_a(net.minecraft.util.text.ITextComponent message, java.util.UUID p_145747_2_) { -+ field_155771_h.info(message.getString()); ++ public void m_6352_(net.minecraft.network.chat.Component message, java.util.UUID p_108776_) { ++ f_139598_.info(message.getString()); } - public int func_230512_b_(int p_230512_1_) { + public int m_7186_(int p_139659_) { diff --git a/patches/minecraft/net/minecraft/server/dedicated/PropertyManager.java.patch b/patches/minecraft/net/minecraft/server/dedicated/PropertyManager.java.patch deleted file mode 100644 index b177a94161..0000000000 --- a/patches/minecraft/net/minecraft/server/dedicated/PropertyManager.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/server/dedicated/PropertyManager.java -+++ b/net/minecraft/server/dedicated/PropertyManager.java -@@ -39,7 +_,7 @@ - - public void func_218970_c(Path p_218970_1_) { - try (OutputStream outputstream = Files.newOutputStream(p_218970_1_)) { -- this.field_73672_b.store(outputstream, "Minecraft server properties"); -+ net.minecraftforge.common.util.SortedProperties.store(field_73672_b, outputstream, "Minecraft server properties"); - } catch (IOException ioexception) { - field_164440_a.error("Failed to store properties to file: " + p_218970_1_); - } diff --git a/patches/minecraft/net/minecraft/server/dedicated/ServerHangWatchdog.java.patch b/patches/minecraft/net/minecraft/server/dedicated/ServerWatchdog.java.patch similarity index 70% rename from patches/minecraft/net/minecraft/server/dedicated/ServerHangWatchdog.java.patch rename to patches/minecraft/net/minecraft/server/dedicated/ServerWatchdog.java.patch index 38cc8b0876..6106ea21b3 100644 --- a/patches/minecraft/net/minecraft/server/dedicated/ServerHangWatchdog.java.patch +++ b/patches/minecraft/net/minecraft/server/dedicated/ServerWatchdog.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/server/dedicated/ServerHangWatchdog.java -+++ b/net/minecraft/server/dedicated/ServerHangWatchdog.java -@@ -40,7 +_,7 @@ +--- a/net/minecraft/server/dedicated/ServerWatchdog.java ++++ b/net/minecraft/server/dedicated/ServerWatchdog.java +@@ -42,7 +_,7 @@ ThreadMXBean threadmxbean = ManagementFactory.getThreadMXBean(); ThreadInfo[] athreadinfo = threadmxbean.dumpAllThreads(true, true); StringBuilder stringbuilder = new StringBuilder(); @@ -8,4 +8,4 @@ + Error error = new Error(String.format("ServerHangWatchdog detected that a single server tick took %.2f seconds (should be max 0.05)", k / 1000F)); // Forge: don't just make a crash report with a seemingly-inexplicable Error for(ThreadInfo threadinfo : athreadinfo) { - if (threadinfo.getThreadId() == this.field_180249_b.func_213170_ax().getId()) { + if (threadinfo.getThreadId() == this.f_139782_.m_6304_().getId()) { diff --git a/patches/minecraft/net/minecraft/server/dedicated/Settings.java.patch b/patches/minecraft/net/minecraft/server/dedicated/Settings.java.patch new file mode 100644 index 0000000000..49a1241a4b --- /dev/null +++ b/patches/minecraft/net/minecraft/server/dedicated/Settings.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/server/dedicated/Settings.java ++++ b/net/minecraft/server/dedicated/Settings.java +@@ -60,7 +_,7 @@ + OutputStream outputstream = Files.newOutputStream(p_139877_); + + try { +- this.f_139798_.store(outputstream, "Minecraft server properties"); ++ net.minecraftforge.common.util.SortedProperties.store(f_139798_, outputstream, "Minecraft server properties"); + } catch (Throwable throwable1) { + if (outputstream != null) { + try { diff --git a/patches/minecraft/net/minecraft/server/gui/MinecraftServerGui.java.patch b/patches/minecraft/net/minecraft/server/gui/MinecraftServerGui.java.patch index af93e0adc8..de003cdfa2 100644 --- a/patches/minecraft/net/minecraft/server/gui/MinecraftServerGui.java.patch +++ b/patches/minecraft/net/minecraft/server/gui/MinecraftServerGui.java.patch @@ -1,23 +1,23 @@ --- a/net/minecraft/server/gui/MinecraftServerGui.java +++ b/net/minecraft/server/gui/MinecraftServerGui.java -@@ -137,8 +_,10 @@ +@@ -139,8 +_,10 @@ return jpanel; } + private java.util.concurrent.CountDownLatch latch = new java.util.concurrent.CountDownLatch(1); - public void func_206931_a() { - this.field_206932_d.start(); + public void m_139908_() { + this.f_139902_.start(); + latch.countDown(); } - public void func_219050_b() { -@@ -153,6 +_,9 @@ + public void m_139925_() { +@@ -155,6 +_,9 @@ } - public void func_164247_a(JTextArea p_164247_1_, JScrollPane p_164247_2_, String p_164247_3_) { + public void m_139914_(JTextArea p_139915_, JScrollPane p_139916_, String p_139917_) { + try { + latch.await(); + } catch (InterruptedException e){} //Prevent logging until after constructor has ended. if (!SwingUtilities.isEventDispatchThread()) { SwingUtilities.invokeLater(() -> { - this.func_164247_a(p_164247_1_, p_164247_2_, p_164247_3_); + this.m_139914_(p_139915_, p_139916_, p_139917_); diff --git a/patches/minecraft/net/minecraft/server/integrated/IntegratedServer.java.patch b/patches/minecraft/net/minecraft/server/integrated/IntegratedServer.java.patch deleted file mode 100644 index d968148116..0000000000 --- a/patches/minecraft/net/minecraft/server/integrated/IntegratedServer.java.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- a/net/minecraft/server/integrated/IntegratedServer.java -+++ b/net/minecraft/server/integrated/IntegratedServer.java -@@ -56,9 +_,10 @@ - this.func_71188_g(true); - this.func_71245_h(true); - this.func_244801_P(); -+ if (!net.minecraftforge.fml.server.ServerLifecycleHooks.handleServerAboutToStart(this)) return false; - this.func_240800_l__(); - this.func_71205_p(this.func_71214_G() + " - " + this.func_240793_aU_().func_76065_j()); -- return true; -+ return net.minecraftforge.fml.server.ServerLifecycleHooks.handleServerStarting(this); - } - - public void func_71217_p(BooleanSupplier p_71217_1_) { -@@ -172,6 +_,7 @@ - } - - public void func_71263_m(boolean p_71263_1_) { -+ if (func_71278_l()) - this.func_213167_f(() -> { - for(ServerPlayerEntity serverplayerentity : Lists.newArrayList(this.func_184103_al().func_181057_v())) { - if (!serverplayerentity.func_110124_au().equals(this.field_211528_n)) { diff --git a/patches/minecraft/net/minecraft/server/level/ChunkHolder.java.patch b/patches/minecraft/net/minecraft/server/level/ChunkHolder.java.patch new file mode 100644 index 0000000000..1def591788 --- /dev/null +++ b/patches/minecraft/net/minecraft/server/level/ChunkHolder.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/server/level/ChunkHolder.java ++++ b/net/minecraft/server/level/ChunkHolder.java +@@ -66,6 +_,7 @@ + private final ChunkHolder.PlayerProvider f_140016_; + private boolean f_140017_; + private boolean f_140018_; ++ LevelChunk currentlyLoading; // Forge: Used to bypass future chain when loading chunks. + private CompletableFuture f_142981_ = CompletableFuture.completedFuture((Void)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 new file mode 100644 index 0000000000..313c94e99e --- /dev/null +++ b/patches/minecraft/net/minecraft/server/level/ChunkMap.java.patch @@ -0,0 +1,49 @@ +--- a/net/minecraft/server/level/ChunkMap.java ++++ b/net/minecraft/server/level/ChunkMap.java +@@ -405,6 +_,7 @@ + if (this.f_140131_.remove(p_140182_, p_140183_) && p_140309_ != null) { + if (p_140309_ instanceof LevelChunk) { + ((LevelChunk)p_140309_).m_62913_(false); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.ChunkEvent.Unload((LevelChunk)p_140309_)); + } + + this.m_140258_(p_140309_); +@@ -583,7 +_,13 @@ + levelchunk.m_62952_(); + if (this.f_140132_.add(chunkpos.m_45588_())) { + levelchunk.m_62913_(true); ++ try { ++ p_140384_.currentlyLoading = levelchunk; // Forge - bypass the future chain when getChunk is called, this prevents deadlocks. + levelchunk.m_156369_(); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.ChunkEvent.Load(levelchunk)); ++ } finally { ++ p_140384_.currentlyLoading = null; // Forge - Stop bypassing the future chain. ++ } + } + + return levelchunk; +@@ -659,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.world.ChunkDataEvent.Save(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; +@@ -715,6 +_,7 @@ + + protected void m_140186_(ServerPlayer p_140187_, ChunkPos p_140188_, Packet[] p_140189_, boolean p_140190_, boolean p_140191_) { + if (p_140187_.f_19853_ == this.f_140133_) { ++ net.minecraftforge.event.ForgeEventFactory.fireChunkWatch(p_140190_, p_140191_, p_140187_, p_140188_, this.f_140133_); + if (p_140191_ && !p_140190_) { + ChunkHolder chunkholder = this.m_140327_(p_140188_.m_45588_()); + if (chunkholder != null) { +@@ -921,7 +_,7 @@ + } + + protected void m_140199_(Entity p_140200_) { +- if (!(p_140200_ instanceof EnderDragonPart)) { ++ if (!(p_140200_ instanceof net.minecraftforge.entity.PartEntity)) { + EntityType entitytype = p_140200_.m_6095_(); + int i = entitytype.m_20681_() * 16; + if (i != 0) { diff --git a/patches/minecraft/net/minecraft/server/level/DistanceManager.java.patch b/patches/minecraft/net/minecraft/server/level/DistanceManager.java.patch new file mode 100644 index 0000000000..91aad81b72 --- /dev/null +++ b/patches/minecraft/net/minecraft/server/level/DistanceManager.java.patch @@ -0,0 +1,63 @@ +--- a/net/minecraft/server/level/DistanceManager.java ++++ b/net/minecraft/server/level/DistanceManager.java +@@ -52,6 +_,8 @@ + final Executor f_140770_; + private long f_140771_; + ++ private final Long2ObjectOpenHashMap>> forcedTickets = new Long2ObjectOpenHashMap<>(); ++ + protected DistanceManager(Executor p_140774_, Executor p_140775_) { + ProcessorHandle processorhandle = ProcessorHandle.m_18714_("player ticket throttler", p_140775_::execute); + ChunkTaskPriorityQueueSorter chunktaskpriorityqueuesorter = new ChunkTaskPriorityQueueSorter(ImmutableList.of(processorhandle), p_140774_, 4); +@@ -146,6 +_,10 @@ + this.f_140762_.m_140715_(p_140785_, p_140786_.m_9433_(), true); + } + ++ if (p_140786_.isForceTicks()) { ++ SortedArraySet> tickets = forcedTickets.computeIfAbsent(p_140785_, e -> SortedArraySet.m_14246_(4)); ++ tickets.m_14253_(ticket); ++ } + } + + void m_140818_(long p_140819_, Ticket p_140820_) { +@@ -158,6 +_,13 @@ + } + + this.f_140762_.m_140715_(p_140819_, m_140797_(sortedarrayset), false); ++ ++ if (p_140820_.isForceTicks()) { ++ SortedArraySet> tickets = forcedTickets.get(p_140819_); ++ if (tickets != null) { ++ tickets.remove(p_140820_); ++ } ++ } + } + + public void m_140792_(TicketType p_140793_, ChunkPos p_140794_, int p_140795_, T p_140796_) { +@@ -178,6 +_,14 @@ + this.m_140818_(p_140851_.m_45588_(), ticket); + } + ++ public void registerTicking(TicketType type, ChunkPos pos, int distance, T value) { ++ this.m_140784_(pos.m_45588_(), new Ticket<>(type, 33 - distance, value, true)); ++ } ++ ++ public void releaseTicking(TicketType type, ChunkPos pos, int distance, T value) { ++ this.m_140818_(pos.m_45588_(), new Ticket<>(type, 33 - distance, value, true)); ++ } ++ + private SortedArraySet> m_140857_(long p_140858_) { + return this.f_140761_.computeIfAbsent(p_140858_, (p_140867_) -> { + return SortedArraySet.m_14246_(4); +@@ -243,6 +_,11 @@ + + public String m_140837_() { + return this.f_140766_.m_140558_(); ++ } ++ ++ public boolean shouldForceTicks(long chunkPos) { ++ SortedArraySet> tickets = forcedTickets.get(chunkPos); ++ return tickets != null && !tickets.isEmpty(); + } + + private void m_143207_(String p_143208_) { diff --git a/patches/minecraft/net/minecraft/server/level/ServerChunkCache.java.patch b/patches/minecraft/net/minecraft/server/level/ServerChunkCache.java.patch new file mode 100644 index 0000000000..cc1aa99fc0 --- /dev/null +++ b/patches/minecraft/net/minecraft/server/level/ServerChunkCache.java.patch @@ -0,0 +1,34 @@ +--- a/net/minecraft/server/level/ServerChunkCache.java ++++ b/net/minecraft/server/level/ServerChunkCache.java +@@ -161,6 +_,7 @@ + if (chunkholder == null) { + return null; + } else { ++ if (chunkholder.currentlyLoading != null) return chunkholder.currentlyLoading; // Forge: If the requested chunk is loading, bypass the future chain to prevent a deadlock. + Either either = chunkholder.m_140080_(ChunkStatus.f_62326_).getNow((Either)null); + if (either == null) { + return null; +@@ -337,7 +_,7 @@ + if (optional.isPresent()) { + LevelChunk levelchunk = optional.get(); + ChunkPos chunkpos = levelchunk.m_7697_(); +- if (this.f_8329_.m_143275_(chunkpos) && !this.f_8325_.m_140397_(chunkpos)) { ++ if ((this.f_8329_.m_143275_(chunkpos) && !this.f_8325_.m_140397_(chunkpos)) || this.f_8327_.shouldForceTicks(chunkpos.m_45588_())) { + levelchunk.m_6141_(levelchunk.m_6319_() + j); + if (flag1 && (this.f_8335_ || this.f_8336_) && this.f_8329_.m_6857_().m_61927_(chunkpos)) { + NaturalSpawner.m_47029_(this.f_8329_, levelchunk, naturalspawner$spawnstate, this.f_8336_, this.f_8335_, flag2); +@@ -414,6 +_,14 @@ + + public void m_8438_(TicketType p_8439_, ChunkPos p_8440_, int p_8441_, T p_8442_) { + this.f_8327_.m_140849_(p_8439_, p_8440_, p_8441_, p_8442_); ++ } ++ ++ public void registerTickingTicket(TicketType type, ChunkPos pos, int distance, T value) { ++ this.f_8327_.registerTicking(type, pos, distance, value); ++ } ++ ++ public void releaseTickingTicket(TicketType type, ChunkPos pos, int distance, T value) { ++ this.f_8327_.releaseTicking(type, pos, distance, value); + } + + public void m_6692_(ChunkPos p_8400_, boolean p_8401_) { diff --git a/patches/minecraft/net/minecraft/server/level/ServerEntity.java.patch b/patches/minecraft/net/minecraft/server/level/ServerEntity.java.patch new file mode 100644 index 0000000000..7dd03de1a6 --- /dev/null +++ b/patches/minecraft/net/minecraft/server/level/ServerEntity.java.patch @@ -0,0 +1,45 @@ +--- a/net/minecraft/server/level/ServerEntity.java ++++ b/net/minecraft/server/level/ServerEntity.java +@@ -81,10 +_,9 @@ + if (this.f_8510_ instanceof ItemFrame && this.f_8521_ % 10 == 0) { + ItemFrame itemframe = (ItemFrame)this.f_8510_; + ItemStack itemstack = itemframe.m_31822_(); +- if (itemstack.m_41720_() instanceof MapItem) { +- Integer integer = MapItem.m_151131_(itemstack); +- MapItemSavedData mapitemsaveddata = MapItem.m_151128_(integer, this.f_8509_); +- if (mapitemsaveddata != null) { ++ Integer integer = MapItem.m_151131_(itemstack); ++ MapItemSavedData mapitemsaveddata = MapItem.m_42853_(itemstack, this.f_8509_); ++ if (mapitemsaveddata != null) { + for(ServerPlayer serverplayer : this.f_8509_.m_6907_()) { + mapitemsaveddata.m_77918_(serverplayer, itemstack); + Packet packet = mapitemsaveddata.m_164796_(integer, serverplayer); +@@ -92,12 +_,13 @@ + serverplayer.f_8906_.m_141995_(packet); + } + } +- } + } + + this.m_8543_(); + } + ++ ++ + 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_()) { + int i1 = Mth.m_14143_(this.f_8510_.m_146908_() * 256.0F / 360.0F); +@@ -189,11 +_,13 @@ + public void m_8534_(ServerPlayer p_8535_) { + this.f_8510_.m_6452_(p_8535_); + p_8535_.f_8906_.m_141995_(new ClientboundRemoveEntitiesPacket(this.f_8510_.m_142049_())); ++ net.minecraftforge.event.ForgeEventFactory.onStopEntityTracking(this.f_8510_, p_8535_); + } + + public void m_8541_(ServerPlayer p_8542_) { + this.m_8536_(p_8542_.f_8906_::m_141995_); + this.f_8510_.m_6457_(p_8542_); ++ net.minecraftforge.event.ForgeEventFactory.onStartEntityTracking(this.f_8510_, p_8542_); + } + + public void m_8536_(Consumer> p_8537_) { diff --git a/patches/minecraft/net/minecraft/server/level/ServerLevel.java.patch b/patches/minecraft/net/minecraft/server/level/ServerLevel.java.patch new file mode 100644 index 0000000000..ca34ad3f30 --- /dev/null +++ b/patches/minecraft/net/minecraft/server/level/ServerLevel.java.patch @@ -0,0 +1,214 @@ +--- a/net/minecraft/server/level/ServerLevel.java ++++ b/net/minecraft/server/level/ServerLevel.java +@@ -173,6 +_,7 @@ + final Int2ObjectMap f_143247_ = new Int2ObjectOpenHashMap<>(); + private final StructureFeatureManager f_8560_; + private final boolean f_8561_; ++ private net.minecraftforge.common.util.WorldCapabilityData capabilityData; + + public ServerLevel(MinecraftServer p_8571_, Executor p_8572_, LevelStorageSource.LevelStorageAccess p_8573_, ServerLevelData p_8574_, ResourceKey p_8575_, DimensionType p_8576_, ChunkProgressListener p_8577_, ChunkGenerator p_8578_, boolean p_8579_, long p_8580_, List p_8581_, boolean p_8582_) { + super(p_8574_, p_8575_, p_8576_, p_8571_::m_129905_, false, p_8579_, p_8580_); +@@ -208,6 +_,7 @@ + } + + this.f_143245_ = new SleepStatus(); ++ this.initCapabilities(); + } + + public void m_8606_(int p_8607_, int p_8608_, boolean p_8609_, boolean p_8610_) { +@@ -303,22 +_,26 @@ + this.f_8548_.m_6846_().m_11270_(new ClientboundGameEventPacket(ClientboundGameEventPacket.f_132161_, this.f_46440_), this.m_46472_()); + } + ++ /* The function in use here has been replaced in order to only send the weather info to players in the correct dimension, ++ * rather than to all players on the server. This is what causes the client-side rain, as the ++ * client believes that it has started raining locally, rather than in another dimension. ++ */ + if (flag != this.m_46471_()) { + if (flag) { +- this.f_8548_.m_6846_().m_11268_(new ClientboundGameEventPacket(ClientboundGameEventPacket.f_132155_, 0.0F)); ++ this.f_8548_.m_6846_().m_11270_(new ClientboundGameEventPacket(ClientboundGameEventPacket.f_132155_, 0.0F), this.m_46472_()); + } else { +- this.f_8548_.m_6846_().m_11268_(new ClientboundGameEventPacket(ClientboundGameEventPacket.f_132154_, 0.0F)); ++ this.f_8548_.m_6846_().m_11270_(new ClientboundGameEventPacket(ClientboundGameEventPacket.f_132154_, 0.0F), this.m_46472_()); + } + +- this.f_8548_.m_6846_().m_11268_(new ClientboundGameEventPacket(ClientboundGameEventPacket.f_132160_, this.f_46438_)); +- this.f_8548_.m_6846_().m_11268_(new ClientboundGameEventPacket(ClientboundGameEventPacket.f_132161_, this.f_46440_)); ++ this.f_8548_.m_6846_().m_11270_(new ClientboundGameEventPacket(ClientboundGameEventPacket.f_132160_, this.f_46438_), this.m_46472_()); ++ this.f_8548_.m_6846_().m_11270_(new ClientboundGameEventPacket(ClientboundGameEventPacket.f_132161_, this.f_46440_), this.m_46472_()); + } + + int l = this.m_46469_().m_46215_(GameRules.f_151486_); + if (this.f_143245_.m_144002_(l) && this.f_143245_.m_144004_(l, this.f_8546_)) { + if (this.m_46469_().m_46207_(GameRules.f_46140_)) { +- long i1 = this.f_46442_.m_6792_() + 24000L; +- this.m_8615_(i1 - i1 % 24000L); ++ long k = this.m_46468_() + 24000L; ++ this.m_8615_(net.minecraftforge.event.ForgeEventFactory.onSleepFinished(this, k - k % 24000L, this.m_46468_())); + } + + this.m_8804_(); +@@ -343,7 +_,7 @@ + this.m_8807_(); + this.f_8557_ = false; + profilerfiller.m_7238_(); +- boolean flag3 = !this.f_8546_.isEmpty() || !this.m_8902_().isEmpty(); ++ boolean flag3 = !this.f_8546_.isEmpty() || net.minecraftforge.common.world.ForgeChunkManager.hasForcedChunks(this); //Forge: Replace vanilla's has forced chunk check with forge's that checks both the vanilla and forge added ones + if (flag3) { + this.m_8886_(); + } +@@ -374,7 +_,9 @@ + } + + profilerfiller.m_6180_("tick"); +- this.m_46653_(this::m_8647_, p_143266_); ++ if (!p_143266_.m_146910_() && !(p_143266_ instanceof net.minecraftforge.entity.PartEntity)) { ++ this.m_46653_(this::m_8647_, p_143266_); ++ } + profilerfiller.m_7238_(); + } + } +@@ -458,6 +_,7 @@ + BlockPos blockpos2 = this.m_5452_(Heightmap.Types.MOTION_BLOCKING, this.m_46496_(i, 0, j, 15)); + BlockPos blockpos3 = blockpos2.m_7495_(); + Biome biome = this.m_46857_(blockpos2); ++ if (this.isAreaLoaded(blockpos2, 1)) // Forge: check area to avoid loading neighbors in unloaded chunks + if (biome.m_47477_(this, blockpos3)) { + this.m_46597_(blockpos3, Blocks.f_50126_.m_49966_()); + } +@@ -627,9 +_,10 @@ + ++p_8664_.f_19797_; + ProfilerFiller profilerfiller = this.m_46473_(); + profilerfiller.m_6521_(() -> { +- return Registry.f_122826_.m_7981_(p_8664_.m_6095_()).toString(); ++ return p_8664_.m_6095_().getRegistryName() == null ? p_8664_.m_6095_().toString() : p_8664_.m_6095_().getRegistryName().toString(); + }); + profilerfiller.m_6174_("tickPassenger"); ++ if (p_8664_.canUpdate()) + p_8664_.m_6083_(); + profilerfiller.m_7238_(); + +@@ -666,6 +_,7 @@ + this.f_143244_.m_157554_(); + } + ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Save(this)); + } + } + +@@ -738,7 +_,48 @@ + this.m_8853_(p_8846_); + } + ++ public void removePlayer(ServerPlayer p_8850_, boolean keepData) { ++ p_8850_.remove(keepData); ++ this.removeEntity(p_8850_, keepData); ++ } ++ ++ public void removeEntityComplete(Entity p_8865_, boolean keepData) { ++ if(p_8865_.isMultipartEntity()) { ++ for(net.minecraftforge.entity.PartEntity parts : p_8865_.getParts()) { ++ parts.remove(keepData); ++ } ++ } ++ ++ this.m_7726_().m_8443_(p_8865_); ++ if (p_8865_ instanceof ServerPlayer) { ++ ServerPlayer serverplayerentity = (ServerPlayer)p_8865_; ++ this.f_8546_.remove(serverplayerentity); ++ } ++ ++ this.m_6188_().m_83420_(p_8865_); ++ if (p_8865_ instanceof Mob) { ++ this.f_143246_.remove(((Mob)p_8865_).m_21573_()); ++ } ++ ++ p_8865_.onRemovedFromWorld(); ++ p_8865_.remove(keepData); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityLeaveWorldEvent(p_8865_, this)); ++ } ++ ++ public void removeEntity(Entity entity) { ++ removeEntity(entity, false); ++ } ++ ++ public void removeEntity(Entity p_8868_, boolean keepData) { ++ if (this.f_8557_) { ++ throw (IllegalStateException) net.minecraft.Util.m_137570_(new IllegalStateException("Removing entity while ticking!")); ++ } else { ++ removeEntityComplete(p_8868_, keepData); ++ } ++ } ++ + private void m_8853_(ServerPlayer p_8854_) { ++ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityJoinWorldEvent(p_8854_, this))) return; + Entity entity = this.m_142646_().m_142694_(p_8854_.m_142081_()); + if (entity != null) { + f_8566_.warn("Force-added player with duplicate UUID {}", (Object)p_8854_.m_142081_().toString()); +@@ -747,6 +_,7 @@ + } + + this.f_143244_.m_157533_(p_8854_); ++ p_8854_.onAddedToWorld(); + } + + private boolean m_8872_(Entity p_8873_) { +@@ -754,6 +_,7 @@ + f_8566_.warn("Tried to add entity {} but it was marked as removed already", (Object)EntityType.m_20613_(p_8873_.m_6095_())); + return false; + } else { ++ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityJoinWorldEvent(p_8873_, this))) return false; + return this.f_143244_.m_157533_(p_8873_); + } + } +@@ -762,6 +_,7 @@ + if (p_8861_.m_142428_().map(Entity::m_142081_).anyMatch(this.f_143244_::m_157550_)) { + return false; + } else { ++ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityJoinWorldEvent(p_8861_, this))) return false; + this.m_47205_(p_8861_); + return true; + } +@@ -790,10 +_,20 @@ + } + + public void m_6263_(@Nullable Player p_8675_, double p_8676_, double p_8677_, double p_8678_, SoundEvent p_8679_, SoundSource p_8680_, float p_8681_, float p_8682_) { ++ net.minecraftforge.event.entity.PlaySoundAtEntityEvent event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtEntity(p_8675_, p_8679_, p_8680_, p_8681_, p_8682_); ++ if (event.isCanceled() || event.getSound() == null) return; ++ p_8679_ = event.getSound(); ++ p_8680_ = event.getCategory(); ++ p_8681_ = event.getVolume(); + this.f_8548_.m_6846_().m_11241_(p_8675_, p_8676_, p_8677_, p_8678_, p_8681_ > 1.0F ? (double)(16.0F * p_8681_) : 16.0D, this.m_46472_(), new ClientboundSoundPacket(p_8679_, p_8680_, p_8676_, p_8677_, p_8678_, p_8681_, p_8682_)); + } + + public void m_6269_(@Nullable Player p_8689_, Entity p_8690_, SoundEvent p_8691_, SoundSource p_8692_, float p_8693_, float p_8694_) { ++ net.minecraftforge.event.entity.PlaySoundAtEntityEvent event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtEntity(p_8689_, p_8691_, p_8692_, p_8693_, p_8694_); ++ if (event.isCanceled() || event.getSound() == null) return; ++ p_8691_ = event.getSound(); ++ p_8692_ = event.getCategory(); ++ p_8693_ = event.getVolume(); + this.f_8548_.m_6846_().m_11241_(p_8689_, p_8690_.m_20185_(), p_8690_.m_20186_(), p_8690_.m_20189_(), p_8693_ > 1.0F ? (double)(16.0F * p_8693_) : 16.0D, this.m_46472_(), new ClientboundSoundEntityPacket(p_8691_, p_8692_, p_8690_, p_8693_, p_8694_)); + } + +@@ -838,6 +_,7 @@ + + public Explosion m_7703_(@Nullable Entity p_8653_, @Nullable DamageSource p_8654_, @Nullable ExplosionDamageCalculator p_8655_, double p_8656_, double p_8657_, double p_8658_, float p_8659_, boolean p_8660_, Explosion.BlockInteraction p_8661_) { + Explosion explosion = new Explosion(this, p_8653_, p_8654_, p_8655_, p_8656_, p_8657_, p_8658_, p_8659_, p_8660_, p_8661_); ++ if (net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this, explosion)) return explosion; + explosion.m_46061_(); + explosion.m_46075_(false); + if (p_8661_ == Explosion.BlockInteraction.NONE) { +@@ -1355,6 +_,12 @@ + BlockPos.m_121976_(i - 2, j, k - 2, i + 2, j, k + 2).forEach((p_143260_) -> { + p_8618_.m_46597_(p_143260_, Blocks.f_50080_.m_49966_()); + }); ++ } ++ ++ protected void initCapabilities() { ++ this.gatherCapabilities(); ++ capabilityData = this.m_8895_().m_164861_(e -> net.minecraftforge.common.util.WorldCapabilityData.load(e, getCapabilities()), () -> new net.minecraftforge.common.util.WorldCapabilityData(getCapabilities()), net.minecraftforge.common.util.WorldCapabilityData.ID); ++ capabilityData.setCapabilities(getCapabilities()); + } + + public LevelEntityGetter m_142646_() { diff --git a/patches/minecraft/net/minecraft/server/level/ServerPlayer.java.patch b/patches/minecraft/net/minecraft/server/level/ServerPlayer.java.patch new file mode 100644 index 0000000000..7ddeef0ced --- /dev/null +++ b/patches/minecraft/net/minecraft/server/level/ServerPlayer.java.patch @@ -0,0 +1,253 @@ +--- a/net/minecraft/server/level/ServerPlayer.java ++++ b/net/minecraft/server/level/ServerPlayer.java +@@ -500,6 +_,7 @@ + } + + public void m_6667_(DamageSource p_9035_) { ++ if (net.minecraftforge.common.ForgeHooks.onLivingDeath(this, p_9035_)) return; + boolean flag = this.f_19853_.m_46469_().m_46207_(GameRules.f_46142_); + if (flag) { + Component component = this.m_21231_().m_19293_(); +@@ -644,13 +_,14 @@ + } + + @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; + this.f_8927_ = true; + ServerLevel serverlevel = this.m_9236_(); + ResourceKey resourcekey = serverlevel.m_46472_(); +- if (resourcekey == Level.f_46430_ && p_9180_.m_46472_() == Level.f_46428_) { ++ if (resourcekey == Level.f_46430_ && p_9180_.m_46472_() == Level.f_46428_ && teleporter.isVanilla()) { //Forge: Fix non-vanilla teleporters triggering end credits + this.m_19877_(); +- this.m_9236_().m_143261_(this, Entity.RemovalReason.CHANGED_DIMENSION); ++ this.m_9236_().removePlayer(this, true); //Forge: The player entity is cloned so keep the data until after cloning calls copyFrom + if (!this.f_8944_) { + this.f_8944_ = true; + this.f_8906_.m_141995_(new ClientboundGameEventPacket(ClientboundGameEventPacket.f_132157_, this.f_8928_ ? 0.0F : 1.0F)); +@@ -664,14 +_,15 @@ + this.f_8906_.m_141995_(new ClientboundChangeDifficultyPacket(leveldata.m_5472_(), leveldata.m_5474_())); + PlayerList playerlist = this.f_8924_.m_6846_(); + playerlist.m_11289_(this); +- serverlevel.m_143261_(this, Entity.RemovalReason.CHANGED_DIMENSION); +- this.m_146912_(); +- PortalInfo portalinfo = this.m_7937_(p_9180_); ++ serverlevel.removeEntity(this, true); //Forge: the player entity is moved to the new world, NOT cloned. So keep the data alive with no matching invalidate call. ++ this.revive(); ++ PortalInfo portalinfo = teleporter.getPortalInfo(this, p_9180_, this::m_7937_); + if (portalinfo != null) { ++ Entity e = teleporter.placeEntity(this, serverlevel, p_9180_, this.m_146908_(), spawnPortal -> {//Forge: Start vanilla logic + serverlevel.m_46473_().m_6180_("moving"); + if (resourcekey == Level.f_46428_ && p_9180_.m_46472_() == Level.f_46429_) { + this.f_8933_ = this.m_20182_(); +- } else if (p_9180_.m_46472_() == Level.f_46430_) { ++ } else if (spawnPortal && p_9180_.m_46472_() == Level.f_46430_) { + this.m_9006_(p_9180_, new BlockPos(portalinfo.f_77676_)); + } + +@@ -683,6 +_,9 @@ + this.m_6027_(portalinfo.f_77676_.f_82479_, portalinfo.f_77676_.f_82480_, portalinfo.f_77676_.f_82481_); + 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("Teleporter %s returned not the player entity but instead %s, expected PlayerEntity %s", teleporter, e, this)); + this.f_8906_.m_141995_(new ClientboundPlayerAbilitiesPacket(this.m_150110_())); + playerlist.m_11229_(this, p_9180_); + playerlist.m_11292_(this); +@@ -691,10 +_,12 @@ + this.f_8906_.m_141995_(new ClientboundUpdateMobEffectPacket(this.m_142049_(), mobeffectinstance)); + } + ++ if (teleporter.playTeleportSound(this, serverlevel, p_9180_)) + 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.fmllegacy.hooks.BasicEventHooks.firePlayerChangedDimensionEvent(this, resourcekey, p_9180_.m_46472_()); + } + + return this; +@@ -768,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); ++ if (ret != null) return Either.left(ret); + Direction direction = this.f_19853_.m_8055_(p_9115_).m_61143_(HorizontalDirectionalBlock.f_54117_); + if (!this.m_5803_() && this.m_6084_()) { + if (!this.f_19853_.m_6042_().m_63956_()) { +@@ -778,7 +_,7 @@ + return Either.left(Player.BedSleepingProblem.OBSTRUCTED); + } else { + this.m_9158_(this.f_19853_.m_46472_(), p_9115_, this.m_146908_(), false, true); +- if (this.f_19853_.m_46461_()) { ++ if (!net.minecraftforge.event.ForgeEventFactory.fireSleepingTimeCheck(this, optAt)) { + return Either.left(Player.BedSleepingProblem.NOT_POSSIBLE_NOW); + } else { + if (!this.m_7500_()) { +@@ -816,6 +_,7 @@ + } + + private boolean m_9116_(BlockPos p_9117_, Direction p_9118_) { ++ if (p_9118_ == null) return false; + return this.m_9222_(p_9117_) || this.m_9222_(p_9117_.m_142300_(p_9118_.m_122424_())); + } + +@@ -924,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_)); + return OptionalInt.of(this.f_8940_); + } + } +@@ -942,6 +_,7 @@ + this.f_8906_.m_141995_(new ClientboundHorseScreenOpenPacket(this.f_8940_, p_9060_.m_6643_(), p_9059_.m_142049_())); + 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_)); + } + + public void m_6986_(ItemStack p_9082_, InteractionHand p_9083_) { +@@ -968,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_)); + this.f_36096_ = this.f_36095_; + } + +@@ -1093,6 +_,13 @@ + this.f_8933_ = p_9016_.f_8933_; + this.m_36362_(p_9016_.m_36331_()); + this.m_36364_(p_9016_.m_36332_()); ++ ++ //Copy over a section of the Entity Data from the old player. ++ //Allows mods to specify data that persists after players respawn. ++ CompoundTag old = p_9016_.getPersistentData(); ++ if (old.m_128441_(PERSISTED_NBT_TAG)) ++ getPersistentData().m_128365_(PERSISTED_NBT_TAG, old.m_128423_(PERSISTED_NBT_TAG)); ++ net.minecraftforge.event.ForgeEventFactory.onPlayerClone(this, p_9016_, !p_9017_); + } + + protected void m_142540_(MobEffectInstance p_143393_, @Nullable Entity p_143394_) { +@@ -1151,6 +_,7 @@ + } + + public boolean m_143403_(GameType p_143404_) { ++ if (!net.minecraftforge.common.ForgeHooks.onChangeGameMode(this, this.f_8941_.m_9290_(), p_143404_)) return false; + if (!this.f_8941_.m_143473_(p_143404_)) { + return false; + } else { +@@ -1206,6 +_,7 @@ + this.f_143378_ = p_9157_.m_179563_(); + this.m_20088_().m_135381_(f_36089_, (byte)p_9157_.m_133887_()); + this.m_20088_().m_135381_(f_36090_, (byte)(p_9157_.m_133888_() == HumanoidArm.LEFT ? 0 : 1)); ++ this.language = p_9157_.m_179561_(); + } + + public boolean m_143432_() { +@@ -1294,7 +_,11 @@ + + @Nullable + public Component m_8957_() { +- return null; ++ if (!this.hasTabListName) { ++ this.tabListDisplayName = net.minecraftforge.event.ForgeEventFactory.getPlayerTabListDisplayName(this); ++ this.hasTabListName = true; ++ } ++ return this.tabListDisplayName; + } + + public void m_6674_(InteractionHand p_9031_) { +@@ -1319,21 +_,23 @@ + this.m_8127_(); + if (p_9000_ == this.f_19853_) { + 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_())) { + ServerLevel serverlevel = this.m_9236_(); + LevelData leveldata = p_9000_.m_6106_(); + this.f_8906_.m_141995_(new ClientboundRespawnPacket(p_9000_.m_6042_(), 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_(), true)); + 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_(); ++ serverlevel.removePlayer(this, true); //Forge: The player entity itself is moved, and not cloned. So we need to keep the data alive with no matching invalidate call later. ++ this.revive(); + this.m_7678_(p_9001_, p_9002_, p_9003_, p_9004_, p_9005_); + this.m_143425_(p_9000_); + p_9000_.m_8622_(this); + this.m_9209_(serverlevel); + this.f_8906_.m_9774_(p_9001_, p_9002_, p_9003_, p_9004_, p_9005_); ++ 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.fmllegacy.hooks.BasicEventHooks.firePlayerChangedDimensionEvent(this, serverlevel.m_46472_(), p_9000_.m_46472_()); + } + + } +@@ -1356,6 +_,7 @@ + } + + 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 (p_9160_ != null) { + boolean flag = p_9160_.equals(this.f_8936_) && p_9159_.equals(this.f_8935_); + if (p_9163_ && !flag) { +@@ -1408,6 +_,8 @@ + if (itementity == null) { + return null; + } else { ++ if (captureDrops() != null) captureDrops().add(itementity); ++ else + this.f_19853_.m_7967_(itementity); + ItemStack itemstack = itementity.m_32055_(); + if (p_9087_) { +@@ -1422,6 +_,29 @@ + } + } + ++ 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; ++ } ++ ++ // We need this as tablistDisplayname may be null even if the the event was fired. ++ private boolean hasTabListName = false; ++ private Component tabListDisplayName = null; ++ /** ++ * Force the name displayed in the tab list to refresh, by firing {@link net.minecraftforge.event.entity.player.PlayerEvent.TabListNameFormat}. ++ */ ++ public void refreshTabListName() { ++ Component oldName = this.tabListDisplayName; ++ this.tabListDisplayName = net.minecraftforge.event.ForgeEventFactory.getPlayerTabListDisplayName(this); ++ if (!java.util.Objects.equals(oldName, this.tabListDisplayName)) { ++ this.m_20194_().m_6846_().m_11268_(new net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket(net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket.Action.UPDATE_DISPLAY_NAME, this)); ++ } ++ } ++ + public TextFilter m_8967_() { + return this.f_8939_; + } +@@ -1481,10 +_,12 @@ + + public boolean m_182294_(boolean p_182295_) { + Inventory inventory = this.m_150109_(); ++ ItemStack selected = inventory.m_36056_(); ++ if (selected.m_41619_() || !selected.onDroppedByPlayer(this)) return false; + ItemStack itemstack = inventory.m_182403_(p_182295_); + this.f_36096_.m_182417_(inventory, inventory.f_35977_).ifPresent((p_182293_) -> { + this.f_36096_.m_150404_(p_182293_, inventory.m_36056_()); + }); +- return this.m_7197_(itemstack, false, true) != null; ++ return net.minecraftforge.common.ForgeHooks.onPlayerTossEvent(this, itemstack, true) != null; + } + } diff --git a/patches/minecraft/net/minecraft/server/level/ServerPlayerGameMode.java.patch b/patches/minecraft/net/minecraft/server/level/ServerPlayerGameMode.java.patch new file mode 100644 index 0000000000..4f07599e52 --- /dev/null +++ b/patches/minecraft/net/minecraft/server/level/ServerPlayerGameMode.java.patch @@ -0,0 +1,134 @@ +--- a/net/minecraft/server/level/ServerPlayerGameMode.java ++++ b/net/minecraft/server/level/ServerPlayerGameMode.java +@@ -123,7 +_,15 @@ + double d1 = this.f_9245_.m_20186_() - ((double)p_9282_.m_123342_() + 0.5D) + 1.5D; + double d2 = this.f_9245_.m_20189_() - ((double)p_9282_.m_123343_() + 0.5D); + double d3 = d0 * d0 + d1 * d1 + d2 * d2; +- if (d3 > 36.0D) { ++ double dist = f_9245_.m_21051_(net.minecraftforge.common.ForgeMod.REACH_DISTANCE.get()).m_22135_() + 1; ++ net.minecraftforge.event.entity.player.PlayerInteractEvent.LeftClickBlock event = net.minecraftforge.common.ForgeHooks.onLeftClickBlock(f_9245_, p_9282_, p_9284_); ++ if (event.isCanceled() || (!this.m_9295_() && event.getUseItem() == net.minecraftforge.eventbus.api.Event.Result.DENY)) { // Restore block and te data ++ f_9245_.f_8906_.m_141995_(new ClientboundBlockBreakAckPacket(p_9282_, f_9244_.m_8055_(p_9282_), p_9283_, false, "mod canceled")); ++ f_9244_.m_7260_(p_9282_, f_9244_.m_8055_(p_9282_), f_9244_.m_8055_(p_9282_), 3); ++ return; ++ } ++ dist *= dist; ++ if (d3 > dist) { + this.f_9245_.f_8906_.m_141995_(new ClientboundBlockBreakAckPacket(p_9282_, this.f_9244_.m_8055_(p_9282_), p_9283_, false, "too far")); + } else if (p_9282_.m_123342_() >= p_9285_) { + this.f_9245_.f_8906_.m_141995_(new ClientboundBlockBreakAckPacket(p_9282_, this.f_9244_.m_8055_(p_9282_), p_9283_, false, "too high")); +@@ -148,6 +_,7 @@ + float f = 1.0F; + BlockState blockstate = this.f_9244_.m_8055_(p_9282_); + if (!blockstate.m_60795_()) { ++ if (event.getUseBlock() != net.minecraftforge.eventbus.api.Event.Result.DENY) + blockstate.m_60686_(this.f_9244_, p_9282_, this.f_9245_); + f = blockstate.m_60625_(this.f_9245_, this.f_9245_.f_19853_, p_9282_); + } +@@ -215,7 +_,8 @@ + + public boolean m_9280_(BlockPos p_9281_) { + BlockState blockstate = this.f_9244_.m_8055_(p_9281_); +- if (!this.f_9245_.m_21205_().m_41720_().m_6777_(blockstate, this.f_9244_, p_9281_, this.f_9245_)) { ++ int exp = net.minecraftforge.common.ForgeHooks.onBlockBreakEvent(f_9244_, f_9247_, f_9245_, p_9281_); ++ if (exp == -1) { + return false; + } else { + BlockEntity blockentity = this.f_9244_.m_7702_(p_9281_); +@@ -223,30 +_,42 @@ + if (block instanceof GameMasterBlock && !this.f_9245_.m_36337_()) { + this.f_9244_.m_7260_(p_9281_, blockstate, blockstate, 3); + return false; ++ } else if (f_9245_.m_21205_().onBlockStartBreak(p_9281_, f_9245_)) { ++ return false; + } else if (this.f_9245_.m_36187_(this.f_9244_, p_9281_, this.f_9247_)) { + return false; + } else { +- block.m_5707_(this.f_9244_, p_9281_, blockstate, this.f_9245_); +- boolean flag = this.f_9244_.m_7471_(p_9281_, false); +- if (flag) { +- block.m_6786_(this.f_9244_, p_9281_, blockstate); +- } +- + if (this.m_9295_()) { ++ removeBlock(p_9281_, false); + return true; + } else { + ItemStack itemstack = this.f_9245_.m_21205_(); + ItemStack itemstack1 = itemstack.m_41777_(); +- boolean flag1 = this.f_9245_.m_36298_(blockstate); ++ boolean flag1 = blockstate.canHarvestBlock(this.f_9244_, p_9281_, this.f_9245_); // previously player.hasCorrectToolForDrops(blockstate) + itemstack.m_41686_(this.f_9244_, blockstate, p_9281_, this.f_9245_); ++ if (itemstack.m_41619_() && !itemstack1.m_41619_()) ++ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this.f_9245_, itemstack1, InteractionHand.MAIN_HAND); ++ boolean flag = removeBlock(p_9281_, flag1); ++ + if (flag && flag1) { + block.m_6240_(this.f_9244_, this.f_9245_, p_9281_, blockstate, blockentity, itemstack1); + } + ++ if (flag && exp > 0) ++ blockstate.m_60734_().m_49805_(f_9244_, p_9281_, exp); ++ + return true; + } + } + } ++ } ++ ++ private boolean removeBlock(BlockPos p_180235_1_, boolean canHarvest) { ++ BlockState state = this.f_9244_.m_8055_(p_180235_1_); ++ boolean removed = state.removedByPlayer(this.f_9244_, p_180235_1_, this.f_9245_, canHarvest, this.f_9244_.m_6425_(p_180235_1_)); ++ if (removed) ++ state.m_60734_().m_6786_(this.f_9244_, p_180235_1_, state); ++ return removed; + } + + public InteractionResult m_6261_(ServerPlayer p_9262_, Level p_9263_, ItemStack p_9264_, InteractionHand p_9265_) { +@@ -255,6 +_,8 @@ + } else if (p_9262_.m_36335_().m_41519_(p_9264_.m_41720_())) { + return InteractionResult.PASS; + } else { ++ InteractionResult cancelResult = net.minecraftforge.common.ForgeHooks.onItemRightClick(p_9262_, p_9265_); ++ if (cancelResult != null) return cancelResult; + int i = p_9264_.m_41613_(); + int j = p_9264_.m_41773_(); + InteractionResultHolder interactionresultholder = p_9264_.m_41682_(p_9263_, p_9262_, p_9265_); +@@ -288,6 +_,8 @@ + public InteractionResult m_7179_(ServerPlayer p_9266_, Level p_9267_, ItemStack p_9268_, InteractionHand p_9269_, BlockHitResult p_9270_) { + BlockPos blockpos = p_9270_.m_82425_(); + BlockState blockstate = p_9267_.m_8055_(blockpos); ++ net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock event = net.minecraftforge.common.ForgeHooks.onRightClickBlock(p_9266_, p_9269_, blockpos, p_9270_); ++ if (event.isCanceled()) return event.getCancellationResult(); + if (this.f_9247_ == GameType.SPECTATOR) { + MenuProvider menuprovider = blockstate.m_60750_(p_9267_, blockpos); + if (menuprovider != null) { +@@ -297,10 +_,15 @@ + return InteractionResult.PASS; + } + } else { ++ UseOnContext useoncontext = new UseOnContext(p_9266_, p_9269_, p_9270_); ++ if (event.getUseItem() != net.minecraftforge.eventbus.api.Event.Result.DENY) { ++ InteractionResult result = p_9268_.onItemUseFirst(useoncontext); ++ if (result != InteractionResult.PASS) return result; ++ } + boolean flag = !p_9266_.m_21205_().m_41619_() || !p_9266_.m_21206_().m_41619_(); +- boolean flag1 = p_9266_.m_36341_() && flag; ++ boolean flag1 = (p_9266_.m_36341_() && flag) && !(p_9266_.m_21205_().doesSneakBypassUse(p_9267_, blockpos, p_9266_) && p_9266_.m_21206_().doesSneakBypassUse(p_9267_, blockpos, p_9266_)); + ItemStack itemstack = p_9268_.m_41777_(); +- if (!flag1) { ++ if (event.getUseBlock() == net.minecraftforge.eventbus.api.Event.Result.ALLOW || (event.getUseBlock() != net.minecraftforge.eventbus.api.Event.Result.DENY && !flag1)) { + InteractionResult interactionresult = blockstate.m_60664_(p_9267_, p_9266_, p_9269_, p_9270_); + if (interactionresult.m_19077_()) { + CriteriaTriggers.f_10562_.m_45482_(p_9266_, blockpos, itemstack); +@@ -308,8 +_,8 @@ + } + } + +- if (!p_9268_.m_41619_() && !p_9266_.m_36335_().m_41519_(p_9268_.m_41720_())) { +- UseOnContext useoncontext = new UseOnContext(p_9266_, p_9269_, p_9270_); ++ if (event.getUseItem() == net.minecraftforge.eventbus.api.Event.Result.ALLOW || (!p_9268_.m_41619_() && !p_9266_.m_36335_().m_41519_(p_9268_.m_41720_()))) { ++ if (event.getUseItem() == net.minecraftforge.eventbus.api.Event.Result.DENY) return InteractionResult.PASS; + InteractionResult interactionresult1; + if (this.m_9295_()) { + int i = p_9268_.m_41613_(); diff --git a/patches/minecraft/net/minecraft/server/level/Ticket.java.patch b/patches/minecraft/net/minecraft/server/level/Ticket.java.patch new file mode 100644 index 0000000000..375623fc45 --- /dev/null +++ b/patches/minecraft/net/minecraft/server/level/Ticket.java.patch @@ -0,0 +1,50 @@ +--- a/net/minecraft/server/level/Ticket.java ++++ b/net/minecraft/server/level/Ticket.java +@@ -9,9 +_,14 @@ + private long f_9423_; + + protected Ticket(TicketType p_9425_, int p_9426_, T p_9427_) { ++ this(p_9425_, p_9426_, p_9427_, false); ++ } ++ ++ public Ticket(TicketType p_9425_, int p_9426_, T p_9427_, boolean forceTicks) { + this.f_9420_ = p_9425_; + this.f_9421_ = p_9426_; + this.f_9422_ = p_9427_; ++ this.forceTicks = forceTicks; + } + + public int compareTo(Ticket p_9432_) { +@@ -31,16 +_,16 @@ + return false; + } else { + Ticket ticket = (Ticket)p_9439_; +- return this.f_9421_ == ticket.f_9421_ && Objects.equals(this.f_9420_, ticket.f_9420_) && Objects.equals(this.f_9422_, ticket.f_9422_); ++ return this.f_9421_ == ticket.f_9421_ && Objects.equals(this.f_9420_, ticket.f_9420_) && Objects.equals(this.f_9422_, ticket.f_9422_) && this.forceTicks == ticket.forceTicks; + } + } + + public int hashCode() { +- return Objects.hash(this.f_9420_, this.f_9421_, this.f_9422_); ++ return Objects.hash(this.f_9420_, this.f_9421_, this.f_9422_, forceTicks); + } + + public String toString() { +- return "Ticket[" + this.f_9420_ + " " + this.f_9421_ + " (" + this.f_9422_ + ")] at " + this.f_9423_; ++ return "Ticket[" + this.f_9420_ + " " + this.f_9421_ + " (" + this.f_9422_ + ")] at " + this.f_9423_ + " force ticks " + forceTicks; + } + + public TicketType m_9428_() { +@@ -58,5 +_,12 @@ + protected boolean m_9434_(long p_9435_) { + long i = this.f_9420_.m_9469_(); + return i != 0L && p_9435_ - this.f_9423_ > i; ++ } ++ ++ /* ======================================== FORGE START =====================================*/ ++ private final boolean forceTicks; ++ ++ public boolean isForceTicks() { ++ return forceTicks; + } + } diff --git a/patches/minecraft/net/minecraft/server/management/PlayerInteractionManager.java.patch b/patches/minecraft/net/minecraft/server/management/PlayerInteractionManager.java.patch deleted file mode 100644 index 97378cb3cd..0000000000 --- a/patches/minecraft/net/minecraft/server/management/PlayerInteractionManager.java.patch +++ /dev/null @@ -1,160 +0,0 @@ ---- a/net/minecraft/server/management/PlayerInteractionManager.java -+++ b/net/minecraft/server/management/PlayerInteractionManager.java -@@ -87,7 +_,7 @@ - ++this.field_73100_i; - if (this.field_73097_j) { - BlockState blockstate = this.field_73092_a.func_180495_p(this.field_180241_i); -- if (blockstate.func_196958_f()) { -+ if (blockstate.isAir(field_73092_a, field_180241_i)) { - this.field_73097_j = false; - } else { - float f = this.func_229859_a_(blockstate, this.field_180241_i, this.field_73093_n); -@@ -98,7 +_,7 @@ - } - } else if (this.field_73088_d) { - BlockState blockstate1 = this.field_73092_a.func_180495_p(this.field_180240_f); -- if (blockstate1.func_196958_f()) { -+ if (blockstate1.isAir(field_73092_a, field_180240_f)) { - this.field_73092_a.func_175715_c(this.field_73090_b.func_145782_y(), this.field_180240_f, -1); - this.field_73094_o = -1; - this.field_73088_d = false; -@@ -126,7 +_,15 @@ - double d1 = this.field_73090_b.func_226278_cu_() - ((double)p_225416_1_.func_177956_o() + 0.5D) + 1.5D; - double d2 = this.field_73090_b.func_226281_cx_() - ((double)p_225416_1_.func_177952_p() + 0.5D); - double d3 = d0 * d0 + d1 * d1 + d2 * d2; -- if (d3 > 36.0D) { -+ double dist = field_73090_b.func_110148_a(net.minecraftforge.common.ForgeMod.REACH_DISTANCE.get()).func_111126_e() + 1; -+ net.minecraftforge.event.entity.player.PlayerInteractEvent.LeftClickBlock event = net.minecraftforge.common.ForgeHooks.onLeftClickBlock(field_73090_b, p_225416_1_, p_225416_3_); -+ if (event.isCanceled() || (!this.func_73083_d() && event.getUseItem() == net.minecraftforge.eventbus.api.Event.Result.DENY)) { // Restore block and te data -+ field_73090_b.field_71135_a.func_147359_a(new SPlayerDiggingPacket(p_225416_1_, field_73092_a.func_180495_p(p_225416_1_), p_225416_2_, false, "mod canceled")); -+ field_73092_a.func_184138_a(p_225416_1_, field_73092_a.func_180495_p(p_225416_1_), field_73092_a.func_180495_p(p_225416_1_), 3); -+ return; -+ } -+ dist *= dist; -+ if (d3 > dist) { - this.field_73090_b.field_71135_a.func_147359_a(new SPlayerDiggingPacket(p_225416_1_, this.field_73092_a.func_180495_p(p_225416_1_), p_225416_2_, false, "too far")); - } else if (p_225416_1_.func_177956_o() >= p_225416_4_) { - this.field_73090_b.field_71135_a.func_147359_a(new SPlayerDiggingPacket(p_225416_1_, this.field_73092_a.func_180495_p(p_225416_1_), p_225416_2_, false, "too high")); -@@ -150,12 +_,13 @@ - this.field_73089_e = this.field_73100_i; - float f = 1.0F; - BlockState blockstate = this.field_73092_a.func_180495_p(p_225416_1_); -- if (!blockstate.func_196958_f()) { -+ if (!blockstate.isAir(field_73092_a, p_225416_1_)) { -+ if (event.getUseBlock() != net.minecraftforge.eventbus.api.Event.Result.DENY) - blockstate.func_196942_a(this.field_73092_a, p_225416_1_, this.field_73090_b); - f = blockstate.func_185903_a(this.field_73090_b, this.field_73090_b.field_70170_p, p_225416_1_); - } - -- if (!blockstate.func_196958_f() && f >= 1.0F) { -+ if (!blockstate.isAir(field_73092_a, p_225416_1_) && f >= 1.0F) { - this.func_229860_a_(p_225416_1_, p_225416_2_, "insta mine"); - } else { - if (this.field_73088_d) { -@@ -218,7 +_,8 @@ - - public boolean func_180237_b(BlockPos p_180237_1_) { - BlockState blockstate = this.field_73092_a.func_180495_p(p_180237_1_); -- if (!this.field_73090_b.func_184614_ca().func_77973_b().func_195938_a(blockstate, this.field_73092_a, p_180237_1_, this.field_73090_b)) { -+ int exp = net.minecraftforge.common.ForgeHooks.onBlockBreakEvent(field_73092_a, field_73091_c, field_73090_b, p_180237_1_); -+ if (exp == -1) { - return false; - } else { - TileEntity tileentity = this.field_73092_a.func_175625_s(p_180237_1_); -@@ -226,30 +_,42 @@ - if ((block instanceof CommandBlockBlock || block instanceof StructureBlock || block instanceof JigsawBlock) && !this.field_73090_b.func_195070_dx()) { - this.field_73092_a.func_184138_a(p_180237_1_, blockstate, blockstate, 3); - return false; -+ } else if (field_73090_b.func_184614_ca().onBlockStartBreak(p_180237_1_, field_73090_b)) { -+ return false; - } else if (this.field_73090_b.func_223729_a(this.field_73092_a, p_180237_1_, this.field_73091_c)) { - return false; - } else { -- block.func_176208_a(this.field_73092_a, p_180237_1_, blockstate, this.field_73090_b); -- boolean flag = this.field_73092_a.func_217377_a(p_180237_1_, false); -- if (flag) { -- block.func_176206_d(this.field_73092_a, p_180237_1_, blockstate); -- } -- - if (this.func_73083_d()) { -+ removeBlock(p_180237_1_, false); - return true; - } else { - ItemStack itemstack = this.field_73090_b.func_184614_ca(); - ItemStack itemstack1 = itemstack.func_77946_l(); -- boolean flag1 = this.field_73090_b.func_234569_d_(blockstate); -+ boolean flag1 = blockstate.canHarvestBlock(this.field_73092_a, p_180237_1_, this.field_73090_b); // previously player.hasCorrectToolForDrops(blockstate) - itemstack.func_179548_a(this.field_73092_a, blockstate, p_180237_1_, this.field_73090_b); -+ if (itemstack.func_190926_b() && !itemstack1.func_190926_b()) -+ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this.field_73090_b, itemstack1, Hand.MAIN_HAND); -+ boolean flag = removeBlock(p_180237_1_, flag1); -+ - if (flag && flag1) { - block.func_180657_a(this.field_73092_a, this.field_73090_b, p_180237_1_, blockstate, tileentity, itemstack1); - } - -+ if (flag && exp > 0) -+ blockstate.func_177230_c().func_180637_b(field_73092_a, p_180237_1_, exp); -+ - return true; - } - } - } -+ } -+ -+ private boolean removeBlock(BlockPos p_180235_1_, boolean canHarvest) { -+ BlockState state = this.field_73092_a.func_180495_p(p_180235_1_); -+ boolean removed = state.removedByPlayer(this.field_73092_a, p_180235_1_, this.field_73090_b, canHarvest, this.field_73092_a.func_204610_c(p_180235_1_)); -+ if (removed) -+ state.func_177230_c().func_176206_d(this.field_73092_a, p_180235_1_, state); -+ return removed; - } - - public ActionResultType func_187250_a(ServerPlayerEntity p_187250_1_, World p_187250_2_, ItemStack p_187250_3_, Hand p_187250_4_) { -@@ -258,6 +_,8 @@ - } else if (p_187250_1_.func_184811_cZ().func_185141_a(p_187250_3_.func_77973_b())) { - return ActionResultType.PASS; - } else { -+ ActionResultType cancelResult = net.minecraftforge.common.ForgeHooks.onItemRightClick(p_187250_1_, p_187250_4_); -+ if (cancelResult != null) return cancelResult; - int i = p_187250_3_.func_190916_E(); - int j = p_187250_3_.func_77952_i(); - ActionResult actionresult = p_187250_3_.func_77957_a(p_187250_2_, p_187250_1_, p_187250_4_); -@@ -291,6 +_,8 @@ - public ActionResultType func_219441_a(ServerPlayerEntity p_219441_1_, World p_219441_2_, ItemStack p_219441_3_, Hand p_219441_4_, BlockRayTraceResult p_219441_5_) { - BlockPos blockpos = p_219441_5_.func_216350_a(); - BlockState blockstate = p_219441_2_.func_180495_p(blockpos); -+ net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock event = net.minecraftforge.common.ForgeHooks.onRightClickBlock(p_219441_1_, p_219441_4_, blockpos, p_219441_5_); -+ if (event.isCanceled()) return event.getCancellationResult(); - if (this.field_73091_c == GameType.SPECTATOR) { - INamedContainerProvider inamedcontainerprovider = blockstate.func_215699_b(p_219441_2_, blockpos); - if (inamedcontainerprovider != null) { -@@ -300,10 +_,15 @@ - return ActionResultType.PASS; - } - } else { -+ ItemUseContext itemusecontext = new ItemUseContext(p_219441_1_, p_219441_4_, p_219441_5_); -+ if (event.getUseItem() != net.minecraftforge.eventbus.api.Event.Result.DENY) { -+ ActionResultType result = p_219441_3_.onItemUseFirst(itemusecontext); -+ if (result != ActionResultType.PASS) return result; -+ } - boolean flag = !p_219441_1_.func_184614_ca().func_190926_b() || !p_219441_1_.func_184592_cb().func_190926_b(); -- boolean flag1 = p_219441_1_.func_226563_dT_() && flag; -+ boolean flag1 = (p_219441_1_.func_226563_dT_() && flag) && !(p_219441_1_.func_184614_ca().doesSneakBypassUse(p_219441_2_, blockpos, p_219441_1_) && p_219441_1_.func_184592_cb().doesSneakBypassUse(p_219441_2_, blockpos, p_219441_1_)); - ItemStack itemstack = p_219441_3_.func_77946_l(); -- if (!flag1) { -+ if (event.getUseBlock() == net.minecraftforge.eventbus.api.Event.Result.ALLOW || (event.getUseBlock() != net.minecraftforge.eventbus.api.Event.Result.DENY && !flag1)) { - ActionResultType actionresulttype = blockstate.func_227031_a_(p_219441_2_, p_219441_1_, p_219441_4_, p_219441_5_); - if (actionresulttype.func_226246_a_()) { - CriteriaTriggers.field_232607_M_.func_226695_a_(p_219441_1_, blockpos, itemstack); -@@ -311,8 +_,8 @@ - } - } - -- if (!p_219441_3_.func_190926_b() && !p_219441_1_.func_184811_cZ().func_185141_a(p_219441_3_.func_77973_b())) { -- ItemUseContext itemusecontext = new ItemUseContext(p_219441_1_, p_219441_4_, p_219441_5_); -+ if (event.getUseItem() == net.minecraftforge.eventbus.api.Event.Result.ALLOW || (!p_219441_3_.func_190926_b() && !p_219441_1_.func_184811_cZ().func_185141_a(p_219441_3_.func_77973_b()))) { -+ if (event.getUseItem() == net.minecraftforge.eventbus.api.Event.Result.DENY) return ActionResultType.PASS; - ActionResultType actionresulttype1; - if (this.func_73083_d()) { - int i = p_219441_3_.func_190916_E(); diff --git a/patches/minecraft/net/minecraft/server/management/PlayerList.java.patch b/patches/minecraft/net/minecraft/server/management/PlayerList.java.patch deleted file mode 100644 index b116b2480b..0000000000 --- a/patches/minecraft/net/minecraft/server/management/PlayerList.java.patch +++ /dev/null @@ -1,161 +0,0 @@ ---- a/net/minecraft/server/management/PlayerList.java -+++ b/net/minecraft/server/management/PlayerList.java -@@ -110,6 +_,7 @@ - private GameType field_72410_m; - private boolean field_72407_n; - private int field_72408_o; -+ private final List playersView = java.util.Collections.unmodifiableList(field_72404_b); - - public PlayerList(MinecraftServer p_i231425_1_, DynamicRegistries.Impl p_i231425_2_, PlayerData p_i231425_3_, int p_i231425_4_) { - this.field_72400_f = p_i231425_1_; -@@ -146,6 +_,7 @@ - IWorldInfo iworldinfo = serverworld1.func_72912_H(); - this.func_72381_a(p_72355_2_, (ServerPlayerEntity)null, serverworld1); - ServerPlayNetHandler serverplaynethandler = new ServerPlayNetHandler(this.field_72400_f, p_72355_1_, p_72355_2_); -+ net.minecraftforge.fml.network.NetworkHooks.sendMCRegistryPackets(p_72355_1_, "PLAY_TO_CLIENT"); - GameRules gamerules = serverworld1.func_82736_K(); - boolean flag = gamerules.func_223586_b(GameRules.field_226683_z_); - boolean flag1 = gamerules.func_223586_b(GameRules.field_223612_o); -@@ -156,6 +_,7 @@ - serverplaynethandler.func_147359_a(new SHeldItemChangePacket(p_72355_2_.field_71071_by.field_70461_c)); - serverplaynethandler.func_147359_a(new SUpdateRecipesPacket(this.field_72400_f.func_199529_aN().func_199510_b())); - serverplaynethandler.func_147359_a(new STagsListPacket(this.field_72400_f.func_244266_aF())); -+ net.minecraftforge.fml.network.NetworkHooks.syncCustomTagTypes(p_72355_2_, this.field_72400_f.func_244266_aF()); - this.func_187243_f(p_72355_2_); - p_72355_2_.func_147099_x().func_150877_d(); - p_72355_2_.func_192037_E().func_192826_c(p_72355_2_); -@@ -170,7 +_,7 @@ - - this.func_232641_a_(iformattabletextcomponent.func_240699_a_(TextFormatting.YELLOW), ChatType.SYSTEM, Util.field_240973_b_); - serverplaynethandler.func_147364_a(p_72355_2_.func_226277_ct_(), p_72355_2_.func_226278_cu_(), p_72355_2_.func_226281_cx_(), p_72355_2_.field_70177_z, p_72355_2_.field_70125_A); -- this.field_72404_b.add(p_72355_2_); -+ this.addPlayer(p_72355_2_); - this.field_177454_f.put(p_72355_2_.func_110124_au(), p_72355_2_); - this.func_148540_a(new SPlayerListItemPacket(SPlayerListItemPacket.Action.ADD_PLAYER, p_72355_2_)); - -@@ -225,6 +_,7 @@ - } - - p_72355_2_.func_71116_b(); -+ net.minecraftforge.fml.hooks.BasicEventHooks.firePlayerLoggedIn( p_72355_2_ ); - } - - protected void func_96456_a(ServerScoreboard p_96456_1_, ServerPlayerEntity p_96456_2_) { -@@ -285,6 +_,7 @@ - compoundnbt1 = compoundnbt; - p_72380_1_.func_70020_e(compoundnbt); - field_148546_d.debug("loading single player"); -+ net.minecraftforge.event.ForgeEventFactory.firePlayerLoadingEvent(p_72380_1_, this.field_72412_k, p_72380_1_.func_110124_au().toString()); - } else { - compoundnbt1 = this.field_72412_k.func_237336_b_(p_72380_1_); - } -@@ -293,6 +_,7 @@ - } - - protected void func_72391_b(ServerPlayerEntity p_72391_1_) { -+ if (p_72391_1_.field_71135_a == null) return; - this.field_72412_k.func_237335_a_(p_72391_1_); - ServerStatisticsManager serverstatisticsmanager = this.field_148547_k.get(p_72391_1_.func_110124_au()); - if (serverstatisticsmanager != null) { -@@ -307,6 +_,7 @@ - } - - public void func_72367_e(ServerPlayerEntity p_72367_1_) { -+ net.minecraftforge.fml.hooks.BasicEventHooks.firePlayerLoggedOut(p_72367_1_); - ServerWorld serverworld = p_72367_1_.func_71121_q(); - p_72367_1_.func_195066_a(Stats.field_75947_j); - this.func_72391_b(p_72367_1_); -@@ -330,7 +_,7 @@ - p_72367_1_.func_213319_R(); - serverworld.func_217434_e(p_72367_1_); - p_72367_1_.func_192039_O().func_192745_a(); -- this.field_72404_b.remove(p_72367_1_); -+ this.removePlayer(p_72367_1_); - this.field_72400_f.func_201300_aS().func_201382_b(p_72367_1_); - UUID uuid = p_72367_1_.func_110124_au(); - ServerPlayerEntity serverplayerentity = this.field_177454_f.get(uuid); -@@ -400,8 +_,8 @@ - } - - public ServerPlayerEntity func_232644_a_(ServerPlayerEntity p_232644_1_, boolean p_232644_2_) { -- this.field_72404_b.remove(p_232644_1_); -- p_232644_1_.func_71121_q().func_217434_e(p_232644_1_); -+ this.removePlayer(p_232644_1_); -+ p_232644_1_.func_71121_q().removePlayer(p_232644_1_, true); // Forge: keep data until copyFrom called - BlockPos blockpos = p_232644_1_.func_241140_K_(); - float f = p_232644_1_.func_242109_L(); - boolean flag = p_232644_1_.func_241142_M_(); -@@ -424,6 +_,7 @@ - ServerPlayerEntity serverplayerentity = new ServerPlayerEntity(this.field_72400_f, serverworld1, p_232644_1_.func_146103_bH(), playerinteractionmanager); - serverplayerentity.field_71135_a = p_232644_1_.field_71135_a; - serverplayerentity.func_193104_a(p_232644_1_, p_232644_2_); -+ p_232644_1_.remove(false); // Forge: clone event had a chance to see old data, now discard it - serverplayerentity.func_145769_d(p_232644_1_.func_145782_y()); - serverplayerentity.func_184819_a(p_232644_1_.func_184591_cq()); - -@@ -465,10 +_,11 @@ - this.func_72354_b(serverplayerentity, serverworld1); - this.func_187243_f(serverplayerentity); - serverworld1.func_217433_d(serverplayerentity); -- this.field_72404_b.add(serverplayerentity); -+ this.addPlayer(serverplayerentity); - this.field_177454_f.put(serverplayerentity.func_110124_au(), serverplayerentity); - serverplayerentity.func_71116_b(); - serverplayerentity.func_70606_j(serverplayerentity.func_110143_aJ()); -+ net.minecraftforge.fml.hooks.BasicEventHooks.firePlayerRespawnEvent(serverplayerentity, p_232644_2_); - if (flag2) { - serverplayerentity.field_71135_a.func_147359_a(new SPlaySoundEffectPacket(SoundEvents.field_232818_ms_, SoundCategory.BLOCKS, (double)blockpos.func_177958_n(), (double)blockpos.func_177956_o(), (double)blockpos.func_177952_p(), 1.0F, 1.0F)); - } -@@ -745,12 +_,6 @@ - if (serverstatisticsmanager == null) { - File file1 = this.field_72400_f.func_240776_a_(FolderName.field_237246_b_).toFile(); - File file2 = new File(file1, uuid + ".json"); -- if (!file2.exists()) { -- File file3 = new File(file1, p_152602_1_.func_200200_C_().getString() + ".json"); -- if (file3.exists() && file3.isFile()) { -- file3.renameTo(file2); -- } -- } - - serverstatisticsmanager = new ServerStatisticsManager(this.field_72400_f, file2); - this.field_148547_k.put(uuid, serverstatisticsmanager); -@@ -769,6 +_,8 @@ - this.field_192055_p.put(uuid, playeradvancements); - } - -+ // Forge: don't overwrite active player with a fake one. -+ if (!(p_192054_1_ instanceof net.minecraftforge.common.util.FakePlayer)) - playeradvancements.func_192739_a(p_192054_1_); - return playeradvancements; - } -@@ -786,7 +_,7 @@ - } - - public List func_181057_v() { -- return this.field_72404_b; -+ return this.playersView; //Unmodifiable view, we don't want people removing things without us knowing. - } - - @Nullable -@@ -804,6 +_,7 @@ - } - - this.func_148540_a(new STagsListPacket(this.field_72400_f.func_244266_aF())); -+ net.minecraftforge.fml.network.NetworkHooks.syncCustomTagTypes(this.field_72400_f.func_244266_aF()); - SUpdateRecipesPacket supdaterecipespacket = new SUpdateRecipesPacket(this.field_72400_f.func_199529_aN().func_199510_b()); - - for(ServerPlayerEntity serverplayerentity : this.field_72404_b) { -@@ -815,5 +_,13 @@ - - public boolean func_206257_x() { - return this.field_72407_n; -+ } -+ -+ public boolean addPlayer(ServerPlayerEntity player) { -+ return field_72404_b.add(player); -+ } -+ -+ public boolean removePlayer(ServerPlayerEntity player) { -+ return this.field_72404_b.remove(player); - } - } diff --git a/patches/minecraft/net/minecraft/server/network/MemoryServerHandshakePacketListenerImpl.java.patch b/patches/minecraft/net/minecraft/server/network/MemoryServerHandshakePacketListenerImpl.java.patch new file mode 100644 index 0000000000..1573cbfcc7 --- /dev/null +++ b/patches/minecraft/net/minecraft/server/network/MemoryServerHandshakePacketListenerImpl.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/server/network/MemoryServerHandshakePacketListenerImpl.java ++++ b/net/minecraft/server/network/MemoryServerHandshakePacketListenerImpl.java +@@ -16,6 +_,7 @@ + } + + public void m_7322_(ClientIntentionPacket p_9697_) { ++ if (!net.minecraftforge.fmllegacy.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_)); + } diff --git a/patches/minecraft/net/minecraft/server/network/ServerConnectionListener.java.patch b/patches/minecraft/net/minecraft/server/network/ServerConnectionListener.java.patch new file mode 100644 index 0000000000..ec06d026ff --- /dev/null +++ b/patches/minecraft/net/minecraft/server/network/ServerConnectionListener.java.patch @@ -0,0 +1,34 @@ +--- a/net/minecraft/server/network/ServerConnectionListener.java ++++ b/net/minecraft/server/network/ServerConnectionListener.java +@@ -50,11 +_,12 @@ + + public class ServerConnectionListener { + private static final Logger f_9701_ = LogManager.getLogger(); ++ private static final int READ_TIMEOUT = Integer.parseInt(System.getProperty("forge.readTimeout", "30")); + public static final LazyLoadedValue f_9698_ = new LazyLoadedValue<>(() -> { +- 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<>(() -> { +- 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_; +@@ -67,6 +_,7 @@ + } + + public void m_9711_(@Nullable InetAddress p_9712_, int p_9713_) throws IOException { ++ if (p_9712_ instanceof java.net.Inet6Address) System.setProperty("java.net.preferIPv4Stack", "false"); + synchronized(this.f_9703_) { + Class oclass; + LazyLoadedValue lazyloadedvalue; +@@ -87,7 +_,7 @@ + } catch (ChannelException channelexception) { + } + +- p_9729_.pipeline().addLast("timeout", new ReadTimeoutHandler(30)).addLast("legacy_query", new LegacyQueryHandler(ServerConnectionListener.this)).addLast("splitter", new Varint21FrameDecoder()).addLast("decoder", new PacketDecoder(PacketFlow.SERVERBOUND)).addLast("prepender", new Varint21LengthFieldPrepender()).addLast("encoder", new PacketEncoder(PacketFlow.CLIENTBOUND)); ++ p_9729_.pipeline().addLast("timeout", new ReadTimeoutHandler(READ_TIMEOUT)).addLast("legacy_query", new LegacyQueryHandler(ServerConnectionListener.this)).addLast("splitter", new Varint21FrameDecoder()).addLast("decoder", new PacketDecoder(PacketFlow.SERVERBOUND)).addLast("prepender", new Varint21LengthFieldPrepender()).addLast("encoder", new PacketEncoder(PacketFlow.CLIENTBOUND)); + int i = ServerConnectionListener.this.f_9702_.m_7032_(); + Connection connection = (Connection)(i > 0 ? new RateKickingConnection(i) : new Connection(PacketFlow.SERVERBOUND)); + ServerConnectionListener.this.f_9704_.add(connection); diff --git a/patches/minecraft/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch b/patches/minecraft/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch new file mode 100644 index 0000000000..4e7aecfe94 --- /dev/null +++ b/patches/minecraft/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch @@ -0,0 +1,72 @@ +--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java ++++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java +@@ -379,9 +_,11 @@ + } + + entity.m_19890_(d3, d4, d5, 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 + boolean flag2 = serverlevel.m_45756_(entity, entity.m_142469_().m_82406_(0.0625D)); + if (flag && (flag1 || !flag2)) { + 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)); + return; + } +@@ -398,7 +_,7 @@ + } + + private boolean m_9793_(Entity p_9794_) { +- return p_9794_.f_19853_.m_45556_(p_9794_.m_142469_().m_82400_(0.0625D).m_82363_(0.0D, -0.55D, 0.0D)).allMatch(BlockBehaviour.BlockStateBase::m_60795_); ++ return BlockPos.m_121921_(p_9794_.m_142469_().m_82400_(0.0625D).m_82363_(0.0D, -0.55D, 0.0D)).allMatch(b -> p_9794_.f_19853_.m_8055_(b).m_60795_()); + } + + public void m_7376_(ServerboundAcceptTeleportationPacket p_9835_) { +@@ -963,7 +_,9 @@ + this.f_9743_.m_9243_(); + int i = this.f_9743_.f_19853_.m_151558_(); + if (blockpos.m_123342_() < i) { +- if (this.f_9766_ == null && this.f_9743_.m_20275_((double)blockpos.m_123341_() + 0.5D, (double)blockpos.m_123342_() + 0.5D, (double)blockpos.m_123343_() + 0.5D) < 64.0D && serverlevel.m_7966_(this.f_9743_, blockpos)) { ++ double dist = f_9743_.m_21051_(net.minecraftforge.common.ForgeMod.REACH_DISTANCE.get()).m_22135_() + 3; ++ dist *= dist; ++ if (this.f_9766_ == null && this.f_9743_.m_20275_((double)blockpos.m_123341_() + 0.5D, (double)blockpos.m_123342_() + 0.5D, (double)blockpos.m_123343_() + 0.5D) < dist && serverlevel.m_7966_(this.f_9743_, blockpos)) { + InteractionResult interactionresult = this.f_9743_.f_8941_.m_7179_(this.f_9743_, serverlevel, itemstack, interactionhand, blockhitresult); + if (direction == Direction.UP && !interactionresult.m_19077_() && blockpos.m_123342_() >= i - 1 && m_9790_(this.f_9743_, itemstack)) { + Component component = (new TranslatableComponent("build.tooHigh", i - 1)).m_130940_(ChatFormatting.RED); +@@ -1077,7 +_,7 @@ + } + + public void m_7388_(ServerboundChatPacket p_9841_) { +- String s = StringUtils.normalizeSpace(p_9841_.m_133837_()); ++ String s = org.apache.commons.lang3.StringUtils.normalizeSpace(p_9841_.m_133837_()); + + for(int i = 0; i < s.length(); ++i) { + if (!SharedConstants.m_136188_(s.charAt(i))) { +@@ -1107,8 +_,10 @@ + String s1 = p_143629_.m_143722_(); + Component component = s1.isEmpty() ? null : new TranslatableComponent("chat.type.text", this.f_9743_.m_5446_(), s1); + Component component1 = new TranslatableComponent("chat.type.text", this.f_9743_.m_5446_(), s); ++ component1 = net.minecraftforge.common.ForgeHooks.onServerChatEvent(this, s, component1); ++ Component finalComponent = component1; + this.f_9745_.m_6846_().m_143991_(component1, (p_143644_) -> { +- return this.f_9743_.m_143421_(p_143644_) ? component : component1; ++ return this.f_9743_.m_143421_(p_143644_) ? component : finalComponent; + }, ChatType.CHAT, this.f_9743_.m_142081_()); + } + +@@ -1196,6 +_,7 @@ + private void m_143678_(InteractionHand p_143679_, ServerGamePacketListenerImpl.EntityInteraction p_143680_) { + ItemStack itemstack = ServerGamePacketListenerImpl.this.f_9743_.m_21120_(p_143679_).m_41777_(); + InteractionResult interactionresult = p_143680_.m_143694_(ServerGamePacketListenerImpl.this.f_9743_, entity, p_143679_); ++ // TODO: if (net.minecraftforge.common.ForgeHooks.onInteractEntityAt(player, entity, entity.position(), p_143679_) != null) return; + if (interactionresult.m_19077_()) { + CriteriaTriggers.f_10565_.m_61494_(ServerGamePacketListenerImpl.this.f_9743_, itemstack, entity); + if (interactionresult.m_19080_()) { +@@ -1401,6 +_,8 @@ + } + + public void m_7423_(ServerboundCustomPayloadPacket p_9860_) { ++ PacketUtils.m_131359_(p_9860_, this, this.f_9743_.m_9236_()); ++ net.minecraftforge.fmllegacy.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 new file mode 100644 index 0000000000..744020db14 --- /dev/null +++ b/patches/minecraft/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java ++++ b/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java +@@ -22,6 +_,7 @@ + } + + public void m_7322_(ClientIntentionPacket p_9975_) { ++ if (!net.minecraftforge.fmllegacy.server.ServerLifecycleHooks.handleServerLogin(p_9975_, this.f_9966_)) return; + switch(p_9975_.m_134735_()) { + case LOGIN: + this.f_9966_.m_129498_(ConnectionProtocol.LOGIN); diff --git a/patches/minecraft/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch b/patches/minecraft/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch new file mode 100644 index 0000000000..910b3979f0 --- /dev/null +++ b/patches/minecraft/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch @@ -0,0 +1,66 @@ +--- a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java ++++ b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +@@ -59,7 +_,13 @@ + } + + public void m_10050_() { +- 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.fmllegacy.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()); +@@ -146,7 +_,7 @@ + this.f_10019_ = ServerLoginPacketListenerImpl.State.KEY; + this.f_10013_.m_129512_(new ClientboundHelloPacket("", this.f_10018_.m_129790_().getPublic().getEncoded(), this.f_10017_)); + } else { +- this.f_10019_ = ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT; ++ this.f_10019_ = ServerLoginPacketListenerImpl.State.NEGOTIATING; + } + + } +@@ -171,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_; + +@@ -179,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; + } 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_ = ServerLoginPacketListenerImpl.this.m_10038_(gameprofile); +- ServerLoginPacketListenerImpl.this.f_10019_ = ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT; ++ ServerLoginPacketListenerImpl.this.f_10019_ = ServerLoginPacketListenerImpl.State.NEGOTIATING; + } else { + ServerLoginPacketListenerImpl.this.m_10053_(new TranslatableComponent("multiplayer.disconnect.unverified_username")); + ServerLoginPacketListenerImpl.f_10015_.error("Username '{}' tried to join with an invalid session", (Object)gameprofile.getName()); +@@ -192,7 +_,7 @@ + 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_ = ServerLoginPacketListenerImpl.this.m_10038_(gameprofile); +- ServerLoginPacketListenerImpl.this.f_10019_ = ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT; ++ ServerLoginPacketListenerImpl.this.f_10019_ = ServerLoginPacketListenerImpl.State.NEGOTIATING; + } else { + ServerLoginPacketListenerImpl.this.m_10053_(new TranslatableComponent("multiplayer.disconnect.authservers_down")); + ServerLoginPacketListenerImpl.f_10015_.error("Couldn't verify username because servers are unavailable"); +@@ -212,6 +_,7 @@ + } + + public void m_7223_(ServerboundCustomQueryPacket p_10045_) { ++ if (!net.minecraftforge.fmllegacy.network.NetworkHooks.onCustomPayload(p_10045_, this.f_10013_)) + this.m_10053_(new TranslatableComponent("multiplayer.disconnect.unexpected_query_response")); + } + diff --git a/patches/minecraft/net/minecraft/server/packs/PackResources.java.patch b/patches/minecraft/net/minecraft/server/packs/PackResources.java.patch new file mode 100644 index 0000000000..16a76607d9 --- /dev/null +++ b/patches/minecraft/net/minecraft/server/packs/PackResources.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/server/packs/PackResources.java ++++ b/net/minecraft/server/packs/PackResources.java +@@ -9,7 +_,7 @@ + import net.minecraft.resources.ResourceLocation; + import net.minecraft.server.packs.metadata.MetadataSectionSerializer; + +-public interface PackResources extends AutoCloseable { ++public interface PackResources extends AutoCloseable, net.minecraftforge.common.extensions.IForgePackResources { + String f_143748_ = ".mcmeta"; + String f_143749_ = "pack.mcmeta"; + diff --git a/patches/minecraft/net/minecraft/server/packs/VanillaPackResources.java.patch b/patches/minecraft/net/minecraft/server/packs/VanillaPackResources.java.patch new file mode 100644 index 0000000000..9cc8410172 --- /dev/null +++ b/patches/minecraft/net/minecraft/server/packs/VanillaPackResources.java.patch @@ -0,0 +1,41 @@ +--- a/net/minecraft/server/packs/VanillaPackResources.java ++++ b/net/minecraft/server/packs/VanillaPackResources.java +@@ -202,7 +_,7 @@ + + try { + URL url = VanillaPackResources.class.getResource(s); +- return m_10335_(s, url) ? url.openStream() : null; ++ return m_10335_(s, url) ? getExtraInputStream(p_10359_, s) : null; + } catch (IOException ioexception) { + return VanillaPackResources.class.getResourceAsStream(s); + } +@@ -218,7 +_,7 @@ + + @Nullable + protected InputStream m_5539_(String p_10334_) { +- return VanillaPackResources.class.getResourceAsStream("/" + p_10334_); ++ return getExtraInputStream(PackType.SERVER_DATA, "/" + p_10334_); + } + + public boolean m_7211_(PackType p_10355_, ResourceLocation p_10356_) { +@@ -291,6 +_,20 @@ + } + + public void close() { ++ } ++ ++ //Vanilla used to just grab from the classpath, this breaks dev environments, and Forge runtime ++ //as forge ships vanilla assets in an 'extra' jar with no classes. ++ //So find that extra jar using the .mcassetsroot marker. ++ private InputStream getExtraInputStream(PackType type, String resource) { ++ try { ++ Path rootDir = f_182296_.get(type); ++ if (rootDir != null) ++ return Files.newInputStream(rootDir.resolve(resource)); ++ return VanillaPackResources.class.getResourceAsStream(resource); ++ } catch (IOException e) { ++ return VanillaPackResources.class.getResourceAsStream(resource); ++ } + } + + public Resource m_142591_(final ResourceLocation p_143764_) throws IOException { diff --git a/patches/minecraft/net/minecraft/server/packs/repository/Pack.java.patch b/patches/minecraft/net/minecraft/server/packs/repository/Pack.java.patch new file mode 100644 index 0000000000..557098e2ef --- /dev/null +++ b/patches/minecraft/net/minecraft/server/packs/repository/Pack.java.patch @@ -0,0 +1,77 @@ +--- a/net/minecraft/server/packs/repository/Pack.java ++++ b/net/minecraft/server/packs/repository/Pack.java +@@ -27,6 +_,7 @@ + private final Pack.Position f_10406_; + private final boolean f_10407_; + private final boolean f_10408_; ++ private final boolean hidden; // Forge: Allow packs to be hidden from the UI entirely + private final PackSource f_10409_; + + @Nullable +@@ -39,7 +_,7 @@ + try { + PackMetadataSection packmetadatasection = packresources.m_5550_(PackMetadataSection.f_10366_); + if (packmetadatasection != null) { +- pack = p_10434_.m_143873_(p_10431_, new TextComponent(packresources.m_8017_()), p_10432_, p_10433_, packmetadatasection, p_10435_, p_10436_); ++ pack = p_10434_.create(p_10431_, new TextComponent(packresources.m_8017_()), p_10432_, p_10433_, packmetadatasection, p_10435_, p_10436_, packresources.isHidden()); + break label54; + } + +@@ -74,7 +_,12 @@ + } + } + ++ @Deprecated + public Pack(String p_10420_, boolean p_10421_, Supplier p_10422_, Component p_10423_, Component p_10424_, PackCompatibility p_10425_, Pack.Position p_10426_, boolean p_10427_, PackSource p_10428_) { ++ this(p_10420_, p_10421_, p_10422_, p_10423_, p_10424_, p_10425_, p_10426_, p_10427_, p_10428_, false); ++ } ++ ++ public Pack(String p_10420_, boolean p_10421_, Supplier p_10422_, Component p_10423_, Component p_10424_, PackCompatibility p_10425_, Pack.Position p_10426_, boolean p_10427_, PackSource p_10428_, boolean hidden) { + this.f_10401_ = p_10420_; + this.f_10402_ = p_10422_; + this.f_10403_ = p_10423_; +@@ -84,10 +_,16 @@ + this.f_10406_ = p_10426_; + this.f_10408_ = p_10427_; + this.f_10409_ = p_10428_; ++ this.hidden = hidden; + } + ++ @Deprecated + public Pack(String p_143865_, Component p_143866_, boolean p_143867_, Supplier p_143868_, PackMetadataSection p_143869_, PackType p_143870_, Pack.Position p_143871_, PackSource p_143872_) { +- this(p_143865_, p_143867_, p_143868_, p_143866_, p_143869_.m_10373_(), PackCompatibility.m_143885_(p_143869_, p_143870_), p_143871_, false, p_143872_); ++ this(p_143865_, p_143867_, p_143868_, p_143866_, p_143869_.m_10373_(), PackCompatibility.m_143885_(p_143869_, p_143870_), p_143871_, false, p_143872_, false); ++ } ++ ++ public Pack(String p_143865_, Component p_143866_, boolean p_143867_, Supplier p_143868_, PackMetadataSection p_143869_, PackType p_143870_, Pack.Position p_143871_, PackSource p_143872_, boolean hidden) { ++ this(p_143865_, p_143867_, p_143868_, p_143866_, p_143869_.m_10373_(), PackCompatibility.m_143885_(p_143869_, p_143870_), p_143871_, false, p_143872_, hidden); + } + + public Component m_10429_() { +@@ -132,6 +_,8 @@ + return this.f_10409_; + } + ++ public boolean isHidden() { return hidden; } ++ + public boolean equals(Object p_10448_) { + if (this == p_10448_) { + return true; +@@ -152,8 +_,15 @@ + + @FunctionalInterface + public interface PackConstructor { +- @Nullable +- Pack m_143873_(String p_143874_, Component p_143875_, boolean p_143876_, Supplier p_143877_, PackMetadataSection p_143878_, Pack.Position p_143879_, PackSource p_143880_); ++ @Deprecated ++ @Nullable ++ default Pack m_143873_(String p_143874_, Component p_143875_, boolean p_143876_, Supplier p_143877_, PackMetadataSection p_143878_, Pack.Position p_143879_, PackSource p_143880_) ++ { ++ return create(p_143874_, p_143875_, p_143876_, p_143877_, p_143878_, p_143879_, p_143880_, false); ++ } ++ ++ @Nullable ++ Pack create(String p_143874_, Component p_143875_, boolean p_143876_, Supplier p_143877_, PackMetadataSection p_143878_, Pack.Position p_143879_, PackSource p_143880_, boolean hidden); + } + + public static enum Position { diff --git a/patches/minecraft/net/minecraft/server/packs/repository/PackRepository.java.patch b/patches/minecraft/net/minecraft/server/packs/repository/PackRepository.java.patch new file mode 100644 index 0000000000..f9a0cffa9d --- /dev/null +++ b/patches/minecraft/net/minecraft/server/packs/repository/PackRepository.java.patch @@ -0,0 +1,29 @@ +--- a/net/minecraft/server/packs/repository/PackRepository.java ++++ b/net/minecraft/server/packs/repository/PackRepository.java +@@ -24,12 +_,12 @@ + + public PackRepository(Pack.PackConstructor p_10502_, RepositorySource... p_10503_) { + this.f_10500_ = p_10502_; +- this.f_10497_ = ImmutableSet.copyOf(p_10503_); ++ this.f_10497_ = new java.util.HashSet<>(java.util.Arrays.asList(p_10503_)); + } + + public PackRepository(PackType p_143890_, RepositorySource... p_143891_) { +- this((p_143894_, p_143895_, p_143896_, p_143897_, p_143898_, p_143899_, p_143900_) -> { +- return new Pack(p_143894_, p_143895_, p_143896_, p_143897_, p_143898_, p_143890_, p_143899_, p_143900_); ++ this((p_143894_, p_143895_, p_143896_, p_143897_, p_143898_, p_143899_, p_143900_, hidden) -> { ++ return new Pack(p_143894_, p_143895_, p_143896_, p_143897_, p_143898_, p_143890_, p_143899_, p_143900_, hidden); + }, p_143891_); + } + +@@ -91,6 +_,10 @@ + @Nullable + public Pack m_10507_(String p_10508_) { + return this.f_10498_.get(p_10508_); ++ } ++ ++ public synchronized void addPackFinder(RepositorySource packFinder) { ++ this.f_10497_.add(packFinder); + } + + public void close() { diff --git a/patches/minecraft/net/minecraft/server/packs/resources/ResourceManagerReloadListener.java.patch b/patches/minecraft/net/minecraft/server/packs/resources/ResourceManagerReloadListener.java.patch new file mode 100644 index 0000000000..0742e14ae2 --- /dev/null +++ b/patches/minecraft/net/minecraft/server/packs/resources/ResourceManagerReloadListener.java.patch @@ -0,0 +1,24 @@ +--- a/net/minecraft/server/packs/resources/ResourceManagerReloadListener.java ++++ b/net/minecraft/server/packs/resources/ResourceManagerReloadListener.java +@@ -5,6 +_,11 @@ + import net.minecraft.util.Unit; + import net.minecraft.util.profiling.ProfilerFiller; + ++/** ++ * @deprecated Forge: {@link net.minecraftforge.resource.ISelectiveResourceReloadListener}, which selectively allows ++ * individual resource types being reloaded should rather be used where possible. ++ */ ++@Deprecated + public interface ResourceManagerReloadListener extends PreparableReloadListener { + default CompletableFuture m_5540_(PreparableReloadListener.PreparationBarrier p_10752_, ResourceManager p_10753_, ProfilerFiller p_10754_, ProfilerFiller p_10755_, Executor p_10756_, Executor p_10757_) { + return p_10752_.m_6769_(Unit.INSTANCE).thenRunAsync(() -> { +@@ -17,4 +_,9 @@ + } + + void m_6213_(ResourceManager p_10758_); ++ ++ @javax.annotation.Nullable ++ default net.minecraftforge.resource.IResourceType getResourceType() { ++ return null; ++ } + } diff --git a/patches/minecraft/net/minecraft/server/packs/resources/SimpleJsonResourceReloadListener.java.patch b/patches/minecraft/net/minecraft/server/packs/resources/SimpleJsonResourceReloadListener.java.patch new file mode 100644 index 0000000000..80b3ab51fb --- /dev/null +++ b/patches/minecraft/net/minecraft/server/packs/resources/SimpleJsonResourceReloadListener.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/server/packs/resources/SimpleJsonResourceReloadListener.java ++++ b/net/minecraft/server/packs/resources/SimpleJsonResourceReloadListener.java +@@ -106,4 +_,8 @@ + + return map; + } ++ ++ protected ResourceLocation getPreparedPath(ResourceLocation rl) { ++ return new ResourceLocation(rl.m_135827_(), this.f_10765_ + "/" + rl.m_135815_() + ".json"); ++ } + } diff --git a/patches/minecraft/net/minecraft/server/players/PlayerList.java.patch b/patches/minecraft/net/minecraft/server/players/PlayerList.java.patch new file mode 100644 index 0000000000..eacb2c44a8 --- /dev/null +++ b/patches/minecraft/net/minecraft/server/players/PlayerList.java.patch @@ -0,0 +1,162 @@ +--- a/net/minecraft/server/players/PlayerList.java ++++ b/net/minecraft/server/players/PlayerList.java +@@ -115,6 +_,7 @@ + private boolean f_11209_; + private static final boolean f_143988_ = false; + private int f_11210_; ++ private final List playersView = java.util.Collections.unmodifiableList(f_11196_); + + public PlayerList(MinecraftServer p_11213_, RegistryAccess.RegistryHolder p_11214_, PlayerDataStorage p_11215_, int p_11216_) { + this.f_11195_ = p_11213_; +@@ -150,6 +_,7 @@ + LevelData leveldata = serverlevel1.m_6106_(); + p_11263_.m_143427_(compoundtag); + ServerGamePacketListenerImpl servergamepacketlistenerimpl = new ServerGamePacketListenerImpl(this.f_11195_, p_11262_, p_11263_); ++ net.minecraftforge.fmllegacy.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_); +@@ -160,6 +_,7 @@ + servergamepacketlistenerimpl.m_141995_(new ClientboundSetCarriedItemPacket(p_11263_.m_150109_().f_35977_)); + servergamepacketlistenerimpl.m_141995_(new ClientboundUpdateRecipesPacket(this.f_11195_.m_129894_().m_44051_())); + servergamepacketlistenerimpl.m_141995_(new ClientboundUpdateTagsPacket(this.f_11195_.m_129895_().m_144442_(this.f_11206_))); ++ net.minecraftforge.fmllegacy.network.NetworkHooks.syncCustomTagTypes(p_11263_, this.f_11195_.m_129895_()); + this.m_11289_(p_11263_); + p_11263_.m_8951_().m_12850_(); + p_11263_.m_8952_().m_12789_(p_11263_); +@@ -174,7 +_,7 @@ + + this.m_11264_(mutablecomponent.m_130940_(ChatFormatting.YELLOW), ChatType.SYSTEM, Util.f_137441_); + servergamepacketlistenerimpl.m_9774_(p_11263_.m_20185_(), p_11263_.m_20186_(), p_11263_.m_20189_(), p_11263_.m_146908_(), p_11263_.m_146909_()); +- this.f_11196_.add(p_11263_); ++ this.addPlayer(p_11263_); + this.f_11197_.put(p_11263_.m_142081_(), p_11263_); + this.m_11268_(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, p_11263_)); + +@@ -229,6 +_,7 @@ + } + + p_11263_.m_143429_(); ++ net.minecraftforge.fmllegacy.hooks.BasicEventHooks.firePlayerLoggedIn( p_11263_ ); + } + + protected void m_11273_(ServerScoreboard p_11274_, ServerPlayer p_11275_) { +@@ -289,6 +_,7 @@ + compoundtag1 = compoundtag; + p_11225_.m_20258_(compoundtag); + f_11188_.debug("loading single player"); ++ net.minecraftforge.event.ForgeEventFactory.firePlayerLoadingEvent(p_11225_, this.f_11204_, p_11225_.m_142081_().toString()); + } else { + compoundtag1 = this.f_11204_.m_78435_(p_11225_); + } +@@ -297,6 +_,7 @@ + } + + protected void m_6765_(ServerPlayer p_11277_) { ++ if (p_11277_.f_8906_ == null) return; + this.f_11204_.m_78433_(p_11277_); + ServerStatsCounter serverstatscounter = this.f_11202_.get(p_11277_.m_142081_()); + if (serverstatscounter != null) { +@@ -311,6 +_,7 @@ + } + + public void m_11286_(ServerPlayer p_11287_) { ++ net.minecraftforge.fmllegacy.hooks.BasicEventHooks.firePlayerLoggedOut(p_11287_); + ServerLevel serverlevel = p_11287_.m_9236_(); + p_11287_.m_36220_(Stats.f_12989_); + this.m_6765_(p_11287_); +@@ -328,7 +_,7 @@ + p_11287_.m_19877_(); + serverlevel.m_143261_(p_11287_, Entity.RemovalReason.UNLOADED_WITH_PLAYER); + p_11287_.m_8960_().m_135978_(); +- this.f_11196_.remove(p_11287_); ++ this.removePlayer(p_11287_); + this.f_11195_.m_129901_().m_136305_(p_11287_); + UUID uuid = p_11287_.m_142081_(); + ServerPlayer serverplayer = this.f_11197_.get(uuid); +@@ -390,8 +_,8 @@ + } + + public ServerPlayer m_11236_(ServerPlayer p_11237_, boolean p_11238_) { +- this.f_11196_.remove(p_11237_); +- p_11237_.m_9236_().m_143261_(p_11237_, Entity.RemovalReason.DISCARDED); ++ this.removePlayer(p_11237_); ++ p_11237_.m_9236_().removePlayer(p_11237_, true); // Forge: keep data until copyFrom called + BlockPos blockpos = p_11237_.m_8961_(); + float f = p_11237_.m_8962_(); + boolean flag = p_11237_.m_8964_(); +@@ -407,6 +_,7 @@ + ServerPlayer serverplayer = new ServerPlayer(this.f_11195_, serverlevel1, p_11237_.m_36316_()); + serverplayer.f_8906_ = p_11237_.f_8906_; + serverplayer.m_9015_(p_11237_, p_11238_); ++ p_11237_.remove(false); // Forge: clone event had a chance to see old data, now discard it + serverplayer.m_20234_(p_11237_.m_142049_()); + serverplayer.m_36163_(p_11237_.m_5737_()); + +@@ -447,10 +_,11 @@ + this.m_11229_(serverplayer, serverlevel1); + this.m_11289_(serverplayer); + serverlevel1.m_8845_(serverplayer); +- this.f_11196_.add(serverplayer); ++ this.addPlayer(serverplayer); + this.f_11197_.put(serverplayer.m_142081_(), serverplayer); + serverplayer.m_143429_(); + serverplayer.m_21153_(serverplayer.m_21223_()); ++ net.minecraftforge.fmllegacy.hooks.BasicEventHooks.firePlayerRespawnEvent(serverplayer, p_11238_); + if (flag2) { + serverplayer.f_8906_.m_141995_(new ClientboundSoundPacket(SoundEvents.f_12377_, SoundSource.BLOCKS, (double)blockpos.m_123341_(), (double)blockpos.m_123342_(), (double)blockpos.m_123343_(), 1.0F, 1.0F)); + } +@@ -726,13 +_,6 @@ + if (serverstatscounter == null) { + File file1 = this.f_11195_.m_129843_(LevelResource.f_78175_).toFile(); + File file2 = new File(file1, uuid + ".json"); +- if (!file2.exists()) { +- File file3 = new File(file1, p_11240_.m_7755_().getString() + ".json"); +- Path path = file3.toPath(); +- if (FileUtil.m_133728_(path) && FileUtil.m_133734_(path) && path.startsWith(file1.getPath()) && file3.isFile()) { +- file3.renameTo(file2); +- } +- } + + serverstatscounter = new ServerStatsCounter(this.f_11195_, file2); + this.f_11202_.put(uuid, serverstatscounter); +@@ -751,6 +_,8 @@ + this.f_11203_.put(uuid, playeradvancements); + } + ++ // Forge: don't overwrite active player with a fake one. ++ if (!(p_11297_ instanceof net.minecraftforge.common.util.FakePlayer)) + playeradvancements.m_135979_(p_11297_); + return playeradvancements; + } +@@ -768,7 +_,7 @@ + } + + public List m_11314_() { +- return this.f_11196_; ++ return this.playersView; //Unmodifiable view, we don't want people removing things without us knowing. + } + + @Nullable +@@ -786,6 +_,7 @@ + } + + this.m_11268_(new ClientboundUpdateTagsPacket(this.f_11195_.m_129895_().m_144442_(this.f_11206_))); ++ net.minecraftforge.fmllegacy.network.NetworkHooks.syncCustomTagTypes(this.f_11195_.m_129895_()); + ClientboundUpdateRecipesPacket clientboundupdaterecipespacket = new ClientboundUpdateRecipesPacket(this.f_11195_.m_129894_().m_44051_()); + + for(ServerPlayer serverplayer : this.f_11196_) { +@@ -797,5 +_,13 @@ + + public boolean m_11316_() { + return this.f_11209_; ++ } ++ ++ public boolean addPlayer(ServerPlayer player) { ++ return f_11196_.add(player); ++ } ++ ++ public boolean removePlayer(ServerPlayer player) { ++ return this.f_11196_.remove(player); + } + } diff --git a/patches/minecraft/net/minecraft/server/rcon/RconConsoleSource.java.patch b/patches/minecraft/net/minecraft/server/rcon/RconConsoleSource.java.patch new file mode 100644 index 0000000000..b953e65307 --- /dev/null +++ b/patches/minecraft/net/minecraft/server/rcon/RconConsoleSource.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/server/rcon/RconConsoleSource.java ++++ b/net/minecraft/server/rcon/RconConsoleSource.java +@@ -35,7 +_,7 @@ + } + + public void m_6352_(Component p_11509_, UUID p_11510_) { +- this.f_11501_.append(p_11509_.getString()); ++ this.f_11501_.append(p_11509_.getString()).append("\n"); // FIX MC-7569 - RCON has no newlines in multiline output + } + + public boolean m_6999_() { diff --git a/patches/minecraft/net/minecraft/server/rcon/thread/RconClient.java.patch b/patches/minecraft/net/minecraft/server/rcon/thread/RconClient.java.patch new file mode 100644 index 0000000000..5970637789 --- /dev/null +++ b/patches/minecraft/net/minecraft/server/rcon/thread/RconClient.java.patch @@ -0,0 +1,22 @@ +--- a/net/minecraft/server/rcon/thread/RconClient.java ++++ b/net/minecraft/server/rcon/thread/RconClient.java +@@ -125,13 +_,14 @@ + } + + private void m_11594_(int p_11595_, String p_11596_) throws IOException { +- int i = p_11596_.length(); +- ++ byte[] whole = p_11596_.getBytes(StandardCharsets.UTF_8); ++ int i = whole.length; ++ int start = 0; + do { + int j = 4096 <= i ? 4096 : i; +- this.m_11590_(p_11595_, 0, p_11596_.substring(0, j)); +- p_11596_ = p_11596_.substring(j); +- i = p_11596_.length(); ++ this.m_11590_(p_11595_, 0, new String(java.util.Arrays.copyOfRange(whole, start, j+start), StandardCharsets.UTF_8)); ++ i -= j; ++ start += j; + } while(0 != i); + + } diff --git a/patches/minecraft/net/minecraft/sounds/SoundEvent.java.patch b/patches/minecraft/net/minecraft/sounds/SoundEvent.java.patch new file mode 100644 index 0000000000..24a088a8d1 --- /dev/null +++ b/patches/minecraft/net/minecraft/sounds/SoundEvent.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/sounds/SoundEvent.java ++++ b/net/minecraft/sounds/SoundEvent.java +@@ -3,7 +_,7 @@ + import com.mojang.serialization.Codec; + import net.minecraft.resources.ResourceLocation; + +-public class SoundEvent { ++public class SoundEvent extends net.minecraftforge.registries.ForgeRegistryEntry { + public static final Codec f_11655_ = ResourceLocation.f_135803_.xmap(SoundEvent::new, (p_11662_) -> { + return p_11662_.f_11656_; + }); diff --git a/patches/minecraft/net/minecraft/sounds/SoundEvents.java.patch b/patches/minecraft/net/minecraft/sounds/SoundEvents.java.patch new file mode 100644 index 0000000000..726486d818 --- /dev/null +++ b/patches/minecraft/net/minecraft/sounds/SoundEvents.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/sounds/SoundEvents.java ++++ b/net/minecraft/sounds/SoundEvents.java +@@ -3,6 +_,7 @@ + import net.minecraft.core.Registry; + import net.minecraft.resources.ResourceLocation; + ++@net.minecraftforge.registries.ObjectHolder("minecraft") + public class SoundEvents { + public static final SoundEvent f_11689_ = m_12656_("ambient.cave"); + public static final SoundEvent f_11742_ = m_12656_("ambient.basalt_deltas.additions"); diff --git a/patches/minecraft/net/minecraft/stats/StatType.java.patch b/patches/minecraft/net/minecraft/stats/StatType.java.patch index 9b2a36533f..03f6652df0 100644 --- a/patches/minecraft/net/minecraft/stats/StatType.java.patch +++ b/patches/minecraft/net/minecraft/stats/StatType.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/stats/StatType.java +++ b/net/minecraft/stats/StatType.java -@@ -10,7 +_,7 @@ - import net.minecraftforge.api.distmarker.Dist; - import net.minecraftforge.api.distmarker.OnlyIn; +@@ -8,7 +_,7 @@ + import net.minecraft.network.chat.Component; + import net.minecraft.network.chat.TranslatableComponent; -public class StatType implements Iterable> { +public class StatType extends net.minecraftforge.registries.ForgeRegistryEntry> implements Iterable> { - private final Registry field_199082_a; - private final Map> field_199083_b = new IdentityHashMap<>(); + private final Registry f_12888_; + private final Map> f_12889_ = new IdentityHashMap<>(); @Nullable diff --git a/patches/minecraft/net/minecraft/tags/BlockTags.java.patch b/patches/minecraft/net/minecraft/tags/BlockTags.java.patch index 65bf7aed28..aa06f3d691 100644 --- a/patches/minecraft/net/minecraft/tags/BlockTags.java.patch +++ b/patches/minecraft/net/minecraft/tags/BlockTags.java.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/tags/BlockTags.java +++ b/net/minecraft/tags/BlockTags.java -@@ -97,6 +_,14 @@ - return field_199899_c.func_232937_a_(p_199894_0_); +@@ -131,6 +_,14 @@ + return f_13053_.m_13244_(p_13117_); } -+ public static net.minecraftforge.common.Tags.IOptionalNamedTag createOptional(ResourceLocation name) { ++ public static net.minecraftforge.common.Tags.IOptionalNamedTag createOptional(net.minecraft.resources.ResourceLocation name) { + return createOptional(name, null); + } + -+ public static net.minecraftforge.common.Tags.IOptionalNamedTag createOptional(ResourceLocation name, @javax.annotation.Nullable java.util.Set> defaults) { -+ return field_199899_c.createOptional(name, defaults); ++ public static net.minecraftforge.common.Tags.IOptionalNamedTag createOptional(net.minecraft.resources.ResourceLocation name, @javax.annotation.Nullable java.util.Set> defaults) { ++ return f_13053_.createOptional(name, defaults); + } + - public static ITagCollection func_199896_a() { - return field_199899_c.func_232939_b_(); + public static TagCollection m_13115_() { + return f_13053_.m_13246_(); } diff --git a/patches/minecraft/net/minecraft/tags/EntityTypeTags.java.patch b/patches/minecraft/net/minecraft/tags/EntityTypeTags.java.patch index 346273f3b9..0a1c07ad5c 100644 --- a/patches/minecraft/net/minecraft/tags/EntityTypeTags.java.patch +++ b/patches/minecraft/net/minecraft/tags/EntityTypeTags.java.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/tags/EntityTypeTags.java +++ b/net/minecraft/tags/EntityTypeTags.java -@@ -16,6 +_,14 @@ - return field_219766_c.func_232937_a_(p_232896_0_); +@@ -23,6 +_,14 @@ + return f_13119_.m_13244_(p_13128_); } -+ public static net.minecraftforge.common.Tags.IOptionalNamedTag> createOptional(ResourceLocation name) { ++ public static net.minecraftforge.common.Tags.IOptionalNamedTag> createOptional(net.minecraft.resources.ResourceLocation name) { + return createOptional(name, null); + } + -+ public static net.minecraftforge.common.Tags.IOptionalNamedTag> createOptional(ResourceLocation name, @javax.annotation.Nullable java.util.Set>> defaults) { -+ return field_219766_c.createOptional(name, defaults); ++ public static net.minecraftforge.common.Tags.IOptionalNamedTag> createOptional(net.minecraft.resources.ResourceLocation name, @javax.annotation.Nullable java.util.Set>> defaults) { ++ return f_13119_.createOptional(name, defaults); + } + - public static ITagCollection> func_219762_a() { - return field_219766_c.func_232939_b_(); + public static TagCollection> m_13126_() { + return f_13119_.m_13246_(); } diff --git a/patches/minecraft/net/minecraft/tags/FluidTags.java.patch b/patches/minecraft/net/minecraft/tags/FluidTags.java.patch index 2af7dc0666..e19cb2f80d 100644 --- a/patches/minecraft/net/minecraft/tags/FluidTags.java.patch +++ b/patches/minecraft/net/minecraft/tags/FluidTags.java.patch @@ -1,23 +1,15 @@ --- a/net/minecraft/tags/FluidTags.java +++ b/net/minecraft/tags/FluidTags.java -@@ -13,7 +_,20 @@ - return field_206961_c.func_232937_a_(p_206956_0_); +@@ -28,4 +_,12 @@ + public static List> m_144300_() { + return f_144297_; } - -+ public static net.minecraftforge.common.Tags.IOptionalNamedTag createOptional(ResourceLocation name) { -+ return createOptional(name, null); ++ ++ public static net.minecraftforge.common.Tags.IOptionalNamedTag createOptional(net.minecraft.resources.ResourceLocation name) { ++ return createOptional(name, null); + } + -+ public static net.minecraftforge.common.Tags.IOptionalNamedTag createOptional(ResourceLocation name, @javax.annotation.Nullable java.util.Set> defaults) { -+ return field_206961_c.createOptional(name, defaults); ++ public static net.minecraftforge.common.Tags.IOptionalNamedTag createOptional(net.minecraft.resources.ResourceLocation name, @javax.annotation.Nullable java.util.Set> defaults) { ++ return f_13130_.createOptional(name, defaults); + } -+ - public static List> func_241280_c_() { - return field_206961_c.func_241288_c_(); -+ } -+ -+ //Forge: Readd this stripped getter like the other tag classes -+ public static ITagCollection func_226157_a_() { -+ return field_206961_c.func_232939_b_(); - } } diff --git a/patches/minecraft/net/minecraft/tags/ITag.java.patch b/patches/minecraft/net/minecraft/tags/ITag.java.patch deleted file mode 100644 index df686e1e3c..0000000000 --- a/patches/minecraft/net/minecraft/tags/ITag.java.patch +++ /dev/null @@ -1,59 +0,0 @@ ---- a/net/minecraft/tags/ITag.java -+++ b/net/minecraft/tags/ITag.java -@@ -46,6 +_,7 @@ - - public static class Builder { - private final List field_232953_a_ = Lists.newArrayList(); -+ private boolean replace = false; - - public static ITag.Builder func_200047_a() { - return new ITag.Builder(); -@@ -68,6 +_,15 @@ - return this.func_232955_a_(new ITag.TagEntry(p_232964_1_), p_232964_2_); - } - -+ public ITag.Builder replace(boolean value) { -+ this.replace = value; -+ return this; -+ } -+ -+ public ITag.Builder replace() { -+ return replace(true); -+ } -+ - public Optional> func_232959_a_(Function> p_232959_1_, Function p_232959_2_) { - ImmutableSet.Builder builder = ImmutableSet.builder(); - -@@ -103,6 +_,7 @@ - this.field_232953_a_.clear(); - } - -+ net.minecraftforge.common.ForgeHooks.deserializeTagAdditions(list, p_232956_1_, field_232953_a_); - list.forEach((p_232958_2_) -> { - this.field_232953_a_.add(new ITag.Proxy(p_232958_2_, p_232956_2_)); - }); -@@ -138,7 +_,7 @@ - itag$proxy.func_232968_a_().func_230237_a_(jsonarray); - } - -- jsonobject.addProperty("replace", false); -+ jsonobject.addProperty("replace", replace); - jsonobject.add("values", jsonarray); - return jsonobject; - } -@@ -178,6 +_,7 @@ - public String toString() { - return this.field_232969_a_.toString(); - } -+ @Override public boolean equals(Object o) { return o == this || (o instanceof ITag.ItemEntry && java.util.Objects.equals(this.field_232969_a_, ((ITag.ItemEntry) o).field_232969_a_)); } - } - - public static class OptionalItemEntry implements ITag.ITagEntry { -@@ -278,5 +_,7 @@ - public String toString() { - return "#" + this.field_200163_a; - } -+ @Override public boolean equals(Object o) { return o == this || (o instanceof ITag.TagEntry && java.util.Objects.equals(this.field_200163_a, ((ITag.TagEntry) o).field_200163_a)); } -+ public ResourceLocation getId() { return field_200163_a; } - } - } diff --git a/patches/minecraft/net/minecraft/tags/ITagCollectionSupplier.java.patch b/patches/minecraft/net/minecraft/tags/ITagCollectionSupplier.java.patch deleted file mode 100644 index 1f4daf3b04..0000000000 --- a/patches/minecraft/net/minecraft/tags/ITagCollectionSupplier.java.patch +++ /dev/null @@ -1,54 +0,0 @@ ---- a/net/minecraft/tags/ITagCollectionSupplier.java -+++ b/net/minecraft/tags/ITagCollectionSupplier.java -@@ -8,7 +_,7 @@ - import net.minecraft.network.PacketBuffer; - import net.minecraft.util.registry.Registry; - --public interface ITagCollectionSupplier { -+public interface ITagCollectionSupplier extends net.minecraftforge.common.extensions.IForgeTagCollectionSupplier { - ITagCollectionSupplier field_242208_a = func_242209_a(ITagCollection.func_242205_c(), ITagCollection.func_242205_c(), ITagCollection.func_242205_c(), ITagCollection.func_242205_c()); - - ITagCollection func_241835_a(); -@@ -22,6 +_,7 @@ - default void func_242212_e() { - TagRegistryManager.func_242193_a(this); - Blocks.func_235419_a_(); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.TagsUpdatedEvent.VanillaTagTypes(this)); - } - - default void func_242210_a(PacketBuffer p_242210_1_) { -@@ -55,6 +_,34 @@ - - public ITagCollection> func_241838_d() { - return p_242209_3_; -+ } -+ }; -+ } -+ -+ static ITagCollectionSupplier reinjectOptionalTags(ITagCollectionSupplier tagCollectionSupplier) { -+ ITagCollection blockTagCollection = BlockTags.field_199899_c.reinjectOptionalTags(tagCollectionSupplier.func_241835_a()); -+ ITagCollection itemTagCollection = ItemTags.field_199906_c.reinjectOptionalTags(tagCollectionSupplier.func_241836_b()); -+ ITagCollection fluidTagCollection = FluidTags.field_206961_c.reinjectOptionalTags(tagCollectionSupplier.func_241837_c()); -+ ITagCollection> entityTypeTagCollection = EntityTypeTags.field_219766_c.reinjectOptionalTags(tagCollectionSupplier.func_241838_d()); -+ return new ITagCollectionSupplier() { -+ @Override -+ public ITagCollection func_241835_a() { -+ return blockTagCollection; -+ } -+ -+ @Override -+ public ITagCollection func_241836_b() { -+ return itemTagCollection; -+ } -+ -+ @Override -+ public ITagCollection func_241837_c() { -+ return fluidTagCollection; -+ } -+ -+ @Override -+ public ITagCollection> func_241838_d() { -+ return entityTypeTagCollection; - } - }; - } diff --git a/patches/minecraft/net/minecraft/tags/ItemTags.java.patch b/patches/minecraft/net/minecraft/tags/ItemTags.java.patch index 03c6569b46..8b358e49d1 100644 --- a/patches/minecraft/net/minecraft/tags/ItemTags.java.patch +++ b/patches/minecraft/net/minecraft/tags/ItemTags.java.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/tags/ItemTags.java +++ b/net/minecraft/tags/ItemTags.java -@@ -65,6 +_,14 @@ - return field_199906_c.func_232937_a_(p_199901_0_); +@@ -82,6 +_,14 @@ + return f_13163_.m_13244_(p_13195_); } -+ public static net.minecraftforge.common.Tags.IOptionalNamedTag createOptional(ResourceLocation name) { ++ public static net.minecraftforge.common.Tags.IOptionalNamedTag createOptional(net.minecraft.resources.ResourceLocation name) { + return createOptional(name, null); + } + -+ public static net.minecraftforge.common.Tags.IOptionalNamedTag createOptional(ResourceLocation name, @javax.annotation.Nullable java.util.Set> defaults) { -+ return field_199906_c.createOptional(name, defaults); ++ public static net.minecraftforge.common.Tags.IOptionalNamedTag createOptional(net.minecraft.resources.ResourceLocation name, @javax.annotation.Nullable java.util.Set> defaults) { ++ return f_13163_.createOptional(name, defaults); + } + - public static ITagCollection func_199903_a() { - return field_199906_c.func_232939_b_(); + public static TagCollection m_13193_() { + return f_13163_.m_13246_(); } diff --git a/patches/minecraft/net/minecraft/tags/NetworkTagManager.java.patch b/patches/minecraft/net/minecraft/tags/NetworkTagManager.java.patch deleted file mode 100644 index b839e0f84c..0000000000 --- a/patches/minecraft/net/minecraft/tags/NetworkTagManager.java.patch +++ /dev/null @@ -1,34 +0,0 @@ ---- a/net/minecraft/tags/NetworkTagManager.java -+++ b/net/minecraft/tags/NetworkTagManager.java -@@ -20,6 +_,7 @@ - protected TagCollectionReader field_199720_b = new TagCollectionReader<>(Registry.field_212630_s::func_241873_b, "tags/items", "item"); - protected TagCollectionReader field_205705_c = new TagCollectionReader<>(Registry.field_212619_h::func_241873_b, "tags/fluids", "fluid"); - protected TagCollectionReader> field_215299_d = new TagCollectionReader<>(Registry.field_212629_r::func_241873_b, "tags/entity_types", "entity_type"); -+ protected Map> customTagTypeReaders = net.minecraftforge.common.ForgeTagHandler.createCustomTagTypeReaders(); - private ITagCollectionSupplier field_242230_e = ITagCollectionSupplier.field_242208_a; - - public ITagCollectionSupplier func_242231_a() { -@@ -31,11 +_,13 @@ - CompletableFuture> completablefuture1 = this.field_199720_b.func_242224_a(p_215226_2_, p_215226_5_); - CompletableFuture> completablefuture2 = this.field_205705_c.func_242224_a(p_215226_2_, p_215226_5_); - CompletableFuture> completablefuture3 = this.field_215299_d.func_242224_a(p_215226_2_, p_215226_5_); -- return CompletableFuture.allOf(completablefuture, completablefuture1, completablefuture2, completablefuture3).thenCompose(p_215226_1_::func_216872_a).thenAcceptAsync((p_232979_5_) -> { -+ CompletableFuture> customTagTypeResults = net.minecraftforge.common.ForgeTagHandler.getCustomTagTypeReloadResults(p_215226_2_, p_215226_5_, customTagTypeReaders); -+ return CompletableFuture.allOf(completablefuture, completablefuture1, completablefuture2, completablefuture3, customTagTypeResults).thenCompose(p_215226_1_::func_216872_a).thenAcceptAsync((p_232979_5_) -> { - ITagCollection itagcollection = this.field_199719_a.func_242226_a(completablefuture.join()); - ITagCollection itagcollection1 = this.field_199720_b.func_242226_a(completablefuture1.join()); - ITagCollection itagcollection2 = this.field_205705_c.func_242226_a(completablefuture2.join()); - ITagCollection> itagcollection3 = this.field_215299_d.func_242226_a(completablefuture3.join()); -+ net.minecraftforge.common.ForgeTagHandler.updateCustomTagTypes(customTagTypeResults.join()); - ITagCollectionSupplier itagcollectionsupplier = ITagCollectionSupplier.func_242209_a(itagcollection, itagcollection1, itagcollection2, itagcollection3); - Multimap multimap = TagRegistryManager.func_242198_b(itagcollectionsupplier); - if (!multimap.isEmpty()) { -@@ -43,6 +_,8 @@ - return p_232978_0_.getKey() + ":" + p_232978_0_.getValue(); - }).sorted().collect(Collectors.joining(","))); - } else { -+ itagcollectionsupplier = ITagCollectionSupplier.reinjectOptionalTags(itagcollectionsupplier); -+ net.minecraftforge.common.ForgeTagHandler.reinjectOptionalTagsCustomTypes(); - TagCollectionManager.func_242180_a(itagcollectionsupplier); - this.field_242230_e = itagcollectionsupplier; - } diff --git a/patches/minecraft/net/minecraft/tags/StaticTagHelper.java.patch b/patches/minecraft/net/minecraft/tags/StaticTagHelper.java.patch new file mode 100644 index 0000000000..328c434efa --- /dev/null +++ b/patches/minecraft/net/minecraft/tags/StaticTagHelper.java.patch @@ -0,0 +1,144 @@ +--- a/net/minecraft/tags/StaticTagHelper.java ++++ b/net/minecraft/tags/StaticTagHelper.java +@@ -17,6 +_,7 @@ + private final String f_144327_; + private TagCollection f_13227_ = TagCollection.m_13410_(); + private final List> f_13228_ = Lists.newArrayList(); ++ private static java.util.Map>> toAdd = com.google.common.collect.Maps.newHashMap(); + + public StaticTagHelper(ResourceKey> p_144329_, String p_144330_) { + this.f_144326_ = p_144329_; +@@ -24,9 +_,46 @@ + } + + public Tag.Named m_13244_(String p_13245_) { +- StaticTagHelper.Wrapper wrapper = new StaticTagHelper.Wrapper<>(new ResourceLocation(p_13245_)); +- this.f_13228_.add(wrapper); +- return wrapper; ++ return add(new StaticTagHelper.Wrapper<>(new ResourceLocation(p_13245_))); ++ } ++ ++ public net.minecraftforge.common.Tags.IOptionalNamedTag createOptional(ResourceLocation key, @Nullable Set> defaults) { ++ return add(new StaticTagHelper.OptionalNamedTag<>(key, defaults)); ++ } ++ ++ /** Call via ForgeTagHandler#makeWrapperTag to avoid any exceptions due to calling this after it is safe to call {@link #bind(String)} */ ++ public static Tag.Named createDelayedTag(ResourceLocation tagRegistry, ResourceLocation name) { ++ return delayedAdd(tagRegistry, new StaticTagHelper.Wrapper<>(name)); ++ } ++ ++ /** Call via ForgeTagHandler#createOptionalTag to avoid any exceptions due to calling this after it is safe to call {@link #createOptional(ResourceLocation, Set)} */ ++ public static net.minecraftforge.common.Tags.IOptionalNamedTag createDelayedOptional(ResourceLocation tagRegistry, ResourceLocation key, @Nullable Set> defaults) { ++ return delayedAdd(tagRegistry, new StaticTagHelper.OptionalNamedTag<>(key, defaults)); ++ } ++ ++ private static synchronized > R delayedAdd(ResourceLocation tagRegistry, R tag) { ++ if (toAdd == null) throw new RuntimeException("Creating delayed tags or optional tags, is only supported before custom tag types have been added."); ++ toAdd.computeIfAbsent(tagRegistry, registry -> Lists.newArrayList()).add(tag); ++ return tag; ++ } ++ ++ public static void performDelayedAdd() { ++ if (toAdd != null) { ++ for (java.util.Map.Entry>> entry : toAdd.entrySet()) { ++ StaticTagHelper tagRegistry = StaticTags.get(entry.getKey()); ++ if (tagRegistry == null) throw new RuntimeException("A mod attempted to add a delayed tag for a registry that doesn't have custom tag support."); ++ for (StaticTagHelper.Wrapper tag : entry.getValue()) { ++ tagRegistry.add((StaticTagHelper.Wrapper) tag); ++ } ++ } ++ toAdd = null; ++ } ++ } ++ ++ private > R add(R namedtag) { ++ namedtag.m_13260_(f_13227_::m_13404_); ++ this.f_13228_.add(namedtag); ++ return namedtag; + } + + public void m_13232_() { +@@ -47,13 +_,31 @@ + }); + } + ++ public TagCollection reinjectOptionalTags(TagCollection tagCollection) { ++ java.util.Map> currentTags = tagCollection.m_5643_(); ++ java.util.Map> missingOptionals = this.f_13228_.stream().filter(e -> e instanceof OptionalNamedTag && !currentTags.containsKey(e.m_6979_())).collect(Collectors.toMap(Wrapper::m_6979_, namedTag -> { ++ OptionalNamedTag optionalNamedTag = (OptionalNamedTag) namedTag; ++ optionalNamedTag.defaulted = true; ++ return optionalNamedTag.resolveDefaulted(); ++ })); ++ if (!missingOptionals.isEmpty()) { ++ missingOptionals.putAll(currentTags); ++ return TagCollection.m_13396_(missingOptionals); ++ } ++ return tagCollection; ++ } ++ + public TagCollection m_13246_() { + return this.f_13227_; + } + ++ public List> getWrappers() { ++ return this.f_13228_; ++ } ++ + public Set m_13247_(TagContainer p_13248_) { + TagCollection tagcollection = p_13248_.m_144452_(this.f_144326_); +- Set set = this.f_13228_.stream().map(StaticTagHelper.Wrapper::m_6979_).collect(Collectors.toSet()); ++ Set set = this.f_13228_.stream().filter(e -> !(e instanceof OptionalNamedTag)).map(StaticTagHelper.Wrapper::m_6979_).collect(Collectors.toSet()); + ImmutableSet immutableset = ImmutableSet.copyOf(tagcollection.m_13406_()); + return Sets.difference(set, immutableset); + } +@@ -67,7 +_,7 @@ + } + + protected void m_144336_(TagContainer.Builder p_144337_) { +- p_144337_.m_144486_(this.f_144326_, TagCollection.m_13396_(this.f_13228_.stream().collect(Collectors.toMap(Tag.Named::m_6979_, (p_144332_) -> { ++ p_144337_.m_144486_(this.f_144326_, TagCollection.m_13396_(this.f_13228_.stream().distinct().collect(Collectors.toMap(Tag.Named::m_6979_, (p_144332_) -> { + return p_144332_; + })))); + } +@@ -103,6 +_,41 @@ + + public List m_6497_() { + return this.m_13263_().m_6497_(); ++ } ++ ++ @Override ++ public String toString() { ++ return "NamedTag[" + m_6979_().toString() + ']'; ++ } ++ @Override public boolean equals(Object o) { return (o == this) || (o instanceof Tag.Named && java.util.Objects.equals(this.m_6979_(), ((Tag.Named)o).m_6979_())); } ++ @Override public int hashCode() { return m_6979_().hashCode(); } ++ } ++ ++ private static class OptionalNamedTag extends Wrapper implements net.minecraftforge.common.Tags.IOptionalNamedTag { ++ @Nullable ++ private final Set> defaults; ++ private boolean defaulted = false; ++ ++ private OptionalNamedTag(ResourceLocation name, @Nullable Set> defaults) { ++ super(name); ++ this.defaults = defaults; ++ } ++ ++ @Override ++ public boolean isDefaulted() { ++ return defaulted; ++ } ++ ++ SetTag resolveDefaulted() { ++ if (defaults == null || defaults.isEmpty()) { ++ return SetTag.m_13216_(); ++ } ++ return SetTag.m_13222_(ImmutableSet.copyOf(defaults.stream().map(java.util.function.Supplier::get).collect(Collectors.toSet()))); ++ } ++ ++ @Override ++ public String toString() { ++ return "OptionalNamedTag[" + m_6979_().toString() + ']'; + } + } + } diff --git a/patches/minecraft/net/minecraft/tags/StaticTags.java.patch b/patches/minecraft/net/minecraft/tags/StaticTags.java.patch new file mode 100644 index 0000000000..e24b15db25 --- /dev/null +++ b/patches/minecraft/net/minecraft/tags/StaticTags.java.patch @@ -0,0 +1,62 @@ +--- a/net/minecraft/tags/StaticTags.java ++++ b/net/minecraft/tags/StaticTags.java +@@ -14,15 +_,16 @@ + import net.minecraft.resources.ResourceLocation; + + public class StaticTags { +- private static final Set> f_144340_ = Sets.newHashSet(); +- private static final List> f_13264_ = Lists.newArrayList(); ++ private static final java.util.Map, StaticTagHelper> HELPER_MAP = new java.util.HashMap<>(); // Forge: Minecraft separates this for no reason, lets make it a map again! ++ private static final Set> f_144340_ = HELPER_MAP.keySet(); ++ private static final java.util.Collection> f_13264_ = HELPER_MAP.values(); + + public static StaticTagHelper m_144351_(ResourceKey> p_144352_, String p_144353_) { +- if (!f_144340_.add(p_144352_)) { ++ if (f_144340_.contains(p_144352_)) { + throw new IllegalStateException("Duplicate entry for static tag collection: " + p_144352_); + } else { + StaticTagHelper statictaghelper = new StaticTagHelper<>(p_144352_, p_144353_); +- f_13264_.add(statictaghelper); ++ HELPER_MAP.put(p_144352_, statictaghelper); + return statictaghelper; + } + } +@@ -55,11 +_,29 @@ + + private static void m_144356_() { + Set> set = m_144355_().stream().map(StaticTagHelper::m_144338_).collect(Collectors.toSet()); +- if (!Sets.difference(f_144340_, set).isEmpty()) { ++ if (!Sets.difference(set, f_144340_).isEmpty()) { // Forge: Fix bug with extra tag collections crashing + throw new IllegalStateException("Missing helper registrations"); + } + } + ++ @javax.annotation.Nullable ++ public static StaticTagHelper get(ResourceLocation rl) { ++ return HELPER_MAP.get(ResourceKey.m_135788_(rl)); ++ } ++ ++ public static Multimap>, ResourceLocation> validateVanillaTags(TagContainer tagCollectionSupplier) { ++ Multimap>, ResourceLocation> multimap = HashMultimap.create(); ++ f_13264_.forEach((tagHelper) -> { ++ if (!net.minecraftforge.common.ForgeTagHandler.getCustomTagTypeNames().contains(tagHelper.m_144338_().m_135782_())) ++ multimap.putAll(tagHelper.m_144338_(), tagHelper.m_13247_(tagCollectionSupplier)); ++ }); ++ return multimap; ++ } ++ ++ public static void fetchCustomTagTypes(TagContainer tagCollectionSupplier) { ++ net.minecraftforge.common.ForgeTagHandler.getCustomTagTypeNames().forEach(tagRegistry -> HELPER_MAP.get(ResourceKey.m_135788_(tagRegistry)).m_13242_(tagCollectionSupplier)); ++ } ++ + public static void m_144349_(Consumer> p_144350_) { + f_13264_.forEach(p_144350_); + } +@@ -70,6 +_,7 @@ + f_13264_.forEach((p_144344_) -> { + p_144344_.m_144336_(tagcontainer$builder); + }); ++ net.minecraftforge.common.ForgeTagHandler.populateTagCollectionManager(); + return tagcontainer$builder.m_144485_(); + } + } diff --git a/patches/minecraft/net/minecraft/tags/Tag.java.patch b/patches/minecraft/net/minecraft/tags/Tag.java.patch new file mode 100644 index 0000000000..92710b5ca0 --- /dev/null +++ b/patches/minecraft/net/minecraft/tags/Tag.java.patch @@ -0,0 +1,60 @@ +--- a/net/minecraft/tags/Tag.java ++++ b/net/minecraft/tags/Tag.java +@@ -49,6 +_,7 @@ + + public static class Builder { + private final List f_13302_ = Lists.newArrayList(); ++ private boolean replace = false; + + public static Tag.Builder m_13304_() { + return new Tag.Builder(); +@@ -79,6 +_,15 @@ + return this.m_13307_(new Tag.OptionalTagEntry(p_144383_), p_144384_); + } + ++ public Tag.Builder replace(boolean value) { ++ this.replace = value; ++ return this; ++ } ++ ++ public Tag.Builder replace() { ++ return replace(true); ++ } ++ + public Either, Tag> m_144371_(Function> p_144372_, Function p_144373_) { + ImmutableSet.Builder builder = ImmutableSet.builder(); + List list = Lists.newArrayList(); +@@ -120,6 +_,7 @@ + this.f_13302_.clear(); + } + ++ net.minecraftforge.common.ForgeHooks.deserializeTagAdditions(list, p_13313_, f_13302_); + list.forEach((p_13319_) -> { + this.f_13302_.add(new Tag.BuilderEntry(p_13319_, p_13314_)); + }); +@@ -155,7 +_,7 @@ + tag$builderentry.m_13347_().m_6383_(jsonarray); + } + +- jsonobject.addProperty("replace", false); ++ jsonobject.addProperty("replace", replace); + jsonobject.add("values", jsonarray); + return jsonobject; + } +@@ -211,6 +_,7 @@ + public String toString() { + return this.f_13349_.toString(); + } ++ @Override public boolean equals(Object o) { return o == this || (o instanceof Tag.ElementEntry && java.util.Objects.equals(this.f_13349_, ((Tag.ElementEntry) o).f_13349_)); } + } + + public interface Entry { +@@ -323,6 +_,8 @@ + public String toString() { + return "#" + this.f_13383_; + } ++ @Override public boolean equals(Object o) { return o == this || (o instanceof Tag.TagEntry && java.util.Objects.equals(this.f_13383_, ((Tag.TagEntry) o).f_13383_)); } ++ public ResourceLocation getId() { return f_13383_; } + + public boolean m_142746_(Predicate p_144404_, Predicate p_144405_) { + return p_144405_.test(this.f_13383_); diff --git a/patches/minecraft/net/minecraft/tags/TagCollectionManager.java.patch b/patches/minecraft/net/minecraft/tags/TagCollectionManager.java.patch deleted file mode 100644 index fd844b9017..0000000000 --- a/patches/minecraft/net/minecraft/tags/TagCollectionManager.java.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/tags/TagCollectionManager.java -+++ b/net/minecraft/tags/TagCollectionManager.java -@@ -3,13 +_,13 @@ - import java.util.stream.Collectors; - - public class TagCollectionManager { -- private static volatile ITagCollectionSupplier field_232918_a_ = ITagCollectionSupplier.func_242209_a(ITagCollection.func_242202_a(BlockTags.func_242174_b().stream().collect(Collectors.toMap(ITag.INamedTag::func_230234_a_, (p_242183_0_) -> { -+ private static volatile ITagCollectionSupplier field_232918_a_ = net.minecraftforge.common.ForgeTagHandler.populateTagCollectionManager(ITagCollection.func_242202_a(BlockTags.func_242174_b().stream().distinct().collect(Collectors.toMap(ITag.INamedTag::func_230234_a_, (p_242183_0_) -> { - return p_242183_0_; -- }))), ITagCollection.func_242202_a(ItemTags.func_242177_b().stream().collect(Collectors.toMap(ITag.INamedTag::func_230234_a_, (p_242182_0_) -> { -+ }))), ITagCollection.func_242202_a(ItemTags.func_242177_b().stream().distinct().collect(Collectors.toMap(ITag.INamedTag::func_230234_a_, (p_242182_0_) -> { - return p_242182_0_; -- }))), ITagCollection.func_242202_a(FluidTags.func_241280_c_().stream().collect(Collectors.toMap(ITag.INamedTag::func_230234_a_, (p_242181_0_) -> { -+ }))), ITagCollection.func_242202_a(FluidTags.func_241280_c_().stream().distinct().collect(Collectors.toMap(ITag.INamedTag::func_230234_a_, (p_242181_0_) -> { - return p_242181_0_; -- }))), ITagCollection.func_242202_a(EntityTypeTags.func_242175_b().stream().collect(Collectors.toMap(ITag.INamedTag::func_230234_a_, (p_242179_0_) -> { -+ }))), ITagCollection.func_242202_a(EntityTypeTags.func_242175_b().stream().distinct().collect(Collectors.toMap(ITag.INamedTag::func_230234_a_, (p_242179_0_) -> { - return p_242179_0_; - })))); - diff --git a/patches/minecraft/net/minecraft/tags/TagContainer.java.patch b/patches/minecraft/net/minecraft/tags/TagContainer.java.patch new file mode 100644 index 0000000000..df79f35fb5 --- /dev/null +++ b/patches/minecraft/net/minecraft/tags/TagContainer.java.patch @@ -0,0 +1,33 @@ +--- a/net/minecraft/tags/TagContainer.java ++++ b/net/minecraft/tags/TagContainer.java +@@ -15,7 +_,7 @@ + import org.apache.logging.log4j.LogManager; + import org.apache.logging.log4j.Logger; + +-public class TagContainer { ++public class TagContainer implements net.minecraftforge.common.extensions.IForgeTagContainer { + static final Logger f_144432_ = LogManager.getLogger(); + public static final TagContainer f_13420_ = new TagContainer(ImmutableMap.of()); + public final Map>, TagCollection> f_144433_; +@@ -74,6 +_,7 @@ + public void m_13431_() { + StaticTags.m_13269_(this); + Blocks.m_50758_(); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.TagsUpdatedEvent.VanillaTagTypes(this)); + } + + public Map>, TagCollection.NetworkPayload> m_144442_(final RegistryAccess p_144443_) { +@@ -108,6 +_,13 @@ + f_144432_.error("Unknown registry {}", (Object)p_144447_); + } + ++ } ++ ++ public static TagContainer reinjectOptionalTags(TagContainer tagCollectionSupplier) { ++ TagContainer.Builder builder = new TagContainer.Builder(); ++ //noinspection unchecked,rawtypes ++ StaticTags.m_144349_(h -> builder.m_144486_(h.m_144338_(), h.reinjectOptionalTags(tagCollectionSupplier.m_144452_((ResourceKey) h.m_144338_())))); ++ return builder.m_144485_(); + } + + public static class Builder { diff --git a/patches/minecraft/net/minecraft/tags/TagManager.java.patch b/patches/minecraft/net/minecraft/tags/TagManager.java.patch new file mode 100644 index 0000000000..3da79ce227 --- /dev/null +++ b/patches/minecraft/net/minecraft/tags/TagManager.java.patch @@ -0,0 +1,41 @@ +--- a/net/minecraft/tags/TagManager.java ++++ b/net/minecraft/tags/TagManager.java +@@ -21,6 +_,7 @@ + public class TagManager implements PreparableReloadListener { + private static final Logger f_144568_ = LogManager.getLogger(); + private final RegistryAccess f_144569_; ++ protected java.util.Map> customTagTypeReaders = net.minecraftforge.common.ForgeTagHandler.createCustomTagTypeReaders(); + private TagContainer f_13478_ = TagContainer.f_13420_; + + public TagManager(RegistryAccess p_144572_) { +@@ -40,15 +_,16 @@ + } + + }); +- return CompletableFuture.allOf(list.stream().map((p_144591_) -> { +- return p_144591_.f_144598_; +- }).toArray((p_144574_) -> { +- return new CompletableFuture[p_144574_]; +- })).thenCompose(p_13482_::m_6769_).thenAcceptAsync((p_144594_) -> { ++ CompletableFuture> customTagTypeResults = net.minecraftforge.common.ForgeTagHandler.getCustomTagTypeReloadResults(p_13483_, p_13486_, customTagTypeReaders); ++ List> futures = Lists.newArrayList(); ++ list.stream().map(li -> li.f_144598_).forEach(futures::add); ++ futures.add(customTagTypeResults); ++ return CompletableFuture.allOf(futures.toArray(CompletableFuture[]::new)).thenCompose(p_13482_::m_6769_).thenAcceptAsync((p_144594_) -> { + TagContainer.Builder tagcontainer$builder = new TagContainer.Builder(); + list.forEach((p_144586_) -> { + p_144586_.m_144602_(tagcontainer$builder); + }); ++ net.minecraftforge.common.ForgeTagHandler.updateCustomTagTypes(customTagTypeResults.join()); + TagContainer tagcontainer = tagcontainer$builder.m_144485_(); + Multimap>, ResourceLocation> multimap = StaticTags.m_13283_(tagcontainer); + if (!multimap.isEmpty()) { +@@ -56,6 +_,8 @@ + return p_144596_.getKey() + ":" + p_144596_.getValue(); + }).sorted().collect(Collectors.joining(","))); + } else { ++ tagcontainer = TagContainer.reinjectOptionalTags(tagcontainer); ++ net.minecraftforge.common.ForgeTagHandler.reinjectOptionalTagsCustomTypes(); + SerializationTags.m_13202_(tagcontainer); + this.f_13478_ = tagcontainer; + } diff --git a/patches/minecraft/net/minecraft/tags/TagRegistry.java.patch b/patches/minecraft/net/minecraft/tags/TagRegistry.java.patch deleted file mode 100644 index 1deb6b493f..0000000000 --- a/patches/minecraft/net/minecraft/tags/TagRegistry.java.patch +++ /dev/null @@ -1,127 +0,0 @@ ---- a/net/minecraft/tags/TagRegistry.java -+++ b/net/minecraft/tags/TagRegistry.java -@@ -16,13 +_,51 @@ - private ITagCollection field_232930_b_ = ITagCollection.func_242205_c(); - private final List> field_232931_c_ = Lists.newArrayList(); - private final Function> field_242184_c; -+ private static java.util.Map>> toAdd = com.google.common.collect.Maps.newHashMap(); - - public TagRegistry(Function> p_i241894_1_) { - this.field_242184_c = p_i241894_1_; - } - - public ITag.INamedTag func_232937_a_(String p_232937_1_) { -- TagRegistry.NamedTag namedtag = new TagRegistry.NamedTag<>(new ResourceLocation(p_232937_1_)); -+ return add(new TagRegistry.NamedTag<>(new ResourceLocation(p_232937_1_))); -+ } -+ -+ public net.minecraftforge.common.Tags.IOptionalNamedTag createOptional(ResourceLocation key, @Nullable Set> defaults) { -+ return add(new TagRegistry.OptionalNamedTag<>(key, defaults)); -+ } -+ -+ /** Call via ForgeTagHandler#makeWrapperTag to avoid any exceptions due to calling this after it is safe to call {@link #createTag(String)} */ -+ public static ITag.INamedTag createDelayedTag(ResourceLocation tagRegistry, ResourceLocation name) { -+ return delayedAdd(tagRegistry, new TagRegistry.NamedTag<>(name)); -+ } -+ -+ /** Call via ForgeTagHandler#createOptionalTag to avoid any exceptions due to calling this after it is safe to call {@link #createOptional(ResourceLocation, Set)} */ -+ public static net.minecraftforge.common.Tags.IOptionalNamedTag createDelayedOptional(ResourceLocation tagRegistry, ResourceLocation key, @Nullable Set> defaults) { -+ return delayedAdd(tagRegistry, new TagRegistry.OptionalNamedTag<>(key, defaults)); -+ } -+ -+ private static synchronized > R delayedAdd(ResourceLocation tagRegistry, R tag) { -+ if (toAdd == null) throw new RuntimeException("Creating delayed tags or optional tags, is only supported before custom tag types have been added."); -+ toAdd.computeIfAbsent(tagRegistry, registry -> Lists.newArrayList()).add(tag); -+ return tag; -+ } -+ -+ public static void performDelayedAdd() { -+ if (toAdd != null) { -+ for (java.util.Map.Entry>> entry : toAdd.entrySet()) { -+ TagRegistry tagRegistry = TagRegistryManager.get(entry.getKey()); -+ if (tagRegistry == null) throw new RuntimeException("A mod attempted to add a delayed tag for a registry that doesn't have custom tag support."); -+ for (TagRegistry.NamedTag tag : entry.getValue()) { -+ tagRegistry.add((TagRegistry.NamedTag) tag); -+ } -+ } -+ toAdd = null; -+ } -+ } -+ -+ private > R add(R namedtag) { -+ namedtag.func_232943_a_(field_232930_b_::func_199910_a); - this.field_232931_c_.add(namedtag); - return namedtag; - } -@@ -46,6 +_,20 @@ - }); - } - -+ public ITagCollection reinjectOptionalTags(ITagCollection tagCollection) { -+ java.util.Map> currentTags = tagCollection.func_241833_a(); -+ java.util.Map> missingOptionals = this.field_232931_c_.stream().filter(e -> e instanceof OptionalNamedTag && !currentTags.containsKey(e.func_230234_a_())).collect(Collectors.toMap(NamedTag::func_230234_a_, namedTag -> { -+ OptionalNamedTag optionalNamedTag = (OptionalNamedTag) namedTag; -+ optionalNamedTag.defaulted = true; -+ return optionalNamedTag.resolveDefaulted(); -+ })); -+ if (!missingOptionals.isEmpty()) { -+ missingOptionals.putAll(currentTags); -+ return ITagCollection.func_242202_a(missingOptionals); -+ } -+ return tagCollection; -+ } -+ - public ITagCollection func_232939_b_() { - return this.field_232930_b_; - } -@@ -56,7 +_,7 @@ - - public Set func_242189_b(ITagCollectionSupplier p_242189_1_) { - ITagCollection itagcollection = this.field_242184_c.apply(p_242189_1_); -- Set set = this.field_232931_c_.stream().map(TagRegistry.NamedTag::func_230234_a_).collect(Collectors.toSet()); -+ Set set = this.field_232931_c_.stream().filter(e -> !(e instanceof OptionalNamedTag)).map(TagRegistry.NamedTag::func_230234_a_).collect(Collectors.toSet()); - ImmutableSet immutableset = ImmutableSet.copyOf(itagcollection.func_199908_a()); - return Sets.difference(set, immutableset); - } -@@ -92,6 +_,41 @@ - - public List func_230236_b_() { - return this.func_232944_c_().func_230236_b_(); -+ } -+ -+ @Override -+ public String toString() { -+ return "NamedTag[" + func_230234_a_().toString() + ']'; -+ } -+ @Override public boolean equals(Object o) { return (o == this) || (o instanceof ITag.INamedTag && java.util.Objects.equals(this.func_230234_a_(), ((ITag.INamedTag)o).func_230234_a_())); } -+ @Override public int hashCode() { return func_230234_a_().hashCode(); } -+ } -+ -+ private static class OptionalNamedTag extends NamedTag implements net.minecraftforge.common.Tags.IOptionalNamedTag { -+ @Nullable -+ private final Set> defaults; -+ private boolean defaulted = false; -+ -+ private OptionalNamedTag(ResourceLocation name, @Nullable Set> defaults) { -+ super(name); -+ this.defaults = defaults; -+ } -+ -+ @Override -+ public boolean isDefaulted() { -+ return defaulted; -+ } -+ -+ Tag resolveDefaulted() { -+ if (defaults == null || defaults.isEmpty()) { -+ return Tag.func_241284_a_(); -+ } -+ return Tag.func_241286_a_(ImmutableSet.copyOf(defaults.stream().map(java.util.function.Supplier::get).collect(Collectors.toSet()))); -+ } -+ -+ @Override -+ public String toString() { -+ return "OptionalNamedTag[" + func_230234_a_().toString() + ']'; - } - } - } diff --git a/patches/minecraft/net/minecraft/tags/TagRegistryManager.java.patch b/patches/minecraft/net/minecraft/tags/TagRegistryManager.java.patch deleted file mode 100644 index f2d5324968..0000000000 --- a/patches/minecraft/net/minecraft/tags/TagRegistryManager.java.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- a/net/minecraft/tags/TagRegistryManager.java -+++ b/net/minecraft/tags/TagRegistryManager.java -@@ -51,4 +_,23 @@ - throw new IllegalStateException("Missing helper registrations"); - } - } -+ -+ @javax.annotation.Nullable -+ public static TagRegistry get(ResourceLocation rl) { -+ return field_242190_a.get(rl); -+ } -+ -+ public static Multimap validateVanillaTags(ITagCollectionSupplier tagCollectionSupplier) { -+ Multimap missingTags = HashMultimap.create(); -+ for (java.util.Map.Entry> entry : field_242190_a.entrySet()) { -+ if (!net.minecraftforge.common.ForgeTagHandler.getCustomTagTypeNames().contains(entry.getKey())) { -+ missingTags.putAll(entry.getKey(), entry.getValue().func_242189_b(tagCollectionSupplier)); -+ } -+ } -+ return missingTags; -+ } -+ -+ public static void fetchCustomTagTypes(ITagCollectionSupplier tagCollectionSupplier) { -+ net.minecraftforge.common.ForgeTagHandler.getCustomTagTypeNames().forEach(tagRegistry -> field_242190_a.get(tagRegistry).func_242188_a(tagCollectionSupplier)); -+ } - } diff --git a/patches/minecraft/net/minecraft/tileentity/AbstractFurnaceTileEntity.java.patch b/patches/minecraft/net/minecraft/tileentity/AbstractFurnaceTileEntity.java.patch deleted file mode 100644 index ddfc7c978e..0000000000 --- a/patches/minecraft/net/minecraft/tileentity/AbstractFurnaceTileEntity.java.patch +++ /dev/null @@ -1,151 +0,0 @@ ---- a/net/minecraft/tileentity/AbstractFurnaceTileEntity.java -+++ b/net/minecraft/tileentity/AbstractFurnaceTileEntity.java -@@ -91,6 +_,7 @@ - this.field_214014_c = p_i49964_2_; - } - -+ @Deprecated //Forge - get burn times by calling ForgeHooks#getBurnTime(ItemStack) - public static Map func_214001_f() { - Map map = Maps.newLinkedHashMap(); - func_213996_a(map, Items.field_151129_at, 20000); -@@ -184,13 +_,13 @@ - return this.field_214018_j > 0; - } - -- public void func_230337_a_(BlockState p_230337_1_, CompoundNBT p_230337_2_) { -+ public void func_230337_a_(BlockState p_230337_1_, CompoundNBT p_230337_2_) { //TODO: MARK - super.func_230337_a_(p_230337_1_, p_230337_2_); - this.field_214012_a = NonNullList.func_191197_a(this.func_70302_i_(), ItemStack.field_190927_a); - ItemStackHelper.func_191283_b(p_230337_2_, this.field_214012_a); -- this.field_214018_j = p_230337_2_.func_74765_d("BurnTime"); -- this.field_214020_l = p_230337_2_.func_74765_d("CookTime"); -- this.field_214021_m = p_230337_2_.func_74765_d("CookTimeTotal"); -+ this.field_214018_j = p_230337_2_.func_74762_e("BurnTime"); -+ this.field_214020_l = p_230337_2_.func_74762_e("CookTime"); -+ this.field_214021_m = p_230337_2_.func_74762_e("CookTimeTotal"); - this.field_214019_k = this.func_213997_a(this.field_214012_a.get(1)); - CompoundNBT compoundnbt = p_230337_2_.func_74775_l("RecipesUsed"); - -@@ -202,9 +_,9 @@ - - public CompoundNBT func_189515_b(CompoundNBT p_189515_1_) { - super.func_189515_b(p_189515_1_); -- p_189515_1_.func_74777_a("BurnTime", (short)this.field_214018_j); -- p_189515_1_.func_74777_a("CookTime", (short)this.field_214020_l); -- p_189515_1_.func_74777_a("CookTimeTotal", (short)this.field_214021_m); -+ p_189515_1_.func_74768_a("BurnTime", this.field_214018_j); -+ p_189515_1_.func_74768_a("CookTime", this.field_214020_l); -+ p_189515_1_.func_74768_a("CookTimeTotal", this.field_214021_m); - ItemStackHelper.func_191282_a(p_189515_1_, this.field_214012_a); - CompoundNBT compoundnbt = new CompoundNBT(); - this.field_214022_n.forEach((p_235643_1_, p_235643_2_) -> { -@@ -230,12 +_,14 @@ - this.field_214019_k = this.field_214018_j; - if (this.func_214006_r()) { - flag1 = true; -+ if (itemstack.hasContainerItem()) -+ this.field_214012_a.set(1, itemstack.getContainerItem()); -+ else - if (!itemstack.func_190926_b()) { - Item item = itemstack.func_77973_b(); - itemstack.func_190918_g(1); - if (itemstack.func_190926_b()) { -- Item item1 = item.func_77668_q(); -- this.field_214012_a.set(1, item1 == null ? ItemStack.field_190927_a : new ItemStack(item1)); -+ this.field_214012_a.set(1, itemstack.getContainerItem()); - } - } - } -@@ -270,7 +_,7 @@ - - protected boolean func_214008_b(@Nullable IRecipe p_214008_1_) { - if (!this.field_214012_a.get(0).func_190926_b() && p_214008_1_ != null) { -- ItemStack itemstack = p_214008_1_.func_77571_b(); -+ ItemStack itemstack = ((IRecipe) p_214008_1_).func_77572_b(this); - if (itemstack.func_190926_b()) { - return false; - } else { -@@ -279,10 +_,10 @@ - return true; - } else if (!itemstack1.func_77969_a(itemstack)) { - return false; -- } else if (itemstack1.func_190916_E() < this.func_70297_j_() && itemstack1.func_190916_E() < itemstack1.func_77976_d()) { -+ } else if (itemstack1.func_190916_E() + itemstack.func_190916_E() <= this.func_70297_j_() && itemstack1.func_190916_E() + itemstack.func_190916_E() <= itemstack1.func_77976_d()) { // Forge fix: make furnace respect stack sizes in furnace recipes - return true; - } else { -- return itemstack1.func_190916_E() < itemstack.func_77976_d(); -+ return itemstack1.func_190916_E() + itemstack.func_190916_E() <= itemstack.func_77976_d(); // Forge fix: make furnace respect stack sizes in furnace recipes - } - } - } else { -@@ -293,12 +_,12 @@ - private void func_214007_c(@Nullable IRecipe p_214007_1_) { - if (p_214007_1_ != null && this.func_214008_b(p_214007_1_)) { - ItemStack itemstack = this.field_214012_a.get(0); -- ItemStack itemstack1 = p_214007_1_.func_77571_b(); -+ ItemStack itemstack1 = ((IRecipe) p_214007_1_).func_77572_b(this); - ItemStack itemstack2 = this.field_214012_a.get(2); - if (itemstack2.func_190926_b()) { - this.field_214012_a.set(2, itemstack1.func_77946_l()); - } else if (itemstack2.func_77973_b() == itemstack1.func_77973_b()) { -- itemstack2.func_190917_f(1); -+ itemstack2.func_190917_f(itemstack1.func_190916_E()); - } - - if (!this.field_145850_b.field_72995_K) { -@@ -318,7 +_,7 @@ - return 0; - } else { - Item item = p_213997_1_.func_77973_b(); -- return func_214001_f().getOrDefault(item, 0); -+ return net.minecraftforge.common.ForgeHooks.getBurnTime(p_213997_1_, this.field_214014_c); - } - } - -@@ -327,7 +_,7 @@ - } - - public static boolean func_213991_b(ItemStack p_213991_0_) { -- return func_214001_f().containsKey(p_213991_0_.func_77973_b()); -+ return net.minecraftforge.common.ForgeHooks.getBurnTime(p_213991_0_, null) > 0; - } - - public int[] func_180463_a(Direction p_180463_1_) { -@@ -410,7 +_,7 @@ - return true; - } else { - ItemStack itemstack = this.field_214012_a.get(1); -- return func_213991_b(p_94041_2_) || p_94041_2_.func_77973_b() == Items.field_151133_ar && itemstack.func_77973_b() != Items.field_151133_ar; -+ return net.minecraftforge.common.ForgeHooks.getBurnTime(p_94041_2_, this.field_214014_c) > 0 || p_94041_2_.func_77973_b() == Items.field_151133_ar && itemstack.func_77973_b() != Items.field_151133_ar; - } - } - -@@ -473,5 +_,28 @@ - p_194018_1_.func_194112_a(itemstack); - } - -+ } -+ -+ net.minecraftforge.common.util.LazyOptional[] handlers = -+ net.minecraftforge.items.wrapper.SidedInvWrapper.create(this, Direction.UP, Direction.DOWN, Direction.NORTH); -+ -+ @Override -+ public net.minecraftforge.common.util.LazyOptional getCapability(net.minecraftforge.common.capabilities.Capability capability, @Nullable Direction facing) { -+ if (!this.field_145846_f && facing != null && capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { -+ if (facing == Direction.UP) -+ return handlers[0].cast(); -+ else if (facing == Direction.DOWN) -+ return handlers[1].cast(); -+ else -+ return handlers[2].cast(); -+ } -+ return super.getCapability(capability, facing); -+ } -+ -+ @Override -+ protected void invalidateCaps() { -+ super.invalidateCaps(); -+ for (int x = 0; x < handlers.length; x++) -+ handlers[x].invalidate(); - } - } diff --git a/patches/minecraft/net/minecraft/tileentity/BeaconTileEntity.java.patch b/patches/minecraft/net/minecraft/tileentity/BeaconTileEntity.java.patch deleted file mode 100644 index 1dbcbf7cd3..0000000000 --- a/patches/minecraft/net/minecraft/tileentity/BeaconTileEntity.java.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/net/minecraft/tileentity/BeaconTileEntity.java -+++ b/net/minecraft/tileentity/BeaconTileEntity.java -@@ -112,8 +_,8 @@ - for(int i1 = 0; i1 < 10 && blockpos.func_177956_o() <= l; ++i1) { - BlockState blockstate = this.field_145850_b.func_180495_p(blockpos); - Block block = blockstate.func_177230_c(); -- if (block instanceof IBeaconBeamColorProvider) { -- float[] afloat = ((IBeaconBeamColorProvider)block).func_196457_d().func_193349_f(); -+ float[] afloat = blockstate.getBeaconColorMultiplier(this.field_145850_b, blockpos, func_174877_v()); -+ if (afloat != null) { - if (this.field_213934_g.size() <= 1) { - beacontileentity$beamsegment = new BeaconTileEntity.BeamSegment(afloat); - this.field_213934_g.add(beacontileentity$beamsegment); diff --git a/patches/minecraft/net/minecraft/tileentity/BrewingStandTileEntity.java.patch b/patches/minecraft/net/minecraft/tileentity/BrewingStandTileEntity.java.patch deleted file mode 100644 index a505e7015d..0000000000 --- a/patches/minecraft/net/minecraft/tileentity/BrewingStandTileEntity.java.patch +++ /dev/null @@ -1,85 +0,0 @@ ---- a/net/minecraft/tileentity/BrewingStandTileEntity.java -+++ b/net/minecraft/tileentity/BrewingStandTileEntity.java -@@ -146,6 +_,7 @@ - - private boolean func_145934_k() { - ItemStack itemstack = this.field_145945_j.get(3); -+ if (!itemstack.func_190926_b()) return net.minecraftforge.common.brewing.BrewingRecipeRegistry.canBrew(field_145945_j, itemstack, field_145947_i); // divert to VanillaBrewingRegistry - if (itemstack.func_190926_b()) { - return false; - } else if (!PotionBrewing.func_185205_a(itemstack)) { -@@ -163,22 +_,22 @@ - } - - private void func_145940_l() { -+ if (net.minecraftforge.event.ForgeEventFactory.onPotionAttemptBrew(field_145945_j)) return; - ItemStack itemstack = this.field_145945_j.get(3); - -- for(int i = 0; i < 3; ++i) { -- this.field_145945_j.set(i, PotionBrewing.func_185212_d(itemstack, this.field_145945_j.get(i))); -- } -- -- itemstack.func_190918_g(1); -+ net.minecraftforge.common.brewing.BrewingRecipeRegistry.brewPotions(field_145945_j, itemstack, field_145947_i); -+ net.minecraftforge.event.ForgeEventFactory.onPotionBrewed(field_145945_j); - BlockPos blockpos = this.func_174877_v(); -- if (itemstack.func_77973_b().func_77634_r()) { -- ItemStack itemstack1 = new ItemStack(itemstack.func_77973_b().func_77668_q()); -+ if (itemstack.hasContainerItem()) { -+ ItemStack itemstack1 = itemstack.getContainerItem(); -+ itemstack.func_190918_g(1); - if (itemstack.func_190926_b()) { - itemstack = itemstack1; - } else if (!this.field_145850_b.field_72995_K) { - InventoryHelper.func_180173_a(this.field_145850_b, (double)blockpos.func_177958_n(), (double)blockpos.func_177956_o(), (double)blockpos.func_177952_p(), itemstack1); - } - } -+ else itemstack.func_190918_g(1); - - this.field_145945_j.set(3, itemstack); - this.field_145850_b.func_217379_c(1035, blockpos, 0); -@@ -229,13 +_,13 @@ - - public boolean func_94041_b(int p_94041_1_, ItemStack p_94041_2_) { - if (p_94041_1_ == 3) { -- return PotionBrewing.func_185205_a(p_94041_2_); -+ return net.minecraftforge.common.brewing.BrewingRecipeRegistry.isValidIngredient(p_94041_2_); - } else { - Item item = p_94041_2_.func_77973_b(); - if (p_94041_1_ == 4) { - return item == Items.field_151065_br; - } else { -- return (item == Items.field_151068_bn || item == Items.field_185155_bH || item == Items.field_185156_bI || item == Items.field_151069_bo) && this.func_70301_a(p_94041_1_).func_190926_b(); -+ return net.minecraftforge.common.brewing.BrewingRecipeRegistry.isValidInput(p_94041_2_) && this.func_70301_a(p_94041_1_).func_190926_b(); - } - } - } -@@ -266,5 +_,28 @@ - - protected Container func_213906_a(int p_213906_1_, PlayerInventory p_213906_2_) { - return new BrewingStandContainer(p_213906_1_, p_213906_2_, this, this.field_213954_a); -+ } -+ -+ net.minecraftforge.common.util.LazyOptional[] handlers = -+ net.minecraftforge.items.wrapper.SidedInvWrapper.create(this, Direction.UP, Direction.DOWN, Direction.NORTH); -+ -+ @Override -+ public net.minecraftforge.common.util.LazyOptional getCapability(net.minecraftforge.common.capabilities.Capability capability, @Nullable Direction facing) { -+ if (!this.field_145846_f && facing != null && capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { -+ if (facing == Direction.UP) -+ return handlers[0].cast(); -+ else if (facing == Direction.DOWN) -+ return handlers[1].cast(); -+ else -+ return handlers[2].cast(); -+ } -+ return super.getCapability(capability, facing); -+ } -+ -+ @Override -+ protected void invalidateCaps() { -+ super.invalidateCaps(); -+ for (int x = 0; x < handlers.length; x++) -+ handlers[x].invalidate(); - } - } diff --git a/patches/minecraft/net/minecraft/tileentity/ChestTileEntity.java.patch b/patches/minecraft/net/minecraft/tileentity/ChestTileEntity.java.patch deleted file mode 100644 index 686577087d..0000000000 --- a/patches/minecraft/net/minecraft/tileentity/ChestTileEntity.java.patch +++ /dev/null @@ -1,61 +0,0 @@ ---- a/net/minecraft/tileentity/ChestTileEntity.java -+++ b/net/minecraft/tileentity/ChestTileEntity.java -@@ -38,6 +_,7 @@ - protected float field_145986_n; - protected int field_145987_o; - private int field_145983_q; -+ private net.minecraftforge.common.util.LazyOptional chestHandler; - - protected ChestTileEntity(TileEntityType p_i48287_1_) { - super(p_i48287_1_); -@@ -202,7 +_,7 @@ - - public static int func_195481_a(IBlockReader p_195481_0_, BlockPos p_195481_1_) { - BlockState blockstate = p_195481_0_.func_180495_p(p_195481_1_); -- if (blockstate.func_177230_c().func_235695_q_()) { -+ if (blockstate.hasTileEntity()) { - TileEntity tileentity = p_195481_0_.func_175625_s(p_195481_1_); - if (tileentity instanceof ChestTileEntity) { - return ((ChestTileEntity)tileentity).field_145987_o; -@@ -220,5 +_,41 @@ - - protected Container func_213906_a(int p_213906_1_, PlayerInventory p_213906_2_) { - return ChestContainer.func_216992_a(p_213906_1_, p_213906_2_, this); -+ } -+ -+ @Override -+ public void func_145836_u() { -+ super.func_145836_u(); -+ if (this.chestHandler != null) { -+ net.minecraftforge.common.util.LazyOptional oldHandler = this.chestHandler; -+ this.chestHandler = null; -+ oldHandler.invalidate(); -+ } -+ } -+ -+ @Override -+ public net.minecraftforge.common.util.LazyOptional getCapability(net.minecraftforge.common.capabilities.Capability cap, Direction side) { -+ if (!this.field_145846_f && cap == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { -+ if (this.chestHandler == null) -+ this.chestHandler = net.minecraftforge.common.util.LazyOptional.of(this::createHandler); -+ return this.chestHandler.cast(); -+ } -+ return super.getCapability(cap, side); -+ } -+ -+ private net.minecraftforge.items.IItemHandlerModifiable createHandler() { -+ BlockState state = this.func_195044_w(); -+ if (!(state.func_177230_c() instanceof ChestBlock)) { -+ return new net.minecraftforge.items.wrapper.InvWrapper(this); -+ } -+ IInventory inv = ChestBlock.func_226916_a_((ChestBlock) state.func_177230_c(), state, func_145831_w(), func_174877_v(), true); -+ return new net.minecraftforge.items.wrapper.InvWrapper(inv == null ? this : inv); -+ } -+ -+ @Override -+ protected void invalidateCaps() { -+ super.invalidateCaps(); -+ if (chestHandler != null) -+ chestHandler.invalidate(); - } - } diff --git a/patches/minecraft/net/minecraft/tileentity/ConduitTileEntity.java.patch b/patches/minecraft/net/minecraft/tileentity/ConduitTileEntity.java.patch deleted file mode 100644 index d258070390..0000000000 --- a/patches/minecraft/net/minecraft/tileentity/ConduitTileEntity.java.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- a/net/minecraft/tileentity/ConduitTileEntity.java -+++ b/net/minecraft/tileentity/ConduitTileEntity.java -@@ -130,10 +_,8 @@ - BlockPos blockpos1 = this.field_174879_c.func_177982_a(j1, k1, l1); - BlockState blockstate = this.field_145850_b.func_180495_p(blockpos1); - -- for(Block block : field_205042_e) { -- if (blockstate.func_203425_a(block)) { -- this.field_205046_i.add(blockpos1); -- } -+ if (blockstate.isConduitFrame(this.field_145850_b, blockpos1, func_174877_v())) { -+ this.field_205046_i.add(blockpos1); - } - } - } diff --git a/patches/minecraft/net/minecraft/tileentity/HopperTileEntity.java.patch b/patches/minecraft/net/minecraft/tileentity/HopperTileEntity.java.patch deleted file mode 100644 index 928c3ce512..0000000000 --- a/patches/minecraft/net/minecraft/tileentity/HopperTileEntity.java.patch +++ /dev/null @@ -1,43 +0,0 @@ ---- a/net/minecraft/tileentity/HopperTileEntity.java -+++ b/net/minecraft/tileentity/HopperTileEntity.java -@@ -133,6 +_,7 @@ - } - - private boolean func_145883_k() { -+ if (net.minecraftforge.items.VanillaInventoryCodeHooks.insertHook(this)) return true; - IInventory iinventory = this.func_145895_l(); - if (iinventory == null) { - return false; -@@ -177,6 +_,8 @@ - } - - public static boolean func_145891_a(IHopper p_145891_0_) { -+ Boolean ret = net.minecraftforge.items.VanillaInventoryCodeHooks.extractHook(p_145891_0_); -+ if (ret != null) return ret; - IInventory iinventory = func_145884_b(p_145891_0_); - if (iinventory != null) { - Direction direction = Direction.DOWN; -@@ -325,7 +_,7 @@ - Block block = blockstate.func_177230_c(); - if (block instanceof ISidedInventoryProvider) { - iinventory = ((ISidedInventoryProvider)block).func_219966_a(blockstate, p_145893_0_, blockpos); -- } else if (block.func_235695_q_()) { -+ } else if (blockstate.hasTileEntity()) { - TileEntity tileentity = p_145893_0_.func_175625_s(blockpos); - if (tileentity instanceof IInventory) { - iinventory = (IInventory)tileentity; -@@ -403,5 +_,14 @@ - - protected Container func_213906_a(int p_213906_1_, PlayerInventory p_213906_2_) { - return new HopperContainer(p_213906_1_, p_213906_2_, this); -+ } -+ -+ @Override -+ protected net.minecraftforge.items.IItemHandler createUnSidedHandler() { -+ return new net.minecraftforge.items.VanillaHopperItemHandler(this); -+ } -+ -+ public long getLastUpdateTime() { -+ return this.field_190578_g; - } - } diff --git a/patches/minecraft/net/minecraft/tileentity/PistonTileEntity.java.patch b/patches/minecraft/net/minecraft/tileentity/PistonTileEntity.java.patch deleted file mode 100644 index 76703fe7a8..0000000000 --- a/patches/minecraft/net/minecraft/tileentity/PistonTileEntity.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/tileentity/PistonTileEntity.java -+++ b/net/minecraft/tileentity/PistonTileEntity.java -@@ -108,7 +_,7 @@ - List list = this.field_145850_b.func_72839_b((Entity)null, AabbHelper.func_227019_a_(axisalignedbb, direction, d0).func_111270_a(axisalignedbb)); - if (!list.isEmpty()) { - List list1 = voxelshape.func_197756_d(); -- boolean flag = this.field_200231_a.func_203425_a(Blocks.field_180399_cE); -+ boolean flag = this.field_200231_a.isSlimeBlock(); //TODO: is this patch really needed the logic of the original seems sound revisit later - Iterator iterator = list.iterator(); - - while(true) { diff --git a/patches/minecraft/net/minecraft/tileentity/TileEntity.java.patch b/patches/minecraft/net/minecraft/tileentity/TileEntity.java.patch deleted file mode 100644 index 1bb3e1a096..0000000000 --- a/patches/minecraft/net/minecraft/tileentity/TileEntity.java.patch +++ /dev/null @@ -1,79 +0,0 @@ ---- a/net/minecraft/tileentity/TileEntity.java -+++ b/net/minecraft/tileentity/TileEntity.java -@@ -16,7 +_,7 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; - --public abstract class TileEntity { -+public abstract class TileEntity extends net.minecraftforge.common.capabilities.CapabilityProvider implements net.minecraftforge.common.extensions.IForgeTileEntity { - private static final Logger field_145852_a = LogManager.getLogger(); - private final TileEntityType field_200663_e; - @Nullable -@@ -26,9 +_,12 @@ - @Nullable - private BlockState field_195045_e; - private boolean field_222816_g; -+ private CompoundNBT customTileData; - - public TileEntity(TileEntityType p_i48289_1_) { -+ super(TileEntity.class); - this.field_200663_e = p_i48289_1_; -+ this.gatherCapabilities(); - } - - @Nullable -@@ -47,6 +_,8 @@ - - public void func_230337_a_(BlockState p_230337_1_, CompoundNBT p_230337_2_) { - this.field_174879_c = new BlockPos(p_230337_2_.func_74762_e("x"), p_230337_2_.func_74762_e("y"), p_230337_2_.func_74762_e("z")); -+ if (p_230337_2_.func_74764_b("ForgeData")) this.customTileData = p_230337_2_.func_74775_l("ForgeData"); -+ if (getCapabilities() != null && p_230337_2_.func_74764_b("ForgeCaps")) deserializeCaps(p_230337_2_.func_74775_l("ForgeCaps")); - } - - public CompoundNBT func_189515_b(CompoundNBT p_189515_1_) { -@@ -62,6 +_,8 @@ - p_189516_1_.func_74768_a("x", this.field_174879_c.func_177958_n()); - p_189516_1_.func_74768_a("y", this.field_174879_c.func_177956_o()); - p_189516_1_.func_74768_a("z", this.field_174879_c.func_177952_p()); -+ if (this.customTileData != null) p_189516_1_.func_218657_a("ForgeData", this.customTileData); -+ if (getCapabilities() != null) p_189516_1_.func_218657_a("ForgeCaps", serializeCaps()); - return p_189516_1_; - } - } -@@ -94,7 +_,7 @@ - if (this.field_145850_b != null) { - this.field_195045_e = this.field_145850_b.func_180495_p(this.field_174879_c); - this.field_145850_b.func_175646_b(this.field_174879_c, this); -- if (!this.field_195045_e.func_196958_f()) { -+ if (!this.field_195045_e.isAir(this.field_145850_b, this.field_174879_c)) { - this.field_145850_b.func_175666_e(this.field_174879_c, this.field_195045_e.func_177230_c()); - } - } -@@ -133,6 +_,13 @@ - - public void func_145843_s() { - this.field_145846_f = true; -+ this.invalidateCaps(); -+ requestModelDataUpdate(); -+ } -+ -+ @Override -+ public void onChunkUnloaded() { -+ this.invalidateCaps(); - } - - public void func_145829_t() { -@@ -173,6 +_,13 @@ - - public TileEntityType func_200662_C() { - return this.field_200663_e; -+ } -+ -+ @Override -+ public CompoundNBT getTileData() { -+ if (this.customTileData == null) -+ this.customTileData = new CompoundNBT(); -+ return this.customTileData; - } - - public void func_222814_r() { diff --git a/patches/minecraft/net/minecraft/tileentity/TileEntityType.java.patch b/patches/minecraft/net/minecraft/tileentity/TileEntityType.java.patch deleted file mode 100644 index 2c2d7f6ce2..0000000000 --- a/patches/minecraft/net/minecraft/tileentity/TileEntityType.java.patch +++ /dev/null @@ -1,34 +0,0 @@ ---- a/net/minecraft/tileentity/TileEntityType.java -+++ b/net/minecraft/tileentity/TileEntityType.java -@@ -16,7 +_,7 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; - --public class TileEntityType { -+public class TileEntityType extends net.minecraftforge.registries.ForgeRegistryEntry> { - private static final Logger field_206866_A = LogManager.getLogger(); - public static final TileEntityType field_200971_b = func_200966_a("furnace", TileEntityType.Builder.func_223042_a(FurnaceTileEntity::new, Blocks.field_150460_al)); - public static final TileEntityType field_200972_c = func_200966_a("chest", TileEntityType.Builder.func_223042_a(ChestTileEntity::new, Blocks.field_150486_ae)); -@@ -54,6 +_,7 @@ - private final Supplier field_200995_z; - private final Set field_223046_I; - private final Type field_206867_C; -+ private final net.minecraftforge.common.util.ReverseTagWrapper> reverseTags = new net.minecraftforge.common.util.ReverseTagWrapper<>(this, () -> net.minecraft.tags.TagCollectionManager.func_242178_a().getCustomTypeCollection(net.minecraftforge.registries.ForgeRegistries.TILE_ENTITIES)); - - @Nullable - public static ResourceLocation func_200969_a(TileEntityType p_200969_0_) { -@@ -73,6 +_,14 @@ - this.field_200995_z = p_i51497_1_; - this.field_223046_I = p_i51497_2_; - this.field_206867_C = p_i51497_3_; -+ } -+ -+ public java.util.Set getTags() { -+ return reverseTags.getTagNames(); -+ } -+ -+ public boolean isIn(net.minecraft.tags.ITag> tag) { -+ return tag.func_230235_a_(this); - } - - @Nullable diff --git a/patches/minecraft/net/minecraft/util/RegistryKey.java.patch b/patches/minecraft/net/minecraft/util/RegistryKey.java.patch deleted file mode 100644 index 7031e32b7c..0000000000 --- a/patches/minecraft/net/minecraft/util/RegistryKey.java.patch +++ /dev/null @@ -1,28 +0,0 @@ ---- a/net/minecraft/util/RegistryKey.java -+++ b/net/minecraft/util/RegistryKey.java -@@ -6,7 +_,7 @@ - import java.util.function.Function; - import net.minecraft.util.registry.Registry; - --public class RegistryKey { -+public class RegistryKey implements Comparable> { - private static final Map> field_240898_a_ = Collections.synchronizedMap(Maps.newIdentityHashMap()); - private final ResourceLocation field_240899_b_; - private final ResourceLocation field_240900_c_; -@@ -47,5 +_,16 @@ - return (p_240907_1_) -> { - return func_240903_a_(p_240902_0_, p_240907_1_); - }; -+ } -+ -+ public ResourceLocation getRegistryName() { -+ return this.field_240899_b_; -+ } -+ -+ @Override -+ public int compareTo(RegistryKey o) { -+ int ret = this.getRegistryName().compareTo(o.getRegistryName()); -+ if (ret == 0) ret = this.func_240901_a_().compareTo(o.func_240901_a_()); -+ return ret; - } - } diff --git a/patches/minecraft/net/minecraft/util/ResourceLocation.java.patch b/patches/minecraft/net/minecraft/util/ResourceLocation.java.patch deleted file mode 100644 index 28d4109f10..0000000000 --- a/patches/minecraft/net/minecraft/util/ResourceLocation.java.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- a/net/minecraft/util/ResourceLocation.java -+++ b/net/minecraft/util/ResourceLocation.java -@@ -112,6 +_,12 @@ - return i; - } - -+ // Normal compare sorts by path first, this compares namespace first. -+ public int compareNamespaced(ResourceLocation o) { -+ int ret = this.field_110626_a.compareTo(o.field_110626_a); -+ return ret != 0 ? ret : this.field_110625_b.compareTo(o.field_110625_b); -+ } -+ - public static ResourceLocation func_195826_a(StringReader p_195826_0_) throws CommandSyntaxException { - int i = p_195826_0_.getCursor(); - diff --git a/patches/minecraft/net/minecraft/util/ScreenShotHelper.java.patch b/patches/minecraft/net/minecraft/util/ScreenShotHelper.java.patch deleted file mode 100644 index 98e7d10cf6..0000000000 --- a/patches/minecraft/net/minecraft/util/ScreenShotHelper.java.patch +++ /dev/null @@ -1,29 +0,0 @@ ---- a/net/minecraft/util/ScreenShotHelper.java -+++ b/net/minecraft/util/ScreenShotHelper.java -@@ -50,13 +_,23 @@ - file2 = new File(file1, p_228051_1_); - } - -+ net.minecraftforge.client.event.ScreenshotEvent event = net.minecraftforge.client.ForgeHooksClient.onScreenshot(nativeimage, file2); -+ if (event.isCanceled()) { -+ p_228051_5_.accept(event.getCancelMessage()); -+ return; -+ } -+ final File target = event.getScreenshotFile(); -+ - Util.func_240992_g_().execute(() -> { - try { -- nativeimage.func_209271_a(file2); -+ nativeimage.func_209271_a(target); - ITextComponent itextcomponent = (new StringTextComponent(file2.getName())).func_240699_a_(TextFormatting.UNDERLINE).func_240700_a_((p_238335_1_) -> { -- return p_238335_1_.func_240715_a_(new ClickEvent(ClickEvent.Action.OPEN_FILE, file2.getAbsolutePath())); -+ return p_238335_1_.func_240715_a_(new ClickEvent(ClickEvent.Action.OPEN_FILE, target.getAbsolutePath())); - }); -- p_228051_5_.accept(new TranslationTextComponent("screenshot.success", itextcomponent)); -+ if (event.getResultMessage() != null) -+ p_228051_5_.accept(event.getResultMessage()); -+ else -+ p_228051_5_.accept(new TranslationTextComponent("screenshot.success", itextcomponent)); - } catch (Exception exception) { - field_148261_a.warn("Couldn't save screenshot", (Throwable)exception); - p_228051_5_.accept(new TranslationTextComponent("screenshot.failure", exception.getMessage())); diff --git a/patches/minecraft/net/minecraft/util/Session.java.patch b/patches/minecraft/net/minecraft/util/Session.java.patch deleted file mode 100644 index b9750f9680..0000000000 --- a/patches/minecraft/net/minecraft/util/Session.java.patch +++ /dev/null @@ -1,49 +0,0 @@ ---- a/net/minecraft/util/Session.java -+++ b/net/minecraft/util/Session.java -@@ -18,8 +_,22 @@ - private final String field_148257_b; - private final String field_148258_c; - private final Session.Type field_152429_d; -+ /** Forge: Cache of the local session's GameProfile properties. */ -+ private com.mojang.authlib.properties.PropertyMap properties; - - public Session(String p_i1098_1_, String p_i1098_2_, String p_i1098_3_, String p_i1098_4_) { -+ if (p_i1098_1_ == null || p_i1098_1_.isEmpty()) { -+ p_i1098_1_ = "MissingName"; -+ p_i1098_2_ = p_i1098_3_ = "NotValid"; -+ org.apache.logging.log4j.Logger logger = org.apache.logging.log4j.LogManager.getLogger(getClass().getName()); -+ logger.log(org.apache.logging.log4j.Level.WARN, "========================================================="); -+ logger.log(org.apache.logging.log4j.Level.WARN, "WARNING!! the username was not set for this session, typically"); -+ logger.log(org.apache.logging.log4j.Level.WARN, "this means you installed Forge incorrectly. We have set your"); -+ logger.log(org.apache.logging.log4j.Level.WARN, "name to \"MissingName\" and your session to nothing. Please"); -+ logger.log(org.apache.logging.log4j.Level.WARN, "check your installation and post a console log from the launcher"); -+ logger.log(org.apache.logging.log4j.Level.WARN, "when asking for help!"); -+ logger.log(org.apache.logging.log4j.Level.WARN, "========================================================="); -+ } - this.field_74286_b = p_i1098_1_; - this.field_148257_b = p_i1098_2_; - this.field_148258_c = p_i1098_3_; -@@ -45,10 +_,22 @@ - public GameProfile func_148256_e() { - try { - UUID uuid = UUIDTypeAdapter.fromString(this.func_148255_b()); -- return new GameProfile(uuid, this.func_111285_a()); -+ GameProfile ret = new GameProfile(uuid, this.func_111285_a()); //Forge: Adds cached GameProfile properties to returned GameProfile. -+ if (properties != null) ret.getProperties().putAll(properties); // Helps to cut down on calls to the session service, -+ return ret; // which helps to fix MC-52974. - } catch (IllegalArgumentException illegalargumentexception) { - return new GameProfile((UUID)null, this.func_111285_a()); - } -+ } -+ -+ //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; - } - - @OnlyIn(Dist.CLIENT) diff --git a/patches/minecraft/net/minecraft/util/SharedConstants.java.patch b/patches/minecraft/net/minecraft/util/SharedConstants.java.patch deleted file mode 100644 index 6d0af6230d..0000000000 --- a/patches/minecraft/net/minecraft/util/SharedConstants.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/util/SharedConstants.java -+++ b/net/minecraft/util/SharedConstants.java -@@ -44,6 +_,7 @@ - } - - static { -+ if (System.getProperty("io.netty.leakDetection.level") == null) // Forge: allow level to be manually specified - ResourceLeakDetector.setLevel(field_184877_a); - CommandSyntaxException.ENABLE_COMMAND_STACK_TRACES = false; - CommandSyntaxException.BUILT_IN_EXCEPTIONS = new TranslatableExceptionProvider(); diff --git a/patches/minecraft/net/minecraft/util/SoundEvent.java.patch b/patches/minecraft/net/minecraft/util/SoundEvent.java.patch deleted file mode 100644 index 9329017a3c..0000000000 --- a/patches/minecraft/net/minecraft/util/SoundEvent.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/util/SoundEvent.java -+++ b/net/minecraft/util/SoundEvent.java -@@ -4,7 +_,7 @@ - import net.minecraftforge.api.distmarker.Dist; - import net.minecraftforge.api.distmarker.OnlyIn; - --public class SoundEvent { -+public class SoundEvent extends net.minecraftforge.registries.ForgeRegistryEntry { - public static final Codec field_232678_a_ = ResourceLocation.field_240908_a_.xmap(SoundEvent::new, (p_232679_0_) -> { - return p_232679_0_.field_187506_b; - }); diff --git a/patches/minecraft/net/minecraft/util/SoundEvents.java.patch b/patches/minecraft/net/minecraft/util/SoundEvents.java.patch deleted file mode 100644 index 3502002388..0000000000 --- a/patches/minecraft/net/minecraft/util/SoundEvents.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/util/SoundEvents.java -+++ b/net/minecraft/util/SoundEvents.java -@@ -2,6 +_,7 @@ - - import net.minecraft.util.registry.Registry; - -+@net.minecraftforge.registries.ObjectHolder("minecraft") - public class SoundEvents { - public static final SoundEvent field_187674_a = func_219592_a("ambient.cave"); - public static final SoundEvent field_232692_b_ = func_219592_a("ambient.basalt_deltas.additions"); diff --git a/patches/minecraft/net/minecraft/util/Util.java.patch b/patches/minecraft/net/minecraft/util/Util.java.patch deleted file mode 100644 index ed30fc929a..0000000000 --- a/patches/minecraft/net/minecraft/util/Util.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/util/Util.java -+++ b/net/minecraft/util/Util.java -@@ -200,7 +_,7 @@ - try { - type = DataFixesManager.func_210901_a().getSchema(DataFixUtils.makeKey(SharedConstants.func_215069_a().getWorldVersion())).getChoiceType(p_240990_0_, p_240990_1_); - } catch (IllegalArgumentException illegalargumentexception) { -- field_195650_a.error("No data fixer registered for {}", (Object)p_240990_1_); -+ field_195650_a.debug("No data fixer registered for {}", (Object)p_240990_1_); - if (SharedConstants.field_206244_b) { - throw illegalargumentexception; - } diff --git a/patches/minecraft/net/minecraft/util/datafix/codec/DatapackCodec.java.patch b/patches/minecraft/net/minecraft/util/datafix/codec/DatapackCodec.java.patch deleted file mode 100644 index d327ab3a34..0000000000 --- a/patches/minecraft/net/minecraft/util/datafix/codec/DatapackCodec.java.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- a/net/minecraft/util/datafix/codec/DatapackCodec.java -+++ b/net/minecraft/util/datafix/codec/DatapackCodec.java -@@ -18,7 +_,7 @@ - private final List field_234883_d_; - - public DatapackCodec(List p_i231607_1_, List p_i231607_2_) { -- this.field_234882_c_ = ImmutableList.copyOf(p_i231607_1_); -+ this.field_234882_c_ = com.google.common.collect.Lists.newArrayList(p_i231607_1_); - this.field_234883_d_ = ImmutableList.copyOf(p_i231607_2_); - } - -@@ -28,5 +_,9 @@ - - public List func_234887_b_() { - return this.field_234883_d_; -+ } -+ -+ public void addModPacks(List modPacks) { -+ field_234882_c_.addAll(modPacks.stream().filter(p->!field_234882_c_.contains(p)).collect(java.util.stream.Collectors.toList())); - } - } diff --git a/patches/minecraft/net/minecraft/util/math/RayTraceContext.java.patch b/patches/minecraft/net/minecraft/util/math/RayTraceContext.java.patch deleted file mode 100644 index 89b11e5f5c..0000000000 --- a/patches/minecraft/net/minecraft/util/math/RayTraceContext.java.patch +++ /dev/null @@ -1,17 +0,0 @@ ---- a/net/minecraft/util/math/RayTraceContext.java -+++ b/net/minecraft/util/math/RayTraceContext.java -@@ -18,12 +_,12 @@ - private final RayTraceContext.FluidMode field_222257_d; - private final ISelectionContext field_222258_e; - -- public RayTraceContext(Vector3d p_i50009_1_, Vector3d p_i50009_2_, RayTraceContext.BlockMode p_i50009_3_, RayTraceContext.FluidMode p_i50009_4_, Entity p_i50009_5_) { -+ public RayTraceContext(Vector3d p_i50009_1_, Vector3d p_i50009_2_, RayTraceContext.BlockMode p_i50009_3_, RayTraceContext.FluidMode p_i50009_4_, @javax.annotation.Nullable Entity p_i50009_5_) { - this.field_222254_a = p_i50009_1_; - this.field_222255_b = p_i50009_2_; - this.field_222256_c = p_i50009_3_; - this.field_222257_d = p_i50009_4_; -- this.field_222258_e = ISelectionContext.func_216374_a(p_i50009_5_); -+ this.field_222258_e = p_i50009_5_ == null ? ISelectionContext.func_216377_a() : ISelectionContext.func_216374_a(p_i50009_5_); - } - - public Vector3d func_222250_a() { diff --git a/patches/minecraft/net/minecraft/util/math/RayTraceResult.java.patch b/patches/minecraft/net/minecraft/util/math/RayTraceResult.java.patch deleted file mode 100644 index c9240b0c14..0000000000 --- a/patches/minecraft/net/minecraft/util/math/RayTraceResult.java.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/net/minecraft/util/math/RayTraceResult.java -+++ b/net/minecraft/util/math/RayTraceResult.java -@@ -5,6 +_,11 @@ - - public abstract class RayTraceResult { - protected final Vector3d field_72307_f; -+ /** Used to determine what sub-segment is hit */ -+ public int subHit = -1; -+ -+ /** Used to add extra hit info */ -+ public Object hitInfo = null; - - protected RayTraceResult(Vector3d p_i51183_1_) { - this.field_72307_f = p_i51183_1_; diff --git a/patches/minecraft/net/minecraft/util/math/shapes/EntitySelectionContext.java.patch b/patches/minecraft/net/minecraft/util/math/shapes/EntitySelectionContext.java.patch deleted file mode 100644 index 793c7503a5..0000000000 --- a/patches/minecraft/net/minecraft/util/math/shapes/EntitySelectionContext.java.patch +++ /dev/null @@ -1,36 +0,0 @@ ---- a/net/minecraft/util/math/shapes/EntitySelectionContext.java -+++ b/net/minecraft/util/math/shapes/EntitySelectionContext.java -@@ -25,6 +_,11 @@ - private final Predicate field_237493_e_; - - protected EntitySelectionContext(boolean p_i232177_1_, double p_i232177_2_, Item p_i232177_4_, Predicate p_i232177_5_) { -+ this(null, p_i232177_1_, p_i232177_2_, p_i232177_4_, p_i232177_5_); -+ } -+ -+ protected EntitySelectionContext(@javax.annotation.Nullable Entity entity, boolean p_i232177_1_, double p_i232177_2_, Item p_i232177_4_, Predicate p_i232177_5_) { -+ this.entity = entity; - this.field_227579_b_ = p_i232177_1_; - this.field_216381_c = p_i232177_2_; - this.field_216382_d = p_i232177_4_; -@@ -33,7 +_,7 @@ - - @Deprecated - protected EntitySelectionContext(Entity p_i51182_1_) { -- this(p_i51182_1_.func_226274_bn_(), p_i51182_1_.func_226278_cu_(), p_i51182_1_ instanceof LivingEntity ? ((LivingEntity)p_i51182_1_).func_184614_ca().func_77973_b() : Items.field_190931_a, p_i51182_1_ instanceof LivingEntity ? ((LivingEntity)p_i51182_1_)::func_230285_a_ : (p_237494_0_) -> { -+ this(p_i51182_1_, p_i51182_1_.func_226274_bn_(), p_i51182_1_.func_226278_cu_(), p_i51182_1_ instanceof LivingEntity ? ((LivingEntity)p_i51182_1_).func_184614_ca().func_77973_b() : Items.field_190931_a, p_i51182_1_ instanceof LivingEntity ? ((LivingEntity)p_i51182_1_)::func_230285_a_ : (p_237494_0_) -> { - return false; - }); - } -@@ -52,5 +_,12 @@ - - public boolean func_216378_a(VoxelShape p_216378_1_, BlockPos p_216378_2_, boolean p_216378_3_) { - return this.field_216381_c > (double)p_216378_2_.func_177956_o() + p_216378_1_.func_197758_c(Direction.Axis.Y) - (double)1.0E-5F; -+ } -+ -+ private final @javax.annotation.Nullable Entity entity; -+ -+ @Override -+ public @javax.annotation.Nullable Entity getEntity() { -+ return entity; - } - } diff --git a/patches/minecraft/net/minecraft/util/math/shapes/ISelectionContext.java.patch b/patches/minecraft/net/minecraft/util/math/shapes/ISelectionContext.java.patch deleted file mode 100644 index c3da893a8f..0000000000 --- a/patches/minecraft/net/minecraft/util/math/shapes/ISelectionContext.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/util/math/shapes/ISelectionContext.java -+++ b/net/minecraft/util/math/shapes/ISelectionContext.java -@@ -6,7 +_,7 @@ - import net.minecraft.item.Item; - import net.minecraft.util.math.BlockPos; - --public interface ISelectionContext { -+public interface ISelectionContext extends net.minecraftforge.common.extensions.IForgeSelectionContext { - static ISelectionContext func_216377_a() { - return EntitySelectionContext.field_216379_a; - } diff --git a/patches/minecraft/net/minecraft/util/math/vector/Matrix3f.java.patch b/patches/minecraft/net/minecraft/util/math/vector/Matrix3f.java.patch deleted file mode 100644 index 794025eb0d..0000000000 --- a/patches/minecraft/net/minecraft/util/math/vector/Matrix3f.java.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/net/minecraft/util/math/vector/Matrix3f.java -+++ b/net/minecraft/util/math/vector/Matrix3f.java -@@ -444,4 +_,11 @@ - public Matrix3f func_226121_d_() { - return new Matrix3f(this); - } -+ -+ // Forge start -+ public void multiplyBackward(Matrix3f other) { -+ Matrix3f copy = other.func_226121_d_(); -+ copy.func_226118_b_(this); -+ this.func_226114_a_(copy); -+ } - } diff --git a/patches/minecraft/net/minecraft/util/math/vector/Matrix4f.java.patch b/patches/minecraft/net/minecraft/util/math/vector/Matrix4f.java.patch deleted file mode 100644 index 1d9e1c697a..0000000000 --- a/patches/minecraft/net/minecraft/util/math/vector/Matrix4f.java.patch +++ /dev/null @@ -1,81 +0,0 @@ ---- a/net/minecraft/util/math/vector/Matrix4f.java -+++ b/net/minecraft/util/math/vector/Matrix4f.java -@@ -386,4 +_,78 @@ - matrix4f.field_226586_l_ = p_226599_2_; - return matrix4f; - } -+ -+ // Forge start -+ public Matrix4f(float[] values) { -+ field_226575_a_ = values[0]; -+ field_226576_b_ = values[1]; -+ field_226577_c_ = values[2]; -+ field_226578_d_ = values[3]; -+ field_226579_e_ = values[4]; -+ field_226580_f_ = values[5]; -+ field_226581_g_ = values[6]; -+ field_226582_h_ = values[7]; -+ field_226583_i_ = values[8]; -+ field_226584_j_ = values[9]; -+ field_226585_k_ = values[10]; -+ field_226586_l_ = values[11]; -+ field_226587_m_ = values[12]; -+ field_226588_n_ = values[13]; -+ field_226589_o_ = values[14]; -+ field_226590_p_ = values[15]; -+ } -+ -+ public void set(Matrix4f mat) { -+ this.field_226575_a_ = mat.field_226575_a_; -+ this.field_226576_b_ = mat.field_226576_b_; -+ this.field_226577_c_ = mat.field_226577_c_; -+ this.field_226578_d_ = mat.field_226578_d_; -+ this.field_226579_e_ = mat.field_226579_e_; -+ this.field_226580_f_ = mat.field_226580_f_; -+ this.field_226581_g_ = mat.field_226581_g_; -+ this.field_226582_h_ = mat.field_226582_h_; -+ this.field_226583_i_ = mat.field_226583_i_; -+ this.field_226584_j_ = mat.field_226584_j_; -+ this.field_226585_k_ = mat.field_226585_k_; -+ this.field_226586_l_ = mat.field_226586_l_; -+ this.field_226587_m_ = mat.field_226587_m_; -+ this.field_226588_n_ = mat.field_226588_n_; -+ this.field_226589_o_ = mat.field_226589_o_; -+ this.field_226590_p_ = mat.field_226590_p_; -+ } -+ -+ public void add(Matrix4f other) { -+ field_226575_a_ += other.field_226575_a_; -+ field_226576_b_ += other.field_226576_b_; -+ field_226577_c_ += other.field_226577_c_; -+ field_226578_d_ += other.field_226578_d_; -+ field_226579_e_ += other.field_226579_e_; -+ field_226580_f_ += other.field_226580_f_; -+ field_226581_g_ += other.field_226581_g_; -+ field_226582_h_ += other.field_226582_h_; -+ field_226583_i_ += other.field_226583_i_; -+ field_226584_j_ += other.field_226584_j_; -+ field_226585_k_ += other.field_226585_k_; -+ field_226586_l_ += other.field_226586_l_; -+ field_226587_m_ += other.field_226587_m_; -+ field_226588_n_ += other.field_226588_n_; -+ field_226589_o_ += other.field_226589_o_; -+ field_226590_p_ += other.field_226590_p_; -+ } -+ -+ public void multiplyBackward(Matrix4f other) { -+ Matrix4f copy = other.func_226601_d_(); -+ copy.func_226595_a_(this); -+ this.set(copy); -+ } -+ -+ public void setTranslation(float x, float y, float z) { -+ this.field_226575_a_ = 1.0F; -+ this.field_226580_f_ = 1.0F; -+ this.field_226585_k_ = 1.0F; -+ this.field_226590_p_ = 1.0F; -+ this.field_226578_d_ = x; -+ this.field_226582_h_ = y; -+ this.field_226586_l_ = z; -+ } - } diff --git a/patches/minecraft/net/minecraft/util/math/vector/TransformationMatrix.java.patch b/patches/minecraft/net/minecraft/util/math/vector/TransformationMatrix.java.patch deleted file mode 100644 index 68dc6a560e..0000000000 --- a/patches/minecraft/net/minecraft/util/math/vector/TransformationMatrix.java.patch +++ /dev/null @@ -1,61 +0,0 @@ ---- a/net/minecraft/util/math/vector/TransformationMatrix.java -+++ b/net/minecraft/util/math/vector/TransformationMatrix.java -@@ -9,7 +_,7 @@ - import org.apache.commons.lang3.tuple.Triple; - - @OnlyIn(Dist.CLIENT) --public final class TransformationMatrix { -+public final class TransformationMatrix implements net.minecraftforge.client.extensions.IForgeTransformationMatrix { - private final Matrix4f field_227976_a_; - private boolean field_227977_b_; - @Nullable -@@ -50,14 +_,14 @@ - return field_227982_g_; - } - -- public TransformationMatrix func_227985_a_(TransformationMatrix p_227985_1_) { -+ public TransformationMatrix compose(TransformationMatrix p_227985_1_) { - Matrix4f matrix4f = this.func_227988_c_(); - matrix4f.func_226595_a_(p_227985_1_.func_227988_c_()); - return new TransformationMatrix(matrix4f); - } - - @Nullable -- public TransformationMatrix func_227987_b_() { -+ public TransformationMatrix inverse() { - if (this == field_227982_g_) { - return this; - } else { -@@ -133,4 +_,32 @@ - public int hashCode() { - return Objects.hash(this.field_227976_a_); - } -+ -+ // FORGE START -+ public Vector3f getTranslation() { -+ func_227990_e_(); -+ return field_227978_c_.func_229195_e_(); -+ } -+ public Vector3f getScale() { -+ func_227990_e_(); -+ return field_227980_e_.func_229195_e_(); -+ } -+ -+ public Quaternion getRightRot() { -+ func_227990_e_(); -+ return field_227981_f_.func_227068_g_(); -+ } -+ -+ private Matrix3f normalTransform = null; -+ public Matrix3f getNormalMatrix() { -+ checkNormalTransform(); -+ return normalTransform; -+ } -+ private void checkNormalTransform() { -+ if (normalTransform == null) { -+ normalTransform = new Matrix3f(field_227976_a_); -+ normalTransform.func_226123_f_(); -+ normalTransform.func_226110_a_(); -+ } -+ } - } diff --git a/patches/minecraft/net/minecraft/util/math/vector/Vector3f.java.patch b/patches/minecraft/net/minecraft/util/math/vector/Vector3f.java.patch deleted file mode 100644 index 8978d47a1a..0000000000 --- a/patches/minecraft/net/minecraft/util/math/vector/Vector3f.java.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/util/math/vector/Vector3f.java -+++ b/net/minecraft/util/math/vector/Vector3f.java -@@ -196,4 +_,17 @@ - public String toString() { - return "[" + this.field_229184_g_ + ", " + this.field_229185_h_ + ", " + this.field_229186_i_ + "]"; - } -+ -+ // Forge start -+ public Vector3f(float[] values) { -+ set(values); -+ } -+ public void set(float[] values) { -+ this.field_229184_g_ = values[0]; -+ this.field_229185_h_ = values[1]; -+ this.field_229186_i_ = values[2]; -+ } -+ public void setX(float x) { this.field_229184_g_ = x; } -+ public void setY(float y) { this.field_229185_h_ = y; } -+ public void setZ(float z) { this.field_229186_i_ = z; } - } diff --git a/patches/minecraft/net/minecraft/util/math/vector/Vector4f.java.patch b/patches/minecraft/net/minecraft/util/math/vector/Vector4f.java.patch deleted file mode 100644 index d2880d9846..0000000000 --- a/patches/minecraft/net/minecraft/util/math/vector/Vector4f.java.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- a/net/minecraft/util/math/vector/Vector4f.java -+++ b/net/minecraft/util/math/vector/Vector4f.java -@@ -125,4 +_,16 @@ - public String toString() { - return "[" + this.field_229368_a_ + ", " + this.field_229369_b_ + ", " + this.field_229370_c_ + ", " + this.field_229371_d_ + "]"; - } -+ -+ // Forge start -+ public void set(float[] values) { -+ this.field_229368_a_ = values[0]; -+ this.field_229369_b_ = values[1]; -+ this.field_229370_c_ = values[2]; -+ this.field_229371_d_ = values[3]; -+ } -+ public void setX(float x) { this.field_229368_a_ = x; } -+ public void setY(float y) { this.field_229369_b_ = y; } -+ public void setZ(float z) { this.field_229370_c_ = z; } -+ public void setW(float z) { this.field_229371_d_ = z; } - } diff --git a/patches/minecraft/net/minecraft/util/palette/PalettedContainer.java.patch b/patches/minecraft/net/minecraft/util/palette/PalettedContainer.java.patch deleted file mode 100644 index 089c89fc99..0000000000 --- a/patches/minecraft/net/minecraft/util/palette/PalettedContainer.java.patch +++ /dev/null @@ -1,43 +0,0 @@ ---- a/net/minecraft/util/palette/PalettedContainer.java -+++ b/net/minecraft/util/palette/PalettedContainer.java -@@ -66,8 +_,11 @@ - } - - private void func_186012_b(int p_186012_1_) { -- if (p_186012_1_ != this.field_186024_e) { -- this.field_186024_e = p_186012_1_; -+ setBits(p_186012_1_, false); -+ } -+ private void setBits(int bitsIn, boolean forceBits) { -+ if (bitsIn != this.field_186024_e) { -+ this.field_186024_e = bitsIn; - if (this.field_186024_e <= 4) { - this.field_186024_e = 4; - this.field_186022_c = new ArrayPalette<>(this.field_205523_d, this.field_186024_e, this, this.field_205524_e); -@@ -76,6 +_,8 @@ - } else { - this.field_186022_c = this.field_205521_b; - this.field_186024_e = MathHelper.func_151241_e(this.field_205523_d.func_186804_a()); -+ if (forceBits) -+ this.field_186024_e = bitsIn; - } - - this.field_186022_c.func_186041_a(this.field_205526_g); -@@ -138,12 +_,16 @@ - this.func_210459_b(); - int i = p_186010_1_.readByte(); - if (this.field_186024_e != i) { -- this.func_186012_b(i); -+ this.setBits(i, true); //Forge, Force bit density to fix network issues, resize below if needed. - } - - this.field_186022_c.func_186038_a(p_186010_1_); - p_186010_1_.func_186873_b(this.field_186021_b.func_188143_a()); - this.func_210460_c(); -+ -+ int regSize = MathHelper.func_151241_e(this.field_205523_d.func_186804_a()); -+ if (this.field_186022_c == field_205521_b && this.field_186024_e != regSize) // Resize bits to fit registry. -+ this.onResize(regSize, field_205526_g); - } - - public void func_186009_b(PacketBuffer p_186009_1_) { diff --git a/patches/minecraft/net/minecraft/util/registry/Bootstrap.java.patch b/patches/minecraft/net/minecraft/util/registry/Bootstrap.java.patch deleted file mode 100644 index 85cfbec62c..0000000000 --- a/patches/minecraft/net/minecraft/util/registry/Bootstrap.java.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- a/net/minecraft/util/registry/Bootstrap.java -+++ b/net/minecraft/util/registry/Bootstrap.java -@@ -48,6 +_,8 @@ - IDispenseItemBehavior.func_218401_c(); - ArgumentTypes.func_197483_a(); - TagRegistryManager.func_242197_b(); -+ net.minecraftforge.registries.GameData.vanillaSnapshot(); -+ if (false) // skip redirectOutputToLog, Forge already redirects stdout and stderr output to log so that they print with more context - func_179868_d(); - } - } -@@ -103,7 +_,6 @@ - Commands.func_242986_b(); - } - -- GlobalEntityTypeAttributes.func_233834_a_(); - } - } - diff --git a/patches/minecraft/net/minecraft/util/registry/DynamicRegistries.java.patch b/patches/minecraft/net/minecraft/util/registry/DynamicRegistries.java.patch deleted file mode 100644 index 434ee0fc1e..0000000000 --- a/patches/minecraft/net/minecraft/util/registry/DynamicRegistries.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/util/registry/DynamicRegistries.java -+++ b/net/minecraft/util/registry/DynamicRegistries.java -@@ -90,6 +_,8 @@ - RegistryKey> registrykey = p_243607_2_.func_243622_a(); - boolean flag = !registrykey.equals(Registry.field_243549_ar) && !registrykey.equals(Registry.field_239698_ad_); - Registry registry = field_243600_c.func_243612_b(registrykey); -+ if (!registrykey.equals(Registry.field_239698_ad_)) -+ registry = ((Registry>)WorldGenRegistries.field_243650_b).func_230516_a_((RegistryKey>)registrykey); - MutableRegistry mutableregistry = p_243607_0_.func_243612_b(registrykey); - - for(Entry, E> entry : registry.func_239659_c_()) { diff --git a/patches/minecraft/net/minecraft/util/registry/Registry.java.patch b/patches/minecraft/net/minecraft/util/registry/Registry.java.patch deleted file mode 100644 index 5bbd78a751..0000000000 --- a/patches/minecraft/net/minecraft/util/registry/Registry.java.patch +++ /dev/null @@ -1,210 +0,0 @@ ---- a/net/minecraft/util/registry/Registry.java -+++ b/net/minecraft/util/registry/Registry.java -@@ -94,6 +_,10 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; - -+/* -+ * Attention Modders: This SHOULD NOT be used, you should use ForgeRegistries instead. As it has a cleaner modder facing API. -+ * We will be wrapping all of these in our API as necessary for syncing and management. -+ */ - public abstract class Registry implements Codec, Keyable, IObjectIntIterable { - protected static final Logger field_212616_e = LogManager.getLogger(); - private static final Map> field_218376_a = Maps.newLinkedHashMap(); -@@ -133,43 +_,43 @@ - public static final RegistryKey> field_239698_ad_ = func_239741_a_("dimension_type"); - public static final RegistryKey> field_239699_ae_ = func_239741_a_("dimension"); - public static final RegistryKey> field_239700_af_ = func_239741_a_("dimension"); -- public static final Registry field_212633_v = func_239746_a_(field_239708_i_, () -> { -+ @Deprecated public static final Registry field_212633_v = forge(field_239708_i_, () -> { - return SoundEvents.field_187638_cR; - }); -- public static final DefaultedRegistry field_212619_h = func_239745_a_(field_239709_j_, "empty", () -> { -+ @Deprecated public static final DefaultedRegistry field_212619_h = forge(field_239709_j_, "empty", () -> { - return Fluids.field_204541_a; - }); -- public static final Registry field_212631_t = func_239746_a_(field_239710_k_, () -> { -+ @Deprecated public static final Registry field_212631_t = forge(field_239710_k_, () -> { - return Effects.field_188425_z; - }); -- public static final DefaultedRegistry field_212618_g = func_239745_a_(field_239711_l_, "air", () -> { -+ @Deprecated public static final DefaultedRegistry field_212618_g = forge(field_239711_l_, "air", () -> { - return Blocks.field_150350_a; - }); -- public static final Registry field_212628_q = func_239746_a_(field_239712_m_, () -> { -+ @Deprecated public static final Registry field_212628_q = forge(field_239712_m_, () -> { - return Enchantments.field_185308_t; - }); -- public static final DefaultedRegistry> field_212629_r = func_239745_a_(field_239713_n_, "pig", () -> { -+ @Deprecated public static final DefaultedRegistry> field_212629_r = forge(field_239713_n_, "pig", () -> { - return EntityType.field_200784_X; - }); -- public static final DefaultedRegistry field_212630_s = func_239745_a_(field_239714_o_, "air", () -> { -+ @Deprecated public static final DefaultedRegistry field_212630_s = forge(field_239714_o_, "air", () -> { - return Items.field_190931_a; - }); -- public static final DefaultedRegistry field_212621_j = func_239745_a_(field_239715_p_, "empty", () -> { -+ @Deprecated public static final DefaultedRegistry field_212621_j = forge(field_239715_p_, "empty", () -> { - return Potions.field_185229_a; - }); -- public static final Registry> field_212632_u = func_239746_a_(field_239664_B_, () -> { -+ @Deprecated public static final Registry> field_212632_u = forge(field_239664_B_, () -> { - return ParticleTypes.field_197611_d; - }); -- public static final Registry> field_212626_o = func_239746_a_(field_239667_E_, () -> { -+ @Deprecated public static final Registry> field_212626_o = forge(field_239667_E_, () -> { - return TileEntityType.field_200971_b; - }); -- public static final DefaultedRegistry field_212620_i = func_239745_a_(field_239668_F_, "kebab", () -> { -+ @Deprecated public static final DefaultedRegistry field_212620_i = forge(field_239668_F_, "kebab", () -> { - return PaintingType.field_200843_b; - }); - public static final Registry field_212623_l = func_239746_a_(field_239669_G_, () -> { - return Stats.field_75953_u; - }); -- public static final DefaultedRegistry field_218360_A = func_239745_a_(field_239670_H_, "empty", () -> { -+ @Deprecated public static final DefaultedRegistry field_218360_A = forge(field_239670_H_, "empty", () -> { - return ChunkStatus.field_223226_a_; - }); - public static final Registry> field_218363_D = func_239746_a_(field_239673_K_, () -> { -@@ -178,40 +_,40 @@ - public static final Registry> field_239691_aJ_ = func_239746_a_(field_239674_L_, () -> { - return IPosRuleTests.field_237103_a_; - }); -- public static final Registry> field_218366_G = func_239746_a_(field_239677_O_, () -> { -+ @Deprecated public static final Registry> field_218366_G = forge(field_239677_O_, () -> { - return ContainerType.field_221514_h; - }); - public static final Registry> field_218367_H = func_239746_a_(field_239678_P_, () -> { - return IRecipeType.field_222149_a; - }); -- public static final Registry> field_218368_I = func_239746_a_(field_239679_Q_, () -> { -+ @Deprecated public static final Registry> field_218368_I = forge(field_239679_Q_, () -> { - return IRecipeSerializer.field_222158_b; - }); -- public static final Registry field_239692_aP_ = func_239746_a_(field_239680_R_, () -> { -+ @Deprecated public static final Registry field_239692_aP_ = forge(field_239680_R_, () -> { - return Attributes.field_233828_k_; - }); -- public static final Registry> field_212634_w = func_239746_a_(field_239681_S_, () -> { -+ @Deprecated public static final Registry> field_212634_w = forge(field_239681_S_, () -> { - return Stats.field_75929_E; - }); - public static final DefaultedRegistry field_218369_K = func_239745_a_(field_239682_T_, "plains", () -> { - return VillagerType.field_221175_c; - }); -- public static final DefaultedRegistry field_218370_L = func_239745_a_(field_239683_U_, "none", () -> { -+ @Deprecated public static final DefaultedRegistry field_218370_L = forge(field_239683_U_, "none", () -> { - return VillagerProfession.field_221151_a; - }); -- public static final DefaultedRegistry field_218371_M = func_239745_a_(field_239684_V_, "unemployed", () -> { -+ @Deprecated public static final DefaultedRegistry field_218371_M = forge(field_239684_V_, "unemployed", () -> { - return PointOfInterestType.field_221054_b; - }); -- public static final DefaultedRegistry> field_218372_N = func_239745_a_(field_239685_W_, "dummy", () -> { -+ @Deprecated public static final DefaultedRegistry> field_218372_N = forge(field_239685_W_, "dummy", () -> { - return MemoryModuleType.field_220940_a; - }); -- public static final DefaultedRegistry> field_218373_O = func_239745_a_(field_239686_X_, "dummy", () -> { -+ @Deprecated public static final DefaultedRegistry> field_218373_O = forge(field_239686_X_, "dummy", () -> { - return SensorType.field_220997_a; - }); -- public static final Registry field_218374_P = func_239746_a_(field_239687_Y_, () -> { -+ @Deprecated public static final Registry field_218374_P = forge(field_239687_Y_, () -> { - return Schedule.field_221383_a; - }); -- public static final Registry field_218375_Q = func_239746_a_(field_239688_Z_, () -> { -+ @Deprecated public static final Registry field_218375_Q = forge(field_239688_Z_, () -> { - return Activity.field_221366_b; - }); - public static final Registry field_239693_aY_ = func_239746_a_(field_239695_aa_, () -> { -@@ -232,19 +_,19 @@ - public static final RegistryKey> field_243555_ax = func_239741_a_("worldgen/template_pool"); - public static final RegistryKey> field_239720_u_ = func_239741_a_("worldgen/biome"); - public static final RegistryKey>> field_239717_r_ = func_239741_a_("worldgen/surface_builder"); -- public static final Registry> field_218378_p = func_239746_a_(field_239717_r_, () -> { -+ @Deprecated public static final Registry> field_218378_p = forge(field_239717_r_, () -> { - return SurfaceBuilder.field_215396_G; - }); - public static final RegistryKey>> field_239716_q_ = func_239741_a_("worldgen/carver"); -- public static final Registry> field_218377_o = func_239746_a_(field_239716_q_, () -> { -+ @Deprecated public static final Registry> field_218377_o = forge(field_239716_q_, () -> { - return WorldCarver.field_222709_a; - }); - public static final RegistryKey>> field_239718_s_ = func_239741_a_("worldgen/feature"); -- public static final Registry> field_218379_q = func_239746_a_(field_239718_s_, () -> { -+ @Deprecated public static final Registry> field_218379_q = forge(field_239718_s_, () -> { - return Feature.field_202290_aj; - }); - public static final RegistryKey>> field_239671_I_ = func_239741_a_("worldgen/structure_feature"); -- public static final Registry> field_218361_B = func_239746_a_(field_239671_I_, () -> { -+ @Deprecated public static final Registry> field_218361_B = forge(field_239671_I_, () -> { - return Structure.field_236367_c_; - }); - public static final RegistryKey> field_239672_J_ = func_239741_a_("worldgen/structure_piece"); -@@ -252,7 +_,7 @@ - return IStructurePieceType.field_214782_c; - }); - public static final RegistryKey>> field_239719_t_ = func_239741_a_("worldgen/decorator"); -- public static final Registry> field_218380_r = func_239746_a_(field_239719_t_, () -> { -+ @Deprecated public static final Registry> field_218380_r = forge(field_239719_t_, () -> { - return Placement.field_215022_h; - }); - public static final RegistryKey>> field_239721_v_ = func_239741_a_("worldgen/block_state_provider_type"); -@@ -265,19 +_,19 @@ - public static final RegistryKey>> field_239666_D_ = func_239741_a_("worldgen/chunk_generator"); - public static final RegistryKey>> field_239675_M_ = func_239741_a_("worldgen/structure_processor"); - public static final RegistryKey>> field_239676_N_ = func_239741_a_("worldgen/structure_pool_element"); -- public static final Registry> field_229387_t_ = func_239746_a_(field_239721_v_, () -> { -+ @Deprecated public static final Registry> field_229387_t_ = forge(field_239721_v_, () -> { - return BlockStateProviderType.field_227394_a_; - }); -- public static final Registry> field_229388_u_ = func_239746_a_(field_239722_w_, () -> { -+ @Deprecated public static final Registry> field_229388_u_ = forge(field_239722_w_, () -> { - return BlockPlacerType.field_227259_a_; - }); -- public static final Registry> field_229389_v_ = func_239746_a_(field_239723_x_, () -> { -+ @Deprecated public static final Registry> field_229389_v_ = forge(field_239723_x_, () -> { - return FoliagePlacerType.field_227386_a_; - }); - public static final Registry> field_239701_aw_ = func_239746_a_(field_239724_y_, () -> { - return TrunkPlacerType.field_236920_a_; - }); -- public static final Registry> field_229390_w_ = func_239746_a_(field_239725_z_, () -> { -+ @Deprecated public static final Registry> field_229390_w_ = forge(field_239725_z_, () -> { - return TreeDecoratorType.field_227426_b_; - }); - public static final Registry> field_239702_ay_ = func_239746_a_(field_239663_A_, () -> { -@@ -323,16 +_,32 @@ - return func_239742_a_(p_239746_0_, Lifecycle.experimental(), p_239746_1_); - } - -+ private static > Registry forge(RegistryKey> key, Supplier def) { -+ return forge(key, Lifecycle.experimental(), def); -+ } -+ - private static DefaultedRegistry func_239745_a_(RegistryKey> p_239745_0_, String p_239745_1_, Supplier p_239745_2_) { - return func_239744_a_(p_239745_0_, p_239745_1_, Lifecycle.experimental(), p_239745_2_); - } - -+ private static > DefaultedRegistry forge(RegistryKey> key, String defKey, Supplier def) { -+ return forge(key, defKey, Lifecycle.experimental(), def); -+ } -+ - private static Registry func_239742_a_(RegistryKey> p_239742_0_, Lifecycle p_239742_1_, Supplier p_239742_2_) { - return func_239743_a_(p_239742_0_, new SimpleRegistry<>(p_239742_0_, p_239742_1_), p_239742_2_, p_239742_1_); - } - -+ private static > Registry forge(RegistryKey> key, Lifecycle cycle, Supplier def) { -+ return func_239743_a_(key, net.minecraftforge.registries.GameData.getWrapper(key, cycle), def, cycle); -+ } -+ - private static DefaultedRegistry func_239744_a_(RegistryKey> p_239744_0_, String p_239744_1_, Lifecycle p_239744_2_, Supplier p_239744_3_) { - return func_239743_a_(p_239744_0_, new DefaultedRegistry<>(p_239744_1_, p_239744_0_, p_239744_2_), p_239744_3_, p_239744_2_); -+ } -+ -+ private static > DefaultedRegistry forge(RegistryKey> key, String defKey, Lifecycle cycle, Supplier def) { -+ return func_239743_a_(key, net.minecraftforge.registries.GameData.getWrapper(key, cycle, defKey), def, cycle); - } - - private static > R func_239743_a_(RegistryKey> p_239743_0_, R p_239743_1_, Supplier p_239743_2_, Lifecycle p_239743_3_) { diff --git a/patches/minecraft/net/minecraft/util/registry/SimpleRegistry.java.patch b/patches/minecraft/net/minecraft/util/registry/SimpleRegistry.java.patch deleted file mode 100644 index fe4acd7369..0000000000 --- a/patches/minecraft/net/minecraft/util/registry/SimpleRegistry.java.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/net/minecraft/util/registry/SimpleRegistry.java -+++ b/net/minecraft/util/registry/SimpleRegistry.java -@@ -212,7 +_,8 @@ - } - - public static Codec> func_241745_c_(RegistryKey> p_241745_0_, Lifecycle p_241745_1_, Codec p_241745_2_) { -- return Codec.unboundedMap(ResourceLocation.field_240908_a_.xmap(RegistryKey.func_240902_a_(p_241745_0_), RegistryKey::func_240901_a_), p_241745_2_).xmap((p_239656_2_) -> { -+ // FORGE: Fix MC-197860 -+ return new net.minecraftforge.common.LenientUnboundedMapCodec<>(ResourceLocation.field_240908_a_.xmap(RegistryKey.func_240902_a_(p_241745_0_), RegistryKey::func_240901_a_), p_241745_2_).xmap((p_239656_2_) -> { - SimpleRegistry simpleregistry = new SimpleRegistry<>(p_241745_0_, p_241745_1_); - p_239656_2_.forEach((p_239653_2_, p_239653_3_) -> { - simpleregistry.func_218381_a(p_239653_2_, p_239653_3_, p_241745_1_); diff --git a/patches/minecraft/net/minecraft/util/registry/WorldGenRegistries.java.patch b/patches/minecraft/net/minecraft/util/registry/WorldGenRegistries.java.patch deleted file mode 100644 index d7d70e011d..0000000000 --- a/patches/minecraft/net/minecraft/util/registry/WorldGenRegistries.java.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- a/net/minecraft/util/registry/WorldGenRegistries.java -+++ b/net/minecraft/util/registry/WorldGenRegistries.java -@@ -45,13 +_,17 @@ - return ProcessorLists.field_244102_b; - }); - public static final Registry field_243656_h = func_243667_a(Registry.field_243555_ax, JigsawPatternRegistry::func_244093_a); -- public static final Registry field_243657_i = func_243667_a(Registry.field_239720_u_, () -> { -+ @Deprecated public static final Registry field_243657_i = forge(Registry.field_239720_u_, () -> { - return BiomeRegistry.field_244200_a; - }); - public static final Registry field_243658_j = func_243667_a(Registry.field_243549_ar, DimensionSettings::func_242746_i); - - private static Registry func_243667_a(RegistryKey> p_243667_0_, Supplier p_243667_1_) { - return func_243665_a(p_243667_0_, Lifecycle.stable(), p_243667_1_); -+ } -+ -+ private static > Registry forge(RegistryKey> key, Supplier def) { -+ return func_243666_a(key, net.minecraftforge.registries.GameData.getWrapper(key, Lifecycle.stable()), def, Lifecycle.stable()); - } - - private static Registry func_243665_a(RegistryKey> p_243665_0_, Lifecycle p_243665_1_, Supplier p_243665_2_) { diff --git a/patches/minecraft/net/minecraft/util/registry/WorldSettingsImport.java.patch b/patches/minecraft/net/minecraft/util/registry/WorldSettingsImport.java.patch deleted file mode 100644 index 1ab024a611..0000000000 --- a/patches/minecraft/net/minecraft/util/registry/WorldSettingsImport.java.patch +++ /dev/null @@ -1,18 +0,0 @@ ---- a/net/minecraft/util/registry/WorldSettingsImport.java -+++ b/net/minecraft/util/registry/WorldSettingsImport.java -@@ -190,6 +_,7 @@ - ) { - JsonParser jsonparser = new JsonParser(); - JsonElement jsonelement = jsonparser.parse(reader); -+ if (jsonelement!= null) jsonelement.getAsJsonObject().addProperty("forge:registry_name", p_241879_3_.func_240901_a_().toString()); - return p_241879_4_.parse(p_241879_1_, jsonelement).map((p_244347_0_) -> { - return Pair.of(p_244347_0_, OptionalInt.empty()); - }); -@@ -231,6 +_,7 @@ - - public DataResult> func_241879_a(DynamicOps p_241879_1_, RegistryKey> p_241879_2_, RegistryKey p_241879_3_, Decoder p_241879_4_) { - JsonElement jsonelement = this.field_244349_a.get(p_241879_3_); -+ if (jsonelement!= null) jsonelement.getAsJsonObject().addProperty("forge:registry_name", p_241879_3_.func_240901_a_().toString()); - return jsonelement == null ? DataResult.error("Unknown element: " + p_241879_3_) : p_241879_4_.parse(p_241879_1_, jsonelement).setLifecycle(this.field_244351_c.get(p_241879_3_)).map((p_244353_2_) -> { - return Pair.of(p_244353_2_, OptionalInt.of(this.field_244350_b.getInt(p_241879_3_))); - }); diff --git a/patches/minecraft/net/minecraft/util/text/LanguageMap.java.patch b/patches/minecraft/net/minecraft/util/text/LanguageMap.java.patch deleted file mode 100644 index 2524105ac6..0000000000 --- a/patches/minecraft/net/minecraft/util/text/LanguageMap.java.patch +++ /dev/null @@ -1,34 +0,0 @@ ---- a/net/minecraft/util/text/LanguageMap.java -+++ b/net/minecraft/util/text/LanguageMap.java -@@ -40,7 +_,8 @@ - field_201045_a.error("Couldn't read strings from /assets/minecraft/lang/en_us.json", (Throwable)ioexception); - } - -- final Map map = builder.build(); -+ final Map map = new java.util.HashMap<>(builder.build()); -+ net.minecraftforge.fml.server.LanguageHook.captureLanguageMap(map); - return new LanguageMap() { - public String func_230503_a_(String p_230503_1_) { - return map.getOrDefault(p_230503_1_, p_230503_1_); -@@ -63,6 +_,11 @@ - }, Style.field_240709_b_).isPresent(); - }; - } -+ -+ @Override -+ public Map getLanguageData() { -+ return map; -+ } - }; - } - -@@ -84,6 +_,9 @@ - public static void func_240594_a_(LanguageMap p_240594_0_) { - field_240592_d_ = p_240594_0_; - } -+ -+ // FORGE START -+ public Map getLanguageData() { return ImmutableMap.of(); } - - public abstract String func_230503_a_(String p_230503_1_); - diff --git a/patches/minecraft/net/minecraft/util/text/Style.java.patch b/patches/minecraft/net/minecraft/util/text/Style.java.patch deleted file mode 100644 index b71811f18b..0000000000 --- a/patches/minecraft/net/minecraft/util/text/Style.java.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- a/net/minecraft/util/text/Style.java -+++ b/net/minecraft/util/text/Style.java -@@ -125,6 +_,18 @@ - return new Style(this.field_150247_b, this.field_150248_c, this.field_150245_d, p_244282_1_, this.field_150243_f, this.field_150244_g, this.field_150251_h, this.field_150252_i, this.field_179990_j, this.field_240710_l_); - } - -+ public Style setUnderlined(@Nullable Boolean underlined) { -+ return new Style(this.field_150247_b, this.field_150248_c, this.field_150245_d, underlined, this.field_150243_f, this.field_150244_g, this.field_150251_h, this.field_150252_i, this.field_179990_j, this.field_240710_l_); -+ } -+ -+ public Style setStrikethrough(@Nullable Boolean strikethrough) { -+ return new Style(this.field_150247_b, this.field_150248_c, this.field_150245_d, this.field_150246_e, strikethrough, this.field_150244_g, this.field_150251_h, this.field_150252_i, this.field_179990_j, this.field_240710_l_); -+ } -+ -+ public Style setObfuscated(@Nullable Boolean obfuscated) { -+ return new Style(this.field_150247_b, this.field_150248_c, this.field_150245_d, this.field_150246_e, this.field_150243_f, obfuscated, this.field_150251_h, this.field_150252_i, this.field_179990_j, this.field_240710_l_); -+ } -+ - public Style func_240715_a_(@Nullable ClickEvent p_240715_1_) { - return new Style(this.field_150247_b, this.field_150248_c, this.field_150245_d, this.field_150246_e, this.field_150243_f, this.field_150244_g, p_240715_1_, this.field_150252_i, this.field_179990_j, this.field_240710_l_); - } diff --git a/patches/minecraft/net/minecraft/util/text/TranslationTextComponent.java.patch b/patches/minecraft/net/minecraft/util/text/TranslationTextComponent.java.patch deleted file mode 100644 index 9ac5955bc9..0000000000 --- a/patches/minecraft/net/minecraft/util/text/TranslationTextComponent.java.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/net/minecraft/util/text/TranslationTextComponent.java -+++ b/net/minecraft/util/text/TranslationTextComponent.java -@@ -88,6 +_,10 @@ - } - } - -+ if (j == 0) { -+ // if we failed to match above, lets try the messageformat handler instead. -+ j = net.minecraftforge.fml.TextComponentMessageFormatHandler.handle(this, this.field_150278_b, this.field_150277_e, p_240758_1_); -+ } - if (j < p_240758_1_.length()) { - String s3 = p_240758_1_.substring(j); - if (s3.indexOf(37) != -1) { diff --git a/patches/minecraft/net/minecraft/village/PointOfInterestType.java.patch b/patches/minecraft/net/minecraft/village/PointOfInterestType.java.patch deleted file mode 100644 index 9cb693598b..0000000000 --- a/patches/minecraft/net/minecraft/village/PointOfInterestType.java.patch +++ /dev/null @@ -1,41 +0,0 @@ ---- a/net/minecraft/village/PointOfInterestType.java -+++ b/net/minecraft/village/PointOfInterestType.java -@@ -21,7 +_,7 @@ - import net.minecraft.util.Util; - import net.minecraft.util.registry.Registry; - --public class PointOfInterestType { -+public class PointOfInterestType extends net.minecraftforge.registries.ForgeRegistryEntry { - private static final Supplier> field_234168_y_ = Suppliers.memoize(() -> { - return Registry.field_218370_L.func_201756_e().map(VillagerProfession::func_221149_b).collect(Collectors.toSet()); - }); -@@ -36,7 +_,7 @@ - }).filter((p_234173_0_) -> { - return p_234173_0_.func_177229_b(BedBlock.field_176472_a) == BedPart.HEAD; - }).collect(ImmutableSet.toImmutableSet()); -- private static final Map field_221073_u = Maps.newHashMap(); -+ private static final Map field_221073_u = net.minecraftforge.registries.GameData.getBlockStatePointOfInterestTypeMap(); - public static final PointOfInterestType field_221054_b = func_226360_a_("unemployed", ImmutableSet.of(), 1, field_221071_s, 1); - public static final PointOfInterestType field_221055_c = func_226359_a_("armorer", func_221042_a(Blocks.field_222424_lM), 1, 1); - public static final PointOfInterestType field_221056_d = func_226359_a_("butcher", func_221042_a(Blocks.field_222423_lL), 1, 1); -@@ -112,16 +_,14 @@ - } - - private static PointOfInterestType func_221052_a(PointOfInterestType p_221052_0_) { -- p_221052_0_.field_221075_w.forEach((p_234169_1_) -> { -- PointOfInterestType pointofinteresttype = field_221073_u.put(p_234169_1_, p_221052_0_); -- if (pointofinteresttype != null) { -- throw (IllegalStateException)Util.func_229757_c_(new IllegalStateException(String.format("%s is defined in too many tags", p_234169_1_))); -- } -- }); - return p_221052_0_; - } - - public static Optional func_221047_b(BlockState p_221047_0_) { - return Optional.ofNullable(field_221073_u.get(p_221047_0_)); -+ } -+ -+ public ImmutableSet getBlockStates() { -+ return ImmutableSet.copyOf(this.field_221075_w); - } - } diff --git a/patches/minecraft/net/minecraft/village/VillageSiege.java.patch b/patches/minecraft/net/minecraft/village/VillageSiege.java.patch deleted file mode 100644 index d02e839ca5..0000000000 --- a/patches/minecraft/net/minecraft/village/VillageSiege.java.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- a/net/minecraft/village/VillageSiege.java -+++ b/net/minecraft/village/VillageSiege.java -@@ -78,7 +_,9 @@ - this.field_75532_g = blockpos.func_177958_n() + MathHelper.func_76141_d(MathHelper.func_76134_b(f) * 32.0F); - this.field_75538_h = blockpos.func_177956_o(); - this.field_75539_i = blockpos.func_177952_p() + MathHelper.func_76141_d(MathHelper.func_76126_a(f) * 32.0F); -- if (this.func_225476_a(p_75529_1_, new BlockPos(this.field_75532_g, this.field_75538_h, this.field_75539_i)) != null) { -+ Vector3d siegeLocation = this.func_225476_a(p_75529_1_, new BlockPos(this.field_75532_g, this.field_75538_h, this.field_75539_i)); -+ if (siegeLocation != null) { -+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.village.VillageSiegeEvent(this, p_75529_1_, playerentity, siegeLocation))) return false; - this.field_75534_e = 0; - this.field_75533_d = 20; - break; -@@ -98,7 +_,7 @@ - if (vector3d != null) { - ZombieEntity zombieentity; - try { -- zombieentity = new ZombieEntity(p_75530_1_); -+ zombieentity = EntityType.field_200725_aD.func_200721_a(p_75530_1_); //Forge: Direct Initialization is deprecated, use EntityType. - zombieentity.func_213386_a(p_75530_1_, p_75530_1_.func_175649_E(zombieentity.func_233580_cy_()), SpawnReason.EVENT, (ILivingEntityData)null, (CompoundNBT)null); - } catch (Exception exception) { - field_242320_a.warn("Failed to create zombie for village siege at {}", vector3d, exception); diff --git a/patches/minecraft/net/minecraft/world/Explosion.java.patch b/patches/minecraft/net/minecraft/world/Explosion.java.patch deleted file mode 100644 index e00bb5abd3..0000000000 --- a/patches/minecraft/net/minecraft/world/Explosion.java.patch +++ /dev/null @@ -1,67 +0,0 @@ ---- a/net/minecraft/world/Explosion.java -+++ b/net/minecraft/world/Explosion.java -@@ -58,6 +_,7 @@ - private final ExplosionContext field_234893_k_; - private final List field_77281_g = Lists.newArrayList(); - private final Map field_77288_k = Maps.newHashMap(); -+ private final Vector3d position; - - @OnlyIn(Dist.CLIENT) - public Explosion(World p_i45752_1_, @Nullable Entity p_i45752_2_, double p_i45752_3_, double p_i45752_5_, double p_i45752_7_, float p_i45752_9_, List p_i45752_10_) { -@@ -86,6 +_,7 @@ - this.field_222260_b = p_i231610_13_; - this.field_199593_j = p_i231610_3_ == null ? DamageSource.func_94539_a(this) : p_i231610_3_; - this.field_234893_k_ = p_i231610_4_ == null ? this.func_234894_a_(p_i231610_2_) : p_i231610_4_; -+ this.position = new Vector3d(this.field_77284_b, this.field_77285_c, this.field_77282_d); - } - - private ExplosionContext func_234894_a_(@Nullable Entity p_234894_1_) { -@@ -176,6 +_,7 @@ - int j2 = MathHelper.func_76128_c(this.field_77282_d - (double)f2 - 1.0D); - int j1 = MathHelper.func_76128_c(this.field_77282_d + (double)f2 + 1.0D); - List list = this.field_77287_j.func_72839_b(this.field_77283_e, new AxisAlignedBB((double)k1, (double)i2, (double)j2, (double)l1, (double)i1, (double)j1)); -+ net.minecraftforge.event.ForgeEventFactory.onExplosionDetonate(this.field_77287_j, this, list, f2); - Vector3d vector3d = new Vector3d(this.field_77284_b, this.field_77285_c, this.field_77282_d); - - for(int k2 = 0; k2 < list.size(); ++k2) { -@@ -234,11 +_,11 @@ - for(BlockPos blockpos : this.field_77281_g) { - BlockState blockstate = this.field_77287_j.func_180495_p(blockpos); - Block block = blockstate.func_177230_c(); -- if (!blockstate.func_196958_f()) { -+ if (!blockstate.isAir(this.field_77287_j, blockpos)) { - BlockPos blockpos1 = blockpos.func_185334_h(); - this.field_77287_j.func_217381_Z().func_76320_a("explosion_blocks"); -- if (block.func_149659_a(this) && this.field_77287_j instanceof ServerWorld) { -- TileEntity tileentity = block.func_235695_q_() ? this.field_77287_j.func_175625_s(blockpos) : null; -+ if (blockstate.canDropFromExplosion(this.field_77287_j, blockpos, this) && this.field_77287_j instanceof ServerWorld) { -+ TileEntity tileentity = blockstate.hasTileEntity() ? this.field_77287_j.func_175625_s(blockpos) : null; - LootContext.Builder lootcontext$builder = (new LootContext.Builder((ServerWorld)this.field_77287_j)).func_216023_a(this.field_77287_j.field_73012_v).func_216015_a(LootParameters.field_237457_g_, Vector3d.func_237489_a_(blockpos)).func_216015_a(LootParameters.field_216289_i, ItemStack.field_190927_a).func_216021_b(LootParameters.field_216288_h, tileentity).func_216021_b(LootParameters.field_216281_a, this.field_77283_e); - if (this.field_222260_b == Explosion.Mode.DESTROY) { - lootcontext$builder.func_216015_a(LootParameters.field_216290_j, this.field_77280_f); -@@ -249,8 +_,7 @@ - }); - } - -- this.field_77287_j.func_180501_a(blockpos, Blocks.field_150350_a.func_176223_P(), 3); -- block.func_180652_a(this.field_77287_j, blockpos, this); -+ blockstate.onBlockExploded(this.field_77287_j, blockpos, this); - this.field_77287_j.func_217381_Z().func_76319_b(); - } - } -@@ -322,6 +_,15 @@ - - public List func_180343_e() { - return this.field_77281_g; -+ } -+ -+ public Vector3d getPosition() { -+ return this.position; -+ } -+ -+ @Nullable -+ public Entity getExploder() { -+ return this.field_77283_e; - } - - public static enum Mode { diff --git a/patches/minecraft/net/minecraft/world/ExplosionContext.java.patch b/patches/minecraft/net/minecraft/world/ExplosionContext.java.patch deleted file mode 100644 index a1ad5cb35e..0000000000 --- a/patches/minecraft/net/minecraft/world/ExplosionContext.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/ExplosionContext.java -+++ b/net/minecraft/world/ExplosionContext.java -@@ -7,7 +_,7 @@ - - public class ExplosionContext { - public Optional func_230312_a_(Explosion p_230312_1_, IBlockReader p_230312_2_, BlockPos p_230312_3_, BlockState p_230312_4_, FluidState p_230312_5_) { -- return p_230312_4_.func_196958_f() && p_230312_5_.func_206888_e() ? Optional.empty() : Optional.of(Math.max(p_230312_4_.func_177230_c().func_149638_a(), p_230312_5_.func_210200_l())); -+ return p_230312_4_.isAir(p_230312_2_, p_230312_3_) && p_230312_5_.func_206888_e() ? Optional.empty() : Optional.of(Math.max(p_230312_4_.getExplosionResistance(p_230312_2_, p_230312_3_, p_230312_1_), p_230312_5_.getExplosionResistance(p_230312_2_, p_230312_3_, p_230312_1_))); - } - - public boolean func_230311_a_(Explosion p_230311_1_, IBlockReader p_230311_2_, BlockPos p_230311_3_, BlockState p_230311_4_, float p_230311_5_) { diff --git a/patches/minecraft/net/minecraft/world/ForcedChunksSaveData.java.patch b/patches/minecraft/net/minecraft/world/ForcedChunksSaveData.java.patch deleted file mode 100644 index 4a6bc33bab..0000000000 --- a/patches/minecraft/net/minecraft/world/ForcedChunksSaveData.java.patch +++ /dev/null @@ -1,33 +0,0 @@ ---- a/net/minecraft/world/ForcedChunksSaveData.java -+++ b/net/minecraft/world/ForcedChunksSaveData.java -@@ -14,14 +_,30 @@ - - public void func_76184_a(CompoundNBT p_76184_1_) { - this.field_212439_a = new LongOpenHashSet(p_76184_1_.func_197645_o("Forced")); -+ this.blockForcedChunks = new net.minecraftforge.common.world.ForgeChunkManager.TicketTracker<>(); -+ this.entityForcedChunks = new net.minecraftforge.common.world.ForgeChunkManager.TicketTracker<>(); -+ net.minecraftforge.common.world.ForgeChunkManager.readForgeForcedChunks(p_76184_1_, this.blockForcedChunks, this.entityForcedChunks); - } - - public CompoundNBT func_189551_b(CompoundNBT p_189551_1_) { - p_189551_1_.func_197644_a("Forced", this.field_212439_a.toLongArray()); -+ net.minecraftforge.common.world.ForgeChunkManager.writeForgeForcedChunks(p_189551_1_, this.blockForcedChunks, this.entityForcedChunks); - return p_189551_1_; - } - - public LongSet func_212438_a() { - return this.field_212439_a; -+ } -+ -+ /* ======================================== FORGE START =====================================*/ -+ private net.minecraftforge.common.world.ForgeChunkManager.TicketTracker blockForcedChunks = new net.minecraftforge.common.world.ForgeChunkManager.TicketTracker<>(); -+ private net.minecraftforge.common.world.ForgeChunkManager.TicketTracker entityForcedChunks = new net.minecraftforge.common.world.ForgeChunkManager.TicketTracker<>(); -+ -+ public net.minecraftforge.common.world.ForgeChunkManager.TicketTracker getBlockForcedChunks() { -+ return this.blockForcedChunks; -+ } -+ -+ public net.minecraftforge.common.world.ForgeChunkManager.TicketTracker getEntityForcedChunks() { -+ return this.entityForcedChunks; - } - } diff --git a/patches/minecraft/net/minecraft/world/IBlockReader.java.patch b/patches/minecraft/net/minecraft/world/IBlockReader.java.patch deleted file mode 100644 index e31d6724a6..0000000000 --- a/patches/minecraft/net/minecraft/world/IBlockReader.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/IBlockReader.java -+++ b/net/minecraft/world/IBlockReader.java -@@ -26,7 +_,7 @@ - FluidState func_204610_c(BlockPos p_204610_1_); - - default int func_217298_h(BlockPos p_217298_1_) { -- return this.func_180495_p(p_217298_1_).func_185906_d(); -+ return this.func_180495_p(p_217298_1_).getLightValue(this, p_217298_1_); - } - - default int func_201572_C() { diff --git a/patches/minecraft/net/minecraft/world/IWorldReader.java.patch b/patches/minecraft/net/minecraft/world/IWorldReader.java.patch deleted file mode 100644 index 7258623530..0000000000 --- a/patches/minecraft/net/minecraft/world/IWorldReader.java.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- a/net/minecraft/world/IWorldReader.java -+++ b/net/minecraft/world/IWorldReader.java -@@ -68,7 +_,7 @@ - } - - default boolean func_175623_d(BlockPos p_175623_1_) { -- return this.func_180495_p(p_175623_1_).func_196958_f(); -+ return this.func_180495_p(p_175623_1_).isAir(this, p_175623_1_); - } - - default boolean func_175710_j(BlockPos p_175710_1_) { -@@ -155,6 +_,10 @@ - @Deprecated - default boolean func_175667_e(BlockPos p_175667_1_) { - return this.func_217354_b(p_175667_1_.func_177958_n() >> 4, p_175667_1_.func_177952_p() >> 4); -+ } -+ -+ default boolean isAreaLoaded(BlockPos center, int range) { -+ return this.func_175707_a(center.func_177982_a(-range, -range, -range), center.func_177982_a(range, range, range)); - } - - @Deprecated diff --git a/patches/minecraft/net/minecraft/world/Teleporter.java.patch b/patches/minecraft/net/minecraft/world/Teleporter.java.patch deleted file mode 100644 index e0508c3465..0000000000 --- a/patches/minecraft/net/minecraft/world/Teleporter.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/Teleporter.java -+++ b/net/minecraft/world/Teleporter.java -@@ -19,7 +_,7 @@ - import net.minecraft.world.server.ServerWorld; - import net.minecraft.world.server.TicketType; - --public class Teleporter { -+public class Teleporter implements net.minecraftforge.common.util.ITeleporter { - protected final ServerWorld field_85192_a; - - public Teleporter(ServerWorld p_i1963_1_) { diff --git a/patches/minecraft/net/minecraft/world/TrackedEntity.java.patch b/patches/minecraft/net/minecraft/world/TrackedEntity.java.patch deleted file mode 100644 index 455bdd442f..0000000000 --- a/patches/minecraft/net/minecraft/world/TrackedEntity.java.patch +++ /dev/null @@ -1,29 +0,0 @@ ---- a/net/minecraft/world/TrackedEntity.java -+++ b/net/minecraft/world/TrackedEntity.java -@@ -81,9 +_,8 @@ - if (this.field_219461_c instanceof ItemFrameEntity && this.field_219472_n % 10 == 0) { - ItemFrameEntity itemframeentity = (ItemFrameEntity)this.field_219461_c; - ItemStack itemstack = itemframeentity.func_82335_i(); -- if (itemstack.func_77973_b() instanceof FilledMapItem) { -- MapData mapdata = FilledMapItem.func_195950_a(itemstack, this.field_219460_b); -- -+ MapData mapdata = FilledMapItem.func_195950_a(itemstack, this.field_219460_b); -+ if (mapdata != null) { - for(ServerPlayerEntity serverplayerentity : this.field_219460_b.func_217369_A()) { - mapdata.func_76191_a(serverplayerentity, itemstack); - IPacket ipacket = ((FilledMapItem)itemstack.func_77973_b()).func_150911_c(itemstack, this.field_219460_b, serverplayerentity); -@@ -187,12 +_,14 @@ - public void func_219454_a(ServerPlayerEntity p_219454_1_) { - this.field_219461_c.func_184203_c(p_219454_1_); - p_219454_1_.func_152339_d(this.field_219461_c); -+ net.minecraftforge.event.ForgeEventFactory.onStopEntityTracking(this.field_219461_c, p_219454_1_); - } - - public void func_219455_b(ServerPlayerEntity p_219455_1_) { - this.func_219452_a(p_219455_1_.field_71135_a::func_147359_a); - this.field_219461_c.func_184178_b(p_219455_1_); - p_219455_1_.func_184848_d(this.field_219461_c); -+ net.minecraftforge.event.ForgeEventFactory.onStartEntityTracking(this.field_219461_c, p_219455_1_); - } - - public void func_219452_a(Consumer> p_219452_1_) { diff --git a/patches/minecraft/net/minecraft/world/World.java.patch b/patches/minecraft/net/minecraft/world/World.java.patch deleted file mode 100644 index f910871ed1..0000000000 --- a/patches/minecraft/net/minecraft/world/World.java.patch +++ /dev/null @@ -1,403 +0,0 @@ ---- a/net/minecraft/world/World.java -+++ b/net/minecraft/world/World.java -@@ -63,7 +_,7 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; - --public abstract class World implements IWorld, AutoCloseable { -+public abstract class World extends net.minecraftforge.common.capabilities.CapabilityProvider implements IWorld, AutoCloseable, net.minecraftforge.common.extensions.IForgeWorld { - protected static final Logger field_195596_d = LogManager.getLogger(); - public static final Codec> field_234917_f_ = ResourceLocation.field_240908_a_.xmap(RegistryKey.func_240902_a_(Registry.field_239699_ae_), RegistryKey::func_240901_a_); - public static final RegistryKey field_234918_g_ = RegistryKey.func_240903_a_(Registry.field_239699_ae_, new ResourceLocation("overworld")); -@@ -73,7 +_,7 @@ - public final List field_147482_g = Lists.newArrayList(); - public final List field_175730_i = Lists.newArrayList(); - protected final List field_147484_a = Lists.newArrayList(); -- protected final List field_147483_b = Lists.newArrayList(); -+ protected final java.util.Set field_147483_b = java.util.Collections.newSetFromMap(new java.util.IdentityHashMap<>()); // Forge: faster "contains" makes removal much more efficient - private final Thread field_217407_c; - private final boolean field_234916_c_; - private int field_73008_k; -@@ -92,8 +_,12 @@ - private final WorldBorder field_175728_M; - private final BiomeManager field_226689_w_; - private final RegistryKey field_73011_w; -+ public boolean restoringBlockSnapshots = false; -+ public boolean captureBlockSnapshots = false; -+ public java.util.ArrayList capturedBlockSnapshots = new java.util.ArrayList<>(); - - protected World(ISpawnWorldInfo p_i241925_1_, RegistryKey p_i241925_2_, final DimensionType p_i241925_3_, Supplier p_i241925_4_, boolean p_i241925_5_, boolean p_i241925_6_, long p_i241925_7_) { -+ super(World.class); - this.field_72984_F = p_i241925_4_; - this.field_72986_A = p_i241925_1_; - this.field_234921_x_ = p_i241925_3_; -@@ -180,17 +_,45 @@ - } else { - Chunk chunk = this.func_175726_f(p_241211_1_); - Block block = p_241211_2_.func_177230_c(); -+ -+ p_241211_1_ = p_241211_1_.func_185334_h(); // Forge - prevent mutable BlockPos leaks -+ net.minecraftforge.common.util.BlockSnapshot blockSnapshot = null; -+ if (this.captureBlockSnapshots && !this.field_72995_K) { -+ blockSnapshot = net.minecraftforge.common.util.BlockSnapshot.create(this.field_73011_w, this, p_241211_1_, p_241211_3_); -+ this.capturedBlockSnapshots.add(blockSnapshot); -+ } -+ -+ BlockState old = func_180495_p(p_241211_1_); -+ int oldLight = old.getLightValue(this, p_241211_1_); -+ int oldOpacity = old.func_200016_a(this, p_241211_1_); -+ - BlockState blockstate = chunk.func_177436_a(p_241211_1_, p_241211_2_, (p_241211_3_ & 64) != 0); - if (blockstate == null) { -+ if (blockSnapshot != null) this.capturedBlockSnapshots.remove(blockSnapshot); - return false; - } else { - BlockState blockstate1 = this.func_180495_p(p_241211_1_); -- if ((p_241211_3_ & 128) == 0 && blockstate1 != blockstate && (blockstate1.func_200016_a(this, p_241211_1_) != blockstate.func_200016_a(this, p_241211_1_) || blockstate1.func_185906_d() != blockstate.func_185906_d() || blockstate1.func_215691_g() || blockstate.func_215691_g())) { -+ if ((p_241211_3_ & 128) == 0 && blockstate1 != blockstate && (blockstate1.func_200016_a(this, p_241211_1_) != oldOpacity || blockstate1.getLightValue(this, p_241211_1_) != oldLight || blockstate1.func_215691_g() || blockstate.func_215691_g())) { - this.func_217381_Z().func_76320_a("queueCheckLight"); - this.func_72863_F().func_212863_j_().func_215568_a(p_241211_1_); - this.func_217381_Z().func_76319_b(); - } - -+ if (blockSnapshot == null) { // Don't notify clients or update physics while capturing blockstates -+ this.markAndNotifyBlock(p_241211_1_, chunk, blockstate, p_241211_2_, p_241211_3_, p_241211_4_); -+ } -+ return true; -+ } -+ } -+ } -+ -+ // Split off from original setBlockState(BlockPos, BlockState, int, int) method in order to directly send client and physic updates -+ public void markAndNotifyBlock(BlockPos p_241211_1_, @Nullable Chunk chunk, BlockState blockstate, BlockState p_241211_2_, int p_241211_3_, int p_241211_4_) -+ { -+ Block block = p_241211_2_.func_177230_c(); -+ BlockState blockstate1 = func_180495_p(p_241211_1_); -+ { -+ { - if (blockstate1 == p_241211_2_) { - if (blockstate != blockstate1) { - this.func_225319_b(p_241211_1_, blockstate, blockstate1); -@@ -216,8 +_,6 @@ - - this.func_217393_a(p_241211_1_, blockstate, blockstate1); - } -- -- return true; - } - } - } -@@ -232,7 +_,7 @@ - - public boolean func_241212_a_(BlockPos p_241212_1_, boolean p_241212_2_, @Nullable Entity p_241212_3_, int p_241212_4_) { - BlockState blockstate = this.func_180495_p(p_241212_1_); -- if (blockstate.func_196958_f()) { -+ if (blockstate.isAir(this, p_241212_1_)) { - return false; - } else { - FluidState fluidstate = this.func_204610_c(p_241212_1_); -@@ -241,7 +_,7 @@ - } - - if (p_241212_2_) { -- TileEntity tileentity = blockstate.func_177230_c().func_235695_q_() ? this.func_175625_s(p_241212_1_) : null; -+ TileEntity tileentity = blockstate.hasTileEntity() ? this.func_175625_s(p_241212_1_) : null; - Block.func_220054_a(blockstate, this, p_241212_1_, tileentity, p_241212_3_, ItemStack.field_190927_a); - } - -@@ -259,6 +_,8 @@ - } - - public void func_195593_d(BlockPos p_195593_1_, Block p_195593_2_) { -+ if (net.minecraftforge.event.ForgeEventFactory.onNeighborNotify(this, p_195593_1_, this.func_180495_p(p_195593_1_), java.util.EnumSet.allOf(Direction.class), false).isCanceled()) -+ return; - this.func_190524_a(p_195593_1_.func_177976_e(), p_195593_2_, p_195593_1_); - this.func_190524_a(p_195593_1_.func_177974_f(), p_195593_2_, p_195593_1_); - this.func_190524_a(p_195593_1_.func_177977_b(), p_195593_2_, p_195593_1_); -@@ -268,6 +_,11 @@ - } - - public void func_175695_a(BlockPos p_175695_1_, Block p_175695_2_, Direction p_175695_3_) { -+ java.util.EnumSet directions = java.util.EnumSet.allOf(Direction.class); -+ directions.remove(p_175695_3_); -+ if (net.minecraftforge.event.ForgeEventFactory.onNeighborNotify(this, p_175695_1_, this.func_180495_p(p_175695_1_), directions, false).isCanceled()) -+ return; -+ - if (p_175695_3_ != Direction.WEST) { - this.func_190524_a(p_175695_1_.func_177976_e(), p_175695_2_, p_175695_1_); - } -@@ -305,9 +_,9 @@ - CrashReportCategory crashreportcategory = crashreport.func_85058_a("Block being updated"); - crashreportcategory.func_189529_a("Source block type", () -> { - try { -- return String.format("ID #%s (%s // %s)", Registry.field_212618_g.func_177774_c(p_190524_2_), p_190524_2_.func_149739_a(), p_190524_2_.getClass().getCanonicalName()); -+ return String.format("ID #%s (%s // %s)", p_190524_2_.getRegistryName(), p_190524_2_.func_149739_a(), p_190524_2_.getClass().getCanonicalName()); - } catch (Throwable throwable1) { -- return "ID #" + Registry.field_212618_g.func_177774_c(p_190524_2_); -+ return "ID #" + p_190524_2_.getRegistryName(); - } - }); - CrashReportCategory.func_175750_a(crashreportcategory, p_190524_1_, blockstate); -@@ -391,10 +_,12 @@ - } - - public boolean func_175700_a(TileEntity p_175700_1_) { -+ if (p_175700_1_.func_145831_w() != this) p_175700_1_.func_226984_a_(this, p_175700_1_.func_174877_v()); // Forge - set the world early as vanilla doesn't set it until next tick - if (this.field_147481_N) { - field_195596_d.error("Adding block entity while ticking: {} @ {}", () -> { - return Registry.field_212626_o.func_177774_c(p_175700_1_.func_200662_C()); - }, p_175700_1_::func_174877_v); -+ return field_147484_a.add(p_175700_1_); // Forge: wait to add new TE if we're currently processing existing ones - } - - boolean flag = this.field_147482_g.add(p_175700_1_); -@@ -402,6 +_,8 @@ - this.field_175730_i.add(p_175700_1_); - } - -+ p_175700_1_.onLoad(); -+ - if (this.field_72995_K) { - BlockPos blockpos = p_175700_1_.func_174877_v(); - BlockState blockstate = this.func_180495_p(blockpos); -@@ -413,6 +_,7 @@ - - public void func_147448_a(Collection p_147448_1_) { - if (this.field_147481_N) { -+ p_147448_1_.stream().filter(te -> te.func_145831_w() != this).forEach(te -> te.func_226984_a_(this, te.func_174877_v())); // Forge - set the world early as vanilla doesn't set it until next tick - this.field_147484_a.addAll(p_147448_1_); - } else { - for(TileEntity tileentity : p_147448_1_) { -@@ -425,13 +_,14 @@ - public void func_217391_K() { - IProfiler iprofiler = this.func_217381_Z(); - iprofiler.func_76320_a("blockEntities"); -+ this.field_147481_N = true;// Forge: Move above remove to prevent CMEs - if (!this.field_147483_b.isEmpty()) { -+ this.field_147483_b.forEach(e -> e.onChunkUnloaded()); - this.field_175730_i.removeAll(this.field_147483_b); - this.field_147482_g.removeAll(this.field_147483_b); - this.field_147483_b.clear(); - } - -- this.field_147481_N = true; - Iterator iterator = this.field_175730_i.iterator(); - - while(iterator.hasNext()) { -@@ -440,8 +_,9 @@ - BlockPos blockpos = tileentity.func_174877_v(); - if (this.func_72863_F().func_222866_a(blockpos) && this.func_175723_af().func_177746_a(blockpos)) { - try { -+ net.minecraftforge.server.timings.TimeTracker.TILE_ENTITY_UPDATE.trackStart(tileentity); - iprofiler.func_194340_a(() -> { -- return String.valueOf((Object)TileEntityType.func_200969_a(tileentity.func_200662_C())); -+ return String.valueOf(tileentity.func_200662_C().getRegistryName()); - }); - if (tileentity.func_200662_C().func_223045_a(this.func_180495_p(blockpos).func_177230_c())) { - ((ITickableTileEntity)tileentity).func_73660_a(); -@@ -454,8 +_,16 @@ - CrashReport crashreport = CrashReport.func_85055_a(throwable, "Ticking block entity"); - CrashReportCategory crashreportcategory = crashreport.func_85058_a("Block entity being ticked"); - tileentity.func_145828_a(crashreportcategory); -+ if (net.minecraftforge.common.ForgeConfig.SERVER.removeErroringTileEntities.get()) { -+ LogManager.getLogger().fatal("{}", crashreport.func_71502_e()); -+ tileentity.func_145843_s(); -+ this.func_175713_t(tileentity.func_174877_v()); -+ } else - throw new ReportedException(crashreport); - } -+ finally { -+ net.minecraftforge.server.timings.TimeTracker.TILE_ENTITY_UPDATE.trackEnd(tileentity); -+ } - } - } - -@@ -463,7 +_,10 @@ - iterator.remove(); - this.field_147482_g.remove(tileentity); - if (this.func_175667_e(tileentity.func_174877_v())) { -- this.func_175726_f(tileentity.func_174877_v()).func_177425_e(tileentity.func_174877_v()); -+ //Forge: Bugfix: If we set the tile entity it immediately sets it in the chunk, so we could be desyned -+ Chunk chunk = this.func_175726_f(tileentity.func_174877_v()); -+ if (chunk.func_177424_a(tileentity.func_174877_v(), Chunk.CreateEntityType.CHECK) == tileentity) -+ chunk.func_177425_e(tileentity.func_174877_v()); - } - } - } -@@ -495,12 +_,15 @@ - - public void func_217390_a(Consumer p_217390_1_, Entity p_217390_2_) { - try { -+ net.minecraftforge.server.timings.TimeTracker.ENTITY_UPDATE.trackStart(p_217390_2_); - p_217390_1_.accept(p_217390_2_); - } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.func_85055_a(throwable, "Ticking entity"); - CrashReportCategory crashreportcategory = crashreport.func_85058_a("Entity being ticked"); - p_217390_2_.func_85029_a(crashreportcategory); - throw new ReportedException(crashreport); -+ } finally { -+ net.minecraftforge.server.timings.TimeTracker.ENTITY_UPDATE.trackEnd(p_217390_2_); - } - } - -@@ -514,6 +_,7 @@ - - public Explosion func_230546_a_(@Nullable Entity p_230546_1_, @Nullable DamageSource p_230546_2_, @Nullable ExplosionContext p_230546_3_, double p_230546_4_, double p_230546_6_, double p_230546_8_, float p_230546_10_, boolean p_230546_11_, Explosion.Mode p_230546_12_) { - Explosion explosion = new Explosion(this, p_230546_1_, p_230546_2_, p_230546_3_, p_230546_4_, p_230546_6_, p_230546_8_, p_230546_10_, p_230546_11_, p_230546_12_); -+ if (net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this, explosion)) return explosion; - explosion.func_77278_a(); - explosion.func_77279_a(true); - return explosion; -@@ -561,6 +_,7 @@ - - public void func_175690_a(BlockPos p_175690_1_, @Nullable TileEntity p_175690_2_) { - if (!func_189509_E(p_175690_1_)) { -+ p_175690_1_ = p_175690_1_.func_185334_h(); // Forge - prevent mutable BlockPos leaks - if (p_175690_2_ != null && !p_175690_2_.func_145837_r()) { - if (this.field_147481_N) { - p_175690_2_.func_226984_a_(this, p_175690_1_); -@@ -576,7 +_,8 @@ - - this.field_147484_a.add(p_175690_2_); - } else { -- this.func_175726_f(p_175690_1_).func_177426_a(p_175690_1_, p_175690_2_); -+ Chunk chunk = this.func_175726_f(p_175690_1_); -+ if (chunk != null) chunk.func_177426_a(p_175690_1_, p_175690_2_); - this.func_175700_a(p_175690_2_); - } - } -@@ -589,6 +_,8 @@ - if (tileentity != null && this.field_147481_N) { - tileentity.func_145843_s(); - this.field_147484_a.remove(tileentity); -+ if (!(tileentity instanceof ITickableTileEntity)) //Forge: If they are not tickable they wont be removed in the update loop. -+ this.field_147482_g.remove(tileentity); - } else { - if (tileentity != null) { - this.field_147484_a.remove(tileentity); -@@ -598,7 +_,7 @@ - - this.func_175726_f(p_175713_1_).func_177425_e(p_175713_1_); - } -- -+ this.func_175666_e(p_175713_1_, func_180495_p(p_175713_1_).func_177230_c()); //Notify neighbors of changes - } - - public boolean func_195588_v(BlockPos p_195588_1_) { -@@ -651,10 +_,10 @@ - public List func_175674_a(@Nullable Entity p_175674_1_, AxisAlignedBB p_175674_2_, @Nullable Predicate p_175674_3_) { - this.func_217381_Z().func_230035_c_("getEntities"); - List list = Lists.newArrayList(); -- int i = MathHelper.func_76128_c((p_175674_2_.field_72340_a - 2.0D) / 16.0D); -- int j = MathHelper.func_76128_c((p_175674_2_.field_72336_d + 2.0D) / 16.0D); -- int k = MathHelper.func_76128_c((p_175674_2_.field_72339_c - 2.0D) / 16.0D); -- int l = MathHelper.func_76128_c((p_175674_2_.field_72334_f + 2.0D) / 16.0D); -+ int i = MathHelper.func_76128_c((p_175674_2_.field_72340_a - getMaxEntityRadius()) / 16.0D); -+ int j = MathHelper.func_76128_c((p_175674_2_.field_72336_d + getMaxEntityRadius()) / 16.0D); -+ int k = MathHelper.func_76128_c((p_175674_2_.field_72339_c - getMaxEntityRadius()) / 16.0D); -+ int l = MathHelper.func_76128_c((p_175674_2_.field_72334_f + getMaxEntityRadius()) / 16.0D); - AbstractChunkProvider abstractchunkprovider = this.func_72863_F(); - - for(int i1 = i; i1 <= j; ++i1) { -@@ -671,10 +_,10 @@ - - public List func_217394_a(@Nullable EntityType p_217394_1_, AxisAlignedBB p_217394_2_, Predicate p_217394_3_) { - this.func_217381_Z().func_230035_c_("getEntities"); -- int i = MathHelper.func_76128_c((p_217394_2_.field_72340_a - 2.0D) / 16.0D); -- int j = MathHelper.func_76143_f((p_217394_2_.field_72336_d + 2.0D) / 16.0D); -- int k = MathHelper.func_76128_c((p_217394_2_.field_72339_c - 2.0D) / 16.0D); -- int l = MathHelper.func_76143_f((p_217394_2_.field_72334_f + 2.0D) / 16.0D); -+ int i = MathHelper.func_76128_c((p_217394_2_.field_72340_a - getMaxEntityRadius()) / 16.0D); -+ int j = MathHelper.func_76143_f((p_217394_2_.field_72336_d + getMaxEntityRadius()) / 16.0D); -+ int k = MathHelper.func_76128_c((p_217394_2_.field_72339_c - getMaxEntityRadius()) / 16.0D); -+ int l = MathHelper.func_76143_f((p_217394_2_.field_72334_f + getMaxEntityRadius()) / 16.0D); - List list = Lists.newArrayList(); - - for(int i1 = i; i1 < j; ++i1) { -@@ -691,10 +_,10 @@ - - public List func_175647_a(Class p_175647_1_, AxisAlignedBB p_175647_2_, @Nullable Predicate p_175647_3_) { - this.func_217381_Z().func_230035_c_("getEntities"); -- int i = MathHelper.func_76128_c((p_175647_2_.field_72340_a - 2.0D) / 16.0D); -- int j = MathHelper.func_76143_f((p_175647_2_.field_72336_d + 2.0D) / 16.0D); -- int k = MathHelper.func_76128_c((p_175647_2_.field_72339_c - 2.0D) / 16.0D); -- int l = MathHelper.func_76143_f((p_175647_2_.field_72334_f + 2.0D) / 16.0D); -+ int i = MathHelper.func_76128_c((p_175647_2_.field_72340_a - getMaxEntityRadius()) / 16.0D); -+ int j = MathHelper.func_76143_f((p_175647_2_.field_72336_d + getMaxEntityRadius()) / 16.0D); -+ int k = MathHelper.func_76128_c((p_175647_2_.field_72339_c - getMaxEntityRadius()) / 16.0D); -+ int l = MathHelper.func_76143_f((p_175647_2_.field_72334_f + getMaxEntityRadius()) / 16.0D); - List list = Lists.newArrayList(); - AbstractChunkProvider abstractchunkprovider = this.func_72863_F(); - -@@ -712,10 +_,10 @@ - - public List func_225316_b(Class p_225316_1_, AxisAlignedBB p_225316_2_, @Nullable Predicate p_225316_3_) { - this.func_217381_Z().func_230035_c_("getLoadedEntities"); -- int i = MathHelper.func_76128_c((p_225316_2_.field_72340_a - 2.0D) / 16.0D); -- int j = MathHelper.func_76143_f((p_225316_2_.field_72336_d + 2.0D) / 16.0D); -- int k = MathHelper.func_76128_c((p_225316_2_.field_72339_c - 2.0D) / 16.0D); -- int l = MathHelper.func_76143_f((p_225316_2_.field_72334_f + 2.0D) / 16.0D); -+ int i = MathHelper.func_76128_c((p_225316_2_.field_72340_a - getMaxEntityRadius()) / 16.0D); -+ int j = MathHelper.func_76143_f((p_225316_2_.field_72336_d + getMaxEntityRadius()) / 16.0D); -+ int k = MathHelper.func_76128_c((p_225316_2_.field_72339_c - getMaxEntityRadius()) / 16.0D); -+ int l = MathHelper.func_76143_f((p_225316_2_.field_72334_f + getMaxEntityRadius()) / 16.0D); - List list = Lists.newArrayList(); - AbstractChunkProvider abstractchunkprovider = this.func_72863_F(); - -@@ -739,6 +_,7 @@ - this.func_175726_f(p_175646_1_).func_76630_e(); - } - -+ this.func_175666_e(p_175646_1_, func_180495_p(p_175646_1_).func_177230_c()); //Notify neighbors of changes - } - - public int func_181545_F() { -@@ -783,7 +_,7 @@ - public int func_175651_c(BlockPos p_175651_1_, Direction p_175651_2_) { - BlockState blockstate = this.func_180495_p(p_175651_1_); - int i = blockstate.func_185911_a(this, p_175651_1_, p_175651_2_); -- return blockstate.func_215686_e(this, p_175651_1_) ? Math.max(i, this.func_175676_y(p_175651_1_)) : i; -+ return blockstate.shouldCheckWeakPower(this, p_175651_1_, p_175651_2_) ? Math.max(i, this.func_175676_y(p_175651_1_)) : i; - } - - public boolean func_175640_z(BlockPos p_175640_1_) { -@@ -938,16 +_,15 @@ - public abstract Scoreboard func_96441_U(); - - public void func_175666_e(BlockPos p_175666_1_, Block p_175666_2_) { -- for(Direction direction : Direction.Plane.HORIZONTAL) { -+ for(Direction direction : Direction.values()) { - BlockPos blockpos = p_175666_1_.func_177972_a(direction); - if (this.func_175667_e(blockpos)) { - BlockState blockstate = this.func_180495_p(blockpos); -- if (blockstate.func_203425_a(Blocks.field_196762_fd)) { -- blockstate.func_215697_a(this, blockpos, p_175666_2_, p_175666_1_, false); -- } else if (blockstate.func_215686_e(this, blockpos)) { -+ blockstate.onNeighborChange(this, blockpos, p_175666_1_); -+ if (blockstate.func_215686_e(this, blockpos)) { - blockpos = blockpos.func_177972_a(direction); - blockstate = this.func_180495_p(blockpos); -- if (blockstate.func_203425_a(Blocks.field_196762_fd)) { -+ if (blockstate.getWeakChanges(this, blockpos)) { - blockstate.func_215697_a(this, blockpos, p_175666_2_, p_175666_1_, false); - } - } -@@ -1022,6 +_,18 @@ - - public BiomeManager func_225523_d_() { - return this.field_226689_w_; -+ } -+ -+ private double maxEntityRadius = 2.0D; -+ @Override -+ public double getMaxEntityRadius() { -+ return maxEntityRadius; -+ } -+ @Override -+ public double increaseMaxEntityRadius(double value) { -+ if (value > maxEntityRadius) -+ maxEntityRadius = value; -+ return maxEntityRadius; - } - - public final boolean func_234925_Z_() { diff --git a/patches/minecraft/net/minecraft/world/WorldSettings.java.patch b/patches/minecraft/net/minecraft/world/WorldSettings.java.patch deleted file mode 100644 index 9432c5ff44..0000000000 --- a/patches/minecraft/net/minecraft/world/WorldSettings.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/world/WorldSettings.java -+++ b/net/minecraft/world/WorldSettings.java -@@ -62,6 +_,7 @@ - } - - public WorldSettings func_234948_a_(Difficulty p_234948_1_) { -+ net.minecraftforge.common.ForgeHooks.onDifficultyChange(p_234948_1_, this.field_234944_d_); - return new WorldSettings(this.field_234943_a_, this.field_77172_b, this.field_77170_d, p_234948_1_, this.field_77168_f, this.field_234945_f_, this.field_234946_g_); - } - diff --git a/patches/minecraft/net/minecraft/world/biome/Biome.java.patch b/patches/minecraft/net/minecraft/world/biome/Biome.java.patch deleted file mode 100644 index 598f090bb8..0000000000 --- a/patches/minecraft/net/minecraft/world/biome/Biome.java.patch +++ /dev/null @@ -1,31 +0,0 @@ ---- a/net/minecraft/world/biome/Biome.java -+++ b/net/minecraft/world/biome/Biome.java -@@ -53,7 +_,7 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; - --public final class Biome { -+public final class Biome extends net.minecraftforge.registries.ForgeRegistryEntry.UncheckedRegistryEntry { - public static final Logger field_150586_aC = LogManager.getLogger(); - public static final Codec field_242418_b = RecordCodecBuilder.create((p_235064_0_) -> { - return p_235064_0_.group(Biome.Climate.field_242459_a.forGetter((p_242446_0_) -> { -@@ -70,7 +_,9 @@ - return p_242443_0_.field_242424_k; - }), MobSpawnInfo.field_242552_c.forGetter((p_242442_0_) -> { - return p_242442_0_.field_242425_l; -- })).apply(p_235064_0_, Biome::new); -+ }), ResourceLocation.field_240908_a_.optionalFieldOf("forge:registry_name").forGetter(b -> Optional.ofNullable(b.getRegistryName()))) -+ .apply(p_235064_0_, (climate, category, depth, scale, effects, gen, spawns, name) -> -+ net.minecraftforge.common.ForgeHooks.enhanceBiome(name.orElse(null), climate, category, depth, scale, effects, gen, spawns, p_235064_0_, Biome::new)); - }); - public static final Codec field_242419_c = RecordCodecBuilder.create((p_242432_0_) -> { - return p_242432_0_.group(Biome.Climate.field_242459_a.forGetter((p_242441_0_) -> { -@@ -200,7 +_,7 @@ - } else { - if (p_201850_2_.func_177956_o() >= 0 && p_201850_2_.func_177956_o() < 256 && p_201850_1_.func_226658_a_(LightType.BLOCK, p_201850_2_) < 10) { - BlockState blockstate = p_201850_1_.func_180495_p(p_201850_2_); -- if (blockstate.func_196958_f() && Blocks.field_150433_aE.func_176223_P().func_196955_c(p_201850_1_, p_201850_2_)) { -+ if (blockstate.isAir(p_201850_1_, p_201850_2_) && Blocks.field_150433_aE.func_176223_P().func_196955_c(p_201850_1_, p_201850_2_)) { - return true; - } - } diff --git a/patches/minecraft/net/minecraft/world/biome/BiomeAmbience.java.patch b/patches/minecraft/net/minecraft/world/biome/BiomeAmbience.java.patch deleted file mode 100644 index ab4066dbca..0000000000 --- a/patches/minecraft/net/minecraft/world/biome/BiomeAmbience.java.patch +++ /dev/null @@ -1,50 +0,0 @@ ---- a/net/minecraft/world/biome/BiomeAmbience.java -+++ b/net/minecraft/world/biome/BiomeAmbience.java -@@ -204,7 +_,7 @@ - } - } - -- public static enum GrassColorModifier implements IStringSerializable { -+ public static enum GrassColorModifier implements IStringSerializable, net.minecraftforge.common.IExtensibleEnum { - NONE("none") { - @OnlyIn(Dist.CLIENT) - public int func_241853_a(double p_241853_1_, double p_241853_3_, int p_241853_5_) { -@@ -226,18 +_,36 @@ - }; - - private final String field_242543_e; -- public static final Codec field_242542_d = IStringSerializable.func_233023_a_(BiomeAmbience.GrassColorModifier::values, BiomeAmbience.GrassColorModifier::func_242546_a); -+ public static final Codec field_242542_d = net.minecraftforge.common.IExtensibleEnum.createCodecForExtensibleEnum(BiomeAmbience.GrassColorModifier::values, BiomeAmbience.GrassColorModifier::func_242546_a); - private static final Map field_242544_f = Arrays.stream(values()).collect(Collectors.toMap(BiomeAmbience.GrassColorModifier::func_242547_b, (p_242545_0_) -> { - return p_242545_0_; - })); - - @OnlyIn(Dist.CLIENT) -- public abstract int func_241853_a(double p_241853_1_, double p_241853_3_, int p_241853_5_); -+ public int func_241853_a(double p_241853_1_, double p_241853_3_, int p_241853_5_) { -+ return delegate.modifyGrassColor(p_241853_1_, p_241853_3_, p_241853_5_); -+ } - - private GrassColorModifier(String p_i241940_3_) { - this.field_242543_e = p_i241940_3_; - } - -+ private ColorModifier delegate; -+ private GrassColorModifier(String name, ColorModifier delegate) { -+ this(name); -+ this.delegate = delegate; -+ } -+ public static GrassColorModifier create(String name, String id, ColorModifier delegate) { -+ throw new IllegalStateException("Enum not extended"); -+ } -+ @Override -+ public void init() { -+ field_242544_f.put(this.func_242547_b(), this); -+ } -+ @FunctionalInterface -+ public interface ColorModifier { -+ int modifyGrassColor(double x, double z, int color); -+ } - public String func_242547_b() { - return this.field_242543_e; - } diff --git a/patches/minecraft/net/minecraft/world/biome/BiomeGenerationSettings.java.patch b/patches/minecraft/net/minecraft/world/biome/BiomeGenerationSettings.java.patch deleted file mode 100644 index c3ff059fdf..0000000000 --- a/patches/minecraft/net/minecraft/world/biome/BiomeGenerationSettings.java.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- a/net/minecraft/world/biome/BiomeGenerationSettings.java -+++ b/net/minecraft/world/biome/BiomeGenerationSettings.java -@@ -47,6 +_,7 @@ - }); - private final Supplier> field_242482_d; - private final Map>>> field_242483_e; -+ private final java.util.Set carversView; - private final List>>> field_242484_f; - private final List>> field_242485_g; - private final List> field_242486_h; -@@ -59,10 +_,15 @@ - this.field_242486_h = p_i241935_3_.stream().flatMap(Collection::stream).map(Supplier::get).flatMap(ConfiguredFeature::func_242768_d).filter((p_242490_0_) -> { - return p_242490_0_.field_222737_a == Feature.field_227247_y_; - }).collect(ImmutableList.toImmutableList()); -+ this.carversView = java.util.Collections.unmodifiableSet(field_242483_e.keySet()); - } - - public List>> func_242489_a(GenerationStage.Carving p_242489_1_) { - return this.field_242483_e.getOrDefault(p_242489_1_, ImmutableList.of()); -+ } -+ -+ public java.util.Set getCarvingStages() { -+ return this.carversView; - } - - public boolean func_242493_a(Structure p_242493_1_) { diff --git a/patches/minecraft/net/minecraft/world/biome/BiomeRegistry.java.patch b/patches/minecraft/net/minecraft/world/biome/BiomeRegistry.java.patch deleted file mode 100644 index 1ea2a23f5a..0000000000 --- a/patches/minecraft/net/minecraft/world/biome/BiomeRegistry.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/biome/BiomeRegistry.java -+++ b/net/minecraft/world/biome/BiomeRegistry.java -@@ -17,7 +_,7 @@ - } - - public static RegistryKey func_244203_a(int p_244203_0_) { -- return field_244202_c.get(p_244203_0_); -+ return ((net.minecraftforge.registries.ForgeRegistry)net.minecraftforge.registries.ForgeRegistries.BIOMES).getKey(p_244203_0_); - } - - static { diff --git a/patches/minecraft/net/minecraft/world/biome/MobSpawnInfo.java.patch b/patches/minecraft/net/minecraft/world/biome/MobSpawnInfo.java.patch deleted file mode 100644 index 55e992eb85..0000000000 --- a/patches/minecraft/net/minecraft/world/biome/MobSpawnInfo.java.patch +++ /dev/null @@ -1,36 +0,0 @@ ---- a/net/minecraft/world/biome/MobSpawnInfo.java -+++ b/net/minecraft/world/biome/MobSpawnInfo.java -@@ -42,21 +_,33 @@ - private final Map> field_242554_e; - private final Map, MobSpawnInfo.SpawnCosts> field_242555_f; - private final boolean field_242556_g; -+ private final java.util.Set typesView; -+ private final java.util.Set> costView; - - private MobSpawnInfo(float p_i241946_1_, Map> p_i241946_2_, Map, MobSpawnInfo.SpawnCosts> p_i241946_3_, boolean p_i241946_4_) { - this.field_242553_d = p_i241946_1_; - this.field_242554_e = p_i241946_2_; - this.field_242555_f = p_i241946_3_; - this.field_242556_g = p_i241946_4_; -+ this.typesView = java.util.Collections.unmodifiableSet(this.field_242554_e.keySet()); -+ this.costView = java.util.Collections.unmodifiableSet(this.field_242555_f.keySet()); - } - - public List func_242559_a(EntityClassification p_242559_1_) { - return this.field_242554_e.getOrDefault(p_242559_1_, ImmutableList.of()); - } - -+ public java.util.Set getSpawnerTypes() { -+ return this.typesView; -+ } -+ - @Nullable - public MobSpawnInfo.SpawnCosts func_242558_a(EntityType p_242558_1_) { - return this.field_242555_f.get(p_242558_1_); -+ } -+ -+ public java.util.Set> getEntityTypes() { -+ return this.costView; - } - - public float func_242557_a() { diff --git a/patches/minecraft/net/minecraft/world/biome/provider/OverworldBiomeProvider.java.patch b/patches/minecraft/net/minecraft/world/biome/provider/OverworldBiomeProvider.java.patch deleted file mode 100644 index 1b007c303d..0000000000 --- a/patches/minecraft/net/minecraft/world/biome/provider/OverworldBiomeProvider.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/biome/provider/OverworldBiomeProvider.java -+++ b/net/minecraft/world/biome/provider/OverworldBiomeProvider.java -@@ -35,7 +_,7 @@ - private final Registry field_242636_k; - - public OverworldBiomeProvider(long p_i241958_1_, boolean p_i241958_3_, boolean p_i241958_4_, Registry p_i241958_5_) { -- super(field_226847_e_.stream().map((p_242638_1_) -> { -+ super(java.util.stream.Stream.concat(field_226847_e_.stream(), net.minecraftforge.common.BiomeManager.getAdditionalOverworldBiomes().stream()).map((p_242638_1_) -> { - return () -> { - return p_i241958_5_.func_243576_d(p_242638_1_); - }; diff --git a/patches/minecraft/net/minecraft/world/border/WorldBorder.java.patch b/patches/minecraft/net/minecraft/world/border/WorldBorder.java.patch deleted file mode 100644 index e36afa8eaa..0000000000 --- a/patches/minecraft/net/minecraft/world/border/WorldBorder.java.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/net/minecraft/world/border/WorldBorder.java -+++ b/net/minecraft/world/border/WorldBorder.java -@@ -136,6 +_,10 @@ - this.field_177758_a.add(p_177737_1_); - } - -+ public void removeListener(IBorderListener listener) { -+ this.field_177758_a.remove(listener); -+ } -+ - public void func_177725_a(int p_177725_1_) { - this.field_177762_h = p_177725_1_; - this.field_212674_i.func_212652_j(); diff --git a/patches/minecraft/net/minecraft/world/chunk/Chunk.java.patch b/patches/minecraft/net/minecraft/world/chunk/Chunk.java.patch deleted file mode 100644 index 7e008ec1af..0000000000 --- a/patches/minecraft/net/minecraft/world/chunk/Chunk.java.patch +++ /dev/null @@ -1,247 +0,0 @@ ---- a/net/minecraft/world/chunk/Chunk.java -+++ b/net/minecraft/world/chunk/Chunk.java -@@ -58,7 +_,7 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; - --public class Chunk implements IChunk { -+public class Chunk extends net.minecraftforge.common.capabilities.CapabilityProvider implements IChunk, net.minecraftforge.common.extensions.IForgeChunk { - private static final Logger field_150817_t = LogManager.getLogger(); - @Nullable - public static final ChunkSection field_186036_a = null; -@@ -92,6 +_,7 @@ - } - - public Chunk(World p_i225781_1_, ChunkPos p_i225781_2_, BiomeContainer p_i225781_3_, UpgradeData p_i225781_4_, ITickList p_i225781_5_, ITickList p_i225781_6_, long p_i225781_7_, @Nullable ChunkSection[] p_i225781_9_, @Nullable Consumer p_i225781_10_) { -+ super(Chunk.class); - this.field_76645_j = new ClassInheritanceMultiMap[16]; - this.field_76637_e = p_i225781_1_; - this.field_212816_F = p_i225781_2_; -@@ -119,7 +_,7 @@ - field_150817_t.warn("Could not set level chunk sections, array length is {} instead of {}", p_i225781_9_.length, this.field_76652_q.length); - } - } -- -+ this.gatherCapabilities(); - } - - public Chunk(World p_i49947_1_, ChunkPrimer p_i49947_2_) { -@@ -264,28 +_,28 @@ - - if (!this.field_76637_e.field_72995_K) { - blockstate.func_196947_b(this.field_76637_e, p_177436_1_, p_177436_2_, p_177436_3_); -- } else if (block1 != block && block1 instanceof ITileEntityProvider) { -+ } else if ((block1 != block || !p_177436_2_.hasTileEntity()) && blockstate.hasTileEntity()) { - this.field_76637_e.func_175713_t(p_177436_1_); - } - - if (!chunksection.func_177485_a(i, j & 15, k).func_203425_a(block)) { - return null; - } else { -- if (block1 instanceof ITileEntityProvider) { -+ if (blockstate.hasTileEntity()) { - TileEntity tileentity = this.func_177424_a(p_177436_1_, Chunk.CreateEntityType.CHECK); - if (tileentity != null) { - tileentity.func_145836_u(); - } - } - -- if (!this.field_76637_e.field_72995_K) { -+ if (!this.field_76637_e.field_72995_K && !this.field_76637_e.captureBlockSnapshots) { - p_177436_2_.func_215705_a(this.field_76637_e, p_177436_1_, blockstate, p_177436_3_); - } - -- if (block instanceof ITileEntityProvider) { -+ if (p_177436_2_.hasTileEntity()) { - TileEntity tileentity1 = this.func_177424_a(p_177436_1_, Chunk.CreateEntityType.CHECK); - if (tileentity1 == null) { -- tileentity1 = ((ITileEntityProvider)block).func_196283_a_(this.field_76637_e); -+ tileentity1 = p_177436_2_.createTileEntity(this.field_76637_e); - this.field_76637_e.func_175690_a(p_177436_1_, tileentity1); - } else { - tileentity1.func_145836_u(); -@@ -321,11 +_,13 @@ - k = this.field_76645_j.length - 1; - } - -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityEvent.EnteringChunk(p_76612_1_, this.field_212816_F.field_77276_a, this.field_212816_F.field_77275_b, p_76612_1_.field_70176_ah, p_76612_1_.field_70164_aj)); - p_76612_1_.field_70175_ag = true; - p_76612_1_.field_70176_ah = this.field_212816_F.field_77276_a; - p_76612_1_.field_70162_ai = k; - p_76612_1_.field_70164_aj = this.field_212816_F.field_77275_b; - this.field_76645_j[k].add(p_76612_1_); -+ this.func_76630_e(); // Forge - ensure chunks are marked to save after an entity add - } - - public void func_201607_a(Heightmap.Type p_201607_1_, long[] p_201607_2_) { -@@ -346,6 +_,7 @@ - } - - this.field_76645_j[p_76608_2_].remove(p_76608_1_); -+ this.func_76630_e(); // Forge - ensure chunks are marked to save after entity removals - } - - public int func_201576_a(Heightmap.Type p_201576_1_, int p_201576_2_, int p_201576_3_) { -@@ -356,7 +_,7 @@ - private TileEntity func_177422_i(BlockPos p_177422_1_) { - BlockState blockstate = this.func_180495_p(p_177422_1_); - Block block = blockstate.func_177230_c(); -- return !block.func_235695_q_() ? null : ((ITileEntityProvider)block).func_196283_a_(this.field_76637_e); -+ return !blockstate.hasTileEntity() ? null : blockstate.createTileEntity(this.field_76637_e); - } - - @Nullable -@@ -367,6 +_,10 @@ - @Nullable - public TileEntity func_177424_a(BlockPos p_177424_1_, Chunk.CreateEntityType p_177424_2_) { - TileEntity tileentity = this.field_150816_i.get(p_177424_1_); -+ if (tileentity != null && tileentity.func_145837_r()) { -+ field_150816_i.remove(p_177424_1_); -+ tileentity = null; -+ } - if (tileentity == null) { - CompoundNBT compoundnbt = this.field_201618_i.remove(p_177424_1_); - if (compoundnbt != null) { -@@ -382,9 +_,6 @@ - tileentity = this.func_177422_i(p_177424_1_); - this.field_76637_e.func_175690_a(p_177424_1_, tileentity); - } -- } else if (tileentity.func_145837_r()) { -- this.field_150816_i.remove(p_177424_1_); -- return null; - } - - return tileentity; -@@ -399,7 +_,7 @@ - } - - public void func_177426_a(BlockPos p_177426_1_, TileEntity p_177426_2_) { -- if (this.func_180495_p(p_177426_1_).func_177230_c() instanceof ITileEntityProvider) { -+ if (this.func_180495_p(p_177426_1_).hasTileEntity()) { - p_177426_2_.func_226984_a_(this.field_76637_e, p_177426_1_); - p_177426_2_.func_145829_t(); - TileEntity tileentity = this.field_150816_i.put(p_177426_1_.func_185334_h(), p_177426_2_); -@@ -418,9 +_,14 @@ - public CompoundNBT func_223134_j(BlockPos p_223134_1_) { - TileEntity tileentity = this.func_175625_s(p_223134_1_); - if (tileentity != null && !tileentity.func_145837_r()) { -+ try { - CompoundNBT compoundnbt1 = tileentity.func_189515_b(new CompoundNBT()); - compoundnbt1.func_74757_a("keepPacked", false); - return compoundnbt1; -+ } catch (Exception e) { -+ LogManager.getLogger().error("A TileEntity type {} has thrown an exception trying to write state. It will not persist, Report this to the mod author", tileentity.getClass().getName(), e); -+ return null; -+ } - } else { - CompoundNBT compoundnbt = this.field_201618_i.get(p_223134_1_); - if (compoundnbt != null) { -@@ -455,8 +_,8 @@ - } - - public void func_177414_a(@Nullable Entity p_177414_1_, AxisAlignedBB p_177414_2_, List p_177414_3_, @Nullable Predicate p_177414_4_) { -- int i = MathHelper.func_76128_c((p_177414_2_.field_72338_b - 2.0D) / 16.0D); -- int j = MathHelper.func_76128_c((p_177414_2_.field_72337_e + 2.0D) / 16.0D); -+ int i = MathHelper.func_76128_c((p_177414_2_.field_72338_b - this.field_76637_e.getMaxEntityRadius()) / 16.0D); -+ int j = MathHelper.func_76128_c((p_177414_2_.field_72337_e + this.field_76637_e.getMaxEntityRadius()) / 16.0D); - i = MathHelper.func_76125_a(i, 0, this.field_76645_j.length - 1); - j = MathHelper.func_76125_a(j, 0, this.field_76645_j.length - 1); - -@@ -472,8 +_,8 @@ - p_177414_3_.add(entity); - } - -- if (entity instanceof EnderDragonEntity) { -- for(EnderDragonPartEntity enderdragonpartentity : ((EnderDragonEntity)entity).func_213404_dT()) { -+ if (entity.isMultipartEntity()) { -+ for(net.minecraftforge.entity.PartEntity enderdragonpartentity : entity.getParts()) { - if (enderdragonpartentity != p_177414_1_ && enderdragonpartentity.func_174813_aQ().func_72326_a(p_177414_2_) && (p_177414_4_ == null || p_177414_4_.test(enderdragonpartentity))) { - p_177414_3_.add(enderdragonpartentity); - } -@@ -486,8 +_,8 @@ - } - - public void func_217313_a(@Nullable EntityType p_217313_1_, AxisAlignedBB p_217313_2_, List p_217313_3_, Predicate p_217313_4_) { -- int i = MathHelper.func_76128_c((p_217313_2_.field_72338_b - 2.0D) / 16.0D); -- int j = MathHelper.func_76128_c((p_217313_2_.field_72337_e + 2.0D) / 16.0D); -+ int i = MathHelper.func_76128_c((p_217313_2_.field_72338_b - this.field_76637_e.getMaxEntityRadius()) / 16.0D); -+ int j = MathHelper.func_76128_c((p_217313_2_.field_72337_e + this.field_76637_e.getMaxEntityRadius()) / 16.0D); - i = MathHelper.func_76125_a(i, 0, this.field_76645_j.length - 1); - j = MathHelper.func_76125_a(j, 0, this.field_76645_j.length - 1); - -@@ -502,8 +_,8 @@ - } - - public void func_177430_a(Class p_177430_1_, AxisAlignedBB p_177430_2_, List p_177430_3_, @Nullable Predicate p_177430_4_) { -- int i = MathHelper.func_76128_c((p_177430_2_.field_72338_b - 2.0D) / 16.0D); -- int j = MathHelper.func_76128_c((p_177430_2_.field_72337_e + 2.0D) / 16.0D); -+ int i = MathHelper.func_76128_c((p_177430_2_.field_72338_b - this.field_76637_e.getMaxEntityRadius()) / 16.0D); -+ int j = MathHelper.func_76128_c((p_177430_2_.field_72337_e + this.field_76637_e.getMaxEntityRadius()) / 16.0D); - i = MathHelper.func_76125_a(i, 0, this.field_76645_j.length - 1); - j = MathHelper.func_76125_a(j, 0, this.field_76645_j.length - 1); - -@@ -535,6 +_,11 @@ - }; - Sets.newHashSet(this.field_150816_i.keySet()).stream().filter(predicate).forEach(this.field_76637_e::func_175713_t); - -+ for (TileEntity tileEntity : field_150816_i.values()) { -+ tileEntity.func_145836_u(); -+ tileEntity.func_195044_w(); -+ } -+ - for(int i = 0; i < this.field_76652_q.length; ++i) { - ChunkSection chunksection = this.field_76652_q[i]; - if ((p_227073_4_ & 1 << i) == 0) { -@@ -598,7 +_,7 @@ - - public Stream func_217304_m() { - return StreamSupport.stream(BlockPos.func_191531_b(this.field_212816_F.func_180334_c(), 0, this.field_212816_F.func_180333_d(), this.field_212816_F.func_180332_e(), 255, this.field_212816_F.func_180330_f()).spliterator(), false).filter((p_217312_1_) -> { -- return this.func_180495_p(p_217312_1_).func_185906_d() != 0; -+ return this.func_180495_p(p_217312_1_).getLightValue(func_177412_p(), p_217312_1_) != 0; - }); - } - -@@ -704,9 +_,8 @@ - BlockState blockstate = this.func_180495_p(p_212815_1_); - TileEntity tileentity; - if ("DUMMY".equals(p_212815_2_.func_74779_i("id"))) { -- Block block = blockstate.func_177230_c(); -- if (block instanceof ITileEntityProvider) { -- tileentity = ((ITileEntityProvider)block).func_196283_a_(this.field_76637_e); -+ if (blockstate.hasTileEntity()) { -+ tileentity = blockstate.createTileEntity(this.field_76637_e); - } else { - tileentity = null; - field_150817_t.warn("Tried to load a DUMMY block entity @ {} but found not block entity block {} at location", p_212815_1_, blockstate); -@@ -794,5 +_,31 @@ - IMMEDIATE, - QUEUED, - CHECK; -+ } -+ -+ /** -+ * FOR INTERNAL USE ONLY -+ *

-+ * Only public for use in {@link AnvilChunkLoader}. -+ */ -+ @java.lang.Deprecated -+ @javax.annotation.Nullable -+ public final CompoundNBT writeCapsToNBT() { -+ return this.serializeCaps(); -+ } -+ -+ /** -+ * FOR INTERNAL USE ONLY -+ *

-+ * Only public for use in {@link AnvilChunkLoader}. -+ */ -+ @java.lang.Deprecated -+ public final void readCapsFromNBT(CompoundNBT tag) { -+ this.deserializeCaps(tag); -+ } -+ -+ @Override -+ public World getWorldForge() { -+ return func_177412_p(); - } - } diff --git a/patches/minecraft/net/minecraft/world/chunk/ChunkPrimer.java.patch b/patches/minecraft/net/minecraft/world/chunk/ChunkPrimer.java.patch deleted file mode 100644 index e02833d64e..0000000000 --- a/patches/minecraft/net/minecraft/world/chunk/ChunkPrimer.java.patch +++ /dev/null @@ -1,18 +0,0 @@ ---- a/net/minecraft/world/chunk/ChunkPrimer.java -+++ b/net/minecraft/world/chunk/ChunkPrimer.java -@@ -138,13 +_,13 @@ - if (this.field_201661_i[j >> 4] == Chunk.field_186036_a && p_177436_2_.func_203425_a(Blocks.field_150350_a)) { - return p_177436_2_; - } else { -- if (p_177436_2_.func_185906_d() > 0) { -+ if (p_177436_2_.getLightValue(this, p_177436_1_) > 0) { - this.field_201663_k.add(new BlockPos((i & 15) + this.func_76632_l().func_180334_c(), j, (k & 15) + this.func_76632_l().func_180333_d())); - } - - ChunkSection chunksection = this.func_217332_a(j >> 4); - BlockState blockstate = chunksection.func_222629_a(i & 15, j & 15, k & 15, p_177436_2_); -- if (this.field_201658_f.func_209003_a(ChunkStatus.field_222613_i) && p_177436_2_ != blockstate && (p_177436_2_.func_200016_a(this, p_177436_1_) != blockstate.func_200016_a(this, p_177436_1_) || p_177436_2_.func_185906_d() != blockstate.func_185906_d() || p_177436_2_.func_215691_g() || blockstate.func_215691_g())) { -+ if (this.field_201658_f.func_209003_a(ChunkStatus.field_222613_i) && p_177436_2_ != blockstate && (p_177436_2_.func_200016_a(this, p_177436_1_) != blockstate.func_200016_a(this, p_177436_1_) || p_177436_2_.getLightValue(this, p_177436_1_) != blockstate.getLightValue(this, p_177436_1_) || p_177436_2_.func_215691_g() || blockstate.func_215691_g())) { - WorldLightManager worldlightmanager = this.func_217307_e(); - worldlightmanager.func_215568_a(p_177436_1_); - } diff --git a/patches/minecraft/net/minecraft/world/chunk/ChunkStatus.java.patch b/patches/minecraft/net/minecraft/world/chunk/ChunkStatus.java.patch deleted file mode 100644 index 00dcd662ee..0000000000 --- a/patches/minecraft/net/minecraft/world/chunk/ChunkStatus.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/chunk/ChunkStatus.java -+++ b/net/minecraft/world/chunk/ChunkStatus.java -@@ -23,7 +_,7 @@ - import net.minecraft.world.server.ServerWorld; - import net.minecraft.world.server.ServerWorldLightManager; - --public class ChunkStatus { -+public class ChunkStatus extends net.minecraftforge.registries.ForgeRegistryEntry { - private static final EnumSet field_222618_n = EnumSet.of(Heightmap.Type.OCEAN_FLOOR_WG, Heightmap.Type.WORLD_SURFACE_WG); - private static final EnumSet field_222619_o = EnumSet.of(Heightmap.Type.OCEAN_FLOOR, Heightmap.Type.WORLD_SURFACE, Heightmap.Type.MOTION_BLOCKING, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES); - private static final ChunkStatus.ILoadingWorker field_223211_p = (p_222588_0_, p_222588_1_, p_222588_2_, p_222588_3_, p_222588_4_, p_222588_5_) -> { diff --git a/patches/minecraft/net/minecraft/world/chunk/IChunk.java.patch b/patches/minecraft/net/minecraft/world/chunk/IChunk.java.patch deleted file mode 100644 index f96db555e8..0000000000 --- a/patches/minecraft/net/minecraft/world/chunk/IChunk.java.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/net/minecraft/world/chunk/IChunk.java -+++ b/net/minecraft/world/chunk/IChunk.java -@@ -145,4 +_,9 @@ - boolean func_217310_r(); - - void func_217305_b(boolean p_217305_1_); -+ -+ @Nullable -+ default net.minecraft.world.IWorld getWorldForge() { -+ return null; -+ } - } diff --git a/patches/minecraft/net/minecraft/world/chunk/storage/ChunkSerializer.java.patch b/patches/minecraft/net/minecraft/world/chunk/storage/ChunkSerializer.java.patch deleted file mode 100644 index d3bfb80919..0000000000 --- a/patches/minecraft/net/minecraft/world/chunk/storage/ChunkSerializer.java.patch +++ /dev/null @@ -1,67 +0,0 @@ ---- a/net/minecraft/world/chunk/storage/ChunkSerializer.java -+++ b/net/minecraft/world/chunk/storage/ChunkSerializer.java -@@ -132,6 +_,7 @@ - ichunk = new Chunk(p_222656_0_.func_201672_e(), p_222656_3_, biomecontainer, upgradedata, iticklist, iticklist1, k1, achunksection, (p_222648_1_) -> { - func_222650_a(compoundnbt, p_222648_1_); - }); -+ if (compoundnbt.func_74764_b("ForgeCaps")) ((Chunk)ichunk).readCapsFromNBT(compoundnbt.func_74775_l("ForgeCaps")); - } else { - ChunkPrimer chunkprimer = new ChunkPrimer(p_222656_3_, upgradedata, achunksection, chunkprimerticklist, chunkprimerticklist1); - chunkprimer.func_225548_a_(biomecontainer); -@@ -144,7 +_,7 @@ - - if (!flag && chunkprimer.func_201589_g().func_209003_a(ChunkStatus.field_222614_j)) { - for(BlockPos blockpos : BlockPos.func_191531_b(p_222656_3_.func_180334_c(), 0, p_222656_3_.func_180333_d(), p_222656_3_.func_180332_e(), 255, p_222656_3_.func_180330_f())) { -- if (ichunk.func_180495_p(blockpos).func_185906_d() != 0) { -+ if (ichunk.func_180495_p(blockpos).getLightValue(ichunk, blockpos) != 0) { - chunkprimer.func_201637_h(blockpos); - } - } -@@ -167,7 +_,7 @@ - Heightmap.func_222690_a(ichunk, enumset); - CompoundNBT compoundnbt4 = compoundnbt.func_74775_l("Structures"); - ichunk.func_201612_a(func_235967_a_(p_222656_1_, compoundnbt4, p_222656_0_.func_72905_C())); -- ichunk.func_201606_b(func_227075_a_(p_222656_3_, compoundnbt4)); -+ net.minecraftforge.common.ForgeHooks.fixNullStructureReferences(ichunk, func_227075_a_(p_222656_3_, compoundnbt4)); - if (compoundnbt.func_74767_n("shouldSave")) { - ichunk.func_177427_f(true); - } -@@ -183,6 +_,7 @@ - } - - if (chunkstatus$type == ChunkStatus.Type.LEVELCHUNK) { -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.ChunkDataEvent.Load(ichunk, p_222656_4_, chunkstatus$type)); - return new ChunkPrimerWrapper((Chunk)ichunk); - } else { - ChunkPrimer chunkprimer1 = (ChunkPrimer)ichunk; -@@ -216,6 +_,8 @@ - chunkprimer1.func_205767_a(generationstage$carving, BitSet.valueOf(compoundnbt5.func_74770_j(s1))); - } - -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.ChunkDataEvent.Load(ichunk, p_222656_4_, chunkstatus$type)); -+ - return chunkprimer1; - } - } -@@ -295,11 +_,21 @@ - for(int k = 0; k < chunk.func_177429_s().length; ++k) { - for(Entity entity : chunk.func_177429_s()[k]) { - CompoundNBT compoundnbt3 = new CompoundNBT(); -+ try { - if (entity.func_70039_c(compoundnbt3)) { - chunk.func_177409_g(true); - listnbt2.add(compoundnbt3); - } -+ } catch (Exception e) { -+ LogManager.getLogger().error("An Entity type {} has thrown an exception trying to write state. It will not persist. Report this to the mod author", entity.func_200600_R(), e); -+ } - } -+ } -+ try { -+ final CompoundNBT capTag = chunk.writeCapsToNBT(); -+ if (capTag != null) compoundnbt1.func_218657_a("ForgeCaps", capTag); -+ } catch (Exception exception) { -+ LogManager.getLogger().error("A capability provider has thrown an exception trying to write state. It will not persist. Report this to the mod author", exception); - } - } else { - ChunkPrimer chunkprimer = (ChunkPrimer)p_222645_1_; diff --git a/patches/minecraft/net/minecraft/world/effect/MobEffect.java.patch b/patches/minecraft/net/minecraft/world/effect/MobEffect.java.patch new file mode 100644 index 0000000000..d2a9c82cd6 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/effect/MobEffect.java.patch @@ -0,0 +1,48 @@ +--- a/net/minecraft/world/effect/MobEffect.java ++++ b/net/minecraft/world/effect/MobEffect.java +@@ -18,7 +_,7 @@ + import net.minecraft.world.entity.ai.attributes.AttributeModifier; + import net.minecraft.world.entity.player.Player; + +-public class MobEffect { ++public class MobEffect extends net.minecraftforge.registries.ForgeRegistryEntry implements net.minecraftforge.common.extensions.IForgeMobEffect { + private final Map f_19446_ = Maps.newHashMap(); + private final MobEffectCategory f_19447_; + private final int f_19448_; +@@ -37,6 +_,7 @@ + protected MobEffect(MobEffectCategory p_19451_, int p_19452_) { + this.f_19447_ = p_19451_; + this.f_19448_ = p_19452_; ++ initClient(); + } + + public void m_6742_(LivingEntity p_19467_, int p_19468_) { +@@ -179,4 +_,28 @@ + public boolean m_19486_() { + return this.f_19447_ == MobEffectCategory.BENEFICIAL; + } ++ ++ // FORGE START ++ private Object effectRenderer; ++ ++ /* ++ DO NOT CALL, IT WILL DISAPPEAR IN THE FUTURE ++ Call RenderProperties.getEffectRenderer instead ++ */ ++ public Object getEffectRendererInternal() { ++ return effectRenderer; ++ } ++ ++ private void initClient() { ++ if (net.minecraftforge.fml.loading.FMLEnvironment.dist == net.minecraftforge.api.distmarker.Dist.CLIENT) { ++ initializeClient(properties -> { ++ this.effectRenderer = properties; ++ }); ++ } ++ } ++ ++ public void initializeClient(java.util.function.Consumer consumer) { ++ } ++ // END FORGE ++ + } diff --git a/patches/minecraft/net/minecraft/world/effect/MobEffectInstance.java.patch b/patches/minecraft/net/minecraft/world/effect/MobEffectInstance.java.patch new file mode 100644 index 0000000000..ffe86af40c --- /dev/null +++ b/patches/minecraft/net/minecraft/world/effect/MobEffectInstance.java.patch @@ -0,0 +1,86 @@ +--- a/net/minecraft/world/effect/MobEffectInstance.java ++++ b/net/minecraft/world/effect/MobEffectInstance.java +@@ -7,7 +_,7 @@ + import org.apache.logging.log4j.LogManager; + import org.apache.logging.log4j.Logger; + +-public class MobEffectInstance implements Comparable { ++public class MobEffectInstance implements Comparable, net.minecraftforge.common.extensions.IForgeMobEffectInstance { + private static final Logger f_19501_ = LogManager.getLogger(); + private final MobEffect f_19502_; + private int f_19503_; +@@ -60,6 +_,7 @@ + this.f_19506_ = p_19549_.f_19506_; + this.f_19508_ = p_19549_.f_19508_; + this.f_19509_ = p_19549_.f_19509_; ++ this.curativeItems = p_19549_.curativeItems == null ? null : new java.util.ArrayList(p_19549_.curativeItems); + } + + public boolean m_19558_(MobEffectInstance p_19559_) { +@@ -108,7 +_,7 @@ + } + + public MobEffect m_19544_() { +- return this.f_19502_; ++ return this.f_19502_ == null ? null : this.f_19502_.delegate.get(); + } + + public int m_19557_() { +@@ -221,12 +_,13 @@ + this.f_19510_.m_19555_(compoundtag); + p_19568_.m_128365_("HiddenEffect", compoundtag); + } ++ writeCurativeItems(p_19568_); + + } + + @Nullable + public static MobEffectInstance m_19560_(CompoundTag p_19561_) { +- int i = p_19561_.m_128445_("Id"); ++ int i = p_19561_.m_128445_("Id") & 0xFF; + MobEffect mobeffect = MobEffect.m_19453_(i); + return mobeffect == null ? null : m_19545_(mobeffect, p_19561_); + } +@@ -250,7 +_,7 @@ + mobeffectinstance = m_19545_(p_19546_, p_19547_.m_128469_("HiddenEffect")); + } + +- return new MobEffectInstance(p_19546_, j, i < 0 ? 0 : i, flag, flag1, flag2, mobeffectinstance); ++ return readCurativeItems(new MobEffectInstance(p_19546_, j, i < 0 ? 0 : i, flag, flag1, flag2, mobeffectinstance), p_19547_); + } + + public void m_19562_(boolean p_19563_) { +@@ -263,6 +_,32 @@ + + 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().compare(this.m_19571_(), p_19566_.m_19571_()).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_().getGuiSortColor(this), p_19566_.m_19544_().getGuiSortColor(this)).result() : ComparisonChain.start().compare(this.m_19571_(), p_19566_.m_19571_()).compare(this.m_19544_().getGuiSortColor(this), p_19566_.m_19544_().getGuiSortColor(this)).result(); ++ } ++ ++ //======================= FORGE START =========================== ++ private java.util.List curativeItems; ++ ++ @Override ++ public java.util.List getCurativeItems() { ++ if (this.curativeItems == null) //Lazy load this so that we don't create a circular dep on Items. ++ this.curativeItems = m_19544_().getCurativeItems(); ++ return this.curativeItems; ++ } ++ @Override ++ public void setCurativeItems(java.util.List curativeItems) { ++ this.curativeItems = curativeItems; ++ } ++ private static MobEffectInstance readCurativeItems(MobEffectInstance effect, CompoundTag nbt) { ++ if (nbt.m_128425_("CurativeItems", net.minecraftforge.common.util.Constants.NBT.TAG_LIST)) { ++ java.util.List items = new java.util.ArrayList(); ++ net.minecraft.nbt.ListTag list = nbt.m_128437_("CurativeItems", net.minecraftforge.common.util.Constants.NBT.TAG_COMPOUND); ++ for (int i = 0; i < list.size(); i++) { ++ items.add(net.minecraft.world.item.ItemStack.m_41712_(list.m_128728_(i))); ++ } ++ effect.setCurativeItems(items); ++ } ++ ++ return effect; + } + } diff --git a/patches/minecraft/net/minecraft/world/effect/MobEffects.java.patch b/patches/minecraft/net/minecraft/world/effect/MobEffects.java.patch new file mode 100644 index 0000000000..f426e0c76e --- /dev/null +++ b/patches/minecraft/net/minecraft/world/effect/MobEffects.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/world/effect/MobEffects.java ++++ b/net/minecraft/world/effect/MobEffects.java +@@ -8,6 +_,7 @@ + import net.minecraft.world.entity.ai.attributes.AttributeModifier; + import net.minecraft.world.entity.ai.attributes.Attributes; + ++@net.minecraftforge.registries.ObjectHolder("minecraft") + public class MobEffects { + public static final MobEffect f_19596_ = m_19623_(1, "speed", (new MobEffect(MobEffectCategory.BENEFICIAL, 8171462)).m_19472_(Attributes.f_22279_, "91AEAA56-376B-4498-935B-2F7F68070635", (double)0.2F, AttributeModifier.Operation.MULTIPLY_TOTAL)); + public static final MobEffect f_19597_ = m_19623_(2, "slowness", (new MobEffect(MobEffectCategory.HARMFUL, 5926017)).m_19472_(Attributes.f_22279_, "7107DE5E-7CE8-4030-940E-514C1F160890", (double)-0.15F, AttributeModifier.Operation.MULTIPLY_TOTAL)); diff --git a/patches/minecraft/net/minecraft/world/end/DragonFightManager.java.patch b/patches/minecraft/net/minecraft/world/end/DragonFightManager.java.patch deleted file mode 100644 index 78142b9ba5..0000000000 --- a/patches/minecraft/net/minecraft/world/end/DragonFightManager.java.patch +++ /dev/null @@ -1,33 +0,0 @@ ---- a/net/minecraft/world/end/DragonFightManager.java -+++ b/net/minecraft/world/end/DragonFightManager.java -@@ -84,6 +_,7 @@ - - this.field_186117_k = p_i231901_4_.func_74767_n("DragonKilled"); - this.field_186118_l = p_i231901_4_.func_74767_n("PreviouslyKilled"); -+ this.field_186120_n = !p_i231901_4_.func_74767_n("LegacyScanPerformed"); // Forge: fix MC-105080 - if (p_i231901_4_.func_74767_n("IsRespawning")) { - this.field_186122_p = DragonSpawnState.START; - } -@@ -118,6 +_,7 @@ - - compoundnbt.func_74757_a("DragonKilled", this.field_186117_k); - compoundnbt.func_74757_a("PreviouslyKilled", this.field_186118_l); -+ compoundnbt.func_74757_a("LegacyScanPerformed", !this.field_186120_n); // Forge: fix MC-105080 - if (this.field_186121_o != null) { - compoundnbt.func_218657_a("ExitPortalLocation", NBTUtil.func_186859_a(this.field_186121_o)); - } -@@ -490,6 +_,13 @@ - endercrystalentity.func_184516_a((BlockPos)null); - } - } -- -+ } -+ -+ public void addPlayer(ServerPlayerEntity player) { -+ this.field_186109_c.func_186760_a(player); -+ } -+ -+ public void removePlayer(ServerPlayerEntity player) { -+ this.field_186109_c.func_186761_b(player); - } - } diff --git a/patches/minecraft/net/minecraft/world/entity/Entity.java.patch b/patches/minecraft/net/minecraft/world/entity/Entity.java.patch new file mode 100644 index 0000000000..8d09cf9e3d --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/Entity.java.patch @@ -0,0 +1,384 @@ +--- a/net/minecraft/world/entity/Entity.java ++++ b/net/minecraft/world/entity/Entity.java +@@ -113,7 +_,7 @@ + import org.apache.logging.log4j.LogManager; + import org.apache.logging.log4j.Logger; + +-public abstract class Entity implements Nameable, EntityAccess, CommandSource { ++public abstract class Entity extends net.minecraftforge.common.capabilities.CapabilityProvider implements Nameable, EntityAccess, CommandSource, net.minecraftforge.common.extensions.IForgeEntity { + protected static final Logger f_19849_ = LogManager.getLogger(); + public static final String f_146815_ = "id"; + public static final String f_146816_ = "Passengers"; +@@ -132,6 +_,7 @@ + private static final double f_146812_ = 0.0023333333333333335D; + public static final String f_146824_ = "UUID"; + private static double f_19846_ = 1.0D; ++ @Deprecated // Forge: Use the getter to allow overriding in mods + private final EntityType f_19847_; + private int f_19848_ = f_19843_.incrementAndGet(); + public boolean f_19850_; +@@ -222,6 +_,7 @@ + private boolean f_146813_; + + public Entity(EntityType p_19870_, Level p_19871_) { ++ super(Entity.class); + this.f_19847_ = p_19870_; + this.f_19853_ = p_19871_; + this.f_19815_ = p_19870_.m_20680_(); +@@ -239,7 +_,11 @@ + this.f_19804_.m_135372_(f_146800_, 0); + this.m_8097_(); + this.m_6034_(0.0D, 0.0D, 0.0D); +- this.f_19816_ = this.m_6380_(Pose.STANDING, this.f_19815_); ++ net.minecraftforge.event.entity.EntityEvent.Size 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.gatherCapabilities(); + } + + public boolean m_20039_(BlockPos p_20040_, BlockState p_20041_) { +@@ -339,6 +_,13 @@ + } + + public void m_142036_() { ++ this.remove(false); ++ } ++ ++ public void remove(boolean keepData) { ++ this.m_146870_(); ++ if (!keepData) ++ this.invalidateCaps(); + } + + public void m_20124_(Pose p_20125_) { +@@ -599,13 +_,13 @@ + double d0 = vec3.f_82479_; + double d1 = vec3.f_82480_; + double d2 = vec3.f_82481_; +- this.f_146794_ = (float)((double)this.f_146794_ + vec3.m_82553_() * 0.6D); ++ this.f_146794_ = (float) ((double) this.f_146794_ + vec3.m_82553_() * 0.6D); + if (!blockstate.m_60620_(BlockTags.f_13082_) && !blockstate.m_60713_(Blocks.f_152499_)) { + d1 = 0.0D; + } + +- this.f_19787_ += (float)vec3.m_165924_() * 0.6F; +- this.f_19788_ += (float)Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 0.6F; ++ this.f_19787_ += (float) vec3.m_165924_() * 0.6F; ++ this.f_19788_ += (float) Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 0.6F; + if (this.f_19788_ > this.f_19829_ && !blockstate.m_60795_()) { + this.f_19829_ = this.m_6059_(); + if (this.m_20069_()) { +@@ -637,25 +_,23 @@ + + this.m_146872_(); + float f2 = this.m_6041_(); +- this.m_20256_(this.m_20184_().m_82542_((double)f2, 1.0D, (double)f2)); +- if (this.f_19853_.m_46847_(this.m_142469_().m_82406_(1.0E-6D)).noneMatch((p_20127_) -> { +- return p_20127_.m_60620_(BlockTags.f_13076_) || p_20127_.m_60713_(Blocks.f_49991_); +- })) { +- if (this.f_19831_ <= 0) { +- this.m_7311_(-this.m_6101_()); +- } +- +- if (this.f_146810_ && (this.f_146808_ || this.m_20071_())) { +- this.m_146873_(); +- } +- } +- +- if (this.m_6060_() && (this.f_146808_ || this.m_20071_())) { ++ this.m_20256_(this.m_20184_().m_82542_((double) f2, 1.0D, (double) f2)); ++ } ++ if (this.f_19853_.m_46847_(this.m_142469_().m_82406_(1.0E-6D)).noneMatch((p_20127_) -> p_20127_.m_60620_(BlockTags.f_13076_) || p_20127_.m_60713_(Blocks.f_49991_))) { ++ if (this.f_19831_ <= 0) { + this.m_7311_(-this.m_6101_()); + } + +- this.f_19853_.m_46473_().m_7238_(); +- } ++ if (this.f_146810_ && (this.f_146808_ || this.m_20071_())) { ++ this.m_146873_(); ++ } ++ } ++ ++ if (this.m_6060_() && (this.f_146808_ || this.m_20071_())) { ++ this.m_7311_(-this.m_6101_()); ++ } ++ ++ this.f_19853_.m_46473_().m_7238_(); + } + } + +@@ -689,10 +_,10 @@ + int j = Mth.m_14107_(this.f_19825_.f_82480_ - (double)0.2F); + int k = Mth.m_14107_(this.f_19825_.f_82481_); + BlockPos blockpos = new BlockPos(i, j, k); +- if (this.f_19853_.m_8055_(blockpos).m_60795_()) { ++ if (this.f_19853_.m_46859_(blockpos)) { + BlockPos blockpos1 = blockpos.m_7495_(); + BlockState blockstate = this.f_19853_.m_8055_(blockpos1); +- if (blockstate.m_60620_(BlockTags.f_13039_) || blockstate.m_60620_(BlockTags.f_13032_) || blockstate.m_60734_() instanceof FenceGateBlock) { ++ if (blockstate.collisionExtendsVertically(this.f_19853_, blockpos1, this)) { + return blockpos1; + } + } +@@ -934,7 +_,7 @@ + protected void m_7355_(BlockPos p_20135_, BlockState p_20136_) { + if (!p_20136_.m_60767_().m_76332_()) { + BlockState blockstate = this.f_19853_.m_8055_(p_20135_.m_7494_()); +- SoundType soundtype = blockstate.m_60620_(BlockTags.f_144271_) ? blockstate.m_60827_() : p_20136_.m_60827_(); ++ SoundType soundtype = blockstate.m_60713_(Blocks.f_50125_) ? blockstate.getSoundType(f_19853_, p_20135_, this) : p_20136_.getSoundType(f_19853_, p_20135_, this); + this.m_5496_(soundtype.m_56776_(), soundtype.m_56773_() * 0.15F, soundtype.m_56774_()); + } + } +@@ -1156,9 +_,10 @@ + int k = Mth.m_14107_(this.m_20189_()); + BlockPos blockpos = new BlockPos(i, j, k); + BlockState blockstate = this.f_19853_.m_8055_(blockpos); ++ if(!blockstate.addRunningEffects(f_19853_, blockpos, this)) + if (blockstate.m_60799_() != RenderShape.INVISIBLE) { + Vec3 vec3 = this.m_20184_(); +- this.f_19853_.m_7106_(new BlockParticleOption(ParticleTypes.f_123794_, blockstate), this.m_20185_() + (this.f_19796_.nextDouble() - 0.5D) * (double)this.f_19815_.f_20377_, this.m_20186_() + 0.1D, this.m_20189_() + (this.f_19796_.nextDouble() - 0.5D) * (double)this.f_19815_.f_20377_, vec3.f_82479_ * -4.0D, 1.5D, vec3.f_82481_ * -4.0D); ++ this.f_19853_.m_7106_(new BlockParticleOption(ParticleTypes.f_123794_, blockstate).setPos(blockpos), this.m_20185_() + (this.f_19796_.nextDouble() - 0.5D) * (double)this.f_19815_.f_20377_, this.m_20186_() + 0.1D, this.m_20189_() + (this.f_19796_.nextDouble() - 0.5D) * (double)this.f_19815_.f_20377_, vec3.f_82479_ * -4.0D, 1.5D, vec3.f_82481_ * -4.0D); + } + + } +@@ -1479,6 +_,7 @@ + if (this.f_146813_) { + p_20241_.m_128379_("HasVisualFire", this.f_146813_); + } ++ p_20241_.m_128379_("CanUpdate", canUpdate); + + if (!this.f_19841_.isEmpty()) { + ListTag listtag = new ListTag(); +@@ -1490,6 +_,10 @@ + p_20241_.m_128365_("Tags", listtag); + } + ++ CompoundTag caps = serializeCaps(); ++ if (caps != null) p_20241_.m_128365_("ForgeCaps", caps); ++ if (persistentData != null) p_20241_.m_128365_("ForgeData", persistentData); ++ + this.m_7380_(p_20241_); + if (this.m_20160_()) { + ListTag listtag1 = new ListTag(); +@@ -1564,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"); ++ if (p_20259_.m_128425_("ForgeData", 10)) persistentData = p_20259_.m_128469_("ForgeData"); ++ if (p_20259_.m_128425_("CanUpdate", 99)) this.canUpdate(p_20259_.m_128471_("CanUpdate")); ++ if (p_20259_.m_128425_("ForgeCaps", 10)) deserializeCaps(p_20259_.m_128469_("ForgeCaps")); + if (p_20259_.m_128425_("Tags", 9)) { + this.f_19841_.clear(); + ListTag listtag3 = p_20259_.m_128437_("Tags", 8); +@@ -1652,6 +_,8 @@ + } else { + ItemEntity itementity = new ItemEntity(this.f_19853_, this.m_20185_(), this.m_20186_() + (double)p_19986_, this.m_20189_(), p_19985_); + itementity.m_32060_(); ++ if (captureDrops() != null) captureDrops().add(itementity); ++ else + this.f_19853_.m_7967_(itementity); + return itementity; + } +@@ -1687,6 +_,7 @@ + + public void m_6083_() { + this.m_20256_(Vec3.f_82478_); ++ if (canUpdate()) + this.m_8119_(); + if (this.m_20159_()) { + this.m_20202_().m_7332_(this); +@@ -1733,6 +_,7 @@ + } + } + ++ if (!net.minecraftforge.event.ForgeEventFactory.canMountEntity(this, p_19966_, true)) return false; + if (p_19967_ || this.m_7341_(p_19966_) && p_19966_.m_7310_(this)) { + if (this.m_20159_()) { + this.m_8127_(); +@@ -1771,6 +_,7 @@ + public void m_6038_() { + if (this.f_19824_ != null) { + Entity entity = this.f_19824_; ++ if (!net.minecraftforge.event.ForgeEventFactory.canMountEntity(this, entity, false)) return; + this.f_19824_ = null; + entity.m_20351_(this); + } +@@ -1936,6 +_,7 @@ + return !this.f_19823_.isEmpty(); + } + ++ @Deprecated //Forge: Use rider sensitive version + public boolean m_6146_() { + return true; + } +@@ -2093,7 +_,7 @@ + this.m_20254_(8); + } + +- this.m_6469_(DamageSource.f_19306_, 5.0F); ++ this.m_6469_(DamageSource.f_19306_, p_19928_.getDamage()); + } + + public void m_6845_(boolean p_20313_) { +@@ -2177,7 +_,7 @@ + } + + protected Component m_5677_() { +- return this.f_19847_.m_20676_(); ++ return this.m_6095_().m_20676_(); // Forge: Use getter to allow overriding by mods + } + + public boolean m_7306_(Entity p_20356_) { +@@ -2232,14 +_,19 @@ + + @Nullable + public Entity m_5489_(ServerLevel p_20118_) { ++ return this.changeDimension(p_20118_, p_20118_.m_8871_()); ++ } ++ @Nullable ++ public Entity changeDimension(ServerLevel p_20118_, net.minecraftforge.common.util.ITeleporter teleporter) { + if (this.f_19853_ instanceof ServerLevel && !this.m_146910_()) { + this.f_19853_.m_46473_().m_6180_("changeDimension"); + this.m_19877_(); + this.f_19853_.m_46473_().m_6180_("reposition"); +- PortalInfo portalinfo = this.m_7937_(p_20118_); ++ PortalInfo portalinfo = teleporter.getPortalInfo(this, p_20118_, this::m_7937_); + if (portalinfo == null) { + return null; + } else { ++ Entity transportedEntity = teleporter.placeEntity(this, (ServerLevel) this.f_19853_, p_20118_, this.f_19857_, spawnPortal -> { //Forge: Start vanilla logic + this.f_19853_.m_46473_().m_6182_("reloading"); + Entity entity = this.m_6095_().m_20615_(p_20118_); + if (entity != null) { +@@ -2247,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); +- if (p_20118_.m_46472_() == Level.f_46430_) { ++ if (spawnPortal && p_20118_.m_46472_() == Level.f_46430_) { + ServerLevel.m_8617_(p_20118_); + } + } ++ return entity; ++ }); //Forge: End vanilla logic + + this.m_6089_(); + this.f_19853_.m_46473_().m_7238_(); + ((ServerLevel)this.f_19853_).m_8886_(); + p_20118_.m_8886_(); + this.f_19853_.m_46473_().m_7238_(); +- return entity; ++ return transportedEntity; + } + } else { + return null; +@@ -2462,8 +_,10 @@ + EntityDimensions entitydimensions = this.f_19815_; + Pose pose = this.m_20089_(); + EntityDimensions entitydimensions1 = this.m_6972_(pose); ++ net.minecraftforge.event.entity.EntityEvent.Size 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.f_19853_.f_46443_ && !this.f_19803_ && !this.f_19794_ && flag && (entitydimensions1.f_20377_ > entitydimensions.f_20377_ || entitydimensions1.f_20378_ > entitydimensions.f_20378_) && !(this instanceof Player)) { +@@ -2471,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.f_19853_.m_151418_(this, voxelshape, vec3, (double)entitydimensions1.f_20377_, (double)entitydimensions1.f_20378_, (double)entitydimensions1.f_20377_).ifPresent((p_146842_) -> { +- this.m_146884_(p_146842_.m_82520_(0.0D, (double)(-entitydimensions1.f_20378_) / 2.0D, 0.0D)); ++ this.m_146884_(p_146842_.m_82520_(0.0D, (double)(-finalEntitydimensions.f_20378_) / 2.0D, 0.0D)); + }); + } + +@@ -2941,6 +_,7 @@ + gameeventlistenerregistrar.m_157862_(this.f_19853_); + } + } ++ if (this.isAddedToWorld() && !this.f_19853_.f_46443_ && !this.m_146910_()) this.f_19853_.m_6325_((int) Math.floor(p_20344_) >> 4, (int) Math.floor(p_20346_) >> 4); // Forge - ensure target chunk is loaded. + + } + +@@ -3048,6 +_,76 @@ + public boolean m_142265_(Level p_146843_, BlockPos p_146844_) { + return true; + } ++ ++ /* ================================== Forge Start =====================================*/ ++ ++ private boolean canUpdate = true; ++ @Override ++ public void canUpdate(boolean value) { ++ this.canUpdate = value; ++ } ++ @Override ++ public boolean canUpdate() { ++ return this.canUpdate; ++ } ++ private java.util.Collection captureDrops = null; ++ @Override ++ public java.util.Collection captureDrops() { ++ return captureDrops; ++ } ++ @Override ++ public java.util.Collection captureDrops(java.util.Collection value) { ++ java.util.Collection ret = captureDrops; ++ this.captureDrops = value; ++ return ret; ++ } ++ private CompoundTag persistentData; ++ @Override ++ public CompoundTag getPersistentData() { ++ if (persistentData == null) ++ persistentData = new CompoundTag(); ++ return persistentData; ++ } ++ @Override ++ public boolean canTrample(BlockState state, BlockPos pos, float fallDistance) { ++ return f_19853_.f_46441_.nextFloat() < fallDistance - 0.5F ++ && this instanceof LivingEntity ++ && (this instanceof Player || net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(f_19853_, this)) ++ && this.m_20205_() * this.m_20205_() * this.m_20206_() > 0.512F; ++ } ++ ++ /** ++ * Internal use for keeping track of entities that are tracked by a world, to ++ * allow guarantees that entity position changes will force a chunk load, avoiding ++ * potential issues with entity desyncing and bad chunk data. ++ */ ++ private boolean isAddedToWorld; ++ ++ @Override ++ public final boolean isAddedToWorld() { return this.isAddedToWorld; } ++ ++ @Override ++ public void onAddedToWorld() { this.isAddedToWorld = true; } ++ ++ @Override ++ public void onRemovedFromWorld() { this.isAddedToWorld = false; } ++ ++ @Override ++ public void revive() { ++ this.m_146912_(); ++ this.reviveCaps(); ++ } ++ ++ // no AT because of overrides ++ /** ++ * Accessor method for {@link #getEyeHeight(Pose, EntityDimensions)} ++ */ ++ public float getEyeHeightAccess(Pose pose, EntityDimensions size) { ++ return this.m_6380_(pose, size); ++ } ++ ++ /* ================================== Forge End =====================================*/ ++ + + @FunctionalInterface + public interface MoveFunction { diff --git a/patches/minecraft/net/minecraft/world/entity/EntityType.java.patch b/patches/minecraft/net/minecraft/world/entity/EntityType.java.patch new file mode 100644 index 0000000000..c0cce220f6 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/EntityType.java.patch @@ -0,0 +1,147 @@ +--- a/net/minecraft/world/entity/EntityType.java ++++ b/net/minecraft/world/entity/EntityType.java +@@ -146,7 +_,7 @@ + import org.apache.logging.log4j.LogManager; + import org.apache.logging.log4j.Logger; + +-public class EntityType implements EntityTypeTest { ++public class EntityType extends net.minecraftforge.registries.ForgeRegistryEntry> implements EntityTypeTest { + private static final Logger f_20534_ = LogManager.getLogger(); + public static final String f_147037_ = "EntityTag"; + private static final float f_147038_ = 1.3964844F; +@@ -280,6 +_,12 @@ + private ResourceLocation f_20546_; + private final EntityDimensions f_20547_; + ++ private final java.util.function.Predicate> velocityUpdateSupplier; ++ private final java.util.function.ToIntFunction> trackingRangeSupplier; ++ private final java.util.function.ToIntFunction> updateIntervalSupplier; ++ private final java.util.function.BiFunction customClientFactory; ++ private final net.minecraftforge.common.util.ReverseTagWrapper> reverseTags = new net.minecraftforge.common.util.ReverseTagWrapper<>(this, net.minecraft.tags.EntityTypeTags::m_13126_); ++ + private static EntityType m_20634_(String p_20635_, EntityType.Builder p_20636_) { + return Registry.m_122961_(Registry.f_122826_, p_20635_, p_20636_.m_20712_(p_20635_)); + } +@@ -293,6 +_,9 @@ + } + + public EntityType(EntityType.EntityFactory p_20574_, MobCategory p_20575_, boolean p_20576_, boolean p_20577_, boolean p_20578_, boolean p_20579_, ImmutableSet p_20580_, EntityDimensions p_20581_, int p_20582_, int p_20583_) { ++ this(p_20574_, p_20575_, p_20576_, p_20577_, p_20578_, p_20579_, p_20580_, p_20581_, p_20582_, p_20583_, EntityType::defaultVelocitySupplier, EntityType::defaultTrackingRangeSupplier, EntityType::defaultUpdateIntervalSupplier, null); ++ } ++ public EntityType(EntityType.EntityFactory p_20574_, MobCategory p_20575_, boolean p_20576_, boolean p_20577_, boolean p_20578_, boolean p_20579_, ImmutableSet p_20580_, EntityDimensions p_20581_, int p_20582_, int p_20583_, final java.util.function.Predicate> velocityUpdateSupplier, final java.util.function.ToIntFunction> trackingRangeSupplier, final java.util.function.ToIntFunction> updateIntervalSupplier, final java.util.function.BiFunction customClientFactory) { + this.f_20535_ = p_20574_; + this.f_20536_ = p_20575_; + this.f_20541_ = p_20579_; +@@ -303,6 +_,10 @@ + this.f_20547_ = p_20581_; + this.f_20542_ = p_20582_; + this.f_20543_ = p_20583_; ++ this.velocityUpdateSupplier = velocityUpdateSupplier; ++ this.trackingRangeSupplier = trackingRangeSupplier; ++ this.updateIntervalSupplier = updateIntervalSupplier; ++ this.customClientFactory = customClientFactory; + } + + @Nullable +@@ -314,6 +_,7 @@ + public T m_20600_(ServerLevel p_20601_, @Nullable CompoundTag p_20602_, @Nullable Component p_20603_, @Nullable Player p_20604_, BlockPos p_20605_, MobSpawnType p_20606_, boolean p_20607_, boolean p_20608_) { + T t = this.m_20655_(p_20601_, p_20602_, p_20603_, p_20604_, p_20605_, p_20606_, p_20607_, p_20608_); + if (t != null) { ++ if (t instanceof net.minecraft.world.entity.Mob && net.minecraftforge.event.ForgeEventFactory.doSpecialSpawn((net.minecraft.world.entity.Mob) t, p_20601_, p_20605_.m_123341_(), p_20605_.m_123342_(), p_20605_.m_123343_(), null, p_20606_)) return null; + p_20601_.m_47205_(t); + } + +@@ -543,14 +_,23 @@ + } + + public int m_20681_() { ++ return trackingRangeSupplier.applyAsInt(this); ++ } ++ private int defaultTrackingRangeSupplier() { + return this.f_20542_; + } + + public int m_20682_() { ++ return updateIntervalSupplier.applyAsInt(this); ++ } ++ private int defaultUpdateIntervalSupplier() { + return this.f_20543_; + } + + public boolean m_20683_() { ++ return velocityUpdateSupplier.test(this); ++ } ++ private boolean defaultVelocitySupplier() { + 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_; + } + +@@ -567,6 +_,19 @@ + return Entity.class; + } + ++ public T customClientSpawn(net.minecraftforge.fmllegacy.network.FMLPlayMessages.SpawnEntity packet, Level world) { ++ if (customClientFactory == null) return this.m_20615_(world); ++ return customClientFactory.apply(packet, world); ++ } ++ ++ /** ++ * Retrieves a list of tags names this is known to be associated with. ++ * This should be used in favor of TagCollection.getOwningTags, as this caches the result and automatically updates when the TagCollection changes. ++ */ ++ public java.util.Set getTags() { ++ return reverseTags.getTagNames(); ++ } ++ + public static class Builder { + private final EntityType.EntityFactory f_20685_; + private final MobCategory f_20686_; +@@ -579,6 +_,11 @@ + private int f_20693_ = 3; + private EntityDimensions f_20694_ = EntityDimensions.m_20395_(0.6F, 1.8F); + ++ private java.util.function.Predicate> velocityUpdateSupplier = EntityType::defaultVelocitySupplier; ++ private java.util.function.ToIntFunction> trackingRangeSupplier = EntityType::defaultTrackingRangeSupplier; ++ private java.util.function.ToIntFunction> updateIntervalSupplier = EntityType::defaultUpdateIntervalSupplier; ++ private java.util.function.BiFunction customClientFactory; ++ + private Builder(EntityType.EntityFactory p_20696_, MobCategory p_20697_) { + this.f_20685_ = p_20696_; + this.f_20686_ = p_20697_; +@@ -635,12 +_,36 @@ + return this; + } + ++ public EntityType.Builder setUpdateInterval(int interval) { ++ this.updateIntervalSupplier = t->interval; ++ return this; ++ } ++ ++ public EntityType.Builder setTrackingRange(int range) { ++ this.trackingRangeSupplier = t->range; ++ return this; ++ } ++ ++ public EntityType.Builder setShouldReceiveVelocityUpdates(boolean value) { ++ this.velocityUpdateSupplier = t->value; ++ return this; ++ } ++ ++ /** ++ * By default, entities are spawned clientside via {@link EntityType#create(Level)}}. ++ * If you need finer control over the spawning process, use this to get read access to the spawn packet. ++ */ ++ public EntityType.Builder setCustomClientFactory(java.util.function.BiFunction customClientFactory) { ++ this.customClientFactory = customClientFactory; ++ return this; ++ } ++ + public EntityType m_20712_(String p_20713_) { + if (this.f_20688_) { + Util.m_137456_(References.f_16785_, p_20713_); + } + +- return new EntityType<>(this.f_20685_, this.f_20686_, this.f_20688_, this.f_20689_, this.f_20690_, this.f_20691_, this.f_20687_, this.f_20694_, this.f_20692_, this.f_20693_); ++ return new EntityType<>(this.f_20685_, this.f_20686_, this.f_20688_, this.f_20689_, this.f_20690_, this.f_20691_, this.f_20687_, this.f_20694_, this.f_20692_, this.f_20693_, velocityUpdateSupplier, trackingRangeSupplier, updateIntervalSupplier, customClientFactory); + } + } + diff --git a/patches/minecraft/net/minecraft/world/entity/ExperienceOrb.java.patch b/patches/minecraft/net/minecraft/world/entity/ExperienceOrb.java.patch new file mode 100644 index 0000000000..9d714c3720 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/ExperienceOrb.java.patch @@ -0,0 +1,37 @@ +--- a/net/minecraft/world/entity/ExperienceOrb.java ++++ b/net/minecraft/world/entity/ExperienceOrb.java +@@ -89,7 +_,8 @@ + this.m_6478_(MoverType.SELF, this.m_20184_()); + float f = 0.98F; + if (this.f_19861_) { +- f = this.f_19853_.m_8055_(new BlockPos(this.m_20185_(), this.m_20186_() - 1.0D, this.m_20189_())).m_60734_().m_49958_() * 0.98F; ++ BlockPos pos =new BlockPos(this.m_20185_(), this.m_20186_() - 1.0D, this.m_20189_()); ++ f = this.f_19853_.m_8055_(pos).getFriction(this.f_19853_, pos, this) * 0.98F; + } + + this.m_20256_(this.m_20184_().m_82542_((double)f, 0.98D, (double)f)); +@@ -167,6 +_,7 @@ + } + + public boolean m_6469_(DamageSource p_20785_, float p_20786_) { ++ if (this.f_19853_.f_46443_ || this.m_146910_()) return false; //Forge: Fixes MC-53850 + if (this.m_6673_(p_20785_)) { + return false; + } else { +@@ -197,6 +_,7 @@ + public void m_6123_(Player p_20792_) { + if (!this.f_19853_.f_46443_) { + if (p_20792_.f_36101_ == 0) { ++ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerXpEvent.PickupXp(p_20792_, this))) return; + p_20792_.f_36101_ = 2; + p_20792_.m_7938_(this, 1); + int i = this.m_147092_(p_20792_, this.f_20770_); +@@ -217,7 +_,7 @@ + Entry entry = EnchantmentHelper.m_44839_(Enchantments.f_44962_, p_147093_, ItemStack::m_41768_); + if (entry != null) { + ItemStack itemstack = entry.getValue(); +- int i = Math.min(this.m_20798_(this.f_20770_), itemstack.m_41773_()); ++ int i = Math.min((int) (this.f_20770_ * itemstack.getXpRepairRatio()), itemstack.m_41773_()); + itemstack.m_41721_(itemstack.m_41773_() - i); + int j = p_147094_ - this.m_20793_(i); + return j > 0 ? this.m_147092_(p_147093_, j) : 0; diff --git a/patches/minecraft/net/minecraft/world/entity/FlyingMob.java.patch b/patches/minecraft/net/minecraft/world/entity/FlyingMob.java.patch new file mode 100644 index 0000000000..1670088303 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/FlyingMob.java.patch @@ -0,0 +1,21 @@ +--- a/net/minecraft/world/entity/FlyingMob.java ++++ b/net/minecraft/world/entity/FlyingMob.java +@@ -28,15 +_,16 @@ + this.m_6478_(MoverType.SELF, this.m_20184_()); + this.m_20256_(this.m_20184_().m_82490_(0.5D)); + } else { ++ BlockPos ground = new BlockPos(this.m_20185_(), this.m_20186_() - 1.0D, this.m_20189_()); + float f = 0.91F; + if (this.f_19861_) { +- f = this.f_19853_.m_8055_(new BlockPos(this.m_20185_(), this.m_20186_() - 1.0D, this.m_20189_())).m_60734_().m_49958_() * 0.91F; ++ f = this.f_19853_.m_8055_(ground).getFriction(this.f_19853_, ground, this) * 0.91F; + } + + float f1 = 0.16277137F / (f * f * f); + f = 0.91F; + if (this.f_19861_) { +- f = this.f_19853_.m_8055_(new BlockPos(this.m_20185_(), this.m_20186_() - 1.0D, this.m_20189_())).m_60734_().m_49958_() * 0.91F; ++ f = this.f_19853_.m_8055_(ground).getFriction(this.f_19853_, ground, this) * 0.91F; + } + + this.m_19920_(this.f_19861_ ? 0.1F * f1 : 0.02F, p_20818_); diff --git a/patches/minecraft/net/minecraft/world/entity/LightningBolt.java.patch b/patches/minecraft/net/minecraft/world/entity/LightningBolt.java.patch new file mode 100644 index 0000000000..029df91c98 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/LightningBolt.java.patch @@ -0,0 +1,33 @@ +--- a/net/minecraft/world/entity/LightningBolt.java ++++ b/net/minecraft/world/entity/LightningBolt.java +@@ -39,6 +_,7 @@ + private ServerPlayer f_20863_; + private final Set f_147134_ = Sets.newHashSet(); + private int f_147135_; ++ private float damage = 5.0F; + + public LightningBolt(EntityType p_20865_, Level p_20866_) { + super(p_20865_, p_20866_); +@@ -74,6 +_,14 @@ + + } + ++ public void setDamage(float damage) { ++ this.damage = damage; ++ } ++ ++ public float getDamage() { ++ return this.damage; ++ } ++ + public void m_8119_() { + super.m_8119_(); + if (this.f_20860_ == 2) { +@@ -123,6 +_,7 @@ + List list1 = this.f_19853_.m_6249_(this, new AABB(this.m_20185_() - 3.0D, this.m_20186_() - 3.0D, this.m_20189_() - 3.0D, this.m_20185_() + 3.0D, this.m_20186_() + 6.0D + 3.0D, this.m_20189_() + 3.0D), Entity::m_6084_); + + for(Entity entity : list1) { ++ if (!net.minecraftforge.event.ForgeEventFactory.onEntityStruckByLightning(entity, this)) + entity.m_8038_((ServerLevel)this.f_19853_, this); + } + diff --git a/patches/minecraft/net/minecraft/world/entity/LivingEntity.java.patch b/patches/minecraft/net/minecraft/world/entity/LivingEntity.java.patch new file mode 100644 index 0000000000..626761732f --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/LivingEntity.java.patch @@ -0,0 +1,566 @@ +--- a/net/minecraft/world/entity/LivingEntity.java ++++ b/net/minecraft/world/entity/LivingEntity.java +@@ -118,7 +_,9 @@ + private static final UUID f_20929_ = UUID.fromString("662A6B8D-DA3E-4C1C-8813-96EA6097278D"); + 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 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; + public static final int f_147168_ = 98; +@@ -268,7 +_,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_(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()); + } + + protected void m_7840_(double p_20990_, boolean p_20991_, BlockState p_20992_, BlockPos p_20993_) { +@@ -286,7 +_,8 @@ + if (!p_20992_.m_60795_()) { + double d0 = Math.min((double)(0.2F + f / 15.0F), 2.5D); + int i = (int)(150.0D * d0); +- ((ServerLevel)this.f_19853_).m_8767_(new BlockParticleOption(ParticleTypes.f_123794_, p_20992_), this.m_20185_(), this.m_20186_(), this.m_20189_(), i, 0.0D, 0.0D, 0.0D, (double)0.15F); ++ if (!p_20992_.addLandingEffects((ServerLevel)this.f_19853_, p_20993_, p_20992_, this, i)) ++ ((ServerLevel)this.f_19853_).m_8767_(new BlockParticleOption(ParticleTypes.f_123794_, p_20992_).setPos(p_20993_), this.m_20185_(), this.m_20186_(), this.m_20189_(), i, 0.0D, 0.0D, 0.0D, (double)0.15F); + } + } + +@@ -352,7 +_,7 @@ + } + } + +- if (!this.f_19853_.f_46443_ && this.m_20159_() && this.m_20202_() != null && !this.m_20202_().m_6146_()) { ++ if (!this.f_19853_.f_46443_ && this.m_20159_() && this.m_20202_() != null && !this.m_20202_().canBeRiddenInWater(this)) { + this.m_8127_(); + } + } else if (this.m_20146_() < this.m_6062_()) { +@@ -716,7 +_,7 @@ + if (!mobeffectinstance.m_19552_(this, () -> { + this.m_141973_(mobeffectinstance, true, (Entity)null); + })) { +- if (!this.f_19853_.f_46443_) { ++ if (!this.f_19853_.f_46443_ && !net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.living.PotionEvent.PotionExpiryEvent(this, mobeffectinstance))) { + iterator.remove(); + this.m_7285_(mobeffectinstance); + } +@@ -766,8 +_,10 @@ + this.m_6842_(false); + } else { + Collection collection = this.f_20945_.values(); +- this.f_19804_.m_135381_(f_20963_, m_21179_(collection)); +- this.f_19804_.m_135381_(f_20962_, PotionUtils.m_43564_(collection)); ++ net.minecraftforge.event.entity.living.PotionColorCalculationEvent event = new net.minecraftforge.event.entity.living.PotionColorCalculationEvent(this, PotionUtils.m_43564_(collection), m_21179_(collection), collection); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); ++ this.f_19804_.m_135381_(f_20963_, event.areParticlesHidden()); ++ this.f_19804_.m_135381_(f_20962_, event.getColor()); + this.m_6842_(this.m_21023_(MobEffects.f_19609_)); + } + +@@ -803,7 +_,7 @@ + d0 *= 0.5D; + } + } +- ++ d0 = net.minecraftforge.common.ForgeHooks.getEntityVisibilityMultiplier(this, p_20969_, d0); + return d0; + } + +@@ -846,7 +_,9 @@ + + boolean flag; + for(flag = false; iterator.hasNext(); flag = true) { +- this.m_7285_(iterator.next()); ++ MobEffectInstance effect = iterator.next(); ++ if(net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.living.PotionEvent.PotionRemoveEvent(this, effect))) continue; ++ this.m_7285_(effect); + iterator.remove(); + } + +@@ -880,6 +_,7 @@ + return false; + } else { + MobEffectInstance mobeffectinstance = this.f_20945_.get(p_147208_.m_19544_()); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.living.PotionEvent.PotionAddedEvent(this, mobeffectinstance, p_147208_)); + if (mobeffectinstance == null) { + this.f_20945_.put(p_147208_.m_19544_(), p_147208_); + this.m_142540_(p_147208_, p_147209_); +@@ -894,6 +_,9 @@ + } + + public boolean m_7301_(MobEffectInstance p_21197_) { ++ net.minecraftforge.event.entity.living.PotionEvent.PotionApplicableEvent event = new net.minecraftforge.event.entity.living.PotionEvent.PotionApplicableEvent(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_) { +@@ -926,6 +_,7 @@ + } + + public boolean m_21195_(MobEffect p_21196_) { ++ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.living.PotionEvent.PotionRemoveEvent(this, p_21196_))) return false; + MobEffectInstance mobeffectinstance = this.m_6234_(p_21196_); + if (mobeffectinstance != null) { + this.m_7285_(mobeffectinstance); +@@ -962,6 +_,8 @@ + } + + public void m_5634_(float p_21116_) { ++ p_21116_ = net.minecraftforge.event.ForgeEventFactory.onLivingHeal(this, p_21116_); ++ if (p_21116_ <= 0) return; + float f = this.m_21223_(); + if (f > 0.0F) { + this.m_21153_(f + p_21116_); +@@ -982,6 +_,7 @@ + } + + public boolean m_6469_(DamageSource p_21016_, float p_21017_) { ++ if (!net.minecraftforge.common.ForgeHooks.onLivingAttack(this, p_21016_, p_21017_)) return false; + if (this.m_6673_(p_21016_)) { + return false; + } else if (this.f_19853_.f_46443_) { +@@ -1046,11 +_,11 @@ + if (entity1 instanceof Player) { + this.f_20889_ = 100; + this.f_20888_ = (Player)entity1; +- } else if (entity1 instanceof Wolf) { +- Wolf wolf = (Wolf)entity1; +- if (wolf.m_21824_()) { ++ } else if (entity1 instanceof net.minecraft.world.entity.TamableAnimal) { ++ net.minecraft.world.entity.TamableAnimal tamableEntity = (net.minecraft.world.entity.TamableAnimal)entity1; ++ if (tamableEntity.m_21824_()) { + this.f_20889_ = 100; +- LivingEntity livingentity = wolf.m_142480_(); ++ LivingEntity livingentity = tamableEntity.m_142480_(); + if (livingentity != null && livingentity.m_6095_() == EntityType.f_20532_) { + this.f_20888_ = (Player)livingentity; + } else { +@@ -1123,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) { +- ((ServerPlayer)this).m_36222_(Stats.f_12932_, Math.round(f1 * 10.0F)); ++ ((ServerPlayer)this).m_6278_(Stats.f_12988_.m_12902_(Stats.f_12932_), Math.round(f1 * 10.0F)); + } + } + +@@ -1161,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); + } + +@@ -1231,6 +_,7 @@ + } + + public void m_6667_(DamageSource p_21014_) { ++ if (net.minecraftforge.common.ForgeHooks.onLivingDeath(this, p_21014_)) return; + if (!this.m_146910_() && !this.f_20890_) { + Entity entity = p_21014_.m_7639_(); + LivingEntity livingentity = this.m_21232_(); +@@ -1266,10 +_,10 @@ + if (!this.f_19853_.f_46443_) { + boolean flag = false; + if (p_21269_ instanceof WitherBoss) { +- if (this.f_19853_.m_46469_().m_46207_(GameRules.f_46132_)) { ++ if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_19853_, this)) { + BlockPos blockpos = this.m_142538_(); + BlockState blockstate = Blocks.f_50070_.m_49966_(); +- if (this.f_19853_.m_8055_(blockpos).m_60795_() && blockstate.m_60710_(this.f_19853_, blockpos)) { ++ if (this.f_19853_.m_46859_(blockpos) && blockstate.m_60710_(this.f_19853_, blockpos)) { + this.f_19853_.m_7731_(blockpos, blockstate, 3); + flag = true; + } +@@ -1286,12 +_,9 @@ + + protected void m_6668_(DamageSource p_21192_) { + Entity entity = p_21192_.m_7639_(); +- int i; +- if (entity instanceof Player) { +- i = EnchantmentHelper.m_44930_((LivingEntity)entity); +- } else { +- i = 0; +- } ++ ++ int i = net.minecraftforge.common.ForgeHooks.getLootingLevel(this, entity, p_21192_); ++ this.captureDrops(new java.util.ArrayList<>()); + + boolean flag = this.f_20889_ > 0; + if (this.m_6125_() && this.f_19853_.m_46469_().m_46207_(GameRules.f_46135_)) { +@@ -1301,6 +_,10 @@ + + this.m_5907_(); + this.m_21226_(); ++ ++ Collection drops = captureDrops(null); ++ if (!net.minecraftforge.common.ForgeHooks.onLivingDrops(this, p_21192_, drops, i, f_20889_ > 0)) ++ drops.forEach(e -> f_19853_.m_7967_(e)); + } + + protected void m_5907_() { +@@ -1324,7 +_,8 @@ + ResourceLocation resourcelocation = this.m_5743_(); + LootTable loottable = this.f_19853_.m_142572_().m_129898_().m_79217_(resourcelocation); + LootContext.Builder lootcontext$builder = this.m_7771_(p_21022_, p_21021_); +- loottable.m_79148_(lootcontext$builder.m_78975_(LootContextParamSets.f_81415_), this::m_19983_); ++ LootContext ctx = lootcontext$builder.m_78975_(LootContextParamSets.f_81415_); ++ loottable.m_79129_(ctx).forEach(this::m_19983_); + } + + protected LootContext.Builder m_7771_(boolean p_21105_, DamageSource p_21106_) { +@@ -1337,6 +_,11 @@ + } + + public void m_147240_(double p_147241_, double p_147242_, double p_147243_) { ++ net.minecraftforge.event.entity.living.LivingKnockBackEvent event = net.minecraftforge.common.ForgeHooks.onLivingKnockBack(this, (float) p_147241_, p_147242_, p_147243_); ++ if(event.isCanceled()) return; ++ p_147241_ = event.getStrength(); ++ p_147242_ = event.getRatioX(); ++ p_147243_ = event.getRatioZ(); + p_147241_ = p_147241_ * (1.0D - this.m_21133_(Attributes.f_22278_)); + if (!(p_147241_ <= 0.0D)) { + this.f_19812_ = true; +@@ -1386,15 +_,7 @@ + } else { + BlockPos blockpos = this.m_142538_(); + BlockState blockstate = this.m_146900_(); +- if (blockstate.m_60620_(BlockTags.f_13082_)) { +- this.f_20957_ = Optional.of(blockpos); +- return true; +- } else if (blockstate.m_60734_() instanceof TrapDoorBlock && this.m_21176_(blockpos, blockstate)) { +- this.f_20957_ = Optional.of(blockpos); +- return true; +- } else { +- return false; +- } ++ return net.minecraftforge.common.ForgeHooks.isLivingOnLadder(blockstate, f_19853_, blockpos, this); + } + } + +@@ -1414,6 +_,11 @@ + } + + public boolean m_142535_(float p_147187_, float p_147188_, DamageSource p_147189_) { ++ float[] ret = net.minecraftforge.common.ForgeHooks.onLivingFall(this, p_147187_, p_147188_); ++ if (ret == null) return false; ++ p_147187_ = ret[0]; ++ p_147188_ = ret[1]; ++ + boolean flag = super.m_142535_(p_147187_, p_147188_, p_147189_); + int i = this.m_5639_(p_147187_, p_147188_); + if (i > 0) { +@@ -1437,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_()); +- BlockState blockstate = this.f_19853_.m_8055_(new BlockPos(i, j, k)); ++ BlockPos pos = new BlockPos(i, j, k); ++ BlockState blockstate = this.f_19853_.m_8055_(pos); + if (!blockstate.m_60795_()) { +- SoundType soundtype = blockstate.m_60827_(); ++ SoundType soundtype = blockstate.getSoundType(f_19853_, pos, this); + this.m_5496_(soundtype.m_56779_(), soundtype.m_56773_() * 0.5F, soundtype.m_56774_() * 0.75F); + } + +@@ -1487,9 +_,9 @@ + float f2 = f1 - p_21194_; + if (f2 > 0.0F && f2 < 3.4028235E37F) { + if (this instanceof ServerPlayer) { +- ((ServerPlayer)this).m_36222_(Stats.f_12934_, Math.round(f2 * 10.0F)); ++ ((ServerPlayer)this).m_6278_(Stats.f_12988_.m_12902_(Stats.f_12934_), Math.round(f2 * 10.0F)); + } else if (p_21193_.m_7639_() instanceof ServerPlayer) { +- ((ServerPlayer)p_21193_.m_7639_()).m_36222_(Stats.f_12930_, Math.round(f2 * 10.0F)); ++ ((ServerPlayer)p_21193_.m_7639_()).m_6278_(Stats.f_12988_.m_12902_(Stats.f_12930_), Math.round(f2 * 10.0F)); + } + } + } +@@ -1509,19 +_,22 @@ + + protected void m_6475_(DamageSource p_21240_, float p_21241_) { + if (!this.m_6673_(p_21240_)) { ++ p_21241_ = net.minecraftforge.common.ForgeHooks.onLivingHurt(this, p_21240_, p_21241_); ++ if (p_21241_ <= 0) return; + p_21241_ = this.m_21161_(p_21240_, p_21241_); + p_21241_ = this.m_6515_(p_21240_, p_21241_); + float f2 = Math.max(p_21241_ - this.m_6103_(), 0.0F); + this.m_7911_(this.m_6103_() - (p_21241_ - f2)); + float f = p_21241_ - f2; + if (f > 0.0F && f < 3.4028235E37F && p_21240_.m_7639_() instanceof ServerPlayer) { +- ((ServerPlayer)p_21240_.m_7639_()).m_36222_(Stats.f_12929_, Math.round(f * 10.0F)); ++ ((ServerPlayer)p_21240_.m_7639_()).m_6278_(Stats.f_12988_.m_12902_(Stats.f_12929_), Math.round(f * 10.0F)); + } + ++ f2 = net.minecraftforge.common.ForgeHooks.onLivingDamage(this, p_21240_, f2); + if (f2 != 0.0F) { + float f1 = this.m_21223_(); +- this.m_21153_(f1 - f2); + this.m_21231_().m_19289_(p_21240_, f1, f2); ++ this.m_21153_(f1 - f2); // Forge: moved to fix MC-121048 + this.m_7911_(this.m_6103_() - f2); + this.m_146852_(GameEvent.f_157808_, p_21240_.m_7639_()); + } +@@ -1576,6 +_,8 @@ + } + + public void m_21011_(InteractionHand p_21012_, boolean p_21013_) { ++ ItemStack stack = this.m_21120_(p_21012_); ++ if (!stack.m_41619_() && stack.onEntitySwing(this)) return; + if (!this.f_20911_ || this.f_20913_ >= this.m_21304_() / 2 || this.f_20913_ < 0) { + this.f_20913_ = -1; + this.f_20911_ = true; +@@ -1935,14 +_,15 @@ + } + + this.f_19812_ = true; ++ net.minecraftforge.common.ForgeHooks.onLivingJump(this); + } + + protected void m_21208_() { +- this.m_20256_(this.m_20184_().m_82520_(0.0D, (double)-0.04F, 0.0D)); ++ this.m_20256_(this.m_20184_().m_82520_(0.0D, (double)-0.04F * this.m_21051_(net.minecraftforge.common.ForgeMod.SWIM_SPEED.get()).m_22135_(), 0.0D)); + } + + protected void m_6197_(net.minecraft.tags.Tag p_21158_) { +- this.m_20256_(this.m_20184_().m_82520_(0.0D, (double)0.04F, 0.0D)); ++ this.m_20256_(this.m_20184_().m_82520_(0.0D, (double)0.04F * this.m_21051_(net.minecraftforge.common.ForgeMod.SWIM_SPEED.get()).m_22135_(), 0.0D)); + } + + protected float m_6108_() { +@@ -1956,11 +_,15 @@ + public void m_7023_(Vec3 p_21280_) { + if (this.m_6142_() || this.m_6109_()) { + double d0 = 0.08D; ++ AttributeInstance gravity = this.m_21051_(net.minecraftforge.common.ForgeMod.ENTITY_GRAVITY.get()); + 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); + this.f_19789_ = 0.0F; ++ } else if (gravity.m_22109_(SLOW_FALLING)) { ++ gravity.m_22130_(SLOW_FALLING); + } ++ d0 = gravity.m_22135_(); + + FluidState fluidstate = this.f_19853_.m_6425_(this.m_142538_()); + if (this.m_20069_() && this.m_6129_() && !this.m_7479_(fluidstate.m_76152_())) { +@@ -1985,6 +_,7 @@ + f5 = 0.96F; + } + ++ f6 *= (float)this.m_21051_(net.minecraftforge.common.ForgeMod.SWIM_SPEED.get()).m_22135_(); + this.m_19920_(f6, p_21280_); + this.m_6478_(MoverType.SELF, this.m_20184_()); + Vec3 vec36 = this.m_20184_(); +@@ -2063,7 +_,7 @@ + } + } else { + BlockPos blockpos = this.m_20099_(); +- float f3 = this.f_19853_.m_8055_(blockpos).m_60734_().m_49958_(); ++ float f3 = this.f_19853_.m_8055_(this.m_20099_()).getFriction(f_19853_, this.m_20099_(), this); + float f4 = this.f_19861_ ? f3 * 0.91F : 0.91F; + Vec3 vec35 = this.m_21074_(p_21280_, f3); + double d2 = vec35.f_82480_; +@@ -2139,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); +- if (d2 < 0.0D && !this.m_146900_().m_60713_(Blocks.f_50616_) && this.m_5791_() && this instanceof Player) { ++ if (d2 < 0.0D && !this.m_146900_().isScaffolding(this) && this.m_5791_() && this instanceof Player) { + d2 = 0.0D; + } + +@@ -2167,6 +_,7 @@ + } + + public void m_8119_() { ++ if (net.minecraftforge.common.ForgeHooks.onLivingUpdate(this)) return; + super.m_8119_(); + this.m_21329_(); + this.m_21333_(); +@@ -2315,6 +_,7 @@ + + ItemStack itemstack1 = this.m_6844_(equipmentslot); + if (!ItemStack.m_41728_(itemstack1, itemstack)) { ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.living.LivingEquipmentChangeEvent(this, equipmentslot, itemstack, itemstack1)); + if (map == null) { + map = Maps.newEnumMap(EquipmentSlot.class); + } +@@ -2538,6 +_,8 @@ + boolean flag = this.m_20291_(7); + if (flag && !this.f_19861_ && !this.m_20159_() && !this.m_21023_(MobEffects.f_19620_)) { + ItemStack itemstack = this.m_6844_(EquipmentSlot.CHEST); ++ flag = itemstack.canElytraFly(this) && itemstack.elytraFlightTick(this, this.f_20937_); ++ if (false) //Forge: Moved to ElytraItem + if (itemstack.m_150930_(Items.f_42741_) && ElytraItem.m_41140_(itemstack)) { + flag = true; + int i = this.f_20937_ + 1; +@@ -2781,8 +_,16 @@ + + private void m_21329_() { + if (this.m_6117_()) { +- if (ItemStack.m_41758_(this.m_21120_(this.m_7655_()), this.f_20935_)) { +- this.f_20935_ = this.m_21120_(this.m_7655_()); ++ ItemStack itemStack = this.m_21120_(this.m_7655_()); ++ if (net.minecraftforge.common.ForgeHooks.canContinueUsing(this.f_20935_, itemStack)) this.f_20935_ = itemStack; ++ if (itemStack == this.f_20935_) { ++ ++ if (!this.f_20935_.m_41619_()) { ++ f_20936_ = net.minecraftforge.event.ForgeEventFactory.onItemUseTick(this, f_20935_, f_20936_); ++ if (f_20936_ > 0) ++ f_20935_.onUsingTick(this, f_20936_); ++ } ++ + this.m_142106_(this.f_20935_); + } else { + this.m_5810_(); +@@ -2835,8 +_,10 @@ + public void m_6672_(InteractionHand p_21159_) { + ItemStack itemstack = this.m_21120_(p_21159_); + if (!itemstack.m_41619_() && !this.m_6117_()) { ++ int duration = net.minecraftforge.event.ForgeEventFactory.onItemUseStart(this, itemstack, itemstack.m_41779_()); ++ if (duration <= 0) return; + this.f_20935_ = itemstack; +- this.f_20936_ = itemstack.m_41779_(); ++ this.f_20936_ = duration; + if (!this.f_19853_.f_46443_) { + this.m_21155_(1, true); + this.m_21155_(2, p_21159_ == InteractionHand.OFF_HAND); +@@ -2896,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_()); ++ if (this.f_19853_ instanceof ServerLevel) //Forge: Fix MC-2518 spawnParticle is nooped on server, need to use server specific variant ++ ((ServerLevel)this.f_19853_).m_8767_(new ItemParticleOption(ParticleTypes.f_123752_, p_21061_), vec31.f_82479_, vec31.f_82480_, vec31.f_82481_, 1, vec3.f_82479_, vec3.f_82480_ + 0.05D, vec3.f_82481_, 0.0D); ++ else + this.f_19853_.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_); + } + +@@ -2908,7 +_,8 @@ + } else { + if (!this.f_20935_.m_41619_() && this.m_6117_()) { + this.m_21137_(this.f_20935_, 16); +- ItemStack itemstack = this.f_20935_.m_41671_(this.f_19853_, this); ++ ItemStack copy = this.f_20935_.m_41777_(); ++ ItemStack itemstack = net.minecraftforge.event.ForgeEventFactory.onItemUseFinish(this, copy, m_21212_(), this.f_20935_.m_41671_(this.f_19853_, this)); + if (itemstack != this.f_20935_) { + this.m_21008_(interactionhand, itemstack); + } +@@ -2933,7 +_,11 @@ + + public void m_21253_() { + if (!this.f_20935_.m_41619_()) { ++ if (!net.minecraftforge.event.ForgeEventFactory.onUseItemStop(this, f_20935_, this.m_21212_())) { ++ ItemStack copy = this instanceof Player ? f_20935_.m_41777_() : null; + this.f_20935_.m_41674_(this.f_19853_, this, this.m_21212_()); ++ if (copy != null && f_20935_.m_41619_()) net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem((Player)this, copy, m_7655_()); ++ } + if (this.f_20935_.m_41781_()) { + this.m_21329_(); + } +@@ -3080,8 +_,8 @@ + } + + BlockState blockstate = this.f_19853_.m_8055_(p_21141_); +- if (blockstate.m_60734_() instanceof BedBlock) { +- this.f_19853_.m_7731_(p_21141_, blockstate.m_61124_(BedBlock.f_49441_, Boolean.valueOf(true)), 3); ++ if (blockstate.isBed(f_19853_, p_21141_, this)) { ++ blockstate.setBedOccupied(f_19853_, p_21141_, this, true); + } + + this.m_20124_(Pose.SLEEPING); +@@ -3097,15 +_,15 @@ + + private boolean m_21334_() { + return this.m_21257_().map((p_147236_) -> { +- return this.f_19853_.m_8055_(p_147236_).m_60734_() instanceof BedBlock; ++ return net.minecraftforge.event.ForgeEventFactory.fireSleepingLocationCheck(this, p_147236_); + }).orElse(false); + } + + public void m_5796_() { + this.m_21257_().filter(this.f_19853_::m_46805_).ifPresent((p_147228_) -> { + BlockState blockstate = this.f_19853_.m_8055_(p_147228_); +- if (blockstate.m_60734_() instanceof BedBlock) { +- this.f_19853_.m_7731_(p_147228_, blockstate.m_61124_(BedBlock.f_49441_, Boolean.valueOf(false)), 3); ++ if (blockstate.isBed(f_19853_, p_147228_, this)) { ++ blockstate.setBedOccupied(f_19853_, p_147228_, this, false); + Vec3 vec31 = BedBlock.m_49458_(this.m_6095_(), this.f_19853_, p_147228_, this.m_146908_()).orElseGet(() -> { + BlockPos blockpos = p_147228_.m_7494_(); + return new Vec3((double)blockpos.m_123341_() + 0.5D, (double)blockpos.m_123342_() + 0.1D, (double)blockpos.m_123343_() + 0.5D); +@@ -3127,7 +_,9 @@ + @Nullable + public Direction m_21259_() { + BlockPos blockpos = this.m_21257_().orElse((BlockPos)null); +- return blockpos != null ? BedBlock.m_49485_(this.f_19853_, blockpos) : null; ++ if (blockpos == null) return Direction.UP; ++ BlockState state = this.f_19853_.m_8055_(blockpos); ++ return !state.isBed(f_19853_, blockpos, this) ? Direction.UP : state.getBedDirection(f_19853_, blockpos); + } + + public boolean m_5830_() { +@@ -3198,6 +_,58 @@ + + public void m_21190_(InteractionHand p_21191_) { + this.m_21166_(p_21191_ == InteractionHand.MAIN_HAND ? EquipmentSlot.MAINHAND : EquipmentSlot.OFFHAND); ++ } ++ ++ /* ==== FORGE START ==== */ ++ /*** ++ * Removes all potion effects that have curativeItem as a curative item for its effect ++ * @param curativeItem The itemstack we are using to cure potion effects ++ */ ++ public boolean curePotionEffects(ItemStack curativeItem) { ++ if (this.f_19853_.f_46443_) ++ return false; ++ boolean ret = false; ++ Iterator itr = this.f_20945_.values().iterator(); ++ while (itr.hasNext()) { ++ MobEffectInstance effect = itr.next(); ++ if (effect.isCurativeItem(curativeItem) && !net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.living.PotionEvent.PotionRemoveEvent(this, effect))) { ++ this.m_7285_(effect); ++ itr.remove(); ++ ret = true; ++ this.f_20948_ = true; ++ } ++ } ++ return ret; ++ } ++ ++ /** ++ * Returns true if the entity's rider (EntityPlayer) should face forward when mounted. ++ * currently only used in vanilla code by pigs. ++ * ++ * @param player The player who is riding the entity. ++ * @return If the player should orient the same direction as this entity. ++ */ ++ public boolean shouldRiderFaceForward(Player player) { ++ return this instanceof net.minecraft.world.entity.animal.Pig; ++ } ++ ++ private final net.minecraftforge.common.util.LazyOptional[] handlers = net.minecraftforge.items.wrapper.EntityEquipmentInvWrapper.create(this); ++ ++ @Override ++ public net.minecraftforge.common.util.LazyOptional getCapability(net.minecraftforge.common.capabilities.Capability capability, @Nullable Direction facing) { ++ if (this.m_6084_() && capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { ++ if (facing == null) return handlers[2].cast(); ++ else if (facing.m_122434_().m_122478_()) return handlers[0].cast(); ++ else if (facing.m_122434_().m_122479_()) return handlers[1].cast(); ++ } ++ return super.getCapability(capability, facing); ++ } ++ ++ @Override ++ protected void invalidateCaps() { ++ super.invalidateCaps(); ++ for (int x = 0; x < handlers.length; x++) ++ handlers[x].invalidate(); + } + + public AABB m_6921_() { diff --git a/patches/minecraft/net/minecraft/world/entity/Mob.java.patch b/patches/minecraft/net/minecraft/world/entity/Mob.java.patch new file mode 100644 index 0000000000..0d94cfdb93 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/Mob.java.patch @@ -0,0 +1,34 @@ +--- a/net/minecraft/world/entity/Mob.java ++++ b/net/minecraft/world/entity/Mob.java +@@ -202,6 +_,7 @@ + + public void m_6710_(@Nullable LivingEntity p_21544_) { + this.f_21362_ = p_21544_; ++ net.minecraftforge.common.ForgeHooks.onLivingSetAttackTarget(this, p_21544_); + } + + public boolean m_6549_(EntityType p_21399_) { +@@ -489,7 +_,7 @@ + public void m_8107_() { + super.m_8107_(); + this.f_19853_.m_46473_().m_6180_("looting"); +- if (!this.f_19853_.f_46443_ && this.m_21531_() && this.m_6084_() && !this.f_20890_ && this.f_19853_.m_46469_().m_46207_(GameRules.f_46132_)) { ++ if (!this.f_19853_.f_46443_ && this.m_21531_() && this.m_6084_() && !this.f_20890_ && net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_19853_, this)) { + for(ItemEntity itementity : this.f_19853_.m_45976_(ItemEntity.class, this.m_142469_().m_82377_(1.0D, 0.0D, 1.0D))) { + if (!itementity.m_146910_() && !itementity.m_32055_().m_41619_() && !itementity.m_32063_() && this.m_7243_(itementity.m_32055_())) { + this.m_7581_(itementity); +@@ -642,6 +_,14 @@ + this.m_146870_(); + } else if (!this.m_21532_() && !this.m_8023_()) { + Entity entity = this.f_19853_.m_45930_(this, -1.0D); ++ net.minecraftforge.eventbus.api.Event.Result result = net.minecraftforge.event.ForgeEventFactory.canEntityDespawn(this); ++ if (result == net.minecraftforge.eventbus.api.Event.Result.DENY) { ++ f_20891_ = 0; ++ entity = null; ++ } else if (result == net.minecraftforge.eventbus.api.Event.Result.ALLOW) { ++ this.remove(false); ++ entity = null; ++ } + if (entity != null) { + double d0 = entity.m_20280_(this); + int i = this.m_6095_().m_20674_().m_21611_(); diff --git a/patches/minecraft/net/minecraft/world/entity/MobCategory.java.patch b/patches/minecraft/net/minecraft/world/entity/MobCategory.java.patch new file mode 100644 index 0000000000..7a4c65b105 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/MobCategory.java.patch @@ -0,0 +1,37 @@ +--- a/net/minecraft/world/entity/MobCategory.java ++++ b/net/minecraft/world/entity/MobCategory.java +@@ -6,7 +_,7 @@ + import java.util.stream.Collectors; + import net.minecraft.util.StringRepresentable; + +-public enum MobCategory implements StringRepresentable { ++public enum MobCategory implements StringRepresentable, net.minecraftforge.common.IExtensibleEnum { + MONSTER("monster", 70, false, false, 128), + CREATURE("creature", 10, true, true, 128), + AMBIENT("ambient", 15, true, false, 128), +@@ -15,7 +_,7 @@ + WATER_AMBIENT("water_ambient", 20, true, false, 64), + MISC("misc", -1, true, true, 128); + +- public static final Codec f_21584_ = StringRepresentable.m_14350_(MobCategory::values, MobCategory::m_21605_); ++ public static final Codec f_21584_ = net.minecraftforge.common.IExtensibleEnum.createCodecForExtensibleEnum(MobCategory::values, MobCategory::m_21605_); + private static final Map f_21585_ = Arrays.stream(values()).collect(Collectors.toMap(MobCategory::m_21607_, (p_21604_) -> { + return p_21604_; + })); +@@ -56,6 +_,16 @@ + + public boolean m_21610_() { + return this.f_21588_; ++ } ++ ++ public static MobCategory create(String name, String id, int maxNumberOfCreatureIn, boolean isPeacefulCreatureIn, boolean isAnimalIn, int despawnDistance) { ++ throw new IllegalStateException("Enum not extended"); ++ } ++ ++ @Override ++ @Deprecated ++ public void init() { ++ f_21585_.put(this.m_21607_(), this); + } + + public int m_21611_() { diff --git a/patches/minecraft/net/minecraft/world/entity/Shearable.java.patch b/patches/minecraft/net/minecraft/world/entity/Shearable.java.patch new file mode 100644 index 0000000000..b3b180c7a4 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/Shearable.java.patch @@ -0,0 +1,14 @@ +--- a/net/minecraft/world/entity/Shearable.java ++++ b/net/minecraft/world/entity/Shearable.java +@@ -2,8 +_,11 @@ + + import net.minecraft.sounds.SoundSource; + ++@Deprecated // Forge: Use IForgeShearable + public interface Shearable { ++ @Deprecated // Forge: Use IForgeShearable + void m_5851_(SoundSource p_21749_); + ++ @Deprecated // Forge: Use IForgeShearable + boolean m_6220_(); + } diff --git a/patches/minecraft/net/minecraft/world/entity/SpawnPlacements.java.patch b/patches/minecraft/net/minecraft/world/entity/SpawnPlacements.java.patch new file mode 100644 index 0000000000..768470adc2 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/SpawnPlacements.java.patch @@ -0,0 +1,30 @@ +--- a/net/minecraft/world/entity/SpawnPlacements.java ++++ b/net/minecraft/world/entity/SpawnPlacements.java +@@ -151,10 +_,26 @@ + boolean m_21780_(EntityType p_21781_, ServerLevelAccessor p_21782_, MobSpawnType p_21783_, BlockPos p_21784_, Random p_21785_); + } + +- public static enum Type { ++ public static enum Type implements net.minecraftforge.common.IExtensibleEnum { + ON_GROUND, + IN_WATER, + NO_RESTRICTIONS, + IN_LAVA; ++ ++ public static Type create(String name, net.minecraftforge.common.util.TriPredicate> predicate) { ++ throw new IllegalStateException("Enum not extended"); ++ } ++ ++ private net.minecraftforge.common.util.TriPredicate> predicate; ++ private Type() { this(null); } ++ private Type(net.minecraftforge.common.util.TriPredicate> predicate) { ++ this.predicate = predicate; ++ } ++ ++ public boolean canSpawnAt(net.minecraft.world.level.LevelReader world, BlockPos pos, EntityType type) { ++ if (this == NO_RESTRICTIONS) return true; ++ if (predicate == null) return net.minecraft.world.level.NaturalSpawner.canSpawnAtBody(this, world, pos, type); ++ return predicate.test(world, pos, type); ++ } + } + } diff --git a/patches/minecraft/net/minecraft/world/entity/ai/attributes/Attribute.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/attributes/Attribute.java.patch new file mode 100644 index 0000000000..fa71871905 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/ai/attributes/Attribute.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/world/entity/ai/attributes/Attribute.java ++++ b/net/minecraft/world/entity/ai/attributes/Attribute.java +@@ -1,6 +_,6 @@ + package net.minecraft.world.entity.ai.attributes; + +-public class Attribute { ++public class Attribute extends net.minecraftforge.registries.ForgeRegistryEntry { + public static final int f_147357_ = 64; + private final double f_22076_; + private boolean f_22077_; diff --git a/patches/minecraft/net/minecraft/world/entity/ai/attributes/AttributeSupplier.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/attributes/AttributeSupplier.java.patch new file mode 100644 index 0000000000..96b0a1224c --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/ai/attributes/AttributeSupplier.java.patch @@ -0,0 +1,33 @@ +--- a/net/minecraft/world/entity/ai/attributes/AttributeSupplier.java ++++ b/net/minecraft/world/entity/ai/attributes/AttributeSupplier.java +@@ -69,6 +_,22 @@ + public static class Builder { + private final Map f_22262_ = Maps.newHashMap(); + private boolean f_22263_; ++ private final java.util.List others = new java.util.ArrayList<>(); ++ ++ public Builder() { } ++ ++ public Builder(AttributeSupplier attributeMap) { ++ this.f_22262_.putAll(attributeMap.f_22241_); ++ } ++ ++ public void combine(Builder other) { ++ this.f_22262_.putAll(other.f_22262_); ++ others.add(other); ++ } ++ ++ public boolean hasAttribute(Attribute attribute) { ++ return this.f_22262_.containsKey(attribute); ++ } + + private AttributeInstance m_22274_(Attribute p_22275_) { + AttributeInstance attributeinstance = new AttributeInstance(p_22275_, (p_22273_) -> { +@@ -93,6 +_,7 @@ + + public AttributeSupplier m_22265_() { + this.f_22263_ = true; ++ others.forEach(p_70141_ -> p_70141_.f_22263_ = true); + return new AttributeSupplier(this.f_22262_); + } + } diff --git a/patches/minecraft/net/minecraft/world/entity/ai/behavior/CrossbowAttack.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/behavior/CrossbowAttack.java.patch new file mode 100644 index 0000000000..689cada2f9 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/ai/behavior/CrossbowAttack.java.patch @@ -0,0 +1,38 @@ +--- a/net/minecraft/world/entity/ai/behavior/CrossbowAttack.java ++++ b/net/minecraft/world/entity/ai/behavior/CrossbowAttack.java +@@ -23,7 +_,7 @@ + + protected boolean m_6114_(ServerLevel p_22778_, E p_22779_) { + LivingEntity livingentity = m_22784_(p_22779_); +- return p_22779_.m_21055_(Items.f_42717_) && BehaviorUtils.m_22667_(p_22779_, livingentity) && BehaviorUtils.m_22632_(p_22779_, livingentity, 0); ++ return p_22779_.m_21093_(is -> is.m_41720_() instanceof CrossbowItem) && BehaviorUtils.m_22667_(p_22779_, livingentity) && BehaviorUtils.m_22632_(p_22779_, livingentity, 0); + } + + protected boolean m_6737_(ServerLevel p_22781_, E p_22782_, long p_22783_) { +@@ -41,7 +_,7 @@ + p_22806_.m_5810_(); + } + +- if (p_22806_.m_21055_(Items.f_42717_)) { ++ if (p_22806_.m_21093_(is -> is.m_41720_() instanceof CrossbowItem)) { + p_22806_.m_6136_(false); + CrossbowItem.m_40884_(p_22806_.m_21211_(), false); + } +@@ -50,7 +_,7 @@ + + private void m_22786_(E p_22787_, LivingEntity p_22788_) { + if (this.f_22772_ == CrossbowAttack.CrossbowState.UNCHARGED) { +- p_22787_.m_6672_(ProjectileUtil.m_37297_(p_22787_, Items.f_42717_)); ++ p_22787_.m_6672_(ProjectileUtil.getWeaponHoldingHand(p_22787_, item -> item instanceof CrossbowItem)); + this.f_22772_ = CrossbowAttack.CrossbowState.CHARGING; + p_22787_.m_6136_(true); + } else if (this.f_22772_ == CrossbowAttack.CrossbowState.CHARGING) { +@@ -73,7 +_,7 @@ + } + } else if (this.f_22772_ == CrossbowAttack.CrossbowState.READY_TO_ATTACK) { + p_22787_.m_6504_(p_22788_, 1.0F); +- ItemStack itemstack1 = p_22787_.m_21120_(ProjectileUtil.m_37297_(p_22787_, Items.f_42717_)); ++ ItemStack itemstack1 = p_22787_.m_21120_(ProjectileUtil.getWeaponHoldingHand(p_22787_, item -> item instanceof CrossbowItem)); + CrossbowItem.m_40884_(itemstack1, false); + this.f_22772_ = CrossbowAttack.CrossbowState.UNCHARGED; + } diff --git a/patches/minecraft/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java.patch new file mode 100644 index 0000000000..8b9b2ba179 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java.patch @@ -0,0 +1,23 @@ +--- a/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java ++++ b/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java +@@ -38,7 +_,7 @@ + } + + protected boolean m_6114_(ServerLevel p_23174_, Villager p_23175_) { +- if (!p_23174_.m_46469_().m_46207_(GameRules.f_46132_)) { ++ if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(p_23174_, p_23175_)) { + return false; + } else if (p_23175_.m_7141_().m_35571_() != VillagerProfession.f_35590_) { + return false; +@@ -118,6 +_,11 @@ + } else if (itemstack.m_150930_(Items.f_42733_)) { + p_23196_.m_7731_(this.f_23159_, Blocks.f_50444_.m_49966_(), 3); + flag = true; ++ } else if (itemstack.m_41720_() instanceof net.minecraftforge.common.IPlantable) { ++ if (((net.minecraftforge.common.IPlantable)itemstack.m_41720_()).getPlantType(p_23196_, f_23159_) == net.minecraftforge.common.PlantType.CROP) { ++ p_23196_.m_7731_(f_23159_, ((net.minecraftforge.common.IPlantable)itemstack.m_41720_()).getPlant(p_23196_, f_23159_), 3); ++ flag = true; ++ } + } + } + diff --git a/patches/minecraft/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java.patch new file mode 100644 index 0000000000..3cd5bbca50 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java ++++ b/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java +@@ -30,7 +_,7 @@ + public boolean m_8036_() { + if (!super.m_8036_()) { + return false; +- } else if (!this.f_25189_.f_19853_.m_46469_().m_46207_(GameRules.f_46132_)) { ++ } else if (!net.minecraftforge.common.ForgeHooks.canEntityDestroy(this.f_25189_.f_19853_, this.f_25190_, this.f_25189_)) { + return false; + } else { + return this.m_25094_(this.f_25189_.f_19853_.m_46791_()) && !this.m_25200_(); diff --git a/patches/minecraft/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch new file mode 100644 index 0000000000..361bdfe037 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/world/entity/ai/goal/EatBlockGoal.java ++++ b/net/minecraft/world/entity/ai/goal/EatBlockGoal.java +@@ -61,7 +_,7 @@ + if (this.f_25204_ == 4) { + BlockPos blockpos = this.f_25202_.m_142538_(); + if (f_25201_.test(this.f_25203_.m_8055_(blockpos))) { +- if (this.f_25203_.m_46469_().m_46207_(GameRules.f_46132_)) { ++ if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_25203_, this.f_25202_)) { + this.f_25203_.m_46961_(blockpos, false); + } + +@@ -70,7 +_,7 @@ + } else { + BlockPos blockpos1 = blockpos.m_7495_(); + if (this.f_25203_.m_8055_(blockpos1).m_60713_(Blocks.f_50440_)) { +- if (this.f_25203_.m_46469_().m_46207_(GameRules.f_46132_)) { ++ if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_25203_, this.f_25202_)) { + this.f_25203_.m_46796_(2001, blockpos1, Block.m_49956_(Blocks.f_50440_.m_49966_())); + this.f_25203_.m_7731_(blockpos1, Blocks.f_50493_.m_49966_(), 2); + } 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 new file mode 100644 index 0000000000..9f541ecadc --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/ai/goal/MeleeAttackGoal.java.patch @@ -0,0 +1,46 @@ +--- a/net/minecraft/world/entity/ai/goal/MeleeAttackGoal.java ++++ b/net/minecraft/world/entity/ai/goal/MeleeAttackGoal.java +@@ -21,6 +_,8 @@ + private final int f_25549_ = 20; + private long f_25550_; + private static final long f_148125_ = 20L; ++ private int failedPathFindingPenalty = 0; ++ private boolean canPenalize = false; + + public MeleeAttackGoal(PathfinderMob p_25552_, double p_25553_, boolean p_25554_) { + this.f_25540_ = p_25552_; +@@ -41,6 +_,15 @@ + } else if (!livingentity.m_6084_()) { + return false; + } else { ++ if (canPenalize) { ++ if (--this.f_25547_ <= 0) { ++ this.f_25543_ = this.f_25540_.m_21573_().m_6570_(livingentity, 0); ++ this.f_25547_ = 4 + this.f_25540_.m_21187_().nextInt(7); ++ return this.f_25543_ != null; ++ } else { ++ return true; ++ } ++ } + this.f_25543_ = this.f_25540_.m_21573_().m_6570_(livingentity, 0); + if (this.f_25543_ != null) { + return true; +@@ -93,6 +_,18 @@ + this.f_25545_ = livingentity.m_20186_(); + this.f_25546_ = livingentity.m_20189_(); + this.f_25547_ = 4 + this.f_25540_.m_21187_().nextInt(7); ++ if (this.canPenalize) { ++ this.f_25547_ += failedPathFindingPenalty; ++ if (this.f_25540_.m_21573_().m_26570_() != null) { ++ net.minecraft.world.level.pathfinder.Node finalPathPoint = this.f_25540_.m_21573_().m_26570_().m_77395_(); ++ if (finalPathPoint != null && livingentity.m_20275_(finalPathPoint.f_77271_, finalPathPoint.f_77272_, finalPathPoint.f_77273_) < 1) ++ failedPathFindingPenalty = 0; ++ else ++ failedPathFindingPenalty += 10; ++ } else { ++ failedPathFindingPenalty += 10; ++ } ++ } + if (d0 > 1024.0D) { + this.f_25547_ += 10; + } else if (d0 > 256.0D) { diff --git a/patches/minecraft/net/minecraft/world/entity/ai/goal/RangedBowAttackGoal.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/goal/RangedBowAttackGoal.java.patch new file mode 100644 index 0000000000..2d2c6bf6c5 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/ai/goal/RangedBowAttackGoal.java.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/world/entity/ai/goal/RangedBowAttackGoal.java ++++ b/net/minecraft/world/entity/ai/goal/RangedBowAttackGoal.java +@@ -36,7 +_,7 @@ + } + + protected boolean m_25803_() { +- return this.f_25782_.m_21055_(Items.f_42411_); ++ return this.f_25782_.m_21093_(is -> is.m_41720_() instanceof BowItem); + } + + public boolean m_8045_() { +@@ -117,7 +_,7 @@ + } + } + } else if (--this.f_25786_ <= 0 && this.f_25787_ >= -60) { +- this.f_25782_.m_6672_(ProjectileUtil.m_37297_(this.f_25782_, Items.f_42411_)); ++ this.f_25782_.m_6672_(ProjectileUtil.getWeaponHoldingHand(this.f_25782_, item -> item instanceof BowItem)); + } + + } diff --git a/patches/minecraft/net/minecraft/world/entity/ai/goal/RangedCrossbowAttackGoal.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/goal/RangedCrossbowAttackGoal.java.patch new file mode 100644 index 0000000000..5b8a0b0347 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/ai/goal/RangedCrossbowAttackGoal.java.patch @@ -0,0 +1,29 @@ +--- a/net/minecraft/world/entity/ai/goal/RangedCrossbowAttackGoal.java ++++ b/net/minecraft/world/entity/ai/goal/RangedCrossbowAttackGoal.java +@@ -34,7 +_,7 @@ + } + + private boolean m_25821_() { +- return this.f_25805_.m_21055_(Items.f_42717_); ++ return this.f_25805_.m_21093_(is -> is.m_41720_() instanceof CrossbowItem); + } + + public boolean m_8045_() { +@@ -89,7 +_,7 @@ + this.f_25805_.m_21563_().m_24960_(livingentity, 30.0F, 30.0F); + if (this.f_25806_ == RangedCrossbowAttackGoal.CrossbowState.UNCHARGED) { + if (!flag2) { +- this.f_25805_.m_6672_(ProjectileUtil.m_37297_(this.f_25805_, Items.f_42717_)); ++ this.f_25805_.m_6672_(ProjectileUtil.getWeaponHoldingHand(this.f_25805_, item -> item instanceof CrossbowItem)); + this.f_25806_ = RangedCrossbowAttackGoal.CrossbowState.CHARGING; + this.f_25805_.m_6136_(true); + } +@@ -113,7 +_,7 @@ + } + } else if (this.f_25806_ == RangedCrossbowAttackGoal.CrossbowState.READY_TO_ATTACK && flag) { + this.f_25805_.m_6504_(livingentity, 1.0F); +- ItemStack itemstack1 = this.f_25805_.m_21120_(ProjectileUtil.m_37297_(this.f_25805_, Items.f_42717_)); ++ ItemStack itemstack1 = this.f_25805_.m_21120_(ProjectileUtil.getWeaponHoldingHand(this.f_25805_, item -> item instanceof CrossbowItem)); + CrossbowItem.m_40884_(itemstack1, false); + this.f_25806_ = RangedCrossbowAttackGoal.CrossbowState.UNCHARGED; + } diff --git a/patches/minecraft/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch new file mode 100644 index 0000000000..079a07d8bb --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java ++++ b/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java +@@ -34,7 +_,7 @@ + } + + public boolean m_8036_() { +- if (!this.f_25837_.f_19853_.m_46469_().m_46207_(GameRules.f_46132_)) { ++ if (!net.minecraftforge.common.ForgeHooks.canEntityDestroy(this.f_25837_.f_19853_, this.f_25602_, this.f_25837_)) { + return false; + } else if (this.f_25600_ > 0) { + --this.f_25600_; 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 new file mode 100644 index 0000000000..2f752e2370 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java.patch @@ -0,0 +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) { + int i = this.f_25884_.m_30624_(); + int j = this.f_25884_.m_7555_(); +- if (j > 0 && this.f_25884_.m_21187_().nextInt(j) < i) { ++ if (j > 0 && this.f_25884_.m_21187_().nextInt(j) < i && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(f_25884_, (Player)entity)) { + this.f_25884_.m_30637_((Player)entity); + return; + } diff --git a/patches/minecraft/net/minecraft/world/entity/ai/memory/MemoryModuleType.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/memory/MemoryModuleType.java.patch new file mode 100644 index 0000000000..3998bb3b58 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/ai/memory/MemoryModuleType.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/entity/ai/memory/MemoryModuleType.java ++++ b/net/minecraft/world/entity/ai/memory/MemoryModuleType.java +@@ -23,7 +_,7 @@ + import net.minecraft.world.level.pathfinder.Path; + import net.minecraft.world.phys.Vec3; + +-public class MemoryModuleType { ++public class MemoryModuleType extends net.minecraftforge.registries.ForgeRegistryEntry> { + public static final MemoryModuleType f_26349_ = m_26388_("dummy"); + public static final MemoryModuleType f_26359_ = m_26390_("home", GlobalPos.f_122633_); + public static final MemoryModuleType f_26360_ = m_26390_("job_site", GlobalPos.f_122633_); diff --git a/patches/minecraft/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch new file mode 100644 index 0000000000..595d3bc9dd --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch @@ -0,0 +1,14 @@ +--- a/net/minecraft/world/entity/ai/navigation/PathNavigation.java ++++ b/net/minecraft/world/entity/ai/navigation/PathNavigation.java +@@ -223,9 +_,9 @@ + Vec3 vec3 = this.m_7475_(); + this.f_26505_ = this.f_26494_.m_20205_() > 0.75F ? this.f_26494_.m_20205_() / 2.0F : 0.75F - this.f_26494_.m_20205_() / 2.0F; + Vec3i vec3i = this.f_26496_.m_77400_(); +- double d0 = Math.abs(this.f_26494_.m_20185_() - ((double)vec3i.m_123341_() + 0.5D)); ++ double d0 = Math.abs(this.f_26494_.m_20185_() - ((double)vec3i.m_123341_() + (this.f_26494_.m_20205_() + 1) / 2D)); //Forge: Fix MC-94054 + double d1 = Math.abs(this.f_26494_.m_20186_() - (double)vec3i.m_123342_()); +- double d2 = Math.abs(this.f_26494_.m_20189_() - ((double)vec3i.m_123343_() + 0.5D)); ++ double d2 = Math.abs(this.f_26494_.m_20189_() - ((double)vec3i.m_123343_() + (this.f_26494_.m_20205_() + 1) / 2D)); //Forge: Fix MC-94054 + boolean flag = d0 < (double)this.f_26505_ && d2 < (double)this.f_26505_ && d1 < 1.0D; + if (flag || this.f_26494_.m_21481_(this.f_26496_.m_77401_().f_77282_) && this.m_26559_(vec3)) { + this.f_26496_.m_77374_(); diff --git a/patches/minecraft/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java.patch new file mode 100644 index 0000000000..7d4c25a629 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java.patch @@ -0,0 +1,12 @@ +--- a/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java ++++ b/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java +@@ -39,7 +_,8 @@ + super.m_7638_(); + } else { + if (this.f_26578_ != null) { +- if (!this.f_26578_.m_123306_(this.f_26494_.m_20182_(), (double)this.f_26494_.m_20205_()) && (!(this.f_26494_.m_20186_() > (double)this.f_26578_.m_123342_()) || !(new BlockPos((double)this.f_26578_.m_123341_(), this.f_26494_.m_20186_(), (double)this.f_26578_.m_123343_())).m_123306_(this.f_26494_.m_20182_(), (double)this.f_26494_.m_20205_()))) { ++ // FORGE: Fix MC-94054 ++ if (!this.f_26578_.m_123306_(this.f_26494_.m_20182_(), Math.max((double)this.f_26494_.m_20205_(), 1.0D)) && (!(this.f_26494_.m_20186_() > (double)this.f_26578_.m_123342_()) || !(new BlockPos((double)this.f_26578_.m_123341_(), this.f_26494_.m_20186_(), (double)this.f_26578_.m_123343_())).m_123306_(this.f_26494_.m_20182_(), Math.max((double)this.f_26494_.m_20205_(), 1.0D)))) { + this.f_26494_.m_21566_().m_6849_((double)this.f_26578_.m_123341_(), (double)this.f_26578_.m_123342_(), (double)this.f_26578_.m_123343_(), this.f_26497_); + } else { + this.f_26578_ = null; diff --git a/patches/minecraft/net/minecraft/world/entity/ai/sensing/SensorType.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/sensing/SensorType.java.patch new file mode 100644 index 0000000000..a733b975b2 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/ai/sensing/SensorType.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/entity/ai/sensing/SensorType.java ++++ b/net/minecraft/world/entity/ai/sensing/SensorType.java +@@ -6,7 +_,7 @@ + import net.minecraft.world.entity.animal.axolotl.AxolotlAi; + import net.minecraft.world.entity.animal.goat.GoatAi; + +-public class SensorType> { ++public class SensorType> extends net.minecraftforge.registries.ForgeRegistryEntry> { + public static final SensorType f_26809_ = m_26828_("dummy", DummySensor::new); + public static final SensorType f_26810_ = m_26828_("nearest_items", NearestItemSensor::new); + public static final SensorType f_26811_ = m_26828_("nearest_living_entities", NearestLivingEntitySensor::new); diff --git a/patches/minecraft/net/minecraft/world/entity/ai/village/VillageSiege.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/village/VillageSiege.java.patch new file mode 100644 index 0000000000..98db7e8d4b --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/ai/village/VillageSiege.java.patch @@ -0,0 +1,22 @@ +--- a/net/minecraft/world/entity/ai/village/VillageSiege.java ++++ b/net/minecraft/world/entity/ai/village/VillageSiege.java +@@ -78,7 +_,9 @@ + this.f_27002_ = blockpos.m_123341_() + Mth.m_14143_(Mth.m_14089_(f) * 32.0F); + this.f_27003_ = blockpos.m_123342_(); + this.f_27004_ = blockpos.m_123343_() + Mth.m_14143_(Mth.m_14031_(f) * 32.0F); +- if (this.m_27009_(p_27008_, new BlockPos(this.f_27002_, this.f_27003_, this.f_27004_)) != null) { ++ Vec3 siegeLocation = this.m_27009_(p_27008_, new BlockPos(this.f_27002_, this.f_27003_, this.f_27004_)); ++ if (siegeLocation != null) { ++ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.village.VillageSiegeEvent(this, p_27008_, player, siegeLocation))) return false; + this.f_27001_ = 0; + this.f_27000_ = 20; + break; +@@ -98,7 +_,7 @@ + if (vec3 != null) { + Zombie zombie; + try { +- zombie = new Zombie(p_27017_); ++ zombie = EntityType.f_20501_.m_20615_(p_27017_); //Forge: Direct Initialization is deprecated, use EntityType. + zombie.m_6518_(p_27017_, p_27017_.m_6436_(zombie.m_142538_()), MobSpawnType.EVENT, (SpawnGroupData)null, (CompoundTag)null); + } catch (Exception exception) { + f_26997_.warn("Failed to create zombie for village siege at {}", vec3, exception); diff --git a/patches/minecraft/net/minecraft/world/entity/ai/village/poi/PoiType.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/village/poi/PoiType.java.patch new file mode 100644 index 0000000000..b591fcd16d --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/ai/village/poi/PoiType.java.patch @@ -0,0 +1,41 @@ +--- a/net/minecraft/world/entity/ai/village/poi/PoiType.java ++++ b/net/minecraft/world/entity/ai/village/poi/PoiType.java +@@ -21,7 +_,7 @@ + import net.minecraft.world.level.block.state.BlockState; + import net.minecraft.world.level.block.state.properties.BedPart; + +-public class PoiType { ++public class PoiType extends net.minecraftforge.registries.ForgeRegistryEntry { + private static final Supplier> f_27353_ = Suppliers.memoize(() -> { + return Registry.f_122869_.m_123024_().map(VillagerProfession::m_35622_).collect(Collectors.toSet()); + }); +@@ -39,7 +_,7 @@ + private static final Set f_148686_ = ImmutableList.of(Blocks.f_50256_, Blocks.f_152477_, Blocks.f_152476_, Blocks.f_152478_).stream().flatMap((p_148697_) -> { + return p_148697_.m_49965_().m_61056_().stream(); + }).collect(ImmutableSet.toImmutableSet()); +- private static final Map f_27323_ = Maps.newHashMap(); ++ private static final Map f_27323_ = net.minecraftforge.registries.GameData.getBlockStatePointOfInterestTypeMap(); + public static final PoiType f_27331_ = m_27379_("unemployed", ImmutableSet.of(), 1, f_27329_, 1); + public static final PoiType f_27332_ = m_27374_("armorer", m_27372_(Blocks.f_50620_), 1, 1); + public static final PoiType f_27333_ = m_27374_("butcher", m_27372_(Blocks.f_50619_), 1, 1); +@@ -124,16 +_,14 @@ + } + + private static PoiType m_27367_(PoiType p_27368_) { +- p_27368_.f_27325_.forEach((p_148691_) -> { +- PoiType poitype = f_27323_.put(p_148691_, p_27368_); +- if (poitype != null) { +- throw (IllegalStateException)Util.m_137570_(new IllegalStateException(String.format("%s is defined in too many tags", p_148691_))); +- } +- }); + return p_27368_; + } + + public static Optional m_27390_(BlockState p_27391_) { + return Optional.ofNullable(f_27323_.get(p_27391_)); ++ } ++ ++ public ImmutableSet getBlockStates() { ++ return ImmutableSet.copyOf(this.f_27325_); + } + } diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Animal.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Animal.java.patch new file mode 100644 index 0000000000..a7b6481554 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/animal/Animal.java.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/world/entity/animal/Animal.java ++++ b/net/minecraft/world/entity/animal/Animal.java +@@ -201,6 +_,17 @@ + + public void m_27563_(ServerLevel p_27564_, Animal p_27565_) { + AgeableMob ageablemob = this.m_142606_(p_27564_, p_27565_); ++ final net.minecraftforge.event.entity.living.BabyEntitySpawnEvent event = new net.minecraftforge.event.entity.living.BabyEntitySpawnEvent(this, p_27565_, ageablemob); ++ final boolean cancelled = net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); ++ ageablemob = event.getChild(); ++ if (cancelled) { ++ //Reset the "inLove" state for the animals ++ this.m_146762_(6000); ++ p_27565_.m_146762_(6000); ++ this.m_27594_(); ++ p_27565_.m_27594_(); ++ return; ++ } + if (ageablemob != null) { + ServerPlayer serverplayer = this.m_27592_(); + if (serverplayer == null && p_27565_.m_27592_() != null) { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Bee.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Bee.java.patch new file mode 100644 index 0000000000..ad09699677 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/animal/Bee.java.patch @@ -0,0 +1,19 @@ +--- a/net/minecraft/world/entity/animal/Bee.java ++++ b/net/minecraft/world/entity/animal/Bee.java +@@ -212,6 +_,7 @@ + this.f_27710_ = p_27793_.m_128451_("TicksSincePollination"); + this.f_27711_ = p_27793_.m_128451_("CannotEnterHiveTicks"); + this.f_27712_ = p_27793_.m_128451_("CropsGrownSincePollination"); ++ if(!f_19853_.f_46443_) //FORGE: allow this entity to be read from nbt on client. (Fixes MC-189565) + this.m_147285_(this.f_19853_, p_27793_); + } + +@@ -469,7 +_,7 @@ + return false; + } else { + BlockEntity blockentity = this.f_19853_.m_7702_(this.f_27698_); +- return blockentity != null && blockentity.m_58903_() == BlockEntityType.f_58912_; ++ return blockentity instanceof BeehiveBlockEntity; + } + } + diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Cat.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Cat.java.patch new file mode 100644 index 0000000000..6a424dc081 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/animal/Cat.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/entity/animal/Cat.java ++++ b/net/minecraft/world/entity/animal/Cat.java +@@ -415,7 +_,7 @@ + } + } else if (this.m_6898_(itemstack)) { + this.m_142075_(p_28153_, p_28154_, itemstack); +- if (this.f_19796_.nextInt(3) == 0) { ++ if (this.f_19796_.nextInt(3) == 0 && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(this, p_28153_)) { + this.m_21828_(p_28153_); + this.m_21839_(true); + this.f_19853_.m_7605_(this, (byte)7); diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Fox.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Fox.java.patch new file mode 100644 index 0000000000..7d727e9ea9 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/animal/Fox.java.patch @@ -0,0 +1,29 @@ +--- a/net/minecraft/world/entity/animal/Fox.java ++++ b/net/minecraft/world/entity/animal/Fox.java +@@ -796,6 +_,17 @@ + protected void m_8026_() { + ServerLevel serverlevel = (ServerLevel)this.f_25114_; + Fox fox = (Fox)this.f_25113_.m_142606_(serverlevel, this.f_25115_); ++ final net.minecraftforge.event.entity.living.BabyEntitySpawnEvent event = new net.minecraftforge.event.entity.living.BabyEntitySpawnEvent(f_25113_, f_25115_, fox); ++ final boolean cancelled = net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); ++ fox = (Fox) event.getChild(); ++ if (cancelled) { ++ //Reset the "inLove" state for the animals ++ this.f_25113_.m_146762_(6000); ++ this.f_25115_.m_146762_(6000); ++ this.f_25113_.m_27594_(); ++ this.f_25115_.m_27594_(); ++ return; ++ } + if (fox != null) { + ServerPlayer serverplayer = this.f_25113_.m_27592_(); + ServerPlayer serverplayer1 = this.f_25115_.m_27592_(); +@@ -867,7 +_,7 @@ + } + + protected void m_28686_() { +- if (Fox.this.f_19853_.m_46469_().m_46207_(GameRules.f_46132_)) { ++ if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(Fox.this.f_19853_, Fox.this)) { + BlockState blockstate = Fox.this.f_19853_.m_8055_(this.f_25602_); + if (blockstate.m_60713_(Blocks.f_50685_)) { + this.m_148928_(blockstate); diff --git a/patches/minecraft/net/minecraft/world/entity/animal/IronGolem.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/IronGolem.java.patch new file mode 100644 index 0000000000..0a8f3ad380 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/animal/IronGolem.java.patch @@ -0,0 +1,23 @@ +--- a/net/minecraft/world/entity/animal/IronGolem.java ++++ b/net/minecraft/world/entity/animal/IronGolem.java +@@ -119,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_()); +- BlockState blockstate = this.f_19853_.m_8055_(new BlockPos(i, j, k)); ++ BlockPos pos = new BlockPos(i, j, k); ++ BlockState blockstate = this.f_19853_.m_8055_(pos); + if (!blockstate.m_60795_()) { +- this.f_19853_.m_7106_(new BlockParticleOption(ParticleTypes.f_123794_, blockstate), this.m_20185_() + ((double)this.f_19796_.nextFloat() - 0.5D) * (double)this.m_20205_(), this.m_20186_() + 0.1D, this.m_20189_() + ((double)this.f_19796_.nextFloat() - 0.5D) * (double)this.m_20205_(), 4.0D * ((double)this.f_19796_.nextFloat() - 0.5D), 0.5D, ((double)this.f_19796_.nextFloat() - 0.5D) * 4.0D); ++ this.f_19853_.m_7106_(new BlockParticleOption(ParticleTypes.f_123794_, blockstate).setPos(pos), this.m_20185_() + ((double)this.f_19796_.nextFloat() - 0.5D) * (double)this.m_20205_(), this.m_20186_() + 0.1D, this.m_20189_() + ((double)this.f_19796_.nextFloat() - 0.5D) * (double)this.m_20205_(), 4.0D * ((double)this.f_19796_.nextFloat() - 0.5D), 0.5D, ((double)this.f_19796_.nextFloat() - 0.5D) * 4.0D); + } + } + +@@ -148,6 +_,7 @@ + public void m_7378_(CompoundTag p_28857_) { + super.m_7378_(p_28857_); + this.m_28887_(p_28857_.m_128471_("PlayerCreated")); ++ if(!f_19853_.f_46443_) //FORGE: allow this entity to be read from nbt on client. (Fixes MC-189565) + this.m_147285_(this.f_19853_, p_28857_); + } + diff --git a/patches/minecraft/net/minecraft/world/entity/animal/MushroomCow.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/MushroomCow.java.patch new file mode 100644 index 0000000000..29eba317e5 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/animal/MushroomCow.java.patch @@ -0,0 +1,66 @@ +--- a/net/minecraft/world/entity/animal/MushroomCow.java ++++ b/net/minecraft/world/entity/animal/MushroomCow.java +@@ -40,7 +_,7 @@ + import net.minecraft.world.level.gameevent.GameEvent; + import org.apache.commons.lang3.tuple.Pair; + +-public class MushroomCow extends Cow implements Shearable { ++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; + private MobEffect f_28909_; +@@ -100,7 +_,7 @@ + + this.m_5496_(soundevent, 1.0F, 1.0F); + return InteractionResult.m_19078_(this.f_19853_.f_46443_); +- } else if (itemstack.m_150930_(Items.f_42574_) && this.m_6220_()) { ++ } else if (false && itemstack.m_41720_() == Items.f_42574_ && this.m_6220_()) { //Forge: Moved to onSheared + this.m_5851_(SoundSource.PLAYERS); + this.m_146852_(GameEvent.f_157781_, p_28941_); + if (!this.f_19853_.f_46443_) { +@@ -235,6 +_,45 @@ + + return mushroomcow$mushroomtype2; + } ++ ++ @Override ++ public boolean isShearable(@javax.annotation.Nonnull ItemStack item, Level world, BlockPos pos) { ++ return m_6220_(); ++ } ++ ++ @javax.annotation.Nonnull ++ @Override ++ public java.util.List onSheared(@javax.annotation.Nullable Player player, @javax.annotation.Nonnull ItemStack item, Level world, BlockPos pos, int fortune) { ++ world.m_6269_(null, this, SoundEvents.f_12075_, player == null ? SoundSource.BLOCKS : SoundSource.PLAYERS, 1.0F, 1.0F); ++ if (!world.m_5776_()) { ++ ((ServerLevel)this.f_19853_).m_8767_(ParticleTypes.f_123813_, this.m_20185_(), this.m_20227_(0.5D), this.m_20189_(), 1, 0.0D, 0.0D, 0.0D, 0.0D); ++ this.remove(false); ++ Cow cow = EntityType.f_20557_.m_20615_(this.f_19853_); ++ cow.m_7678_(this.m_20185_(), this.m_20186_(), this.m_20189_(), this.m_146909_(), this.m_146908_()); ++ cow.m_21153_(this.m_21223_()); ++ cow.f_20883_ = this.f_20883_; ++ if (this.m_8077_()) { ++ cow.m_6593_(this.m_7770_()); ++ cow.m_20340_(this.m_20151_()); ++ } ++ ++ if (this.m_21532_()) { ++ cow.m_21530_(); ++ } ++ ++ cow.m_20331_(this.m_20147_()); ++ this.f_19853_.m_7967_(cow); ++ ++ java.util.List items = new java.util.ArrayList<>(); ++ for (int i = 0; i < 5; ++i) { ++ items.add(new ItemStack(this.m_28955_().f_28961_.m_60734_())); ++ } ++ ++ return items; ++ } ++ return java.util.Collections.emptyList(); ++ } ++ + + public static enum MushroomType { + RED("red", Blocks.f_50073_.m_49966_()), diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Ocelot.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Ocelot.java.patch new file mode 100644 index 0000000000..2169a41d17 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/animal/Ocelot.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/entity/animal/Ocelot.java ++++ b/net/minecraft/world/entity/animal/Ocelot.java +@@ -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.f_19853_.f_46443_) { +- if (this.f_19796_.nextInt(3) == 0) { ++ if (this.f_19796_.nextInt(3) == 0 && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(this, p_29021_)) { + this.m_29045_(true); + this.m_29047_(true); + this.f_19853_.m_7605_(this, (byte)41); diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Parrot.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Parrot.java.patch new file mode 100644 index 0000000000..707c96bc5a --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/animal/Parrot.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/entity/animal/Parrot.java ++++ b/net/minecraft/world/entity/animal/Parrot.java +@@ -235,7 +_,7 @@ + } + + if (!this.f_19853_.f_46443_) { +- if (this.f_19796_.nextInt(10) == 0) { ++ if (this.f_19796_.nextInt(10) == 0 && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(this, p_29414_)) { + this.m_21828_(p_29414_); + this.f_19853_.m_7605_(this, (byte)7); + } else { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Pig.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Pig.java.patch new file mode 100644 index 0000000000..8e380b333d --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/animal/Pig.java.patch @@ -0,0 +1,19 @@ +--- a/net/minecraft/world/entity/animal/Pig.java ++++ b/net/minecraft/world/entity/animal/Pig.java +@@ -201,7 +_,7 @@ + } + + public void m_8038_(ServerLevel p_29473_, LightningBolt p_29474_) { +- if (p_29473_.m_46791_() != Difficulty.PEACEFUL) { ++ if (p_29473_.m_46791_() != Difficulty.PEACEFUL && net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, EntityType.f_20531_, (timer) -> {})) { + ZombifiedPiglin zombifiedpiglin = EntityType.f_20531_.m_20615_(p_29473_); + zombifiedpiglin.m_8061_(EquipmentSlot.MAINHAND, new ItemStack(Items.f_42430_)); + zombifiedpiglin.m_7678_(this.m_20185_(), this.m_20186_(), this.m_20189_(), this.m_146908_(), this.m_146909_()); +@@ -213,6 +_,7 @@ + } + + zombifiedpiglin.m_21530_(); ++ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, zombifiedpiglin); + p_29473_.m_7967_(zombifiedpiglin); + this.m_146870_(); + } else { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/PolarBear.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/PolarBear.java.patch new file mode 100644 index 0000000000..e1443c5712 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/animal/PolarBear.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/world/entity/animal/PolarBear.java ++++ b/net/minecraft/world/entity/animal/PolarBear.java +@@ -105,6 +_,7 @@ + + public void m_7378_(CompoundTag p_29541_) { + super.m_7378_(p_29541_); ++ if(!f_19853_.f_46443_) //FORGE: allow this entity to be read from nbt on client. (Fixes MC-189565) + this.m_147285_(this.f_19853_, p_29541_); + } + diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Rabbit.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Rabbit.java.patch new file mode 100644 index 0000000000..c2f1dc15b8 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/animal/Rabbit.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/entity/animal/Rabbit.java ++++ b/net/minecraft/world/entity/animal/Rabbit.java +@@ -507,7 +_,7 @@ + + public boolean m_8036_() { + if (this.f_25600_ <= 0) { +- if (!this.f_29778_.f_19853_.m_46469_().m_46207_(GameRules.f_46132_)) { ++ if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_29778_.f_19853_, this.f_29778_)) { + return false; + } + diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Sheep.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Sheep.java.patch new file mode 100644 index 0000000000..1892cbf2d6 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/animal/Sheep.java.patch @@ -0,0 +1,48 @@ +--- a/net/minecraft/world/entity/animal/Sheep.java ++++ b/net/minecraft/world/entity/animal/Sheep.java +@@ -60,7 +_,7 @@ + import net.minecraft.world.level.gameevent.GameEvent; + import net.minecraft.world.level.storage.loot.BuiltInLootTables; + +-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_) -> { +@@ -212,7 +_,7 @@ + + public InteractionResult m_6071_(Player p_29853_, InteractionHand p_29854_) { + ItemStack itemstack = p_29853_.m_21120_(p_29854_); +- if (itemstack.m_150930_(Items.f_42574_)) { ++ if (false && itemstack.m_41720_() == Items.f_42574_) { //Forge: Moved to onSheared + if (!this.f_19853_.f_46443_ && this.m_6220_()) { + this.m_5851_(SoundSource.PLAYERS); + this.m_146852_(GameEvent.f_157781_, p_29853_); +@@ -357,5 +_,27 @@ + + protected float m_6431_(Pose p_29850_, EntityDimensions p_29851_) { + return 0.95F * p_29851_.f_20378_; ++ } ++ ++ @Override ++ public boolean isShearable(@javax.annotation.Nonnull ItemStack item, Level world, BlockPos pos) { ++ return m_6220_(); ++ } ++ ++ @javax.annotation.Nonnull ++ @Override ++ public java.util.List onSheared(@Nullable Player player, @javax.annotation.Nonnull 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); ++ if (!world.f_46443_) { ++ this.m_29878_(true); ++ int i = 1 + this.f_19796_.nextInt(3); ++ ++ java.util.List items = new java.util.ArrayList<>(); ++ for (int j = 0; j < i; ++j) { ++ items.add(new ItemStack(f_29800_.get(this.m_29874_()))); ++ } ++ return items; ++ } ++ return java.util.Collections.emptyList(); + } + } diff --git a/patches/minecraft/net/minecraft/world/entity/animal/SnowGolem.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/SnowGolem.java.patch new file mode 100644 index 0000000000..3e8e7aa8b2 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/animal/SnowGolem.java.patch @@ -0,0 +1,60 @@ +--- a/net/minecraft/world/entity/animal/SnowGolem.java ++++ b/net/minecraft/world/entity/animal/SnowGolem.java +@@ -39,7 +_,7 @@ + import net.minecraft.world.level.gameevent.GameEvent; + import net.minecraft.world.phys.Vec3; + +-public class SnowGolem extends AbstractGolem implements Shearable, RangedAttackMob { ++public class SnowGolem extends AbstractGolem implements Shearable, RangedAttackMob, net.minecraftforge.common.IForgeShearable { + private static final EntityDataAccessor f_29899_ = SynchedEntityData.m_135353_(SnowGolem.class, EntityDataSerializers.f_135027_); + private static final byte f_149047_ = 16; + private static final float f_149048_ = 1.7F; +@@ -94,7 +_,7 @@ + this.m_6469_(DamageSource.f_19307_, 1.0F); + } + +- if (!this.f_19853_.m_46469_().m_46207_(GameRules.f_46132_)) { ++ if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_19853_, this)) { + return; + } + +@@ -105,7 +_,7 @@ + j = Mth.m_14107_(this.m_20186_()); + k = Mth.m_14107_(this.m_20189_() + (double)((float)(l / 2 % 2 * 2 - 1) * 0.25F)); + BlockPos blockpos = new BlockPos(i, j, k); +- if (this.f_19853_.m_8055_(blockpos).m_60795_() && this.f_19853_.m_46857_(blockpos).m_47505_(blockpos) < 0.8F && blockstate.m_60710_(this.f_19853_, blockpos)) { ++ if (this.f_19853_.m_46859_(blockpos) && this.f_19853_.m_46857_(blockpos).m_47505_(blockpos) < 0.8F && blockstate.m_60710_(this.f_19853_, blockpos)) { + this.f_19853_.m_46597_(blockpos, blockstate); + } + } +@@ -131,7 +_,7 @@ + + protected InteractionResult m_6071_(Player p_29920_, InteractionHand p_29921_) { + ItemStack itemstack = p_29920_.m_21120_(p_29921_); +- if (itemstack.m_150930_(Items.f_42574_) && this.m_6220_()) { ++ if (false && itemstack.m_41720_() == Items.f_42574_ && this.m_6220_()) { //Forge: Moved to onSheared + this.m_5851_(SoundSource.PLAYERS); + this.m_146852_(GameEvent.f_157781_, p_29920_); + if (!this.f_19853_.f_46443_) { +@@ -190,5 +_,21 @@ + + public Vec3 m_7939_() { + return new Vec3(0.0D, (double)(0.75F * this.m_20192_()), (double)(this.m_20205_() * 0.4F)); ++ } ++ ++ @Override ++ public boolean isShearable(@javax.annotation.Nonnull ItemStack item, Level world, BlockPos pos) { ++ return m_6220_(); ++ } ++ ++ @javax.annotation.Nonnull ++ @Override ++ public java.util.List onSheared(@Nullable Player player, @javax.annotation.Nonnull ItemStack item, Level world, BlockPos pos, int fortune) { ++ world.m_6269_(null, this, SoundEvents.f_12480_, player == null ? SoundSource.BLOCKS : SoundSource.PLAYERS, 1.0F, 1.0F); ++ if (!world.m_5776_()) { ++ m_29936_(false); ++ return java.util.Collections.singletonList(new ItemStack(Items.f_42047_)); ++ } ++ return java.util.Collections.emptyList(); + } + } diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Wolf.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Wolf.java.patch new file mode 100644 index 0000000000..daf5485055 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/animal/Wolf.java.patch @@ -0,0 +1,19 @@ +--- a/net/minecraft/world/entity/animal/Wolf.java ++++ b/net/minecraft/world/entity/animal/Wolf.java +@@ -136,6 +_,7 @@ + this.m_30397_(DyeColor.m_41053_(p_30402_.m_128451_("CollarColor"))); + } + ++ if(!f_19853_.f_46443_) //FORGE: allow this entity to be read from nbt on client. (Fixes MC-189565) + this.m_147285_(this.f_19853_, p_30402_); + } + +@@ -348,7 +_,7 @@ + itemstack.m_41774_(1); + } + +- if (this.f_19796_.nextInt(3) == 0) { ++ if (this.f_19796_.nextInt(3) == 0 && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(this, p_30412_)) { + this.m_21828_(p_30412_); + this.f_21344_.m_26573_(); + this.m_6710_((LivingEntity)null); 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 new file mode 100644 index 0000000000..460bf46f5d --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch @@ -0,0 +1,56 @@ +--- a/net/minecraft/world/entity/animal/horse/AbstractHorse.java ++++ b/net/minecraft/world/entity/animal/horse/AbstractHorse.java +@@ -286,6 +_,7 @@ + + this.f_30520_.m_19164_(this); + this.m_7493_(); ++ this.itemHandler = net.minecraftforge.common.util.LazyOptional.of(() -> new net.minecraftforge.items.wrapper.InvWrapper(this.f_30520_)); + } + + protected void m_7493_() { +@@ -344,9 +_,9 @@ + protected void m_7355_(BlockPos p_30584_, BlockState p_30585_) { + if (!p_30585_.m_60767_().m_76332_()) { + BlockState blockstate = this.f_19853_.m_8055_(p_30584_.m_7494_()); +- SoundType soundtype = p_30585_.m_60827_(); ++ SoundType soundtype = p_30585_.getSoundType(f_19853_, p_30584_, this); + if (blockstate.m_60713_(Blocks.f_50125_)) { +- soundtype = blockstate.m_60827_(); ++ soundtype = blockstate.getSoundType(f_19853_, p_30584_, this); + } + + if (this.m_20160_() && this.f_30523_) { +@@ -698,6 +_,7 @@ + this.m_20334_(vec3.f_82479_, d1, vec3.f_82481_); + this.m_30655_(true); + this.f_19812_ = true; ++ net.minecraftforge.common.ForgeHooks.onLivingJump(this); + if (f1 > 0.0F) { + float f2 = Mth.m_14031_(this.m_146908_() * ((float)Math.PI / 180F)); + float f3 = Mth.m_14089_(this.m_146908_() * ((float)Math.PI / 180F)); +@@ -1027,6 +_,25 @@ + + this.m_7505_(); + return super.m_6518_(p_30555_, p_30556_, p_30557_, p_30558_, p_30559_); ++ } ++ ++ private net.minecraftforge.common.util.LazyOptional itemHandler = null; ++ ++ @Override ++ public net.minecraftforge.common.util.LazyOptional getCapability(net.minecraftforge.common.capabilities.Capability capability, @Nullable net.minecraft.core.Direction facing) { ++ if (this.m_6084_() && capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY && itemHandler != null) ++ return itemHandler.cast(); ++ return super.getCapability(capability, facing); ++ } ++ ++ @Override ++ protected void invalidateCaps() { ++ super.invalidateCaps(); ++ if (itemHandler != null) { ++ net.minecraftforge.common.util.LazyOptional oldHandler = itemHandler; ++ itemHandler = null; ++ oldHandler.invalidate(); ++ } + } + + public boolean m_149511_(Container p_149512_) { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/horse/Horse.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/horse/Horse.java.patch new file mode 100644 index 0000000000..d509feb683 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/animal/horse/Horse.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/entity/animal/horse/Horse.java ++++ b/net/minecraft/world/entity/animal/horse/Horse.java +@@ -139,6 +_,8 @@ + this.m_5496_(SoundEvents.f_11974_, p_30709_.m_56773_() * 0.6F, p_30709_.m_56774_()); + } + ++ ItemStack stack = this.f_30520_.m_8020_(1); ++ if (m_6010_(stack)) stack.onHorseArmorTick(f_19853_, this); + } + + protected SoundEvent m_7515_() { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java.patch new file mode 100644 index 0000000000..6050c9fc6d --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java.patch @@ -0,0 +1,22 @@ +--- a/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java ++++ b/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java +@@ -27,6 +_,10 @@ + + public void m_8037_() { + ServerLevel serverlevel = (ServerLevel)this.f_30925_.f_19853_; ++ // Forge: Trigger the trap in a tick task to avoid crashes when mods add goals to skeleton horses ++ // (MC-206338/Forge PR #7509) ++ serverlevel.m_142572_().m_6937_(new net.minecraft.server.TickTask(serverlevel.m_142572_().m_129921_(), () -> { ++ if (!this.f_30925_.m_6084_()) return; + DifficultyInstance difficultyinstance = serverlevel.m_6436_(this.f_30925_.m_142538_()); + this.f_30925_.m_30923_(false); + this.f_30925_.m_30651_(true); +@@ -46,7 +_,7 @@ + abstracthorse.m_5997_(this.f_30925_.m_21187_().nextGaussian() * 0.5D, 0.0D, this.f_30925_.m_21187_().nextGaussian() * 0.5D); + serverlevel.m_47205_(abstracthorse); + } +- ++ })); + } + + private AbstractHorse m_30929_(DifficultyInstance p_30930_) { diff --git a/patches/minecraft/net/minecraft/world/entity/boss/EnderDragonPart.java.patch b/patches/minecraft/net/minecraft/world/entity/boss/EnderDragonPart.java.patch new file mode 100644 index 0000000000..9906520e98 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/boss/EnderDragonPart.java.patch @@ -0,0 +1,18 @@ +--- a/net/minecraft/world/entity/boss/EnderDragonPart.java ++++ b/net/minecraft/world/entity/boss/EnderDragonPart.java +@@ -8,13 +_,13 @@ + import net.minecraft.world.entity.Pose; + import net.minecraft.world.entity.boss.enderdragon.EnderDragon; + +-public class EnderDragonPart extends Entity { ++public class EnderDragonPart extends net.minecraftforge.entity.PartEntity { + public final EnderDragon f_31010_; + public final String f_31011_; + private final EntityDimensions f_31012_; + + public EnderDragonPart(EnderDragon p_31014_, String p_31015_, float p_31016_, float p_31017_) { +- super(p_31014_.m_6095_(), p_31014_.f_19853_); ++ super(p_31014_); + this.f_31012_ = EntityDimensions.m_20395_(p_31016_, p_31017_); + this.m_6210_(); + this.f_31010_ = p_31014_; 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 new file mode 100644 index 0000000000..1b767f5ee4 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch @@ -0,0 +1,28 @@ +--- a/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java ++++ b/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java +@@ -420,7 +_,7 @@ + BlockPos blockpos = new BlockPos(k1, l1, i2); + BlockState blockstate = this.f_19853_.m_8055_(blockpos); + if (!blockstate.m_60795_() && blockstate.m_60767_() != Material.f_76309_) { +- if (this.f_19853_.m_46469_().m_46207_(GameRules.f_46132_) && !blockstate.m_60620_(BlockTags.f_13069_)) { ++ if (net.minecraftforge.common.ForgeHooks.canEntityDestroy(this.f_19853_, blockpos, this) && !BlockTags.f_13069_.m_8110_(blockstate.m_60734_())) { + flag1 = this.f_19853_.m_7471_(blockpos, false) || flag1; + } else { + flag = true; +@@ -847,6 +_,16 @@ + + public boolean m_6072_() { + return false; ++ } ++ ++ @Override ++ public boolean isMultipartEntity() { ++ return true; ++ } ++ ++ @Override ++ public net.minecraftforge.entity.PartEntity[] getParts() { ++ return this.f_31089_; + } + + public void m_142223_(ClientboundAddMobPacket p_149572_) { diff --git a/patches/minecraft/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch b/patches/minecraft/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch new file mode 100644 index 0000000000..8315f1ab16 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch @@ -0,0 +1,37 @@ +--- a/net/minecraft/world/entity/boss/wither/WitherBoss.java ++++ b/net/minecraft/world/entity/boss/wither/WitherBoss.java +@@ -209,7 +_,7 @@ + int k1 = this.m_31502_() - 1; + this.f_31430_.m_142711_(1.0F - (float)k1 / 220.0F); + if (k1 <= 0) { +- Explosion.BlockInteraction explosion$blockinteraction = this.f_19853_.m_46469_().m_46207_(GameRules.f_46132_) ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.NONE; ++ Explosion.BlockInteraction explosion$blockinteraction = net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_19853_, this) ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.NONE; + this.f_19853_.m_46518_(this, this.m_20185_(), this.m_20188_(), this.m_20189_(), 7.0F, false, explosion$blockinteraction); + if (!this.m_20067_()) { + this.f_19853_.m_6798_(1023, this.m_142538_(), 0); +@@ -270,7 +_,7 @@ + + if (this.f_31429_ > 0) { + --this.f_31429_; +- if (this.f_31429_ == 0 && this.f_19853_.m_46469_().m_46207_(GameRules.f_46132_)) { ++ if (this.f_31429_ == 0 && net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_19853_, this)) { + int j1 = Mth.m_14107_(this.m_20186_()); + int i2 = Mth.m_14107_(this.m_20185_()); + int j2 = Mth.m_14107_(this.m_20189_()); +@@ -284,7 +_,7 @@ + int i1 = j2 + k2; + BlockPos blockpos = new BlockPos(l2, l, i1); + BlockState blockstate = this.f_19853_.m_8055_(blockpos); +- if (m_31491_(blockstate)) { ++ if (blockstate.canEntityDestroy(this.f_19853_, blockpos, this) && net.minecraftforge.event.ForgeEventFactory.onEntityDestroyBlock(this, blockpos, blockstate)) { + flag = this.f_19853_.m_46953_(blockpos, true, this) || flag; + } + } +@@ -305,6 +_,7 @@ + } + } + ++ @Deprecated //Forge: DO NOT USE use BlockState.canEntityDestroy + public static boolean m_31491_(BlockState p_31492_) { + return !p_31492_.m_60795_() && !p_31492_.m_60620_(BlockTags.f_13070_); + } diff --git a/patches/minecraft/net/minecraft/world/entity/decoration/ArmorStand.java.patch b/patches/minecraft/net/minecraft/world/entity/decoration/ArmorStand.java.patch new file mode 100644 index 0000000000..06b5e501e2 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/decoration/ArmorStand.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/entity/decoration/ArmorStand.java ++++ b/net/minecraft/world/entity/decoration/ArmorStand.java +@@ -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_) -> { +- return p_31582_ instanceof AbstractMinecart && ((AbstractMinecart)p_31582_).m_6064_() == AbstractMinecart.Type.RIDEABLE; ++ return p_31582_ instanceof AbstractMinecart && ((AbstractMinecart)p_31582_).canBeRidden(); + }; + private final NonNullList f_31538_ = NonNullList.m_122780_(2, ItemStack.f_41583_); + private final NonNullList f_31539_ = NonNullList.m_122780_(4, ItemStack.f_41583_); diff --git a/patches/minecraft/net/minecraft/world/entity/decoration/HangingEntity.java.patch b/patches/minecraft/net/minecraft/world/entity/decoration/HangingEntity.java.patch new file mode 100644 index 0000000000..bbfbf794f0 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/decoration/HangingEntity.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/entity/decoration/HangingEntity.java ++++ b/net/minecraft/world/entity/decoration/HangingEntity.java +@@ -118,6 +_,8 @@ + int j1 = (j - 1) / -2; + blockpos$mutableblockpos.m_122190_(blockpos).m_122175_(direction, k + i1).m_122175_(Direction.UP, l + j1); + BlockState blockstate = this.f_19853_.m_8055_(blockpos$mutableblockpos); ++ if (net.minecraft.world.level.block.Block.m_49863_(this.f_19853_, blockpos$mutableblockpos, this.f_31699_)) ++ continue; + if (!blockstate.m_60767_().m_76333_() && !DiodeBlock.m_52586_(blockstate)) { + return false; + } diff --git a/patches/minecraft/net/minecraft/world/entity/decoration/Motive.java.patch b/patches/minecraft/net/minecraft/world/entity/decoration/Motive.java.patch new file mode 100644 index 0000000000..c738d9d289 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/decoration/Motive.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/entity/decoration/Motive.java ++++ b/net/minecraft/world/entity/decoration/Motive.java +@@ -2,7 +_,7 @@ + + import net.minecraft.core.Registry; + +-public class Motive { ++public class Motive extends net.minecraftforge.registries.ForgeRegistryEntry { + public static final Motive f_31866_ = m_31897_("kebab", 16, 16); + public static final Motive f_31867_ = m_31897_("aztec", 16, 16); + public static final Motive f_31868_ = m_31897_("alban", 16, 16); diff --git a/patches/minecraft/net/minecraft/world/entity/item/ItemEntity.java.patch b/patches/minecraft/net/minecraft/world/entity/item/ItemEntity.java.patch new file mode 100644 index 0000000000..297ae9c751 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/item/ItemEntity.java.patch @@ -0,0 +1,127 @@ +--- a/net/minecraft/world/entity/item/ItemEntity.java ++++ b/net/minecraft/world/entity/item/ItemEntity.java +@@ -41,6 +_,10 @@ + private UUID f_31988_; + private UUID f_31982_; + public final float f_31983_; ++ /** ++ * The maximum age of this EntityItem. The item is expired once this is reached. ++ */ ++ public int lifespan = 6000; + + public ItemEntity(EntityType p_31991_, Level p_31992_) { + super(p_31991_, p_31992_); +@@ -57,6 +_,7 @@ + this.m_6034_(p_149664_, p_149665_, p_149666_); + this.m_20334_(p_149668_, p_149669_, p_149670_); + this.m_32045_(p_149667_); ++ this.lifespan = (p_149667_.m_41720_() == null ? 6000 : p_149667_.getEntityLifespan(p_149663_)); + } + + private ItemEntity(ItemEntity p_31994_) { +@@ -80,6 +_,7 @@ + } + + public void m_8119_() { ++ if (m_32055_().onEntityItemUpdate(this)) return; + if (this.m_32055_().m_41619_()) { + this.m_146870_(); + } else { +@@ -116,7 +_,7 @@ + this.m_6478_(MoverType.SELF, this.m_20184_()); + float f1 = 0.98F; + if (this.f_19861_) { +- f1 = this.f_19853_.m_8055_(new BlockPos(this.m_20185_(), this.m_20186_() - 1.0D, this.m_20189_())).m_60734_().m_49958_() * 0.98F; ++ f1 = this.f_19853_.m_8055_(new BlockPos(this.m_20185_(), this.m_20186_() - 1.0D, this.m_20189_())).getFriction(f_19853_, new BlockPos(this.m_20185_(), this.m_20186_() - 1.0D, this.m_20189_()), this) * 0.98F; + } + + this.m_20256_(this.m_20184_().m_82542_((double)f1, 0.98D, (double)f1)); +@@ -146,7 +_,14 @@ + } + } + +- if (!this.f_19853_.f_46443_ && this.f_31985_ >= 6000) { ++ ItemStack item = this.m_32055_(); ++ if (!this.f_19853_.f_46443_ && this.f_31985_ >= lifespan) { ++ int hook = net.minecraftforge.event.ForgeEventFactory.onItemExpire(this, item); ++ if (hook < 0) this.remove(false); ++ else this.lifespan += hook; ++ } ++ ++ if (item.m_41619_()) { + this.m_146870_(); + } + +@@ -204,6 +_,8 @@ + return false; + } else if (p_32028_.m_41782_() ^ p_32027_.m_41782_()) { + return false; ++ } else if (!p_32027_.areCapsCompatible(p_32028_)) { ++ return false; + } else { + return !p_32028_.m_41782_() || p_32028_.m_41783_().equals(p_32027_.m_41783_()); + } +@@ -237,6 +_,7 @@ + } + + public boolean m_6469_(DamageSource p_32013_, float p_32014_) { ++ if (this.f_19853_.f_46443_ || this.m_146910_()) return false; //Forge: Fixes MC-53850 + if (this.m_6673_(p_32013_)) { + return false; + } else if (!this.m_32055_().m_41619_() && this.m_32055_().m_150930_(Items.f_42686_) && p_32013_.m_19372_()) { +@@ -260,6 +_,7 @@ + p_32050_.m_128376_("Health", (short)this.f_31987_); + p_32050_.m_128376_("Age", (short)this.f_31985_); + p_32050_.m_128376_("PickupDelay", (short)this.f_31986_); ++ p_32050_.m_128405_("Lifespan", lifespan); + if (this.m_32057_() != null) { + p_32050_.m_128362_("Thrower", this.m_32057_()); + } +@@ -280,6 +_,7 @@ + if (p_32034_.m_128441_("PickupDelay")) { + this.f_31986_ = p_32034_.m_128448_("PickupDelay"); + } ++ if (p_32034_.m_128441_("Lifespan")) lifespan = p_32034_.m_128451_("Lifespan"); + + if (p_32034_.m_128403_("Owner")) { + this.f_31982_ = p_32034_.m_128342_("Owner"); +@@ -299,10 +_,18 @@ + + public void m_6123_(Player p_32040_) { + if (!this.f_19853_.f_46443_) { ++ if (this.f_31986_ > 0) return; + ItemStack itemstack = this.m_32055_(); + Item item = itemstack.m_41720_(); + int i = itemstack.m_41613_(); +- if (this.f_31986_ == 0 && (this.f_31982_ == null || this.f_31982_.equals(p_32040_.m_142081_())) && p_32040_.m_150109_().m_36054_(itemstack)) { ++ ++ int hook = net.minecraftforge.event.ForgeEventFactory.onItemPickup(this, p_32040_); ++ if (hook < 0) return; ++ ++ ItemStack copy = itemstack.m_41777_(); ++ if (this.f_31986_ == 0 && (this.f_31982_ == null || lifespan - this.f_31985_ <= 200 || this.f_31982_.equals(p_32040_.m_142081_())) && (hook == 1 || i <= 0 || p_32040_.m_150109_().m_36054_(itemstack))) { ++ copy.m_41764_(copy.m_41613_() - m_32055_().m_41613_()); ++ net.minecraftforge.fmllegacy.hooks.BasicEventHooks.firePlayerItemPickupEvent(p_32040_, this, copy); + p_32040_.m_7938_(this, i); + if (itemstack.m_41619_()) { + this.m_146870_(); +@@ -326,8 +_,8 @@ + } + + @Nullable +- public Entity m_5489_(ServerLevel p_32042_) { +- Entity entity = super.m_5489_(p_32042_); ++ public Entity changeDimension(ServerLevel p_32042_, net.minecraftforge.common.util.ITeleporter teleporter) { ++ Entity entity = super.changeDimension(p_32042_, teleporter); + if (!this.f_19853_.f_46443_ && entity instanceof ItemEntity) { + ((ItemEntity)entity).m_32069_(); + } +@@ -403,7 +_,7 @@ + + public void m_32065_() { + this.m_32062_(); +- this.f_31985_ = 5999; ++ this.f_31985_ = m_32055_().getEntityLifespan(f_19853_) - 1; + } + + public float m_32008_(float p_32009_) { diff --git a/patches/minecraft/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch new file mode 100644 index 0000000000..32357f7278 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch @@ -0,0 +1,23 @@ +--- a/net/minecraft/world/entity/monster/AbstractSkeleton.java ++++ b/net/minecraft/world/entity/monster/AbstractSkeleton.java +@@ -152,7 +_,7 @@ + if (this.f_19853_ != null && !this.f_19853_.f_46443_) { + this.f_21345_.m_25363_(this.f_32131_); + this.f_21345_.m_25363_(this.f_32130_); +- ItemStack itemstack = this.m_21120_(ProjectileUtil.m_37297_(this, Items.f_42411_)); ++ ItemStack itemstack = this.m_21120_(ProjectileUtil.getWeaponHoldingHand(this, item -> item instanceof net.minecraft.world.item.BowItem)); + if (itemstack.m_150930_(Items.f_42411_)) { + int i = 20; + if (this.f_19853_.m_46791_() != Difficulty.HARD) { +@@ -169,8 +_,10 @@ + } + + public void m_6504_(LivingEntity p_32141_, float p_32142_) { +- ItemStack itemstack = this.m_6298_(this.m_21120_(ProjectileUtil.m_37297_(this, Items.f_42411_))); ++ ItemStack itemstack = this.m_6298_(this.m_21120_(ProjectileUtil.getWeaponHoldingHand(this, item -> item instanceof net.minecraft.world.item.BowItem))); + AbstractArrow abstractarrow = this.m_7932_(itemstack, p_32142_); ++ if (this.m_21205_().m_41720_() instanceof net.minecraft.world.item.BowItem) ++ abstractarrow = ((net.minecraft.world.item.BowItem)this.m_21205_().m_41720_()).customArrow(abstractarrow); + double d0 = p_32141_.m_20185_() - this.m_20185_(); + double d1 = p_32141_.m_20227_(0.3333333333333333D) - abstractarrow.m_20186_(); + double d2 = p_32141_.m_20189_() - this.m_20189_(); diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Creeper.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Creeper.java.patch new file mode 100644 index 0000000000..416a1e2d31 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/monster/Creeper.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/entity/monster/Creeper.java ++++ b/net/minecraft/world/entity/monster/Creeper.java +@@ -220,7 +_,7 @@ + + private void m_32315_() { + if (!this.f_19853_.f_46443_) { +- Explosion.BlockInteraction explosion$blockinteraction = this.f_19853_.m_46469_().m_46207_(GameRules.f_46132_) ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.NONE; ++ Explosion.BlockInteraction explosion$blockinteraction = net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_19853_, this) ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.NONE; + float f = this.m_7090_() ? 2.0F : 1.0F; + this.f_20890_ = true; + this.f_19853_.m_46511_(this, this.m_20185_(), this.m_20186_(), this.m_20189_(), (float)this.f_32272_ * f, explosion$blockinteraction); diff --git a/patches/minecraft/net/minecraft/world/entity/monster/CrossbowAttackMob.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/CrossbowAttackMob.java.patch new file mode 100644 index 0000000000..dfa98e8a18 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/monster/CrossbowAttackMob.java.patch @@ -0,0 +1,14 @@ +--- a/net/minecraft/world/entity/monster/CrossbowAttackMob.java ++++ b/net/minecraft/world/entity/monster/CrossbowAttackMob.java +@@ -24,9 +_,9 @@ + void m_5847_(); + + default void m_32336_(LivingEntity p_32337_, float p_32338_) { +- InteractionHand interactionhand = ProjectileUtil.m_37297_(p_32337_, Items.f_42717_); ++ InteractionHand interactionhand = ProjectileUtil.getWeaponHoldingHand(p_32337_, item -> item instanceof CrossbowItem); + ItemStack itemstack = p_32337_.m_21120_(interactionhand); +- if (p_32337_.m_21055_(Items.f_42717_)) { ++ if (p_32337_.m_21093_(is -> is.m_41720_() instanceof CrossbowItem)) { + CrossbowItem.m_40887_(p_32337_.f_19853_, p_32337_, interactionhand, itemstack, p_32338_, (float)(14 - p_32337_.f_19853_.m_46791_().m_19028_() * 4)); + } + diff --git a/patches/minecraft/net/minecraft/world/entity/monster/EnderMan.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/EnderMan.java.patch new file mode 100644 index 0000000000..b7d50d14f6 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/monster/EnderMan.java.patch @@ -0,0 +1,80 @@ +--- a/net/minecraft/world/entity/monster/EnderMan.java ++++ b/net/minecraft/world/entity/monster/EnderMan.java +@@ -98,7 +_,6 @@ + } + + public void m_6710_(@Nullable LivingEntity p_32537_) { +- super.m_6710_(p_32537_); + AttributeInstance attributeinstance = this.m_21051_(Attributes.f_22279_); + if (p_32537_ == null) { + this.f_32477_ = 0; +@@ -113,6 +_,7 @@ + } + } + ++ super.m_6710_(p_32537_); //Forge: Moved down to allow event handlers to write data manager values. + } + + protected void m_8097_() { +@@ -181,12 +_,13 @@ + } + + this.m_32521_(blockstate); ++ if(!f_19853_.f_46443_) //FORGE: allow this entity to be read from nbt on client. (Fixes MC-189565) + this.m_147285_(this.f_19853_, p_32511_); + } + + boolean m_32534_(Player p_32535_) { + ItemStack itemstack = p_32535_.m_150109_().f_35975_.get(3); +- if (itemstack.m_150930_(Blocks.f_50143_.m_5456_())) { ++ if (itemstack.isEnderMask(p_32535_, this)) { + return false; + } else { + Vec3 vec3 = p_32535_.m_20252_(1.0F).m_82541_(); +@@ -265,7 +_,9 @@ + boolean flag = blockstate.m_60767_().m_76334_(); + boolean flag1 = blockstate.m_60819_().m_76153_(FluidTags.f_13131_); + if (flag && !flag1) { +- boolean flag2 = this.m_20984_(p_32544_, p_32545_, p_32546_, true); ++ net.minecraftforge.event.entity.EntityTeleportEvent.EnderEntity event = net.minecraftforge.event.ForgeEventFactory.onEnderTeleport(this, p_32544_, p_32545_, p_32546_); ++ if (event.isCanceled()) return false; ++ boolean flag2 = this.m_20984_(event.getTargetX(), event.getTargetY(), event.getTargetZ(), true); + if (flag2 && !this.m_20067_()) { + this.f_19853_.m_6263_((Player)null, this.f_19854_, this.f_19855_, this.f_19856_, SoundEvents.f_11852_, this.m_5720_(), 1.0F, 1.0F); + this.m_5496_(SoundEvents.f_11852_, 1.0F, 1.0F); +@@ -382,7 +_,7 @@ + public boolean m_8036_() { + if (this.f_32554_.m_32530_() == null) { + return false; +- } else if (!this.f_32554_.f_19853_.m_46469_().m_46207_(GameRules.f_46132_)) { ++ } else if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_32554_.f_19853_, this.f_32554_)) { + return false; + } else { + return this.f_32554_.m_21187_().nextInt(2000) == 0; +@@ -402,7 +_,7 @@ + BlockState blockstate2 = this.f_32554_.m_32530_(); + if (blockstate2 != null) { + blockstate2 = Block.m_49931_(blockstate2, this.f_32554_.f_19853_, blockpos); +- if (this.m_32558_(level, blockpos, blockstate2, blockstate, blockstate1, blockpos1)) { ++ if (this.m_32558_(level, blockpos, blockstate2, blockstate, blockstate1, blockpos1) && !net.minecraftforge.event.ForgeEventFactory.onBlockPlace(f_32554_, net.minecraftforge.common.util.BlockSnapshot.create(level.m_46472_(), level, blockpos1), net.minecraft.core.Direction.UP)) { + level.m_7731_(blockpos, blockstate2, 3); + level.m_142346_(this.f_32554_, GameEvent.f_157797_, blockpos); + this.f_32554_.m_32521_((BlockState)null); +@@ -412,7 +_,7 @@ + } + + private boolean m_32558_(Level p_32559_, BlockPos p_32560_, BlockState p_32561_, BlockState p_32562_, BlockState p_32563_, BlockPos p_32564_) { +- return p_32562_.m_60795_() && !p_32563_.m_60795_() && !p_32563_.m_60713_(Blocks.f_50752_) && p_32563_.m_60838_(p_32559_, p_32564_) && p_32561_.m_60710_(p_32559_, p_32560_) && p_32559_.m_45933_(this.f_32554_, AABB.m_82333_(Vec3.m_82528_(p_32560_))).isEmpty(); ++ return p_32562_.m_60795_() && !p_32563_.m_60795_() && !p_32563_.m_60713_(Blocks.f_50752_) && !p_32563_.m_60620_(net.minecraftforge.common.Tags.Blocks.ENDERMAN_PLACE_ON_BLACKLIST) && p_32563_.m_60838_(p_32559_, p_32564_) && p_32561_.m_60710_(p_32559_, p_32560_) && p_32559_.m_45933_(this.f_32554_, AABB.m_82333_(Vec3.m_82528_(p_32560_))).isEmpty(); + } + } + +@@ -501,7 +_,7 @@ + public boolean m_8036_() { + if (this.f_32583_.m_32530_() != null) { + return false; +- } else if (!this.f_32583_.f_19853_.m_46469_().m_46207_(GameRules.f_46132_)) { ++ } else if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_32583_.f_19853_, this.f_32583_)) { + return false; + } else { + return this.f_32583_.m_21187_().nextInt(20) == 0; diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Evoker.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Evoker.java.patch new file mode 100644 index 0000000000..d39b340fc7 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/monster/Evoker.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/entity/monster/Evoker.java ++++ b/net/minecraft/world/entity/monster/Evoker.java +@@ -272,7 +_,7 @@ + return false; + } else if (Evoker.this.f_19797_ < this.f_33775_) { + return false; +- } else if (!Evoker.this.f_19853_.m_46469_().m_46207_(GameRules.f_46132_)) { ++ } else if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(Evoker.this.f_19853_, Evoker.this)) { + return false; + } else { + List list = Evoker.this.f_19853_.m_45971_(Sheep.class, this.f_32705_, Evoker.this, Evoker.this.m_142469_().m_82377_(16.0D, 4.0D, 16.0D)); diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Illusioner.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Illusioner.java.patch new file mode 100644 index 0000000000..79d6b2320b --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/monster/Illusioner.java.patch @@ -0,0 +1,14 @@ +--- a/net/minecraft/world/entity/monster/Illusioner.java ++++ b/net/minecraft/world/entity/monster/Illusioner.java +@@ -178,8 +_,10 @@ + } + + public void m_6504_(LivingEntity p_32918_, float p_32919_) { +- ItemStack itemstack = this.m_6298_(this.m_21120_(ProjectileUtil.m_37297_(this, Items.f_42411_))); ++ ItemStack itemstack = this.m_6298_(this.m_21120_(ProjectileUtil.getWeaponHoldingHand(this, item -> item instanceof net.minecraft.world.item.BowItem))); + AbstractArrow abstractarrow = ProjectileUtil.m_37300_(this, itemstack, p_32919_); ++ if (this.m_21205_().m_41720_() instanceof net.minecraft.world.item.BowItem) ++ abstractarrow = ((net.minecraft.world.item.BowItem)this.m_21205_().m_41720_()).customArrow(abstractarrow); + double d0 = p_32918_.m_20185_() - this.m_20185_(); + double d1 = p_32918_.m_20227_(0.3333333333333333D) - abstractarrow.m_20186_(); + double d2 = p_32918_.m_20189_() - this.m_20189_(); diff --git a/patches/minecraft/net/minecraft/world/entity/monster/MagmaCube.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/MagmaCube.java.patch new file mode 100644 index 0000000000..841fa75ce1 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/monster/MagmaCube.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/world/entity/monster/MagmaCube.java ++++ b/net/minecraft/world/entity/monster/MagmaCube.java +@@ -72,6 +_,7 @@ + Vec3 vec3 = this.m_20184_(); + this.m_20334_(vec3.f_82479_, (double)(this.m_6118_() + (float)this.m_33632_() * 0.1F), vec3.f_82481_); + this.f_19812_ = true; ++ net.minecraftforge.common.ForgeHooks.onLivingJump(this); + } + + protected void m_6197_(Tag p_32988_) { diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Pillager.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Pillager.java.patch new file mode 100644 index 0000000000..f6c2bbf85c --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/monster/Pillager.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/entity/monster/Pillager.java ++++ b/net/minecraft/world/entity/monster/Pillager.java +@@ -121,7 +_,7 @@ + public AbstractIllager.IllagerArmPose m_6768_() { + if (this.m_33309_()) { + return AbstractIllager.IllagerArmPose.CROSSBOW_CHARGE; +- } else if (this.m_21055_(Items.f_42717_)) { ++ } else if (this.m_21093_(is -> is.m_41720_() instanceof net.minecraft.world.item.CrossbowItem)) { + return AbstractIllager.IllagerArmPose.CROSSBOW_HOLD; + } else { + return this.m_5912_() ? AbstractIllager.IllagerArmPose.ATTACKING : AbstractIllager.IllagerArmPose.NEUTRAL; diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Ravager.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Ravager.java.patch new file mode 100644 index 0000000000..01456c1b9e --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/monster/Ravager.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/entity/monster/Ravager.java ++++ b/net/minecraft/world/entity/monster/Ravager.java +@@ -142,7 +_,7 @@ + this.m_21051_(Attributes.f_22279_).m_22100_(Mth.m_14139_(0.1D, d1, d0)); + } + +- if (this.f_19862_ && this.f_19853_.m_46469_().m_46207_(GameRules.f_46132_)) { ++ if (this.f_19862_ && net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_19853_, this)) { + boolean flag = false; + AABB aabb = this.m_142469_().m_82400_(0.2D); + diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Silverfish.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Silverfish.java.patch new file mode 100644 index 0000000000..cce9f52ef3 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/monster/Silverfish.java.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/world/entity/monster/Silverfish.java ++++ b/net/minecraft/world/entity/monster/Silverfish.java +@@ -135,7 +_,7 @@ + return false; + } else { + Random random = this.f_25725_.m_21187_(); +- if (this.f_25725_.f_19853_.m_46469_().m_46207_(GameRules.f_46132_) && random.nextInt(10) == 0) { ++ if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_25725_.f_19853_, this.f_25725_) && random.nextInt(10) == 0) { + this.f_33555_ = Direction.m_122404_(random); + BlockPos blockpos = (new BlockPos(this.f_25725_.m_20185_(), this.f_25725_.m_20186_() + 0.5D, this.f_25725_.m_20189_())).m_142300_(this.f_33555_); + BlockState blockstate = this.f_25725_.f_19853_.m_8055_(blockpos); +@@ -204,7 +_,7 @@ + BlockState blockstate = level.m_8055_(blockpos1); + Block block = blockstate.m_60734_(); + if (block instanceof InfestedBlock) { +- if (level.m_46469_().m_46207_(GameRules.f_46132_)) { ++ if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(level, this.f_33562_)) { + level.m_46953_(blockpos1, true, this.f_33562_); + } else { + level.m_7731_(blockpos1, ((InfestedBlock)block).m_153432_(level.m_8055_(blockpos1)), 3); diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Slime.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Slime.java.patch new file mode 100644 index 0000000000..dbdab71d33 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/monster/Slime.java.patch @@ -0,0 +1,45 @@ +--- a/net/minecraft/world/entity/monster/Slime.java ++++ b/net/minecraft/world/entity/monster/Slime.java +@@ -125,6 +_,7 @@ + if (this.f_19861_ && !this.f_33583_) { + int i = this.m_33632_(); + ++ if (spawnCustomParticles()) i = 0; // don't spawn particles if it's handled by the implementation itself + for(int j = 0; j < i * 8; ++j) { + float f = this.f_19796_.nextFloat() * ((float)Math.PI * 2F); + float f1 = this.f_19796_.nextFloat() * 0.5F + 0.5F; +@@ -176,9 +_,10 @@ + return (EntityType)super.m_6095_(); + } + +- public void m_142687_(Entity.RemovalReason p_149847_) { ++ @Override ++ public void remove(boolean keepData) { + int i = this.m_33632_(); +- if (!this.f_19853_.f_46443_ && i > 1 && this.m_21224_()) { ++ if (!this.f_19853_.f_46443_ && i > 1 && this.m_21224_() && !this.m_146910_()) { + Component component = this.m_7770_(); + boolean flag = this.m_21525_(); + float f = (float)i / 4.0F; +@@ -202,7 +_,7 @@ + } + } + +- super.m_142687_(p_149847_); ++ super.remove(keepData); + } + + public void m_7334_(Entity p_33636_) { +@@ -321,6 +_,12 @@ + public EntityDimensions m_6972_(Pose p_33597_) { + return super.m_6972_(p_33597_).m_20388_(0.255F * (float)this.m_33632_()); + } ++ ++ /** ++ * Called when the slime spawns particles on landing, see onUpdate. ++ * Return true to prevent the spawning of the default particles. ++ */ ++ protected boolean spawnCustomParticles() { return false; } + + static class SlimeAttackGoal extends Goal { + private final Slime f_33645_; diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Spider.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Spider.java.patch new file mode 100644 index 0000000000..c0f9023a8a --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/monster/Spider.java.patch @@ -0,0 +1,16 @@ +--- a/net/minecraft/world/entity/monster/Spider.java ++++ b/net/minecraft/world/entity/monster/Spider.java +@@ -119,7 +_,12 @@ + } + + public boolean m_7301_(MobEffectInstance p_33809_) { +- return p_33809_.m_19544_() == MobEffects.f_19614_ ? false : super.m_7301_(p_33809_); ++ if (p_33809_.m_19544_() == MobEffects.f_19614_) { ++ net.minecraftforge.event.entity.living.PotionEvent.PotionApplicableEvent event = new net.minecraftforge.event.entity.living.PotionEvent.PotionApplicableEvent(this, p_33809_); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); ++ return event.getResult() == net.minecraftforge.eventbus.api.Event.Result.ALLOW; ++ } ++ return super.m_7301_(p_33809_); + } + + public boolean m_33816_() { diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Zombie.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Zombie.java.patch new file mode 100644 index 0000000000..ea78360ff0 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/monster/Zombie.java.patch @@ -0,0 +1,79 @@ +--- a/net/minecraft/world/entity/monster/Zombie.java ++++ b/net/minecraft/world/entity/monster/Zombie.java +@@ -191,7 +_,7 @@ + if (!this.f_19853_.f_46443_ && this.m_6084_() && !this.m_21525_()) { + if (this.m_34329_()) { + --this.f_34266_; +- if (this.f_34266_ < 0) { ++ if (this.f_34266_ < 0 && net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, EntityType.f_20501_, (timer) -> this.f_34266_ = timer)) { + this.m_7595_(); + } + } else if (this.m_7593_()) { +@@ -253,6 +_,7 @@ + if (zombie != null) { + zombie.m_34339_(zombie.f_19853_.m_6436_(zombie.m_142538_()).m_19057_()); + zombie.m_34336_(zombie.m_7586_() && this.m_34330_()); ++ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, zombie); + } + + } +@@ -273,11 +_,14 @@ + livingentity = (LivingEntity)p_34288_.m_7639_(); + } + +- if (livingentity != null && this.f_19853_.m_46791_() == Difficulty.HARD && (double)this.f_19796_.nextFloat() < this.m_21133_(Attributes.f_22287_) && this.f_19853_.m_46469_().m_46207_(GameRules.f_46134_)) { + int i = Mth.m_14107_(this.m_20185_()); + int j = Mth.m_14107_(this.m_20186_()); + int k = Mth.m_14107_(this.m_20189_()); +- Zombie zombie = new Zombie(this.f_19853_); ++ net.minecraftforge.event.entity.living.ZombieEvent.SummonAidEvent event = net.minecraftforge.event.ForgeEventFactory.fireZombieSummonAid(this, f_19853_, i, j, k, livingentity, this.m_21051_(Attributes.f_22287_).m_22135_()); ++ if (event.getResult() == net.minecraftforge.eventbus.api.Event.Result.DENY) return true; ++ if (event.getResult() == net.minecraftforge.eventbus.api.Event.Result.ALLOW || ++ livingentity != null && this.f_19853_.m_46791_() == Difficulty.HARD && (double)this.f_19796_.nextFloat() < this.m_21051_(Attributes.f_22287_).m_22135_() && this.f_19853_.m_46469_().m_46207_(GameRules.f_46134_)) { ++ Zombie zombie = event.getCustomSummonedAid() != null && event.getResult() == net.minecraftforge.eventbus.api.Event.Result.ALLOW ? event.getCustomSummonedAid() : EntityType.f_20501_.m_20615_(this.f_19853_); + + for(int l = 0; l < 50; ++l) { + int i1 = i + Mth.m_14072_(this.f_19796_, 7, 40) * Mth.m_14072_(this.f_19796_, -1, 1); +@@ -289,6 +_,7 @@ + if (NaturalSpawner.m_47051_(spawnplacements$type, this.f_19853_, blockpos, entitytype) && SpawnPlacements.m_21759_(entitytype, serverlevel, MobSpawnType.REINFORCEMENT, blockpos, this.f_19853_.f_46441_)) { + zombie.m_6034_((double)i1, (double)j1, (double)k1); + if (!this.f_19853_.m_45914_((double)i1, (double)j1, (double)k1, 7.0D) && this.f_19853_.m_45784_(zombie) && this.f_19853_.m_45786_(zombie) && !this.f_19853_.m_46855_(zombie.m_142469_())) { ++ if (livingentity != null) + zombie.m_6710_(livingentity); + zombie.m_6518_(serverlevel, this.f_19853_.m_6436_(zombie.m_142538_()), MobSpawnType.REINFORCEMENT, (SpawnGroupData)null, (CompoundTag)null); + serverlevel.m_47205_(zombie); +@@ -374,7 +_,7 @@ + + public void m_5837_(ServerLevel p_34281_, LivingEntity p_34282_) { + super.m_5837_(p_34281_, p_34282_); +- if ((p_34281_.m_46791_() == Difficulty.NORMAL || p_34281_.m_46791_() == Difficulty.HARD) && p_34282_ instanceof Villager) { ++ if ((p_34281_.m_46791_() == Difficulty.NORMAL || p_34281_.m_46791_() == Difficulty.HARD) && p_34282_ instanceof Villager && net.minecraftforge.event.ForgeEventFactory.canLivingConvert(p_34282_, EntityType.f_20530_, (timer) -> {})) { + if (p_34281_.m_46791_() != Difficulty.HARD && this.f_19796_.nextBoolean()) { + return; + } +@@ -386,6 +_,7 @@ + zombievillager.m_34391_(villager.m_35517_().m_26179_(NbtOps.f_128958_).getValue()); + zombievillager.m_34411_(villager.m_6616_().m_45388_()); + zombievillager.m_34373_(villager.m_7809_()); ++ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(p_34282_, zombievillager); + if (!this.m_20067_()) { + p_34281_.m_5898_((Player)null, 1026, this.m_142538_(), 0); + } +@@ -457,7 +_,7 @@ + } + + public static boolean m_34302_(Random p_34303_) { +- return p_34303_.nextFloat() < 0.05F; ++ return p_34303_.nextFloat() < net.minecraftforge.common.ForgeConfig.SERVER.zombieBabyChance.get(); + } + + protected void m_34339_(float p_34340_) { +@@ -477,7 +_,7 @@ + } + + protected void m_7572_() { +- this.m_21051_(Attributes.f_22287_).m_22100_(this.f_19796_.nextDouble() * (double)0.1F); ++ this.m_21051_(Attributes.f_22287_).m_22100_(this.f_19796_.nextDouble() * net.minecraftforge.common.ForgeConfig.SERVER.zombieBaseSummonChance.get()); + } + + public double m_6049_() { diff --git a/patches/minecraft/net/minecraft/world/entity/monster/ZombieVillager.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/ZombieVillager.java.patch new file mode 100644 index 0000000000..5f24c79d1e --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/monster/ZombieVillager.java.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/world/entity/monster/ZombieVillager.java ++++ b/net/minecraft/world/entity/monster/ZombieVillager.java +@@ -119,7 +_,7 @@ + if (!this.f_19853_.f_46443_ && this.m_6084_() && this.m_34408_()) { + int i = this.m_34410_(); + this.f_34365_ -= i; +- if (this.f_34365_ <= 0) { ++ if (this.f_34365_ <= 0 && net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, EntityType.f_20492_, (timer) -> this.f_34365_ = timer)) { + this.m_34398_((ServerLevel)this.f_19853_); + } + } +@@ -221,7 +_,7 @@ + if (!this.m_20067_()) { + p_34399_.m_5898_((Player)null, 1027, this.m_142538_(), 0); + } +- ++ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, villager); + } + + private int m_34410_() { diff --git a/patches/minecraft/net/minecraft/world/entity/monster/ZombifiedPiglin.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/ZombifiedPiglin.java.patch new file mode 100644 index 0000000000..563978bdd0 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/monster/ZombifiedPiglin.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/world/entity/monster/ZombifiedPiglin.java ++++ b/net/minecraft/world/entity/monster/ZombifiedPiglin.java +@@ -175,6 +_,7 @@ + + public void m_7378_(CompoundTag p_34446_) { + super.m_7378_(p_34446_); ++ if(!f_19853_.f_46443_) //FORGE: allow this entity to be read from nbt on client. (Fixes MC-189565) + this.m_147285_(this.f_19853_, p_34446_); + } + 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 new file mode 100644 index 0000000000..dcda2e19bc --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch @@ -0,0 +1,19 @@ +--- a/net/minecraft/world/entity/monster/hoglin/Hoglin.java ++++ b/net/minecraft/world/entity/monster/hoglin/Hoglin.java +@@ -126,7 +_,7 @@ + HoglinAi.m_34577_(this); + if (this.m_34554_()) { + ++this.f_34484_; +- if (this.f_34484_ > 300) { ++ if (this.f_34484_ > 300 && net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, EntityType.f_20500_, (timer) -> this.f_34484_ = timer)) { + this.m_34500_(SoundEvents.f_11959_); + this.m_34531_((ServerLevel)this.f_19853_); + } +@@ -219,6 +_,7 @@ + Zoglin zoglin = this.m_21406_(EntityType.f_20500_, true); + if (zoglin != null) { + zoglin.m_7292_(new MobEffectInstance(MobEffects.f_19604_, 200, 0)); ++ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, zoglin); + } + + } 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 new file mode 100644 index 0000000000..e8fc4892db --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java.patch @@ -0,0 +1,22 @@ +--- a/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java ++++ b/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java +@@ -80,9 +_,10 @@ + ++this.f_34649_; + } else { + this.f_34649_ = 0; ++ this.f_34649_ = 0; + } + +- if (this.f_34649_ > 300) { ++ if (this.f_34649_ > 300 && net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, EntityType.f_20531_, (timer) -> this.f_34649_ = timer)) { + this.m_7580_(); + this.m_8063_((ServerLevel)this.f_19853_); + } +@@ -97,6 +_,7 @@ + ZombifiedPiglin zombifiedpiglin = this.m_21406_(EntityType.f_20531_, true); + if (zombifiedpiglin != null) { + zombifiedpiglin.m_7292_(new MobEffectInstance(MobEffects.f_19604_, 200, 0)); ++ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, zombifiedpiglin); + } + + } 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 new file mode 100644 index 0000000000..159655def2 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/monster/piglin/Piglin.java.patch @@ -0,0 +1,29 @@ +--- a/net/minecraft/world/entity/monster/piglin/Piglin.java ++++ b/net/minecraft/world/entity/monster/piglin/Piglin.java +@@ -282,7 +_,7 @@ + } else if (this.m_34773_()) { + return PiglinArmPose.CROSSBOW_CHARGE; + } else { +- return this.m_5912_() && this.m_21055_(Items.f_42717_) ? PiglinArmPose.CROSSBOW_HOLD : PiglinArmPose.DEFAULT; ++ return this.m_5912_() && this.m_21093_(is -> is.m_41720_() instanceof net.minecraft.world.item.CrossbowItem) ? PiglinArmPose.CROSSBOW_HOLD : PiglinArmPose.DEFAULT; + } + } + +@@ -324,7 +_,7 @@ + } + + protected void m_34785_(ItemStack p_34786_) { +- if (p_34786_.m_150930_(PiglinAi.f_34794_)) { ++ if (p_34786_.isPiglinCurrency()) { + this.m_8061_(EquipmentSlot.OFFHAND, p_34786_); + this.m_21508_(EquipmentSlot.OFFHAND); + } else { +@@ -334,7 +_,7 @@ + } + + public boolean m_7243_(ItemStack p_34777_) { +- return this.f_19853_.m_46469_().m_46207_(GameRules.f_46132_) && this.m_21531_() && PiglinAi.m_34857_(this, p_34777_); ++ return net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_19853_, this) && this.m_21531_() && PiglinAi.m_34857_(this, p_34777_); + } + + protected boolean m_34787_(ItemStack p_34788_) { diff --git a/patches/minecraft/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch new file mode 100644 index 0000000000..4de3c93911 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch @@ -0,0 +1,47 @@ +--- a/net/minecraft/world/entity/monster/piglin/PiglinAi.java ++++ b/net/minecraft/world/entity/monster/piglin/PiglinAi.java +@@ -258,7 +_,7 @@ + ItemStack itemstack = p_34868_.m_21120_(InteractionHand.OFF_HAND); + p_34868_.m_21008_(InteractionHand.OFF_HAND, ItemStack.f_41583_); + if (p_34868_.m_34667_()) { +- boolean flag = m_149967_(itemstack); ++ boolean flag = itemstack.isPiglinCurrency(); + if (p_34869_ && flag) { + m_34860_(p_34868_, m_34996_(p_34868_)); + } else if (!flag) { +@@ -345,7 +_,7 @@ + return false; + } else if (m_35024_(p_34858_) && p_34858_.m_6274_().m_21874_(MemoryModuleType.f_26372_)) { + return false; +- } else if (m_149967_(p_34859_)) { ++ } else if (p_34859_.isPiglinCurrency()) { + return m_35028_(p_34858_); + } else { + boolean flag = p_34858_.m_34780_(p_34859_); +@@ -445,7 +_,7 @@ + } + + protected static boolean m_34909_(Piglin p_34910_, ItemStack p_34911_) { +- return !m_35024_(p_34910_) && !m_35020_(p_34910_) && p_34910_.m_34667_() && m_149967_(p_34911_); ++ return !m_35024_(p_34910_) && !m_35020_(p_34910_) && p_34910_.m_34667_() && p_34911_.isPiglinCurrency(); + } + + protected static void m_34837_(Piglin p_34838_, LivingEntity p_34839_) { +@@ -546,7 +_,7 @@ + public static boolean m_34808_(LivingEntity p_34809_) { + for(ItemStack itemstack : p_34809_.m_6168_()) { + Item item = itemstack.m_41720_(); +- if (item instanceof ArmorItem && ((ArmorItem)item).m_40401_() == ArmorMaterials.GOLD) { ++ if (itemstack.makesPiglinsNeutral(p_34809_)) { + return true; + } + } +@@ -704,7 +_,7 @@ + } + + private static boolean m_34918_(LivingEntity p_34919_) { +- return p_34919_.m_21055_(Items.f_42717_); ++ return p_34919_.m_21093_(is -> is.m_41720_() instanceof net.minecraft.world.item.CrossbowItem); + } + + private static void m_34938_(LivingEntity p_34939_) { 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 new file mode 100644 index 0000000000..6d1ae564c7 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/monster/piglin/StopHoldingItemIfNoLongerAdmiring.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/entity/monster/piglin/StopHoldingItemIfNoLongerAdmiring.java ++++ b/net/minecraft/world/entity/monster/piglin/StopHoldingItemIfNoLongerAdmiring.java +@@ -13,7 +_,7 @@ + } + + protected boolean m_6114_(ServerLevel p_35255_, E p_35256_) { +- return !p_35256_.m_21206_().m_41619_() && !p_35256_.m_21206_().m_150930_(Items.f_42740_); ++ return !p_35256_.m_21206_().m_41619_() && !p_35256_.m_21206_().isShield(p_35256_); + } + + protected void m_6735_(ServerLevel p_35258_, E p_35259_, long p_35260_) { diff --git a/patches/minecraft/net/minecraft/world/entity/npc/AbstractVillager.java.patch b/patches/minecraft/net/minecraft/world/entity/npc/AbstractVillager.java.patch new file mode 100644 index 0000000000..4d81607902 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/npc/AbstractVillager.java.patch @@ -0,0 +1,14 @@ +--- a/net/minecraft/world/entity/npc/AbstractVillager.java ++++ b/net/minecraft/world/entity/npc/AbstractVillager.java +@@ -164,9 +_,9 @@ + } + + @Nullable +- public Entity m_5489_(ServerLevel p_35295_) { ++ public Entity changeDimension(ServerLevel p_35295_, net.minecraftforge.common.util.ITeleporter teleporter) { + this.m_7996_(); +- return super.m_5489_(p_35295_); ++ return super.changeDimension(p_35295_, teleporter); + } + + protected void m_7996_() { diff --git a/patches/minecraft/net/minecraft/world/entity/npc/CatSpawner.java.patch b/patches/minecraft/net/minecraft/world/entity/npc/CatSpawner.java.patch new file mode 100644 index 0000000000..7f5072f5b3 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/npc/CatSpawner.java.patch @@ -0,0 +1,13 @@ +--- a/net/minecraft/world/entity/npc/CatSpawner.java ++++ b/net/minecraft/world/entity/npc/CatSpawner.java +@@ -84,8 +_,9 @@ + if (cat == null) { + return 0; + } else { ++ cat.m_20035_(p_35334_, 0.0F, 0.0F); // Fix MC-147659: Some witch huts spawn the incorrect cat ++ if(net.minecraftforge.common.ForgeHooks.canEntitySpawn(cat, p_35335_, p_35334_.m_123341_(), p_35334_.m_123342_(), p_35334_.m_123343_(), null, MobSpawnType.NATURAL) == -1) return 0; + cat.m_6518_(p_35335_, p_35335_.m_6436_(p_35334_), MobSpawnType.NATURAL, (SpawnGroupData)null, (CompoundTag)null); +- cat.m_20035_(p_35334_, 0.0F, 0.0F); + p_35335_.m_47205_(cat); + return 1; + } diff --git a/patches/minecraft/net/minecraft/world/entity/npc/Villager.java.patch b/patches/minecraft/net/minecraft/world/entity/npc/Villager.java.patch new file mode 100644 index 0000000000..dc1af63ed8 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/npc/Villager.java.patch @@ -0,0 +1,38 @@ +--- a/net/minecraft/world/entity/npc/Villager.java ++++ b/net/minecraft/world/entity/npc/Villager.java +@@ -250,7 +_,7 @@ + + public InteractionResult m_6071_(Player p_35472_, InteractionHand p_35473_) { + ItemStack itemstack = p_35472_.m_21120_(p_35473_); +- if (!itemstack.m_150930_(Items.f_42601_) && this.m_6084_() && !this.m_35306_() && !this.m_5803_()) { ++ if (itemstack.m_41720_() != Items.f_42601_ && this.m_6084_() && !this.m_35306_() && !this.m_5803_() && !p_35472_.m_36341_()) { + if (this.m_6162_()) { + this.m_35518_(); + return InteractionResult.m_19078_(this.f_19853_.f_46443_); +@@ -651,7 +_,8 @@ + } + + protected Component m_5677_() { +- return new TranslatableComponent(this.m_6095_().m_20675_() + "." + Registry.f_122869_.m_7981_(this.m_7141_().m_35571_()).m_135815_()); ++ net.minecraft.resources.ResourceLocation profName = this.m_7141_().m_35571_().getRegistryName(); ++ return new TranslatableComponent(this.m_6095_().m_20675_() + '.' + (!"minecraft".equals(profName.m_135827_()) ? profName.m_135827_() + '.' : "") + profName.m_135815_()); + } + + public void m_7822_(byte p_35391_) { +@@ -703,7 +_,7 @@ + } + + public void m_8038_(ServerLevel p_35409_, LightningBolt p_35410_) { +- if (p_35409_.m_46791_() != Difficulty.PEACEFUL) { ++ if (p_35409_.m_46791_() != Difficulty.PEACEFUL && net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, EntityType.f_20495_, (timer) -> {})) { + f_19849_.info("Villager {} was struck by lightning {}.", this, p_35410_); + Witch witch = EntityType.f_20495_.m_20615_(p_35409_); + witch.m_7678_(this.m_20185_(), this.m_20186_(), this.m_20189_(), this.m_146908_(), this.m_146909_()); +@@ -715,6 +_,7 @@ + } + + witch.m_21530_(); ++ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, witch); + p_35409_.m_47205_(witch); + this.m_35524_(); + this.m_146870_(); diff --git a/patches/minecraft/net/minecraft/world/entity/npc/VillagerProfession.java.patch b/patches/minecraft/net/minecraft/world/entity/npc/VillagerProfession.java.patch new file mode 100644 index 0000000000..0346b5d91d --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/npc/VillagerProfession.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/entity/npc/VillagerProfession.java ++++ b/net/minecraft/world/entity/npc/VillagerProfession.java +@@ -12,7 +_,7 @@ + import net.minecraft.world.level.block.Block; + import net.minecraft.world.level.block.Blocks; + +-public class VillagerProfession { ++public class VillagerProfession extends net.minecraftforge.registries.ForgeRegistryEntry { + public static final VillagerProfession f_35585_ = m_35612_("none", PoiType.f_27331_, (SoundEvent)null); + public static final VillagerProfession f_35586_ = m_35612_("armorer", PoiType.f_27332_, SoundEvents.f_12510_); + public static final VillagerProfession f_35587_ = m_35612_("butcher", PoiType.f_27333_, SoundEvents.f_12564_); diff --git a/patches/minecraft/net/minecraft/world/entity/player/Inventory.java.patch b/patches/minecraft/net/minecraft/world/entity/player/Inventory.java.patch new file mode 100644 index 0000000000..35a90b411b --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/player/Inventory.java.patch @@ -0,0 +1,30 @@ +--- a/net/minecraft/world/entity/player/Inventory.java ++++ b/net/minecraft/world/entity/player/Inventory.java +@@ -184,7 +_,8 @@ + int i = p_36049_.m_41613_(); + ItemStack itemstack = this.m_8020_(p_36048_); + if (itemstack.m_41619_()) { +- itemstack = new ItemStack(item, 0); ++ itemstack = p_36049_.m_41777_(); // Forge: Replace Item clone above to preserve item capabilities when picking the item up. ++ itemstack.m_41764_(0); + if (p_36049_.m_41782_()) { + itemstack.m_41751_(p_36049_.m_41783_().m_6426_()); + } +@@ -235,7 +_,7 @@ + } + } + } +- ++ f_35975_.forEach(e -> e.onArmorTick(f_35978_.f_19853_, f_35978_)); + } + + public boolean m_36054_(ItemStack p_36055_) { +@@ -284,6 +_,8 @@ + } catch (Throwable throwable) { + CrashReport crashreport = CrashReport.m_127521_(throwable, "Adding item to inventory"); + CrashReportCategory crashreportcategory = crashreport.m_127514_("Item being added"); ++ crashreportcategory.m_128165_("Registry Name", () -> String.valueOf(p_36042_.m_41720_().getRegistryName())); ++ crashreportcategory.m_128165_("Item Class", () -> p_36042_.m_41720_().getClass().getName()); + crashreportcategory.m_128159_("Item ID", Item.m_41393_(p_36042_.m_41720_())); + crashreportcategory.m_128159_("Item data", p_36042_.m_41773_()); + crashreportcategory.m_128165_("Item name", () -> { diff --git a/patches/minecraft/net/minecraft/world/entity/player/Player.java.patch b/patches/minecraft/net/minecraft/world/entity/player/Player.java.patch new file mode 100644 index 0000000000..ac0d49da81 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/player/Player.java.patch @@ -0,0 +1,404 @@ +--- a/net/minecraft/world/entity/player/Player.java ++++ b/net/minecraft/world/entity/player/Player.java +@@ -111,6 +_,7 @@ + import net.minecraft.world.scores.Team; + + public abstract class Player extends LivingEntity { ++ public static final String PERSISTED_NBT_TAG = "PlayerPersisted"; + public static final String f_150081_ = "OfflinePlayer:"; + public static final int f_150082_ = 16; + public static final int f_150083_ = 20; +@@ -161,6 +_,9 @@ + private final ItemCooldowns f_36087_ = this.m_7478_(); + @Nullable + public FishingHook f_36083_; ++ private final java.util.Collection prefixes = new java.util.LinkedList<>(); ++ private final java.util.Collection suffixes = new java.util.LinkedList<>(); ++ @Nullable private Pose forcedPose; + + public Player(Level p_36114_, BlockPos p_36115_, float p_36116_, GameProfile p_36117_) { + super(EntityType.f_20532_, p_36114_); +@@ -186,7 +_,7 @@ + } + + public static AttributeSupplier.Builder m_36340_() { +- return LivingEntity.m_21183_().m_22268_(Attributes.f_22281_, 1.0D).m_22268_(Attributes.f_22279_, (double)0.1F).m_22266_(Attributes.f_22283_).m_22266_(Attributes.f_22286_); ++ return LivingEntity.m_21183_().m_22268_(Attributes.f_22281_, 1.0D).m_22268_(Attributes.f_22279_, (double) 0.1F).m_22266_(Attributes.f_22283_).m_22266_(Attributes.f_22286_).m_22266_(net.minecraftforge.common.ForgeMod.REACH_DISTANCE.get()).m_22266_(Attributes.f_22282_); + } + + protected void m_8097_() { +@@ -200,6 +_,7 @@ + } + + public void m_8119_() { ++ net.minecraftforge.fmllegacy.hooks.BasicEventHooks.onPlayerPreTick(this); + this.f_19794_ = this.m_5833_(); + if (this.m_5833_()) { + this.f_19861_ = false; +@@ -215,7 +_,7 @@ + this.f_36110_ = 100; + } + +- if (!this.f_19853_.f_46443_ && this.f_19853_.m_46461_()) { ++ if (!this.f_19853_.f_46443_ && !net.minecraftforge.event.ForgeEventFactory.fireSleepingTimeCheck(this, m_21257_())) { + this.m_6145_(false, true); + } + } else if (this.f_36110_ > 0) { +@@ -270,6 +_,7 @@ + this.m_36372_(); + this.f_36087_.m_41518_(); + this.m_7594_(); ++ net.minecraftforge.fmllegacy.hooks.BasicEventHooks.onPlayerPostTick(this); + } + + public boolean m_36341_() { +@@ -345,6 +_,10 @@ + } + + protected void m_7594_() { ++ if(forcedPose != null) { ++ this.m_20124_(forcedPose); ++ return; ++ } + if (this.m_20175_(Pose.SWIMMING)) { + Pose pose; + if (this.m_21255_()) { +@@ -559,6 +_,7 @@ + } + + public void m_6667_(DamageSource p_36152_) { ++ if (net.minecraftforge.common.ForgeHooks.onLivingDeath(this, p_36152_)) return; + super.m_6667_(p_36152_); + this.m_20090_(); + if (!this.m_5833_()) { +@@ -615,7 +_,7 @@ + + @Nullable + public ItemEntity m_36176_(ItemStack p_36177_, boolean p_36178_) { +- return this.m_7197_(p_36177_, false, p_36178_); ++ return net.minecraftforge.common.ForgeHooks.onPlayerTossEvent(this, p_36177_, false); + } + + @Nullable +@@ -653,7 +_,12 @@ + } + } + ++ @Deprecated //Use location sensitive version below + public float m_36281_(BlockState p_36282_) { ++ return getDigSpeed(p_36282_, null); ++ } ++ ++ public float getDigSpeed(BlockState p_36282_, @Nullable BlockPos pos) { + float f = this.f_36093_.m_36020_(p_36282_); + if (f > 1.0F) { + int i = EnchantmentHelper.m_44926_(this); +@@ -695,11 +_,12 @@ + f /= 5.0F; + } + ++ f = net.minecraftforge.event.ForgeEventFactory.getBreakSpeed(this, p_36282_, f, pos); + return f; + } + + public boolean m_36298_(BlockState p_36299_) { +- return !p_36299_.m_60834_() || this.f_36093_.m_36056_().m_41735_(p_36299_); ++ return net.minecraftforge.event.ForgeEventFactory.doPlayerHarvestCheck(this, p_36299_, !p_36299_.m_60834_() || this.f_36093_.m_36056_().m_41735_(p_36299_)); + } + + public void m_7378_(CompoundTag p_36215_) { +@@ -776,6 +_,7 @@ + } + + public boolean m_6469_(DamageSource p_36154_, float p_36155_) { ++ if (!net.minecraftforge.common.ForgeHooks.onPlayerAttack(this, p_36154_, p_36155_)) return false; + if (this.m_6673_(p_36154_)) { + return false; + } else if (this.f_36077_.f_35934_ && !p_36154_.m_19378_()) { +@@ -807,7 +_,7 @@ + + protected void m_6728_(LivingEntity p_36295_) { + super.m_6728_(p_36295_); +- if (p_36295_.m_21205_().m_41720_() instanceof AxeItem) { ++ if (p_36295_.m_21205_().canDisableShield(this.f_20935_, this, p_36295_)) { + this.m_36384_(true); + } + +@@ -836,7 +_,7 @@ + } + + protected void m_7909_(float p_36383_) { +- if (this.f_20935_.m_150930_(Items.f_42740_)) { ++ if (this.f_20935_.isShield(this)) { + if (!this.f_19853_.f_46443_) { + this.m_36246_(Stats.f_12982_.m_12902_(this.f_20935_.m_41720_())); + } +@@ -846,6 +_,7 @@ + InteractionHand interactionhand = this.m_7655_(); + this.f_20935_.m_41622_(i, this, (p_36149_) -> { + p_36149_.m_21190_(interactionhand); ++ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this, this.f_20935_, interactionhand); + }); + if (this.f_20935_.m_41619_()) { + if (interactionhand == InteractionHand.MAIN_HAND) { +@@ -864,10 +_,13 @@ + + protected void m_6475_(DamageSource p_36312_, float p_36313_) { + if (!this.m_6673_(p_36312_)) { ++ p_36313_ = net.minecraftforge.common.ForgeHooks.onLivingHurt(this, p_36312_, p_36313_); ++ if (p_36313_ <= 0) return; + p_36313_ = this.m_21161_(p_36312_, p_36313_); + p_36313_ = this.m_6515_(p_36312_, p_36313_); + float f2 = Math.max(p_36313_ - this.m_6103_(), 0.0F); + this.m_7911_(this.m_6103_() - (p_36313_ - f2)); ++ f2 = net.minecraftforge.common.ForgeHooks.onLivingDamage(this, p_36312_, f2); + float f = p_36313_ - f2; + if (f > 0.0F && f < 3.4028235E37F) { + this.m_36222_(Stats.f_12933_, Math.round(f * 10.0F)); +@@ -876,8 +_,8 @@ + if (f2 != 0.0F) { + this.m_36399_(p_36312_.m_19377_()); + float f1 = this.m_21223_(); +- this.m_21153_(this.m_21223_() - f2); + this.m_21231_().m_19289_(p_36312_, f1, f2); ++ this.m_21153_(f1 - f2); // Forge: moved to fix MC-121048 + if (f2 < 3.4028235E37F) { + this.m_36222_(Stats.f_12931_, Math.round(f2 * 10.0F)); + } +@@ -926,6 +_,8 @@ + + return InteractionResult.PASS; + } else { ++ InteractionResult cancelResult = net.minecraftforge.common.ForgeHooks.onInteractEntity(this, p_36158_, p_36159_); ++ if (cancelResult != null) return cancelResult; + ItemStack itemstack = this.m_21120_(p_36159_); + ItemStack itemstack1 = itemstack.m_41777_(); + InteractionResult interactionresult = p_36158_.m_6096_(this, p_36159_); +@@ -934,6 +_,9 @@ + itemstack.m_41764_(itemstack1.m_41613_()); + } + ++ if (!this.f_36077_.f_35937_ && itemstack.m_41619_()) { ++ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this, itemstack1, p_36159_); ++ } + return interactionresult; + } else { + if (!itemstack.m_41619_() && p_36158_ instanceof LivingEntity) { +@@ -944,6 +_,7 @@ + InteractionResult interactionresult1 = itemstack.m_41647_(this, (LivingEntity)p_36158_, p_36159_); + if (interactionresult1.m_19077_()) { + if (itemstack.m_41619_() && !this.f_36077_.f_35937_) { ++ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this, itemstack1, p_36159_); + this.m_21008_(p_36159_, ItemStack.f_41583_); + } + +@@ -1028,6 +_,7 @@ + } + + public void m_5706_(Entity p_36347_) { ++ if (!net.minecraftforge.common.ForgeHooks.onPlayerAttackTarget(this, p_36347_)) return; + if (p_36347_.m_6097_()) { + if (!p_36347_.m_7313_(this)) { + float f = (float)this.m_21133_(Attributes.f_22281_); +@@ -1045,7 +_,7 @@ + if (f > 0.0F || f1 > 0.0F) { + boolean flag = f2 > 0.9F; + boolean flag1 = false; +- int i = 0; ++ float i = (float)this.m_21133_(Attributes.f_22282_); // Forge: Initialize this value to the attack knockback attribute of the player, which is by default 0 + i = i + EnchantmentHelper.m_44894_(this); + if (this.m_20142_() && flag) { + this.f_19853_.m_6263_((Player)null, this.m_20185_(), this.m_20186_(), this.m_20189_(), SoundEvents.f_12314_, this.m_5720_(), 1.0F, 1.0F); +@@ -1055,8 +_,10 @@ + + boolean flag2 = flag && this.f_19789_ > 0.0F && !this.f_19861_ && !this.m_6147_() && !this.m_20069_() && !this.m_21023_(MobEffects.f_19610_) && !this.m_20159_() && p_36347_ instanceof LivingEntity; + flag2 = flag2 && !this.m_20142_(); ++ net.minecraftforge.event.entity.player.CriticalHitEvent hitResult = net.minecraftforge.common.ForgeHooks.getCriticalHit(this, p_36347_, flag2, flag2 ? 1.5F : 1.0F); ++ flag2 = hitResult != null; + if (flag2) { +- f *= 1.5F; ++ f *= hitResult.getDamageModifier(); + } + + f = f + f1; +@@ -1139,13 +_,15 @@ + EnchantmentHelper.m_44896_(this, p_36347_); + ItemStack itemstack1 = this.m_21205_(); + Entity entity = p_36347_; +- if (p_36347_ instanceof EnderDragonPart) { +- entity = ((EnderDragonPart)p_36347_).f_31010_; ++ if (p_36347_ instanceof net.minecraftforge.entity.PartEntity) { ++ entity = ((net.minecraftforge.entity.PartEntity) p_36347_).getParent(); + } + + if (!this.f_19853_.f_46443_ && !itemstack1.m_41619_() && entity instanceof LivingEntity) { ++ ItemStack copy = itemstack1.m_41777_(); + itemstack1.m_41640_((LivingEntity)entity, this); + if (itemstack1.m_41619_()) { ++ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this, copy, InteractionHand.MAIN_HAND); + this.m_21008_(InteractionHand.MAIN_HAND, ItemStack.f_41583_); + } + } +@@ -1187,7 +_,7 @@ + } + + if (this.f_19796_.nextFloat() < f) { +- this.m_36335_().m_41524_(Items.f_42740_, 100); ++ this.m_36335_().m_41524_(this.m_21211_().m_41720_(), 100); + this.m_5810_(); + this.f_19853_.m_7605_(this, (byte)30); + } +@@ -1212,8 +_,9 @@ + public void m_7583_() { + } + +- public void m_142687_(Entity.RemovalReason p_150097_) { +- super.m_142687_(p_150097_); ++ @Override ++ public void remove(boolean keepData) { ++ super.remove(keepData); + this.f_36095_.m_6877_(this); + if (this.f_36096_ != null) { + this.f_36096_.m_6877_(this); +@@ -1247,6 +_,7 @@ + } + + public void m_6145_(boolean p_36226_, boolean p_36227_) { ++ net.minecraftforge.event.ForgeEventFactory.onPlayerWakeup(this, p_36226_, p_36227_); + super.m_5796_(); + if (this.f_19853_ instanceof ServerLevel && p_36227_) { + ((ServerLevel)this.f_19853_).m_8878_(); +@@ -1272,7 +_,7 @@ + } else if (block instanceof BedBlock && BedBlock.m_49488_(p_36131_)) { + return BedBlock.m_49458_(EntityType.f_20532_, p_36131_, p_36132_, p_36133_); + } else if (!p_36134_) { +- return Optional.empty(); ++ return blockstate.getRespawnPosition(EntityType.f_20532_, p_36131_, p_36132_, p_36133_, null); + } else { + boolean flag = block.m_5568_(); + boolean flag1 = p_36131_.m_8055_(p_36132_.m_7494_()).m_60734_().m_5568_(); +@@ -1452,6 +_,7 @@ + + public boolean m_142535_(float p_150093_, float p_150094_, DamageSource p_150095_) { + if (this.f_36077_.f_35936_) { ++ net.minecraftforge.event.ForgeEventFactory.onPlayerFall(this, p_150093_, p_150093_); + return false; + } else { + if (p_150093_ >= 2.0F) { +@@ -1465,7 +_,7 @@ + public boolean m_36319_() { + if (!this.f_19861_ && !this.m_21255_() && !this.m_20069_() && !this.m_21023_(MobEffects.f_19620_)) { + ItemStack itemstack = this.m_6844_(EquipmentSlot.CHEST); +- if (itemstack.m_150930_(Items.f_42741_) && ElytraItem.m_41140_(itemstack)) { ++ if (itemstack.canElytraFly(this)) { + this.m_36320_(); + return true; + } +@@ -1506,6 +_,10 @@ + } + + public void m_6756_(int p_36291_) { ++ net.minecraftforge.event.entity.player.PlayerXpEvent.XpChange event = new net.minecraftforge.event.entity.player.PlayerXpEvent.XpChange(this, p_36291_); ++ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) return; ++ p_36291_ = event.getAmount(); ++ + 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); +@@ -1534,7 +_,7 @@ + } + + public void m_7408_(ItemStack p_36172_, int p_36173_) { +- this.f_36078_ -= p_36173_; ++ m_6749_(-p_36173_); + if (this.f_36078_ < 0) { + this.f_36078_ = 0; + this.f_36080_ = 0.0F; +@@ -1545,6 +_,10 @@ + } + + public void m_6749_(int p_36276_) { ++ net.minecraftforge.event.entity.player.PlayerXpEvent.LevelChange event = new net.minecraftforge.event.entity.player.PlayerXpEvent.LevelChange(this, p_36276_); ++ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) return; ++ p_36276_ = event.getLevels(); ++ + this.f_36078_ += p_36276_; + if (this.f_36078_ < 0) { + this.f_36078_ = 0; +@@ -1732,7 +_,11 @@ + } + + public Component m_5446_() { +- MutableComponent mutablecomponent = PlayerTeam.m_83348_(this.m_5647_(), this.m_7755_()); ++ if (this.displayname == null) this.displayname = net.minecraftforge.event.ForgeEventFactory.getPlayerDisplayName(this, this.m_7755_()); ++ MutableComponent mutablecomponent = new TextComponent(""); ++ mutablecomponent = prefixes.stream().reduce(mutablecomponent, MutableComponent::m_7220_); ++ mutablecomponent = mutablecomponent.m_7220_(PlayerTeam.m_83348_(this.m_5647_(), this.displayname)); ++ mutablecomponent = suffixes.stream().reduce(mutablecomponent, MutableComponent::m_7220_); + return this.m_36218_(mutablecomponent); + } + +@@ -1978,5 +_,63 @@ + public Component m_36423_() { + return this.f_36413_; + } ++ } ++ ++ // =========== FORGE START ==============// ++ public Collection getPrefixes() { ++ return this.prefixes; ++ } ++ ++ public Collection getSuffixes() { ++ return this.suffixes; ++ } ++ ++ private Component displayname = null; ++ /** ++ * Force the displayed name to refresh, by firing {@link net.minecraftforge.event.entity.player.PlayerEvent.NameFormat}, using the real player name as event parameter. ++ */ ++ public void refreshDisplayName() { ++ this.displayname = net.minecraftforge.event.ForgeEventFactory.getPlayerDisplayName(this, this.m_7755_()); ++ } ++ ++ private final net.minecraftforge.common.util.LazyOptional ++ playerMainHandler = net.minecraftforge.common.util.LazyOptional.of( ++ () -> new net.minecraftforge.items.wrapper.PlayerMainInvWrapper(f_36093_)); ++ ++ private final net.minecraftforge.common.util.LazyOptional ++ playerEquipmentHandler = net.minecraftforge.common.util.LazyOptional.of( ++ () -> new net.minecraftforge.items.wrapper.CombinedInvWrapper( ++ new net.minecraftforge.items.wrapper.PlayerArmorInvWrapper(f_36093_), ++ new net.minecraftforge.items.wrapper.PlayerOffhandInvWrapper(f_36093_))); ++ ++ private final net.minecraftforge.common.util.LazyOptional ++ playerJoinedHandler = net.minecraftforge.common.util.LazyOptional.of( ++ () -> new net.minecraftforge.items.wrapper.PlayerInvWrapper(f_36093_)); ++ ++ @Override ++ public net.minecraftforge.common.util.LazyOptional getCapability(net.minecraftforge.common.capabilities.Capability capability, @Nullable Direction facing) { ++ if (this.m_6084_() && capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { ++ if (facing == null) return playerJoinedHandler.cast(); ++ else if (facing.m_122434_().m_122478_()) return playerMainHandler.cast(); ++ else if (facing.m_122434_().m_122479_()) return playerEquipmentHandler.cast(); ++ } ++ return super.getCapability(capability, facing); ++ } ++ ++ /** ++ * Force a pose for the player. If set, the vanilla pose determination and clearance check is skipped. Make sure the pose is clear yourself (e.g. in PlayerTick). ++ * This has to be set just once, do not set it every tick. ++ * Make sure to clear (null) the pose if not required anymore and only use if necessary. ++ */ ++ public void setForcedPose(@Nullable Pose pose) { ++ this.forcedPose = pose; ++ } ++ ++ /** ++ * @return The forced pose if set, null otherwise ++ */ ++ @Nullable ++ public Pose getForcedPose() { ++ return this.forcedPose; + } + } diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/AbstractArrow.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/AbstractArrow.java.patch new file mode 100644 index 0000000000..9fcf1d8f6e --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/projectile/AbstractArrow.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/entity/projectile/AbstractArrow.java ++++ b/net/minecraft/world/entity/projectile/AbstractArrow.java +@@ -184,7 +_,7 @@ + } + } + +- if (hitresult != null && !flag) { ++ if (hitresult != null && hitresult.m_6662_() != HitResult.Type.MISS && !flag && !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, hitresult)) { + this.m_6532_(hitresult); + this.f_19812_ = true; + } diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java.patch new file mode 100644 index 0000000000..68286cff68 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java ++++ b/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java +@@ -64,7 +_,7 @@ + } + + HitResult hitresult = ProjectileUtil.m_37294_(this, this::m_5603_); +- if (hitresult.m_6662_() != HitResult.Type.MISS) { ++ if (hitresult.m_6662_() != HitResult.Type.MISS && !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, hitresult)) { + this.m_6532_(hitresult); + } + diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch new file mode 100644 index 0000000000..4e693e9ffe --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch @@ -0,0 +1,16 @@ +--- a/net/minecraft/world/entity/projectile/FireworkRocketEntity.java ++++ b/net/minecraft/world/entity/projectile/FireworkRocketEntity.java +@@ -147,6 +_,13 @@ + + } + ++ @Override ++ protected void m_6532_(HitResult result) { ++ if (result.m_6662_() == HitResult.Type.MISS || !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, result)) { ++ super.m_6532_(result); ++ } ++ } ++ + private void m_37080_() { + this.f_19853_.m_7605_(this, (byte)17); + this.m_146852_(GameEvent.f_157812_, this.m_37282_()); diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/FishingHook.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/FishingHook.java.patch new file mode 100644 index 0000000000..9beb6ca21f --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/projectile/FishingHook.java.patch @@ -0,0 +1,75 @@ +--- a/net/minecraft/world/entity/projectile/FishingHook.java ++++ b/net/minecraft/world/entity/projectile/FishingHook.java +@@ -237,7 +_,7 @@ + + private void m_37171_() { + HitResult hitresult = ProjectileUtil.m_37294_(this, this::m_5603_); +- this.m_6532_(hitresult); ++ if (hitresult.m_6662_() == HitResult.Type.MISS || !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, hitresult)) this.m_6532_(hitresult); + } + + protected boolean m_5603_(Entity p_37135_) { +@@ -292,7 +_,7 @@ + double d1 = (double)((float)Mth.m_14107_(this.m_20186_()) + 1.0F); + double d2 = this.m_20189_() + (double)(f2 * (float)this.f_37091_ * 0.1F); + BlockState blockstate = serverlevel.m_8055_(new BlockPos(d0, d1 - 1.0D, d2)); +- if (blockstate.m_60713_(Blocks.f_49990_)) { ++ if (serverlevel.m_8055_(new BlockPos((int)d0, (int)d1 - 1, (int)d2)).m_60767_() == net.minecraft.world.level.material.Material.f_76305_) { + if (this.f_19796_.nextFloat() < 0.15F) { + serverlevel.m_8767_(ParticleTypes.f_123795_, d0, d1 - (double)0.1F, d2, 1, (double)f1, 0.1D, (double)f2, 0.0D); + } +@@ -328,7 +_,7 @@ + double d5 = (double)((float)Mth.m_14107_(this.m_20186_()) + 1.0F); + double d6 = this.m_20189_() + (double)(Mth.m_14089_(f6) * f7 * 0.1F); + BlockState blockstate1 = serverlevel.m_8055_(new BlockPos(d4, d5 - 1.0D, d6)); +- if (blockstate1.m_60713_(Blocks.f_49990_)) { ++ if (serverlevel.m_8055_(new BlockPos(d4, d5 - 1.0D, d6)).m_60767_() == net.minecraft.world.level.material.Material.f_76305_) { + serverlevel.m_8767_(ParticleTypes.f_123769_, d4, d5, d6, 2 + this.f_19796_.nextInt(2), (double)0.1F, 0.0D, (double)0.1F, 0.0D); + } + } +@@ -399,6 +_,7 @@ + Player player = this.m_37168_(); + if (!this.f_19853_.f_46443_ && player != null && !this.m_37136_(player)) { + int i = 0; ++ net.minecraftforge.event.entity.player.ItemFishedEvent event = null; + if (this.f_37094_ != null) { + this.m_150155_(this.f_37094_); + CriteriaTriggers.f_10553_.m_40416_((ServerPlayer)player, p_37157_, this, Collections.emptyList()); +@@ -406,8 +_,15 @@ + i = this.f_37094_ instanceof ItemEntity ? 3 : 5; + } else if (this.f_37089_ > 0) { + LootContext.Builder lootcontext$builder = (new LootContext.Builder((ServerLevel)this.f_19853_)).m_78972_(LootContextParams.f_81460_, this.m_20182_()).m_78972_(LootContextParams.f_81463_, p_37157_).m_78972_(LootContextParams.f_81455_, this).m_78977_(this.f_19796_).m_78963_((float)this.f_37096_ + player.m_36336_()); ++ lootcontext$builder.m_78972_(LootContextParams.f_81458_, this.m_37282_()).m_78972_(LootContextParams.f_81455_, this); + LootTable loottable = this.f_19853_.m_142572_().m_129898_().m_79217_(BuiltInLootTables.f_78720_); + List list = loottable.m_79129_(lootcontext$builder.m_78975_(LootContextParamSets.f_81414_)); ++ event = new net.minecraftforge.event.entity.player.ItemFishedEvent(list, this.f_19861_ ? 2 : 1, this); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); ++ if (event.isCanceled()) { ++ this.remove(false); ++ return event.getRodDamage(); ++ } + CriteriaTriggers.f_10553_.m_40416_((ServerPlayer)player, p_37157_, this, list); + + for(ItemStack itemstack : list) { +@@ -432,7 +_,7 @@ + } + + this.m_146870_(); +- return i; ++ return event == null ? i : event.getRodDamage(); + } else { + return 0; + } +@@ -470,6 +_,12 @@ + public void m_5602_(@Nullable Entity p_150154_) { + super.m_5602_(p_150154_); + this.m_150147_(this); ++ } ++ ++ @Override ++ public void remove(boolean keepData) { ++ super.remove(keepData); ++ m_150147_(null); + } + + private void m_150147_(@Nullable FishingHook p_150148_) { diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/LargeFireball.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/LargeFireball.java.patch new file mode 100644 index 0000000000..d8e1fbe09d --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/projectile/LargeFireball.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/entity/projectile/LargeFireball.java ++++ b/net/minecraft/world/entity/projectile/LargeFireball.java +@@ -26,7 +_,7 @@ + protected void m_6532_(HitResult p_37218_) { + super.m_6532_(p_37218_); + if (!this.f_19853_.f_46443_) { +- boolean flag = this.f_19853_.m_46469_().m_46207_(GameRules.f_46132_); ++ boolean flag = net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_19853_, this.m_37282_()); + this.f_19853_.m_46518_((Entity)null, this.m_20185_(), this.m_20186_(), this.m_20189_(), (float)this.f_37197_, flag, flag ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.NONE); + this.m_146870_(); + } diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/LlamaSpit.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/LlamaSpit.java.patch new file mode 100644 index 0000000000..cd74a985e3 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/projectile/LlamaSpit.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/world/entity/projectile/LlamaSpit.java ++++ b/net/minecraft/world/entity/projectile/LlamaSpit.java +@@ -30,6 +_,7 @@ + super.m_8119_(); + Vec3 vec3 = this.m_20184_(); + HitResult hitresult = ProjectileUtil.m_37294_(this, this::m_5603_); ++ if (hitresult.m_6662_() != HitResult.Type.MISS && !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, hitresult)) + this.m_6532_(hitresult); + double d0 = this.m_20185_() + vec3.f_82479_; + double d1 = this.m_20186_() + vec3.f_82480_; diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/Projectile.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/Projectile.java.patch new file mode 100644 index 0000000000..0290dfd3be --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/projectile/Projectile.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/entity/projectile/Projectile.java ++++ b/net/minecraft/world/entity/projectile/Projectile.java +@@ -211,7 +_,7 @@ + if (entity instanceof Player) { + return entity.m_142265_(p_150167_, p_150168_); + } else { +- return entity == null || p_150167_.m_46469_().m_46207_(GameRules.f_46132_); ++ return entity == null || net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(p_150167_, entity); + } + } + } diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/ProjectileUtil.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/ProjectileUtil.java.patch new file mode 100644 index 0000000000..ce834c7c77 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/projectile/ProjectileUtil.java.patch @@ -0,0 +1,25 @@ +--- a/net/minecraft/world/entity/projectile/ProjectileUtil.java ++++ b/net/minecraft/world/entity/projectile/ProjectileUtil.java +@@ -57,7 +_,7 @@ + Vec3 vec31 = optional.get(); + double d1 = p_37289_.m_82557_(vec31); + if (d1 < d0 || d0 == 0.0D) { +- if (entity1.m_20201_() == p_37288_.m_20201_()) { ++ if (entity1.m_20201_() == p_37288_.m_20201_() && !entity1.canRiderInteract()) { + if (d0 == 0.0D) { + entity = entity1; + vec3 = vec31; +@@ -127,8 +_,13 @@ + } + } + ++ @Deprecated // Forge: Use the version below that takes in a Predicate instead of an Item + public static InteractionHand m_37297_(LivingEntity p_37298_, Item p_37299_) { + return p_37298_.m_21205_().m_150930_(p_37299_) ? InteractionHand.MAIN_HAND : InteractionHand.OFF_HAND; ++ } ++ ++ public static InteractionHand getWeaponHoldingHand(LivingEntity livingEntity, Predicate itemPredicate) { ++ return itemPredicate.test(livingEntity.m_21205_().m_41720_()) ? InteractionHand.MAIN_HAND : InteractionHand.OFF_HAND; + } + + public static AbstractArrow m_37300_(LivingEntity p_37301_, ItemStack p_37302_, float p_37303_) { diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch new file mode 100644 index 0000000000..b6847b227b --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/entity/projectile/ShulkerBullet.java ++++ b/net/minecraft/world/entity/projectile/ShulkerBullet.java +@@ -211,7 +_,7 @@ + } + + HitResult hitresult = ProjectileUtil.m_37294_(this, this::m_5603_); +- if (hitresult.m_6662_() != HitResult.Type.MISS) { ++ if (hitresult.m_6662_() != HitResult.Type.MISS && !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, hitresult)) { + this.m_6532_(hitresult); + } + } diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/SmallFireball.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/SmallFireball.java.patch new file mode 100644 index 0000000000..d9b83113c2 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/projectile/SmallFireball.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/entity/projectile/SmallFireball.java ++++ b/net/minecraft/world/entity/projectile/SmallFireball.java +@@ -49,7 +_,7 @@ + super.m_8060_(p_37384_); + if (!this.f_19853_.f_46443_) { + Entity entity = this.m_37282_(); +- if (!(entity instanceof Mob) || this.f_19853_.m_46469_().m_46207_(GameRules.f_46132_)) { ++ if (!(entity instanceof Mob) || net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_19853_, this)) { + BlockPos blockpos = p_37384_.m_82425_().m_142300_(p_37384_.m_82434_()); + if (this.f_19853_.m_46859_(blockpos)) { + this.f_19853_.m_46597_(blockpos, BaseFireBlock.m_49245_(this.f_19853_, blockpos)); diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/ThrowableProjectile.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/ThrowableProjectile.java.patch new file mode 100644 index 0000000000..7fdec6f153 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/projectile/ThrowableProjectile.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/entity/projectile/ThrowableProjectile.java ++++ b/net/minecraft/world/entity/projectile/ThrowableProjectile.java +@@ -58,7 +_,7 @@ + } + } + +- if (hitresult.m_6662_() != HitResult.Type.MISS && !flag) { ++ if (hitresult.m_6662_() != HitResult.Type.MISS && !flag && !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, hitresult)) { + this.m_6532_(hitresult); + } + diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch new file mode 100644 index 0000000000..cbe04f54db --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch @@ -0,0 +1,38 @@ +--- a/net/minecraft/world/entity/projectile/ThrownEnderpearl.java ++++ b/net/minecraft/world/entity/projectile/ThrownEnderpearl.java +@@ -47,6 +_,8 @@ + if (entity instanceof ServerPlayer) { + ServerPlayer serverplayer = (ServerPlayer)entity; + if (serverplayer.f_8906_.m_6198_().m_129536_() && serverplayer.f_19853_ == this.f_19853_ && !serverplayer.m_5803_()) { ++ net.minecraftforge.event.entity.EntityTeleportEvent.EnderPearl event = net.minecraftforge.event.ForgeEventFactory.onEnderPearlLand(serverplayer, this.m_20185_(), this.m_20186_(), this.m_20189_(), this, 5.0F); ++ if (!event.isCanceled()) { // Don't indent to lower patch size + if (this.f_19796_.nextFloat() < 0.05F && this.f_19853_.m_46469_().m_46207_(GameRules.f_46134_)) { + Endermite endermite = EntityType.f_20567_.m_20615_(this.f_19853_); + endermite.m_7678_(entity.m_20185_(), entity.m_20186_(), entity.m_20189_(), entity.m_146908_(), entity.m_146909_()); +@@ -59,8 +_,10 @@ + entity.m_6021_(this.m_20185_(), this.m_20186_(), this.m_20189_()); + } + ++ entity.m_6021_(event.getTargetX(), event.getTargetY(), event.getTargetZ()); + entity.f_19789_ = 0.0F; +- entity.m_6469_(DamageSource.f_19315_, 5.0F); ++ entity.m_6469_(DamageSource.f_19315_, event.getAttackDamage()); ++ } //Forge: End + } + } else if (entity != null) { + entity.m_6021_(this.m_20185_(), this.m_20186_(), this.m_20189_()); +@@ -83,12 +_,12 @@ + } + + @Nullable +- public Entity m_5489_(ServerLevel p_37506_) { ++ public Entity changeDimension(ServerLevel p_37506_, net.minecraftforge.common.util.ITeleporter teleporter) { + Entity entity = this.m_37282_(); + if (entity != null && entity.f_19853_.m_46472_() != p_37506_.m_46472_()) { + this.m_5602_((Entity)null); + } + +- return super.m_5489_(p_37506_); ++ return super.changeDimension(p_37506_, teleporter); + } + } diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/WitherSkull.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/WitherSkull.java.patch new file mode 100644 index 0000000000..3885f6a8b3 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/projectile/WitherSkull.java.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/world/entity/projectile/WitherSkull.java ++++ b/net/minecraft/world/entity/projectile/WitherSkull.java +@@ -41,7 +_,7 @@ + } + + public float m_7077_(Explosion p_37619_, BlockGetter p_37620_, BlockPos p_37621_, BlockState p_37622_, FluidState p_37623_, float p_37624_) { +- return this.m_37635_() && WitherBoss.m_31491_(p_37622_) ? Math.min(0.8F, p_37624_) : p_37624_; ++ return this.m_37635_() && p_37622_.canEntityDestroy(p_37620_, p_37621_, this) ? Math.min(0.8F, p_37624_) : p_37624_; + } + + protected void m_5790_(EntityHitResult p_37626_) { +@@ -83,7 +_,7 @@ + protected void m_6532_(HitResult p_37628_) { + super.m_6532_(p_37628_); + if (!this.f_19853_.f_46443_) { +- Explosion.BlockInteraction explosion$blockinteraction = this.f_19853_.m_46469_().m_46207_(GameRules.f_46132_) ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.NONE; ++ Explosion.BlockInteraction explosion$blockinteraction = net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_19853_, this.m_37282_()) ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.NONE; + this.f_19853_.m_46518_(this, this.m_20185_(), this.m_20186_(), this.m_20189_(), 1.0F, false, explosion$blockinteraction); + this.m_146870_(); + } diff --git a/patches/minecraft/net/minecraft/world/entity/raid/Raid.java.patch b/patches/minecraft/net/minecraft/world/entity/raid/Raid.java.patch new file mode 100644 index 0000000000..4be881557a --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/raid/Raid.java.patch @@ -0,0 +1,32 @@ +--- a/net/minecraft/world/entity/raid/Raid.java ++++ b/net/minecraft/world/entity/raid/Raid.java +@@ -809,7 +_,7 @@ + } + } + +- static enum RaiderType { ++ public static enum RaiderType implements net.minecraftforge.common.IExtensibleEnum { + 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}), +@@ -823,6 +_,20 @@ + private RaiderType(EntityType p_37821_, int[] p_37822_) { + this.f_37814_ = p_37821_; + this.f_37815_ = p_37822_; ++ } ++ ++ /** ++ * The waveCountsIn integer decides how many entities of the EntityType defined in typeIn will spawn in each wave. ++ * For example, one ravager will always spawn in wave 3. ++ */ ++ public static RaiderType create(String name, EntityType typeIn, int[] waveCountsIn) { ++ throw new IllegalStateException("Enum not extended"); ++ } ++ ++ @Override ++ @Deprecated ++ public void init() { ++ f_37813_ = values(); + } + } + } diff --git a/patches/minecraft/net/minecraft/world/entity/schedule/Activity.java.patch b/patches/minecraft/net/minecraft/world/entity/schedule/Activity.java.patch new file mode 100644 index 0000000000..7b6746640e --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/schedule/Activity.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/entity/schedule/Activity.java ++++ b/net/minecraft/world/entity/schedule/Activity.java +@@ -2,7 +_,7 @@ + + import net.minecraft.core.Registry; + +-public class Activity { ++public class Activity extends net.minecraftforge.registries.ForgeRegistryEntry { + public static final Activity f_37978_ = m_37999_("core"); + public static final Activity f_37979_ = m_37999_("idle"); + public static final Activity f_37980_ = m_37999_("work"); diff --git a/patches/minecraft/net/minecraft/world/entity/schedule/Schedule.java.patch b/patches/minecraft/net/minecraft/world/entity/schedule/Schedule.java.patch new file mode 100644 index 0000000000..e7e7f927bc --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/schedule/Schedule.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/entity/schedule/Schedule.java ++++ b/net/minecraft/world/entity/schedule/Schedule.java +@@ -8,7 +_,7 @@ + import java.util.stream.Collectors; + import net.minecraft.core.Registry; + +-public class Schedule { ++public class Schedule extends net.minecraftforge.registries.ForgeRegistryEntry { + public static final int f_150241_ = 2000; + public static final int f_150242_ = 7000; + public static final Schedule f_38012_ = m_38029_("empty").m_38040_(0, Activity.f_37979_).m_38039_(); diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch new file mode 100644 index 0000000000..dfa84dac4f --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch @@ -0,0 +1,279 @@ +--- a/net/minecraft/world/entity/vehicle/AbstractMinecart.java ++++ b/net/minecraft/world/entity/vehicle/AbstractMinecart.java +@@ -46,7 +_,7 @@ + import net.minecraft.world.phys.AABB; + import net.minecraft.world.phys.Vec3; + +-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 @@ + 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_); +@@ -98,6 +_,14 @@ + this.f_19855_ = p_38093_; + this.f_19856_ = p_38094_; + } ++ ++ public net.minecraftforge.common.IMinecartCollisionHandler getCollisionHandler() { ++ return COLLISIONS; ++ } ++ ++ public static void registerCollisionHandler(@Nullable net.minecraftforge.common.IMinecartCollisionHandler handler) { ++ COLLISIONS = handler; ++ } + + 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) { +@@ -133,7 +_,7 @@ + } + + public boolean m_6094_() { +- return true; ++ return canBePushed; + } + + protected Vec3 m_7643_(Direction.Axis p_38132_, BlockUtil.FoundRectangle p_38133_) { +@@ -300,9 +_,9 @@ + + BlockPos blockpos = new BlockPos(k, i, j); + BlockState blockstate = this.f_19853_.m_8055_(blockpos); +- if (BaseRailBlock.m_49416_(blockstate)) { ++ if (canUseRail() && BaseRailBlock.m_49416_(blockstate)) { + this.m_6401_(blockpos, blockstate); +- if (blockstate.m_60713_(Blocks.f_50285_)) { ++ if (blockstate.m_60734_() instanceof PoweredRailBlock && ((PoweredRailBlock) blockstate.m_60734_()).isActivatorRail()) { + this.m_6025_(k, i, j, blockstate.m_61143_(PoweredRailBlock.f_55215_)); + } + } else { +@@ -327,8 +_,11 @@ + } + + this.m_19915_(this.m_146908_(), this.m_146909_()); +- if (this.m_6064_() == AbstractMinecart.Type.RIDEABLE && this.m_20184_().m_165925_() > 0.01D) { +- List list = this.f_19853_.m_6249_(this, this.m_142469_().m_82377_((double)0.2F, 0.0D, (double)0.2F), EntitySelector.m_20421_(this)); ++ AABB box; ++ if (getCollisionHandler() != null) box = getCollisionHandler().getMinecartCollisionBox(this); ++ else box = this.m_142469_().m_82377_(0.2F, 0.0D, 0.2F); ++ if (canBeRidden() && this.m_20184_().m_165925_() > 0.01D) { ++ List list = this.f_19853_.m_6249_(this, box, EntitySelector.m_20421_(this)); + if (!list.isEmpty()) { + for(int l = 0; l < list.size(); ++l) { + Entity entity1 = list.get(l); +@@ -340,7 +_,7 @@ + } + } + } else { +- for(Entity entity : this.f_19853_.m_45933_(this, this.m_142469_().m_82377_((double)0.2F, 0.0D, (double)0.2F))) { ++ for(Entity entity : this.f_19853_.m_45933_(this, box)) { + if (!this.m_20363_(entity) && entity.m_6094_() && entity instanceof AbstractMinecart) { + entity.m_7334_(this); + } +@@ -365,16 +_,23 @@ + } + + protected void m_38163_() { +- double d0 = this.m_7097_(); ++ double d0 = f_19861_ ? this.m_7097_() : getMaxSpeedAirLateral(); + Vec3 vec3 = this.m_20184_(); + this.m_20334_(Mth.m_14008_(vec3.f_82479_, -d0, d0), vec3.f_82480_, Mth.m_14008_(vec3.f_82481_, -d0, d0)); + if (this.f_19861_) { + this.m_20256_(this.m_20184_().m_82490_(0.5D)); + } + ++ if (getMaxSpeedAirVertical() > 0 && m_20184_().f_82480_ > getMaxSpeedAirVertical()) { ++ if(Math.abs(m_20184_().f_82479_) < 0.3f && Math.abs(m_20184_().f_82481_) < 0.3f) ++ m_20256_(new Vec3(m_20184_().f_82479_, 0.15f, m_20184_().f_82481_)); ++ else ++ m_20256_(new Vec3(m_20184_().f_82479_, getMaxSpeedAirVertical(), m_20184_().f_82481_)); ++ } ++ + this.m_6478_(MoverType.SELF, this.m_20184_()); + if (!this.f_19861_) { +- this.m_20256_(this.m_20184_().m_82490_(0.95D)); ++ this.m_20256_(this.m_20184_().m_82490_(getDragAir())); + } + + } +@@ -388,7 +_,8 @@ + d1 = (double)p_38156_.m_123342_(); + boolean flag = false; + boolean flag1 = false; +- if (p_38157_.m_60713_(Blocks.f_50030_)) { ++ BaseRailBlock baserailblock = (BaseRailBlock) p_38157_.m_60734_(); ++ if (baserailblock instanceof PoweredRailBlock && !((PoweredRailBlock) baserailblock).isActivatorRail()) { + flag = p_38157_.m_61143_(PoweredRailBlock.f_55215_); + flag1 = !flag; + } +@@ -399,22 +_,22 @@ + } + + Vec3 vec31 = this.m_20184_(); +- RailShape railshape = p_38157_.m_61143_(((BaseRailBlock)p_38157_.m_60734_()).m_7978_()); ++ RailShape railshape = ((BaseRailBlock)p_38157_.m_60734_()).getRailDirection(p_38157_, this.f_19853_, p_38156_, this); + switch(railshape) { + case ASCENDING_EAST: +- this.m_20256_(vec31.m_82520_(-d3, 0.0D, 0.0D)); ++ this.m_20256_(vec31.m_82520_(-1 * getSlopeAdjustment(), 0.0D, 0.0D)); + ++d1; + break; + case ASCENDING_WEST: +- this.m_20256_(vec31.m_82520_(d3, 0.0D, 0.0D)); ++ this.m_20256_(vec31.m_82520_(getSlopeAdjustment(), 0.0D, 0.0D)); + ++d1; + break; + case ASCENDING_NORTH: +- this.m_20256_(vec31.m_82520_(0.0D, 0.0D, d3)); ++ this.m_20256_(vec31.m_82520_(0.0D, 0.0D, getSlopeAdjustment())); + ++d1; + break; + case ASCENDING_SOUTH: +- this.m_20256_(vec31.m_82520_(0.0D, 0.0D, -d3)); ++ this.m_20256_(vec31.m_82520_(0.0D, 0.0D, -1 * getSlopeAdjustment())); + ++d1; + } + +@@ -445,7 +_,7 @@ + } + } + +- if (flag1) { ++ if (flag1 && shouldDoRailFunctions()) { + double d22 = this.m_20184_().m_165924_(); + if (d22 < 0.03D) { + this.m_20256_(Vec3.f_82478_); +@@ -474,10 +_,7 @@ + d0 = d23 + d4 * d14; + d2 = d10 + d5 * d14; + this.m_6034_(d0, d1, d2); +- double d24 = this.m_20160_() ? 0.75D : 1.0D; +- double d25 = this.m_7097_(); +- vec31 = this.m_20184_(); +- this.m_6478_(MoverType.SELF, new Vec3(Mth.m_14008_(d24 * vec31.f_82479_, -d25, d25), 0.0D, Mth.m_14008_(d24 * vec31.f_82481_, -d25, d25))); ++ this.moveMinecartOnRail(p_38156_); + 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_()) { +@@ -505,7 +_,10 @@ + this.m_20334_(d26 * (double)(j - p_38156_.m_123341_()), vec35.f_82480_, d26 * (double)(i - p_38156_.m_123343_())); + } + +- if (flag) { ++ if (shouldDoRailFunctions()) ++ baserailblock.onMinecartPass(p_38157_, f_19853_, p_38156_, this); ++ ++ if (flag && shouldDoRailFunctions()) { + Vec3 vec36 = this.m_20184_(); + double d27 = vec36.m_165924_(); + if (d27 > 0.01D) { +@@ -565,7 +_,7 @@ + + BlockState blockstate = this.f_19853_.m_8055_(new BlockPos(i, j, k)); + if (BaseRailBlock.m_49416_(blockstate)) { +- RailShape railshape = blockstate.m_61143_(((BaseRailBlock)blockstate.m_60734_()).m_7978_()); ++ RailShape railshape = ((BaseRailBlock)blockstate.m_60734_()).getRailDirection(blockstate, this.f_19853_, new BlockPos(i, j, k), this); + p_38098_ = (double)j; + if (railshape.m_61745_()) { + p_38098_ = (double)(j + 1); +@@ -604,7 +_,7 @@ + + BlockState blockstate = this.f_19853_.m_8055_(new BlockPos(i, j, k)); + if (BaseRailBlock.m_49416_(blockstate)) { +- RailShape railshape = blockstate.m_61143_(((BaseRailBlock)blockstate.m_60734_()).m_7978_()); ++ RailShape railshape = ((BaseRailBlock)blockstate.m_60734_()).getRailDirection(blockstate, this.f_19853_, new BlockPos(i, j, k), this); + Pair pair = m_38125_(railshape); + Vec3i vec3i = pair.getFirst(); + Vec3i vec3i1 = pair.getSecond(); +@@ -666,6 +_,10 @@ + } + + public void m_7334_(Entity p_38165_) { ++ if (getCollisionHandler() != null) { ++ getCollisionHandler().onEntityCollision(this, p_38165_); ++ return; ++ } + if (!this.f_19853_.f_46443_) { + if (!p_38165_.f_19794_ && !this.f_19794_) { + if (!this.m_20363_(p_38165_)) { +@@ -699,11 +_,11 @@ + + Vec3 vec32 = this.m_20184_(); + Vec3 vec33 = p_38165_.m_20184_(); +- if (((AbstractMinecart)p_38165_).m_6064_() == AbstractMinecart.Type.FURNACE && this.m_6064_() != AbstractMinecart.Type.FURNACE) { ++ if (((AbstractMinecart)p_38165_).isPoweredCart() && !this.isPoweredCart()) { + this.m_20256_(vec32.m_82542_(0.2D, 1.0D, 0.2D)); + this.m_5997_(vec33.f_82479_ - d0, 0.0D, vec33.f_82481_ - d1); + p_38165_.m_20256_(vec33.m_82542_(0.95D, 1.0D, 0.95D)); +- } else if (((AbstractMinecart)p_38165_).m_6064_() != AbstractMinecart.Type.FURNACE && this.m_6064_() == AbstractMinecart.Type.FURNACE) { ++ } else if (!((AbstractMinecart)p_38165_).isPoweredCart() && this.isPoweredCart()) { + 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)); +@@ -807,6 +_,42 @@ + return new ClientboundAddEntityPacket(this); + } + ++ // Forge Start ++ private boolean canUseRail = true; ++ @Override public boolean canUseRail() { return canUseRail; } ++ @Override public void setCanUseRail(boolean value) { this.canUseRail = value; } ++ private float currentSpeedCapOnRail = getMaxCartSpeedOnRail(); ++ @Override public float getCurrentCartSpeedCapOnRail() { return currentSpeedCapOnRail; } ++ @Override public void setCurrentCartSpeedCapOnRail(float value) { currentSpeedCapOnRail = Math.min(value, getMaxCartSpeedOnRail()); } ++ private float maxSpeedAirLateral = DEFAULT_MAX_SPEED_AIR_LATERAL; ++ @Override public float getMaxSpeedAirLateral() { return maxSpeedAirLateral; } ++ @Override public void setMaxSpeedAirLateral(float value) { maxSpeedAirLateral = value; } ++ private float maxSpeedAirVertical = DEFAULT_MAX_SPEED_AIR_VERTICAL; ++ @Override public float getMaxSpeedAirVertical() { return maxSpeedAirVertical; } ++ @Override public void setMaxSpeedAirVertical(float value) { maxSpeedAirVertical = value; } ++ private double dragAir = DEFAULT_AIR_DRAG; ++ @Override public double getDragAir() { return dragAir; } ++ @Override public void setDragAir(double value) { dragAir = value; } ++ @Override ++ public double getMaxSpeedWithRail() { //Non-default because getMaximumSpeed is protected ++ if (!canUseRail()) return m_7097_(); ++ BlockPos pos = this.getCurrentRailPosition(); ++ BlockState state = this.f_19853_.m_8055_(pos); ++ if (!state.m_60620_(BlockTags.f_13034_)) return m_7097_(); ++ ++ float railMaxSpeed = ((BaseRailBlock)state.m_60734_()).getRailMaxSpeed(state, this.f_19853_, pos, this); ++ return Math.min(railMaxSpeed, getCurrentCartSpeedCapOnRail()); ++ } ++ @Override ++ public void moveMinecartOnRail(BlockPos pos) { //Non-default because getMaximumSpeed is protected ++ AbstractMinecart mc = this; ++ double d24 = mc.m_20160_() ? 0.75D : 1.0D; ++ double d25 = mc.getMaxSpeedWithRail(); ++ Vec3 vec3d1 = mc.m_20184_(); ++ mc.m_6478_(MoverType.SELF, new Vec3(Mth.m_14008_(d24 * vec3d1.f_82479_, -d25, d25), 0.0D, Mth.m_14008_(d24 * vec3d1.f_82481_, -d25, d25))); ++ } ++ // Forge end ++ + public ItemStack m_142340_() { + Item item; + switch(this.m_6064_()) { +@@ -828,7 +_,8 @@ + default: + item = Items.f_42449_; + } +- ++ // TODO, should this be above? ++ if (item == null) return getCartItem(); + return new ItemStack(item); + } + diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java.patch new file mode 100644 index 0000000000..2a1e4e5678 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java.patch @@ -0,0 +1,70 @@ +--- a/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java ++++ b/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java +@@ -122,12 +_,18 @@ + } + } + +- public void m_142687_(Entity.RemovalReason p_150255_) { +- if (!this.f_19853_.f_46443_ && p_150255_.m_146965_()) { ++ public Entity changeDimension(ServerLevel p_38246_, net.minecraftforge.common.util.ITeleporter teleporter) { ++ this.dropContentsWhenDead(false); ++ return super.changeDimension(p_38246_, teleporter); ++ } ++ ++ @Override ++ public void remove(boolean keepData) { ++ if (!this.f_19853_.f_46443_ && this.dropContents) { + Containers.m_18998_(this.f_19853_, this, this); + } + +- super.m_142687_(p_150255_); ++ super.remove(keepData); + } + + protected void m_7380_(CompoundTag p_38248_) { +@@ -156,6 +_,8 @@ + } + + public InteractionResult m_6096_(Player p_38232_, InteractionHand p_38233_) { ++ InteractionResult ret = super.m_6096_(p_38232_, p_38233_); ++ if (ret.m_19077_()) return ret; + p_38232_.m_5893_(this); + if (!p_38232_.f_19853_.f_46443_) { + this.m_146852_(GameEvent.f_157803_, p_38232_); +@@ -189,6 +_,8 @@ + + this.f_38204_ = null; + LootContext.Builder lootcontext$builder = (new LootContext.Builder((ServerLevel)this.f_19853_)).m_78972_(LootContextParams.f_81460_, this.m_20182_()).m_78965_(this.f_38205_); ++ // Forge: add this entity to loot context, however, currently Vanilla uses 'this' for the player creating the chests. So we take over 'killer_entity' for this. ++ lootcontext$builder.m_78972_(LootContextParams.f_81458_, this); + if (p_38255_ != null) { + lootcontext$builder.m_78963_(p_38255_.m_36336_()).m_78972_(LootContextParams.f_81455_, p_38255_); + } +@@ -219,4 +_,27 @@ + } + + protected abstract AbstractContainerMenu m_7402_(int p_38222_, Inventory p_38223_); ++ ++ // Forge Start ++ ++ private boolean dropContents = this.f_19853_.m_46469_().m_46207_(GameRules.f_46137_); ++ ++ private net.minecraftforge.common.util.LazyOptional itemHandler = net.minecraftforge.common.util.LazyOptional.of(() -> new net.minecraftforge.items.wrapper.InvWrapper(this)); ++ ++ @Override ++ public net.minecraftforge.common.util.LazyOptional getCapability(net.minecraftforge.common.capabilities.Capability capability, @Nullable net.minecraft.core.Direction facing) { ++ if (this.m_6084_() && capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) ++ return itemHandler.cast(); ++ return super.getCapability(capability, facing); ++ } ++ ++ @Override ++ protected void invalidateCaps() { ++ super.invalidateCaps(); ++ itemHandler.invalidate(); ++ } ++ ++ public void dropContentsWhenDead(boolean value) { ++ this.dropContents = value; ++ } + } diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/Boat.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/Boat.java.patch new file mode 100644 index 0000000000..e14c486000 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/Boat.java.patch @@ -0,0 +1,28 @@ +--- a/net/minecraft/world/entity/vehicle/Boat.java ++++ b/net/minecraft/world/entity/vehicle/Boat.java +@@ -475,7 +_,7 @@ + blockpos$mutableblockpos.m_122178_(l1, k2, i2); + BlockState blockstate = this.f_19853_.m_8055_(blockpos$mutableblockpos); + if (!(blockstate.m_60734_() instanceof WaterlilyBlock) && Shapes.m_83157_(blockstate.m_60812_(this.f_19853_, blockpos$mutableblockpos).m_83216_((double)l1, (double)k2, (double)i2), voxelshape, BooleanOp.f_82689_)) { +- f += blockstate.m_60734_().m_49958_(); ++ f += blockstate.getFriction(this.f_19853_, blockpos$mutableblockpos, this); + ++k1; + } + } +@@ -821,6 +_,16 @@ + + public boolean m_5842_() { + return this.f_38279_ == Boat.Status.UNDER_WATER || this.f_38279_ == Boat.Status.UNDER_FLOWING_WATER; ++ } ++ ++ // Forge: Fix MC-119811 by instantly completing lerp on board ++ @Override ++ protected void m_20348_(Entity passenger) { ++ super.m_20348_(passenger); ++ if (this.m_6109_() && this.f_38267_ > 0) { ++ this.f_38267_ = 0; ++ this.m_19890_(this.f_38268_, this.f_38269_, this.f_38270_, (float)this.f_38271_, (float)this.f_38272_); ++ } + } + + public ItemStack m_142340_() { diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/Minecart.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/Minecart.java.patch new file mode 100644 index 0000000000..39a97c9397 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/Minecart.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/entity/vehicle/Minecart.java ++++ b/net/minecraft/world/entity/vehicle/Minecart.java +@@ -16,6 +_,8 @@ + } + + public InteractionResult m_6096_(Player p_38483_, InteractionHand p_38484_) { ++ InteractionResult ret = super.m_6096_(p_38483_, p_38484_); ++ if (ret.m_19077_()) return ret; + if (p_38483_.m_36341_()) { + return InteractionResult.PASS; + } else if (this.m_20160_()) { diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java.patch new file mode 100644 index 0000000000..87ab95bd17 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java ++++ b/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java +@@ -72,6 +_,8 @@ + } + + public InteractionResult m_6096_(Player p_38522_, InteractionHand p_38523_) { ++ InteractionResult ret = super.m_6096_(p_38522_, p_38523_); ++ if (ret.m_19077_()) return ret; + return this.f_38505_.m_45412_(p_38522_); + } + diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartFurnace.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartFurnace.java.patch new file mode 100644 index 0000000000..ff3e897538 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartFurnace.java.patch @@ -0,0 +1,23 @@ +--- a/net/minecraft/world/entity/vehicle/MinecartFurnace.java ++++ b/net/minecraft/world/entity/vehicle/MinecartFurnace.java +@@ -71,6 +_,11 @@ + return (this.m_20069_() ? 3.0D : 4.0D) / 20.0D; + } + ++ @Override ++ public float getMaxCartSpeedOnRail() { ++ return 0.2f; ++ } ++ + public void m_7617_(DamageSource p_38560_) { + super.m_7617_(p_38560_); + if (!p_38560_.m_19372_() && this.f_19853_.m_46469_().m_46207_(GameRules.f_46137_)) { +@@ -115,6 +_,8 @@ + } + + public InteractionResult m_6096_(Player p_38562_, InteractionHand p_38563_) { ++ InteractionResult ret = super.m_6096_(p_38562_, p_38563_); ++ if (ret.m_19077_()) return ret; + ItemStack itemstack = p_38562_.m_21120_(p_38563_); + if (f_38549_.test(itemstack) && this.f_38548_ + 3600 <= 32000) { + if (!p_38562_.m_150110_().f_35937_) { diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartSpawner.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartSpawner.java.patch new file mode 100644 index 0000000000..ed257982df --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartSpawner.java.patch @@ -0,0 +1,15 @@ +--- a/net/minecraft/world/entity/vehicle/MinecartSpawner.java ++++ b/net/minecraft/world/entity/vehicle/MinecartSpawner.java +@@ -14,6 +_,12 @@ + public void m_142523_(Level p_150342_, BlockPos p_150343_, int p_150344_) { + p_150342_.m_7605_(MinecartSpawner.this, (byte)p_150344_); + } ++ ++ @Override ++ @javax.annotation.Nullable ++ public net.minecraft.world.entity.Entity getSpawnerEntity() { ++ return MinecartSpawner.this; ++ } + }; + private final Runnable f_150333_; + diff --git a/patches/minecraft/net/minecraft/world/food/FoodProperties.java.patch b/patches/minecraft/net/minecraft/world/food/FoodProperties.java.patch new file mode 100644 index 0000000000..aae2b25e88 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/food/FoodProperties.java.patch @@ -0,0 +1,73 @@ +--- a/net/minecraft/world/food/FoodProperties.java ++++ b/net/minecraft/world/food/FoodProperties.java +@@ -11,15 +_,26 @@ + private final boolean f_38725_; + private final boolean f_38726_; + private final boolean f_38727_; +- private final List> f_38728_; +- ++ private final List, Float>> f_38728_; ++ ++ private FoodProperties(FoodProperties.Builder builder) { ++ this.f_38723_ = builder.f_38750_; ++ this.f_38724_ = builder.f_38751_; ++ this.f_38725_ = builder.f_38752_; ++ this.f_38726_ = builder.f_38753_; ++ this.f_38727_ = builder.f_38754_; ++ this.f_38728_ = builder.f_38755_; ++ } ++ ++ // Forge: Use builder method instead ++ @Deprecated + FoodProperties(int p_38730_, float p_38731_, boolean p_38732_, boolean p_38733_, boolean p_38734_, List> p_38735_) { + this.f_38723_ = p_38730_; + this.f_38724_ = p_38731_; + this.f_38725_ = p_38732_; + this.f_38726_ = p_38733_; + this.f_38727_ = p_38734_; +- this.f_38728_ = p_38735_; ++ this.f_38728_ = p_38735_.stream().map(pair -> Pair., Float>of(pair::getFirst, pair.getSecond())).collect(java.util.stream.Collectors.toList()); + } + + public int m_38744_() { +@@ -43,7 +_,7 @@ + } + + public List> m_38749_() { +- return this.f_38728_; ++ return this.f_38728_.stream().map(pair -> Pair.of(pair.getFirst() != null ? pair.getFirst().get() : null, pair.getSecond())).collect(java.util.stream.Collectors.toList()); + } + + public static class Builder { +@@ -52,7 +_,7 @@ + private boolean f_38752_; + private boolean f_38753_; + private boolean f_38754_; +- private final List> f_38755_ = Lists.newArrayList(); ++ private final List, Float>> f_38755_ = Lists.newArrayList(); + + public FoodProperties.Builder m_38760_(int p_38761_) { + this.f_38750_ = p_38761_; +@@ -79,13 +_,20 @@ + return this; + } + ++ public FoodProperties.Builder effect(java.util.function.Supplier effectIn, float probability) { ++ this.f_38755_.add(Pair.of(effectIn, probability)); ++ return this; ++ } ++ ++ // Forge: Use supplier method instead ++ @Deprecated + public FoodProperties.Builder m_38762_(MobEffectInstance p_38763_, float p_38764_) { +- this.f_38755_.add(Pair.of(p_38763_, p_38764_)); ++ this.f_38755_.add(Pair.of(() -> p_38763_, p_38764_)); + return this; + } + + public FoodProperties m_38767_() { +- return new FoodProperties(this.f_38750_, this.f_38751_, this.f_38752_, this.f_38753_, this.f_38754_, this.f_38755_); ++ return new FoodProperties(this); + } + } + } diff --git a/patches/minecraft/net/minecraft/world/gen/DebugChunkGenerator.java.patch b/patches/minecraft/net/minecraft/world/gen/DebugChunkGenerator.java.patch deleted file mode 100644 index 761f130278..0000000000 --- a/patches/minecraft/net/minecraft/world/gen/DebugChunkGenerator.java.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/net/minecraft/world/gen/DebugChunkGenerator.java -+++ b/net/minecraft/world/gen/DebugChunkGenerator.java -@@ -103,4 +_,10 @@ - - return blockstate; - } -+ -+ public static void initValidStates() { -+ field_177464_a = StreamSupport.stream(Registry.field_212618_g.spliterator(), false).flatMap(block -> block.func_176194_O().func_177619_a().stream()).collect(Collectors.toList()); -+ field_177462_b = MathHelper.func_76123_f(MathHelper.func_76129_c(field_177464_a.size())); -+ field_181039_c = MathHelper.func_76123_f((float) (field_177464_a.size() / field_177462_b)); -+ } - } diff --git a/patches/minecraft/net/minecraft/world/gen/FlatGenerationSettings.java.patch b/patches/minecraft/net/minecraft/world/gen/FlatGenerationSettings.java.patch deleted file mode 100644 index c451eb8054..0000000000 --- a/patches/minecraft/net/minecraft/world/gen/FlatGenerationSettings.java.patch +++ /dev/null @@ -1,29 +0,0 @@ ---- a/net/minecraft/world/gen/FlatGenerationSettings.java -+++ b/net/minecraft/world/gen/FlatGenerationSettings.java -@@ -147,8 +_,16 @@ - biomegenerationsettings$builder.func_242513_a(GenerationStage.Decoration.LAKES, Features.field_243790_P); - } - -+ Map, StructureFeature> map = new java.util.HashMap<>(field_202247_j); -+ net.minecraft.util.registry.WorldGenRegistries.field_243654_f.func_201756_e().filter(f -> !map.containsKey(f.field_236268_b_)).forEach(f -> map.put(f.field_236268_b_, f)); - for(Entry, StructureSeparationSettings> entry : this.field_236933_f_.func_236195_a_().entrySet()) { -- biomegenerationsettings$builder.func_242516_a(biomegenerationsettings.func_242491_a(field_202247_j.get(entry.getKey()))); -+ if (!map.containsKey(entry.getKey())) { -+ field_211404_q.error("FORGE: There's no known StructureFeature for {} when preparing the {} flatworld biome." + -+ " The structure will be skipped and may not spawn." + -+ " Please register your StructureFeatures in the WorldGenRegistries!", entry.getKey().func_143025_a(), biome.getRegistryName()); -+ continue; -+ } -+ biomegenerationsettings$builder.func_242516_a(biomegenerationsettings.func_242491_a(map.get(entry.getKey()))); - } - - boolean flag = (!this.field_202245_D || this.field_242867_d.func_230519_c_(biome).equals(Optional.of(Biomes.field_185440_P))) && this.field_236934_k_; -@@ -174,7 +_,7 @@ - } - } - -- return (new Biome.Builder()).func_205415_a(biome.func_201851_b()).func_205419_a(biome.func_201856_r()).func_205421_a(biome.func_185355_j()).func_205420_b(biome.func_185360_m()).func_205414_c(biome.func_242445_k()).func_205417_d(biome.func_76727_i()).func_235097_a_(biome.func_235089_q_()).func_242457_a(biomegenerationsettings$builder.func_242508_a()).func_242458_a(biome.func_242433_b()).func_242455_a(); -+ return (new Biome.Builder()).func_205415_a(biome.func_201851_b()).func_205419_a(biome.func_201856_r()).func_205421_a(biome.func_185355_j()).func_205420_b(biome.func_185360_m()).func_205414_c(biome.func_242445_k()).func_205417_d(biome.func_76727_i()).func_235097_a_(biome.func_235089_q_()).func_242457_a(biomegenerationsettings$builder.func_242508_a()).func_242458_a(biome.func_242433_b()).func_242455_a().setRegistryName(biome.getRegistryName()); - } - - public DimensionStructuresSettings func_236943_d_() { diff --git a/patches/minecraft/net/minecraft/world/gen/NoiseChunkGenerator.java.patch b/patches/minecraft/net/minecraft/world/gen/NoiseChunkGenerator.java.patch deleted file mode 100644 index 11ad56f7d0..0000000000 --- a/patches/minecraft/net/minecraft/world/gen/NoiseChunkGenerator.java.patch +++ /dev/null @@ -1,31 +0,0 @@ ---- a/net/minecraft/world/gen/NoiseChunkGenerator.java -+++ b/net/minecraft/world/gen/NoiseChunkGenerator.java -@@ -525,8 +_,8 @@ - objectlistiterator1.back(objectlist1.size()); - BlockState blockstate = this.func_236086_a_(d18, i2); - if (blockstate != field_222562_i) { -- if (blockstate.func_185906_d() != 0) { -- blockpos$mutable.func_181079_c(i3, i2, l3); -+ blockpos$mutable.func_181079_c(i3, i2, l3); -+ if (blockstate.getLightValue(chunkprimer, blockpos$mutable) != 0) { - chunkprimer.func_201637_h(blockpos$mutable); - } - -@@ -582,6 +_,9 @@ - } - - public List func_230353_a_(Biome p_230353_1_, StructureManager p_230353_2_, EntityClassification p_230353_3_, BlockPos p_230353_4_) { -+ List spawns = net.minecraftforge.common.world.StructureSpawnManager.getStructureSpawns(p_230353_2_, p_230353_3_, p_230353_4_); -+ if (spawns != null) return spawns; -+ if (false) {//Forge: We handle these hardcoded cases above in StructureSpawnManager#getStructureSpawns, but allow for insideOnly to be changed and allow for creatures to be spawned in ones other than just the witch hut - if (p_230353_2_.func_235010_a_(p_230353_4_, true, Structure.field_236374_j_).func_75069_d()) { - if (p_230353_3_ == EntityClassification.MONSTER) { - return Structure.field_236374_j_.func_202279_e(); -@@ -604,6 +_,7 @@ - if (p_230353_2_.func_235010_a_(p_230353_4_, true, Structure.field_236378_n_).func_75069_d()) { - return Structure.field_236378_n_.func_202279_e(); - } -+ } - } - - return super.func_230353_a_(p_230353_1_, p_230353_2_, p_230353_3_, p_230353_4_); diff --git a/patches/minecraft/net/minecraft/world/gen/WorldGenRegion.java.patch b/patches/minecraft/net/minecraft/world/gen/WorldGenRegion.java.patch deleted file mode 100644 index b6e87ad68b..0000000000 --- a/patches/minecraft/net/minecraft/world/gen/WorldGenRegion.java.patch +++ /dev/null @@ -1,60 +0,0 @@ ---- a/net/minecraft/world/gen/WorldGenRegion.java -+++ b/net/minecraft/world/gen/WorldGenRegion.java -@@ -173,11 +_,11 @@ - - public boolean func_241212_a_(BlockPos p_241212_1_, boolean p_241212_2_, @Nullable Entity p_241212_3_, int p_241212_4_) { - BlockState blockstate = this.func_180495_p(p_241212_1_); -- if (blockstate.func_196958_f()) { -+ if (blockstate.isAir(this, p_241212_1_)) { - return false; - } else { - if (p_241212_2_) { -- TileEntity tileentity = blockstate.func_177230_c().func_235695_q_() ? this.func_175625_s(p_241212_1_) : null; -+ TileEntity tileentity = blockstate.hasTileEntity() ? this.func_175625_s(p_241212_1_) : null; - Block.func_220054_a(blockstate, this.field_201689_f, p_241212_1_, tileentity, p_241212_3_, ItemStack.field_190927_a); - } - -@@ -197,11 +_,11 @@ - if (compoundnbt != null) { - if ("DUMMY".equals(compoundnbt.func_74779_i("id"))) { - Block block = blockstate.func_177230_c(); -- if (!(block instanceof ITileEntityProvider)) { -+ if (!blockstate.hasTileEntity()) { - return null; - } - -- tileentity = ((ITileEntityProvider)block).func_196283_a_(this.field_201689_f); -+ tileentity = blockstate.createTileEntity(this.field_201689_f); - } else { - tileentity = TileEntity.func_235657_b_(blockstate, compoundnbt); - } -@@ -212,7 +_,7 @@ - } - } - -- if (blockstate.func_177230_c() instanceof ITileEntityProvider) { -+ if (blockstate.hasTileEntity()) { - field_208303_a.warn("Tried to access a block entity before it was created. {}", (Object)p_175625_1_); - } - -@@ -228,9 +_,9 @@ - } - - Block block = p_241211_2_.func_177230_c(); -- if (block.func_235695_q_()) { -+ if (p_241211_2_.hasTileEntity()) { - if (ichunk.func_201589_g().func_202129_d() == ChunkStatus.Type.LEVELCHUNK) { -- ichunk.func_177426_a(p_241211_1_, ((ITileEntityProvider)block).func_196283_a_(this)); -+ ichunk.func_177426_a(p_241211_1_, p_241211_2_.createTileEntity(this)); - } else { - CompoundNBT compoundnbt = new CompoundNBT(); - compoundnbt.func_74768_a("x", p_241211_1_.func_177958_n()); -@@ -239,7 +_,7 @@ - compoundnbt.func_74778_a("id", "DUMMY"); - ichunk.func_201591_a(compoundnbt); - } -- } else if (blockstate != null && blockstate.func_177230_c().func_235695_q_()) { -+ } else if (blockstate != null && blockstate.hasTileEntity()) { - ichunk.func_177425_e(p_241211_1_); - } - diff --git a/patches/minecraft/net/minecraft/world/gen/blockplacer/BlockPlacerType.java.patch b/patches/minecraft/net/minecraft/world/gen/blockplacer/BlockPlacerType.java.patch deleted file mode 100644 index d83cfa6109..0000000000 --- a/patches/minecraft/net/minecraft/world/gen/blockplacer/BlockPlacerType.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/gen/blockplacer/BlockPlacerType.java -+++ b/net/minecraft/world/gen/blockplacer/BlockPlacerType.java -@@ -3,7 +_,7 @@ - import com.mojang.serialization.Codec; - import net.minecraft.util.registry.Registry; - --public class BlockPlacerType

{ -+public class BlockPlacerType

extends net.minecraftforge.registries.ForgeRegistryEntry> { - public static final BlockPlacerType field_227259_a_ = func_236438_a_("simple_block_placer", SimpleBlockPlacer.field_236446_b_); - public static final BlockPlacerType field_227260_b_ = func_236438_a_("double_plant_placer", DoublePlantBlockPlacer.field_236443_b_); - public static final BlockPlacerType field_227261_c_ = func_236438_a_("column_placer", ColumnBlockPlacer.field_236439_b_); diff --git a/patches/minecraft/net/minecraft/world/gen/blockstateprovider/BlockStateProviderType.java.patch b/patches/minecraft/net/minecraft/world/gen/blockstateprovider/BlockStateProviderType.java.patch deleted file mode 100644 index 8a7b32d0e7..0000000000 --- a/patches/minecraft/net/minecraft/world/gen/blockstateprovider/BlockStateProviderType.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/gen/blockstateprovider/BlockStateProviderType.java -+++ b/net/minecraft/world/gen/blockstateprovider/BlockStateProviderType.java -@@ -3,7 +_,7 @@ - import com.mojang.serialization.Codec; - import net.minecraft.util.registry.Registry; - --public class BlockStateProviderType

{ -+public class BlockStateProviderType

extends net.minecraftforge.registries.ForgeRegistryEntry> { - public static final BlockStateProviderType field_227394_a_ = func_236800_a_("simple_state_provider", SimpleBlockStateProvider.field_236809_b_); - public static final BlockStateProviderType field_227395_b_ = func_236800_a_("weighted_state_provider", WeightedBlockStateProvider.field_236811_b_); - public static final BlockStateProviderType field_227396_c_ = func_236800_a_("plain_flower_provider", PlainFlowerBlockStateProvider.field_236804_b_); diff --git a/patches/minecraft/net/minecraft/world/gen/carver/WorldCarver.java.patch b/patches/minecraft/net/minecraft/world/gen/carver/WorldCarver.java.patch deleted file mode 100644 index d5b0d38447..0000000000 --- a/patches/minecraft/net/minecraft/world/gen/carver/WorldCarver.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/gen/carver/WorldCarver.java -+++ b/net/minecraft/world/gen/carver/WorldCarver.java -@@ -22,7 +_,7 @@ - import net.minecraft.world.gen.feature.ProbabilityConfig; - import org.apache.commons.lang3.mutable.MutableBoolean; - --public abstract class WorldCarver { -+public abstract class WorldCarver extends net.minecraftforge.registries.ForgeRegistryEntry> { - public static final WorldCarver field_222709_a = func_222699_a("cave", new CaveWorldCarver(ProbabilityConfig.field_236576_b_, 256)); - public static final WorldCarver field_236240_b_ = func_222699_a("nether_cave", new NetherCaveCarver(ProbabilityConfig.field_236576_b_)); - public static final WorldCarver field_222711_c = func_222699_a("canyon", new CanyonWorldCarver(ProbabilityConfig.field_236576_b_)); diff --git a/patches/minecraft/net/minecraft/world/gen/feature/AbstractBigMushroomFeature.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/AbstractBigMushroomFeature.java.patch deleted file mode 100644 index 2f3dc4b1c6..0000000000 --- a/patches/minecraft/net/minecraft/world/gen/feature/AbstractBigMushroomFeature.java.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/world/gen/feature/AbstractBigMushroomFeature.java -+++ b/net/minecraft/world/gen/feature/AbstractBigMushroomFeature.java -@@ -19,7 +_,7 @@ - protected void func_227210_a_(IWorld p_227210_1_, Random p_227210_2_, BlockPos p_227210_3_, BigMushroomFeatureConfig p_227210_4_, int p_227210_5_, BlockPos.Mutable p_227210_6_) { - for(int i = 0; i < p_227210_5_; ++i) { - p_227210_6_.func_189533_g(p_227210_3_).func_189534_c(Direction.UP, i); -- if (!p_227210_1_.func_180495_p(p_227210_6_).func_200015_d(p_227210_1_, p_227210_6_)) { -+ if (p_227210_1_.func_180495_p(p_227210_6_).canBeReplacedByLogs(p_227210_1_, p_227210_6_)) { - this.func_230367_a_(p_227210_1_, p_227210_6_, p_227210_4_.field_227273_b_.func_225574_a_(p_227210_2_, p_227210_3_)); - } - } -@@ -48,7 +_,7 @@ - for(int l = -k; l <= k; ++l) { - for(int i1 = -k; i1 <= k; ++i1) { - BlockState blockstate = p_227209_1_.func_180495_p(p_227209_4_.func_239621_a_(p_227209_2_, l, j, i1)); -- if (!blockstate.func_196958_f() && !blockstate.func_235714_a_(BlockTags.field_206952_E)) { -+ if (!blockstate.isAir(p_227209_1_, p_227209_4_.func_239621_a_(p_227209_2_, l, j, i1)) && !blockstate.func_235714_a_(BlockTags.field_206952_E)) { - return false; - } - } diff --git a/patches/minecraft/net/minecraft/world/gen/feature/BaseTreeFeatureConfig.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/BaseTreeFeatureConfig.java.patch deleted file mode 100644 index dc9a518a5b..0000000000 --- a/patches/minecraft/net/minecraft/world/gen/feature/BaseTreeFeatureConfig.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/world/gen/feature/BaseTreeFeatureConfig.java -+++ b/net/minecraft/world/gen/feature/BaseTreeFeatureConfig.java -@@ -32,6 +_,7 @@ - return p_236684_0_.field_236682_l_; - })).apply(p_236683_0_, BaseTreeFeatureConfig::new); - }); -+ //TODO: Review this, see if we can hook in the sapling into the Codec - public final BlockStateProvider field_227368_m_; - public final BlockStateProvider field_227369_n_; - public final List field_227370_o_; diff --git a/patches/minecraft/net/minecraft/world/gen/feature/BigBrownMushroomFeature.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/BigBrownMushroomFeature.java.patch deleted file mode 100644 index b6433ded21..0000000000 --- a/patches/minecraft/net/minecraft/world/gen/feature/BigBrownMushroomFeature.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/gen/feature/BigBrownMushroomFeature.java -+++ b/net/minecraft/world/gen/feature/BigBrownMushroomFeature.java -@@ -24,7 +_,7 @@ - boolean flag5 = flag2 || flag3; - if (!flag4 || !flag5) { - p_225564_5_.func_239621_a_(p_225564_3_, j, p_225564_4_, k); -- if (!p_225564_1_.func_180495_p(p_225564_5_).func_200015_d(p_225564_1_, p_225564_5_)) { -+ if (p_225564_1_.func_180495_p(p_225564_5_).canBeReplacedByLeaves(p_225564_1_, p_225564_5_)) { - boolean flag6 = flag || flag5 && j == 1 - i; - boolean flag7 = flag1 || flag5 && j == i - 1; - boolean flag8 = flag2 || flag4 && k == 1 - i; diff --git a/patches/minecraft/net/minecraft/world/gen/feature/BigRedMushroomFeature.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/BigRedMushroomFeature.java.patch deleted file mode 100644 index 8a7f5d719b..0000000000 --- a/patches/minecraft/net/minecraft/world/gen/feature/BigRedMushroomFeature.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/gen/feature/BigRedMushroomFeature.java -+++ b/net/minecraft/world/gen/feature/BigRedMushroomFeature.java -@@ -26,7 +_,7 @@ - boolean flag5 = flag2 || flag3; - if (i >= p_225564_4_ || flag4 != flag5) { - p_225564_5_.func_239621_a_(p_225564_3_, l, i, i1); -- if (!p_225564_1_.func_180495_p(p_225564_5_).func_200015_d(p_225564_1_, p_225564_5_)) { -+ if (p_225564_1_.func_180495_p(p_225564_5_).canBeReplacedByLeaves(p_225564_1_, p_225564_5_)) { - this.func_230367_a_(p_225564_1_, p_225564_5_, p_225564_6_.field_227272_a_.func_225574_a_(p_225564_2_, p_225564_3_).func_206870_a(HugeMushroomBlock.field_196465_z, Boolean.valueOf(i >= p_225564_4_ - 1)).func_206870_a(HugeMushroomBlock.field_196464_y, Boolean.valueOf(l < -k)).func_206870_a(HugeMushroomBlock.field_196461_b, Boolean.valueOf(l > k)).func_206870_a(HugeMushroomBlock.field_196459_a, Boolean.valueOf(i1 < -k)).func_206870_a(HugeMushroomBlock.field_196463_c, Boolean.valueOf(i1 > k))); - } - } diff --git a/patches/minecraft/net/minecraft/world/gen/feature/DungeonsFeature.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/DungeonsFeature.java.patch deleted file mode 100644 index f63eb5bb83..0000000000 --- a/patches/minecraft/net/minecraft/world/gen/feature/DungeonsFeature.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/world/gen/feature/DungeonsFeature.java -+++ b/net/minecraft/world/gen/feature/DungeonsFeature.java -@@ -123,6 +_,6 @@ - } - - private EntityType func_201043_a(Random p_201043_1_) { -- return Util.func_240989_a_(field_175916_b, p_201043_1_); -+ return net.minecraftforge.common.DungeonHooks.getRandomDungeonMob(p_201043_1_); - } - } diff --git a/patches/minecraft/net/minecraft/world/gen/feature/Feature.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/Feature.java.patch deleted file mode 100644 index 988f519fed..0000000000 --- a/patches/minecraft/net/minecraft/world/gen/feature/Feature.java.patch +++ /dev/null @@ -1,25 +0,0 @@ ---- a/net/minecraft/world/gen/feature/Feature.java -+++ b/net/minecraft/world/gen/feature/Feature.java -@@ -15,7 +_,7 @@ - import net.minecraft.world.gen.feature.structure.BasaltDeltasStructure; - import net.minecraft.world.gen.feature.structure.NetherackBlobReplacementStructure; - --public abstract class Feature { -+public abstract class Feature extends net.minecraftforge.registries.ForgeRegistryEntry> { - public static final Feature field_227245_q_ = func_214468_a("no_op", new NoOpFeature(NoFeatureConfig.field_236558_a_)); - public static final Feature field_236291_c_ = func_214468_a("tree", new TreeFeature(BaseTreeFeatureConfig.field_236676_a_)); - public static final FlowersFeature field_227247_y_ = func_214468_a("flower", new DefaultFlowersFeature(BlockClusterFeatureConfig.field_236587_a_)); -@@ -97,11 +_,11 @@ - public abstract boolean func_241855_a(ISeedReader p_241855_1_, ChunkGenerator p_241855_2_, Random p_241855_3_, BlockPos p_241855_4_, FC p_241855_5_); - - protected static boolean func_227249_a_(Block p_227249_0_) { -- return p_227249_0_ == Blocks.field_150348_b || p_227249_0_ == Blocks.field_196650_c || p_227249_0_ == Blocks.field_196654_e || p_227249_0_ == Blocks.field_196656_g; -+ return net.minecraftforge.common.Tags.Blocks.STONE.func_230235_a_(p_227249_0_); - } - - public static boolean func_227250_b_(Block p_227250_0_) { -- return p_227250_0_ == Blocks.field_150346_d || p_227250_0_ == Blocks.field_196658_i || p_227250_0_ == Blocks.field_196661_l || p_227250_0_ == Blocks.field_196660_k || p_227250_0_ == Blocks.field_150391_bh; -+ return net.minecraftforge.common.Tags.Blocks.DIRT.func_230235_a_(p_227250_0_); - } - - public static boolean func_236293_a_(IWorldGenerationBaseReader p_236293_0_, BlockPos p_236293_1_) { diff --git a/patches/minecraft/net/minecraft/world/gen/feature/GlowstoneBlobFeature.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/GlowstoneBlobFeature.java.patch deleted file mode 100644 index 01b9ae2fab..0000000000 --- a/patches/minecraft/net/minecraft/world/gen/feature/GlowstoneBlobFeature.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/gen/feature/GlowstoneBlobFeature.java -+++ b/net/minecraft/world/gen/feature/GlowstoneBlobFeature.java -@@ -26,7 +_,7 @@ - - for(int i = 0; i < 1500; ++i) { - BlockPos blockpos = p_241855_4_.func_177982_a(p_241855_3_.nextInt(8) - p_241855_3_.nextInt(8), -p_241855_3_.nextInt(12), p_241855_3_.nextInt(8) - p_241855_3_.nextInt(8)); -- if (p_241855_1_.func_180495_p(blockpos).func_196958_f()) { -+ if (p_241855_1_.func_180495_p(blockpos).isAir(p_241855_1_, blockpos)) { - int j = 0; - - for(Direction direction : Direction.values()) { diff --git a/patches/minecraft/net/minecraft/world/gen/feature/IceSpikeFeature.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/IceSpikeFeature.java.patch deleted file mode 100644 index b3c7da451e..0000000000 --- a/patches/minecraft/net/minecraft/world/gen/feature/IceSpikeFeature.java.patch +++ /dev/null @@ -1,28 +0,0 @@ ---- a/net/minecraft/world/gen/feature/IceSpikeFeature.java -+++ b/net/minecraft/world/gen/feature/IceSpikeFeature.java -@@ -42,14 +_,14 @@ - if ((i1 == 0 && j1 == 0 || !(f1 * f1 + f2 * f2 > f * f)) && (i1 != -l && i1 != l && j1 != -l && j1 != l || !(p_241855_3_.nextFloat() > 0.75F))) { - BlockState blockstate = p_241855_1_.func_180495_p(p_241855_4_.func_177982_a(i1, k, j1)); - Block block = blockstate.func_177230_c(); -- if (blockstate.func_196958_f() || func_227250_b_(block) || block == Blocks.field_196604_cC || block == Blocks.field_150432_aD) { -+ if (blockstate.isAir(p_241855_1_, p_241855_4_.func_177982_a(i1, k, j1)) || func_227250_b_(block) || block == Blocks.field_196604_cC || block == Blocks.field_150432_aD) { - this.func_230367_a_(p_241855_1_, p_241855_4_.func_177982_a(i1, k, j1), Blocks.field_150403_cj.func_176223_P()); - } - - if (k != 0 && l > 1) { - blockstate = p_241855_1_.func_180495_p(p_241855_4_.func_177982_a(i1, -k, j1)); - block = blockstate.func_177230_c(); -- if (blockstate.func_196958_f() || func_227250_b_(block) || block == Blocks.field_196604_cC || block == Blocks.field_150432_aD) { -+ if (blockstate.isAir(p_241855_1_, p_241855_4_.func_177982_a(i1, -k, j1)) || func_227250_b_(block) || block == Blocks.field_196604_cC || block == Blocks.field_150432_aD) { - this.func_230367_a_(p_241855_1_, p_241855_4_.func_177982_a(i1, -k, j1), Blocks.field_150403_cj.func_176223_P()); - } - } -@@ -76,7 +_,7 @@ - while(blockpos.func_177956_o() > 50) { - BlockState blockstate1 = p_241855_1_.func_180495_p(blockpos); - Block block1 = blockstate1.func_177230_c(); -- if (!blockstate1.func_196958_f() && !func_227250_b_(block1) && block1 != Blocks.field_196604_cC && block1 != Blocks.field_150432_aD && block1 != Blocks.field_150403_cj) { -+ if (!blockstate1.isAir(p_241855_1_, blockpos) && !func_227250_b_(block1) && block1 != Blocks.field_196604_cC && block1 != Blocks.field_150432_aD && block1 != Blocks.field_150403_cj) { - break; - } - diff --git a/patches/minecraft/net/minecraft/world/gen/feature/SpringFeature.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/SpringFeature.java.patch deleted file mode 100644 index 66693176ff..0000000000 --- a/patches/minecraft/net/minecraft/world/gen/feature/SpringFeature.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/gen/feature/SpringFeature.java -+++ b/net/minecraft/world/gen/feature/SpringFeature.java -@@ -19,7 +_,7 @@ - return false; - } else { - BlockState blockstate = p_241855_1_.func_180495_p(p_241855_4_); -- if (!blockstate.func_196958_f() && !p_241855_5_.field_227366_f_.contains(blockstate.func_177230_c())) { -+ if (!blockstate.isAir(p_241855_1_, p_241855_4_) && !p_241855_5_.field_227366_f_.contains(blockstate.func_177230_c())) { - return false; - } else { - int i = 0; diff --git a/patches/minecraft/net/minecraft/world/gen/feature/jigsaw/JigsawPattern.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/jigsaw/JigsawPattern.java.patch deleted file mode 100644 index 69c6dc13c9..0000000000 --- a/patches/minecraft/net/minecraft/world/gen/feature/jigsaw/JigsawPattern.java.patch +++ /dev/null @@ -1,33 +0,0 @@ ---- a/net/minecraft/world/gen/feature/jigsaw/JigsawPattern.java -+++ b/net/minecraft/world/gen/feature/jigsaw/JigsawPattern.java -@@ -104,11 +_,11 @@ - return this.field_214953_e.size(); - } - -- public static enum PlacementBehaviour implements IStringSerializable { -+ public static enum PlacementBehaviour implements IStringSerializable, net.minecraftforge.common.IExtensibleEnum { - TERRAIN_MATCHING("terrain_matching", ImmutableList.of(new GravityStructureProcessor(Heightmap.Type.WORLD_SURFACE_WG, -1))), - RIGID("rigid", ImmutableList.of()); - -- public static final Codec field_236858_c_ = IStringSerializable.func_233023_a_(JigsawPattern.PlacementBehaviour::values, JigsawPattern.PlacementBehaviour::func_214938_a); -+ public static final Codec field_236858_c_ = net.minecraftforge.common.IExtensibleEnum.createCodecForExtensibleEnum(JigsawPattern.PlacementBehaviour::values, JigsawPattern.PlacementBehaviour::func_214938_a); - private static final Map field_214939_c = Arrays.stream(values()).collect(Collectors.toMap(JigsawPattern.PlacementBehaviour::func_214936_a, (p_214935_0_) -> { - return p_214935_0_; - })); -@@ -134,6 +_,16 @@ - - public String func_176610_l() { - return this.field_214940_d; -+ } -+ -+ public static PlacementBehaviour create(String enumName, String p_i50487_3_, ImmutableList p_i50487_4_) { -+ throw new IllegalStateException("Enum not extended"); -+ } -+ -+ @Override -+ @Deprecated -+ public void init() { -+ field_214939_c.put(func_214936_a(), this); - } - } - } diff --git a/patches/minecraft/net/minecraft/world/gen/feature/jigsaw/SingleJigsawPiece.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/jigsaw/SingleJigsawPiece.java.patch deleted file mode 100644 index 03bf53934e..0000000000 --- a/patches/minecraft/net/minecraft/world/gen/feature/jigsaw/SingleJigsawPiece.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/gen/feature/jigsaw/SingleJigsawPiece.java -+++ b/net/minecraft/world/gen/feature/jigsaw/SingleJigsawPiece.java -@@ -106,7 +_,7 @@ - if (!template.func_237146_a_(p_230378_2_, p_230378_5_, p_230378_6_, placementsettings, p_230378_9_, 18)) { - return false; - } else { -- for(Template.BlockInfo template$blockinfo : Template.func_237145_a_(p_230378_2_, p_230378_5_, p_230378_6_, placementsettings, this.func_214857_a(p_230378_1_, p_230378_5_, p_230378_7_, false))) { -+ for(Template.BlockInfo template$blockinfo : Template.processBlockInfos(p_230378_2_, p_230378_5_, p_230378_6_, placementsettings, this.func_214857_a(p_230378_1_, p_230378_5_, p_230378_7_, false), template)) { - this.func_214846_a(p_230378_2_, template$blockinfo, p_230378_5_, p_230378_7_, p_230378_9_, p_230378_8_); - } - diff --git a/patches/minecraft/net/minecraft/world/gen/feature/structure/FortressStructure.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/structure/FortressStructure.java.patch deleted file mode 100644 index 70e34afe8f..0000000000 --- a/patches/minecraft/net/minecraft/world/gen/feature/structure/FortressStructure.java.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/net/minecraft/world/gen/feature/structure/FortressStructure.java -+++ b/net/minecraft/world/gen/feature/structure/FortressStructure.java -@@ -30,7 +_,8 @@ - return FortressStructure.Start::new; - } - -- public List func_202279_e() { -+ @Override -+ public List getDefaultSpawnList() { - return field_202381_d; - } - diff --git a/patches/minecraft/net/minecraft/world/gen/feature/structure/MineshaftPieces.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/structure/MineshaftPieces.java.patch deleted file mode 100644 index b4dafc3732..0000000000 --- a/patches/minecraft/net/minecraft/world/gen/feature/structure/MineshaftPieces.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/gen/feature/structure/MineshaftPieces.java -+++ b/net/minecraft/world/gen/feature/structure/MineshaftPieces.java -@@ -207,7 +_,7 @@ - - protected boolean func_186167_a(ISeedReader p_186167_1_, MutableBoundingBox p_186167_2_, Random p_186167_3_, int p_186167_4_, int p_186167_5_, int p_186167_6_, ResourceLocation p_186167_7_) { - BlockPos blockpos = new BlockPos(this.func_74865_a(p_186167_4_, p_186167_6_), this.func_74862_a(p_186167_5_), this.func_74873_b(p_186167_4_, p_186167_6_)); -- if (p_186167_2_.func_175898_b(blockpos) && p_186167_1_.func_180495_p(blockpos).func_196958_f() && !p_186167_1_.func_180495_p(blockpos.func_177977_b()).func_196958_f()) { -+ if (p_186167_2_.func_175898_b(blockpos) && p_186167_1_.func_180495_p(blockpos).isAir(p_186167_1_, blockpos) && !p_186167_1_.func_180495_p(blockpos.func_177977_b()).isAir(p_186167_1_, blockpos.func_177977_b())) { - BlockState blockstate = Blocks.field_150448_aq.func_176223_P().func_206870_a(RailBlock.field_176565_b, p_186167_3_.nextBoolean() ? RailShape.NORTH_SOUTH : RailShape.EAST_WEST); - this.func_175811_a(p_186167_1_, blockstate, p_186167_4_, p_186167_5_, p_186167_6_, p_186167_2_); - ChestMinecartEntity chestminecartentity = new ChestMinecartEntity(p_186167_1_.func_201672_e(), (double)blockpos.func_177958_n() + 0.5D, (double)blockpos.func_177956_o() + 0.5D, (double)blockpos.func_177952_p() + 0.5D); diff --git a/patches/minecraft/net/minecraft/world/gen/feature/structure/OceanMonumentStructure.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/structure/OceanMonumentStructure.java.patch deleted file mode 100644 index 610366e549..0000000000 --- a/patches/minecraft/net/minecraft/world/gen/feature/structure/OceanMonumentStructure.java.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/net/minecraft/world/gen/feature/structure/OceanMonumentStructure.java -+++ b/net/minecraft/world/gen/feature/structure/OceanMonumentStructure.java -@@ -49,7 +_,8 @@ - return OceanMonumentStructure.Start::new; - } - -- public List func_202279_e() { -+ @Override -+ public List getDefaultSpawnList() { - return field_175803_h; - } - diff --git a/patches/minecraft/net/minecraft/world/gen/feature/structure/PillagerOutpostStructure.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/structure/PillagerOutpostStructure.java.patch deleted file mode 100644 index db2dd13c64..0000000000 --- a/patches/minecraft/net/minecraft/world/gen/feature/structure/PillagerOutpostStructure.java.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/net/minecraft/world/gen/feature/structure/PillagerOutpostStructure.java -+++ b/net/minecraft/world/gen/feature/structure/PillagerOutpostStructure.java -@@ -19,7 +_,8 @@ - super(p_i231977_1_, 0, true, true); - } - -- public List func_202279_e() { -+ @Override -+ public List getDefaultSpawnList() { - return field_214558_a; - } - diff --git a/patches/minecraft/net/minecraft/world/gen/feature/structure/Structure.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/structure/Structure.java.patch deleted file mode 100644 index 8cb44aef7b..0000000000 --- a/patches/minecraft/net/minecraft/world/gen/feature/structure/Structure.java.patch +++ /dev/null @@ -1,30 +0,0 @@ ---- a/net/minecraft/world/gen/feature/structure/Structure.java -+++ b/net/minecraft/world/gen/feature/structure/Structure.java -@@ -38,7 +_,7 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; - --public abstract class Structure { -+public abstract class Structure extends net.minecraftforge.registries.ForgeRegistryEntry> implements net.minecraftforge.common.extensions.IForgeStructure { - public static final BiMap> field_236365_a_ = HashBiMap.create(); - private static final Map, GenerationStage.Decoration> field_236385_u_ = Maps.newHashMap(); - private static final Logger field_208204_b = LogManager.getLogger(); -@@ -237,11 +_,16 @@ - } - - public List func_202279_e() { -- return ImmutableList.of(); -+ return getSpawnList(net.minecraft.entity.EntityClassification.MONSTER); - } - - public List func_214469_f() { -- return ImmutableList.of(); -+ return getSpawnList(net.minecraft.entity.EntityClassification.CREATURE); -+ } -+ -+ @Override -+ public final List getSpawnList(net.minecraft.entity.EntityClassification classification) { -+ return net.minecraftforge.common.world.StructureSpawnManager.getSpawnList(getStructure(), classification); - } - - public interface IStartFactory { diff --git a/patches/minecraft/net/minecraft/world/gen/feature/structure/StructurePiece.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/structure/StructurePiece.java.patch deleted file mode 100644 index 28c68cc628..0000000000 --- a/patches/minecraft/net/minecraft/world/gen/feature/structure/StructurePiece.java.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/net/minecraft/world/gen/feature/structure/StructurePiece.java -+++ b/net/minecraft/world/gen/feature/structure/StructurePiece.java -@@ -57,6 +_,9 @@ - } - - public final CompoundNBT func_143010_b() { -+ if (Registry.field_218362_C.func_177774_c(this.func_214807_k()) == null) { // FORGE: Friendlier error then the Null String error below. -+ throw new RuntimeException("StructurePiece \"" + this.getClass().getName() + "\": \"" + this.func_214807_k() + "\" missing ID Mapping, Modder see MapGenStructureIO"); -+ } - CompoundNBT compoundnbt = new CompoundNBT(); - compoundnbt.func_74778_a("id", Registry.field_218362_C.func_177774_c(this.func_214807_k()).toString()); - compoundnbt.func_218657_a("BB", this.field_74887_e.func_151535_h()); diff --git a/patches/minecraft/net/minecraft/world/gen/feature/structure/StructureStart.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/structure/StructureStart.java.patch deleted file mode 100644 index c53125dca8..0000000000 --- a/patches/minecraft/net/minecraft/world/gen/feature/structure/StructureStart.java.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/net/minecraft/world/gen/feature/structure/StructureStart.java -+++ b/net/minecraft/world/gen/feature/structure/StructureStart.java -@@ -84,6 +_,9 @@ - public CompoundNBT func_143021_a(int p_143021_1_, int p_143021_2_) { - CompoundNBT compoundnbt = new CompoundNBT(); - if (this.func_75069_d()) { -+ if (Registry.field_218361_B.func_177774_c(this.func_214627_k()) == null) { // FORGE: This is just a more friendly error instead of the 'Null String' below -+ throw new RuntimeException("StructureStart \"" + this.getClass().getName() + "\": \"" + this.func_214627_k() + "\" missing ID Mapping, Modder see MapGenStructureIO"); -+ } - compoundnbt.func_74778_a("id", Registry.field_218361_B.func_177774_c(this.func_214627_k()).toString()); - compoundnbt.func_74768_a("ChunkX", p_143021_1_); - compoundnbt.func_74768_a("ChunkZ", p_143021_2_); diff --git a/patches/minecraft/net/minecraft/world/gen/feature/structure/SwampHutStructure.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/structure/SwampHutStructure.java.patch deleted file mode 100644 index fc934fc192..0000000000 --- a/patches/minecraft/net/minecraft/world/gen/feature/structure/SwampHutStructure.java.patch +++ /dev/null @@ -1,18 +0,0 @@ ---- a/net/minecraft/world/gen/feature/structure/SwampHutStructure.java -+++ b/net/minecraft/world/gen/feature/structure/SwampHutStructure.java -@@ -24,11 +_,13 @@ - return SwampHutStructure.Start::new; - } - -- public List func_202279_e() { -+ @Override -+ public List getDefaultSpawnList() { - return field_202384_d; - } - -- public List func_214469_f() { -+ @Override -+ public List getDefaultCreatureSpawnList() { - return field_214559_aS; - } - diff --git a/patches/minecraft/net/minecraft/world/gen/feature/template/StructureProcessor.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/template/StructureProcessor.java.patch deleted file mode 100644 index 9c860e0f95..0000000000 --- a/patches/minecraft/net/minecraft/world/gen/feature/template/StructureProcessor.java.patch +++ /dev/null @@ -1,41 +0,0 @@ ---- a/net/minecraft/world/gen/feature/template/StructureProcessor.java -+++ b/net/minecraft/world/gen/feature/template/StructureProcessor.java -@@ -6,7 +_,37 @@ - - public abstract class StructureProcessor { - @Nullable -- public abstract Template.BlockInfo func_230386_a_(IWorldReader p_230386_1_, BlockPos p_230386_2_, BlockPos p_230386_3_, Template.BlockInfo p_230386_4_, Template.BlockInfo p_230386_5_, PlacementSettings p_230386_6_); -+ @Deprecated //Forge: Use process below, with the Template context -+ public Template.BlockInfo func_230386_a_(IWorldReader p_230386_1_, BlockPos p_230386_2_, BlockPos p_230386_3_, Template.BlockInfo p_230386_4_, Template.BlockInfo p_230386_5_, PlacementSettings p_230386_6_) { -+ return p_230386_5_; -+ } - - protected abstract IStructureProcessorType func_215192_a(); -+ -+ @Nullable -+ public Template.BlockInfo process(IWorldReader p_230386_1_, BlockPos p_230386_2_, BlockPos p_230386_3_, Template.BlockInfo p_230386_4_, Template.BlockInfo p_230386_5_, PlacementSettings p_230386_6_, @Nullable Template template) { -+ return func_230386_a_(p_230386_1_, p_230386_2_, p_230386_3_, p_230386_4_, p_230386_5_, p_230386_6_); -+ } -+ -+ /** -+ * FORGE: Add entity processing. -+ *

-+ * Use this method to process entities from a structure in much the same way as -+ * blocks, parameters are analogous. -+ * -+ * @param world -+ * @param seedPos -+ * @param rawEntityInfo -+ * @param entityInfo -+ * @param placementSettings -+ * @param template -+ * -+ * @see #process(IWorldReader, BlockPos, -+ * net.minecraft.world.gen.feature.template.Template.BlockInfo, -+ * net.minecraft.world.gen.feature.template.Template.BlockInfo, -+ * PlacementSettings) -+ */ -+ public Template.EntityInfo processEntity(IWorldReader world, BlockPos seedPos, Template.EntityInfo rawEntityInfo, Template.EntityInfo entityInfo, PlacementSettings placementSettings, Template template) { -+ return entityInfo; -+ } - } diff --git a/patches/minecraft/net/minecraft/world/gen/feature/template/Template.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/template/Template.java.patch deleted file mode 100644 index 8fdb082967..0000000000 --- a/patches/minecraft/net/minecraft/world/gen/feature/template/Template.java.patch +++ /dev/null @@ -1,103 +0,0 @@ ---- a/net/minecraft/world/gen/feature/template/Template.java -+++ b/net/minecraft/world/gen/feature/template/Template.java -@@ -190,6 +_,10 @@ - return func_207669_a(p_186266_1_, p_186266_0_.func_186212_b(), p_186266_0_.func_186215_c(), p_186266_0_.func_207664_d()); - } - -+ public static Vector3d transformedVec3d(PlacementSettings placementIn, Vector3d pos) { -+ return func_207667_a(pos, placementIn.func_186212_b(), placementIn.func_186215_c(), placementIn.func_207664_d()); -+ } -+ - public void func_237144_a_(IServerWorld p_237144_1_, BlockPos p_237144_2_, PlacementSettings p_237144_3_, Random p_237144_4_) { - p_237144_3_.func_186224_i(); - this.func_237152_b_(p_237144_1_, p_237144_2_, p_237144_3_, p_237144_4_); -@@ -215,7 +_,7 @@ - int i1 = Integer.MIN_VALUE; - int j1 = Integer.MIN_VALUE; - -- for(Template.BlockInfo template$blockinfo : func_237145_a_(p_237146_1_, p_237146_2_, p_237146_3_, p_237146_4_, list)) { -+ for(Template.BlockInfo template$blockinfo : processBlockInfos(p_237146_1_, p_237146_2_, p_237146_3_, p_237146_4_, list, this)) { - BlockPos blockpos = template$blockinfo.field_186242_a; - if (mutableboundingbox == null || mutableboundingbox.func_175898_b(blockpos)) { - FluidState fluidstate = p_237146_4_.func_204763_l() ? p_237146_1_.func_204610_c(blockpos) : null; -@@ -330,7 +_,7 @@ - } - - if (!p_237146_4_.func_186221_e()) { -- this.func_237143_a_(p_237146_1_, p_237146_2_, p_237146_4_.func_186212_b(), p_237146_4_.func_186215_c(), p_237146_4_.func_207664_d(), mutableboundingbox, p_237146_4_.func_237134_m_()); -+ this.addEntitiesToWorld(p_237146_1_, p_237146_2_, p_237146_4_); - } - - return true; -@@ -359,14 +_,19 @@ - }); - } - -+ @Deprecated //Use Forge version - public static List func_237145_a_(IWorld p_237145_0_, BlockPos p_237145_1_, BlockPos p_237145_2_, PlacementSettings p_237145_3_, List p_237145_4_) { -+ return processBlockInfos(p_237145_0_, p_237145_1_, p_237145_2_, p_237145_3_, p_237145_4_, null); -+ } -+ -+ public static List processBlockInfos(IWorld p_237145_0_, BlockPos p_237145_1_, BlockPos p_237145_2_, PlacementSettings p_237145_3_, List p_237145_4_, @Nullable Template template) { - List list = Lists.newArrayList(); - - for(Template.BlockInfo template$blockinfo : p_237145_4_) { - BlockPos blockpos = func_186266_a(p_237145_3_, template$blockinfo.field_186242_a).func_177971_a(p_237145_1_); - Template.BlockInfo template$blockinfo1 = new Template.BlockInfo(blockpos, template$blockinfo.field_186243_b, template$blockinfo.field_186244_c != null ? template$blockinfo.field_186244_c.func_74737_b() : null); - -- for(Iterator iterator = p_237145_3_.func_215221_j().iterator(); template$blockinfo1 != null && iterator.hasNext(); template$blockinfo1 = iterator.next().func_230386_a_(p_237145_0_, p_237145_1_, p_237145_2_, template$blockinfo, template$blockinfo1, p_237145_3_)) { -+ for(Iterator iterator = p_237145_3_.func_215221_j().iterator(); template$blockinfo1 != null && iterator.hasNext(); template$blockinfo1 = iterator.next().process(p_237145_0_, p_237145_1_, p_237145_2_, template$blockinfo, template$blockinfo1, p_237145_3_, template)) { - } - - if (template$blockinfo1 != null) { -@@ -377,13 +_,30 @@ - return list; - } - -- private void func_237143_a_(IServerWorld p_237143_1_, BlockPos p_237143_2_, Mirror p_237143_3_, Rotation p_237143_4_, BlockPos p_237143_5_, @Nullable MutableBoundingBox p_237143_6_, boolean p_237143_7_) { -- for(Template.EntityInfo template$entityinfo : this.field_186271_b) { -- BlockPos blockpos = func_207669_a(template$entityinfo.field_186248_b, p_237143_3_, p_237143_4_, p_237143_5_).func_177971_a(p_237143_2_); -- if (p_237143_6_ == null || p_237143_6_.func_175898_b(blockpos)) { -+ public static List processEntityInfos(@Nullable Template template, IWorld p_215387_0_, BlockPos p_215387_1_, PlacementSettings p_215387_2_, List p_215387_3_) { -+ List list = Lists.newArrayList(); -+ for(Template.EntityInfo entityInfo : p_215387_3_) { -+ Vector3d pos = transformedVec3d(p_215387_2_, entityInfo.field_186247_a).func_178787_e(Vector3d.func_237491_b_(p_215387_1_)); -+ BlockPos blockpos = func_186266_a(p_215387_2_, entityInfo.field_186248_b).func_177971_a(p_215387_1_); -+ Template.EntityInfo info = new Template.EntityInfo(pos, blockpos, entityInfo.field_186249_c); -+ for (StructureProcessor proc : p_215387_2_.func_215221_j()) { -+ info = proc.processEntity(p_215387_0_, p_215387_1_, entityInfo, info, p_215387_2_, template); -+ if (info == null) -+ break; -+ } -+ if (info != null) -+ list.add(info); -+ } -+ return list; -+ } -+ -+ private void addEntitiesToWorld(IServerWorld p_237143_1_, BlockPos p_237143_2_, PlacementSettings placementIn) { -+ for(Template.EntityInfo template$entityinfo : processEntityInfos(this, p_237143_1_, p_237143_2_, placementIn, this.field_186271_b)) { -+ BlockPos blockpos = func_207669_a(template$entityinfo.field_186248_b, placementIn.func_186212_b(), placementIn.func_186215_c(), placementIn.func_207664_d()).func_177971_a(p_237143_2_); -+ blockpos = template$entityinfo.field_186248_b; // FORGE: Position will have already been transformed by processEntityInfos -+ if (placementIn.func_186213_g() == null || placementIn.func_186213_g().func_175898_b(blockpos)) { - CompoundNBT compoundnbt = template$entityinfo.field_186249_c.func_74737_b(); -- Vector3d vector3d = func_207667_a(template$entityinfo.field_186247_a, p_237143_3_, p_237143_4_, p_237143_5_); -- Vector3d vector3d1 = vector3d.func_72441_c((double)p_237143_2_.func_177958_n(), (double)p_237143_2_.func_177956_o(), (double)p_237143_2_.func_177952_p()); -+ Vector3d vector3d1 = template$entityinfo.field_186247_a; // FORGE: Position will have already been transformed by processEntityInfos - ListNBT listnbt = new ListNBT(); - listnbt.add(DoubleNBT.func_229684_a_(vector3d1.field_72450_a)); - listnbt.add(DoubleNBT.func_229684_a_(vector3d1.field_72448_b)); -@@ -391,10 +_,10 @@ - compoundnbt.func_218657_a("Pos", listnbt); - compoundnbt.func_82580_o("UUID"); - func_215382_a(p_237143_1_, compoundnbt).ifPresent((p_242927_6_) -> { -- float f = p_242927_6_.func_184217_a(p_237143_3_); -- f = f + (p_242927_6_.field_70177_z - p_242927_6_.func_184229_a(p_237143_4_)); -+ float f = p_242927_6_.func_184217_a(placementIn.func_186212_b()); -+ f = f + (p_242927_6_.field_70177_z - p_242927_6_.func_184229_a(placementIn.func_186215_c())); - p_242927_6_.func_70012_b(vector3d1.field_72450_a, vector3d1.field_72448_b, vector3d1.field_72449_c, f, p_242927_6_.field_70125_A); -- if (p_237143_7_ && p_242927_6_ instanceof MobEntity) { -+ if (placementIn.func_237134_m_() && p_242927_6_ instanceof MobEntity) { - ((MobEntity)p_242927_6_).func_213386_a(p_237143_1_, p_237143_1_.func_175649_E(new BlockPos(vector3d1)), SpawnReason.STRUCTURE, (ILivingEntityData)null, compoundnbt); - } - diff --git a/patches/minecraft/net/minecraft/world/gen/foliageplacer/FoliagePlacerType.java.patch b/patches/minecraft/net/minecraft/world/gen/foliageplacer/FoliagePlacerType.java.patch deleted file mode 100644 index 302690bbc2..0000000000 --- a/patches/minecraft/net/minecraft/world/gen/foliageplacer/FoliagePlacerType.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/gen/foliageplacer/FoliagePlacerType.java -+++ b/net/minecraft/world/gen/foliageplacer/FoliagePlacerType.java -@@ -3,7 +_,7 @@ - import com.mojang.serialization.Codec; - import net.minecraft.util.registry.Registry; - --public class FoliagePlacerType

{ -+public class FoliagePlacerType

extends net.minecraftforge.registries.ForgeRegistryEntry> { - public static final FoliagePlacerType field_227386_a_ = func_236773_a_("blob_foliage_placer", BlobFoliagePlacer.field_236738_a_); - public static final FoliagePlacerType field_227387_b_ = func_236773_a_("spruce_foliage_placer", SpruceFoliagePlacer.field_236790_a_); - public static final FoliagePlacerType field_227388_c_ = func_236773_a_("pine_foliage_placer", PineFoliagePlacer.field_236784_a_); diff --git a/patches/minecraft/net/minecraft/world/gen/layer/BiomeLayer.java.patch b/patches/minecraft/net/minecraft/world/gen/layer/BiomeLayer.java.patch deleted file mode 100644 index 83ef9affd9..0000000000 --- a/patches/minecraft/net/minecraft/world/gen/layer/BiomeLayer.java.patch +++ /dev/null @@ -1,64 +0,0 @@ ---- a/net/minecraft/world/gen/layer/BiomeLayer.java -+++ b/net/minecraft/world/gen/layer/BiomeLayer.java -@@ -10,12 +_,13 @@ - private static final int[] field_202746_t = new int[]{4, 3, 5, 1}; - private static final int[] field_202747_u = new int[]{12, 12, 12, 30}; - private int[] field_151623_c = field_202744_r; -+ private final boolean legacyDesert; -+ private java.util.List[] biomes = new java.util.ArrayList[net.minecraftforge.common.BiomeManager.BiomeType.values().length]; - - public BiomeLayer(boolean p_i232147_1_) { -- if (p_i232147_1_) { -- this.field_151623_c = field_202743_q; -- } -- -+ this.legacyDesert = p_i232147_1_; -+ for (net.minecraftforge.common.BiomeManager.BiomeType type : net.minecraftforge.common.BiomeManager.BiomeType.values()) -+ biomes[type.ordinal()] = new java.util.ArrayList<>(net.minecraftforge.common.BiomeManager.getBiomes(type)); - } - - public int func_202726_a(INoiseRandom p_202726_1_, int p_202726_2_) { -@@ -28,26 +_,39 @@ - return p_202726_1_.func_202696_a(3) == 0 ? 39 : 38; - } - -- return this.field_151623_c[p_202726_1_.func_202696_a(this.field_151623_c.length)]; -+ return getBiomeId(net.minecraftforge.common.BiomeManager.BiomeType.DESERT, p_202726_1_); - case 2: - if (i > 0) { - return 21; - } - -- return field_202745_s[p_202726_1_.func_202696_a(field_202745_s.length)]; -+ return getBiomeId(net.minecraftforge.common.BiomeManager.BiomeType.WARM, p_202726_1_); - case 3: - if (i > 0) { - return 32; - } - -- return field_202746_t[p_202726_1_.func_202696_a(field_202746_t.length)]; -+ return getBiomeId(net.minecraftforge.common.BiomeManager.BiomeType.COOL, p_202726_1_); - case 4: -- return field_202747_u[p_202726_1_.func_202696_a(field_202747_u.length)]; -+ return getBiomeId(net.minecraftforge.common.BiomeManager.BiomeType.ICY, p_202726_1_); - default: - return 14; - } - } else { - return p_202726_2_; - } -+ } -+ -+ private int getBiomeId(net.minecraftforge.common.BiomeManager.BiomeType type, INoiseRandom context) { -+ return net.minecraft.util.registry.WorldGenRegistries.field_243657_i.func_148757_b( -+ net.minecraft.util.registry.WorldGenRegistries.field_243657_i.func_230516_a_(getBiome(type, context))); -+ } -+ protected net.minecraft.util.RegistryKey getBiome(net.minecraftforge.common.BiomeManager.BiomeType type, INoiseRandom context) { -+ if (type == net.minecraftforge.common.BiomeManager.BiomeType.DESERT && this.legacyDesert) -+ type = net.minecraftforge.common.BiomeManager.BiomeType.DESERT_LEGACY; -+ java.util.List biomeList = biomes[type.ordinal()]; -+ int totalWeight = net.minecraft.util.WeightedRandom.func_76272_a(biomeList); -+ int weight = net.minecraftforge.common.BiomeManager.isTypeListModded(type) ? context.func_202696_a(totalWeight) : context.func_202696_a(totalWeight / 10) * 10; -+ return net.minecraft.util.WeightedRandom.func_180166_a(biomeList, weight).getKey(); - } - } diff --git a/patches/minecraft/net/minecraft/world/gen/placement/Placement.java.patch b/patches/minecraft/net/minecraft/world/gen/placement/Placement.java.patch deleted file mode 100644 index f472be26be..0000000000 --- a/patches/minecraft/net/minecraft/world/gen/placement/Placement.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/gen/placement/Placement.java -+++ b/net/minecraft/world/gen/placement/Placement.java -@@ -8,7 +_,7 @@ - import net.minecraft.world.gen.feature.FeatureSpreadConfig; - import net.minecraft.world.gen.feature.WorldDecoratingHelper; - --public abstract class Placement { -+public abstract class Placement extends net.minecraftforge.registries.ForgeRegistryEntry> { - public static final Placement field_215022_h = func_214999_a("nope", new Passthrough(NoPlacementConfig.field_236555_a_)); - public static final Placement field_242898_b = func_214999_a("chance", new ChancePlacement(ChanceConfig.field_236950_a_)); - public static final Placement field_242899_c = func_214999_a("count", new CountPlacement(FeatureSpreadConfig.field_242797_a)); diff --git a/patches/minecraft/net/minecraft/world/gen/settings/DimensionGeneratorSettings.java.patch b/patches/minecraft/net/minecraft/world/gen/settings/DimensionGeneratorSettings.java.patch deleted file mode 100644 index 3912df8c9c..0000000000 --- a/patches/minecraft/net/minecraft/world/gen/settings/DimensionGeneratorSettings.java.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/world/gen/settings/DimensionGeneratorSettings.java -+++ b/net/minecraft/world/gen/settings/DimensionGeneratorSettings.java -@@ -192,7 +_,7 @@ - String s3 = (String)p_242753_1_.get("level-type"); - String s4 = Optional.ofNullable(s3).map((p_236217_0_) -> { - return p_236217_0_.toLowerCase(Locale.ROOT); -- }).orElse("default"); -+ }).orElseGet(net.minecraftforge.common.ForgeHooks::getDefaultWorldType); - p_242753_1_.put("level-type", s4); - long i = (new Random()).nextLong(); - if (!s1.isEmpty()) { -@@ -210,6 +_,8 @@ - Registry registry = p_242753_0_.func_243612_b(Registry.field_239720_u_); - Registry registry1 = p_242753_0_.func_243612_b(Registry.field_243549_ar); - SimpleRegistry simpleregistry = DimensionType.func_242718_a(registry2, registry, registry1, i); -+ net.minecraftforge.common.world.ForgeWorldType type = net.minecraftforge.registries.ForgeRegistries.WORLD_TYPES.getValue(new net.minecraft.util.ResourceLocation(s4)); -+ if (type != null) return type.createSettings(p_242753_0_, i, flag, false, s); - switch(s4) { - case "flat": - JsonObject jsonobject = !s.isEmpty() ? JSONUtils.func_212745_a(s) : new JsonObject(); diff --git a/patches/minecraft/net/minecraft/world/gen/surfacebuilders/SurfaceBuilder.java.patch b/patches/minecraft/net/minecraft/world/gen/surfacebuilders/SurfaceBuilder.java.patch deleted file mode 100644 index 4ad336ae6e..0000000000 --- a/patches/minecraft/net/minecraft/world/gen/surfacebuilders/SurfaceBuilder.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/gen/surfacebuilders/SurfaceBuilder.java -+++ b/net/minecraft/world/gen/surfacebuilders/SurfaceBuilder.java -@@ -8,7 +_,7 @@ - import net.minecraft.world.biome.Biome; - import net.minecraft.world.chunk.IChunk; - --public abstract class SurfaceBuilder { -+public abstract class SurfaceBuilder extends net.minecraftforge.registries.ForgeRegistryEntry> { - private static final BlockState field_215410_g = Blocks.field_150346_d.func_176223_P(); - private static final BlockState field_215411_h = Blocks.field_196658_i.func_176223_P(); - private static final BlockState field_215412_i = Blocks.field_196661_l.func_176223_P(); diff --git a/patches/minecraft/net/minecraft/world/gen/treedecorator/TreeDecoratorType.java.patch b/patches/minecraft/net/minecraft/world/gen/treedecorator/TreeDecoratorType.java.patch deleted file mode 100644 index 13d6687c1f..0000000000 --- a/patches/minecraft/net/minecraft/world/gen/treedecorator/TreeDecoratorType.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/gen/treedecorator/TreeDecoratorType.java -+++ b/net/minecraft/world/gen/treedecorator/TreeDecoratorType.java -@@ -3,7 +_,7 @@ - import com.mojang.serialization.Codec; - import net.minecraft.util.registry.Registry; - --public class TreeDecoratorType

{ -+public class TreeDecoratorType

extends net.minecraftforge.registries.ForgeRegistryEntry> { - public static final TreeDecoratorType field_227425_a_ = func_236877_a_("trunk_vine", TrunkVineTreeDecorator.field_236878_a_); - public static final TreeDecoratorType field_227426_b_ = func_236877_a_("leave_vine", LeaveVineTreeDecorator.field_236870_a_); - public static final TreeDecoratorType field_227427_c_ = func_236877_a_("cocoa", CocoaTreeDecorator.field_236866_a_); diff --git a/patches/minecraft/net/minecraft/world/inventory/AbstractContainerMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/AbstractContainerMenu.java.patch new file mode 100644 index 0000000000..e61619fa6a --- /dev/null +++ b/patches/minecraft/net/minecraft/world/inventory/AbstractContainerMenu.java.patch @@ -0,0 +1,43 @@ +--- a/net/minecraft/world/inventory/AbstractContainerMenu.java ++++ b/net/minecraft/world/inventory/AbstractContainerMenu.java +@@ -204,9 +_,11 @@ + private void m_150407_(int p_150408_, ItemStack p_150409_, Supplier p_150410_) { + ItemStack itemstack = this.f_38841_.get(p_150408_); + if (!ItemStack.m_41728_(itemstack, p_150409_)) { ++ boolean clientStackChanged = !p_150409_.equals(itemstack, true); + ItemStack itemstack1 = p_150410_.get(); + this.f_38841_.set(p_150408_, itemstack1); + ++ if(clientStackChanged) + for(ContainerListener containerlistener : this.f_38848_) { + containerlistener.m_7934_(this, p_150408_, itemstack1); + } +@@ -592,14 +_,15 @@ + ItemStack itemstack = slot.m_7993_(); + if (!itemstack.m_41619_() && ItemStack.m_150942_(p_38904_, itemstack)) { + int j = itemstack.m_41613_() + p_38904_.m_41613_(); +- if (j <= p_38904_.m_41741_()) { ++ int maxSize = Math.min(slot.m_6641_(), p_38904_.m_41741_()); ++ if (j <= maxSize) { + p_38904_.m_41764_(0); + itemstack.m_41764_(j); + slot.m_6654_(); + flag = true; +- } else if (itemstack.m_41613_() < p_38904_.m_41741_()) { +- p_38904_.m_41774_(p_38904_.m_41741_() - itemstack.m_41613_()); +- itemstack.m_41764_(p_38904_.m_41741_()); ++ } else if (itemstack.m_41613_() < maxSize) { ++ p_38904_.m_41774_(maxSize - itemstack.m_41613_()); ++ itemstack.m_41764_(maxSize); + slot.m_6654_(); + flag = true; + } +@@ -699,7 +_,7 @@ + p_38925_.m_41764_(1); + break; + case 2: +- p_38925_.m_41764_(p_38925_.m_41720_().m_41459_()); ++ p_38925_.m_41764_(p_38925_.m_41741_()); + } + + p_38925_.m_41769_(p_38926_); diff --git a/patches/minecraft/net/minecraft/world/inventory/AbstractFurnaceMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/AbstractFurnaceMenu.java.patch new file mode 100644 index 0000000000..f2fd063093 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/inventory/AbstractFurnaceMenu.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/inventory/AbstractFurnaceMenu.java ++++ b/net/minecraft/world/inventory/AbstractFurnaceMenu.java +@@ -147,7 +_,7 @@ + } + + protected boolean m_38988_(ItemStack p_38989_) { +- return AbstractFurnaceBlockEntity.m_58399_(p_38989_); ++ return net.minecraftforge.common.ForgeHooks.getBurnTime(p_38989_, this.f_38957_) > 0; + } + + public int m_38995_() { diff --git a/patches/minecraft/net/minecraft/world/inventory/AnvilMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/AnvilMenu.java.patch new file mode 100644 index 0000000000..b0e0e1a137 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/inventory/AnvilMenu.java.patch @@ -0,0 +1,51 @@ +--- a/net/minecraft/world/inventory/AnvilMenu.java ++++ b/net/minecraft/world/inventory/AnvilMenu.java +@@ -53,6 +_,8 @@ + p_150474_.m_6749_(-this.f_39002_.m_6501_()); + } + ++ float breakChance = net.minecraftforge.common.ForgeHooks.onAnvilRepair(p_150474_, p_150475_, AnvilMenu.this.f_39769_.m_8020_(0), AnvilMenu.this.f_39769_.m_8020_(1)); ++ + this.f_39769_.m_6836_(0, ItemStack.f_41583_); + if (this.f_39000_ > 0) { + ItemStack itemstack = this.f_39769_.m_8020_(1); +@@ -69,7 +_,7 @@ + this.f_39002_.m_6422_(0); + this.f_39770_.m_39292_((p_150479_, p_150480_) -> { + BlockState blockstate = p_150479_.m_8055_(p_150480_); +- if (!p_150474_.m_150110_().f_35937_ && blockstate.m_60620_(BlockTags.f_13033_) && p_150474_.m_21187_().nextFloat() < 0.12F) { ++ if (!p_150474_.m_150110_().f_35937_ && blockstate.m_60620_(BlockTags.f_13033_) && p_150474_.m_21187_().nextFloat() < breakChance) { + BlockState blockstate1 = AnvilBlock.m_48824_(blockstate); + if (blockstate1 == null) { + p_150479_.m_7471_(p_150480_, false); +@@ -100,8 +_,11 @@ + Map map = EnchantmentHelper.m_44831_(itemstack1); + j = j + itemstack.m_41610_() + (itemstack2.m_41619_() ? 0 : itemstack2.m_41610_()); + this.f_39000_ = 0; ++ boolean flag = false; ++ + if (!itemstack2.m_41619_()) { +- boolean flag = itemstack2.m_150930_(Items.f_42690_) && !EnchantedBookItem.m_41163_(itemstack2).isEmpty(); ++ if (!net.minecraftforge.common.ForgeHooks.onAnvilChange(this, itemstack, itemstack2, f_39768_, f_39001_, j, this.f_39771_)) return; ++ flag = itemstack2.m_41720_() == Items.f_42690_ && !EnchantedBookItem.m_41163_(itemstack2).isEmpty(); + if (itemstack1.m_41763_() && itemstack1.m_41720_().m_6832_(itemstack, itemstack2)) { + int l2 = Math.min(itemstack1.m_41773_(), itemstack1.m_41776_() / 4); + if (l2 <= 0) { +@@ -218,6 +_,7 @@ + i += k; + itemstack1.m_41714_(new TextComponent(this.f_39001_)); + } ++ if (flag && !itemstack1.isBookEnchantable(itemstack2)) itemstack1 = ItemStack.f_41583_; + + this.f_39002_.m_6422_(j + i); + if (i <= 0) { +@@ -271,5 +_,9 @@ + + public int m_39028_() { + return this.f_39002_.m_6501_(); ++ } ++ ++ public void setMaximumCost(int value) { ++ this.f_39002_.m_6422_(value); + } + } diff --git a/patches/minecraft/net/minecraft/world/inventory/BeaconMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/BeaconMenu.java.patch new file mode 100644 index 0000000000..6a0d8ebe96 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/inventory/BeaconMenu.java.patch @@ -0,0 +1,15 @@ +--- a/net/minecraft/world/inventory/BeaconMenu.java ++++ b/net/minecraft/world/inventory/BeaconMenu.java +@@ -89,10 +_,8 @@ + } + + slot.m_40234_(itemstack1, itemstack); +- } else if (!this.f_39032_.m_6657_() && this.f_39032_.m_5857_(itemstack1) && itemstack1.m_41613_() == 1) { +- if (!this.m_38903_(itemstack1, 0, 1, false)) { +- return ItemStack.f_41583_; +- } ++ } else if (this.m_38903_(itemstack1, 0, 1, false)) { //Forge Fix Shift Clicking in beacons with stacks larger then 1. ++ return ItemStack.f_41583_; + } else if (p_39052_ >= 1 && p_39052_ < 28) { + if (!this.m_38903_(itemstack1, 28, 37, false)) { + return ItemStack.f_41583_; diff --git a/patches/minecraft/net/minecraft/world/inventory/BrewingStandMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/BrewingStandMenu.java.patch new file mode 100644 index 0000000000..b87a68b1cf --- /dev/null +++ b/patches/minecraft/net/minecraft/world/inventory/BrewingStandMenu.java.patch @@ -0,0 +1,28 @@ +--- a/net/minecraft/world/inventory/BrewingStandMenu.java ++++ b/net/minecraft/world/inventory/BrewingStandMenu.java +@@ -146,7 +_,7 @@ + } + + public boolean m_5857_(ItemStack p_39121_) { +- return PotionBrewing.m_43506_(p_39121_); ++ return net.minecraftforge.common.brewing.BrewingRecipeRegistry.isValidIngredient(p_39121_); + } + + public int m_6641_() { +@@ -170,6 +_,7 @@ + public void m_142406_(Player p_150499_, ItemStack p_150500_) { + Potion potion = PotionUtils.m_43579_(p_150500_); + if (p_150499_ instanceof ServerPlayer) { ++ net.minecraftforge.event.ForgeEventFactory.onPlayerBrewedPotion(p_150499_, p_150500_); + CriteriaTriggers.f_10577_.m_19120_((ServerPlayer)p_150499_, potion); + } + +@@ -177,7 +_,7 @@ + } + + public static boolean m_39133_(ItemStack p_39134_) { +- return p_39134_.m_150930_(Items.f_42589_) || p_39134_.m_150930_(Items.f_42736_) || p_39134_.m_150930_(Items.f_42739_) || p_39134_.m_150930_(Items.f_42590_); ++ return net.minecraftforge.common.brewing.BrewingRecipeRegistry.isValidInput(p_39134_); + } + } + } diff --git a/patches/minecraft/net/minecraft/world/inventory/EnchantmentMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/EnchantmentMenu.java.patch new file mode 100644 index 0000000000..79836f5fc9 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/inventory/EnchantmentMenu.java.patch @@ -0,0 +1,78 @@ +--- a/net/minecraft/world/inventory/EnchantmentMenu.java ++++ b/net/minecraft/world/inventory/EnchantmentMenu.java +@@ -52,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 net.minecraftforge.common.Tags.Items.GEMS_LAPIS.m_8110_(p_39517_.m_41720_()); + } + }); + +@@ -78,40 +_,28 @@ + this.m_38895_(DataSlot.m_39406_(this.f_39448_, 2)); + } + ++ private float getPower(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos) { ++ return world.m_8055_(pos).getEnchantPowerBonus(world, pos); ++ } ++ + public void m_6199_(Container p_39461_) { + if (p_39461_ == this.f_39449_) { + ItemStack itemstack = p_39461_.m_8020_(0); + if (!itemstack.m_41619_() && itemstack.m_41792_()) { + this.f_39450_.m_39292_((p_39485_, p_39486_) -> { +- int j = 0; ++ int power = 0; + + for(int k = -1; k <= 1; ++k) { + for(int l = -1; l <= 1; ++l) { + if ((k != 0 || l != 0) && p_39485_.m_46859_(p_39486_.m_142082_(l, 0, k)) && p_39485_.m_46859_(p_39486_.m_142082_(l, 1, k))) { +- if (p_39485_.m_8055_(p_39486_.m_142082_(l * 2, 0, k * 2)).m_60713_(Blocks.f_50078_)) { +- ++j; +- } +- +- if (p_39485_.m_8055_(p_39486_.m_142082_(l * 2, 1, k * 2)).m_60713_(Blocks.f_50078_)) { +- ++j; +- } ++ power += getPower(p_39485_, p_39486_.m_142082_(l * 2, 0, k * 2)); ++ power += getPower(p_39485_, p_39486_.m_142082_(l * 2, 1, k * 2)); + + if (l != 0 && k != 0) { +- if (p_39485_.m_8055_(p_39486_.m_142082_(l * 2, 0, k)).m_60713_(Blocks.f_50078_)) { +- ++j; +- } +- +- if (p_39485_.m_8055_(p_39486_.m_142082_(l * 2, 1, k)).m_60713_(Blocks.f_50078_)) { +- ++j; +- } +- +- if (p_39485_.m_8055_(p_39486_.m_142082_(l, 0, k * 2)).m_60713_(Blocks.f_50078_)) { +- ++j; +- } +- +- if (p_39485_.m_8055_(p_39486_.m_142082_(l, 1, k * 2)).m_60713_(Blocks.f_50078_)) { +- ++j; +- } ++ power += getPower(p_39485_, p_39486_.m_142082_(l * 2, 0, k)); ++ power += getPower(p_39485_, p_39486_.m_142082_(l * 2, 1, k)); ++ power += getPower(p_39485_, p_39486_.m_142082_(l, 0, k * 2)); ++ power += getPower(p_39485_, p_39486_.m_142082_(l, 1, k * 2)); + } + } + } +@@ -120,12 +_,13 @@ + this.f_39451_.setSeed((long)this.f_39452_.m_6501_()); + + for(int i1 = 0; i1 < 3; ++i1) { +- this.f_39446_[i1] = EnchantmentHelper.m_44872_(this.f_39451_, i1, j, itemstack); ++ this.f_39446_[i1] = EnchantmentHelper.m_44872_(this.f_39451_, i1, (int)power, itemstack); + this.f_39447_[i1] = -1; + this.f_39448_[i1] = -1; + if (this.f_39446_[i1] < i1 + 1) { + this.f_39446_[i1] = 0; + } ++ this.f_39446_[i1] = net.minecraftforge.event.ForgeEventFactory.onEnchantmentLevelSet(p_39485_, p_39486_, i1, (int)power, itemstack, f_39446_[i1]); + } + + for(int j1 = 0; j1 < 3; ++j1) { diff --git a/patches/minecraft/net/minecraft/world/inventory/FurnaceResultSlot.java.patch b/patches/minecraft/net/minecraft/world/inventory/FurnaceResultSlot.java.patch new file mode 100644 index 0000000000..f7c25e4c84 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/inventory/FurnaceResultSlot.java.patch @@ -0,0 +1,9 @@ +--- a/net/minecraft/world/inventory/FurnaceResultSlot.java ++++ b/net/minecraft/world/inventory/FurnaceResultSlot.java +@@ -44,5 +_,6 @@ + } + + this.f_39540_ = 0; ++ net.minecraftforge.fmllegacy.hooks.BasicEventHooks.firePlayerSmeltedEvent(this.f_39539_, p_39558_); + } + } diff --git a/patches/minecraft/net/minecraft/world/inventory/GrindstoneMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/GrindstoneMenu.java.patch new file mode 100644 index 0000000000..50f0698196 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/inventory/GrindstoneMenu.java.patch @@ -0,0 +1,21 @@ +--- a/net/minecraft/world/inventory/GrindstoneMenu.java ++++ b/net/minecraft/world/inventory/GrindstoneMenu.java +@@ -144,12 +_,13 @@ + } + + Item item = itemstack.m_41720_(); +- int k = item.m_41462_() - itemstack.m_41773_(); +- int l = item.m_41462_() - itemstack1.m_41773_(); +- int i1 = k + l + item.m_41462_() * 5 / 100; +- i = Math.max(item.m_41462_() - i1, 0); ++ int k = itemstack.m_41776_() - itemstack.m_41773_(); ++ int l = itemstack.m_41776_() - itemstack1.m_41773_(); ++ int i1 = k + l + itemstack.m_41776_() * 5 / 100; ++ i = Math.max(itemstack.m_41776_() - i1, 0); + itemstack2 = this.m_39590_(itemstack, itemstack1); +- if (!itemstack2.m_41763_()) { ++ if (!itemstack2.isRepairable()) i = itemstack.m_41773_(); ++ if (!itemstack2.m_41763_() || !itemstack2.isRepairable()) { + if (!ItemStack.m_41728_(itemstack, itemstack1)) { + this.f_39559_.m_6836_(0, ItemStack.f_41583_); + this.m_38946_(); diff --git a/patches/minecraft/net/minecraft/world/inventory/InventoryMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/InventoryMenu.java.patch new file mode 100644 index 0000000000..6eae97fcad --- /dev/null +++ b/patches/minecraft/net/minecraft/world/inventory/InventoryMenu.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/inventory/InventoryMenu.java ++++ b/net/minecraft/world/inventory/InventoryMenu.java +@@ -57,7 +_,7 @@ + } + + public boolean m_5857_(ItemStack p_39746_) { +- return equipmentslot == Mob.m_147233_(p_39746_); ++ return p_39746_.canEquip(equipmentslot, f_39703_); + } + + public boolean m_8010_(Player p_39744_) { diff --git a/patches/minecraft/net/minecraft/world/inventory/MenuType.java.patch b/patches/minecraft/net/minecraft/world/inventory/MenuType.java.patch new file mode 100644 index 0000000000..14c3c0923a --- /dev/null +++ b/patches/minecraft/net/minecraft/world/inventory/MenuType.java.patch @@ -0,0 +1,26 @@ +--- a/net/minecraft/world/inventory/MenuType.java ++++ b/net/minecraft/world/inventory/MenuType.java +@@ -3,7 +_,7 @@ + import net.minecraft.core.Registry; + import net.minecraft.world.entity.player.Inventory; + +-public class MenuType { ++public class MenuType extends net.minecraftforge.registries.ForgeRegistryEntry> implements net.minecraftforge.common.extensions.IForgeContainerType { + public static final MenuType f_39957_ = m_39988_("generic_9x1", ChestMenu::m_39234_); + public static final MenuType f_39958_ = m_39988_("generic_9x2", ChestMenu::m_39243_); + public static final MenuType f_39959_ = m_39988_("generic_9x3", ChestMenu::m_39255_); +@@ -42,6 +_,14 @@ + + public T m_39985_(int p_39986_, Inventory p_39987_) { + return this.f_39981_.m_39994_(p_39986_, p_39987_); ++ } ++ ++ @Override ++ public T create(int windowId, Inventory playerInv, net.minecraft.network.FriendlyByteBuf extraData) { ++ if (this.f_39981_ instanceof net.minecraftforge.fmllegacy.network.IContainerFactory) { ++ return ((net.minecraftforge.fmllegacy.network.IContainerFactory) this.f_39981_).create(windowId, playerInv, extraData); ++ } ++ return m_39985_(windowId, playerInv); + } + + public interface MenuSupplier { diff --git a/patches/minecraft/net/minecraft/world/inventory/RecipeBookMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/RecipeBookMenu.java.patch new file mode 100644 index 0000000000..aaee4a35e1 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/inventory/RecipeBookMenu.java.patch @@ -0,0 +1,13 @@ +--- a/net/minecraft/world/inventory/RecipeBookMenu.java ++++ b/net/minecraft/world/inventory/RecipeBookMenu.java +@@ -29,6 +_,10 @@ + + public abstract int m_6653_(); + ++ public java.util.List getRecipeBookCategories() { ++ return net.minecraft.client.RecipeBookCategories.m_92269_(this.m_5867_()); ++ } ++ + public abstract RecipeBookType m_5867_(); + + public abstract boolean m_142157_(int p_150635_); diff --git a/patches/minecraft/net/minecraft/world/inventory/ResultSlot.java.patch b/patches/minecraft/net/minecraft/world/inventory/ResultSlot.java.patch new file mode 100644 index 0000000000..4f2d48e8c5 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/inventory/ResultSlot.java.patch @@ -0,0 +1,21 @@ +--- a/net/minecraft/world/inventory/ResultSlot.java ++++ b/net/minecraft/world/inventory/ResultSlot.java +@@ -41,6 +_,7 @@ + protected void m_5845_(ItemStack p_40185_) { + if (this.f_40164_ > 0) { + p_40185_.m_41678_(this.f_40163_.f_19853_, this.f_40163_, this.f_40164_); ++ net.minecraftforge.fmllegacy.hooks.BasicEventHooks.firePlayerCraftingEvent(this.f_40163_, p_40185_, this.f_40162_); + } + + if (this.f_40218_ instanceof RecipeHolder) { +@@ -52,8 +_,9 @@ + + public void m_142406_(Player p_150638_, ItemStack p_150639_) { + this.m_5845_(p_150639_); ++ net.minecraftforge.common.ForgeHooks.setCraftingPlayer(p_150638_); + NonNullList nonnulllist = p_150638_.f_19853_.m_7465_().m_44069_(RecipeType.f_44107_, this.f_40162_, p_150638_.f_19853_); +- ++ net.minecraftforge.common.ForgeHooks.setCraftingPlayer(null); + for(int i = 0; i < nonnulllist.size(); ++i) { + ItemStack itemstack = this.f_40162_.m_8020_(i); + ItemStack itemstack1 = nonnulllist.get(i); diff --git a/patches/minecraft/net/minecraft/inventory/container/Slot.java.patch b/patches/minecraft/net/minecraft/world/inventory/Slot.java.patch similarity index 70% rename from patches/minecraft/net/minecraft/inventory/container/Slot.java.patch rename to patches/minecraft/net/minecraft/world/inventory/Slot.java.patch index f59906d78b..f17ee17df1 100644 --- a/patches/minecraft/net/minecraft/inventory/container/Slot.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/Slot.java.patch @@ -1,17 +1,17 @@ ---- a/net/minecraft/inventory/container/Slot.java -+++ b/net/minecraft/inventory/container/Slot.java -@@ -77,7 +_,7 @@ +--- a/net/minecraft/world/inventory/Slot.java ++++ b/net/minecraft/world/inventory/Slot.java +@@ -74,7 +_,7 @@ + @Nullable - @OnlyIn(Dist.CLIENT) - public Pair func_225517_c_() { + public Pair m_7543_() { - return null; + return backgroundPair; } - public ItemStack func_75209_a(int p_75209_1_) { -@@ -91,5 +_,37 @@ - @OnlyIn(Dist.CLIENT) - public boolean func_111238_b() { + public ItemStack m_6201_(int p_40227_) { +@@ -87,6 +_,38 @@ + + public boolean m_6659_() { return true; + } + @@ -22,7 +22,7 @@ + * @return Index in associated inventory for this slot. + */ + public int getSlotIndex() { -+ return field_75225_a; ++ return f_40217_; + } + + /** @@ -31,7 +31,7 @@ + * @return true if the other slot is in the same inventory + */ + public boolean isSameInventory(Slot other) { -+ return this.field_75224_c == other.field_75224_c; ++ return this.f_40218_ == other.f_40218_; + } + + private Pair backgroundPair; @@ -46,4 +46,5 @@ + this.backgroundPair = Pair.of(atlas, sprite); + return this; } - } + + public Optional m_150641_(int p_150642_, int p_150643_, Player p_150644_) { diff --git a/patches/minecraft/net/minecraft/world/item/ArmorItem.java.patch b/patches/minecraft/net/minecraft/world/item/ArmorItem.java.patch new file mode 100644 index 0000000000..cafce0b3aa --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/ArmorItem.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/item/ArmorItem.java ++++ b/net/minecraft/world/item/ArmorItem.java +@@ -71,7 +_,7 @@ + UUID uuid = f_40380_[p_40387_.m_20749_()]; + builder.put(Attributes.f_22284_, new AttributeModifier(uuid, "Armor modifier", (double)this.f_40381_, AttributeModifier.Operation.ADDITION)); + builder.put(Attributes.f_22285_, new AttributeModifier(uuid, "Armor toughness", (double)this.f_40382_, AttributeModifier.Operation.ADDITION)); +- if (p_40386_ == ArmorMaterials.NETHERITE) { ++ if (this.f_40378_ > 0) { + builder.put(Attributes.f_22278_, new AttributeModifier(uuid, "Armor knockback resistance", (double)this.f_40378_, AttributeModifier.Operation.ADDITION)); + } + diff --git a/patches/minecraft/net/minecraft/world/item/ArrowItem.java.patch b/patches/minecraft/net/minecraft/world/item/ArrowItem.java.patch new file mode 100644 index 0000000000..20d8edb167 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/ArrowItem.java.patch @@ -0,0 +1,12 @@ +--- a/net/minecraft/world/item/ArrowItem.java ++++ b/net/minecraft/world/item/ArrowItem.java +@@ -15,4 +_,9 @@ + arrow.m_36878_(p_40514_); + return arrow; + } ++ ++ public boolean isInfinite(ItemStack stack, ItemStack bow, net.minecraft.world.entity.player.Player player) { ++ int enchant = net.minecraft.world.item.enchantment.EnchantmentHelper.m_44843_(net.minecraft.world.item.enchantment.Enchantments.f_44952_, bow); ++ return enchant <= 0 ? false : this.getClass() == ArrowItem.class; ++ } + } diff --git a/patches/minecraft/net/minecraft/world/item/AxeItem.java.patch b/patches/minecraft/net/minecraft/world/item/AxeItem.java.patch new file mode 100644 index 0000000000..66579b4f0d --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/AxeItem.java.patch @@ -0,0 +1,33 @@ +--- a/net/minecraft/world/item/AxeItem.java ++++ b/net/minecraft/world/item/AxeItem.java +@@ -23,7 +_,7 @@ + protected static final Map f_150683_ = (new Builder()).put(Blocks.f_50011_, Blocks.f_50044_).put(Blocks.f_49999_, Blocks.f_50010_).put(Blocks.f_50043_, Blocks.f_50049_).put(Blocks.f_50004_, Blocks.f_50009_).put(Blocks.f_50015_, Blocks.f_50048_).put(Blocks.f_50003_, Blocks.f_50008_).put(Blocks.f_50013_, Blocks.f_50046_).put(Blocks.f_50001_, Blocks.f_50006_).put(Blocks.f_50014_, Blocks.f_50047_).put(Blocks.f_50002_, Blocks.f_50007_).put(Blocks.f_50012_, Blocks.f_50045_).put(Blocks.f_50000_, Blocks.f_50005_).put(Blocks.f_50686_, Blocks.f_50687_).put(Blocks.f_50688_, Blocks.f_50689_).put(Blocks.f_50695_, Blocks.f_50696_).put(Blocks.f_50697_, Blocks.f_50698_).build(); + + public AxeItem(Tier p_40521_, float p_40522_, float p_40523_, Item.Properties p_40524_) { +- super(p_40522_, p_40523_, p_40521_, BlockTags.f_144280_, p_40524_); ++ super(p_40522_, p_40523_, p_40521_, BlockTags.f_144280_, p_40524_.addToolType(net.minecraftforge.common.ToolType.AXE, p_40521_.m_6604_())); + } + + public InteractionResult m_6225_(UseOnContext p_40529_) { +@@ -31,7 +_,7 @@ + BlockPos blockpos = p_40529_.m_8083_(); + Player player = p_40529_.m_43723_(); + BlockState blockstate = level.m_8055_(blockpos); +- Optional optional = this.m_150690_(blockstate); ++ Optional optional = Optional.ofNullable(blockstate.getToolModifiedState(level, blockpos, player, p_40529_.m_43722_(), net.minecraftforge.common.ToolType.AXE)); + Optional optional1 = WeatheringCopper.m_154899_(blockstate); + Optional optional2 = Optional.ofNullable(HoneycombItem.f_150864_.get().get(blockstate.m_60734_())).map((p_150694_) -> { + return p_150694_.m_152465_(blockstate); +@@ -67,6 +_,12 @@ + } else { + return InteractionResult.PASS; + } ++ } ++ ++ @javax.annotation.Nullable ++ public static BlockState getAxeStrippingState(BlockState originalState) { ++ Block block = f_150683_.get(originalState.m_60734_()); ++ return block != null ? block.m_49966_().m_61124_(RotatedPillarBlock.f_55923_, originalState.m_61143_(RotatedPillarBlock.f_55923_)) : null; + } + + private Optional m_150690_(BlockState p_150691_) { diff --git a/patches/minecraft/net/minecraft/world/item/BlockItem.java.patch b/patches/minecraft/net/minecraft/world/item/BlockItem.java.patch new file mode 100644 index 0000000000..71cacf8c35 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/BlockItem.java.patch @@ -0,0 +1,51 @@ +--- a/net/minecraft/world/item/BlockItem.java ++++ b/net/minecraft/world/item/BlockItem.java +@@ -78,9 +_,9 @@ + } + } + +- SoundType soundtype = blockstate1.m_60827_(); +- level.m_5594_(player, blockpos, this.m_40587_(blockstate1), SoundSource.BLOCKS, (soundtype.m_56773_() + 1.0F) / 2.0F, soundtype.m_56774_() * 0.8F); + level.m_142346_(player, GameEvent.f_157797_, blockpos); ++ SoundType soundtype = blockstate1.getSoundType(level, blockpos, p_40577_.m_43723_()); ++ level.m_5594_(player, blockpos, this.getPlaceSound(blockstate1, level, blockpos, p_40577_.m_43723_()), SoundSource.BLOCKS, (soundtype.m_56773_() + 1.0F) / 2.0F, soundtype.m_56774_() * 0.8F); + if (player == null || !player.m_150110_().f_35937_) { + itemstack.m_41774_(1); + } +@@ -91,10 +_,16 @@ + } + } + ++ @Deprecated //Forge: Use more sensitive version {@link BlockItem#getPlaceSound(BlockState, IBlockReader, BlockPos, Entity) } + protected SoundEvent m_40587_(BlockState p_40588_) { + return p_40588_.m_60827_().m_56777_(); + } + ++ //Forge: Sensitive version of BlockItem#getPlaceSound ++ protected SoundEvent getPlaceSound(BlockState state, Level world, BlockPos pos, Player entity) { ++ return state.getSoundType(world, pos, entity).m_56777_(); ++ } ++ + @Nullable + public BlockPlaceContext m_7732_(BlockPlaceContext p_40609_) { + return p_40609_; +@@ -201,11 +_,19 @@ + } + + public Block m_40614_() { ++ return this.getBlockRaw() == null ? null : this.getBlockRaw().delegate.get(); ++ } ++ ++ private Block getBlockRaw() { + return this.f_40563_; + } + + public void m_6192_(Map p_40607_, Item p_40608_) { + p_40607_.put(this.m_40614_(), p_40608_); ++ } ++ ++ public void removeFromBlockToItemMap(Map blockToItemMap, Item itemIn) { ++ blockToItemMap.remove(this.m_40614_()); + } + + public boolean m_142095_() { diff --git a/patches/minecraft/net/minecraft/world/item/BoneMealItem.java.patch b/patches/minecraft/net/minecraft/world/item/BoneMealItem.java.patch new file mode 100644 index 0000000000..fbe8f04505 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/BoneMealItem.java.patch @@ -0,0 +1,29 @@ +--- a/net/minecraft/world/item/BoneMealItem.java ++++ b/net/minecraft/world/item/BoneMealItem.java +@@ -34,7 +_,7 @@ + Level level = p_40637_.m_43725_(); + BlockPos blockpos = p_40637_.m_8083_(); + BlockPos blockpos1 = blockpos.m_142300_(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_) { + level.m_46796_(1505, blockpos, 0); + } +@@ -55,8 +_,17 @@ + } + } + ++ @Deprecated //Forge: Use Player/Hand version + public static boolean m_40627_(ItemStack p_40628_, Level p_40629_, BlockPos p_40630_) { ++ if (p_40629_ instanceof net.minecraft.server.level.ServerLevel) ++ return applyBonemeal(p_40628_, p_40629_, p_40630_, net.minecraftforge.common.util.FakePlayerFactory.getMinecraft((net.minecraft.server.level.ServerLevel)p_40629_)); ++ return false; ++ } ++ ++ public static boolean applyBonemeal(ItemStack p_40628_, Level p_40629_, BlockPos p_40630_, net.minecraft.world.entity.player.Player player) { + 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_)) { diff --git a/patches/minecraft/net/minecraft/world/item/BowItem.java.patch b/patches/minecraft/net/minecraft/world/item/BowItem.java.patch new file mode 100644 index 0000000000..63ea0f6035 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/BowItem.java.patch @@ -0,0 +1,50 @@ +--- a/net/minecraft/world/item/BowItem.java ++++ b/net/minecraft/world/item/BowItem.java +@@ -26,18 +_,23 @@ + Player player = (Player)p_40669_; + boolean flag = player.m_150110_().f_35937_ || EnchantmentHelper.m_44843_(Enchantments.f_44952_, p_40667_) > 0; + ItemStack itemstack = player.m_6298_(p_40667_); ++ ++ int i = this.m_8105_(p_40667_) - p_40670_; ++ i = net.minecraftforge.event.ForgeEventFactory.onArrowLoose(p_40667_, p_40668_, player, i, !itemstack.m_41619_() || flag); ++ if (i < 0) return; ++ + if (!itemstack.m_41619_() || flag) { + if (itemstack.m_41619_()) { + itemstack = new ItemStack(Items.f_42412_); + } + +- int i = this.m_8105_(p_40667_) - p_40670_; + float f = m_40661_(i); + if (!((double)f < 0.1D)) { +- boolean flag1 = flag && itemstack.m_150930_(Items.f_42412_); ++ boolean flag1 = player.m_150110_().f_35937_ || (itemstack.m_41720_() instanceof ArrowItem && ((ArrowItem)itemstack.m_41720_()).isInfinite(itemstack, p_40667_, player)); + if (!p_40668_.f_46443_) { + ArrowItem arrowitem = (ArrowItem)(itemstack.m_41720_() instanceof ArrowItem ? itemstack.m_41720_() : Items.f_42412_); + AbstractArrow abstractarrow = arrowitem.m_6394_(p_40668_, itemstack, player); ++ abstractarrow = customArrow(abstractarrow); + abstractarrow.m_37251_(player, player.m_146909_(), player.m_146908_(), 0.0F, f * 3.0F, 1.0F); + if (f == 1.0F) { + abstractarrow.m_36762_(true); +@@ -102,6 +_,10 @@ + public InteractionResultHolder m_7203_(Level p_40672_, Player p_40673_, InteractionHand p_40674_) { + ItemStack itemstack = p_40673_.m_21120_(p_40674_); + boolean flag = !p_40673_.m_6298_(itemstack).m_41619_(); ++ ++ InteractionResultHolder ret = net.minecraftforge.event.ForgeEventFactory.onArrowNock(itemstack, p_40672_, p_40673_, p_40674_, flag); ++ if (ret != null) return ret; ++ + if (!p_40673_.m_150110_().f_35937_ && !flag) { + return InteractionResultHolder.m_19100_(itemstack); + } else { +@@ -112,6 +_,10 @@ + + public Predicate m_6437_() { + return f_43005_; ++ } ++ ++ public AbstractArrow customArrow(AbstractArrow arrow) { ++ return arrow; + } + + public int m_6615_() { diff --git a/patches/minecraft/net/minecraft/world/item/BucketItem.java.patch b/patches/minecraft/net/minecraft/world/item/BucketItem.java.patch new file mode 100644 index 0000000000..9f4b2b4a7d --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/BucketItem.java.patch @@ -0,0 +1,76 @@ +--- a/net/minecraft/world/item/BucketItem.java ++++ b/net/minecraft/world/item/BucketItem.java +@@ -32,14 +_,28 @@ + public class BucketItem extends Item implements DispensibleContainerItem { + private final Fluid f_40687_; + ++ // Forge: Use the other constructor that takes a Supplier ++ @Deprecated + public BucketItem(Fluid p_40689_, Item.Properties p_40690_) { + super(p_40690_); + this.f_40687_ = p_40689_; ++ this.fluidSupplier = p_40689_.delegate; ++ } ++ ++ /** ++ * @param supplier A fluid supplier such as {@link net.minecraftforge.fmllegacy.RegistryObject} ++ */ ++ public BucketItem(java.util.function.Supplier supplier, Item.Properties builder) { ++ super(builder); ++ this.f_40687_ = null; ++ this.fluidSupplier = supplier; + } + + public InteractionResultHolder m_7203_(Level p_40703_, Player p_40704_, InteractionHand p_40705_) { + ItemStack itemstack = p_40704_.m_21120_(p_40705_); + BlockHitResult blockhitresult = m_41435_(p_40703_, p_40704_, this.f_40687_ == Fluids.f_76191_ ? ClipContext.Fluid.SOURCE_ONLY : ClipContext.Fluid.NONE); ++ InteractionResultHolder ret = net.minecraftforge.event.ForgeEventFactory.onBucketUse(p_40704_, p_40703_, itemstack, blockhitresult); ++ if (ret != null) return ret; + if (blockhitresult.m_6662_() == HitResult.Type.MISS) { + return InteractionResultHolder.m_19098_(itemstack); + } else if (blockhitresult.m_6662_() != HitResult.Type.BLOCK) { +@@ -72,7 +_,7 @@ + return InteractionResultHolder.m_19100_(itemstack); + } else { + BlockState blockstate = p_40703_.m_8055_(blockpos); +- BlockPos blockpos2 = blockstate.m_60734_() instanceof LiquidBlockContainer && this.f_40687_ == Fluids.f_76193_ ? blockpos : blockpos1; ++ BlockPos blockpos2 = canBlockContainFluid(p_40703_, blockpos, blockstate) ? blockpos : blockpos1; + if (this.m_142073_(p_40704_, p_40703_, blockpos2, blockhitresult)) { + this.m_142131_(p_40704_, p_40703_, itemstack, blockpos2); + if (p_40704_ instanceof ServerPlayer) { +@@ -120,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; +@@ -140,8 +_,25 @@ + } + + protected void m_7718_(@Nullable Player p_40696_, LevelAccessor p_40697_, BlockPos p_40698_) { +- SoundEvent soundevent = this.f_40687_.m_76108_(FluidTags.f_13132_) ? SoundEvents.f_11780_ : SoundEvents.f_11778_; ++ SoundEvent soundevent = this.f_40687_.getAttributes().getEmptySound(); ++ if(soundevent == null) soundevent = this.f_40687_.m_76108_(FluidTags.f_13132_) ? SoundEvents.f_11780_ : SoundEvents.f_11778_; + p_40697_.m_5594_(p_40696_, p_40698_, soundevent, SoundSource.BLOCKS, 1.0F, 1.0F); + p_40697_.m_142346_(p_40696_, GameEvent.f_157769_, p_40698_); ++ } ++ ++ @Override ++ public net.minecraftforge.common.capabilities.ICapabilityProvider initCapabilities(ItemStack stack, @Nullable net.minecraft.nbt.CompoundTag nbt) { ++ if (this.getClass() == BucketItem.class) ++ return new net.minecraftforge.fluids.capability.wrappers.FluidBucketWrapper(stack); ++ else ++ return super.initCapabilities(stack, nbt); ++ } ++ ++ private final java.util.function.Supplier fluidSupplier; ++ public Fluid getFluid() { return fluidSupplier.get(); } ++ ++ private 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_); + } + } diff --git a/patches/minecraft/net/minecraft/world/item/ChorusFruitItem.java.patch b/patches/minecraft/net/minecraft/world/item/ChorusFruitItem.java.patch new file mode 100644 index 0000000000..573926f018 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/ChorusFruitItem.java.patch @@ -0,0 +1,13 @@ +--- a/net/minecraft/world/item/ChorusFruitItem.java ++++ b/net/minecraft/world/item/ChorusFruitItem.java +@@ -30,7 +_,9 @@ + p_40714_.m_8127_(); + } + +- if (p_40714_.m_20984_(d3, d4, d5, true)) { ++ net.minecraftforge.event.entity.EntityTeleportEvent.ChorusFruit event = net.minecraftforge.event.ForgeEventFactory.onChorusFruitTeleport(p_40714_, d3, d4, d5); ++ if (event.isCanceled()) return itemstack; ++ if (p_40714_.m_20984_(event.getTargetX(), event.getTargetY(), event.getTargetZ(), true)) { + SoundEvent soundevent = p_40714_ instanceof Fox ? SoundEvents.f_11953_ : SoundEvents.f_11757_; + p_40713_.m_6263_((Player)null, d0, d1, d2, soundevent, SoundSource.PLAYERS, 1.0F, 1.0F); + p_40714_.m_5496_(soundevent, 1.0F, 1.0F); diff --git a/patches/minecraft/net/minecraft/world/item/CreativeModeTab.java.patch b/patches/minecraft/net/minecraft/world/item/CreativeModeTab.java.patch new file mode 100644 index 0000000000..f4211a5feb --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/CreativeModeTab.java.patch @@ -0,0 +1,129 @@ +--- a/net/minecraft/world/item/CreativeModeTab.java ++++ b/net/minecraft/world/item/CreativeModeTab.java +@@ -85,18 +_,23 @@ + private final String f_40763_; + private final Component f_40764_; + private String f_40765_; ++ @Deprecated + private String f_40766_ = "items.png"; ++ private net.minecraft.resources.ResourceLocation backgroundLocation; + private boolean f_40767_ = true; + private boolean f_40768_ = true; + private EnchantmentCategory[] f_40769_ = new EnchantmentCategory[0]; + private ItemStack f_40770_; + ++ public CreativeModeTab(String label) { ++ this(-1, label); ++ } ++ + public CreativeModeTab(int p_40773_, String p_40774_) { +- this.f_40762_ = p_40773_; + this.f_40763_ = p_40774_; + this.f_40764_ = new TranslatableComponent("itemGroup." + p_40774_); + this.f_40770_ = ItemStack.f_41583_; +- f_40748_[p_40773_] = this; ++ this.f_40762_ = addGroupSafe(p_40773_, this); + } + + public int m_40775_() { +@@ -121,15 +_,28 @@ + + public abstract ItemStack m_6976_(); + ++ /** ++ * @deprecated Forge use {@link #getBackgroundImage()} instead ++ */ ++ @Deprecated + public String m_40788_() { + return this.f_40766_; + } + ++ /** ++ * @deprecated Forge: use {@link #setBackgroundImage(net.minecraft.resources.ResourceLocation)} instead ++ */ ++ @Deprecated + public CreativeModeTab m_40779_(String p_40780_) { + this.f_40766_ = p_40780_; + return this; + } + ++ public CreativeModeTab setBackgroundImage(net.minecraft.resources.ResourceLocation texture) { ++ this.backgroundLocation = texture; ++ return this; ++ } ++ + public CreativeModeTab m_40784_(String p_40785_) { + this.f_40765_ = p_40785_; + return this; +@@ -154,10 +_,12 @@ + } + + public int m_40793_() { ++ if (f_40762_ > 11) return ((f_40762_ - 12) % 10) % 5; + return this.f_40762_ % 6; + } + + public boolean m_40794_() { ++ if (f_40762_ > 11) return ((f_40762_ - 12) % 10) < 5; + return this.f_40762_ < 6; + } + +@@ -191,5 +_,58 @@ + item.m_6787_(this, p_40778_); + } + ++ } ++ ++ public int getTabPage() { ++ return f_40762_ < 12 ? 0 : ((f_40762_ - 12) / 10) + 1; ++ } ++ ++ public boolean hasSearchBar() { ++ return f_40762_ == f_40754_.f_40762_; ++ } ++ ++ /** ++ * Gets the width of the search bar of the creative tab, use this if your ++ * creative tab name overflows together with a custom texture. ++ * ++ * @return The width of the search bar, 89 by default ++ */ ++ public int getSearchbarWidth() { ++ return 89; ++ } ++ ++ public net.minecraft.resources.ResourceLocation getBackgroundImage() { ++ if (backgroundLocation != null) return backgroundLocation; //FORGE: allow custom namespace ++ return new net.minecraft.resources.ResourceLocation("textures/gui/container/creative_inventory/tab_" + this.m_40788_()); ++ } ++ ++ private static final net.minecraft.resources.ResourceLocation CREATIVE_INVENTORY_TABS = new net.minecraft.resources.ResourceLocation("textures/gui/container/creative_inventory/tabs.png"); ++ public net.minecraft.resources.ResourceLocation getTabsImage() { ++ return CREATIVE_INVENTORY_TABS; ++ } ++ ++ public int getLabelColor() { ++ return 4210752; ++ } ++ ++ public int getSlotColor() { ++ return -2130706433; ++ } ++ ++ public static synchronized int getGroupCountSafe() { ++ return CreativeModeTab.f_40748_.length; ++ } ++ ++ private static synchronized int addGroupSafe(int index, CreativeModeTab newGroup) { ++ if(index == -1) { ++ index = f_40748_.length; ++ } ++ if (index >= f_40748_.length) { ++ CreativeModeTab[] tmp = new CreativeModeTab[index + 1]; ++ System.arraycopy(f_40748_, 0, tmp, 0, f_40748_.length); ++ f_40748_ = tmp; ++ } ++ f_40748_[index] = newGroup; ++ return index; + } + } diff --git a/patches/minecraft/net/minecraft/world/item/DiggerItem.java.patch b/patches/minecraft/net/minecraft/world/item/DiggerItem.java.patch new file mode 100644 index 0000000000..48d99968eb --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/DiggerItem.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/world/item/DiggerItem.java ++++ b/net/minecraft/world/item/DiggerItem.java +@@ -33,6 +_,7 @@ + } + + public float m_8102_(ItemStack p_41004_, BlockState p_41005_) { ++ if (getToolTypes(p_41004_).stream().anyMatch(e -> p_41005_.isToolEffective(e))) return f_40980_; + return this.f_40979_.m_8110_(p_41005_.m_60734_()) ? this.f_40980_ : 1.0F; + } + diff --git a/patches/minecraft/net/minecraft/world/item/DyeColor.java.patch b/patches/minecraft/net/minecraft/world/item/DyeColor.java.patch new file mode 100644 index 0000000000..4738cc5da6 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/DyeColor.java.patch @@ -0,0 +1,41 @@ +--- a/net/minecraft/world/item/DyeColor.java ++++ b/net/minecraft/world/item/DyeColor.java +@@ -39,6 +_,7 @@ + private final MaterialColor f_41036_; + private final float[] f_41039_; + private final int f_41040_; ++ private final net.minecraftforge.common.Tags.IOptionalNamedTag tag; + private final int f_41041_; + + private DyeColor(int p_41046_, String p_41047_, int p_41048_, MaterialColor p_41049_, int p_41050_, int p_41051_) { +@@ -49,6 +_,7 @@ + int i = (p_41048_ & 16711680) >> 16; + int j = (p_41048_ & '\uff00') >> 8; + int k = (p_41048_ & 255) >> 0; ++ this.tag = net.minecraft.tags.ItemTags.createOptional(new net.minecraft.resources.ResourceLocation("forge", "dyes/" + p_41047_)); + this.f_41039_ = new float[]{(float)i / 255.0F, (float)j / 255.0F, (float)k / 255.0F}; + this.f_41040_ = p_41050_; + } +@@ -106,5 +_,22 @@ + + public String m_7912_() { + return this.f_41035_; ++ } ++ ++ public net.minecraftforge.common.Tags.IOptionalNamedTag getTag() { ++ return tag; ++ } ++ ++ @Nullable ++ public static DyeColor getColor(ItemStack stack) { ++ if (stack.m_41720_() instanceof DyeItem) ++ return ((DyeItem)stack.m_41720_()).m_41089_(); ++ ++ for (DyeColor color : f_41032_) { ++ if (stack.m_150922_(color.getTag())) ++ return color; ++ } ++ ++ return null; + } + } diff --git a/patches/minecraft/net/minecraft/world/item/DyeableHorseArmorItem.java.patch b/patches/minecraft/net/minecraft/world/item/DyeableHorseArmorItem.java.patch new file mode 100644 index 0000000000..79d6002a10 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/DyeableHorseArmorItem.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/world/item/DyeableHorseArmorItem.java ++++ b/net/minecraft/world/item/DyeableHorseArmorItem.java +@@ -4,4 +_,7 @@ + public DyeableHorseArmorItem(int p_41110_, String p_41111_, Item.Properties p_41112_) { + super(p_41110_, p_41111_, p_41112_); + } ++ public DyeableHorseArmorItem(int p_41110_, net.minecraft.resources.ResourceLocation p_41111_, Item.Properties p_41112_) { ++ super(p_41110_, p_41111_, p_41112_); ++ } + } diff --git a/patches/minecraft/net/minecraft/world/item/ElytraItem.java.patch b/patches/minecraft/net/minecraft/world/item/ElytraItem.java.patch new file mode 100644 index 0000000000..461fa214f0 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/ElytraItem.java.patch @@ -0,0 +1,22 @@ +--- a/net/minecraft/world/item/ElytraItem.java ++++ b/net/minecraft/world/item/ElytraItem.java +@@ -43,6 +_,19 @@ + } + } + ++ @Override ++ public boolean canElytraFly(ItemStack stack, net.minecraft.world.entity.LivingEntity entity) { ++ return ElytraItem.m_41140_(stack); ++ } ++ ++ @Override ++ public boolean elytraFlightTick(ItemStack stack, net.minecraft.world.entity.LivingEntity entity, int flightTicks) { ++ if (!entity.f_19853_.f_46443_ && (flightTicks + 1) % 20 == 0) { ++ stack.m_41622_(1, entity, e -> e.m_21166_(net.minecraft.world.entity.EquipmentSlot.CHEST)); ++ } ++ return true; ++ } ++ + @Nullable + public SoundEvent m_142602_() { + return SoundEvents.f_11674_; diff --git a/patches/minecraft/net/minecraft/world/item/HoeItem.java.patch b/patches/minecraft/net/minecraft/world/item/HoeItem.java.patch new file mode 100644 index 0000000000..6d1ba81783 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/HoeItem.java.patch @@ -0,0 +1,30 @@ +--- a/net/minecraft/world/item/HoeItem.java ++++ b/net/minecraft/world/item/HoeItem.java +@@ -26,13 +_,16 @@ + }, m_150849_(Blocks.f_50493_.m_49966_(), Items.f_151017_)))); + + public HoeItem(Tier p_41336_, int p_41337_, float p_41338_, Item.Properties p_41339_) { +- super((float)p_41337_, p_41338_, p_41336_, BlockTags.f_144281_, p_41339_); ++ super((float)p_41337_, p_41338_, p_41336_, BlockTags.f_144281_, p_41339_.addToolType(net.minecraftforge.common.ToolType.HOE, p_41336_.m_6604_())); + } + + public InteractionResult m_6225_(UseOnContext p_41341_) { + Level level = p_41341_.m_43725_(); + BlockPos blockpos = p_41341_.m_8083_(); + Pair, Consumer> pair = f_41332_.get(level.m_8055_(blockpos).m_60734_()); ++ int hook = net.minecraftforge.event.ForgeEventFactory.onHoeUse(p_41341_); ++ if (hook != 0) return hook > 0 ? InteractionResult.SUCCESS : InteractionResult.FAIL; ++ if (p_41341_.m_43719_() != Direction.DOWN && level.m_46859_(blockpos.m_7494_())) { + if (pair == null) { + return InteractionResult.PASS; + } else { +@@ -55,6 +_,9 @@ + return InteractionResult.PASS; + } + } ++ } ++ ++ return InteractionResult.PASS; + } + + public static Consumer m_150858_(BlockState p_150859_) { diff --git a/patches/minecraft/net/minecraft/world/item/HorseArmorItem.java.patch b/patches/minecraft/net/minecraft/world/item/HorseArmorItem.java.patch new file mode 100644 index 0000000000..0dc5fa9bd3 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/HorseArmorItem.java.patch @@ -0,0 +1,26 @@ +--- a/net/minecraft/world/item/HorseArmorItem.java ++++ b/net/minecraft/world/item/HorseArmorItem.java +@@ -5,16 +_,20 @@ + public class HorseArmorItem extends Item { + private static final String f_150882_ = "textures/entity/horse/"; + private final int f_41361_; +- private final String f_41362_; ++ private final ResourceLocation f_41362_; + + public HorseArmorItem(int p_41364_, String p_41365_, Item.Properties p_41366_) { ++ this(p_41364_, new ResourceLocation("textures/entity/horse/armor/horse_armor_" + p_41365_ + ".png"), p_41366_); ++ } ++ ++ public HorseArmorItem(int p_41364_, ResourceLocation p_41111_, Item.Properties p_41366_) { + super(p_41366_); + this.f_41361_ = p_41364_; +- this.f_41362_ = "textures/entity/horse/armor/horse_armor_" + p_41365_ + ".png"; ++ this.f_41362_ = p_41111_; + } + + public ResourceLocation m_41367_() { +- return new ResourceLocation(this.f_41362_); ++ return f_41362_; + } + + public int m_41368_() { diff --git a/patches/minecraft/net/minecraft/world/item/Item.java.patch b/patches/minecraft/net/minecraft/world/item/Item.java.patch new file mode 100644 index 0000000000..829e90c492 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/Item.java.patch @@ -0,0 +1,176 @@ +--- a/net/minecraft/world/item/Item.java ++++ b/net/minecraft/world/item/Item.java +@@ -46,9 +_,9 @@ + import org.apache.logging.log4j.LogManager; + import org.apache.logging.log4j.Logger; + +-public class Item implements ItemLike { ++public class Item extends net.minecraftforge.registries.ForgeRegistryEntry implements ItemLike, net.minecraftforge.common.extensions.IForgeItem { + private static final Logger f_150883_ = LogManager.getLogger(); +- public static final Map f_41373_ = Maps.newHashMap(); ++ public static final Map f_41373_ = net.minecraftforge.registries.GameData.getBlockItemMap(); + protected static final UUID f_41374_ = UUID.fromString("CB3F55D3-645C-4F38-A497-9C13A33DB5CF"); + protected static final UUID f_41375_ = UUID.fromString("FA233E1C-4180-4865-B01B-BCCE9785ACA3"); + public static final int f_150884_ = 64; +@@ -92,7 +_,9 @@ + f_150883_.error("Item classes should end with Item and {} doesn't.", (Object)s); + } + } +- ++ this.canRepair = p_41383_.canRepair; ++ this.toolClasses.putAll(p_41383_.toolClasses); ++ initClient(); + } + + public void m_5929_(Level p_41428_, LivingEntity p_41429_, ItemStack p_41430_, int p_41431_) { +@@ -138,10 +_,12 @@ + return this.m_41472_() ? p_41411_.m_5584_(p_41410_, p_41409_) : p_41409_; + } + ++ @Deprecated // Use ItemStack sensitive version. + public final int m_41459_() { + return this.f_41370_; + } + ++ @Deprecated // Use ItemStack sensitive version. + public final int m_41462_() { + return this.f_41371_; + } +@@ -216,10 +_,12 @@ + } + + @Nullable ++ @Deprecated // Use ItemStack sensitive version. + public final Item m_41469_() { + return this.f_41378_; + } + ++ @Deprecated // Use ItemStack sensitive version. + public boolean m_41470_() { + return this.f_41378_ != null; + } +@@ -282,7 +_,7 @@ + } + + public boolean m_8120_(ItemStack p_41456_) { +- return this.m_41459_() == 1 && this.m_41465_(); ++ return this.getItemStackLimit(p_41456_) == 1 && this.isDamageable(p_41456_); + } + + protected static BlockHitResult m_41435_(Level p_41436_, Player p_41437_, ClipContext.Fluid p_41438_) { +@@ -295,8 +_,8 @@ + float f5 = Mth.m_14031_(-f * ((float)Math.PI / 180F)); + float f6 = f3 * f4; + float f7 = f2 * f4; +- double d0 = 5.0D; +- Vec3 vec31 = vec3.m_82520_((double)f6 * 5.0D, (double)f5 * 5.0D, (double)f7 * 5.0D); ++ double d0 = p_41437_.m_21051_(net.minecraftforge.common.ForgeMod.REACH_DISTANCE.get()).m_22135_();; ++ Vec3 vec31 = vec3.m_82520_((double)f6 * d0, (double)f5 * d0, (double)f7 * d0); + return p_41436_.m_45547_(new ClipContext(vec3, vec31, ClipContext.Block.OUTLINE, p_41438_, p_41437_)); + } + +@@ -312,6 +_,7 @@ + } + + protected boolean m_41389_(CreativeModeTab p_41390_) { ++ if (getCreativeTabs().stream().anyMatch(tab -> tab == p_41390_)) return true; + CreativeModeTab creativemodetab = this.m_41471_(); + return creativemodetab != null && (p_41390_ == CreativeModeTab.f_40754_ || p_41390_ == creativemodetab); + } +@@ -325,12 +_,37 @@ + return false; + } + ++ @Deprecated // Use ItemStack sensitive version. + public Multimap m_7167_(EquipmentSlot p_41388_) { + return ImmutableMultimap.of(); + } + ++ private final java.util.Map toolClasses = Maps.newHashMap(); ++ private final net.minecraftforge.common.util.ReverseTagWrapper reverseTags = new net.minecraftforge.common.util.ReverseTagWrapper<>(this, net.minecraft.tags.ItemTags::m_13193_); ++ protected final boolean canRepair; ++ ++ @Override ++ public boolean isRepairable(ItemStack stack) { ++ return canRepair && isDamageable(stack); ++ } ++ ++ @Override ++ public java.util.Set getToolTypes(ItemStack stack) { ++ return toolClasses.keySet(); ++ } ++ ++ @Override ++ public int getHarvestLevel(ItemStack stack, net.minecraftforge.common.ToolType tool, @Nullable Player player, @Nullable BlockState blockState) { ++ return toolClasses.getOrDefault(tool, -1); ++ } ++ ++ @Override ++ public java.util.Set getTags() { ++ return reverseTags.getTagNames(); ++ } ++ + public boolean m_41463_(ItemStack p_41464_) { +- return false; ++ return p_41464_.m_41720_() == Items.f_42717_; + } + + public ItemStack m_7968_() { +@@ -371,6 +_,31 @@ + return true; + } + ++ // FORGE START ++ private Object renderProperties; ++ ++ /* ++ DO NOT CALL, IT WILL DISAPPEAR IN THE FUTURE ++ Call RenderProperties.get instead ++ */ ++ public Object getRenderPropertiesInternal() { ++ return renderProperties; ++ } ++ ++ private void initClient() { ++ if (net.minecraftforge.fml.loading.FMLEnvironment.dist == net.minecraftforge.api.distmarker.Dist.CLIENT) { ++ initializeClient(properties -> { ++ if (properties == this) ++ throw new IllegalStateException("Don't extend IItemRenderProperties in your item, use an anonymous class instead."); ++ this.renderProperties = properties; ++ }); ++ } ++ } ++ ++ public void initializeClient(java.util.function.Consumer consumer) { ++ } ++ // END FORGE ++ + public static class Properties { + int f_41478_ = 64; + int f_41479_; +@@ -379,6 +_,8 @@ + Rarity f_41482_ = Rarity.COMMON; + FoodProperties f_41483_; + boolean f_41484_; ++ private boolean canRepair = true; ++ private java.util.Map toolClasses = Maps.newHashMap(); + + public Item.Properties m_41489_(FoodProperties p_41490_) { + this.f_41483_ = p_41490_; +@@ -421,6 +_,16 @@ + + public Item.Properties m_41486_() { + this.f_41484_ = true; ++ return this; ++ } ++ ++ public Item.Properties setNoRepair() { ++ canRepair = false; ++ return this; ++ } ++ ++ public Item.Properties addToolType(net.minecraftforge.common.ToolType type, int level) { ++ toolClasses.put(type, level); + return this; + } + } diff --git a/patches/minecraft/net/minecraft/world/item/ItemStack.java.patch b/patches/minecraft/net/minecraft/world/item/ItemStack.java.patch new file mode 100644 index 0000000000..fb1123ac5c --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/ItemStack.java.patch @@ -0,0 +1,252 @@ +--- a/net/minecraft/world/item/ItemStack.java ++++ b/net/minecraft/world/item/ItemStack.java +@@ -74,7 +_,7 @@ + import org.apache.logging.log4j.LogManager; + import org.apache.logging.log4j.Logger; + +-public final class ItemStack { ++public final class ItemStack extends net.minecraftforge.common.capabilities.CapabilityProvider implements net.minecraftforge.common.extensions.IForgeItemStack { + public static final Codec f_41582_ = RecordCodecBuilder.create((p_41697_) -> { + return p_41697_.group(Registry.f_122827_.fieldOf("id").forGetter((p_150946_) -> { + return p_150946_.f_41589_; +@@ -84,6 +_,9 @@ + return Optional.ofNullable(p_150939_.f_41590_); + })).apply(p_41697_, ItemStack::new); + }); ++ private final net.minecraftforge.registries.IRegistryDelegate delegate; ++ private CompoundTag capNBT; ++ + private static final Logger f_41585_ = LogManager.getLogger(); + public static final ItemStack f_41583_ = new ItemStack((Item)null); + public static final DecimalFormat f_41584_ = Util.m_137469_(new DecimalFormat("#.##"), (p_41704_) -> { +@@ -127,14 +_,19 @@ + p_41606_.ifPresent(this::m_41751_); + } + +- public ItemStack(ItemLike p_41601_, int p_41602_) { +- this.f_41589_ = p_41601_ == null ? null : p_41601_.m_5456_(); +- this.f_41587_ = p_41602_; +- if (this.f_41589_ != null && this.f_41589_.m_41465_()) { ++ public ItemStack(ItemLike p_41601_, int p_41602_) { this(p_41601_, p_41602_, (CompoundTag) null); } ++ public ItemStack(ItemLike p_41604_, int p_41605_, @Nullable CompoundTag p_41606_) { ++ super(ItemStack.class); ++ this.capNBT = p_41606_; ++ this.f_41589_ = p_41604_ == null ? null : p_41604_.m_5456_(); ++ this.delegate = p_41604_ == null ? null : p_41604_.m_5456_().delegate; ++ this.f_41587_ = p_41605_; ++ if (this.f_41589_ != null && this.f_41589_.isDamageable(this)) { + this.m_41721_(this.m_41773_()); + } + + this.m_41617_(); ++ this.forgeInit(); + } + + private void m_41617_() { +@@ -143,18 +_,23 @@ + } + + private ItemStack(CompoundTag p_41608_) { ++ super(ItemStack.class); ++ this.capNBT = p_41608_.m_128441_("ForgeCaps") ? p_41608_.m_128469_("ForgeCaps") : null; ++ Item rawItem = + this.f_41589_ = Registry.f_122827_.m_7745_(new ResourceLocation(p_41608_.m_128461_("id"))); ++ this.delegate = rawItem.delegate; + this.f_41587_ = p_41608_.m_128445_("Count"); + if (p_41608_.m_128425_("tag", 10)) { + this.f_41590_ = p_41608_.m_128469_("tag"); + this.m_41720_().m_142312_(this.f_41590_); + } + +- if (this.m_41720_().m_41465_()) { ++ if (this.m_41720_().isDamageable(this)) { + this.m_41721_(this.m_41773_()); + } + + this.m_41617_(); ++ this.forgeInit(); + } + + public static ItemStack m_41712_(CompoundTag p_41713_) { +@@ -185,7 +_,7 @@ + } + + public Item m_41720_() { +- return this.f_41591_ ? Items.f_41852_ : this.f_41589_; ++ return this.f_41591_ || this.delegate == null ? Items.f_41852_ : this.delegate.get(); + } + + public boolean m_150922_(Tag p_150923_) { +@@ -197,6 +_,15 @@ + } + + public InteractionResult m_41661_(UseOnContext p_41662_) { ++ if (!p_41662_.m_43725_().f_46443_) return net.minecraftforge.common.ForgeHooks.onPlaceItemIntoWorld(p_41662_); ++ return onItemUse(p_41662_, (c) -> m_41720_().m_6225_(p_41662_)); ++ } ++ ++ public InteractionResult onItemUseFirst(UseOnContext p_41662_) { ++ return onItemUse(p_41662_, (c) -> m_41720_().onItemUseFirst(this, p_41662_)); ++ } ++ ++ private InteractionResult onItemUse(UseOnContext p_41662_, java.util.function.Function callback) { + Player player = p_41662_.m_43723_(); + BlockPos blockpos = p_41662_.m_8083_(); + BlockInWorld blockinworld = new BlockInWorld(p_41662_.m_43725_(), blockpos, false); +@@ -204,7 +_,7 @@ + return InteractionResult.PASS; + } else { + Item item = this.m_41720_(); +- InteractionResult interactionresult = item.m_6225_(p_41662_); ++ InteractionResult interactionresult = callback.apply(p_41662_); + if (player != null && interactionresult.m_146666_()) { + player.m_36246_(Stats.f_12982_.m_12902_(item)); + } +@@ -233,11 +_,15 @@ + p_41740_.m_128365_("tag", this.f_41590_.m_6426_()); + } + ++ CompoundTag cnbt = this.serializeCaps(); ++ if (cnbt != null && !cnbt.m_128456_()) { ++ p_41740_.m_128365_("ForgeCaps", cnbt); ++ } + return p_41740_; + } + + public int m_41741_() { +- return this.m_41720_().m_41459_(); ++ return this.m_41720_().getItemStackLimit(this); + } + + public boolean m_41753_() { +@@ -245,7 +_,7 @@ + } + + public boolean m_41763_() { +- if (!this.f_41591_ && this.m_41720_().m_41462_() > 0) { ++ if (!this.f_41591_ && this.m_41720_().isDamageable(this)) { + CompoundTag compoundtag = this.m_41783_(); + return compoundtag == null || !compoundtag.m_128471_("Unbreakable"); + } else { +@@ -254,19 +_,19 @@ + } + + public boolean m_41768_() { +- return this.m_41763_() && this.m_41773_() > 0; ++ return this.m_41763_() && m_41720_().isDamaged(this); + } + + public int m_41773_() { +- return this.f_41590_ == null ? 0 : this.f_41590_.m_128451_("Damage"); ++ return this.m_41720_().getDamage(this); + } + + public void m_41721_(int p_41722_) { +- this.m_41784_().m_128405_("Damage", Math.max(0, p_41722_)); ++ this.m_41720_().setDamage(this, p_41722_); + } + + public int m_41776_() { +- return this.m_41720_().m_41462_(); ++ return this.m_41720_().getMaxDamage(this); + } + + public boolean m_41629_(int p_41630_, Random p_41631_, @Nullable ServerPlayer p_41632_) { +@@ -302,6 +_,7 @@ + public void m_41622_(int p_41623_, T p_41624_, Consumer p_41625_) { + if (!p_41624_.f_19853_.f_46443_ && (!(p_41624_ instanceof Player) || !((Player)p_41624_).m_150110_().f_35937_)) { + if (this.m_41763_()) { ++ p_41623_ = this.m_41720_().damageItem(this, p_41623_, p_41624_, p_41625_); + if (this.m_41629_(p_41623_, p_41624_.m_21187_(), p_41624_ instanceof ServerPlayer ? (ServerPlayer)p_41624_ : null)) { + p_41625_.accept(p_41624_); + Item item = this.m_41720_(); +@@ -354,7 +_,7 @@ + } + + public boolean m_41735_(BlockState p_41736_) { +- return this.m_41720_().m_8096_(p_41736_); ++ return this.m_41720_().canHarvestBlock(this, p_41736_); + } + + public InteractionResult m_41647_(Player p_41648_, LivingEntity p_41649_, InteractionHand p_41650_) { +@@ -365,7 +_,7 @@ + if (this.m_41619_()) { + return f_41583_; + } else { +- ItemStack itemstack = new ItemStack(this.m_41720_(), this.f_41587_); ++ ItemStack itemstack = new ItemStack(this.m_41720_(), this.f_41587_, this.serializeCaps()); + itemstack.m_41754_(this.m_41612_()); + if (this.f_41590_ != null) { + itemstack.f_41590_ = this.f_41590_.m_6426_(); +@@ -382,7 +_,7 @@ + if (p_41659_.f_41590_ == null && p_41660_.f_41590_ != null) { + return false; + } else { +- return p_41659_.f_41590_ == null || p_41659_.f_41590_.equals(p_41660_.f_41590_); ++ return (p_41659_.f_41590_ == null || p_41659_.f_41590_.equals(p_41660_.f_41590_)) && p_41659_.areCapsCompatible(p_41660_); + } + } else { + return false; +@@ -405,7 +_,7 @@ + } else if (this.f_41590_ == null && p_41745_.f_41590_ != null) { + return false; + } else { +- return this.f_41590_ == null || this.f_41590_.equals(p_41745_.f_41590_); ++ return (this.f_41590_ == null || this.f_41590_.equals(p_41745_.f_41590_)) && this.areCapsCompatible(p_41745_); + } + } + +@@ -529,7 +_,7 @@ + + public void m_41751_(@Nullable CompoundTag p_41752_) { + this.f_41590_ = p_41752_; +- if (this.m_41720_().m_41465_()) { ++ if (this.m_41720_().isDamageable(this)) { + this.m_41721_(this.m_41773_()); + } + +@@ -729,6 +_,7 @@ + } + } + ++ net.minecraftforge.event.ForgeEventFactory.onItemTooltip(this, p_41652_, list, p_41653_); + return list; + } + +@@ -866,9 +_,10 @@ + } + } + } else { +- multimap = this.m_41720_().m_7167_(p_41639_); ++ multimap = this.m_41720_().getAttributeModifiers(p_41639_, this); + } + ++ multimap = net.minecraftforge.common.ForgeHooks.getAttributeModifiers(this, p_41639_, multimap); + return multimap; + } + +@@ -1005,6 +_,24 @@ + + public boolean m_41614_() { + return this.m_41720_().m_41472_(); ++ } ++ ++ // FORGE START ++ public void deserializeNBT(CompoundTag nbt) { ++ final ItemStack itemStack = ItemStack.m_41712_(nbt); ++ this.m_41751_(itemStack.m_41783_()); ++ if (itemStack.capNBT != null) deserializeCaps(itemStack.capNBT); ++ } ++ ++ /** ++ * Set up forge's ItemStack additions. ++ */ ++ private void forgeInit() { ++ if (this.delegate != null) { ++ net.minecraftforge.common.capabilities.ICapabilityProvider provider = f_41589_.initCapabilities(this, this.capNBT); ++ this.gatherCapabilities(provider); ++ if (this.capNBT != null) deserializeCaps(this.capNBT); ++ } + } + + public SoundEvent m_41615_() { diff --git a/patches/minecraft/net/minecraft/world/item/Items.java.patch b/patches/minecraft/net/minecraft/world/item/Items.java.patch new file mode 100644 index 0000000000..e8a464524b --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/Items.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/world/item/Items.java ++++ b/net/minecraft/world/item/Items.java +@@ -14,6 +_,7 @@ + import net.minecraft.world.level.block.entity.BannerPattern; + import net.minecraft.world.level.material.Fluids; + ++@net.minecraftforge.registries.ObjectHolder("minecraft") + public class Items { + public static final Item f_41852_ = m_42810_(Blocks.f_50016_, new AirItem(Blocks.f_50016_, new Item.Properties())); + public static final Item f_41905_ = m_42807_(Blocks.f_50069_, CreativeModeTab.f_40749_); diff --git a/patches/minecraft/net/minecraft/world/item/MapItem.java.patch b/patches/minecraft/net/minecraft/world/item/MapItem.java.patch new file mode 100644 index 0000000000..f4ae1f5edd --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/MapItem.java.patch @@ -0,0 +1,23 @@ +--- a/net/minecraft/world/item/MapItem.java ++++ b/net/minecraft/world/item/MapItem.java +@@ -55,8 +_,18 @@ + + @Nullable + public static MapItemSavedData m_42853_(ItemStack p_42854_, Level p_42855_) { +- Integer integer = m_151131_(p_42854_); +- return m_151128_(integer, p_42855_); ++ // Forge: Add instance method so that mods can override ++ Item map = p_42854_.m_41720_(); ++ if(map instanceof MapItem) { ++ return ((MapItem)map).getCustomMapData(p_42854_, p_42855_); ++ } ++ return null; ++ } ++ ++ @Nullable ++ protected MapItemSavedData getCustomMapData(ItemStack p_42910_, Level p_42911_) { ++ Integer integer = m_151131_(p_42910_); ++ return m_151128_(integer, p_42911_); + } + + @Nullable diff --git a/patches/minecraft/net/minecraft/world/item/MilkBucketItem.java.patch b/patches/minecraft/net/minecraft/world/item/MilkBucketItem.java.patch new file mode 100644 index 0000000000..4a06053be2 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/MilkBucketItem.java.patch @@ -0,0 +1,32 @@ +--- a/net/minecraft/world/item/MilkBucketItem.java ++++ b/net/minecraft/world/item/MilkBucketItem.java +@@ -17,6 +_,7 @@ + } + + public ItemStack m_5922_(ItemStack p_42923_, Level p_42924_, LivingEntity p_42925_) { ++ if (!p_42924_.f_46443_) p_42925_.curePotionEffects(p_42923_); // FORGE - move up so stack.shrink does not turn stack into air + if (p_42925_ instanceof ServerPlayer) { + ServerPlayer serverplayer = (ServerPlayer)p_42925_; + CriteriaTriggers.f_10592_.m_23682_(serverplayer, p_42923_); +@@ -27,10 +_,6 @@ + p_42923_.m_41774_(1); + } + +- if (!p_42924_.f_46443_) { +- p_42925_.m_21219_(); +- } +- + return p_42923_.m_41619_() ? new ItemStack(Items.f_42446_) : p_42923_; + } + +@@ -44,5 +_,10 @@ + + public InteractionResultHolder m_7203_(Level p_42927_, Player p_42928_, InteractionHand p_42929_) { + return ItemUtils.m_150959_(p_42927_, p_42928_, p_42929_); ++ } ++ ++ @Override ++ public net.minecraftforge.common.capabilities.ICapabilityProvider initCapabilities(ItemStack stack, @javax.annotation.Nullable net.minecraft.nbt.CompoundTag nbt) { ++ return new net.minecraftforge.fluids.capability.wrappers.FluidBucketWrapper(stack); + } + } diff --git a/patches/minecraft/net/minecraft/world/item/MinecartItem.java.patch b/patches/minecraft/net/minecraft/world/item/MinecartItem.java.patch new file mode 100644 index 0000000000..947ba6084e --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/MinecartItem.java.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/world/item/MinecartItem.java ++++ b/net/minecraft/world/item/MinecartItem.java +@@ -28,7 +_,7 @@ + double d2 = p_42949_.m_7094_() + (double)direction.m_122431_() * 1.125D; + BlockPos blockpos = p_42949_.m_7961_().m_142300_(direction); + BlockState blockstate = level.m_8055_(blockpos); +- RailShape railshape = blockstate.m_60734_() instanceof BaseRailBlock ? blockstate.m_61143_(((BaseRailBlock)blockstate.m_60734_()).m_7978_()) : RailShape.NORTH_SOUTH; ++ RailShape railshape = blockstate.m_60734_() instanceof BaseRailBlock ? ((BaseRailBlock)blockstate.m_60734_()).getRailDirection(blockstate, level, blockpos, null) : RailShape.NORTH_SOUTH; + double d3; + if (blockstate.m_60620_(BlockTags.f_13034_)) { + if (railshape.m_61745_()) { +@@ -81,7 +_,7 @@ + } else { + ItemStack itemstack = p_42943_.m_43722_(); + if (!level.f_46443_) { +- RailShape railshape = blockstate.m_60734_() instanceof BaseRailBlock ? blockstate.m_61143_(((BaseRailBlock)blockstate.m_60734_()).m_7978_()) : RailShape.NORTH_SOUTH; ++ RailShape railshape = blockstate.m_60734_() instanceof BaseRailBlock ? ((BaseRailBlock)blockstate.m_60734_()).getRailDirection(blockstate, level, blockpos, null) : RailShape.NORTH_SOUTH; + double d0 = 0.0D; + if (railshape.m_61745_()) { + d0 = 0.5D; diff --git a/patches/minecraft/net/minecraft/world/item/MobBucketItem.java.patch b/patches/minecraft/net/minecraft/world/item/MobBucketItem.java.patch new file mode 100644 index 0000000000..cbe5f037ce --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/MobBucketItem.java.patch @@ -0,0 +1,43 @@ +--- a/net/minecraft/world/item/MobBucketItem.java ++++ b/net/minecraft/world/item/MobBucketItem.java +@@ -25,11 +_,24 @@ + public class MobBucketItem extends BucketItem { + private final EntityType f_151134_; + private final SoundEvent f_151135_; ++ private final java.util.function.Supplier> fishTypeSupplier; ++ private final java.util.function.Supplier emptySoundSupplier; + ++ @Deprecated + public MobBucketItem(EntityType p_151137_, Fluid p_151138_, SoundEvent p_151139_, Item.Properties p_151140_) { + super(p_151138_, p_151140_); + this.f_151134_ = p_151137_; + this.f_151135_ = p_151139_; ++ this.emptySoundSupplier = null; ++ this.fishTypeSupplier = () -> p_151137_; ++ } ++ ++ public MobBucketItem(java.util.function.Supplier> entitySupplier, java.util.function.Supplier fluidSupplier, java.util.function.Supplier soundSupplier, Item.Properties properties) { ++ super(fluidSupplier, properties); ++ this.f_151134_ = null; ++ this.f_151135_ = null; ++ this.emptySoundSupplier = soundSupplier; ++ this.fishTypeSupplier = entitySupplier; + } + + public void m_142131_(@Nullable Player p_151146_, Level p_151147_, ItemStack p_151148_, BlockPos p_151149_) { +@@ -80,6 +_,14 @@ + p_151157_.add(mutablecomponent); + } + } +- ++ } ++ ++ // Forge Start ++ protected EntityType getFishType() { ++ return fishTypeSupplier.get(); ++ } ++ ++ protected SoundEvent getEmptySound() { ++ return emptySoundSupplier.get(); + } + } diff --git a/patches/minecraft/net/minecraft/world/item/Rarity.java.patch b/patches/minecraft/net/minecraft/world/item/Rarity.java.patch new file mode 100644 index 0000000000..3f879b67fc --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/Rarity.java.patch @@ -0,0 +1,21 @@ +--- a/net/minecraft/world/item/Rarity.java ++++ b/net/minecraft/world/item/Rarity.java +@@ -2,7 +_,7 @@ + + import net.minecraft.ChatFormatting; + +-public enum Rarity { ++public enum Rarity implements net.minecraftforge.common.IExtensibleEnum { + COMMON(ChatFormatting.WHITE), + UNCOMMON(ChatFormatting.YELLOW), + RARE(ChatFormatting.AQUA), +@@ -12,5 +_,9 @@ + + private Rarity(ChatFormatting p_43028_) { + this.f_43022_ = p_43028_; ++ } ++ ++ public static Rarity create(String name, ChatFormatting p_43028_) { ++ throw new IllegalStateException("Enum not extended"); + } + } diff --git a/patches/minecraft/net/minecraft/world/item/RecordItem.java.patch b/patches/minecraft/net/minecraft/world/item/RecordItem.java.patch new file mode 100644 index 0000000000..75fb7fd47d --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/RecordItem.java.patch @@ -0,0 +1,49 @@ +--- a/net/minecraft/world/item/RecordItem.java ++++ b/net/minecraft/world/item/RecordItem.java +@@ -20,15 +_,38 @@ + import net.minecraft.world.level.block.state.BlockState; + + public class RecordItem extends Item { ++ @Deprecated // Forge: refer to WorldRender#playRecord. Modders: there's no need to reflectively modify this map! + private static final Map f_43032_ = Maps.newHashMap(); + private final int f_43033_; ++ @Deprecated // Forge: refer to soundSupplier + private final SoundEvent f_43034_; ++ private final java.util.function.Supplier soundSupplier; + ++ @Deprecated // Forge: Use the constructor that takes a supplier instead + public RecordItem(int p_43037_, SoundEvent p_43038_, Item.Properties p_43039_) { + super(p_43039_); + this.f_43033_ = p_43037_; + this.f_43034_ = p_43038_; + f_43032_.put(this.f_43034_, this); ++ this.soundSupplier = this.f_43034_.delegate; ++ } ++ ++ /** ++ * For mod use, allows to create a music disc without having to create a new ++ * SoundEvent before their registry event is fired. ++ * ++ * @param comparatorValue The value this music disc should output on the comparator. Must be between 0 and 15. ++ * @param soundSupplier A supplier that provides the sound that should be played. Use a ++ * {@link net.minecraftforge.fmllegacy.RegistryObject}{@code } or a ++ * {@link net.minecraftforge.registries.IRegistryDelegate} for this parameter. ++ * @param builder A set of {@link Item.Properties} that describe this item. ++ */ ++ public RecordItem(int comparatorValue, java.util.function.Supplier soundSupplier, Item.Properties builder) ++ { ++ super(builder); ++ this.f_43033_ = comparatorValue; ++ this.f_43034_ = null; ++ this.soundSupplier = soundSupplier; + } + + public InteractionResult m_6225_(UseOnContext p_43048_) { +@@ -71,6 +_,6 @@ + } + + public SoundEvent m_43051_() { +- return this.f_43034_; ++ return this.soundSupplier.get(); + } + } diff --git a/patches/minecraft/net/minecraft/world/item/ShearsItem.java.patch b/patches/minecraft/net/minecraft/world/item/ShearsItem.java.patch new file mode 100644 index 0000000000..f14e328ed3 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/ShearsItem.java.patch @@ -0,0 +1,28 @@ +--- a/net/minecraft/world/item/ShearsItem.java ++++ b/net/minecraft/world/item/ShearsItem.java +@@ -38,4 +_,25 @@ + return 15.0F; + } + } ++ ++ @Override ++ public net.minecraft.world.InteractionResult m_6880_(ItemStack stack, net.minecraft.world.entity.player.Player playerIn, LivingEntity entity, net.minecraft.world.InteractionHand hand) { ++ if (entity.f_19853_.f_46443_) return net.minecraft.world.InteractionResult.PASS; ++ if (entity instanceof net.minecraftforge.common.IForgeShearable) { ++ net.minecraftforge.common.IForgeShearable target = (net.minecraftforge.common.IForgeShearable)entity; ++ BlockPos pos = new BlockPos(entity.m_20185_(), entity.m_20186_(), entity.m_20189_()); ++ if (target.isShearable(stack, entity.f_19853_, pos)) { ++ java.util.List drops = target.onSheared(playerIn, stack, entity.f_19853_, pos, ++ net.minecraft.world.item.enchantment.EnchantmentHelper.m_44843_(net.minecraft.world.item.enchantment.Enchantments.f_44987_, stack)); ++ java.util.Random rand = new java.util.Random(); ++ drops.forEach(d -> { ++ net.minecraft.world.entity.item.ItemEntity ent = entity.m_5552_(d, 1.0F); ++ ent.m_20256_(ent.m_20184_().m_82520_((double)((rand.nextFloat() - rand.nextFloat()) * 0.1F), (double)(rand.nextFloat() * 0.05F), (double)((rand.nextFloat() - rand.nextFloat()) * 0.1F))); ++ }); ++ stack.m_41622_(1, entity, e -> e.m_21190_(hand)); ++ } ++ return net.minecraft.world.InteractionResult.SUCCESS; ++ } ++ return net.minecraft.world.InteractionResult.PASS; ++ } + } diff --git a/patches/minecraft/net/minecraft/world/item/ShovelItem.java.patch b/patches/minecraft/net/minecraft/world/item/ShovelItem.java.patch new file mode 100644 index 0000000000..5e4b2b8e49 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/ShovelItem.java.patch @@ -0,0 +1,34 @@ +--- a/net/minecraft/world/item/ShovelItem.java ++++ b/net/minecraft/world/item/ShovelItem.java +@@ -21,7 +_,7 @@ + protected static final Map f_43110_ = Maps.newHashMap((new Builder()).put(Blocks.f_50440_, Blocks.f_152481_.m_49966_()).put(Blocks.f_50493_, Blocks.f_152481_.m_49966_()).put(Blocks.f_50599_, Blocks.f_152481_.m_49966_()).put(Blocks.f_50546_, Blocks.f_152481_.m_49966_()).put(Blocks.f_50195_, Blocks.f_152481_.m_49966_()).put(Blocks.f_152549_, Blocks.f_152481_.m_49966_()).build()); + + public ShovelItem(Tier p_43114_, float p_43115_, float p_43116_, Item.Properties p_43117_) { +- super(p_43115_, p_43116_, p_43114_, BlockTags.f_144283_, p_43117_); ++ super(p_43115_, p_43116_, p_43114_, BlockTags.f_144283_, p_43117_.addToolType(net.minecraftforge.common.ToolType.SHOVEL, p_43114_.m_6604_())); + } + + public InteractionResult m_6225_(UseOnContext p_43119_) { +@@ -32,9 +_,9 @@ + return InteractionResult.PASS; + } else { + Player player = p_43119_.m_43723_(); +- BlockState blockstate1 = f_43110_.get(blockstate.m_60734_()); ++ BlockState blockstate1 = blockstate.getToolModifiedState(level, blockpos, player, p_43119_.m_43722_(), net.minecraftforge.common.ToolType.SHOVEL); + BlockState blockstate2 = null; +- if (blockstate1 != null && level.m_8055_(blockpos.m_7494_()).m_60795_()) { ++ if (blockstate1 != null && level.m_46859_(blockpos.m_7494_())) { + level.m_5594_(player, blockpos, SoundEvents.f_12406_, SoundSource.BLOCKS, 1.0F, 1.0F); + blockstate2 = blockstate1; + } else if (blockstate.m_60734_() instanceof CampfireBlock && blockstate.m_61143_(CampfireBlock.f_51227_)) { +@@ -61,5 +_,10 @@ + return InteractionResult.PASS; + } + } ++ } ++ ++ @javax.annotation.Nullable ++ public static BlockState getShovelPathingState(BlockState originalState) { ++ return f_43110_.get(originalState.m_60734_()); + } + } diff --git a/patches/minecraft/net/minecraft/world/item/StandingAndWallBlockItem.java.patch b/patches/minecraft/net/minecraft/world/item/StandingAndWallBlockItem.java.patch new file mode 100644 index 0000000000..b2f8cd3020 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/StandingAndWallBlockItem.java.patch @@ -0,0 +1,12 @@ +--- a/net/minecraft/world/item/StandingAndWallBlockItem.java ++++ b/net/minecraft/world/item/StandingAndWallBlockItem.java +@@ -42,4 +_,9 @@ + super.m_6192_(p_43252_, p_43253_); + p_43252_.put(this.f_43246_, p_43253_); + } ++ ++ public void removeFromBlockToItemMap(Map blockToItemMap, Item itemIn) { ++ super.removeFromBlockToItemMap(blockToItemMap, itemIn); ++ blockToItemMap.remove(this.f_43246_); ++ } + } diff --git a/patches/minecraft/net/minecraft/world/item/alchemy/Potion.java.patch b/patches/minecraft/net/minecraft/world/item/alchemy/Potion.java.patch new file mode 100644 index 0000000000..663d62a4e4 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/alchemy/Potion.java.patch @@ -0,0 +1,27 @@ +--- a/net/minecraft/world/item/alchemy/Potion.java ++++ b/net/minecraft/world/item/alchemy/Potion.java +@@ -7,7 +_,8 @@ + import net.minecraft.resources.ResourceLocation; + import net.minecraft.world.effect.MobEffectInstance; + +-public class Potion { ++public class Potion extends net.minecraftforge.registries.ForgeRegistryEntry { ++ private final net.minecraftforge.common.util.ReverseTagWrapper reverseTags = new net.minecraftforge.common.util.ReverseTagWrapper(this, () -> net.minecraft.tags.SerializationTags.m_13199_().m_144452_(Registry.f_122905_)); + private final String f_43481_; + private final ImmutableList f_43482_; + +@@ -22,6 +_,14 @@ + public Potion(@Nullable String p_43484_, MobEffectInstance... p_43485_) { + this.f_43481_ = p_43484_; + this.f_43482_ = ImmutableList.copyOf(p_43485_); ++ } ++ ++ public java.util.Set getTags() { ++ return reverseTags.getTagNames(); ++ } ++ ++ public boolean is(net.minecraft.tags.Tag tag) { ++ return tag.m_8110_(this); + } + + public String m_43492_(String p_43493_) { diff --git a/patches/minecraft/net/minecraft/world/item/alchemy/PotionBrewing.java.patch b/patches/minecraft/net/minecraft/world/item/alchemy/PotionBrewing.java.patch new file mode 100644 index 0000000000..0ff07b686e --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/alchemy/PotionBrewing.java.patch @@ -0,0 +1,72 @@ +--- a/net/minecraft/world/item/alchemy/PotionBrewing.java ++++ b/net/minecraft/world/item/alchemy/PotionBrewing.java +@@ -57,7 +_,7 @@ + int i = 0; + + 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_) { + return true; + } + } +@@ -79,7 +_,7 @@ + + for(int j = f_43495_.size(); i < j; ++i) { + PotionBrewing.Mix mix = f_43495_.get(i); +- 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 @@ + + for(int j = f_43494_.size(); i < j; ++i) { + PotionBrewing.Mix mix = f_43494_.get(i); +- 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 @@ + + for(int j = f_43495_.size(); i < j; ++i) { + PotionBrewing.Mix mix = f_43495_.get(i); +- 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_)) { ++ return PotionUtils.m_43549_(new ItemStack(mix.f_43534_.get()), potion); + } + } + +@@ -118,8 +_,8 @@ + + for(int k = f_43494_.size(); i < k; ++i) { + PotionBrewing.Mix mix1 = f_43494_.get(i); +- 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_)) { ++ return PotionUtils.m_43549_(new ItemStack(item), mix1.f_43534_.get()); + } + } + } +@@ -212,15 +_,15 @@ + f_43494_.add(new PotionBrewing.Mix<>(p_43514_, Ingredient.m_43929_(p_43515_), p_43516_)); + } + +- public static class Mix { +- final T f_43532_; ++ public static class Mix> { ++ public final net.minecraftforge.registries.IRegistryDelegate f_43532_; + public final Ingredient f_43533_; +- final T f_43534_; ++ public final net.minecraftforge.registries.IRegistryDelegate f_43534_; + + public Mix(T p_43536_, Ingredient p_43537_, T p_43538_) { +- this.f_43532_ = p_43536_; ++ this.f_43532_ = p_43536_.delegate; + this.f_43533_ = p_43537_; +- this.f_43534_ = p_43538_; ++ this.f_43534_ = p_43538_.delegate; + } + } + } diff --git a/patches/minecraft/net/minecraft/world/item/crafting/BannerDuplicateRecipe.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/BannerDuplicateRecipe.java.patch new file mode 100644 index 0000000000..ec057917ad --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/crafting/BannerDuplicateRecipe.java.patch @@ -0,0 +1,13 @@ +--- a/net/minecraft/world/item/crafting/BannerDuplicateRecipe.java ++++ b/net/minecraft/world/item/crafting/BannerDuplicateRecipe.java +@@ -81,8 +_,8 @@ + for(int i = 0; i < nonnulllist.size(); ++i) { + ItemStack itemstack = p_43791_.m_8020_(i); + if (!itemstack.m_41619_()) { +- if (itemstack.m_41720_().m_41470_()) { +- nonnulllist.set(i, new ItemStack(itemstack.m_41720_().m_41469_())); ++ if (itemstack.hasContainerItem()) { ++ nonnulllist.set(i, itemstack.getContainerItem()); + } else if (itemstack.m_41782_() && BannerBlockEntity.m_58504_(itemstack) > 0) { + ItemStack itemstack1 = itemstack.m_41777_(); + itemstack1.m_41764_(1); diff --git a/patches/minecraft/net/minecraft/world/item/crafting/BookCloningRecipe.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/BookCloningRecipe.java.patch new file mode 100644 index 0000000000..49d15ffcf1 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/crafting/BookCloningRecipe.java.patch @@ -0,0 +1,13 @@ +--- a/net/minecraft/world/item/crafting/BookCloningRecipe.java ++++ b/net/minecraft/world/item/crafting/BookCloningRecipe.java +@@ -79,8 +_,8 @@ + + for(int i = 0; i < nonnulllist.size(); ++i) { + ItemStack itemstack = p_43820_.m_8020_(i); +- if (itemstack.m_41720_().m_41470_()) { +- nonnulllist.set(i, new ItemStack(itemstack.m_41720_().m_41469_())); ++ if (itemstack.hasContainerItem()) { ++ nonnulllist.set(i, itemstack.getContainerItem()); + } else if (itemstack.m_41720_() instanceof WrittenBookItem) { + ItemStack itemstack1 = itemstack.m_41777_(); + itemstack1.m_41764_(1); diff --git a/patches/minecraft/net/minecraft/world/item/crafting/Ingredient.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/Ingredient.java.patch new file mode 100644 index 0000000000..f9de9ca432 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/crafting/Ingredient.java.patch @@ -0,0 +1,96 @@ +--- a/net/minecraft/world/item/crafting/Ingredient.java ++++ b/net/minecraft/world/item/crafting/Ingredient.java +@@ -29,15 +_,24 @@ + import net.minecraft.world.level.ItemLike; + + public class Ingredient implements Predicate { ++ //Because Mojang caches things... we need to invalidate them.. so... here we go.. ++ private static final java.util.Set INSTANCES = java.util.Collections.newSetFromMap(new java.util.WeakHashMap()); ++ public static void invalidateAll() { ++ INSTANCES.stream().filter(e -> e != null).forEach(i -> i.invalidate()); ++ } ++ + public static final Ingredient f_43901_ = new Ingredient(Stream.empty()); + private final Ingredient.Value[] f_43902_; + private ItemStack[] f_43903_; + private IntList f_43904_; ++ private final boolean isSimple; + + protected Ingredient(Stream p_43907_) { + this.f_43902_ = p_43907_.toArray((p_43933_) -> { + return new Ingredient.Value[p_43933_]; + }); ++ this.isSimple = !net.minecraftforge.fmllegacy.DatagenModLoader.isRunningDataGen() && !Arrays.stream(f_43902_).anyMatch(list -> list.m_6223_().stream().anyMatch(stack -> stack.m_41720_().isDamageable(stack))); ++ Ingredient.INSTANCES.add(this); + } + + public ItemStack[] m_43908_() { +@@ -92,6 +_,10 @@ + + public final void m_43923_(FriendlyByteBuf p_43924_) { + this.m_43948_(); ++ if (!this.isVanilla()) { ++ net.minecraftforge.common.crafting.CraftingHelper.write(p_43924_, this); ++ return; ++ } + p_43924_.m_178352_(Arrays.asList(this.f_43903_), FriendlyByteBuf::m_130055_); + } + +@@ -113,6 +_,25 @@ + return this.f_43902_.length == 0 && (this.f_43903_ == null || this.f_43903_.length == 0) && (this.f_43904_ == null || this.f_43904_.isEmpty()); + } + ++ protected void invalidate() { ++ this.f_43903_ = null; ++ this.f_43904_ = null; ++ } ++ ++ public boolean isSimple() { ++ return isSimple || this == f_43901_; ++ } ++ ++ private final boolean isVanilla = this.getClass() == Ingredient.class; ++ public final boolean isVanilla() { ++ 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.f_43902_.length == 0 ? f_43901_ : ingredient; +@@ -146,6 +_,8 @@ + + public static Ingredient m_43917_(@Nullable JsonElement p_43918_) { + if (p_43918_ != null && !p_43918_.isJsonNull()) { ++ Ingredient ret = net.minecraftforge.common.crafting.CraftingHelper.getIngredient(p_43918_); ++ if (ret != null) return ret; + if (p_43918_.isJsonObject()) { + return m_43938_(Stream.of(m_43919_(p_43918_.getAsJsonObject()))); + } else if (p_43918_.isJsonArray()) { +@@ -182,6 +_,12 @@ + } + } + ++ //Merges several vanilla Ingredients together. As a quirk of how the json is structured, we can't tell if its a single Ingredient type or multiple so we split per item and re-merge here. ++ //Only public for internal use, so we can access a private field in here. ++ public static Ingredient merge(Collection parts) { ++ return m_43938_(parts.stream().flatMap(i -> Arrays.stream(i.f_43902_))); ++ } ++ + public static class ItemValue implements Ingredient.Value { + private final ItemStack f_43951_; + +@@ -214,6 +_,9 @@ + list.add(new ItemStack(item)); + } + ++ if (list.size() == 0 && !net.minecraftforge.common.ForgeConfig.SERVER.treatEmptyTagsAsAir.get()) { ++ list.add(new ItemStack(net.minecraft.world.level.block.Blocks.f_50375_).m_41714_(new net.minecraft.network.chat.TextComponent("Empty Tag: " + SerializationTags.m_13199_().m_144454_(Registry.f_122904_, this.f_43959_, () -> new IllegalStateException("Unrecognized tag"))))); ++ } + 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 new file mode 100644 index 0000000000..f2975c81db --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/crafting/Recipe.java.patch @@ -0,0 +1,15 @@ +--- a/net/minecraft/world/item/crafting/Recipe.java ++++ b/net/minecraft/world/item/crafting/Recipe.java +@@ -21,9 +_,9 @@ + NonNullList nonnulllist = NonNullList.m_122780_(p_44004_.m_6643_(), ItemStack.f_41583_); + + for(int i = 0; i < nonnulllist.size(); ++i) { +- Item item = p_44004_.m_8020_(i).m_41720_(); +- if (item.m_41470_()) { +- nonnulllist.set(i, new ItemStack(item.m_41469_())); ++ ItemStack item = p_44004_.m_8020_(i); ++ if (item.hasContainerItem()) { ++ nonnulllist.set(i, item.getContainerItem()); + } + } + diff --git a/patches/minecraft/net/minecraft/world/item/crafting/RecipeManager.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/RecipeManager.java.patch new file mode 100644 index 0000000000..e477d21882 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/crafting/RecipeManager.java.patch @@ -0,0 +1,21 @@ +--- a/net/minecraft/world/item/crafting/RecipeManager.java ++++ b/net/minecraft/world/item/crafting/RecipeManager.java +@@ -49,9 +_,18 @@ + + for(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 { ++ if (entry.getValue().isJsonObject() && !net.minecraftforge.common.crafting.CraftingHelper.processConditions(entry.getValue().getAsJsonObject(), "conditions")) { ++ f_44006_.debug("Skipping loading recipe {} as it's conditions were not met", resourcelocation); ++ continue; ++ } + Recipe recipe = m_44045_(resourcelocation, GsonHelper.m_13918_(entry.getValue(), "top element")); ++ if (recipe == null) { ++ f_44006_.info("Skipping loading recipe {} as it's serializer returned null", resourcelocation); ++ continue; ++ } + map.computeIfAbsent(recipe.m_6671_(), (p_44075_) -> { + return ImmutableMap.builder(); + }).put(resourcelocation, recipe); diff --git a/patches/minecraft/net/minecraft/world/item/crafting/RecipeSerializer.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/RecipeSerializer.java.patch new file mode 100644 index 0000000000..b095831f09 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/crafting/RecipeSerializer.java.patch @@ -0,0 +1,19 @@ +--- a/net/minecraft/world/item/crafting/RecipeSerializer.java ++++ b/net/minecraft/world/item/crafting/RecipeSerializer.java +@@ -5,7 +_,7 @@ + import net.minecraft.network.FriendlyByteBuf; + import net.minecraft.resources.ResourceLocation; + +-public interface RecipeSerializer> { ++public interface RecipeSerializer> extends net.minecraftforge.registries.IForgeRegistryEntry> { + RecipeSerializer f_44076_ = m_44098_("crafting_shaped", new ShapedRecipe.Serializer()); + RecipeSerializer f_44077_ = m_44098_("crafting_shapeless", new ShapelessRecipe.Serializer()); + SimpleRecipeSerializer f_44078_ = m_44098_("crafting_special_armordye", new SimpleRecipeSerializer<>(ArmorDyeRecipe::new)); +@@ -30,6 +_,7 @@ + + T m_6729_(ResourceLocation p_44103_, JsonObject p_44104_); + ++ @javax.annotation.Nullable + T m_8005_(ResourceLocation p_44105_, 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 new file mode 100644 index 0000000000..932886a22f --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/crafting/RepairItemRecipe.java.patch @@ -0,0 +1,38 @@ +--- a/net/minecraft/world/item/crafting/RepairItemRecipe.java ++++ b/net/minecraft/world/item/crafting/RepairItemRecipe.java +@@ -27,7 +_,7 @@ + list.add(itemstack); + if (list.size() > 1) { + ItemStack itemstack1 = list.get(0); +- if (!itemstack.m_150930_(itemstack1.m_41720_()) || itemstack1.m_41613_() != 1 || itemstack.m_41613_() != 1 || !itemstack1.m_41720_().m_41465_()) { ++ if (itemstack.m_41720_() != itemstack1.m_41720_() || itemstack1.m_41613_() != 1 || itemstack.m_41613_() != 1 || !itemstack1.isRepairable()) { + return false; + } + } +@@ -46,7 +_,7 @@ + list.add(itemstack); + if (list.size() > 1) { + ItemStack itemstack1 = list.get(0); +- if (!itemstack.m_150930_(itemstack1.m_41720_()) || itemstack1.m_41613_() != 1 || itemstack.m_41613_() != 1 || !itemstack1.m_41720_().m_41465_()) { ++ if (itemstack.m_41720_() != itemstack1.m_41720_() || itemstack1.m_41613_() != 1 || itemstack.m_41613_() != 1 || !itemstack1.isRepairable()) { + return ItemStack.f_41583_; + } + } +@@ -56,12 +_,12 @@ + if (list.size() == 2) { + ItemStack itemstack3 = list.get(0); + ItemStack itemstack4 = list.get(1); +- if (itemstack3.m_150930_(itemstack4.m_41720_()) && itemstack3.m_41613_() == 1 && itemstack4.m_41613_() == 1 && itemstack3.m_41720_().m_41465_()) { ++ if (itemstack3.m_41720_() == itemstack4.m_41720_() && itemstack3.m_41613_() == 1 && itemstack4.m_41613_() == 1 && itemstack3.isRepairable()) { + Item item = itemstack3.m_41720_(); +- int j = item.m_41462_() - itemstack3.m_41773_(); +- int k = item.m_41462_() - itemstack4.m_41773_(); +- int l = j + k + item.m_41462_() * 5 / 100; +- int i1 = item.m_41462_() - l; ++ int j = itemstack3.m_41776_() - itemstack3.m_41773_(); ++ int k = itemstack3.m_41776_() - itemstack4.m_41773_(); ++ int l = j + k + itemstack3.m_41776_() * 5 / 100; ++ int i1 = itemstack3.m_41776_() - l; + if (i1 < 0) { + i1 = 0; + } diff --git a/patches/minecraft/net/minecraft/world/item/crafting/ShapedRecipe.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/ShapedRecipe.java.patch new file mode 100644 index 0000000000..94b9694e11 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/crafting/ShapedRecipe.java.patch @@ -0,0 +1,94 @@ +--- 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; + import net.minecraft.world.level.Level; + +-public class ShapedRecipe implements CraftingRecipe { ++public class ShapedRecipe implements CraftingRecipe, net.minecraftforge.common.crafting.IShapedRecipe { ++ static int MAX_WIDTH = 3; ++ static int MAX_HEIGHT = 3; ++ /** ++ * Expand the max width and height allowed in the deserializer. ++ * This should be called by modders who add custom crafting tables that are larger than the vanilla 3x3. ++ * @param width your max recipe width ++ * @param height your max recipe height ++ */ ++ public static void setCraftingSize(int width, int height) { ++ if (MAX_WIDTH < width) MAX_WIDTH = width; ++ if (MAX_HEIGHT < height) MAX_HEIGHT = height; ++ } ++ + final int f_44146_; + final int f_44147_; + final NonNullList f_44148_; +@@ -110,10 +_,20 @@ + return this.f_44146_; + } + ++ @Override ++ public int getRecipeWidth() { ++ return m_44220_(); ++ } ++ + public int m_44221_() { + return this.f_44147_; + } + ++ @Override ++ public int getRecipeHeight() { ++ 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()); +@@ -202,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()) { +@@ -244,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); + } + + public static Item m_151278_(JsonObject p_151279_) { +@@ -269,7 +_,8 @@ + } + } + +- public static class Serializer implements RecipeSerializer { ++ public static class Serializer extends net.minecraftforge.registries.ForgeRegistryEntry> 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", ""); + Map map = ShapedRecipe.m_44210_(GsonHelper.m_13930_(p_44237_, "key")); diff --git a/patches/minecraft/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch new file mode 100644 index 0000000000..4b7977e78a --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch @@ -0,0 +1,58 @@ +--- a/net/minecraft/world/item/crafting/ShapelessRecipe.java ++++ b/net/minecraft/world/item/crafting/ShapelessRecipe.java +@@ -18,12 +_,14 @@ + final String f_44242_; + final ItemStack f_44243_; + final NonNullList f_44244_; ++ private final boolean isSimple; + + public ShapelessRecipe(ResourceLocation p_44246_, String p_44247_, ItemStack p_44248_, NonNullList p_44249_) { + this.f_44241_ = p_44246_; + this.f_44242_ = p_44247_; + this.f_44243_ = p_44248_; + this.f_44244_ = p_44249_; ++ this.isSimple = p_44249_.stream().allMatch(Ingredient::isSimple); + } + + public ResourceLocation m_6423_() { +@@ -48,17 +_,20 @@ + + public boolean m_5818_(CraftingContainer p_44262_, Level p_44263_) { + StackedContents stackedcontents = new StackedContents(); ++ java.util.List inputs = new java.util.ArrayList<>(); + int i = 0; + + for(int j = 0; j < p_44262_.m_6643_(); ++j) { + ItemStack itemstack = p_44262_.m_8020_(j); + if (!itemstack.m_41619_()) { + ++i; ++ if (isSimple) + stackedcontents.m_36468_(itemstack, 1); ++ else inputs.add(itemstack); + } + } + +- return i == this.f_44244_.size() && stackedcontents.m_36475_(this, (IntList)null); ++ return i == this.f_44244_.size() && (isSimple ? stackedcontents.m_36475_(this, (IntList)null) : net.minecraftforge.common.util.RecipeMatcher.findMatches(inputs, this.f_44244_) != null); + } + + public ItemStack m_5874_(CraftingContainer p_44260_) { +@@ -69,14 +_,15 @@ + return p_44252_ * p_44253_ >= this.f_44244_.size(); + } + +- public static class Serializer implements RecipeSerializer { ++ public static class Serializer extends net.minecraftforge.registries.ForgeRegistryEntry> 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", ""); + 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, itemstack, nonnulllist); diff --git a/patches/minecraft/net/minecraft/world/item/crafting/ShulkerBoxColoring.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/ShulkerBoxColoring.java.patch new file mode 100644 index 0000000000..f72a8f704e --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/crafting/ShulkerBoxColoring.java.patch @@ -0,0 +1,38 @@ +--- a/net/minecraft/world/item/crafting/ShulkerBoxColoring.java ++++ b/net/minecraft/world/item/crafting/ShulkerBoxColoring.java +@@ -25,7 +_,7 @@ + if (Block.m_49814_(itemstack.m_41720_()) instanceof ShulkerBoxBlock) { + ++i; + } else { +- if (!(itemstack.m_41720_() instanceof DyeItem)) { ++ if (!itemstack.m_150922_(net.minecraftforge.common.Tags.Items.DYES)) { + return false; + } + +@@ -43,7 +_,7 @@ + + public ItemStack m_5874_(CraftingContainer p_44322_) { + ItemStack itemstack = ItemStack.f_41583_; +- DyeItem dyeitem = (DyeItem)Items.f_42535_; ++ net.minecraft.world.item.DyeColor dyecolor = net.minecraft.world.item.DyeColor.WHITE; + + for(int i = 0; i < p_44322_.m_6643_(); ++i) { + ItemStack itemstack1 = p_44322_.m_8020_(i); +@@ -51,13 +_,14 @@ + Item item = itemstack1.m_41720_(); + if (Block.m_49814_(item) instanceof ShulkerBoxBlock) { + itemstack = itemstack1; +- } else if (item instanceof DyeItem) { +- dyeitem = (DyeItem)item; ++ } else { ++ net.minecraft.world.item.DyeColor tmp = net.minecraft.world.item.DyeColor.getColor(itemstack1); ++ if (tmp != null) dyecolor = tmp; + } + } + } + +- ItemStack itemstack2 = ShulkerBoxBlock.m_56250_(dyeitem.m_41089_()); ++ ItemStack itemstack2 = ShulkerBoxBlock.m_56250_(dyecolor); + if (itemstack.m_41782_()) { + itemstack2.m_41751_(itemstack.m_41783_().m_6426_()); + } diff --git a/patches/minecraft/net/minecraft/world/item/crafting/SimpleCookingSerializer.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/SimpleCookingSerializer.java.patch new file mode 100644 index 0000000000..4ed9bf212b --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/crafting/SimpleCookingSerializer.java.patch @@ -0,0 +1,30 @@ +--- a/net/minecraft/world/item/crafting/SimpleCookingSerializer.java ++++ b/net/minecraft/world/item/crafting/SimpleCookingSerializer.java +@@ -8,7 +_,7 @@ + import net.minecraft.util.GsonHelper; + import net.minecraft.world.item.ItemStack; + +-public class SimpleCookingSerializer implements RecipeSerializer { ++public class SimpleCookingSerializer extends net.minecraftforge.registries.ForgeRegistryEntry> implements RecipeSerializer { + private final int f_44327_; + private final SimpleCookingSerializer.CookieBaker f_44328_; + +@@ -21,11 +_,17 @@ + String s = GsonHelper.m_13851_(p_44348_, "group", ""); + 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_43917_(jsonelement); ++ //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(Registry.f_122827_.m_6612_(resourcelocation).orElseThrow(() -> { ++ itemstack = new ItemStack(Registry.f_122827_.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, ingredient, itemstack, f, i); diff --git a/patches/minecraft/net/minecraft/world/item/crafting/SimpleRecipeSerializer.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/SimpleRecipeSerializer.java.patch new file mode 100644 index 0000000000..e9eb08797f --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/crafting/SimpleRecipeSerializer.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/item/crafting/SimpleRecipeSerializer.java ++++ b/net/minecraft/world/item/crafting/SimpleRecipeSerializer.java +@@ -5,7 +_,7 @@ + import net.minecraft.network.FriendlyByteBuf; + import net.minecraft.resources.ResourceLocation; + +-public class SimpleRecipeSerializer> implements RecipeSerializer { ++public class SimpleRecipeSerializer> extends net.minecraftforge.registries.ForgeRegistryEntry> implements RecipeSerializer { + private final Function f_44397_; + + public SimpleRecipeSerializer(Function p_44399_) { diff --git a/patches/minecraft/net/minecraft/world/item/crafting/SingleItemRecipe.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/SingleItemRecipe.java.patch new file mode 100644 index 0000000000..9e0e51b30d --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/crafting/SingleItemRecipe.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/item/crafting/SingleItemRecipe.java ++++ b/net/minecraft/world/item/crafting/SingleItemRecipe.java +@@ -60,7 +_,7 @@ + return this.f_44410_.m_41777_(); + } + +- public static class Serializer implements RecipeSerializer { ++ public static class Serializer extends net.minecraftforge.registries.ForgeRegistryEntry> implements RecipeSerializer { + final SingleItemRecipe.Serializer.SingleItemMaker f_44433_; + + protected Serializer(SingleItemRecipe.Serializer.SingleItemMaker p_44435_) { diff --git a/patches/minecraft/net/minecraft/world/item/crafting/UpgradeRecipe.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/UpgradeRecipe.java.patch new file mode 100644 index 0000000000..2ff05ab4cd --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/crafting/UpgradeRecipe.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/item/crafting/UpgradeRecipe.java ++++ b/net/minecraft/world/item/crafting/UpgradeRecipe.java +@@ -72,7 +_,7 @@ + }); + } + +- public static class Serializer implements RecipeSerializer { ++ public static class Serializer extends net.minecraftforge.registries.ForgeRegistryEntry> implements RecipeSerializer { + public UpgradeRecipe m_6729_(ResourceLocation p_44562_, JsonObject p_44563_) { + Ingredient ingredient = Ingredient.m_43917_(GsonHelper.m_13930_(p_44563_, "base")); + Ingredient ingredient1 = Ingredient.m_43917_(GsonHelper.m_13930_(p_44563_, "addition")); diff --git a/patches/minecraft/net/minecraft/world/item/enchantment/Enchantment.java.patch b/patches/minecraft/net/minecraft/world/item/enchantment/Enchantment.java.patch new file mode 100644 index 0000000000..3ab09a4642 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/enchantment/Enchantment.java.patch @@ -0,0 +1,61 @@ +--- a/net/minecraft/world/item/enchantment/Enchantment.java ++++ b/net/minecraft/world/item/enchantment/Enchantment.java +@@ -16,7 +_,8 @@ + import net.minecraft.world.entity.MobType; + import net.minecraft.world.item.ItemStack; + +-public abstract class Enchantment { ++public abstract class Enchantment extends net.minecraftforge.registries.ForgeRegistryEntry { ++ private final net.minecraftforge.common.util.ReverseTagWrapper reverseTags = new net.minecraftforge.common.util.ReverseTagWrapper<>(this, () -> net.minecraft.tags.SerializationTags.m_13199_().getCustomTypeCollection(net.minecraftforge.registries.ForgeRegistries.ENCHANTMENTS)); + private final EquipmentSlot[] f_44671_; + private final Enchantment.Rarity f_44674_; + public final EnchantmentCategory f_44672_; +@@ -34,6 +_,14 @@ + this.f_44671_ = p_44678_; + } + ++ public java.util.Set getTags() { ++ return reverseTags.getTagNames(); ++ } ++ ++ public boolean is(net.minecraft.tags.Tag tag) { ++ return tag.m_8110_(this); ++ } ++ + public Map m_44684_(LivingEntity p_44685_) { + Map map = Maps.newEnumMap(EquipmentSlot.class); + +@@ -111,7 +_,7 @@ + } + + public boolean m_6081_(ItemStack p_44689_) { +- return this.f_44672_.m_7454_(p_44689_.m_41720_()); ++ return canApplyAtEnchantingTable(p_44689_); + } + + public void m_7677_(LivingEntity p_44686_, Entity p_44687_, int p_44688_) { +@@ -133,6 +_,24 @@ + } + + public boolean m_6592_() { ++ return true; ++ } ++ ++ /** ++ * This applies specifically to applying at the enchanting table. The other method {@link #canApply(ItemStack)} ++ * applies for all possible enchantments. ++ * @param stack ++ * @return ++ */ ++ public boolean canApplyAtEnchantingTable(ItemStack stack) { ++ return stack.canApplyAtEnchantingTable(this); ++ } ++ ++ /** ++ * Is this enchantment allowed to be enchanted on books via Enchantment Table ++ * @return false to disable the vanilla feature ++ */ ++ public boolean isAllowedOnBooks() { + return true; + } + diff --git a/patches/minecraft/net/minecraft/world/item/enchantment/EnchantmentCategory.java.patch b/patches/minecraft/net/minecraft/world/item/enchantment/EnchantmentCategory.java.patch new file mode 100644 index 0000000000..16b5f15580 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/enchantment/EnchantmentCategory.java.patch @@ -0,0 +1,32 @@ +--- a/net/minecraft/world/item/enchantment/EnchantmentCategory.java ++++ b/net/minecraft/world/item/enchantment/EnchantmentCategory.java +@@ -13,7 +_,7 @@ + import net.minecraft.world.item.Wearable; + import net.minecraft.world.level.block.Block; + +-public enum EnchantmentCategory { ++public enum EnchantmentCategory implements net.minecraftforge.common.IExtensibleEnum { + ARMOR { + public boolean m_7454_(Item p_44751_) { + return p_44751_ instanceof ArmorItem; +@@ -85,5 +_,19 @@ + } + }; + +- public abstract boolean m_7454_(Item p_44743_); ++ private java.util.function.Predicate delegate; ++ ++ private EnchantmentCategory() {} ++ ++ private EnchantmentCategory(java.util.function.Predicate delegate) { ++ this.delegate = delegate; ++ } ++ ++ public static EnchantmentCategory create(String name, java.util.function.Predicate delegate) { ++ throw new IllegalStateException("Enum not extended"); ++ } ++ ++ public boolean m_7454_(Item p_44743_) { ++ return this.delegate == null ? false : this.delegate.test(p_44743_); ++ } + } diff --git a/patches/minecraft/net/minecraft/world/item/enchantment/EnchantmentHelper.java.patch b/patches/minecraft/net/minecraft/world/item/enchantment/EnchantmentHelper.java.patch new file mode 100644 index 0000000000..baa2255c1f --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/enchantment/EnchantmentHelper.java.patch @@ -0,0 +1,29 @@ +--- a/net/minecraft/world/item/enchantment/EnchantmentHelper.java ++++ b/net/minecraft/world/item/enchantment/EnchantmentHelper.java +@@ -298,7 +_,7 @@ + + public static int m_44872_(Random p_44873_, int p_44874_, int p_44875_, ItemStack p_44876_) { + Item item = p_44876_.m_41720_(); +- int i = item.m_6473_(); ++ int i = p_44876_.getItemEnchantability(); + if (i <= 0) { + return 0; + } else { +@@ -336,7 +_,7 @@ + public static List m_44909_(Random p_44910_, ItemStack p_44911_, int p_44912_, boolean p_44913_) { + List list = Lists.newArrayList(); + Item item = p_44911_.m_41720_(); +- int i = item.m_6473_(); ++ int i = p_44911_.getItemEnchantability(); + if (i <= 0) { + return list; + } else { +@@ -392,7 +_,7 @@ + boolean flag = p_44819_.m_150930_(Items.f_42517_); + + for(Enchantment enchantment : Registry.f_122825_) { +- if ((!enchantment.m_6591_() || p_44820_) && enchantment.m_6592_() && (enchantment.f_44672_.m_7454_(item) || flag)) { ++ if ((!enchantment.m_6591_() || p_44820_) && enchantment.m_6592_() && (enchantment.canApplyAtEnchantingTable(p_44819_) || (flag && enchantment.isAllowedOnBooks()))) { + for(int i = enchantment.m_6586_(); i > enchantment.m_44702_() - 1; --i) { + if (p_44818_ >= enchantment.m_6183_(i) && p_44818_ <= enchantment.m_6175_(i)) { + list.add(new EnchantmentInstance(enchantment, i)); diff --git a/patches/minecraft/net/minecraft/world/item/enchantment/Enchantments.java.patch b/patches/minecraft/net/minecraft/world/item/enchantment/Enchantments.java.patch new file mode 100644 index 0000000000..d9d2fafed6 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/enchantment/Enchantments.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/world/item/enchantment/Enchantments.java ++++ b/net/minecraft/world/item/enchantment/Enchantments.java +@@ -3,6 +_,7 @@ + import net.minecraft.core.Registry; + import net.minecraft.world.entity.EquipmentSlot; + ++@net.minecraftforge.registries.ObjectHolder("minecraft") + public class Enchantments { + private static final EquipmentSlot[] f_44964_ = new EquipmentSlot[]{EquipmentSlot.HEAD, EquipmentSlot.CHEST, EquipmentSlot.LEGS, EquipmentSlot.FEET}; + public static final Enchantment f_44965_ = m_44992_("protection", new ProtectionEnchantment(Enchantment.Rarity.COMMON, ProtectionEnchantment.Type.ALL, f_44964_)); diff --git a/patches/minecraft/net/minecraft/world/item/enchantment/FrostWalkerEnchantment.java.patch b/patches/minecraft/net/minecraft/world/item/enchantment/FrostWalkerEnchantment.java.patch new file mode 100644 index 0000000000..fc5f3b28c5 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/enchantment/FrostWalkerEnchantment.java.patch @@ -0,0 +1,12 @@ +--- a/net/minecraft/world/item/enchantment/FrostWalkerEnchantment.java ++++ b/net/minecraft/world/item/enchantment/FrostWalkerEnchantment.java +@@ -44,7 +_,8 @@ + BlockState blockstate1 = p_45020_.m_8055_(blockpos$mutableblockpos); + if (blockstate1.m_60795_()) { + BlockState blockstate2 = p_45020_.m_8055_(blockpos); +- if (blockstate2.m_60767_() == Material.f_76305_ && blockstate2.m_61143_(LiquidBlock.f_54688_) == 0 && blockstate.m_60710_(p_45020_, blockpos) && p_45020_.m_45752_(blockstate, blockpos, CollisionContext.m_82749_())) { ++ boolean isFull = blockstate2.m_60734_() == Blocks.f_49990_ && blockstate2.m_61143_(LiquidBlock.f_54688_) == 0; //TODO: Forge, modded waters? ++ if (blockstate2.m_60767_() == Material.f_76305_ && isFull && blockstate.m_60710_(p_45020_, blockpos) && p_45020_.m_45752_(blockstate, blockpos, CollisionContext.m_82749_()) && !net.minecraftforge.event.ForgeEventFactory.onBlockPlace(p_45019_, net.minecraftforge.common.util.BlockSnapshot.create(p_45020_.m_46472_(), p_45020_, blockpos), net.minecraft.core.Direction.UP)) { + p_45020_.m_46597_(blockpos, blockstate); + p_45020_.m_6219_().m_5945_(blockpos, Blocks.f_50449_, Mth.m_14072_(p_45019_.m_21187_(), 60, 120)); + } diff --git a/patches/minecraft/net/minecraft/world/item/trading/MerchantOffer.java.patch b/patches/minecraft/net/minecraft/world/item/trading/MerchantOffer.java.patch new file mode 100644 index 0000000000..64e78ca2cb --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/trading/MerchantOffer.java.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/world/item/trading/MerchantOffer.java ++++ b/net/minecraft/world/item/trading/MerchantOffer.java +@@ -75,7 +_,7 @@ + int i = this.f_45310_.m_41613_(); + ItemStack itemstack = this.f_45310_.m_41777_(); + int j = Math.max(0, Mth.m_14143_((float)(i * this.f_45317_) * this.f_45318_)); +- itemstack.m_41764_(Mth.m_14045_(i + j + this.f_45316_, 1, this.f_45310_.m_41720_().m_41459_())); ++ itemstack.m_41764_(Mth.m_14045_(i + j + this.f_45316_, 1, this.f_45310_.m_41741_())); + return itemstack; + } + +@@ -179,7 +_,7 @@ + return true; + } else { + ItemStack itemstack = p_45366_.m_41777_(); +- if (itemstack.m_41720_().m_41465_()) { ++ if (itemstack.m_41720_().isDamageable(itemstack)) { + itemstack.m_41721_(itemstack.m_41773_()); + } + diff --git a/patches/minecraft/net/minecraft/world/level/BaseSpawner.java.patch b/patches/minecraft/net/minecraft/world/level/BaseSpawner.java.patch new file mode 100644 index 0000000000..c3a15235c8 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/BaseSpawner.java.patch @@ -0,0 +1,27 @@ +--- a/net/minecraft/world/level/BaseSpawner.java ++++ b/net/minecraft/world/level/BaseSpawner.java +@@ -127,11 +_,12 @@ + entity.m_7678_(entity.m_20185_(), entity.m_20186_(), entity.m_20189_(), p_151312_.f_46441_.nextFloat() * 360.0F, 0.0F); + if (entity instanceof Mob) { + Mob mob = (Mob)entity; +- if (!mob.m_5545_(p_151312_, MobSpawnType.SPAWNER) || !mob.m_6914_(p_151312_)) { ++ if (!net.minecraftforge.event.ForgeEventFactory.canEntitySpawnSpawner(mob, p_151312_, (float)entity.m_20185_(), (float)entity.m_20186_(), (float)entity.m_20189_(), this)) { + continue; + } + + if (this.f_45444_.m_47265_().m_128440_() == 1 && this.f_45444_.m_47265_().m_128425_("id", 8)) { ++ if (!net.minecraftforge.event.ForgeEventFactory.doSpecialSpawn(mob, p_151312_, (float)entity.m_20185_(), (float)entity.m_20186_(), (float)entity.m_20189_(), this, MobSpawnType.SPAWNER)) + ((Mob)entity).m_6518_(p_151312_, p_151312_.m_6436_(entity.m_142538_()), MobSpawnType.SPAWNER, (SpawnGroupData)null, (CompoundTag)null); + } + } +@@ -271,5 +_,10 @@ + + public double m_45474_() { + return this.f_45446_; ++ } ++ ++ @Nullable ++ public Entity getSpawnerEntity() { ++ return null; + } + } diff --git a/patches/minecraft/net/minecraft/world/level/BlockGetter.java.patch b/patches/minecraft/net/minecraft/world/level/BlockGetter.java.patch new file mode 100644 index 0000000000..d6f63afde9 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/BlockGetter.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/BlockGetter.java ++++ b/net/minecraft/world/level/BlockGetter.java +@@ -32,7 +_,7 @@ + FluidState m_6425_(BlockPos p_45569_); + + default int m_7146_(BlockPos p_45572_) { +- return this.m_8055_(p_45572_).m_60791_(); ++ return this.m_8055_(p_45572_).getLightEmission(this, p_45572_); + } + + default int m_7469_() { diff --git a/patches/minecraft/net/minecraft/world/level/ClipContext.java.patch b/patches/minecraft/net/minecraft/world/level/ClipContext.java.patch new file mode 100644 index 0000000000..2ccd824150 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/ClipContext.java.patch @@ -0,0 +1,17 @@ +--- a/net/minecraft/world/level/ClipContext.java ++++ b/net/minecraft/world/level/ClipContext.java +@@ -18,12 +_,12 @@ + private final ClipContext.Fluid f_45685_; + private final CollisionContext f_45686_; + +- public ClipContext(Vec3 p_45688_, Vec3 p_45689_, ClipContext.Block p_45690_, ClipContext.Fluid p_45691_, Entity p_45692_) { ++ public ClipContext(Vec3 p_45688_, Vec3 p_45689_, ClipContext.Block p_45690_, ClipContext.Fluid p_45691_, @javax.annotation.Nullable Entity p_45692_) { + this.f_45682_ = p_45688_; + this.f_45683_ = p_45689_; + this.f_45684_ = p_45690_; + this.f_45685_ = p_45691_; +- this.f_45686_ = CollisionContext.m_82750_(p_45692_); ++ this.f_45686_ = p_45692_ == null ? CollisionContext.m_82749_() : CollisionContext.m_82750_(p_45692_); + } + + public Vec3 m_45693_() { diff --git a/patches/minecraft/net/minecraft/world/level/DataPackConfig.java.patch b/patches/minecraft/net/minecraft/world/level/DataPackConfig.java.patch new file mode 100644 index 0000000000..422609290a --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/DataPackConfig.java.patch @@ -0,0 +1,21 @@ +--- a/net/minecraft/world/level/DataPackConfig.java ++++ b/net/minecraft/world/level/DataPackConfig.java +@@ -18,7 +_,7 @@ + private final List f_45845_; + + public DataPackConfig(List p_45848_, List p_45849_) { +- this.f_45844_ = ImmutableList.copyOf(p_45848_); ++ this.f_45844_ = com.google.common.collect.Lists.newArrayList(p_45848_); + this.f_45845_ = ImmutableList.copyOf(p_45849_); + } + +@@ -28,5 +_,9 @@ + + public List m_45855_() { + return this.f_45845_; ++ } ++ ++ public void addModPacks(List modPacks) { ++ f_45844_.addAll(modPacks.stream().filter(p->!f_45844_.contains(p)).collect(java.util.stream.Collectors.toList())); + } + } diff --git a/patches/minecraft/net/minecraft/world/level/Explosion.java.patch b/patches/minecraft/net/minecraft/world/level/Explosion.java.patch new file mode 100644 index 0000000000..b5fda42660 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/Explosion.java.patch @@ -0,0 +1,61 @@ +--- a/net/minecraft/world/level/Explosion.java ++++ b/net/minecraft/world/level/Explosion.java +@@ -57,6 +_,7 @@ + private final ExplosionDamageCalculator f_46019_; + private final List f_46020_ = Lists.newArrayList(); + private final Map f_46021_ = Maps.newHashMap(); ++ private final Vec3 position; + + public Explosion(Level p_151471_, @Nullable Entity p_151472_, double p_151473_, double p_151474_, double p_151475_, float p_151476_) { + this(p_151471_, p_151472_, p_151473_, p_151474_, p_151475_, p_151476_, false, Explosion.BlockInteraction.DESTROY); +@@ -86,6 +_,7 @@ + this.f_46010_ = p_46060_; + this.f_46018_ = p_46053_ == null ? DamageSource.m_19358_(this) : p_46053_; + this.f_46019_ = p_46054_ == null ? this.m_46062_(p_46052_) : p_46054_; ++ this.position = new Vec3(this.f_46013_, this.f_46014_, this.f_46015_); + } + + private ExplosionDamageCalculator m_46062_(@Nullable Entity p_46063_) { +@@ -181,6 +_,7 @@ + int j2 = Mth.m_14107_(this.f_46015_ - (double)f2 - 1.0D); + int j1 = Mth.m_14107_(this.f_46015_ + (double)f2 + 1.0D); + List list = this.f_46012_.m_45933_(this.f_46016_, new AABB((double)k1, (double)i2, (double)j2, (double)l1, (double)i1, (double)j1)); ++ 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) { +@@ -242,7 +_,7 @@ + if (!blockstate.m_60795_()) { + BlockPos blockpos1 = blockpos.m_7949_(); + this.f_46012_.m_46473_().m_6180_("explosion_blocks"); +- if (block.m_6903_(this) && this.f_46012_ instanceof ServerLevel) { ++ if (blockstate.canDropFromExplosion(this.f_46012_, blockpos, this) && this.f_46012_ instanceof ServerLevel) { + BlockEntity blockentity = blockstate.m_155947_() ? this.f_46012_.m_7702_(blockpos) : null; + LootContext.Builder lootcontext$builder = (new LootContext.Builder((ServerLevel)this.f_46012_)).m_78977_(this.f_46012_.f_46441_).m_78972_(LootContextParams.f_81460_, Vec3.m_82512_(blockpos)).m_78972_(LootContextParams.f_81463_, ItemStack.f_41583_).m_78984_(LootContextParams.f_81462_, blockentity).m_78984_(LootContextParams.f_81455_, this.f_46016_); + if (this.f_46010_ == Explosion.BlockInteraction.DESTROY) { +@@ -254,8 +_,7 @@ + }); + } + +- this.f_46012_.m_7731_(blockpos, Blocks.f_50016_.m_49966_(), 3); +- block.m_7592_(this.f_46012_, blockpos, this); ++ blockstate.onBlockExploded(this.f_46012_, blockpos, this); + this.f_46012_.m_46473_().m_7238_(); + } + } +@@ -327,6 +_,15 @@ + + public List m_46081_() { + return this.f_46020_; ++ } ++ ++ public Vec3 getPosition() { ++ return this.position; ++ } ++ ++ @Nullable ++ public Entity getExploder() { ++ return this.f_46016_; + } + + public static enum BlockInteraction { diff --git a/patches/minecraft/net/minecraft/world/level/ExplosionDamageCalculator.java.patch b/patches/minecraft/net/minecraft/world/level/ExplosionDamageCalculator.java.patch new file mode 100644 index 0000000000..5a10defa2c --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/ExplosionDamageCalculator.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/ExplosionDamageCalculator.java ++++ b/net/minecraft/world/level/ExplosionDamageCalculator.java +@@ -7,7 +_,7 @@ + + public class ExplosionDamageCalculator { + public Optional m_6617_(Explosion p_46099_, BlockGetter p_46100_, BlockPos p_46101_, BlockState p_46102_, FluidState p_46103_) { +- return p_46102_.m_60795_() && p_46103_.m_76178_() ? Optional.empty() : Optional.of(Math.max(p_46102_.m_60734_().m_7325_(), p_46103_.m_76190_())); ++ return p_46102_.m_60795_() && p_46103_.m_76178_() ? Optional.empty() : Optional.of(Math.max(p_46102_.getExplosionResistance(p_46100_, p_46101_, p_46099_), p_46103_.getExplosionResistance(p_46100_, p_46101_, p_46099_))); + } + + public boolean m_6714_(Explosion p_46094_, BlockGetter p_46095_, BlockPos p_46096_, BlockState p_46097_, float p_46098_) { diff --git a/patches/minecraft/net/minecraft/world/level/ForcedChunksSavedData.java.patch b/patches/minecraft/net/minecraft/world/level/ForcedChunksSavedData.java.patch new file mode 100644 index 0000000000..24cafcb467 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/ForcedChunksSavedData.java.patch @@ -0,0 +1,35 @@ +--- a/net/minecraft/world/level/ForcedChunksSavedData.java ++++ b/net/minecraft/world/level/ForcedChunksSavedData.java +@@ -19,15 +_,31 @@ + } + + public static ForcedChunksSavedData m_151483_(CompoundTag p_151484_) { +- return new ForcedChunksSavedData(new LongOpenHashSet(p_151484_.m_128467_("Forced"))); ++ ForcedChunksSavedData savedData = new ForcedChunksSavedData(new LongOpenHashSet(p_151484_.m_128467_("Forced"))); ++ net.minecraftforge.common.world.ForgeChunkManager.readForgeForcedChunks(p_151484_, savedData.blockForcedChunks, savedData.entityForcedChunks); ++ return savedData; + } + + public CompoundTag m_7176_(CompoundTag p_46120_) { + p_46120_.m_128388_("Forced", this.f_46114_.toLongArray()); ++ net.minecraftforge.common.world.ForgeChunkManager.writeForgeForcedChunks(p_46120_, this.blockForcedChunks, this.entityForcedChunks); + return p_46120_; + } + + public LongSet m_46116_() { + return this.f_46114_; ++ } ++ ++ /* ======================================== FORGE START =====================================*/ ++ // TODO: not sure if these are being written correctly. load used to refer to these directly. ++ private net.minecraftforge.common.world.ForgeChunkManager.TicketTracker blockForcedChunks = new net.minecraftforge.common.world.ForgeChunkManager.TicketTracker<>(); ++ private net.minecraftforge.common.world.ForgeChunkManager.TicketTracker entityForcedChunks = new net.minecraftforge.common.world.ForgeChunkManager.TicketTracker<>(); ++ ++ public net.minecraftforge.common.world.ForgeChunkManager.TicketTracker getBlockForcedChunks() { ++ return this.blockForcedChunks; ++ } ++ ++ public net.minecraftforge.common.world.ForgeChunkManager.TicketTracker getEntityForcedChunks() { ++ return this.entityForcedChunks; + } + } diff --git a/patches/minecraft/net/minecraft/world/level/Level.java.patch b/patches/minecraft/net/minecraft/world/level/Level.java.patch new file mode 100644 index 0000000000..9fba42183c --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/Level.java.patch @@ -0,0 +1,221 @@ +--- a/net/minecraft/world/level/Level.java ++++ b/net/minecraft/world/level/Level.java +@@ -65,7 +_,7 @@ + import org.apache.logging.log4j.LogManager; + import org.apache.logging.log4j.Logger; + +-public abstract class Level implements LevelAccessor, AutoCloseable { ++public abstract class Level extends net.minecraftforge.common.capabilities.CapabilityProvider implements LevelAccessor, AutoCloseable, net.minecraftforge.common.extensions.IForgeLevel { + protected static final Logger f_46426_ = LogManager.getLogger(); + public static final Codec> f_46427_ = ResourceLocation.f_135803_.xmap(ResourceKey.m_135797_(Registry.f_122819_), ResourceKey::m_135782_); + public static final ResourceKey f_46428_ = ResourceKey.m_135785_(Registry.f_122819_, new ResourceLocation("overworld")); +@@ -82,6 +_,7 @@ + protected final List f_151512_ = Lists.newArrayList(); + private final List f_151503_ = Lists.newArrayList(); + private boolean f_151504_; ++ protected final java.util.Set f_46434_ = java.util.Collections.newSetFromMap(new java.util.IdentityHashMap<>()); // Forge: faster "contains" makes removal much more efficient + private final Thread f_46423_; + private final boolean f_46424_; + private int f_46425_; +@@ -99,8 +_,12 @@ + private final WorldBorder f_46447_; + private final BiomeManager f_46420_; + private final ResourceKey f_46421_; ++ public boolean restoringBlockSnapshots = false; ++ public boolean captureBlockSnapshots = false; ++ public java.util.ArrayList capturedBlockSnapshots = new java.util.ArrayList<>(); + + protected Level(WritableLevelData p_46450_, ResourceKey p_46451_, final DimensionType p_46452_, Supplier p_46453_, boolean p_46454_, boolean p_46455_, long p_46456_) { ++ super(Level.class); + this.f_46446_ = p_46453_; + this.f_46442_ = p_46450_; + this.f_46445_ = p_46452_; +@@ -180,17 +_,45 @@ + } else { + LevelChunk levelchunk = this.m_46745_(p_46605_); + Block block = p_46606_.m_60734_(); ++ ++ p_46605_ = p_46605_.m_7949_(); // Forge - prevent mutable BlockPos leaks ++ net.minecraftforge.common.util.BlockSnapshot blockSnapshot = null; ++ if (this.captureBlockSnapshots && !this.f_46443_) { ++ blockSnapshot = net.minecraftforge.common.util.BlockSnapshot.create(this.f_46421_, this, p_46605_, p_46607_); ++ this.capturedBlockSnapshots.add(blockSnapshot); ++ } ++ ++ BlockState old = m_8055_(p_46605_); ++ int oldLight = old.getLightEmission(this, p_46605_); ++ int oldOpacity = old.m_60739_(this, p_46605_); ++ + BlockState blockstate = levelchunk.m_6978_(p_46605_, p_46606_, (p_46607_ & 64) != 0); + if (blockstate == null) { ++ if (blockSnapshot != null) this.capturedBlockSnapshots.remove(blockSnapshot); + return false; + } else { + BlockState blockstate1 = this.m_8055_(p_46605_); +- if ((p_46607_ & 128) == 0 && blockstate1 != blockstate && (blockstate1.m_60739_(this, p_46605_) != blockstate.m_60739_(this, p_46605_) || blockstate1.m_60791_() != blockstate.m_60791_() || blockstate1.m_60787_() || blockstate.m_60787_())) { ++ if ((p_46607_ & 128) == 0 && blockstate1 != blockstate && (blockstate1.m_60739_(this, p_46605_) != oldOpacity || blockstate1.getLightEmission(this, p_46605_) != oldLight || blockstate1.m_60787_() || blockstate.m_60787_())) { + this.m_46473_().m_6180_("queueCheckLight"); + this.m_7726_().m_7827_().m_142202_(p_46605_); + this.m_46473_().m_7238_(); + } + ++ if (blockSnapshot == null) { // Don't notify clients or update physics while capturing blockstates ++ this.markAndNotifyBlock(p_46605_, levelchunk, blockstate, p_46606_, p_46607_, p_46608_); ++ } ++ ++ return true; ++ } ++ } ++ } ++ ++ // Split off from original setBlockState(BlockPos, BlockState, int, int) method in order to directly send client and physic updates ++ public void markAndNotifyBlock(BlockPos p_46605_, @Nullable LevelChunk levelchunk, BlockState blockstate, BlockState p_46606_, int p_46607_, int p_46608_) { ++ Block block = p_46606_.m_60734_(); ++ BlockState blockstate1 = m_8055_(p_46605_); ++ { ++ { + if (blockstate1 == p_46606_) { + if (blockstate != blockstate1) { + this.m_6550_(p_46605_, blockstate, blockstate1); +@@ -216,8 +_,6 @@ + + this.m_6559_(p_46605_, blockstate, blockstate1); + } +- +- return true; + } + } + } +@@ -267,6 +_,8 @@ + } + + public void m_46672_(BlockPos p_46673_, Block p_46674_) { ++ if (net.minecraftforge.event.ForgeEventFactory.onNeighborNotify(this, p_46673_, this.m_8055_(p_46673_), java.util.EnumSet.allOf(Direction.class), false).isCanceled()) ++ return; + this.m_46586_(p_46673_.m_142125_(), p_46674_, p_46673_); + this.m_46586_(p_46673_.m_142126_(), p_46674_, p_46673_); + this.m_46586_(p_46673_.m_7495_(), p_46674_, p_46673_); +@@ -276,6 +_,11 @@ + } + + public void m_46590_(BlockPos p_46591_, Block p_46592_, Direction p_46593_) { ++ java.util.EnumSet directions = java.util.EnumSet.allOf(Direction.class); ++ directions.remove(p_46593_); ++ if (net.minecraftforge.event.ForgeEventFactory.onNeighborNotify(this, p_46591_, this.m_8055_(p_46591_), directions, false).isCanceled()) ++ return; ++ + if (p_46593_ != Direction.WEST) { + this.m_46586_(p_46591_.m_142125_(), p_46592_, p_46591_); + } +@@ -313,9 +_,9 @@ + CrashReportCategory crashreportcategory = crashreport.m_127514_("Block being updated"); + crashreportcategory.m_128165_("Source block type", () -> { + try { +- return String.format("ID #%s (%s // %s)", Registry.f_122824_.m_7981_(p_46588_), p_46588_.m_7705_(), p_46588_.getClass().getCanonicalName()); ++ return String.format("ID #%s (%s // %s)", p_46588_.getRegistryName(), p_46588_.m_7705_(), p_46588_.getClass().getCanonicalName()); + } catch (Throwable throwable1) { +- return "ID #" + Registry.f_122824_.m_7981_(p_46588_); ++ return "ID #" + p_46588_.getRegistryName(); + } + }); + CrashReportCategory.m_178950_(crashreportcategory, this, p_46587_, blockstate); +@@ -404,8 +_,9 @@ + protected void m_46463_() { + ProfilerFiller profilerfiller = this.m_46473_(); + profilerfiller.m_6180_("blockEntities"); +- this.f_151504_ = true; ++ this.f_151504_ = true;// Forge: Move above remove to prevent CMEs + if (!this.f_151503_.isEmpty()) { ++ this.f_46434_.forEach(e -> e.onChunkUnloaded()); + this.f_151512_.addAll(this.f_151503_); + this.f_151503_.clear(); + } +@@ -427,12 +_,15 @@ + + public void m_46653_(Consumer p_46654_, T p_46655_) { + try { ++ net.minecraftforge.server.timings.TimeTracker.ENTITY_UPDATE.trackStart(p_46655_); + p_46654_.accept(p_46655_); + } catch (Throwable throwable) { + CrashReport crashreport = CrashReport.m_127521_(throwable, "Ticking entity"); + CrashReportCategory crashreportcategory = crashreport.m_127514_("Entity being ticked"); + p_46655_.m_7976_(crashreportcategory); + throw new ReportedException(crashreport); ++ } finally { ++ net.minecraftforge.server.timings.TimeTracker.ENTITY_UPDATE.trackEnd(p_46655_); + } + } + +@@ -446,6 +_,7 @@ + + public Explosion m_7703_(@Nullable Entity p_46526_, @Nullable DamageSource p_46527_, @Nullable ExplosionDamageCalculator p_46528_, double p_46529_, double p_46530_, double p_46531_, float p_46532_, boolean p_46533_, Explosion.BlockInteraction p_46534_) { + Explosion explosion = new Explosion(this, p_46526_, p_46527_, p_46528_, p_46529_, p_46530_, p_46531_, p_46532_, p_46533_, p_46534_); ++ if (net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this, explosion)) return explosion; + explosion.m_46061_(); + explosion.m_46075_(true); + return explosion; +@@ -473,6 +_,7 @@ + if (!this.m_151570_(p_46748_)) { + this.m_46745_(p_46748_).m_8114_(p_46748_); + } ++ this.m_46717_(p_46748_, m_8055_(p_46748_).m_60734_()); //Notify neighbors of changes + } + + public boolean m_46749_(BlockPos p_46750_) { +@@ -571,6 +_,7 @@ + this.m_46745_(p_151544_).m_6427_(); + } + ++ this.m_46717_(p_151544_, m_8055_(p_151544_).m_60734_()); //Notify neighbors of changes + } + + public int m_5736_() { +@@ -615,7 +_,7 @@ + public int m_46681_(BlockPos p_46682_, Direction p_46683_) { + BlockState blockstate = this.m_8055_(p_46682_); + int i = blockstate.m_60746_(this, p_46682_, p_46683_); +- return blockstate.m_60796_(this, p_46682_) ? Math.max(i, this.m_46751_(p_46682_)) : i; ++ return blockstate.shouldCheckWeakPower(this, p_46682_, p_46683_) ? Math.max(i, this.m_46751_(p_46682_)) : i; + } + + public boolean m_46753_(BlockPos p_46754_) { +@@ -768,16 +_,15 @@ + public abstract Scoreboard m_6188_(); + + public void m_46717_(BlockPos p_46718_, Block p_46719_) { +- for(Direction direction : Direction.Plane.HORIZONTAL) { ++ for(Direction direction : Direction.values()) { + BlockPos blockpos = p_46718_.m_142300_(direction); + if (this.m_46805_(blockpos)) { + BlockState blockstate = this.m_8055_(blockpos); +- if (blockstate.m_60713_(Blocks.f_50328_)) { +- blockstate.m_60690_(this, blockpos, p_46719_, p_46718_, false); +- } else if (blockstate.m_60796_(this, blockpos)) { ++ blockstate.onNeighborChange(this, blockpos, p_46718_); ++ if (blockstate.m_60796_(this, blockpos)) { + blockpos = blockpos.m_142300_(direction); + blockstate = this.m_8055_(blockpos); +- if (blockstate.m_60713_(Blocks.f_50328_)) { ++ if (blockstate.getWeakChanges(this, blockpos)) { + blockstate.m_60690_(this, blockpos, p_46719_, p_46718_, false); + } + } +@@ -856,6 +_,18 @@ + + public BiomeManager m_7062_() { + return this.f_46420_; ++ } ++ ++ private double maxEntityRadius = 2.0D; ++ @Override ++ public double getMaxEntityRadius() { ++ return maxEntityRadius; ++ } ++ @Override ++ public double increaseMaxEntityRadius(double value) { ++ if (value > maxEntityRadius) ++ maxEntityRadius = value; ++ return maxEntityRadius; + } + + public final boolean m_46659_() { diff --git a/patches/minecraft/net/minecraft/world/level/LevelReader.java.patch b/patches/minecraft/net/minecraft/world/level/LevelReader.java.patch new file mode 100644 index 0000000000..857e64ee46 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/LevelReader.java.patch @@ -0,0 +1,13 @@ +--- a/net/minecraft/world/level/LevelReader.java ++++ b/net/minecraft/world/level/LevelReader.java +@@ -169,6 +_,10 @@ + return this.m_151577_(p_46806_.m_123341_(), p_46806_.m_123343_()); + } + ++ default boolean isAreaLoaded(BlockPos center, int range) { ++ return this.m_46832_(center.m_142082_(-range, -range, -range), center.m_142082_(range, range, range)); ++ } ++ + @Deprecated + default boolean m_46832_(BlockPos p_46833_, BlockPos p_46834_) { + return this.m_46812_(p_46833_.m_123341_(), p_46833_.m_123342_(), p_46833_.m_123343_(), p_46834_.m_123341_(), p_46834_.m_123342_(), p_46834_.m_123343_()); diff --git a/patches/minecraft/net/minecraft/world/level/LevelSettings.java.patch b/patches/minecraft/net/minecraft/world/level/LevelSettings.java.patch new file mode 100644 index 0000000000..ae9c0d0e6c --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/LevelSettings.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/world/level/LevelSettings.java ++++ b/net/minecraft/world/level/LevelSettings.java +@@ -62,6 +_,7 @@ + } + + public LevelSettings m_46918_(Difficulty p_46919_) { ++ net.minecraftforge.common.ForgeHooks.onDifficultyChange(p_46919_, this.f_46905_); + return new LevelSettings(this.f_46902_, this.f_46903_, this.f_46904_, p_46919_, this.f_46906_, this.f_46907_, this.f_46908_); + } + diff --git a/patches/minecraft/net/minecraft/world/level/NaturalSpawner.java.patch b/patches/minecraft/net/minecraft/world/level/NaturalSpawner.java.patch new file mode 100644 index 0000000000..48dfcb86f8 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/NaturalSpawner.java.patch @@ -0,0 +1,75 @@ +--- a/net/minecraft/world/level/NaturalSpawner.java ++++ b/net/minecraft/world/level/NaturalSpawner.java +@@ -45,6 +_,7 @@ + import org.apache.logging.log4j.LogManager; + import org.apache.logging.log4j.Logger; + ++// TODO: ForgeEventFactory.getPotentialSpawns, ForgeHooks.canEntitySpawn + public final class NaturalSpawner { + private static final Logger f_46977_ = LogManager.getLogger(); + private static final int f_151589_ = 24; +@@ -81,7 +_,7 @@ + mob = (Mob)entity; + } while(mob.m_21532_() || mob.m_8023_()); + +- MobCategory mobcategory = entity.m_6095_().m_20674_(); ++ MobCategory mobcategory = entity.getClassification(true); + if (mobcategory != MobCategory.MISC) { + Entity finalEntity = entity; + BlockPos blockpos = entity.m_142538_(); +@@ -174,13 +_,15 @@ + } + + mob.m_7678_(d0, (double)i, d1, p_47040_.f_46441_.nextFloat() * 360.0F, 0.0F); +- if (m_46991_(p_47040_, mob, d2)) { ++ int canSpawn = net.minecraftforge.common.ForgeHooks.canEntitySpawn(mob, p_47040_, d0, i, d1, null, MobSpawnType.NATURAL); ++ if (canSpawn != -1 && (canSpawn == 1 || m_46991_(p_47040_, mob, d2))) { ++ if (!net.minecraftforge.event.ForgeEventFactory.doSpecialSpawn(mob, p_47040_, (float)d0, (float)i, (float)d1, null, MobSpawnType.NATURAL)) + spawngroupdata = mob.m_6518_(p_47040_, p_47040_.m_6436_(mob.m_142538_()), MobSpawnType.NATURAL, spawngroupdata, (CompoundTag)null); + ++j; + ++l1; + p_47040_.m_47205_(mob); + p_47044_.m_47100_(mob, p_47041_); +- if (j >= mob.m_5792_()) { ++ if (j >= net.minecraftforge.event.ForgeEventFactory.getMaxSpawnPackSize(mob)) { + return; + } + +@@ -290,6 +_,13 @@ + if (p_47052_ == SpawnPlacements.Type.NO_RESTRICTIONS) { + return true; + } else if (p_47055_ != null && p_47053_.m_6857_().m_61937_(p_47054_)) { ++ return p_47052_.canSpawnAt(p_47053_, p_47054_, p_47055_); ++ } ++ return false; ++ } ++ ++ public static boolean canSpawnAtBody(SpawnPlacements.Type p_47052_, LevelReader p_47053_, BlockPos p_47054_, @Nullable EntityType p_47055_) { ++ { + BlockState blockstate = p_47053_.m_8055_(p_47054_); + FluidState fluidstate = p_47053_.m_6425_(p_47054_); + BlockPos blockpos = p_47054_.m_7494_(); +@@ -302,14 +_,12 @@ + case ON_GROUND: + default: + BlockState blockstate1 = p_47053_.m_8055_(blockpos1); +- if (!blockstate1.m_60643_(p_47053_, blockpos1, p_47055_)) { ++ if (!blockstate1.canCreatureSpawn(p_47053_, blockpos1, p_47052_, p_47055_)) { + return false; + } else { + return m_47056_(p_47053_, p_47054_, blockstate, fluidstate, p_47055_) && m_47056_(p_47053_, blockpos, p_47053_.m_8055_(blockpos), p_47053_.m_6425_(blockpos), p_47055_); + } + } +- } else { +- return false; + } + } + +@@ -355,6 +_,7 @@ + entity.m_7678_(d0, (double)blockpos.m_123342_(), d1, p_151620_.nextFloat() * 360.0F, 0.0F); + if (entity instanceof Mob) { + Mob mob = (Mob)entity; ++ if (net.minecraftforge.common.ForgeHooks.canEntitySpawn(mob, p_151617_, d0, blockpos.m_123342_(), d1, null, MobSpawnType.CHUNK_GENERATION) == -1) continue; + if (mob.m_5545_(p_151617_, MobSpawnType.CHUNK_GENERATION) && mob.m_6914_(p_151617_)) { + spawngroupdata = mob.m_6518_(p_151617_, p_151617_.m_6436_(mob.m_142538_()), MobSpawnType.CHUNK_GENERATION, spawngroupdata, (CompoundTag)null); + p_151617_.m_47205_(mob); diff --git a/patches/minecraft/net/minecraft/world/level/biome/Biome.java.patch b/patches/minecraft/net/minecraft/world/level/biome/Biome.java.patch new file mode 100644 index 0000000000..7d2a332a4c --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/biome/Biome.java.patch @@ -0,0 +1,22 @@ +--- a/net/minecraft/world/level/biome/Biome.java ++++ b/net/minecraft/world/level/biome/Biome.java +@@ -51,7 +_,7 @@ + import org.apache.logging.log4j.LogManager; + import org.apache.logging.log4j.Logger; + +-public final class Biome { ++public final class Biome extends net.minecraftforge.registries.ForgeRegistryEntry.UncheckedRegistryEntry { + public static final Logger f_47428_ = LogManager.getLogger(); + public static final Codec f_47429_ = RecordCodecBuilder.create((p_47527_) -> { + return p_47527_.group(Biome.ClimateSettings.f_47679_.forGetter((p_151717_) -> { +@@ -68,7 +_,9 @@ + return p_151707_.f_47438_; + }), MobSpawnSettings.f_48327_.forGetter((p_151705_) -> { + return p_151705_.f_47439_; +- })).apply(p_47527_, Biome::new); ++ }), ResourceLocation.f_135803_.optionalFieldOf("forge:registry_name").forGetter(b -> Optional.ofNullable(b.getRegistryName()))) ++ .apply(p_47527_, (climate, category, depth, scale, effects, gen, spawns, name) -> ++ net.minecraftforge.common.ForgeHooks.enhanceBiome(name.orElse(null), climate, category, depth, scale, effects, gen, spawns, p_47527_, Biome::new)); + }); + public static final Codec f_47430_ = RecordCodecBuilder.create((p_47504_) -> { + return p_47504_.group(Biome.ClimateSettings.f_47679_.forGetter((p_151703_) -> { diff --git a/patches/minecraft/net/minecraft/world/level/biome/BiomeGenerationSettings.java.patch b/patches/minecraft/net/minecraft/world/level/biome/BiomeGenerationSettings.java.patch new file mode 100644 index 0000000000..f86043f75f --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/biome/BiomeGenerationSettings.java.patch @@ -0,0 +1,26 @@ +--- a/net/minecraft/world/level/biome/BiomeGenerationSettings.java ++++ b/net/minecraft/world/level/biome/BiomeGenerationSettings.java +@@ -48,6 +_,7 @@ + }); + private final Supplier> f_47779_; + private final Map>>> f_47780_; ++ private final java.util.Set carversView; + private final List>>> f_47781_; + private final List>> f_47782_; + private final List> f_47783_; +@@ -60,10 +_,15 @@ + this.f_47783_ = p_47788_.stream().flatMap(Collection::stream).map(Supplier::get).flatMap(ConfiguredFeature::m_65398_).filter((p_47802_) -> { + return p_47802_.f_65377_ == Feature.f_65761_; + }).collect(ImmutableList.toImmutableList()); ++ this.carversView = java.util.Collections.unmodifiableSet(f_47780_.keySet()); + } + + public List>> m_47799_(GenerationStep.Carving p_47800_) { + return this.f_47780_.getOrDefault(p_47800_, ImmutableList.of()); ++ } ++ ++ public java.util.Set getCarvingStages() { ++ return this.carversView; + } + + public boolean m_47808_(StructureFeature p_47809_) { diff --git a/patches/minecraft/net/minecraft/world/level/biome/BiomeSpecialEffects.java.patch b/patches/minecraft/net/minecraft/world/level/biome/BiomeSpecialEffects.java.patch new file mode 100644 index 0000000000..cf77f52a52 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/biome/BiomeSpecialEffects.java.patch @@ -0,0 +1,49 @@ +--- a/net/minecraft/world/level/biome/BiomeSpecialEffects.java ++++ b/net/minecraft/world/level/biome/BiomeSpecialEffects.java +@@ -202,7 +_,7 @@ + } + } + +- public static enum GrassColorModifier implements StringRepresentable { ++ public static enum GrassColorModifier implements StringRepresentable, net.minecraftforge.common.IExtensibleEnum { + NONE("none") { + public int m_6583_(double p_48081_, double p_48082_, int p_48083_) { + return p_48083_; +@@ -221,17 +_,35 @@ + }; + + private final String f_48051_; +- public static final Codec f_48050_ = StringRepresentable.m_14350_(BiomeSpecialEffects.GrassColorModifier::values, BiomeSpecialEffects.GrassColorModifier::m_48070_); ++ public static final Codec f_48050_ = net.minecraftforge.common.IExtensibleEnum.createCodecForExtensibleEnum(BiomeSpecialEffects.GrassColorModifier::values, BiomeSpecialEffects.GrassColorModifier::m_48070_); + private static final Map f_48052_ = Arrays.stream(values()).collect(Collectors.toMap(BiomeSpecialEffects.GrassColorModifier::m_48072_, (p_48069_) -> { + return p_48069_; + })); + +- public abstract int m_6583_(double p_48065_, double p_48066_, int p_48067_); ++ public int m_6583_(double p_48065_, double p_48066_, int p_48067_) { ++ return delegate.modifyGrassColor(p_48065_, p_48066_, p_48067_); ++ } + + GrassColorModifier(String p_48058_) { + this.f_48051_ = p_48058_; + } + ++ private ColorModifier delegate; ++ private GrassColorModifier(String name, ColorModifier delegate) { ++ this(name); ++ this.delegate = delegate; ++ } ++ public static GrassColorModifier create(String name, String id, ColorModifier delegate) { ++ throw new IllegalStateException("Enum not extended"); ++ } ++ @Override ++ public void init() { ++ f_48052_.put(this.m_48072_(), this); ++ } ++ @FunctionalInterface ++ public interface ColorModifier { ++ int modifyGrassColor(double x, double z, int color); ++ } + public String m_48072_() { + return this.f_48051_; + } diff --git a/patches/minecraft/net/minecraft/world/level/biome/MobSpawnSettings.java.patch b/patches/minecraft/net/minecraft/world/level/biome/MobSpawnSettings.java.patch new file mode 100644 index 0000000000..c81a8d6204 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/biome/MobSpawnSettings.java.patch @@ -0,0 +1,36 @@ +--- a/net/minecraft/world/level/biome/MobSpawnSettings.java ++++ b/net/minecraft/world/level/biome/MobSpawnSettings.java +@@ -44,21 +_,33 @@ + private final Map> f_48329_; + private final Map, MobSpawnSettings.MobSpawnCost> f_48330_; + private final boolean f_48331_; ++ private final java.util.Set typesView; ++ private final java.util.Set> costView; + + MobSpawnSettings(float p_48334_, Map> p_48335_, Map, MobSpawnSettings.MobSpawnCost> p_48336_, boolean p_48337_) { + this.f_48328_ = p_48334_; + this.f_48329_ = ImmutableMap.copyOf(p_48335_); + this.f_48330_ = ImmutableMap.copyOf(p_48336_); + this.f_48331_ = p_48337_; ++ this.typesView = java.util.Collections.unmodifiableSet(this.f_48329_.keySet()); ++ this.costView = java.util.Collections.unmodifiableSet(this.f_48330_.keySet()); + } + + public WeightedRandomList m_151798_(MobCategory p_151799_) { + return this.f_48329_.getOrDefault(p_151799_, f_151796_); + } + ++ public java.util.Set getSpawnerTypes() { ++ return this.typesView; ++ } ++ + @Nullable + public MobSpawnSettings.MobSpawnCost m_48345_(EntityType p_48346_) { + return this.f_48330_.get(p_48346_); ++ } ++ ++ public java.util.Set> getEntityTypes() { ++ return this.costView; + } + + public float m_48344_() { diff --git a/patches/minecraft/net/minecraft/world/level/biome/OverworldBiomeSource.java.patch b/patches/minecraft/net/minecraft/world/level/biome/OverworldBiomeSource.java.patch new file mode 100644 index 0000000000..5b82df17d0 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/biome/OverworldBiomeSource.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/biome/OverworldBiomeSource.java ++++ b/net/minecraft/world/level/biome/OverworldBiomeSource.java +@@ -31,7 +_,7 @@ + private final Registry f_48587_; + + public OverworldBiomeSource(long p_48590_, boolean p_48591_, boolean p_48592_, Registry p_48593_) { +- super(f_48583_.stream().map((p_48603_) -> { ++ super(java.util.stream.Stream.concat(f_48583_.stream(), net.minecraftforge.common.BiomeManager.getAdditionalOverworldBiomes().stream()).map((p_48603_) -> { + return () -> { + return p_48593_.m_123013_(p_48603_); + }; diff --git a/patches/minecraft/net/minecraft/world/level/block/BambooBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/BambooBlock.java.patch new file mode 100644 index 0000000000..06fd879783 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/BambooBlock.java.patch @@ -0,0 +1,16 @@ +--- a/net/minecraft/world/level/block/BambooBlock.java ++++ b/net/minecraft/world/level/block/BambooBlock.java +@@ -114,10 +_,11 @@ + + public void m_7455_(BlockState p_48936_, ServerLevel p_48937_, BlockPos p_48938_, Random p_48939_) { + if (p_48936_.m_61143_(f_48871_) == 0) { +- if (p_48939_.nextInt(3) == 0 && p_48937_.m_46859_(p_48938_.m_7494_()) && p_48937_.m_45524_(p_48938_.m_7494_(), 0) >= 9) { ++ if (p_48937_.m_46859_(p_48938_.m_7494_()) && p_48937_.m_45524_(p_48938_.m_7494_(), 0) >= 9) { + int i = this.m_48932_(p_48937_, p_48938_) + 1; +- if (i < 16) { ++ if (i < 16 && net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_48937_, p_48938_, p_48936_, p_48939_.nextInt(3) == 0)) { + this.m_48910_(p_48936_, p_48937_, p_48938_, p_48939_, i); ++ net.minecraftforge.common.ForgeHooks.onCropsGrowPost(p_48937_, p_48938_, p_48936_); + } + } + diff --git a/patches/minecraft/net/minecraft/world/level/block/BaseFireBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/BaseFireBlock.java.patch new file mode 100644 index 0000000000..7d61eb335c --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/BaseFireBlock.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/world/level/block/BaseFireBlock.java ++++ b/net/minecraft/world/level/block/BaseFireBlock.java +@@ -126,6 +_,7 @@ + if (!p_49282_.m_60713_(p_49279_.m_60734_())) { + if (m_49248_(p_49280_)) { + Optional optional = PortalShape.m_77708_(p_49280_, p_49281_, Direction.Axis.X); ++ optional = net.minecraftforge.event.ForgeEventFactory.onTrySpawnPortal(p_49280_, p_49281_, optional); + if (optional.isPresent()) { + optional.get().m_77743_(); + return; diff --git a/patches/minecraft/net/minecraft/world/level/block/BaseRailBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/BaseRailBlock.java.patch new file mode 100644 index 0000000000..836c36bb20 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/BaseRailBlock.java.patch @@ -0,0 +1,64 @@ +--- a/net/minecraft/world/level/block/BaseRailBlock.java ++++ b/net/minecraft/world/level/block/BaseRailBlock.java +@@ -20,7 +_,7 @@ + import net.minecraft.world.phys.shapes.CollisionContext; + import net.minecraft.world.phys.shapes.VoxelShape; + +-public abstract class BaseRailBlock extends Block implements SimpleWaterloggedBlock { ++public abstract class BaseRailBlock extends Block implements net.minecraftforge.common.extensions.IForgeBaseRailBlock { + protected static final VoxelShape f_49355_ = Block.m_49796_(0.0D, 0.0D, 0.0D, 16.0D, 2.0D, 16.0D); + protected static final VoxelShape f_49356_ = Block.m_49796_(0.0D, 0.0D, 0.0D, 16.0D, 8.0D, 16.0D); + public static final BooleanProperty f_152149_ = BlockStateProperties.f_61362_; +@@ -45,6 +_,7 @@ + + public VoxelShape m_5940_(BlockState p_49403_, BlockGetter p_49404_, BlockPos p_49405_, CollisionContext p_49406_) { + RailShape railshape = p_49403_.m_60713_(this) ? p_49403_.m_61143_(this.m_7978_()) : null; ++ RailShape railShape2 = p_49403_.m_60713_(this) ? getRailDirection(p_49403_, p_49404_, p_49405_, null) : null; + return railshape != null && railshape.m_61745_() ? f_49356_ : f_49355_; + } + +@@ -69,7 +_,7 @@ + + public void m_6861_(BlockState p_49377_, Level p_49378_, BlockPos p_49379_, Block p_49380_, BlockPos p_49381_, boolean p_49382_) { + if (!p_49378_.f_46443_ && p_49378_.m_8055_(p_49379_).m_60713_(this)) { +- RailShape railshape = p_49377_.m_61143_(this.m_7978_()); ++ RailShape railshape = getRailDirection(p_49377_, p_49378_, p_49379_, null); + if (m_49398_(p_49379_, p_49378_, railshape)) { + m_49950_(p_49377_, p_49378_, p_49379_); + p_49378_.m_7471_(p_49379_, p_49382_); +@@ -118,7 +_,7 @@ + public void m_6810_(BlockState p_49384_, Level p_49385_, BlockPos p_49386_, BlockState p_49387_, boolean p_49388_) { + if (!p_49388_) { + super.m_6810_(p_49384_, p_49385_, p_49386_, p_49387_, p_49388_); +- if (p_49384_.m_61143_(this.m_7978_()).m_61745_()) { ++ if (getRailDirection(p_49384_, p_49385_, p_49386_, null).m_61745_()) { + p_49385_.m_46672_(p_49386_.m_7494_(), this); + } + +@@ -139,6 +_,7 @@ + return blockstate.m_61124_(this.m_7978_(), flag1 ? RailShape.EAST_WEST : RailShape.NORTH_SOUTH).m_61124_(f_152149_, Boolean.valueOf(flag)); + } + ++ @Deprecated //Forge: Use getRailDirection(IBlockAccess, BlockPos, IBlockState, EntityMinecart) for enhanced ability + public abstract Property m_7978_(); + + public BlockState m_7417_(BlockState p_152151_, Direction p_152152_, BlockState p_152153_, LevelAccessor p_152154_, BlockPos p_152155_, BlockPos p_152156_) { +@@ -152,4 +_,18 @@ + public FluidState m_5888_(BlockState p_152158_) { + return p_152158_.m_61143_(f_152149_) ? Fluids.f_76193_.m_76068_(false) : super.m_5888_(p_152158_); + } ++ ++ /* ======================================== FORGE START =====================================*/ ++ ++ @Override ++ public boolean isFlexibleRail(BlockState state, BlockGetter world, BlockPos pos) ++ { ++ return !this.f_49357_; ++ } ++ ++ @Override ++ public RailShape getRailDirection(BlockState state, BlockGetter world, BlockPos pos, @javax.annotation.Nullable net.minecraft.world.entity.vehicle.AbstractMinecart cart) { ++ return state.m_61143_(m_7978_()); ++ } ++ /* ========================================= FORGE END ======================================*/ + } diff --git a/patches/minecraft/net/minecraft/world/level/block/BeehiveBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/BeehiveBlock.java.patch new file mode 100644 index 0000000000..0e949b86be --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/BeehiveBlock.java.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/world/level/block/BeehiveBlock.java ++++ b/net/minecraft/world/level/block/BeehiveBlock.java +@@ -71,6 +_,9 @@ + public int m_6782_(BlockState p_49620_, Level p_49621_, BlockPos p_49622_) { + return p_49620_.m_61143_(f_49564_); + } ++ // Forge: Fixed MC-227255 Beehives and bee nests do not rotate/mirror correctly in structure blocks ++ @Override public BlockState m_6843_(BlockState blockState, net.minecraft.world.level.block.Rotation rotation) { return blockState.m_61124_(f_49563_, rotation.m_55954_(blockState.m_61143_(f_49563_))); } ++ @Override public BlockState m_6943_(BlockState blockState, net.minecraft.world.level.block.Mirror mirror) { return blockState.m_60717_(mirror.m_54846_(blockState.m_61143_(f_49563_))); } + + public void m_6240_(Level p_49584_, Player p_49585_, BlockPos p_49586_, BlockState p_49587_, @Nullable BlockEntity p_49588_, ItemStack p_49589_) { + super.m_6240_(p_49584_, p_49585_, p_49586_, p_49587_, p_49588_, p_49589_); +@@ -91,6 +_,7 @@ + List list = p_49650_.m_45976_(Bee.class, (new AABB(p_49651_)).m_82377_(8.0D, 6.0D, 8.0D)); + if (!list.isEmpty()) { + List list1 = p_49650_.m_45976_(Player.class, (new AABB(p_49651_)).m_82377_(8.0D, 6.0D, 8.0D)); ++ if (list1.isEmpty()) return; //Forge: Prevent Error when no players are around. + int i = list1.size(); + + for(Bee bee : list) { diff --git a/patches/minecraft/net/minecraft/world/level/block/Block.java.patch b/patches/minecraft/net/minecraft/world/level/block/Block.java.patch new file mode 100644 index 0000000000..31e4e24a82 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/Block.java.patch @@ -0,0 +1,203 @@ +--- a/net/minecraft/world/level/block/Block.java ++++ b/net/minecraft/world/level/block/Block.java +@@ -62,9 +_,10 @@ + import org.apache.logging.log4j.LogManager; + import org.apache.logging.log4j.Logger; + +-public class Block extends BlockBehaviour implements ItemLike { ++public class Block extends BlockBehaviour implements ItemLike, net.minecraftforge.common.extensions.IForgeBlock { + protected static final Logger f_49790_ = LogManager.getLogger(); +- public static final IdMapper f_49791_ = new IdMapper<>(); ++ @Deprecated //Forge: Do not use, use GameRegistry ++ public static final IdMapper f_49791_ = net.minecraftforge.registries.GameData.getBlockStateIDMap(); + private static final LoadingCache f_49785_ = CacheBuilder.newBuilder().maximumSize(512L).weakKeys().build(new CacheLoader() { + public Boolean load(VoxelShape p_49972_) { + return !Shapes.m_83157_(Shapes.m_83144_(), p_49972_, BooleanOp.f_82687_); +@@ -169,6 +_,8 @@ + super(p_49795_); + StateDefinition.Builder builder = new StateDefinition.Builder<>(this); + this.m_7926_(builder); ++ this.harvestLevel = p_49795_.getHarvestLevel(); ++ this.harvestTool = p_49795_.getHarvestTool(); + this.f_49792_ = builder.m_61101_(Block::m_49966_, BlockState::new); + this.m_49959_(this.f_49792_.m_61090_()); + if (SharedConstants.f_136183_) { +@@ -177,7 +_,7 @@ + f_49790_.error("Block classes should end with Block and {} doesn't.", (Object)s); + } + } +- ++ initClient(); + } + + public static boolean m_152463_(BlockState p_152464_) { +@@ -323,7 +_,7 @@ + } + + private static void m_152440_(Level p_152441_, Supplier p_152442_, ItemStack p_152443_) { +- if (!p_152441_.f_46443_ && !p_152443_.m_41619_() && p_152441_.m_46469_().m_46207_(GameRules.f_46136_)) { ++ if (!p_152441_.f_46443_ && !p_152443_.m_41619_() && p_152441_.m_46469_().m_46207_(GameRules.f_46136_) && !p_152441_.restoringBlockSnapshots) { + ItemEntity itementity = p_152442_.get(); + itementity.m_32060_(); + p_152441_.m_7967_(itementity); +@@ -331,12 +_,13 @@ + } + + public void m_49805_(ServerLevel p_49806_, BlockPos p_49807_, int p_49808_) { +- if (p_49806_.m_46469_().m_46207_(GameRules.f_46136_)) { ++ if (p_49806_.m_46469_().m_46207_(GameRules.f_46136_) && !p_49806_.restoringBlockSnapshots) { + ExperienceOrb.m_147082_(p_49806_, Vec3.m_82512_(p_49807_), p_49808_); + } + + } + ++ @Deprecated //Forge: Use more sensitive version + public float m_7325_() { + return this.f_60444_; + } +@@ -383,8 +_,10 @@ + + public void m_5548_(BlockGetter p_49821_, Entity p_49822_) { + p_49822_.m_20256_(p_49822_.m_20184_().m_82542_(1.0D, 0.0D, 1.0D)); ++ p_49822_.m_20256_(p_49822_.m_20184_().m_82542_(1.0D, 0.0D, 1.0D)); + } + ++ @Deprecated //Forge: Use more sensitive version + public ItemStack m_7397_(BlockGetter p_49823_, BlockPos p_49824_, BlockState p_49825_) { + return new ItemStack(this); + } +@@ -421,6 +_,7 @@ + public void m_141997_(BlockState p_152450_, Level p_152451_, BlockPos p_152452_, Biome.Precipitation p_152453_) { + } + ++ @Deprecated //Forge: Use more sensitive version + public boolean m_6903_(Explosion p_49826_) { + return true; + } +@@ -456,6 +_,7 @@ + return p_152456_.m_61124_(p_152457_, p_152455_.m_61143_(p_152457_)); + } + ++ @Deprecated //Forge: Use more sensitive version {@link IForgeBlockState#getSoundType(IWorldReader, BlockPos, Entity) } + public SoundType m_49962_(BlockState p_49963_) { + return this.f_60446_; + } +@@ -465,7 +_,7 @@ + this.f_49788_ = Item.m_41439_(this); + } + +- return this.f_49788_; ++ return this.f_49788_.delegate.get(); //Forge: Vanilla caches the items, update with registry replacements. + } + + public boolean m_49967_() { +@@ -473,7 +_,7 @@ + } + + public String toString() { +- return "Block{" + Registry.f_122824_.m_7981_(this) + "}"; ++ return "Block{" + getRegistryName() + "}"; + } + + public void m_5871_(ItemStack p_49816_, @Nullable BlockGetter p_49817_, List p_49818_, TooltipFlag p_49819_) { +@@ -486,6 +_,100 @@ + protected ImmutableMap m_152458_(Function p_152459_) { + return this.f_49792_.m_61056_().stream().collect(ImmutableMap.toImmutableMap(Function.identity(), p_152459_)); + } ++ ++ /* ======================================== FORGE START =====================================*/ ++ protected Random RANDOM = new Random(); ++ private net.minecraftforge.common.ToolType harvestTool; ++ private int harvestLevel; ++ private final net.minecraftforge.common.util.ReverseTagWrapper reverseTags = new net.minecraftforge.common.util.ReverseTagWrapper<>(this, BlockTags::m_13115_); ++ private Object renderProperties; ++ ++ /* ++ DO NOT CALL, IT WILL DISAPPEAR IN THE FUTURE ++ Call RenderProperties.get instead ++ */ ++ public Object getRenderPropertiesInternal() { ++ return renderProperties; ++ } ++ ++ private void initClient() { ++ if (net.minecraftforge.fml.loading.FMLEnvironment.dist == net.minecraftforge.api.distmarker.Dist.CLIENT) { ++ initializeClient(properties -> { ++ if (properties == this) ++ throw new IllegalStateException("Don't extend IBlockRenderProperties in your block, use an anonymous class instead."); ++ this.renderProperties = properties; ++ }); ++ } ++ } ++ ++ public void initializeClient(java.util.function.Consumer consumer) { ++ } ++ ++ @Nullable ++ @Override ++ public net.minecraftforge.common.ToolType getHarvestTool(BlockState state) { ++ return harvestTool; //TODO: RE-Evaluate ++ } ++ ++ @Override ++ public int getHarvestLevel(BlockState state) { ++ return harvestLevel; //TODO: RE-Evaluate ++ } ++ ++ @Override ++ public boolean canSustainPlant(BlockState state, BlockGetter world, BlockPos pos, Direction facing, net.minecraftforge.common.IPlantable plantable) { ++ BlockState plant = plantable.getPlant(world, pos.m_142300_(facing)); ++ net.minecraftforge.common.PlantType type = plantable.getPlantType(world, pos.m_142300_(facing)); ++ ++ if (plant.m_60734_() == Blocks.f_50128_) ++ return state.m_60713_(Blocks.f_50128_) || state.m_60713_(Blocks.f_49992_) || state.m_60713_(Blocks.f_49993_); ++ ++ if (plant.m_60734_() == Blocks.f_50130_ && this == Blocks.f_50130_) ++ return true; ++ ++ if (plantable instanceof BushBlock && ((BushBlock)plantable).m_6266_(state, world, pos)) ++ return true; ++ ++ if (net.minecraftforge.common.PlantType.DESERT.equals(type)) { ++ return this == Blocks.f_49992_ || this == Blocks.f_50352_ || this instanceof GlazedTerracottaBlock; ++ } else if (net.minecraftforge.common.PlantType.NETHER.equals(type)) { ++ return this == Blocks.f_50135_; ++ } else if (net.minecraftforge.common.PlantType.CROP.equals(type)) { ++ return state.m_60713_(Blocks.f_50093_); ++ } else if (net.minecraftforge.common.PlantType.CAVE.equals(type)) { ++ return state.m_60783_(world, pos, Direction.UP); ++ } else if (net.minecraftforge.common.PlantType.PLAINS.equals(type)) { ++ return this == Blocks.f_50440_ || net.minecraftforge.common.Tags.Blocks.DIRT.m_8110_(this) || this == Blocks.f_50093_; ++ } else if (net.minecraftforge.common.PlantType.WATER.equals(type)) { ++ return state.m_60767_() == net.minecraft.world.level.material.Material.f_76305_; //&& state.getValue(BlockLiquidWrapper) ++ } else if (net.minecraftforge.common.PlantType.BEACH.equals(type)) { ++ boolean isBeach = state.m_60713_(Blocks.f_50440_) || net.minecraftforge.common.Tags.Blocks.DIRT.m_8110_(this) || state.m_60713_(Blocks.f_49992_) || state.m_60713_(Blocks.f_49993_); ++ boolean hasWater = false; ++ for (Direction face : Direction.Plane.HORIZONTAL) { ++ BlockState blockState = world.m_8055_(pos.m_142300_(face)); ++ net.minecraft.world.level.material.FluidState fluidState = world.m_6425_(pos.m_142300_(face)); ++ hasWater |= blockState.m_60713_(Blocks.f_50449_); ++ hasWater |= fluidState.m_76153_(net.minecraft.tags.FluidTags.f_13131_); ++ if (hasWater) ++ break; //No point continuing. ++ } ++ return isBeach && hasWater; ++ } ++ return false; ++ } ++ ++ @Override ++ public final java.util.Set getTags() { ++ return reverseTags.getTagNames(); ++ } ++ ++ static { ++ net.minecraftforge.common.ForgeHooks.setBlockToolSetter((block, tool, level) -> { ++ block.harvestTool = tool; ++ block.harvestLevel = level; ++ }); ++ } ++ /* ========================================= FORGE END ======================================*/ + + public static final class BlockStatePairKey { + private final BlockState f_49980_; diff --git a/patches/minecraft/net/minecraft/world/level/block/Blocks.java.patch b/patches/minecraft/net/minecraft/world/level/block/Blocks.java.patch new file mode 100644 index 0000000000..e0f433a30f --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/Blocks.java.patch @@ -0,0 +1,36 @@ +--- a/net/minecraft/world/level/block/Blocks.java ++++ b/net/minecraft/world/level/block/Blocks.java +@@ -35,6 +_,7 @@ + import net.minecraft.world.level.material.Material; + import net.minecraft.world.level.material.MaterialColor; + ++@net.minecraftforge.registries.ObjectHolder("minecraft") + public class Blocks { + public static final Block f_50016_ = m_50795_("air", new AirBlock(BlockBehaviour.Properties.m_60939_(Material.f_76296_).m_60910_().m_60993_().m_60996_())); + public static final Block f_50069_ = m_50795_("stone", new Block(BlockBehaviour.Properties.m_60944_(Material.f_76278_, MaterialColor.f_76409_).m_60999_().m_60913_(1.5F, 6.0F))); +@@ -135,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)); +- public static final Block f_50030_ = m_50795_("powered_rail", new PoweredRailBlock(BlockBehaviour.Properties.m_60939_(Material.f_76310_).m_60910_().m_60978_(0.7F).m_60918_(SoundType.f_56743_))); ++ public static final Block f_50030_ = m_50795_("powered_rail", new PoweredRailBlock(BlockBehaviour.Properties.m_60939_(Material.f_76310_).m_60910_().m_60978_(0.7F).m_60918_(SoundType.f_56743_), true)); + public static final Block f_50031_ = m_50795_("detector_rail", new DetectorRailBlock(BlockBehaviour.Properties.m_60939_(Material.f_76310_).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_60939_(Material.f_76311_).m_60910_().m_60999_().m_60978_(4.0F))); +@@ -1107,16 +_,5 @@ + + public static void m_50758_() { + Block.f_49791_.forEach(BlockBehaviour.BlockStateBase::m_60611_); +- } +- +- static { +- for(Block block : Registry.f_122824_) { +- for(BlockState blockstate : block.m_49965_().m_61056_()) { +- Block.f_49791_.m_122667_(blockstate); +- } +- +- block.m_60589_(); +- } +- + } + } diff --git a/patches/minecraft/net/minecraft/world/level/block/BushBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/BushBlock.java.patch new file mode 100644 index 0000000000..4d53af1547 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/BushBlock.java.patch @@ -0,0 +1,33 @@ +--- a/net/minecraft/world/level/block/BushBlock.java ++++ b/net/minecraft/world/level/block/BushBlock.java +@@ -10,7 +_,7 @@ + import net.minecraft.world.level.block.state.BlockState; + import net.minecraft.world.level.pathfinder.PathComputationType; + +-public class BushBlock extends Block { ++public class BushBlock extends Block implements net.minecraftforge.common.IPlantable { + public BushBlock(BlockBehaviour.Properties p_51021_) { + super(p_51021_); + } +@@ -25,6 +_,8 @@ + + public boolean m_7898_(BlockState p_51028_, LevelReader p_51029_, BlockPos p_51030_) { + BlockPos blockpos = p_51030_.m_7495_(); ++ if (p_51028_.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. ++ return p_51029_.m_8055_(blockpos).canSustainPlant(p_51029_, blockpos, Direction.UP, this); + return this.m_6266_(p_51029_.m_8055_(blockpos), p_51029_, blockpos); + } + +@@ -34,5 +_,12 @@ + + public boolean m_7357_(BlockState p_51023_, BlockGetter p_51024_, BlockPos p_51025_, PathComputationType p_51026_) { + return p_51026_ == PathComputationType.AIR && !this.f_60443_ ? true : super.m_7357_(p_51023_, p_51024_, p_51025_, p_51026_); ++ } ++ ++ @Override ++ public BlockState getPlant(BlockGetter world, BlockPos pos) { ++ BlockState state = world.m_8055_(pos); ++ if (state.m_60734_() != this) return m_49966_(); ++ return state; + } + } diff --git a/patches/minecraft/net/minecraft/world/level/block/CactusBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/CactusBlock.java.patch new file mode 100644 index 0000000000..36afaeb4c6 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/CactusBlock.java.patch @@ -0,0 +1,62 @@ +--- a/net/minecraft/world/level/block/CactusBlock.java ++++ b/net/minecraft/world/level/block/CactusBlock.java +@@ -21,7 +_,7 @@ + import net.minecraft.world.phys.shapes.CollisionContext; + import net.minecraft.world.phys.shapes.VoxelShape; + +-public class CactusBlock extends Block { ++public class CactusBlock extends Block implements net.minecraftforge.common.IPlantable { + public static final IntegerProperty f_51131_ = BlockStateProperties.f_61410_; + public static final int f_152740_ = 15; + protected static final int f_152741_ = 1; +@@ -34,6 +_,7 @@ + } + + public void m_7458_(BlockState p_51138_, ServerLevel p_51139_, BlockPos p_51140_, Random p_51141_) { ++ if (!p_51139_.isAreaLoaded(p_51140_, 1)) return; // Forge: prevent growing cactus from loading unloaded chunks with block update + if (!p_51138_.m_60710_(p_51139_, p_51140_)) { + p_51139_.m_46961_(p_51140_, true); + } +@@ -49,6 +_,7 @@ + + if (i < 3) { + int j = p_51166_.m_61143_(f_51131_); ++ if(net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_51167_, blockpos, p_51166_, true)) { + if (j == 15) { + p_51167_.m_46597_(blockpos, this.m_49966_()); + BlockState blockstate = p_51166_.m_61124_(f_51131_, Integer.valueOf(0)); +@@ -57,7 +_,8 @@ + } else { + p_51167_.m_7731_(p_51168_, p_51166_.m_61124_(f_51131_, Integer.valueOf(j + 1)), 4); + } +- ++ net.minecraftforge.common.ForgeHooks.onCropsGrowPost(p_51167_, p_51168_, p_51166_); ++ } + } + } + } +@@ -88,7 +_,7 @@ + } + + BlockState blockstate1 = p_51154_.m_8055_(p_51155_.m_7495_()); +- return (blockstate1.m_60713_(Blocks.f_50128_) || blockstate1.m_60713_(Blocks.f_49992_) || blockstate1.m_60713_(Blocks.f_49993_)) && !p_51154_.m_8055_(p_51155_.m_7494_()).m_60767_().m_76332_(); ++ return blockstate1.canSustainPlant(p_51154_, p_51155_, Direction.UP, this) && !p_51154_.m_8055_(p_51155_.m_7494_()).m_60767_().m_76332_(); + } + + public void m_7892_(BlockState p_51148_, Level p_51149_, BlockPos p_51150_, Entity p_51151_) { +@@ -101,5 +_,15 @@ + + public boolean m_7357_(BlockState p_51143_, BlockGetter p_51144_, BlockPos p_51145_, PathComputationType p_51146_) { + return false; ++ } ++ ++ @Override ++ public net.minecraftforge.common.PlantType getPlantType(BlockGetter world, BlockPos pos) { ++ return net.minecraftforge.common.PlantType.DESERT; ++ } ++ ++ @Override ++ public BlockState getPlant(BlockGetter world, BlockPos pos) { ++ return m_49966_(); + } + } diff --git a/patches/minecraft/net/minecraft/world/level/block/CampfireBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/CampfireBlock.java.patch new file mode 100644 index 0000000000..fb8bb71ce1 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/CampfireBlock.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/block/CampfireBlock.java ++++ b/net/minecraft/world/level/block/CampfireBlock.java +@@ -205,7 +_,7 @@ + return true; + } + +- boolean flag = Shapes.m_83157_(f_51231_, blockstate.m_60742_(p_51249_, p_51250_, CollisionContext.m_82749_()), BooleanOp.f_82689_); ++ boolean flag = Shapes.m_83157_(f_51231_, blockstate.m_60742_(p_51249_, blockpos, CollisionContext.m_82749_()), BooleanOp.f_82689_);//Forge fix: MC-201374 + if (flag) { + BlockState blockstate1 = p_51249_.m_8055_(blockpos.m_7495_()); + return m_51319_(blockstate1); diff --git a/patches/minecraft/net/minecraft/world/level/block/ChestBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/ChestBlock.java.patch new file mode 100644 index 0000000000..38ebf5097a --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/ChestBlock.java.patch @@ -0,0 +1,12 @@ +--- a/net/minecraft/world/level/block/ChestBlock.java ++++ b/net/minecraft/world/level/block/ChestBlock.java +@@ -336,7 +_,8 @@ + } + + public BlockState m_6943_(BlockState p_51549_, Mirror p_51550_) { +- return p_51549_.m_60717_(p_51550_.m_54846_(p_51549_.m_61143_(f_51478_))); ++ BlockState rotated = p_51549_.m_60717_(p_51550_.m_54846_(p_51549_.m_61143_(f_51478_))); ++ return p_51550_ == Mirror.NONE ? rotated : rotated.m_61124_(f_51479_, rotated.m_61143_(f_51479_).m_61486_()); // Forge: Fixed MC-134110 Structure mirroring breaking apart double chests + } + + protected void m_7926_(StateDefinition.Builder p_51562_) { diff --git a/patches/minecraft/net/minecraft/world/level/block/ChorusFlowerBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/ChorusFlowerBlock.java.patch new file mode 100644 index 0000000000..0c08bd2123 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/ChorusFlowerBlock.java.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/world/level/block/ChorusFlowerBlock.java ++++ b/net/minecraft/world/level/block/ChorusFlowerBlock.java +@@ -43,7 +_,7 @@ + BlockPos blockpos = p_51704_.m_7494_(); + if (p_51703_.m_46859_(blockpos) && blockpos.m_123342_() < p_51703_.m_151558_()) { + int i = p_51702_.m_61143_(f_51647_); +- if (i < 5) { ++ if (i < 5 && net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_51703_, blockpos, p_51702_, true)) { + boolean flag = false; + boolean flag1 = false; + BlockState blockstate = p_51703_.m_8055_(p_51704_.m_7495_()); +@@ -99,7 +_,7 @@ + } else { + this.m_51658_(p_51703_, p_51704_); + } +- ++ net.minecraftforge.common.ForgeHooks.onCropsGrowPost(p_51703_, p_51704_, p_51702_); + } + } + } diff --git a/patches/minecraft/net/minecraft/world/level/block/CocoaBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/CocoaBlock.java.patch new file mode 100644 index 0000000000..bdaadc5b6c --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/CocoaBlock.java.patch @@ -0,0 +1,16 @@ +--- a/net/minecraft/world/level/block/CocoaBlock.java ++++ b/net/minecraft/world/level/block/CocoaBlock.java +@@ -47,10 +_,11 @@ + } + + public void m_7455_(BlockState p_51782_, ServerLevel p_51783_, BlockPos p_51784_, Random p_51785_) { +- if (p_51783_.f_46441_.nextInt(5) == 0) { ++ if (true) { + int i = p_51782_.m_61143_(f_51736_); +- if (i < 2) { ++ if (i < 2 && net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_51783_, p_51784_, p_51782_, p_51783_.f_46441_.nextInt(5) == 0)) { + p_51783_.m_7731_(p_51784_, p_51782_.m_61124_(f_51736_, Integer.valueOf(i + 1)), 2); ++ net.minecraftforge.common.ForgeHooks.onCropsGrowPost(p_51783_, p_51784_, p_51782_); + } + } + diff --git a/patches/minecraft/net/minecraft/world/level/block/ComparatorBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/ComparatorBlock.java.patch new file mode 100644 index 0000000000..1a20e43ad1 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/ComparatorBlock.java.patch @@ -0,0 +1,19 @@ +--- a/net/minecraft/world/level/block/ComparatorBlock.java ++++ b/net/minecraft/world/level/block/ComparatorBlock.java +@@ -166,4 +_,16 @@ + protected void m_7926_(StateDefinition.Builder p_51887_) { + p_51887_.m_61104_(f_54117_, f_51854_, f_52496_); + } ++ ++ @Override ++ public boolean getWeakChanges(BlockState state, net.minecraft.world.level.LevelReader world, BlockPos pos) { ++ return state.m_60713_(Blocks.f_50328_); ++ } ++ ++ @Override ++ public void onNeighborChange(BlockState state, net.minecraft.world.level.LevelReader world, BlockPos pos, BlockPos neighbor) { ++ if (pos.m_123342_() == neighbor.m_123342_() && world instanceof Level && !((Level)world).m_5776_()) { ++ state.m_60690_((Level)world, pos, world.m_8055_(neighbor).m_60734_(), neighbor, false); ++ } ++ } + } diff --git a/patches/minecraft/net/minecraft/world/level/block/CropBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/CropBlock.java.patch new file mode 100644 index 0000000000..22140841d0 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/CropBlock.java.patch @@ -0,0 +1,39 @@ +--- a/net/minecraft/world/level/block/CropBlock.java ++++ b/net/minecraft/world/level/block/CropBlock.java +@@ -64,12 +_,14 @@ + } + + public void m_7455_(BlockState p_52292_, ServerLevel p_52293_, BlockPos p_52294_, Random p_52295_) { ++ if (!p_52293_.isAreaLoaded(p_52294_, 1)) return; // Forge: prevent loading unloaded chunks when checking neighbor's light + if (p_52293_.m_45524_(p_52294_, 0) >= 9) { + int i = this.m_52305_(p_52292_); + if (i < this.m_7419_()) { + float f = m_52272_(this, p_52293_, p_52294_); +- if (p_52295_.nextInt((int)(25.0F / f) + 1) == 0) { ++ if (net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_52293_, p_52294_, p_52292_, p_52295_.nextInt((int)(25.0F / f) + 1) == 0)) { + p_52293_.m_7731_(p_52294_, this.m_52289_(i + 1), 2); ++ net.minecraftforge.common.ForgeHooks.onCropsGrowPost(p_52293_, p_52294_, p_52292_); + } + } + } +@@ -98,9 +_,9 @@ + for(int j = -1; j <= 1; ++j) { + float f1 = 0.0F; + BlockState blockstate = p_52274_.m_8055_(blockpos.m_142082_(i, 0, j)); +- if (blockstate.m_60713_(Blocks.f_50093_)) { ++ if (blockstate.canSustainPlant(p_52274_, blockpos.m_142082_(i, 0, j), net.minecraft.core.Direction.UP, (net.minecraftforge.common.IPlantable) p_52273_)) { + f1 = 1.0F; +- if (blockstate.m_61143_(FarmBlock.f_53243_) > 0) { ++ if (blockstate.isFertile(p_52274_, p_52275_.m_142082_(i, 0, j))) { + f1 = 3.0F; + } + } +@@ -136,7 +_,7 @@ + } + + public void m_7892_(BlockState p_52277_, Level p_52278_, BlockPos p_52279_, Entity p_52280_) { +- if (p_52280_ instanceof Ravager && p_52278_.m_46469_().m_46207_(GameRules.f_46132_)) { ++ if (p_52280_ instanceof Ravager && net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(p_52278_, p_52280_)) { + p_52278_.m_46953_(p_52279_, true, p_52280_); + } + diff --git a/patches/minecraft/net/minecraft/world/level/block/DeadBushBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/DeadBushBlock.java.patch new file mode 100644 index 0000000000..30d0c903d3 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/DeadBushBlock.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/block/DeadBushBlock.java ++++ b/net/minecraft/world/level/block/DeadBushBlock.java +@@ -8,7 +_,7 @@ + import net.minecraft.world.phys.shapes.CollisionContext; + import net.minecraft.world.phys.shapes.VoxelShape; + +-public class DeadBushBlock extends BushBlock { ++public class DeadBushBlock extends BushBlock implements net.minecraftforge.common.IForgeShearable { + protected static final float f_153120_ = 6.0F; + protected static final VoxelShape f_52414_ = Block.m_49796_(2.0D, 0.0D, 2.0D, 14.0D, 13.0D, 14.0D); + diff --git a/patches/minecraft/net/minecraft/world/level/block/DetectorRailBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/DetectorRailBlock.java.patch new file mode 100644 index 0000000000..9bfad8ab0d --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/DetectorRailBlock.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/block/DetectorRailBlock.java ++++ b/net/minecraft/world/level/block/DetectorRailBlock.java +@@ -136,6 +_,8 @@ + } + + List list1 = this.m_52436_(p_52455_, p_52456_, AbstractMinecart.class, EntitySelector.f_20405_); ++ List carts = this.m_52436_(p_52455_, p_52456_, AbstractMinecart.class, null); ++ if (!carts.isEmpty() && carts.get(0).getComparatorLevel() > -1) return carts.get(0).getComparatorLevel(); + if (!list1.isEmpty()) { + return AbstractContainerMenu.m_38938_((Container)list1.get(0)); + } diff --git a/patches/minecraft/net/minecraft/world/level/block/DiodeBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/DiodeBlock.java.patch new file mode 100644 index 0000000000..8ef0463c2c --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/DiodeBlock.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/block/DiodeBlock.java ++++ b/net/minecraft/world/level/block/DiodeBlock.java +@@ -165,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_142300_(direction.m_122424_()); ++ if (net.minecraftforge.event.ForgeEventFactory.onNeighborNotify(p_52581_, p_52582_, p_52581_.m_8055_(p_52582_), java.util.EnumSet.of(direction.m_122424_()), false).isCanceled()) ++ return; + p_52581_.m_46586_(blockpos, this, p_52582_); + p_52581_.m_46590_(blockpos, this, direction); + } diff --git a/patches/minecraft/net/minecraft/world/level/block/DoublePlantBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/DoublePlantBlock.java.patch new file mode 100644 index 0000000000..a56887ac4a --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/DoublePlantBlock.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/world/level/block/DoublePlantBlock.java ++++ b/net/minecraft/world/level/block/DoublePlantBlock.java +@@ -53,6 +_,7 @@ + return super.m_7898_(p_52887_, p_52888_, p_52889_); + } else { + BlockState blockstate = p_52888_.m_8055_(p_52889_.m_7495_()); ++ if (p_52887_.m_60734_() != this) return super.m_7898_(p_52887_, p_52888_, p_52889_); //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. + return blockstate.m_60713_(this) && blockstate.m_61143_(f_52858_) == DoubleBlockHalf.LOWER; + } + } diff --git a/patches/minecraft/net/minecraft/world/level/block/DropperBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/DropperBlock.java.patch new file mode 100644 index 0000000000..a8ccd5e28e --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/DropperBlock.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/block/DropperBlock.java ++++ b/net/minecraft/world/level/block/DropperBlock.java +@@ -38,7 +_,7 @@ + p_52944_.m_46796_(1001, p_52945_, 0); + } else { + ItemStack itemstack = dispenserblockentity.m_8020_(i); +- if (!itemstack.m_41619_()) { ++ if (!itemstack.m_41619_() && net.minecraftforge.items.VanillaInventoryCodeHooks.dropperInsertHook(p_52944_, p_52945_, dispenserblockentity, i, itemstack)) { + Direction direction = p_52944_.m_8055_(p_52945_).m_61143_(f_52659_); + Container container = HopperBlockEntity.m_59390_(p_52944_, p_52945_.m_142300_(direction)); + ItemStack itemstack1; diff --git a/patches/minecraft/net/minecraft/world/level/block/EnchantmentTableBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/EnchantmentTableBlock.java.patch new file mode 100644 index 0000000000..daa464dd1e --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/EnchantmentTableBlock.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/block/EnchantmentTableBlock.java ++++ b/net/minecraft/world/level/block/EnchantmentTableBlock.java +@@ -55,7 +_,7 @@ + if (p_52984_.nextInt(16) == 0) { + for(int k = 0; k <= 1; ++k) { + BlockPos blockpos = p_52983_.m_142082_(i, k, j); +- if (p_52982_.m_8055_(blockpos).m_60713_(Blocks.f_50078_)) { ++ if (p_52982_.m_8055_(blockpos).getEnchantPowerBonus(p_52982_, blockpos) > 0) { + if (!p_52982_.m_46859_(p_52983_.m_142082_(i / 2, 0, j / 2))) { + break; + } diff --git a/patches/minecraft/net/minecraft/world/level/block/FallingBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/FallingBlock.java.patch new file mode 100644 index 0000000000..e41a311332 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/FallingBlock.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/block/FallingBlock.java ++++ b/net/minecraft/world/level/block/FallingBlock.java +@@ -30,7 +_,7 @@ + } + + public void m_7458_(BlockState p_53216_, ServerLevel p_53217_, BlockPos p_53218_, Random p_53219_) { +- if (m_53241_(p_53217_.m_8055_(p_53218_.m_7495_())) && p_53218_.m_123342_() >= p_53217_.m_141937_()) { ++ if (m_53241_(p_53217_.m_8055_(p_53218_.m_7495_())) && p_53218_.m_123342_() >= 0) { + FallingBlockEntity fallingblockentity = new FallingBlockEntity(p_53217_, (double)p_53218_.m_123341_() + 0.5D, (double)p_53218_.m_123342_(), (double)p_53218_.m_123343_() + 0.5D, p_53217_.m_8055_(p_53218_)); + this.m_6788_(fallingblockentity); + p_53217_.m_7967_(fallingblockentity); diff --git a/patches/minecraft/net/minecraft/world/level/block/FarmBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/FarmBlock.java.patch new file mode 100644 index 0000000000..97ed40c916 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/FarmBlock.java.patch @@ -0,0 +1,32 @@ +--- a/net/minecraft/world/level/block/FarmBlock.java ++++ b/net/minecraft/world/level/block/FarmBlock.java +@@ -81,7 +_,7 @@ + } + + public void m_142072_(Level p_153227_, BlockState p_153228_, BlockPos p_153229_, Entity p_153230_, float p_153231_) { +- if (!p_153227_.f_46443_ && p_153227_.f_46441_.nextFloat() < p_153231_ - 0.5F && p_153230_ instanceof LivingEntity && (p_153230_ instanceof Player || p_153227_.m_46469_().m_46207_(GameRules.f_46132_)) && p_153230_.m_20205_() * p_153230_.m_20205_() * p_153230_.m_20206_() > 0.512F) { ++ if (!p_153227_.f_46443_ && net.minecraftforge.common.ForgeHooks.onFarmlandTrample(p_153227_, p_153229_, Blocks.f_50493_.m_49966_(), p_153231_, p_153230_)) { // Forge: Move logic to Entity#canTrample + m_53296_(p_153228_, p_153227_, p_153229_); + } + +@@ -93,8 +_,9 @@ + } + + private static boolean m_53250_(BlockGetter p_53251_, BlockPos p_53252_) { +- Block block = p_53251_.m_8055_(p_53252_.m_7494_()).m_60734_(); +- return block instanceof CropBlock || block instanceof StemBlock || block instanceof AttachedStemBlock; ++ BlockState plant = p_53251_.m_8055_(p_53252_.m_7494_()); ++ BlockState state = p_53251_.m_8055_(p_53252_); ++ return plant.m_60734_() instanceof net.minecraftforge.common.IPlantable && state.canSustainPlant(p_53251_, p_53252_, Direction.UP, (net.minecraftforge.common.IPlantable)plant.m_60734_()); + } + + private static boolean m_53258_(LevelReader p_53259_, BlockPos p_53260_) { +@@ -104,7 +_,7 @@ + } + } + +- return false; ++ return net.minecraftforge.common.FarmlandWaterManager.hasBlockWaterTicket(p_53259_, p_53260_); + } + + protected void m_7926_(StateDefinition.Builder p_53283_) { diff --git a/patches/minecraft/net/minecraft/world/level/block/FireBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/FireBlock.java.patch new file mode 100644 index 0000000000..9e088138f6 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/FireBlock.java.patch @@ -0,0 +1,136 @@ +--- a/net/minecraft/world/level/block/FireBlock.java ++++ b/net/minecraft/world/level/block/FireBlock.java +@@ -103,13 +_,13 @@ + protected BlockState m_53470_(BlockGetter p_53471_, BlockPos p_53472_) { + BlockPos blockpos = p_53472_.m_7495_(); + BlockState blockstate = p_53471_.m_8055_(blockpos); +- if (!this.m_7599_(blockstate) && !blockstate.m_60783_(p_53471_, blockpos, Direction.UP)) { ++ if (!this.canCatchFire(p_53471_, p_53472_, Direction.UP) && !blockstate.m_60783_(p_53471_, blockpos, Direction.UP)) { + BlockState blockstate1 = this.m_49966_(); + + for(Direction direction : Direction.values()) { + BooleanProperty booleanproperty = f_53414_.get(direction); + if (booleanproperty != null) { +- blockstate1 = blockstate1.m_61124_(booleanproperty, Boolean.valueOf(this.m_7599_(p_53471_.m_8055_(p_53472_.m_142300_(direction))))); ++ blockstate1 = blockstate1.m_61124_(booleanproperty, Boolean.valueOf(this.canCatchFire(p_53471_, p_53472_.m_142300_(direction), direction.m_122424_()))); + } + } + +@@ -132,7 +_,7 @@ + } + + BlockState blockstate = p_53450_.m_8055_(p_53451_.m_7495_()); +- boolean flag = blockstate.m_60620_(p_53450_.m_6042_().m_63968_()); ++ boolean flag = blockstate.isFireSource(p_53450_, p_53451_, Direction.UP); + int i = p_53449_.m_61143_(f_53408_); + if (!flag && p_53450_.m_46471_() && this.m_53428_(p_53450_, p_53451_) && p_53452_.nextFloat() < 0.2F + (float)i * 0.03F) { + p_53450_.m_7471_(p_53451_, false); +@@ -153,7 +_,7 @@ + return; + } + +- if (i == 15 && p_53452_.nextInt(4) == 0 && !this.m_7599_(p_53450_.m_8055_(p_53451_.m_7495_()))) { ++ if (i == 15 && p_53452_.nextInt(4) == 0 && !this.canCatchFire(p_53450_, p_53451_.m_7495_(), Direction.UP)) { + p_53450_.m_7471_(p_53451_, false); + return; + } +@@ -161,12 +_,12 @@ + + boolean flag1 = p_53450_.m_46761_(p_53451_); + int k = flag1 ? -50 : 0; +- this.m_53431_(p_53450_, p_53451_.m_142126_(), 300 + k, p_53452_, i); +- this.m_53431_(p_53450_, p_53451_.m_142125_(), 300 + k, p_53452_, i); +- this.m_53431_(p_53450_, p_53451_.m_7495_(), 250 + k, p_53452_, i); +- this.m_53431_(p_53450_, p_53451_.m_7494_(), 250 + k, p_53452_, i); +- this.m_53431_(p_53450_, p_53451_.m_142127_(), 300 + k, p_53452_, i); +- this.m_53431_(p_53450_, p_53451_.m_142128_(), 300 + k, p_53452_, i); ++ this.tryCatchFire(p_53450_, p_53451_.m_142126_(), 300 + k, p_53452_, i, Direction.WEST); ++ this.tryCatchFire(p_53450_, p_53451_.m_142125_(), 300 + k, p_53452_, i, Direction.EAST); ++ this.tryCatchFire(p_53450_, p_53451_.m_7495_(), 250 + k, p_53452_, i, Direction.UP); ++ this.tryCatchFire(p_53450_, p_53451_.m_7494_(), 250 + k, p_53452_, i, Direction.DOWN); ++ this.tryCatchFire(p_53450_, p_53451_.m_142127_(), 300 + k, p_53452_, i, Direction.SOUTH); ++ this.tryCatchFire(p_53450_, p_53451_.m_142128_(), 300 + k, p_53452_, i, Direction.NORTH); + BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); + + for(int l = -1; l <= 1; ++l) { +@@ -204,16 +_,18 @@ + return p_53429_.m_46758_(p_53430_) || p_53429_.m_46758_(p_53430_.m_142125_()) || p_53429_.m_46758_(p_53430_.m_142126_()) || p_53429_.m_46758_(p_53430_.m_142127_()) || p_53429_.m_46758_(p_53430_.m_142128_()); + } + ++ @Deprecated //Forge: Use IForgeBlockState.getFlammability, Public for default implementation only. + public int m_53492_(BlockState p_53493_) { + return p_53493_.m_61138_(BlockStateProperties.f_61362_) && p_53493_.m_61143_(BlockStateProperties.f_61362_) ? 0 : this.f_53422_.getInt(p_53493_.m_60734_()); + } + ++ @Deprecated //Forge: Use IForgeBlockState.getFireSpreadSpeed + public int m_53494_(BlockState p_53495_) { + return p_53495_.m_61138_(BlockStateProperties.f_61362_) && p_53495_.m_61143_(BlockStateProperties.f_61362_) ? 0 : this.f_53421_.getInt(p_53495_.m_60734_()); + } + +- private void m_53431_(Level p_53432_, BlockPos p_53433_, int p_53434_, Random p_53435_, int p_53436_) { +- int i = this.m_53492_(p_53432_.m_8055_(p_53433_)); ++ private void tryCatchFire(Level p_53432_, BlockPos p_53433_, int p_53434_, Random p_53435_, int p_53436_, Direction face) { ++ int i = p_53432_.m_8055_(p_53433_).getFlammability(p_53432_, p_53433_, face); + if (p_53435_.nextInt(p_53434_) < i) { + BlockState blockstate = p_53432_.m_8055_(p_53433_); + if (p_53435_.nextInt(p_53436_ + 10) < 5 && !p_53432_.m_46758_(p_53433_)) { +@@ -223,11 +_,7 @@ + p_53432_.m_7471_(p_53433_, false); + } + +- Block block = blockstate.m_60734_(); +- if (block instanceof TntBlock) { +- TntBlock tntblock = (TntBlock)block; +- TntBlock.m_57433_(p_53432_, p_53433_); +- } ++ blockstate.catchFire(p_53432_, p_53433_, face, null); + } + + } +@@ -239,7 +_,7 @@ + + private boolean m_53485_(BlockGetter p_53486_, BlockPos p_53487_) { + for(Direction direction : Direction.values()) { +- if (this.m_7599_(p_53486_.m_8055_(p_53487_.m_142300_(direction)))) { ++ if (this.canCatchFire(p_53486_, p_53487_.m_142300_(direction), direction.m_122424_())) { + return true; + } + } +@@ -255,13 +_,14 @@ + + for(Direction direction : Direction.values()) { + BlockState blockstate = p_53442_.m_8055_(p_53443_.m_142300_(direction)); +- i = Math.max(this.m_53494_(blockstate), i); ++ i = Math.max(blockstate.getFireSpreadSpeed(p_53442_, p_53443_.m_142300_(direction), direction.m_122424_()), i); + } + + return i; + } + } + ++ @Deprecated //Forge: Use canCatchFire with more context + protected boolean m_7599_(BlockState p_53489_) { + return this.m_53494_(p_53489_) > 0; + } +@@ -280,8 +_,21 @@ + } + + private void m_53444_(Block p_53445_, int p_53446_, int p_53447_) { ++ if (p_53445_ == Blocks.f_50016_) throw new IllegalArgumentException("Tried to set air on fire... This is bad."); + this.f_53421_.put(p_53445_, p_53446_); + this.f_53422_.put(p_53445_, p_53447_); ++ } ++ ++ /** ++ * Side sensitive version that calls the block function. ++ * ++ * @param world The current world ++ * @param pos Block position ++ * @param face The side the fire is coming from ++ * @return True if the face can catch fire. ++ */ ++ public boolean canCatchFire(BlockGetter world, BlockPos pos, Direction face) { ++ return world.m_8055_(pos).isFlammable(world, pos, face); + } + + public static void m_53484_() { diff --git a/patches/minecraft/net/minecraft/world/level/block/FlowerPotBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/FlowerPotBlock.java.patch new file mode 100644 index 0000000000..4017fe7a53 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/FlowerPotBlock.java.patch @@ -0,0 +1,86 @@ +--- a/net/minecraft/world/level/block/FlowerPotBlock.java ++++ b/net/minecraft/world/level/block/FlowerPotBlock.java +@@ -28,10 +_,33 @@ + protected static final VoxelShape f_53523_ = Block.m_49796_(5.0D, 0.0D, 5.0D, 11.0D, 6.0D, 11.0D); + private final Block f_53525_; + ++ @Deprecated // Mods should use the constructor below + public FlowerPotBlock(Block p_53528_, BlockBehaviour.Properties p_53529_) { +- super(p_53529_); +- this.f_53525_ = p_53528_; +- f_53524_.put(p_53528_, this); ++ this(Blocks.f_50276_ == null ? null : () -> (FlowerPotBlock) Blocks.f_50276_.delegate.get(), () -> p_53528_.delegate.get(), p_53529_); ++ if (Blocks.f_50276_ != null) { ++ ((FlowerPotBlock)Blocks.f_50276_).addPlant(p_53528_.getRegistryName(), () -> this); ++ } ++ } ++ ++ /** ++ * For mod use, eliminates the need to extend this class, and prevents modded ++ * flower pots from altering vanilla behavior. ++ * ++ * @param emptyPot The empty pot for this pot, or null for self. ++ * @param block The flower block. ++ * @param properties ++ */ ++ public FlowerPotBlock(@javax.annotation.Nullable java.util.function.Supplier emptyPot, java.util.function.Supplier p_53528_, BlockBehaviour.Properties properties) { ++ super(properties); ++ this.f_53525_ = null; // Unused, redirected by coremod ++ this.flowerDelegate = p_53528_; ++ if (emptyPot == null) { ++ this.fullPots = Maps.newHashMap(); ++ this.emptyPot = null; ++ } else { ++ this.fullPots = java.util.Collections.emptyMap(); ++ this.emptyPot = emptyPot; ++ } + } + + public VoxelShape m_5940_(BlockState p_53556_, BlockGetter p_53557_, BlockPos p_53558_, CollisionContext p_53559_) { +@@ -45,7 +_,7 @@ + public InteractionResult m_6227_(BlockState p_53540_, Level p_53541_, BlockPos p_53542_, Player p_53543_, InteractionHand p_53544_, BlockHitResult p_53545_) { + ItemStack itemstack = p_53543_.m_21120_(p_53544_); + Item item = itemstack.m_41720_(); +- BlockState blockstate = (item instanceof BlockItem ? f_53524_.getOrDefault(((BlockItem)item).m_40614_(), Blocks.f_50016_) : Blocks.f_50016_).m_49966_(); ++ BlockState blockstate = (item instanceof BlockItem ? getEmptyPot().fullPots.getOrDefault(((BlockItem)item).m_40614_().getRegistryName(), Blocks.f_50016_.delegate).get() : Blocks.f_50016_).m_49966_(); + boolean flag = blockstate.m_60713_(Blocks.f_50016_); + boolean flag1 = this.m_153267_(); + if (flag != flag1) { +@@ -63,7 +_,7 @@ + p_53543_.m_36176_(itemstack1, false); + } + +- p_53541_.m_7731_(p_53542_, Blocks.f_50276_.m_49966_(), 3); ++ p_53541_.m_7731_(p_53542_, getEmptyPot().m_49966_(), 3); + } + + p_53541_.m_142346_(p_53543_, GameEvent.f_157792_, p_53542_); +@@ -86,10 +_,27 @@ + } + + public Block m_53560_() { +- return this.f_53525_; ++ return flowerDelegate.get(); + } + + public boolean m_7357_(BlockState p_53535_, BlockGetter p_53536_, BlockPos p_53537_, PathComputationType p_53538_) { + return false; + } ++ ++ //Forge Start ++ private final Map> fullPots; ++ private final java.util.function.Supplier emptyPot; ++ private final java.util.function.Supplier flowerDelegate; ++ ++ public FlowerPotBlock getEmptyPot() { ++ return emptyPot == null ? this : emptyPot.get(); ++ } ++ ++ public void addPlant(net.minecraft.resources.ResourceLocation flower, java.util.function.Supplier fullPot) { ++ if (getEmptyPot() != this) { ++ throw new IllegalArgumentException("Cannot add plant to non-empty pot: " + this); ++ } ++ fullPots.put(flower, fullPot); ++ } ++ //Forge End + } diff --git a/patches/minecraft/net/minecraft/world/level/block/GrowingPlantHeadBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/GrowingPlantHeadBlock.java.patch new file mode 100644 index 0000000000..44ee0721d9 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/GrowingPlantHeadBlock.java.patch @@ -0,0 +1,15 @@ +--- a/net/minecraft/world/level/block/GrowingPlantHeadBlock.java ++++ b/net/minecraft/world/level/block/GrowingPlantHeadBlock.java +@@ -35,10 +_,11 @@ + } + + public void m_7455_(BlockState p_53963_, ServerLevel p_53964_, BlockPos p_53965_, Random p_53966_) { +- if (p_53963_.m_61143_(f_53924_) < 25 && p_53966_.nextDouble() < this.f_53925_) { ++ if (p_53963_.m_61143_(f_53924_) < 25 && net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_53964_, p_53965_.m_142300_(this.f_53859_), p_53964_.m_8055_(p_53965_.m_142300_(this.f_53859_)),p_53966_.nextDouble() < this.f_53925_)) { + BlockPos blockpos = p_53965_.m_142300_(this.f_53859_); + if (this.m_5971_(p_53964_.m_8055_(blockpos))) { + p_53964_.m_46597_(blockpos, this.m_142452_(p_53963_, p_53964_.f_46441_)); ++ net.minecraftforge.common.ForgeHooks.onCropsGrowPost(p_53964_, blockpos, p_53964_.m_8055_(blockpos)); + } + } + diff --git a/patches/minecraft/net/minecraft/world/level/block/LeavesBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/LeavesBlock.java.patch new file mode 100644 index 0000000000..ffa8c15472 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/LeavesBlock.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/block/LeavesBlock.java ++++ b/net/minecraft/world/level/block/LeavesBlock.java +@@ -19,7 +_,7 @@ + import net.minecraft.world.phys.shapes.Shapes; + import net.minecraft.world.phys.shapes.VoxelShape; + +-public class LeavesBlock extends Block { ++public class LeavesBlock extends Block implements net.minecraftforge.common.IForgeShearable { + public static final int f_153563_ = 7; + public static final IntegerProperty f_54418_ = BlockStateProperties.f_61414_; + public static final BooleanProperty f_54419_ = BlockStateProperties.f_61447_; diff --git a/patches/minecraft/net/minecraft/world/level/block/LiquidBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/LiquidBlock.java.patch new file mode 100644 index 0000000000..5fb44b5461 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/LiquidBlock.java.patch @@ -0,0 +1,80 @@ +--- a/net/minecraft/world/level/block/LiquidBlock.java ++++ b/net/minecraft/world/level/block/LiquidBlock.java +@@ -35,6 +_,7 @@ + public static final VoxelShape f_54690_ = Block.m_49796_(0.0D, 0.0D, 0.0D, 16.0D, 8.0D, 16.0D); + public static final ImmutableList f_181233_ = ImmutableList.of(Direction.DOWN, Direction.SOUTH, Direction.NORTH, Direction.EAST, Direction.WEST); + ++ @Deprecated // Forge: Use the constructor that takes a supplier + public LiquidBlock(FlowingFluid p_54694_, BlockBehaviour.Properties p_54695_) { + super(p_54695_); + this.f_54689_ = p_54694_; +@@ -47,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))); ++ fluidStateCacheInitialized = true; ++ supplier = p_54694_.delegate; ++ } ++ ++ /** ++ * @param supplier A fluid supplier such as {@link net.minecraftforge.fmllegacy.RegistryObject} ++ */ ++ public LiquidBlock(java.util.function.Supplier p_54694_, BlockBehaviour.Properties p_54695_) { ++ super(p_54695_); ++ this.f_54689_ = null; ++ this.f_54691_ = Lists.newArrayList(); ++ this.m_49959_(this.f_49792_.m_61090_().m_61124_(f_54688_, Integer.valueOf(0))); ++ this.supplier = p_54694_; + } + + public VoxelShape m_5939_(BlockState p_54760_, BlockGetter p_54761_, BlockPos p_54762_, CollisionContext p_54763_) { +@@ -71,6 +_,7 @@ + + public FluidState m_5888_(BlockState p_54765_) { + int i = p_54765_.m_61143_(f_54688_); ++ if (!fluidStateCacheInitialized) initFluidStateCache(); + return this.f_54691_.get(Math.min(i, 8)); + } + +@@ -120,13 +_,13 @@ + BlockPos blockpos = p_54698_.m_142300_(direction.m_122424_()); + if (p_54697_.m_6425_(blockpos).m_76153_(FluidTags.f_13131_)) { + Block block = p_54697_.m_6425_(p_54698_).m_76170_() ? Blocks.f_50080_ : Blocks.f_50652_; +- p_54697_.m_46597_(p_54698_, block.m_49966_()); ++ p_54697_.m_46597_(p_54698_, net.minecraftforge.event.ForgeEventFactory.fireFluidPlaceBlockEvent(p_54697_, p_54698_, p_54698_, block.m_49966_())); + this.m_54700_(p_54697_, p_54698_); + return false; + } + + if (flag && p_54697_.m_8055_(blockpos).m_60713_(Blocks.f_50568_)) { +- p_54697_.m_46597_(p_54698_, Blocks.f_50137_.m_49966_()); ++ p_54697_.m_46597_(p_54698_, net.minecraftforge.event.ForgeEventFactory.fireFluidPlaceBlockEvent(p_54697_, p_54698_, p_54698_, Blocks.f_50137_.m_49966_())); + this.m_54700_(p_54697_, p_54698_); + return false; + } +@@ -150,6 +_,25 @@ + return new ItemStack(this.f_54689_.m_6859_()); + } else { + return ItemStack.f_41583_; ++ } ++ } ++ ++ // Forge start ++ private final java.util.function.Supplier supplier; ++ public FlowingFluid getFluid() { ++ return (FlowingFluid)supplier.get(); ++ } ++ ++ private boolean fluidStateCacheInitialized = false; ++ protected synchronized void initFluidStateCache() { ++ if (fluidStateCacheInitialized == false) { ++ this.f_54691_.add(getFluid().m_76068_(false)); ++ ++ for (int i = 1; i < 8; ++i) ++ this.f_54691_.add(getFluid().m_75953_(8 - i, false)); ++ ++ this.f_54691_.add(getFluid().m_75953_(8, true)); ++ fluidStateCacheInitialized = true; + } + } + diff --git a/patches/minecraft/net/minecraft/world/level/block/MushroomBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/MushroomBlock.java.patch new file mode 100644 index 0000000000..39d6e6a210 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/MushroomBlock.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/block/MushroomBlock.java ++++ b/net/minecraft/world/level/block/MushroomBlock.java +@@ -69,7 +_,7 @@ + if (blockstate.m_60620_(BlockTags.f_13057_)) { + return true; + } else { +- return p_54881_.m_45524_(p_54882_, 0) < 13 && this.m_6266_(blockstate, p_54881_, blockpos); ++ return p_54881_.m_45524_(p_54882_, 0) < 13 && blockstate.canSustainPlant(p_54881_, blockpos, net.minecraft.core.Direction.UP, this); + } + } + diff --git a/patches/minecraft/net/minecraft/world/level/block/NetherWartBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/NetherWartBlock.java.patch new file mode 100644 index 0000000000..f18affcd9a --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/NetherWartBlock.java.patch @@ -0,0 +1,14 @@ +--- a/net/minecraft/world/level/block/NetherWartBlock.java ++++ b/net/minecraft/world/level/block/NetherWartBlock.java +@@ -38,9 +_,10 @@ + + public void m_7455_(BlockState p_54981_, ServerLevel p_54982_, BlockPos p_54983_, Random p_54984_) { + int i = p_54981_.m_61143_(f_54967_); +- if (i < 3 && p_54984_.nextInt(10) == 0) { ++ if (i < 3 && net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_54982_, p_54983_, p_54981_, p_54984_.nextInt(10) == 0)) { + p_54981_ = p_54981_.m_61124_(f_54967_, Integer.valueOf(i + 1)); + p_54982_.m_7731_(p_54983_, p_54981_, 2); ++ net.minecraftforge.common.ForgeHooks.onCropsGrowPost(p_54982_, p_54983_, p_54981_); + } + + } diff --git a/patches/minecraft/net/minecraft/world/level/block/NoteBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/NoteBlock.java.patch new file mode 100644 index 0000000000..8d03c9190c --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/NoteBlock.java.patch @@ -0,0 +1,23 @@ +--- a/net/minecraft/world/level/block/NoteBlock.java ++++ b/net/minecraft/world/level/block/NoteBlock.java +@@ -62,7 +_,9 @@ + if (p_55035_.f_46443_) { + return InteractionResult.SUCCESS; + } else { +- p_55034_ = p_55034_.m_61122_(f_55013_); ++ int _new = net.minecraftforge.common.ForgeHooks.onNoteChange(p_55035_, p_55036_, p_55034_, p_55034_.m_61143_(f_55013_), p_55034_.m_61122_(f_55013_).m_61143_(f_55013_)); ++ if (_new == -1) return InteractionResult.FAIL; ++ p_55034_ = p_55034_.m_61124_(f_55013_, _new); + p_55035_.m_7731_(p_55036_, p_55034_, 3); + this.m_55019_(p_55035_, p_55036_); + p_55037_.m_36220_(Stats.f_12960_); +@@ -78,6 +_,9 @@ + } + + public boolean m_8133_(BlockState p_55023_, Level p_55024_, BlockPos p_55025_, int p_55026_, int p_55027_) { ++ net.minecraftforge.event.world.NoteBlockEvent.Play e = new net.minecraftforge.event.world.NoteBlockEvent.Play(p_55024_, p_55025_, p_55023_, p_55023_.m_61143_(f_55013_), p_55023_.m_61143_(f_55011_)); ++ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(e)) return false; ++ p_55023_ = p_55023_.m_61124_(f_55013_, e.getVanillaNoteId()).m_61124_(f_55011_, e.getInstrument()); + int i = p_55023_.m_61143_(f_55013_); + float f = (float)Math.pow(2.0D, (double)(i - 12) / 12.0D); + p_55024_.m_5594_((Player)null, p_55025_, p_55023_.m_61143_(f_55011_).m_61668_(), SoundSource.RECORDS, 3.0F, f); diff --git a/patches/minecraft/net/minecraft/world/level/block/OreBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/OreBlock.java.patch new file mode 100644 index 0000000000..e51ed4fc97 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/OreBlock.java.patch @@ -0,0 +1,19 @@ +--- a/net/minecraft/world/level/block/OreBlock.java ++++ b/net/minecraft/world/level/block/OreBlock.java +@@ -23,12 +_,10 @@ + + public void m_8101_(BlockState p_55142_, ServerLevel p_55143_, BlockPos p_55144_, ItemStack p_55145_) { + super.m_8101_(p_55142_, p_55143_, p_55144_, p_55145_); +- if (EnchantmentHelper.m_44843_(Enchantments.f_44985_, p_55145_) == 0) { +- int i = this.f_153990_.m_142270_(p_55143_.f_46441_); +- if (i > 0) { +- this.m_49805_(p_55143_, p_55144_, i); +- } +- } ++ } + ++ @Override ++ public int getExpDrop(BlockState state, net.minecraft.world.level.LevelReader reader, BlockPos pos, int fortune, int silktouch) { ++ return silktouch == 0 ? this.f_153990_.m_142270_(RANDOM) : 0; + } + } diff --git a/patches/minecraft/net/minecraft/world/level/block/PoweredRailBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/PoweredRailBlock.java.patch new file mode 100644 index 0000000000..cfb6604cfb --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/PoweredRailBlock.java.patch @@ -0,0 +1,57 @@ +--- a/net/minecraft/world/level/block/PoweredRailBlock.java ++++ b/net/minecraft/world/level/block/PoweredRailBlock.java +@@ -14,10 +_,16 @@ + public class PoweredRailBlock extends BaseRailBlock { + public static final EnumProperty f_55214_ = BlockStateProperties.f_61404_; + public static final BooleanProperty f_55215_ = BlockStateProperties.f_61448_; ++ private final boolean isActivator; // TRUE for an Activator Rail, FALSE for Powered Rail + + public PoweredRailBlock(BlockBehaviour.Properties p_55218_) { +- super(true, p_55218_); ++ this(p_55218_, false); ++ } ++ ++ protected PoweredRailBlock(BlockBehaviour.Properties builder, boolean isPoweredRail) { ++ super(true, builder); + this.m_49959_(this.f_49792_.m_61090_().m_61124_(f_55214_, RailShape.NORTH_SOUTH).m_61124_(f_55215_, Boolean.valueOf(false)).m_61124_(f_152149_, Boolean.valueOf(false))); ++ this.isActivator = !isPoweredRail; + } + + protected boolean m_55219_(Level p_55220_, BlockPos p_55221_, BlockState p_55222_, boolean p_55223_, int p_55224_) { +@@ -99,13 +_,13 @@ + + protected boolean m_55225_(Level p_55226_, BlockPos p_55227_, boolean p_55228_, int p_55229_, RailShape p_55230_) { + BlockState blockstate = p_55226_.m_8055_(p_55227_); +- if (!blockstate.m_60713_(this)) { ++ if (!(blockstate.m_60734_() instanceof PoweredRailBlock)) { + return false; + } else { +- RailShape railshape = blockstate.m_61143_(f_55214_); ++ RailShape railshape = getRailDirection(blockstate, p_55226_, p_55227_, null); + if (p_55230_ != RailShape.EAST_WEST || railshape != RailShape.NORTH_SOUTH && railshape != RailShape.ASCENDING_NORTH && railshape != RailShape.ASCENDING_SOUTH) { + if (p_55230_ != RailShape.NORTH_SOUTH || railshape != RailShape.EAST_WEST && railshape != RailShape.ASCENDING_EAST && railshape != RailShape.ASCENDING_WEST) { +- if (blockstate.m_61143_(f_55215_)) { ++ if (isActivator == (((PoweredRailBlock) blockstate.m_60734_()).isActivator)) { + return p_55226_.m_46753_(p_55227_) ? true : this.m_55219_(p_55226_, p_55227_, blockstate, p_55228_, p_55229_ + 1); + } else { + return false; +@@ -156,6 +_,9 @@ + return p_55240_.m_61124_(f_55214_, RailShape.SOUTH_EAST); + case NORTH_EAST: + return p_55240_.m_61124_(f_55214_, RailShape.SOUTH_WEST); ++ case NORTH_SOUTH: //Forge fix: MC-196102 ++ case EAST_WEST: ++ return p_55240_; + } + case COUNTERCLOCKWISE_90: + switch((RailShape)p_55240_.m_61143_(f_55214_)) { +@@ -254,5 +_,9 @@ + + protected void m_7926_(StateDefinition.Builder p_55243_) { + p_55243_.m_61104_(f_55214_, f_55215_, f_152149_); ++ } ++ ++ public boolean isActivatorRail() { ++ return isActivator; + } + } diff --git a/patches/minecraft/net/minecraft/world/level/block/RailBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/RailBlock.java.patch new file mode 100644 index 0000000000..09b395d0a6 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/RailBlock.java.patch @@ -0,0 +1,12 @@ +--- a/net/minecraft/world/level/block/RailBlock.java ++++ b/net/minecraft/world/level/block/RailBlock.java +@@ -49,6 +_,9 @@ + return p_55405_.m_61124_(f_55392_, RailShape.SOUTH_EAST); + case NORTH_EAST: + return p_55405_.m_61124_(f_55392_, RailShape.SOUTH_WEST); ++ case NORTH_SOUTH: //Forge fix: MC-196102 ++ case EAST_WEST: ++ return p_55405_; + } + case COUNTERCLOCKWISE_90: + switch((RailShape)p_55405_.m_61143_(f_55392_)) { diff --git a/patches/minecraft/net/minecraft/world/level/block/RailState.java.patch b/patches/minecraft/net/minecraft/world/level/block/RailState.java.patch new file mode 100644 index 0000000000..cc0b7e58c4 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/RailState.java.patch @@ -0,0 +1,57 @@ +--- a/net/minecraft/world/level/block/RailState.java ++++ b/net/minecraft/world/level/block/RailState.java +@@ -16,14 +_,16 @@ + private BlockState f_55417_; + private final boolean f_55418_; + private final List f_55419_ = Lists.newArrayList(); ++ private final boolean canMakeSlopes; + + public RailState(Level p_55421_, BlockPos p_55422_, BlockState p_55423_) { + this.f_55414_ = p_55421_; + this.f_55415_ = p_55422_; + this.f_55417_ = p_55423_; + this.f_55416_ = (BaseRailBlock)p_55423_.m_60734_(); +- RailShape railshape = p_55423_.m_61143_(this.f_55416_.m_7978_()); +- this.f_55418_ = this.f_55416_.m_49413_(); ++ RailShape railshape = this.f_55416_.getRailDirection(f_55417_, p_55421_, p_55422_, null); ++ this.f_55418_ = !this.f_55416_.isFlexibleRail(f_55417_, p_55421_, p_55422_); ++ this.canMakeSlopes = this.f_55416_.canMakeSlopes(f_55417_, p_55421_, p_55422_); + this.m_55427_(railshape); + } + +@@ -179,7 +_,7 @@ + } + } + +- if (railshape == RailShape.NORTH_SOUTH) { ++ if (railshape == RailShape.NORTH_SOUTH && canMakeSlopes) { + if (BaseRailBlock.m_49364_(this.f_55414_, blockpos.m_7494_())) { + railshape = RailShape.ASCENDING_NORTH; + } +@@ -189,7 +_,7 @@ + } + } + +- if (railshape == RailShape.EAST_WEST) { ++ if (railshape == RailShape.EAST_WEST && canMakeSlopes) { + if (BaseRailBlock.m_49364_(this.f_55414_, blockpos3.m_7494_())) { + railshape = RailShape.ASCENDING_EAST; + } +@@ -305,7 +_,7 @@ + } + } + +- if (railshape == RailShape.NORTH_SOUTH) { ++ if (railshape == RailShape.NORTH_SOUTH && canMakeSlopes) { + if (BaseRailBlock.m_49364_(this.f_55414_, blockpos.m_7494_())) { + railshape = RailShape.ASCENDING_NORTH; + } +@@ -315,7 +_,7 @@ + } + } + +- if (railshape == RailShape.EAST_WEST) { ++ if (railshape == RailShape.EAST_WEST && canMakeSlopes) { + if (BaseRailBlock.m_49364_(this.f_55414_, blockpos3.m_7494_())) { + railshape = RailShape.ASCENDING_EAST; + } diff --git a/patches/minecraft/net/minecraft/world/level/block/RedStoneOreBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/RedStoneOreBlock.java.patch new file mode 100644 index 0000000000..10dd60c726 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/RedStoneOreBlock.java.patch @@ -0,0 +1,18 @@ +--- a/net/minecraft/world/level/block/RedStoneOreBlock.java ++++ b/net/minecraft/world/level/block/RedStoneOreBlock.java +@@ -71,11 +_,11 @@ + + public void m_8101_(BlockState p_55462_, ServerLevel p_55463_, BlockPos p_55464_, ItemStack p_55465_) { + super.m_8101_(p_55462_, p_55463_, p_55464_, p_55465_); +- if (EnchantmentHelper.m_44843_(Enchantments.f_44985_, p_55465_) == 0) { +- int i = 1 + p_55463_.f_46441_.nextInt(5); +- this.m_49805_(p_55463_, p_55464_, i); +- } ++ } + ++ @Override ++ public int getExpDrop(BlockState state, net.minecraft.world.level.LevelReader world, BlockPos pos, int fortune, int silktouch) { ++ return silktouch == 0 ? 1 + RANDOM.nextInt(5) : 0; + } + + public void m_7100_(BlockState p_55479_, Level p_55480_, BlockPos p_55481_, Random p_55482_) { diff --git a/patches/minecraft/net/minecraft/world/level/block/SaplingBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/SaplingBlock.java.patch new file mode 100644 index 0000000000..5cf76f4350 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/SaplingBlock.java.patch @@ -0,0 +1,18 @@ +--- a/net/minecraft/world/level/block/SaplingBlock.java ++++ b/net/minecraft/world/level/block/SaplingBlock.java +@@ -32,6 +_,7 @@ + + public void m_7455_(BlockState p_56003_, ServerLevel p_56004_, BlockPos p_56005_, Random p_56006_) { + if (p_56004_.m_46803_(p_56005_.m_7494_()) >= 9 && p_56006_.nextInt(7) == 0) { ++ if (!p_56004_.isAreaLoaded(p_56005_, 1)) return; // Forge: prevent loading unloaded chunks when checking neighbor's light + this.m_55980_(p_56004_, p_56005_, p_56003_, p_56006_); + } + +@@ -41,6 +_,7 @@ + if (p_55983_.m_61143_(f_55973_) == 0) { + p_55981_.m_7731_(p_55982_, p_55983_.m_61122_(f_55973_), 4); + } else { ++ if (!net.minecraftforge.event.ForgeEventFactory.saplingGrowTree(p_55981_, p_55984_, p_55982_)) return; + this.f_55975_.m_6334_(p_55981_, p_55981_.m_7726_().m_8481_(), p_55982_, p_55983_, p_55984_); + } + diff --git a/patches/minecraft/net/minecraft/world/level/block/SeagrassBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/SeagrassBlock.java.patch new file mode 100644 index 0000000000..28f28317d7 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/SeagrassBlock.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/block/SeagrassBlock.java ++++ b/net/minecraft/world/level/block/SeagrassBlock.java +@@ -19,7 +_,7 @@ + import net.minecraft.world.phys.shapes.CollisionContext; + import net.minecraft.world.phys.shapes.VoxelShape; + +-public class SeagrassBlock extends BushBlock implements BonemealableBlock, LiquidBlockContainer { ++public class SeagrassBlock extends BushBlock implements BonemealableBlock, LiquidBlockContainer, net.minecraftforge.common.IForgeShearable { + protected static final float f_154492_ = 6.0F; + protected static final VoxelShape f_154493_ = Block.m_49796_(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D); + diff --git a/patches/minecraft/net/minecraft/world/level/block/SoundType.java.patch b/patches/minecraft/net/minecraft/world/level/block/SoundType.java.patch new file mode 100644 index 0000000000..c3c4501cb9 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/SoundType.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/world/level/block/SoundType.java ++++ b/net/minecraft/world/level/block/SoundType.java +@@ -88,6 +_,7 @@ + private final SoundEvent f_56737_; + private final SoundEvent f_56738_; + ++ @Deprecated // Forge: Use {@link net.minecraftforge.common.util.ForgeSoundType} instead for suppliers + public SoundType(float p_56766_, float p_56767_, SoundEvent p_56768_, SoundEvent p_56769_, SoundEvent p_56770_, SoundEvent p_56771_, SoundEvent p_56772_) { + this.f_56731_ = p_56766_; + this.f_56732_ = p_56767_; diff --git a/patches/minecraft/net/minecraft/world/level/block/SpawnerBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/SpawnerBlock.java.patch new file mode 100644 index 0000000000..071112a23a --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/SpawnerBlock.java.patch @@ -0,0 +1,16 @@ +--- a/net/minecraft/world/level/block/SpawnerBlock.java ++++ b/net/minecraft/world/level/block/SpawnerBlock.java +@@ -29,8 +_,11 @@ + + public void m_8101_(BlockState p_56789_, ServerLevel p_56790_, BlockPos p_56791_, ItemStack p_56792_) { + super.m_8101_(p_56789_, p_56790_, p_56791_, p_56792_); +- int i = 15 + p_56790_.f_46441_.nextInt(15) + p_56790_.f_46441_.nextInt(15); +- this.m_49805_(p_56790_, p_56791_, i); ++ } ++ ++ @Override ++ public int getExpDrop(BlockState state, net.minecraft.world.level.LevelReader world, BlockPos pos, int fortune, int silktouch) { ++ return 15 + RANDOM.nextInt(15) + RANDOM.nextInt(15); + } + + public RenderShape m_7514_(BlockState p_56794_) { diff --git a/patches/minecraft/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java.patch new file mode 100644 index 0000000000..36a5061f2b --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java ++++ b/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java +@@ -35,6 +_,7 @@ + + public void m_7455_(BlockState p_56819_, ServerLevel p_56820_, BlockPos p_56821_, Random p_56822_) { + if (!m_56823_(p_56819_, p_56820_, p_56821_)) { ++ if (!p_56820_.isAreaLoaded(p_56821_, 3)) return; // Forge: prevent loading unloaded chunks when checking neighbor's light and spreading + p_56820_.m_46597_(p_56821_, Blocks.f_50493_.m_49966_()); + } else { + if (p_56820_.m_46803_(p_56821_.m_7494_()) >= 9) { diff --git a/patches/minecraft/net/minecraft/world/level/block/StairBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/StairBlock.java.patch new file mode 100644 index 0000000000..637f99b48d --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/StairBlock.java.patch @@ -0,0 +1,39 @@ +--- a/net/minecraft/world/level/block/StairBlock.java ++++ b/net/minecraft/world/level/block/StairBlock.java +@@ -81,11 +_,21 @@ + return voxelshape; + } + ++ @Deprecated // Forge: Use the other constructor that takes a Supplier + public StairBlock(BlockState p_56862_, BlockBehaviour.Properties p_56863_) { + super(p_56863_); + this.m_49959_(this.f_49792_.m_61090_().m_61124_(f_56841_, Direction.NORTH).m_61124_(f_56842_, Half.BOTTOM).m_61124_(f_56843_, StairsShape.STRAIGHT).m_61124_(f_56844_, Boolean.valueOf(false))); + this.f_56858_ = p_56862_.m_60734_(); + this.f_56859_ = p_56862_; ++ this.stateSupplier = () -> p_56862_; ++ } ++ ++ public StairBlock(java.util.function.Supplier state, BlockBehaviour.Properties properties) { ++ super(properties); ++ this.m_49959_(this.f_49792_.m_61090_().m_61124_(f_56841_, Direction.NORTH).m_61124_(f_56842_, Half.BOTTOM).m_61124_(f_56843_, StairsShape.STRAIGHT).m_61124_(f_56844_, Boolean.valueOf(false))); ++ this.f_56858_ = Blocks.f_50016_; // These are unused, fields are redirected ++ this.f_56859_ = Blocks.f_50016_.m_49966_(); ++ this.stateSupplier = state; + } + + public boolean m_7923_(BlockState p_56967_) { +@@ -262,4 +_,14 @@ + public boolean m_7357_(BlockState p_56891_, BlockGetter p_56892_, BlockPos p_56893_, PathComputationType p_56894_) { + return false; + } ++ ++ // Forge Start ++ private final java.util.function.Supplier stateSupplier; ++ private Block getModelBlock() { ++ return getModelState().m_60734_(); ++ } ++ private BlockState getModelState() { ++ return stateSupplier.get(); ++ } ++ // Forge end + } diff --git a/patches/minecraft/net/minecraft/world/level/block/StemBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/StemBlock.java.patch new file mode 100644 index 0000000000..73a27c49ae --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/StemBlock.java.patch @@ -0,0 +1,43 @@ +--- a/net/minecraft/world/level/block/StemBlock.java ++++ b/net/minecraft/world/level/block/StemBlock.java +@@ -43,22 +_,24 @@ + } + + public void m_7455_(BlockState p_57042_, ServerLevel p_57043_, BlockPos p_57044_, Random p_57045_) { ++ if (!p_57043_.isAreaLoaded(p_57044_, 1)) return; // Forge: prevent loading unloaded chunks when checking neighbor's light + if (p_57043_.m_45524_(p_57044_, 0) >= 9) { + float f = CropBlock.m_52272_(this, p_57043_, p_57044_); +- if (p_57045_.nextInt((int)(25.0F / f) + 1) == 0) { ++ if (net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_57043_, p_57044_, p_57042_, p_57045_.nextInt((int)(25.0F / f) + 1) == 0)) { + int i = p_57042_.m_61143_(f_57013_); + if (i < 7) { +- p_57042_ = p_57042_.m_61124_(f_57013_, Integer.valueOf(i + 1)); +- p_57043_.m_7731_(p_57044_, p_57042_, 2); ++ p_57043_.m_7731_(p_57044_, p_57042_.m_61124_(f_57013_, Integer.valueOf(i + 1)), 2); + } else { + Direction direction = Direction.Plane.HORIZONTAL.m_122560_(p_57045_); + BlockPos blockpos = p_57044_.m_142300_(direction); + BlockState blockstate = p_57043_.m_8055_(blockpos.m_7495_()); +- if (p_57043_.m_8055_(blockpos).m_60795_() && (blockstate.m_60713_(Blocks.f_50093_) || blockstate.m_60620_(BlockTags.f_144274_))) { ++ Block block = blockstate.m_60734_(); ++ if (p_57043_.m_46859_(blockpos) && (blockstate.canSustainPlant(p_57043_, blockpos.m_7495_(), Direction.UP, this) || block == Blocks.f_50093_ || block == Blocks.f_50493_ || block == Blocks.f_50546_ || block == Blocks.f_50599_ || block == Blocks.f_50440_)) { + p_57043_.m_46597_(blockpos, this.f_57015_.m_49966_()); + p_57043_.m_46597_(p_57044_, this.f_57015_.m_7810_().m_49966_().m_61124_(HorizontalDirectionalBlock.f_54117_, direction)); + } + } ++ net.minecraftforge.common.ForgeHooks.onCropsGrowPost(p_57043_, p_57044_, p_57042_); + } + + } +@@ -92,5 +_,11 @@ + + public StemGrownBlock m_57056_() { + return this.f_57015_; ++ } ++ ++ //FORGE START ++ @Override ++ public net.minecraftforge.common.PlantType getPlantType(BlockGetter world, BlockPos pos) { ++ return net.minecraftforge.common.PlantType.CROP; + } + } diff --git a/patches/minecraft/net/minecraft/world/level/block/SugarCaneBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/SugarCaneBlock.java.patch new file mode 100644 index 0000000000..15699e6f61 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/SugarCaneBlock.java.patch @@ -0,0 +1,51 @@ +--- a/net/minecraft/world/level/block/SugarCaneBlock.java ++++ b/net/minecraft/world/level/block/SugarCaneBlock.java +@@ -18,7 +_,7 @@ + import net.minecraft.world.phys.shapes.CollisionContext; + import net.minecraft.world.phys.shapes.VoxelShape; + +-public class SugarCaneBlock extends Block { ++public class SugarCaneBlock extends Block implements net.minecraftforge.common.IPlantable { + public static final IntegerProperty f_57164_ = BlockStateProperties.f_61410_; + protected static final float f_154735_ = 6.0F; + protected static final VoxelShape f_57165_ = Block.m_49796_(2.0D, 0.0D, 2.0D, 14.0D, 16.0D, 14.0D); +@@ -47,12 +_,14 @@ + + if (i < 3) { + int j = p_57188_.m_61143_(f_57164_); ++ if (net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_57189_, p_57190_, p_57188_, true)) { + if (j == 15) { + p_57189_.m_46597_(p_57190_.m_7494_(), this.m_49966_()); + p_57189_.m_7731_(p_57190_, p_57188_.m_61124_(f_57164_, Integer.valueOf(0)), 4); + } else { + p_57189_.m_7731_(p_57190_, p_57188_.m_61124_(f_57164_, Integer.valueOf(j + 1)), 4); + } ++ } + } + } + +@@ -67,6 +_,8 @@ + } + + public boolean m_7898_(BlockState p_57175_, LevelReader p_57176_, BlockPos p_57177_) { ++ BlockState soil = p_57176_.m_8055_(p_57177_.m_7495_()); ++ if (soil.canSustainPlant(p_57176_, p_57177_.m_7495_(), Direction.UP, this)) return true; + BlockState blockstate = p_57176_.m_8055_(p_57177_.m_7495_()); + if (blockstate.m_60713_(this)) { + return true; +@@ -89,5 +_,15 @@ + + protected void m_7926_(StateDefinition.Builder p_57186_) { + p_57186_.m_61104_(f_57164_); ++ } ++ ++ @Override ++ public net.minecraftforge.common.PlantType getPlantType(BlockGetter world, BlockPos pos) { ++ return net.minecraftforge.common.PlantType.BEACH; ++ } ++ ++ @Override ++ public BlockState getPlant(BlockGetter world, BlockPos pos) { ++ return m_49966_(); + } + } diff --git a/patches/minecraft/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch new file mode 100644 index 0000000000..a0e5291429 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch @@ -0,0 +1,13 @@ +--- a/net/minecraft/world/level/block/SweetBerryBushBlock.java ++++ b/net/minecraft/world/level/block/SweetBerryBushBlock.java +@@ -56,8 +_,9 @@ + + public void m_7455_(BlockState p_57286_, ServerLevel p_57287_, BlockPos p_57288_, Random p_57289_) { + int i = p_57286_.m_61143_(f_57244_); +- if (i < 3 && p_57289_.nextInt(5) == 0 && p_57287_.m_45524_(p_57288_.m_7494_(), 0) >= 9) { ++ if (i < 3 && p_57287_.m_45524_(p_57288_.m_7494_(), 0) >= 9 && net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_57287_, p_57288_, p_57286_,p_57289_.nextInt(5) == 0)) { + p_57287_.m_7731_(p_57288_, p_57286_.m_61124_(f_57244_, Integer.valueOf(i + 1)), 2); ++ net.minecraftforge.common.ForgeHooks.onCropsGrowPost(p_57287_, p_57288_, p_57286_); + } + + } diff --git a/patches/minecraft/net/minecraft/world/level/block/TallGrassBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/TallGrassBlock.java.patch new file mode 100644 index 0000000000..c5c157348a --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/TallGrassBlock.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/block/TallGrassBlock.java ++++ b/net/minecraft/world/level/block/TallGrassBlock.java +@@ -10,7 +_,7 @@ + import net.minecraft.world.phys.shapes.CollisionContext; + import net.minecraft.world.phys.shapes.VoxelShape; + +-public class TallGrassBlock extends BushBlock implements BonemealableBlock { ++public class TallGrassBlock extends BushBlock implements BonemealableBlock, net.minecraftforge.common.IForgeShearable { + protected static final float f_154739_ = 6.0F; + protected static final VoxelShape f_57315_ = Block.m_49796_(2.0D, 0.0D, 2.0D, 14.0D, 13.0D, 14.0D); + diff --git a/patches/minecraft/net/minecraft/world/level/block/TntBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/TntBlock.java.patch new file mode 100644 index 0000000000..07ac97b3d8 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/TntBlock.java.patch @@ -0,0 +1,67 @@ +--- a/net/minecraft/world/level/block/TntBlock.java ++++ b/net/minecraft/world/level/block/TntBlock.java +@@ -33,10 +_,14 @@ + this.m_49959_(this.m_49966_().m_61124_(f_57419_, Boolean.valueOf(false))); + } + ++ public void catchFire(BlockState state, Level world, BlockPos pos, @Nullable net.minecraft.core.Direction face, @Nullable LivingEntity igniter) { ++ m_57436_(world, pos, igniter); ++ } ++ + public void m_6807_(BlockState p_57466_, Level p_57467_, BlockPos p_57468_, BlockState p_57469_, boolean p_57470_) { + if (!p_57469_.m_60713_(p_57466_.m_60734_())) { + if (p_57467_.m_46753_(p_57468_)) { +- m_57433_(p_57467_, p_57468_); ++ catchFire(p_57466_, p_57467_, p_57468_, null, null); + p_57467_.m_7471_(p_57468_, false); + } + +@@ -45,7 +_,7 @@ + + public void m_6861_(BlockState p_57457_, Level p_57458_, BlockPos p_57459_, Block p_57460_, BlockPos p_57461_, boolean p_57462_) { + if (p_57458_.m_46753_(p_57459_)) { +- m_57433_(p_57458_, p_57459_); ++ catchFire(p_57457_, p_57458_, p_57459_, null, null); + p_57458_.m_7471_(p_57459_, false); + } + +@@ -53,7 +_,7 @@ + + public void m_5707_(Level p_57445_, BlockPos p_57446_, BlockState p_57447_, Player p_57448_) { + if (!p_57445_.m_5776_() && !p_57448_.m_7500_() && p_57447_.m_61143_(f_57419_)) { +- m_57433_(p_57445_, p_57446_); ++ catchFire(p_57447_, p_57445_, p_57446_, null, null); + } + + super.m_5707_(p_57445_, p_57446_, p_57447_, p_57448_); +@@ -68,10 +_,12 @@ + } + } + ++ @Deprecated //Forge: Prefer using IForgeBlock#catchFire + public static void m_57433_(Level p_57434_, BlockPos p_57435_) { + m_57436_(p_57434_, p_57435_, (LivingEntity)null); + } + ++ @Deprecated //Forge: Prefer using IForgeBlock#catchFire + private static void m_57436_(Level p_57437_, BlockPos p_57438_, @Nullable LivingEntity p_57439_) { + if (!p_57437_.f_46443_) { + PrimedTnt primedtnt = new PrimedTnt(p_57437_, (double)p_57438_.m_123341_() + 0.5D, (double)p_57438_.m_123342_(), (double)p_57438_.m_123343_() + 0.5D, p_57439_); +@@ -86,7 +_,7 @@ + if (!itemstack.m_150930_(Items.f_42409_) && !itemstack.m_150930_(Items.f_42613_)) { + return super.m_6227_(p_57450_, p_57451_, p_57452_, p_57453_, p_57454_, p_57455_); + } else { +- m_57436_(p_57451_, p_57452_, p_57453_); ++ catchFire(p_57450_, p_57451_, p_57452_, p_57455_.m_82434_(), p_57453_); + p_57451_.m_7731_(p_57452_, Blocks.f_50016_.m_49966_(), 11); + Item item = itemstack.m_41720_(); + if (!p_57453_.m_7500_()) { +@@ -109,7 +_,7 @@ + BlockPos blockpos = p_57431_.m_82425_(); + Entity entity = p_57432_.m_37282_(); + if (p_57432_.m_6060_() && p_57432_.m_142265_(p_57429_, blockpos)) { +- m_57436_(p_57429_, blockpos, entity instanceof LivingEntity ? (LivingEntity)entity : null); ++ catchFire(p_57430_, p_57429_, blockpos, null, entity instanceof LivingEntity ? (LivingEntity)entity : null); + p_57429_.m_7471_(blockpos, false); + } + } diff --git a/patches/minecraft/net/minecraft/world/level/block/TrapDoorBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/TrapDoorBlock.java.patch new file mode 100644 index 0000000000..c4f339c994 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/TrapDoorBlock.java.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/world/level/block/TrapDoorBlock.java ++++ b/net/minecraft/world/level/block/TrapDoorBlock.java +@@ -152,4 +_,17 @@ + + return super.m_7417_(p_57554_, p_57555_, p_57556_, p_57557_, p_57558_, p_57559_); + } ++ ++ //Forge Start ++ @Override ++ public boolean isLadder(BlockState state, net.minecraft.world.level.LevelReader world, BlockPos pos, net.minecraft.world.entity.LivingEntity entity) { ++ if (state.m_61143_(f_57514_)) { ++ BlockPos downPos = pos.m_7495_(); ++ BlockState down = world.m_8055_(downPos); ++ return down.m_60734_().makesOpenTrapdoorAboveClimbable(down, world, downPos, state); ++ } ++ return false; ++ } ++ //Forge End ++ + } diff --git a/patches/minecraft/net/minecraft/world/level/block/TripWireHookBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/TripWireHookBlock.java.patch new file mode 100644 index 0000000000..9fd183e7e1 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/TripWireHookBlock.java.patch @@ -0,0 +1,12 @@ +--- a/net/minecraft/world/level/block/TripWireHookBlock.java ++++ b/net/minecraft/world/level/block/TripWireHookBlock.java +@@ -155,8 +_,8 @@ + BlockPos blockpos2 = p_57687_.m_5484_(direction, k); + BlockState blockstate2 = ablockstate[k]; + if (blockstate2 != null) { ++ if (!p_57686_.m_8055_(blockpos2).m_60795_()) { // FORGE: fix MC-129055 + p_57686_.m_7731_(blockpos2, blockstate2.m_61124_(f_57669_, Boolean.valueOf(flag2)), 3); +- if (!p_57686_.m_8055_(blockpos2).m_60795_()) { + } + } + } diff --git a/patches/minecraft/net/minecraft/world/level/block/TurtleEggBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/TurtleEggBlock.java.patch new file mode 100644 index 0000000000..1535ccf2b0 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/TurtleEggBlock.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/block/TurtleEggBlock.java ++++ b/net/minecraft/world/level/block/TurtleEggBlock.java +@@ -151,7 +_,7 @@ + if (!(p_57769_ instanceof LivingEntity)) { + return false; + } else { +- return p_57769_ instanceof Player || p_57768_.m_46469_().m_46207_(GameRules.f_46132_); ++ return p_57769_ instanceof Player || net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(p_57768_, p_57769_); + } + } else { + return false; diff --git a/patches/minecraft/net/minecraft/world/level/block/VineBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/VineBlock.java.patch new file mode 100644 index 0000000000..6924a877dc --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/VineBlock.java.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/world/level/block/VineBlock.java ++++ b/net/minecraft/world/level/block/VineBlock.java +@@ -22,7 +_,7 @@ + import net.minecraft.world.phys.shapes.Shapes; + import net.minecraft.world.phys.shapes.VoxelShape; + +-public class VineBlock extends Block { ++public class VineBlock extends Block implements net.minecraftforge.common.IForgeShearable { + public static final BooleanProperty f_57833_ = PipeBlock.f_55152_; + public static final BooleanProperty f_57834_ = PipeBlock.f_55148_; + public static final BooleanProperty f_57835_ = PipeBlock.f_55149_; +@@ -157,7 +_,7 @@ + } + + public void m_7455_(BlockState p_57892_, ServerLevel p_57893_, BlockPos p_57894_, Random p_57895_) { +- if (p_57895_.nextInt(4) == 0) { ++ if (p_57893_.f_46441_.nextInt(4) == 0 && p_57893_.isAreaLoaded(p_57894_, 4)) { // Forge: check area to prevent loading unloaded chunks + Direction direction = Direction.m_122404_(p_57895_); + BlockPos blockpos = p_57894_.m_7494_(); + if (direction.m_122434_().m_122479_() && !p_57892_.m_61143_(m_57883_(direction))) { diff --git a/patches/minecraft/net/minecraft/world/level/block/WebBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/WebBlock.java.patch new file mode 100644 index 0000000000..516d627280 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/WebBlock.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/block/WebBlock.java ++++ b/net/minecraft/world/level/block/WebBlock.java +@@ -7,7 +_,7 @@ + import net.minecraft.world.level.block.state.BlockState; + import net.minecraft.world.phys.Vec3; + +-public class WebBlock extends Block { ++public class WebBlock extends Block implements net.minecraftforge.common.IForgeShearable { + public WebBlock(BlockBehaviour.Properties p_58178_) { + super(p_58178_); + } 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 new file mode 100644 index 0000000000..1dae2f2917 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch @@ -0,0 +1,176 @@ +--- a/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java ++++ b/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java +@@ -105,6 +_,7 @@ + this.f_58312_ = p_154994_; + } + ++ /**@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); +@@ -204,9 +_,9 @@ + super.m_142466_(p_155025_); + this.f_58310_ = NonNullList.m_122780_(this.m_6643_(), ItemStack.f_41583_); + ContainerHelper.m_18980_(p_155025_, this.f_58310_); +- this.f_58316_ = p_155025_.m_128448_("BurnTime"); +- this.f_58318_ = p_155025_.m_128448_("CookTime"); +- this.f_58319_ = p_155025_.m_128448_("CookTimeTotal"); ++ this.f_58316_ = p_155025_.m_128451_("BurnTime"); ++ this.f_58318_ = p_155025_.m_128451_("CookTime"); ++ this.f_58319_ = p_155025_.m_128451_("CookTimeTotal"); + this.f_58317_ = this.m_7743_(this.f_58310_.get(1)); + CompoundTag compoundtag = p_155025_.m_128469_("RecipesUsed"); + +@@ -218,9 +_,9 @@ + + public CompoundTag m_6945_(CompoundTag p_58379_) { + super.m_6945_(p_58379_); +- p_58379_.m_128376_("BurnTime", (short)this.f_58316_); +- p_58379_.m_128376_("CookTime", (short)this.f_58318_); +- p_58379_.m_128376_("CookTimeTotal", (short)this.f_58319_); ++ p_58379_.m_128405_("BurnTime", this.f_58316_); ++ p_58379_.m_128405_("CookTime", this.f_58318_); ++ p_58379_.m_128405_("CookTimeTotal", this.f_58319_); + ContainerHelper.m_18973_(p_58379_, this.f_58310_); + CompoundTag compoundtag = new CompoundTag(); + this.f_58320_.forEach((p_58382_, p_58383_) -> { +@@ -239,30 +_,32 @@ + + ItemStack itemstack = p_155017_.f_58310_.get(1); + if (p_155017_.m_58425_() || !itemstack.m_41619_() && !p_155017_.f_58310_.get(0).m_41619_()) { +- Recipe recipe = p_155014_.m_7465_().m_44015_((RecipeType)p_155017_.f_58312_, p_155017_, p_155014_).orElse((AbstractCookingRecipe)null); ++ Recipe recipe = p_155014_.m_7465_().m_44015_((RecipeType)p_155017_.f_58312_, p_155017_, p_155014_).orElse(null); + int i = p_155017_.m_6893_(); +- if (!p_155017_.m_58425_() && m_155005_(recipe, p_155017_.f_58310_, i)) { ++ if (!p_155017_.m_58425_() && p_155017_.m_155005_(recipe, 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_()) { + flag1 = true; ++ if (itemstack.hasContainerItem()) ++ p_155017_.f_58310_.set(1, itemstack.getContainerItem()); ++ else + if (!itemstack.m_41619_()) { + Item item = itemstack.m_41720_(); + itemstack.m_41774_(1); + if (itemstack.m_41619_()) { +- Item item1 = item.m_41469_(); +- p_155017_.f_58310_.set(1, item1 == null ? ItemStack.f_41583_ : new ItemStack(item1)); ++ p_155017_.f_58310_.set(1, itemstack.getContainerItem()); + } + } + } + } + +- if (p_155017_.m_58425_() && m_155005_(recipe, p_155017_.f_58310_, i)) { ++ if (p_155017_.m_58425_() && p_155017_.m_155005_(recipe, 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_155009_(p_155014_, p_155017_.f_58312_, p_155017_); +- if (m_155026_(recipe, p_155017_.f_58310_, i)) { ++ if (p_155017_.m_155026_(recipe, p_155017_.f_58310_, i)) { + p_155017_.m_6029_(recipe); + } + +@@ -287,9 +_,9 @@ + + } + +- private static boolean m_155005_(@Nullable Recipe p_155006_, NonNullList p_155007_, int p_155008_) { ++ private boolean m_155005_(@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_(); ++ ItemStack itemstack = ((Recipe) p_155006_).m_5874_(this); + if (itemstack.m_41619_()) { + return false; + } else { +@@ -298,10 +_,10 @@ + return true; + } else if (!itemstack1.m_41656_(itemstack)) { + return false; +- } else if (itemstack1.m_41613_() < p_155008_ && itemstack1.m_41613_() < itemstack1.m_41741_()) { ++ } else if (itemstack1.m_41613_() + itemstack.m_41613_() <= p_155008_ && itemstack1.m_41613_() + itemstack.m_41613_() <= itemstack1.m_41741_()) { // Forge fix: make furnace respect stack sizes in furnace recipes + return true; + } else { +- return itemstack1.m_41613_() < itemstack.m_41741_(); ++ return itemstack1.m_41613_() + itemstack.m_41613_() <= itemstack.m_41741_(); // Forge fix: make furnace respect stack sizes in furnace recipes + } + } + } else { +@@ -309,15 +_,15 @@ + } + } + +- private static boolean m_155026_(@Nullable Recipe p_155027_, NonNullList p_155028_, int p_155029_) { +- if (p_155027_ != null && m_155005_(p_155027_, p_155028_, p_155029_)) { ++ private boolean m_155026_(@Nullable Recipe p_155027_, NonNullList p_155028_, int p_155029_) { ++ if (p_155027_ != null && this.m_155005_(p_155027_, p_155028_, p_155029_)) { + ItemStack itemstack = p_155028_.get(0); +- ItemStack itemstack1 = p_155027_.m_8043_(); ++ ItemStack itemstack1 = ((Recipe) p_155027_).m_5874_(this); + ItemStack itemstack2 = p_155028_.get(2); + if (itemstack2.m_41619_()) { + p_155028_.set(2, itemstack1.m_41777_()); + } else if (itemstack2.m_150930_(itemstack1.m_41720_())) { +- itemstack2.m_41769_(1); ++ itemstack2.m_41769_(itemstack1.m_41613_()); + } + + if (itemstack.m_150930_(Blocks.f_50057_.m_5456_()) && !p_155028_.get(1).m_41619_() && p_155028_.get(1).m_150930_(Items.f_42446_)) { +@@ -336,7 +_,7 @@ + return 0; + } else { + Item item = p_58343_.m_41720_(); +- return m_58423_().getOrDefault(item, 0); ++ return net.minecraftforge.common.ForgeHooks.getBurnTime(p_58343_, this.f_58312_); + } + } + +@@ -345,7 +_,7 @@ + } + + public static boolean m_58399_(ItemStack p_58400_) { +- return m_58423_().containsKey(p_58400_.m_41720_()); ++ return net.minecraftforge.common.ForgeHooks.getBurnTime(p_58400_, null) > 0; + } + + public int[] m_7071_(Direction p_58363_) { +@@ -425,7 +_,7 @@ + return true; + } else { + ItemStack itemstack = this.f_58310_.get(1); +- return m_58399_(p_58390_) || p_58390_.m_150930_(Items.f_42446_) && !itemstack.m_150930_(Items.f_42446_); ++ return net.minecraftforge.common.ForgeHooks.getBurnTime(p_58390_, this.f_58312_) > 0 || p_58390_.m_150930_(Items.f_42446_) && !itemstack.m_150930_(Items.f_42446_); + } + } + +@@ -483,5 +_,28 @@ + p_58342_.m_36491_(itemstack); + } + ++ } ++ ++ net.minecraftforge.common.util.LazyOptional[] handlers = ++ net.minecraftforge.items.wrapper.SidedInvWrapper.create(this, Direction.UP, Direction.DOWN, Direction.NORTH); ++ ++ @Override ++ public net.minecraftforge.common.util.LazyOptional getCapability(net.minecraftforge.common.capabilities.Capability capability, @Nullable Direction facing) { ++ if (!this.f_58859_ && facing != null && capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { ++ if (facing == Direction.UP) ++ return handlers[0].cast(); ++ else if (facing == Direction.DOWN) ++ return handlers[1].cast(); ++ else ++ return handlers[2].cast(); ++ } ++ return super.getCapability(capability, facing); ++ } ++ ++ @Override ++ protected void invalidateCaps() { ++ super.invalidateCaps(); ++ for (int x = 0; x < handlers.length; x++) ++ handlers[x].invalidate(); + } + } diff --git a/patches/minecraft/net/minecraft/tileentity/BannerPattern.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/BannerPattern.java.patch similarity index 72% rename from patches/minecraft/net/minecraft/tileentity/BannerPattern.java.patch rename to patches/minecraft/net/minecraft/world/level/block/entity/BannerPattern.java.patch index 59fa24fcaa..199ef09435 100644 --- a/patches/minecraft/net/minecraft/tileentity/BannerPattern.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/BannerPattern.java.patch @@ -1,15 +1,15 @@ ---- a/net/minecraft/tileentity/BannerPattern.java -+++ b/net/minecraft/tileentity/BannerPattern.java -@@ -12,7 +_,7 @@ - import net.minecraftforge.api.distmarker.OnlyIn; - import org.apache.commons.lang3.tuple.Pair; +--- a/net/minecraft/world/level/block/entity/BannerPattern.java ++++ b/net/minecraft/world/level/block/entity/BannerPattern.java +@@ -10,7 +_,7 @@ + import net.minecraft.resources.ResourceLocation; + import net.minecraft.world.item.DyeColor; -public enum BannerPattern { +public enum BannerPattern implements net.minecraftforge.common.IExtensibleEnum { BASE("base", "b", false), SQUARE_BOTTOM_LEFT("square_bottom_left", "bl"), SQUARE_BOTTOM_RIGHT("square_bottom_right", "br"), -@@ -100,6 +_,14 @@ +@@ -106,6 +_,14 @@ } return null; diff --git a/patches/minecraft/net/minecraft/tileentity/LockableTileEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java.patch similarity index 60% rename from patches/minecraft/net/minecraft/tileentity/LockableTileEntity.java.patch rename to patches/minecraft/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java.patch index c77323ae19..dd0de399a8 100644 --- a/patches/minecraft/net/minecraft/tileentity/LockableTileEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java.patch @@ -1,17 +1,17 @@ ---- a/net/minecraft/tileentity/LockableTileEntity.java -+++ b/net/minecraft/tileentity/LockableTileEntity.java -@@ -81,4 +_,21 @@ +--- a/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java ++++ b/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java +@@ -82,4 +_,21 @@ } - protected abstract Container func_213906_a(int p_213906_1_, PlayerInventory p_213906_2_); + protected abstract AbstractContainerMenu m_6555_(int p_58627_, Inventory p_58628_); + + private net.minecraftforge.common.util.LazyOptional itemHandler = net.minecraftforge.common.util.LazyOptional.of(() -> createUnSidedHandler()); + protected net.minecraftforge.items.IItemHandler createUnSidedHandler() { + return new net.minecraftforge.items.wrapper.InvWrapper(this); + } + -+ public net.minecraftforge.common.util.LazyOptional getCapability(net.minecraftforge.common.capabilities.Capability cap, @javax.annotation.Nullable net.minecraft.util.Direction side) { -+ if (!this.field_145846_f && cap == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY ) ++ public net.minecraftforge.common.util.LazyOptional getCapability(net.minecraftforge.common.capabilities.Capability cap, @javax.annotation.Nullable net.minecraft.core.Direction side) { ++ if (!this.f_58859_ && cap == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY ) + return itemHandler.cast(); + return super.getCapability(cap, side); + } 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 new file mode 100644 index 0000000000..12c8868677 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/entity/BeaconBlockEntity.java.patch @@ -0,0 +1,13 @@ +--- a/net/minecraft/world/level/block/entity/BeaconBlockEntity.java ++++ b/net/minecraft/world/level/block/entity/BeaconBlockEntity.java +@@ -117,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_(); +- if (block instanceof BeaconBeamBlock) { +- float[] afloat = ((BeaconBeamBlock)block).m_7988_().m_41068_(); ++ float[] afloat = blockstate.getBeaconColorMultiplier(p_155108_, blockpos, p_155109_); ++ if (afloat != null) { + if (p_155111_.f_58649_.size() <= 1) { + beaconblockentity$beaconbeamsection = new BeaconBlockEntity.BeaconBeamSection(afloat); + p_155111_.f_58649_.add(beaconblockentity$beaconbeamsection); diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/BlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/BlockEntity.java.patch new file mode 100644 index 0000000000..bf3b9f85e0 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/entity/BlockEntity.java.patch @@ -0,0 +1,72 @@ +--- a/net/minecraft/world/level/block/entity/BlockEntity.java ++++ b/net/minecraft/world/level/block/entity/BlockEntity.java +@@ -12,7 +_,7 @@ + import org.apache.logging.log4j.LogManager; + import org.apache.logging.log4j.Logger; + +-public abstract class BlockEntity { ++public abstract class BlockEntity extends net.minecraftforge.common.capabilities.CapabilityProvider implements net.minecraftforge.common.extensions.IForgeBlockEntity { + private static final Logger f_58854_ = LogManager.getLogger(); + private final BlockEntityType f_58855_; + @Nullable +@@ -20,11 +_,14 @@ + protected final BlockPos f_58858_; + protected boolean f_58859_; + private BlockState f_58856_; ++ private CompoundTag customTileData; + + public BlockEntity(BlockEntityType p_155228_, BlockPos p_155229_, BlockState p_155230_) { ++ super(BlockEntity.class); + this.f_58855_ = p_155228_; + this.f_58858_ = p_155229_.m_7949_(); + this.f_58856_ = p_155230_; ++ this.gatherCapabilities(); + } + + @Nullable +@@ -41,6 +_,8 @@ + } + + public void m_142466_(CompoundTag p_155245_) { ++ if (p_155245_.m_128441_("ForgeData")) this.customTileData = p_155245_.m_128469_("ForgeData"); ++ if (getCapabilities() != null && p_155245_.m_128441_("ForgeCaps")) deserializeCaps(p_155245_.m_128469_("ForgeCaps")); + } + + public CompoundTag m_6945_(CompoundTag p_58888_) { +@@ -56,6 +_,8 @@ + p_58895_.m_128405_("x", this.f_58858_.m_123341_()); + p_58895_.m_128405_("y", this.f_58858_.m_123342_()); + p_58895_.m_128405_("z", this.f_58858_.m_123343_()); ++ if (this.customTileData != null) p_58895_.m_128365_("ForgeData", this.customTileData); ++ if (getCapabilities() != null) p_58895_.m_128365_("ForgeCaps", serializeCaps()); + return p_58895_; + } + } +@@ -128,6 +_,13 @@ + + public void m_7651_() { + this.f_58859_ = true; ++ this.invalidateCaps(); ++ requestModelDataUpdate(); ++ } ++ ++ @Override ++ public void onChunkUnloaded() { ++ this.invalidateCaps(); + } + + public void m_6339_() { +@@ -154,6 +_,13 @@ + + public BlockEntityType m_58903_() { + return this.f_58855_; ++ } ++ ++ @Override ++ public CompoundTag getTileData() { ++ if (this.customTileData == null) ++ this.customTileData = new CompoundTag(); ++ return this.customTileData; + } + + @Deprecated diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/BlockEntityType.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/BlockEntityType.java.patch new file mode 100644 index 0000000000..90b1585f61 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/entity/BlockEntityType.java.patch @@ -0,0 +1,34 @@ +--- a/net/minecraft/world/level/block/entity/BlockEntityType.java ++++ b/net/minecraft/world/level/block/entity/BlockEntityType.java +@@ -17,7 +_,7 @@ + import org.apache.logging.log4j.LogManager; + import org.apache.logging.log4j.Logger; + +-public class BlockEntityType { ++public class BlockEntityType extends net.minecraftforge.registries.ForgeRegistryEntry> { + private static final Logger f_58913_ = LogManager.getLogger(); + public static final BlockEntityType f_58917_ = m_58956_("furnace", BlockEntityType.Builder.m_155273_(FurnaceBlockEntity::new, Blocks.f_50094_)); + public static final BlockEntityType f_58918_ = m_58956_("chest", BlockEntityType.Builder.m_155273_(ChestBlockEntity::new, Blocks.f_50087_)); +@@ -56,6 +_,7 @@ + private final BlockEntityType.BlockEntitySupplier f_58914_; + private final Set f_58915_; + private final Type f_58916_; ++ private final net.minecraftforge.common.util.ReverseTagWrapper> reverseTags = new net.minecraftforge.common.util.ReverseTagWrapper<>(this, () -> net.minecraft.tags.SerializationTags.m_13199_().getCustomTypeCollection(net.minecraftforge.registries.ForgeRegistries.BLOCK_ENTITIES)); + + @Nullable + public static ResourceLocation m_58954_(BlockEntityType p_58955_) { +@@ -75,6 +_,14 @@ + this.f_58914_ = p_155259_; + this.f_58915_ = p_155260_; + this.f_58916_ = p_155261_; ++ } ++ ++ public java.util.Set getTags() { ++ return reverseTags.getTagNames(); ++ } ++ ++ public boolean isIn(net.minecraft.tags.Tag> tag) { ++ return tag.m_8110_(this); + } + + @Nullable diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java.patch new file mode 100644 index 0000000000..8045940cc8 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java.patch @@ -0,0 +1,82 @@ +--- a/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java ++++ b/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java +@@ -148,6 +_,7 @@ + + private static boolean m_155294_(NonNullList p_155295_) { + ItemStack itemstack = p_155295_.get(3); ++ if (!itemstack.m_41619_()) return net.minecraftforge.common.brewing.BrewingRecipeRegistry.canBrew(p_155295_, itemstack, f_58974_); // divert to VanillaBrewingRegistry + if (itemstack.m_41619_()) { + return false; + } else if (!PotionBrewing.m_43506_(itemstack)) { +@@ -165,21 +_,21 @@ + } + + private static void m_155290_(Level p_155291_, BlockPos p_155292_, NonNullList p_155293_) { ++ if (net.minecraftforge.event.ForgeEventFactory.onPotionAttemptBrew(p_155293_)) return; + ItemStack itemstack = p_155293_.get(3); + +- for(int i = 0; i < 3; ++i) { +- p_155293_.set(i, PotionBrewing.m_43529_(itemstack, p_155293_.get(i))); +- } +- +- itemstack.m_41774_(1); +- if (itemstack.m_41720_().m_41470_()) { +- ItemStack itemstack1 = new ItemStack(itemstack.m_41720_().m_41469_()); ++ net.minecraftforge.common.brewing.BrewingRecipeRegistry.brewPotions(p_155293_, itemstack, f_58974_); ++ net.minecraftforge.event.ForgeEventFactory.onPotionBrewed(p_155293_); ++ if (itemstack.hasContainerItem()) { ++ ItemStack itemstack1 = itemstack.getContainerItem(); ++ itemstack.m_41774_(1); + if (itemstack.m_41619_()) { + itemstack = itemstack1; + } else { + Containers.m_18992_(p_155291_, (double)p_155292_.m_123341_(), (double)p_155292_.m_123342_(), (double)p_155292_.m_123343_(), itemstack1); + } + } ++ else itemstack.m_41774_(1); + + p_155293_.set(3, itemstack); + p_155291_.m_46796_(1035, p_155292_, 0); +@@ -230,11 +_,11 @@ + + public boolean m_7013_(int p_59017_, ItemStack p_59018_) { + if (p_59017_ == 3) { +- return PotionBrewing.m_43506_(p_59018_); ++ return net.minecraftforge.common.brewing.BrewingRecipeRegistry.isValidIngredient(p_59018_); + } else if (p_59017_ == 4) { + return p_59018_.m_150930_(Items.f_42593_); + } else { +- return (p_59018_.m_150930_(Items.f_42589_) || p_59018_.m_150930_(Items.f_42736_) || p_59018_.m_150930_(Items.f_42739_) || p_59018_.m_150930_(Items.f_42590_)) && this.m_8020_(p_59017_).m_41619_(); ++ return net.minecraftforge.common.brewing.BrewingRecipeRegistry.isValidInput(p_59018_) && this.m_8020_(p_59017_).m_41619_(); + } + } + +@@ -260,5 +_,28 @@ + + protected AbstractContainerMenu m_6555_(int p_58990_, Inventory p_58991_) { + return new BrewingStandMenu(p_58990_, p_58991_, this, this.f_58971_); ++ } ++ ++ net.minecraftforge.common.util.LazyOptional[] handlers = ++ net.minecraftforge.items.wrapper.SidedInvWrapper.create(this, Direction.UP, Direction.DOWN, Direction.NORTH); ++ ++ @Override ++ public net.minecraftforge.common.util.LazyOptional getCapability(net.minecraftforge.common.capabilities.Capability capability, @Nullable Direction facing) { ++ if (!this.f_58859_ && facing != null && capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { ++ if (facing == Direction.UP) ++ return handlers[0].cast(); ++ else if (facing == Direction.DOWN) ++ return handlers[1].cast(); ++ else ++ return handlers[2].cast(); ++ } ++ return super.getCapability(capability, facing); ++ } ++ ++ @Override ++ protected void invalidateCaps() { ++ super.invalidateCaps(); ++ for (int x = 0; x < handlers.length; x++) ++ handlers[x].invalidate(); + } + } diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/ChestBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/ChestBlockEntity.java.patch new file mode 100644 index 0000000000..7c9862d770 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/entity/ChestBlockEntity.java.patch @@ -0,0 +1,46 @@ +--- a/net/minecraft/world/level/block/entity/ChestBlockEntity.java ++++ b/net/minecraft/world/level/block/entity/ChestBlockEntity.java +@@ -162,6 +_,43 @@ + return ChestMenu.m_39237_(p_59082_, p_59083_, this); + } + ++ private net.minecraftforge.common.util.LazyOptional chestHandler; ++ @Override ++ public void m_155250_(BlockState p_155251_) { ++ super.m_155250_(p_155251_); ++ if (this.chestHandler != null) { ++ net.minecraftforge.common.util.LazyOptional oldHandler = this.chestHandler; ++ this.chestHandler = null; ++ oldHandler.invalidate(); ++ } ++ } ++ ++ @Override ++ public net.minecraftforge.common.util.LazyOptional getCapability(net.minecraftforge.common.capabilities.Capability cap, Direction side) { ++ if (!this.f_58859_ && cap == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { ++ if (this.chestHandler == null) ++ this.chestHandler = net.minecraftforge.common.util.LazyOptional.of(this::createHandler); ++ return this.chestHandler.cast(); ++ } ++ return super.getCapability(cap, side); ++ } ++ ++ private net.minecraftforge.items.IItemHandlerModifiable createHandler() { ++ BlockState state = this.m_58900_(); ++ if (!(state.m_60734_() instanceof ChestBlock)) { ++ return new net.minecraftforge.items.wrapper.InvWrapper(this); ++ } ++ Container inv = ChestBlock.m_51511_((ChestBlock) state.m_60734_(), state, m_58904_(), m_58899_(), true); ++ return new net.minecraftforge.items.wrapper.InvWrapper(inv == null ? this : inv); ++ } ++ ++ @Override ++ protected void invalidateCaps() { ++ super.invalidateCaps(); ++ if (chestHandler != null) ++ chestHandler.invalidate(); ++ } ++ + public void m_155350_() { + if (!this.f_58859_) { + this.f_155324_.m_155476_(this.m_58904_(), this.m_58899_(), this.m_58900_()); diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/ConduitBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/ConduitBlockEntity.java.patch new file mode 100644 index 0000000000..7977d23baa --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/entity/ConduitBlockEntity.java.patch @@ -0,0 +1,15 @@ +--- a/net/minecraft/world/level/block/entity/ConduitBlockEntity.java ++++ b/net/minecraft/world/level/block/entity/ConduitBlockEntity.java +@@ -155,10 +_,8 @@ + BlockPos blockpos1 = p_155416_.m_142082_(j1, k1, l1); + BlockState blockstate = p_155415_.m_8055_(blockpos1); + +- for(Block block : f_59184_) { +- if (blockstate.m_60713_(block)) { +- p_155417_.add(blockpos1); +- } ++ if (blockstate.isConduitFrame(p_155415_, blockpos1, p_155416_)) { ++ p_155417_.add(blockpos1); + } + } + } 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 new file mode 100644 index 0000000000..e7a1f89475 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch @@ -0,0 +1,45 @@ +--- a/net/minecraft/world/level/block/entity/HopperBlockEntity.java ++++ b/net/minecraft/world/level/block/entity/HopperBlockEntity.java +@@ -104,7 +_,7 @@ + if (!p_155582_.m_59407_() && p_155581_.m_61143_(HopperBlock.f_54022_)) { + boolean flag = false; + if (!p_155582_.m_7983_()) { +- flag = m_155562_(p_155579_, p_155580_, p_155581_, p_155582_); ++ flag = ejectItems(p_155579_, p_155580_, p_155581_, p_155582_); + } + + if (!p_155582_.m_59404_()) { +@@ -132,7 +_,8 @@ + return true; + } + +- private static boolean m_155562_(Level p_155563_, BlockPos p_155564_, BlockState p_155565_, Container p_155566_) { ++ private static boolean ejectItems(Level p_155563_, BlockPos p_155564_, BlockState p_155565_, HopperBlockEntity p_155566_) { ++ if (net.minecraftforge.items.VanillaInventoryCodeHooks.insertHook(p_155566_)) return true; + Container container = m_155592_(p_155563_, p_155564_, p_155565_); + if (container == null) { + return false; +@@ -177,6 +_,8 @@ + } + + public static boolean m_155552_(Level p_155553_, Hopper p_155554_) { ++ Boolean ret = net.minecraftforge.items.VanillaInventoryCodeHooks.extractHook(p_155553_, p_155554_); ++ if (ret != null) return ret; + Container container = m_155596_(p_155553_, p_155554_); + if (container != null) { + Direction direction = Direction.DOWN; +@@ -400,5 +_,14 @@ + + protected AbstractContainerMenu m_6555_(int p_59312_, Inventory p_59313_) { + return new HopperMenu(p_59312_, p_59313_, this); ++ } ++ ++ @Override ++ protected net.minecraftforge.items.IItemHandler createUnSidedHandler() { ++ return new net.minecraftforge.items.VanillaHopperItemHandler(this); ++ } ++ ++ public long getLastUpdateTime() { ++ return this.f_59303_; + } + } diff --git a/patches/minecraft/net/minecraft/tileentity/ShulkerBoxTileEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java.patch similarity index 52% rename from patches/minecraft/net/minecraft/tileentity/ShulkerBoxTileEntity.java.patch rename to patches/minecraft/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java.patch index 5b8b3d0657..71b58be7d0 100644 --- a/patches/minecraft/net/minecraft/tileentity/ShulkerBoxTileEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java.patch @@ -1,7 +1,7 @@ ---- a/net/minecraft/tileentity/ShulkerBoxTileEntity.java -+++ b/net/minecraft/tileentity/ShulkerBoxTileEntity.java -@@ -284,6 +_,11 @@ - return this.field_190599_i == ShulkerBoxTileEntity.AnimationStatus.CLOSED; +--- a/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java ++++ b/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java +@@ -241,6 +_,11 @@ + return this.f_59647_ == ShulkerBoxBlockEntity.AnimationStatus.CLOSED; } + @Override 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 new file mode 100644 index 0000000000..7fdad8e1f4 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/piston/PistonBaseBlock.java.patch @@ -0,0 +1,37 @@ +--- a/net/minecraft/world/level/block/piston/PistonBaseBlock.java ++++ b/net/minecraft/world/level/block/piston/PistonBaseBlock.java +@@ -168,6 +_,7 @@ + } + + if (p_60195_ == 0) { ++ if (net.minecraftforge.event.ForgeEventFactory.onPistonMovePre(p_60193_, p_60194_, direction, true)) return false; + if (!this.m_60181_(p_60193_, p_60194_, direction, true)) { + return false; + } +@@ -176,6 +_,7 @@ + p_60193_.m_5594_((Player)null, p_60194_, SoundEvents.f_12312_, SoundSource.BLOCKS, 0.5F, p_60193_.f_46441_.nextFloat() * 0.25F + 0.6F); + p_60193_.m_151555_(GameEvent.f_157775_, p_60194_); + } else if (p_60195_ == 1 || p_60195_ == 2) { ++ if (net.minecraftforge.event.ForgeEventFactory.onPistonMovePre(p_60193_, p_60194_, direction, false)) return false; + BlockEntity blockentity1 = p_60193_.m_7702_(p_60194_.m_142300_(direction)); + if (blockentity1 instanceof PistonMovingBlockEntity) { + ((PistonMovingBlockEntity)blockentity1).m_60401_(); +@@ -216,6 +_,7 @@ + p_60193_.m_151555_(GameEvent.f_157774_, p_60194_); + } + ++ net.minecraftforge.event.ForgeEventFactory.onPistonMovePost(p_60193_, p_60194_, direction, (p_60195_ == 0)); + return true; + } + +@@ -352,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_))); ++ } ++ ++ public BlockState rotate(BlockState state, net.minecraft.world.level.LevelAccessor world, BlockPos pos, Rotation direction) { ++ return state.m_61143_(f_60153_) ? state : super.rotate(state, world, pos, direction); + } + + public BlockState m_6943_(BlockState p_60212_, Mirror p_60213_) { diff --git a/patches/minecraft/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java.patch new file mode 100644 index 0000000000..d07ada5c2c --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java ++++ b/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java +@@ -106,7 +_,7 @@ + List list = p_155911_.m_45933_((Entity)null, PistonMath.m_60328_(aabb, direction, d0).m_82367_(aabb)); + if (!list.isEmpty()) { + List list1 = voxelshape.m_83299_(); +- boolean flag = p_155914_.f_60334_.m_60713_(Blocks.f_50374_); ++ boolean flag = p_155914_.f_60334_.isSlimeBlock(); //TODO: is this patch really needed the logic of the original seems sound revisit later + Iterator iterator = list.iterator(); + + while(true) { diff --git a/patches/minecraft/net/minecraft/world/level/block/piston/PistonStructureResolver.java.patch b/patches/minecraft/net/minecraft/world/level/block/piston/PistonStructureResolver.java.patch new file mode 100644 index 0000000000..cbc96d42f9 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/piston/PistonStructureResolver.java.patch @@ -0,0 +1,70 @@ +--- a/net/minecraft/world/level/block/piston/PistonStructureResolver.java ++++ b/net/minecraft/world/level/block/piston/PistonStructureResolver.java +@@ -51,7 +_,7 @@ + } else { + for(int i = 0; i < this.f_60414_.size(); ++i) { + BlockPos blockpos = this.f_60414_.get(i); +- if (m_155937_(this.f_60409_.m_8055_(blockpos)) && !this.m_60431_(blockpos)) { ++ if (this.f_60409_.m_8055_(blockpos).isStickyBlock() && !this.m_60431_(blockpos)) { + return false; + } + } +@@ -60,23 +_,9 @@ + } + } + +- private static boolean m_155937_(BlockState p_155938_) { +- return p_155938_.m_60713_(Blocks.f_50374_) || p_155938_.m_60713_(Blocks.f_50719_); +- } +- +- private static boolean m_155939_(BlockState p_155940_, BlockState p_155941_) { +- if (p_155940_.m_60713_(Blocks.f_50719_) && p_155941_.m_60713_(Blocks.f_50374_)) { +- return false; +- } else if (p_155940_.m_60713_(Blocks.f_50374_) && p_155941_.m_60713_(Blocks.f_50719_)) { +- return false; +- } else { +- return m_155937_(p_155940_) || m_155937_(p_155941_); +- } +- } +- + private boolean m_60433_(BlockPos p_60434_, Direction p_60435_) { + BlockState blockstate = this.f_60409_.m_8055_(p_60434_); +- if (blockstate.m_60795_()) { ++ if (f_60409_.m_46859_(p_60434_)) { + return true; + } else if (!PistonBaseBlock.m_60204_(blockstate, this.f_60409_, p_60434_, this.f_60413_, false, p_60435_)) { + return true; +@@ -89,11 +_,12 @@ + if (i + this.f_60414_.size() > 12) { + return false; + } else { +- while(m_155937_(blockstate)) { ++ BlockState oldState; ++ while(blockstate.isStickyBlock()) { + BlockPos blockpos = p_60434_.m_5484_(this.f_60413_.m_122424_(), i); +- BlockState blockstate1 = blockstate; ++ oldState = blockstate; + blockstate = this.f_60409_.m_8055_(blockpos); +- if (blockstate.m_60795_() || !m_155939_(blockstate1, blockstate) || !PistonBaseBlock.m_60204_(blockstate, this.f_60409_, blockpos, this.f_60413_, false, this.f_60413_.m_122424_()) || blockpos.equals(this.f_60410_)) { ++ if (blockstate.m_60795_() || !oldState.canStickTo(blockstate) || !PistonBaseBlock.m_60204_(blockstate, this.f_60409_, blockpos, this.f_60413_, false, this.f_60413_.m_122424_()) || blockpos.equals(this.f_60410_)) { + break; + } + +@@ -120,7 +_,7 @@ + + for(int k = 0; k <= j + l; ++k) { + BlockPos blockpos2 = this.f_60414_.get(k); +- if (m_155937_(this.f_60409_.m_8055_(blockpos2)) && !this.m_60431_(blockpos2)) { ++ if (this.f_60409_.m_8055_(blockpos2).isStickyBlock() && !this.m_60431_(blockpos2)) { + return false; + } + } +@@ -174,7 +_,7 @@ + if (direction.m_122434_() != this.f_60413_.m_122434_()) { + BlockPos blockpos = p_60432_.m_142300_(direction); + BlockState blockstate1 = this.f_60409_.m_8055_(blockpos); +- if (m_155939_(blockstate1, blockstate) && !this.m_60433_(blockpos, direction)) { ++ if (blockstate1.canStickTo(blockstate) && !this.m_60433_(blockpos, direction)) { + return false; + } + } 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 new file mode 100644 index 0000000000..1f27f8d8fd --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/state/BlockBehaviour.java.patch @@ -0,0 +1,163 @@ +--- a/net/minecraft/world/level/block/state/BlockBehaviour.java ++++ b/net/minecraft/world/level/block/state/BlockBehaviour.java +@@ -64,7 +_,8 @@ + import net.minecraft.world.phys.shapes.Shapes; + import net.minecraft.world.phys.shapes.VoxelShape; + +-public abstract class BlockBehaviour { ++//TODO, Delegates are weird here now, because Block extends this. ++public abstract class BlockBehaviour extends net.minecraftforge.registries.ForgeRegistryEntry { + protected static final Direction[] f_60441_ = new Direction[]{Direction.WEST, Direction.EAST, Direction.NORTH, Direction.SOUTH, Direction.DOWN, Direction.UP}; + protected final Material f_60442_; + protected final boolean f_60443_; +@@ -91,6 +_,8 @@ + this.f_60449_ = p_60452_.f_60893_; + this.f_60438_ = p_60452_.f_60903_; + this.f_60439_ = p_60452_; ++ final ResourceLocation lootTableCache = p_60452_.f_60894_; ++ this.lootTableSupplier = lootTableCache != null ? () -> lootTableCache : p_60452_.lootTableSupplier != null ? p_60452_.lootTableSupplier : () -> new ResourceLocation(this.getRegistryName().m_135827_(), "blocks/" + this.getRegistryName().m_135815_()); + } + + @Deprecated +@@ -132,7 +_,7 @@ + + @Deprecated + public void m_6810_(BlockState p_60515_, Level p_60516_, BlockPos p_60517_, BlockState p_60518_, boolean p_60519_) { +- if (p_60515_.m_155947_() && !p_60515_.m_60713_(p_60518_.m_60734_())) { ++ if (p_60515_.m_155947_() && (!p_60515_.m_60713_(p_60518_.m_60734_()) || !p_60518_.m_155947_())) { + p_60516_.m_46747_(p_60517_); + } + +@@ -202,7 +_,7 @@ + + @Deprecated + public boolean m_6864_(BlockState p_60470_, BlockPlaceContext p_60471_) { +- return this.f_60442_.m_76336_() && (p_60471_.m_43722_().m_41619_() || !p_60471_.m_43722_().m_150930_(this.m_5456_())); ++ return p_60470_.m_60767_().m_76336_() && (p_60471_.m_43722_().m_41619_() || p_60471_.m_43722_().m_41720_() != this.m_5456_()); + } + + @Deprecated +@@ -308,8 +_,8 @@ + if (f == -1.0F) { + return 0.0F; + } else { +- int i = p_60467_.m_36298_(p_60466_) ? 30 : 100; +- return p_60467_.m_36281_(p_60466_) / f / (float)i; ++ int i = net.minecraftforge.common.ForgeHooks.canHarvestBlock(p_60466_, p_60467_, p_60468_, p_60469_) ? 30 : 100; ++ return p_60467_.getDigSpeed(p_60466_, p_60469_) / f / (float)i; + } + } + +@@ -337,8 +_,7 @@ + + public final ResourceLocation m_60589_() { + if (this.f_60440_ == null) { +- ResourceLocation resourcelocation = Registry.f_122824_.m_7981_(this.m_7374_()); +- this.f_60440_ = new ResourceLocation(resourcelocation.m_135827_(), "blocks/" + resourcelocation.m_135815_()); ++ this.f_60440_ = this.lootTableSupplier.get(); + } + + return this.f_60440_; +@@ -360,6 +_,14 @@ + return this.f_60439_.f_60888_; + } + ++ protected boolean isAir(BlockState state) { ++ return ((BlockStateBase)state).f_60596_; ++ } ++ ++ /* ======================================== FORGE START ===================================== */ ++ private final java.util.function.Supplier lootTableSupplier; ++ /* ========================================= FORGE END ====================================== */ ++ + public abstract static class BlockStateBase extends StateHolder { + private final int f_60594_; + private final boolean f_60595_; +@@ -438,18 +_,22 @@ + return this.f_60595_; + } + ++ /** @deprecated use {@link BlockState#getLightValue(IBlockReader, BlockPos)} */ ++ @Deprecated + public int m_60791_() { + return this.f_60594_; + } + + public boolean m_60795_() { +- return this.f_60596_; ++ return this.m_60734_().isAir((BlockState)this); + } + + public MaterialColor m_60780_(BlockGetter p_60781_, BlockPos p_60782_) { + return this.f_60598_; + } + ++ /** @deprecated use {@link BlockState#rotate(IWorld, BlockPos, Rotation)} */ ++ @Deprecated + public BlockState m_60717_(Rotation p_60718_) { + return this.m_60734_().m_6843_(this.m_7160_(), p_60718_); + } +@@ -821,8 +_,11 @@ + ResourceLocation f_60894_; + boolean f_60895_ = true; + boolean f_60896_; ++ private int harvestLevel = -1; ++ private net.minecraftforge.common.ToolType harvestTool; ++ private java.util.function.Supplier lootTableSupplier; + BlockBehaviour.StateArgumentPredicate> f_60897_ = (p_60935_, p_60936_, p_60937_, p_60938_) -> { +- return p_60935_.m_60783_(p_60936_, p_60937_, Direction.UP) && p_60935_.m_60791_() < 14; ++ return p_60935_.m_60783_(p_60936_, p_60937_, Direction.UP) && p_60935_.getLightEmission(p_60936_, p_60937_) < 14; + }; + BlockBehaviour.StatePredicate f_60898_ = (p_60985_, p_60986_, p_60987_) -> { + return p_60985_.m_60767_().m_76337_() && p_60985_.m_60838_(p_60986_, p_60987_); +@@ -882,6 +_,8 @@ + blockbehaviour$properties.f_60895_ = p_60927_.f_60439_.f_60895_; + blockbehaviour$properties.f_60896_ = p_60927_.f_60439_.f_60896_; + blockbehaviour$properties.f_60889_ = p_60927_.f_60439_.f_60889_; ++ blockbehaviour$properties.harvestLevel = p_60927_.f_60439_.harvestLevel; ++ blockbehaviour$properties.harvestTool = p_60927_.f_60439_.harvestTool; + return blockbehaviour$properties; + } + +@@ -896,6 +_,24 @@ + return this; + } + ++ public BlockBehaviour.Properties harvestLevel(int harvestLevel) { ++ this.harvestLevel = harvestLevel; ++ return this; ++ } ++ ++ public BlockBehaviour.Properties harvestTool(net.minecraftforge.common.ToolType harvestTool) { ++ this.harvestTool = harvestTool; ++ return this; ++ } ++ ++ public int getHarvestLevel() { ++ return this.harvestLevel; ++ } ++ ++ public net.minecraftforge.common.ToolType getHarvestTool() { ++ return this.harvestTool; ++ } ++ + public BlockBehaviour.Properties m_60911_(float p_60912_) { + this.f_60891_ = p_60912_; + return this; +@@ -949,9 +_,15 @@ + return this; + } + ++ @Deprecated // FORGE: Use the variant that takes a Supplier below + public BlockBehaviour.Properties m_60916_(Block p_60917_) { +- this.f_60894_ = p_60917_.m_60589_(); ++ this.lootTableSupplier = () -> p_60917_.delegate.get().m_60589_(); + return this; ++ } ++ ++ public BlockBehaviour.Properties lootFrom(java.util.function.Supplier blockIn) { ++ this.lootTableSupplier = () -> blockIn.get().m_60589_(); ++ return this; + } + + public BlockBehaviour.Properties m_60996_() { diff --git a/patches/minecraft/net/minecraft/world/level/block/state/BlockState.java.patch b/patches/minecraft/net/minecraft/world/level/block/state/BlockState.java.patch new file mode 100644 index 0000000000..ef1d685ab6 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/state/BlockState.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/block/state/BlockState.java ++++ b/net/minecraft/world/level/block/state/BlockState.java +@@ -7,7 +_,7 @@ + import net.minecraft.world.level.block.Block; + import net.minecraft.world.level.block.state.properties.Property; + +-public class BlockState extends BlockBehaviour.BlockStateBase { ++public class BlockState extends BlockBehaviour.BlockStateBase implements net.minecraftforge.common.extensions.IForgeBlockState { + public static final Codec f_61039_ = m_61127_(Registry.f_122824_, Block::m_49966_).stable(); + + public BlockState(Block p_61042_, ImmutableMap, Comparable> p_61043_, MapCodec p_61044_) { diff --git a/patches/minecraft/net/minecraft/block/WoodType.java.patch b/patches/minecraft/net/minecraft/world/level/block/state/properties/WoodType.java.patch similarity index 58% rename from patches/minecraft/net/minecraft/block/WoodType.java.patch rename to patches/minecraft/net/minecraft/world/level/block/state/properties/WoodType.java.patch index 9bb3324586..19a5262a7d 100644 --- a/patches/minecraft/net/minecraft/block/WoodType.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/state/properties/WoodType.java.patch @@ -1,8 +1,8 @@ ---- a/net/minecraft/block/WoodType.java -+++ b/net/minecraft/block/WoodType.java +--- a/net/minecraft/world/level/block/state/properties/WoodType.java ++++ b/net/minecraft/world/level/block/state/properties/WoodType.java @@ -32,4 +_,11 @@ - public String func_227048_b_() { - return this.field_227045_h_; + public String m_61846_() { + return this.f_61839_; } + + /** diff --git a/patches/minecraft/net/minecraft/world/level/chunk/ChunkAccess.java.patch b/patches/minecraft/net/minecraft/world/level/chunk/ChunkAccess.java.patch new file mode 100644 index 0000000000..fe6c8fd362 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/chunk/ChunkAccess.java.patch @@ -0,0 +1,12 @@ +--- a/net/minecraft/world/level/chunk/ChunkAccess.java ++++ b/net/minecraft/world/level/chunk/ChunkAccess.java +@@ -158,4 +_,9 @@ + boolean m_6332_(); + + void m_8094_(boolean p_62100_); ++ ++ @Nullable ++ default net.minecraft.world.level.LevelAccessor getWorldForge() { ++ return null; ++ } + } diff --git a/patches/minecraft/net/minecraft/world/level/chunk/ChunkStatus.java.patch b/patches/minecraft/net/minecraft/world/level/chunk/ChunkStatus.java.patch new file mode 100644 index 0000000000..d8fa802a48 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/chunk/ChunkStatus.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/chunk/ChunkStatus.java ++++ b/net/minecraft/world/level/chunk/ChunkStatus.java +@@ -23,7 +_,7 @@ + import net.minecraft.world.level.levelgen.Heightmap; + import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager; + +-public class ChunkStatus { ++public class ChunkStatus extends net.minecraftforge.registries.ForgeRegistryEntry { + private static final EnumSet f_62327_ = EnumSet.of(Heightmap.Types.OCEAN_FLOOR_WG, Heightmap.Types.WORLD_SURFACE_WG); + private static final EnumSet f_62328_ = EnumSet.of(Heightmap.Types.OCEAN_FLOOR, Heightmap.Types.WORLD_SURFACE, Heightmap.Types.MOTION_BLOCKING, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES); + private static final ChunkStatus.LoadingTask f_62329_ = (p_62461_, p_62462_, p_62463_, p_62464_, p_62465_, p_62466_) -> { diff --git a/patches/minecraft/net/minecraft/world/level/chunk/LevelChunk.java.patch b/patches/minecraft/net/minecraft/world/level/chunk/LevelChunk.java.patch new file mode 100644 index 0000000000..09f8920546 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/chunk/LevelChunk.java.patch @@ -0,0 +1,143 @@ +--- a/net/minecraft/world/level/chunk/LevelChunk.java ++++ b/net/minecraft/world/level/chunk/LevelChunk.java +@@ -57,7 +_,7 @@ + import org.apache.logging.log4j.LogManager; + import org.apache.logging.log4j.Logger; + +-public class LevelChunk implements ChunkAccess { ++public class LevelChunk extends net.minecraftforge.common.capabilities.CapabilityProvider implements ChunkAccess, net.minecraftforge.common.extensions.IForgeLevelChunk { + static final Logger f_62771_ = LogManager.getLogger(); + private static final TickingBlockEntity f_156361_ = new TickingBlockEntity() { + public void m_142224_() { +@@ -106,6 +_,7 @@ + } + + public LevelChunk(Level p_62800_, ChunkPos p_62801_, ChunkBiomeContainer p_62802_, UpgradeData p_62803_, TickList p_62804_, TickList p_62805_, long p_62806_, @Nullable LevelChunkSection[] p_62807_, @Nullable Consumer p_62808_) { ++ super(LevelChunk.class); + this.f_62776_ = p_62800_; + this.f_62792_ = p_62801_; + this.f_62778_ = p_62803_; +@@ -132,6 +_,7 @@ + } + + this.f_62783_ = new ShortList[p_62800_.m_151559_()]; ++ this.gatherCapabilities(); + } + + public LevelChunk(ServerLevel p_156365_, ProtoChunk p_156366_, @Nullable Consumer p_156367_) { +@@ -279,14 +_,14 @@ + boolean flag2 = blockstate.m_155947_(); + if (!this.f_62776_.f_46443_) { + blockstate.m_60753_(this.f_62776_, p_62865_, p_62866_, p_62867_); +- } else if (!blockstate.m_60713_(block) && flag2) { ++ } else if ((!blockstate.m_60713_(block) || !p_62866_.m_155947_()) && flag2) { + this.m_8114_(p_62865_); + } + + if (!levelchunksection.m_62982_(k, l, i1).m_60713_(block)) { + return null; + } else { +- if (!this.f_62776_.f_46443_) { ++ if (!this.f_62776_.f_46443_ && !this.f_62776_.captureBlockSnapshots) { + p_62866_.m_60696_(this.f_62776_, p_62865_, blockstate, p_62867_); + } + +@@ -349,6 +_,10 @@ + @Nullable + public BlockEntity m_5685_(BlockPos p_62868_, LevelChunk.EntityCreationType p_62869_) { + BlockEntity blockentity = this.f_62779_.get(p_62868_); ++ if (blockentity != null && blockentity.m_58901_()) { ++ f_62779_.remove(p_62868_); ++ blockentity = null; ++ } + if (blockentity == null) { + CompoundTag compoundtag = this.f_62774_.remove(p_62868_); + if (compoundtag != null) { +@@ -366,9 +_,6 @@ + this.m_142170_(blockentity); + } + } +- } else if (blockentity.m_58901_()) { +- this.f_62779_.remove(p_62868_); +- return null; + } + + return blockentity; +@@ -418,9 +_,14 @@ + public CompoundTag m_8051_(BlockPos p_62932_) { + BlockEntity blockentity = this.m_7702_(p_62932_); + if (blockentity != null && !blockentity.m_58901_()) { ++ try { + CompoundTag compoundtag1 = blockentity.m_6945_(new CompoundTag()); + compoundtag1.m_128379_("keepPacked", false); + return compoundtag1; ++ } catch (Exception e) { ++ LogManager.getLogger().error("A BlockEntity type {} has thrown an exception trying to write state. It will not persist, Report this to the mod author", blockentity.getClass().getName(), e); ++ return null; ++ } + } else { + CompoundTag compoundtag = this.f_62774_.get(p_62932_); + if (compoundtag != null) { +@@ -567,7 +_,7 @@ + + public Stream m_6267_() { + return StreamSupport.stream(BlockPos.m_121976_(this.f_62792_.m_45604_(), this.m_141937_(), this.f_62792_.m_45605_(), this.f_62792_.m_45608_(), this.m_151558_() - 1, this.f_62792_.m_45609_()).spliterator(), false).filter((p_156419_) -> { +- return this.m_8055_(p_156419_).m_60791_() != 0; ++ return this.m_8055_(p_156419_).getLightEmission(m_62953_(), p_156419_) != 0; + }); + } + +@@ -826,6 +_,7 @@ + if (LevelChunk.this.m_156410_(blockpos)) { + try { + ProfilerFiller profilerfiller = LevelChunk.this.f_62776_.m_46473_(); ++ net.minecraftforge.server.timings.TimeTracker.BLOCK_ENTITY_UPDATE.trackStart(f_156428_); + profilerfiller.m_6521_(this::m_142280_); + BlockState blockstate = LevelChunk.this.m_8055_(blockpos); + if (this.f_156428_.m_58903_().m_155262_(blockstate)) { +@@ -843,6 +_,12 @@ + CrashReport crashreport = CrashReport.m_127521_(throwable, "Ticking block entity"); + CrashReportCategory crashreportcategory = crashreport.m_127514_("Block entity being ticked"); + this.f_156428_.m_58886_(crashreportcategory); ++ ++ if (net.minecraftforge.common.ForgeConfig.SERVER.removeErroringBlockEntities.get()) { ++ LogManager.getLogger().fatal("{}", crashreport.m_127526_()); ++ f_156428_.m_7651_(); ++ LevelChunk.this.m_8114_(f_156428_.m_58899_()); ++ } else + throw new ReportedException(crashreport); + } + } +@@ -871,6 +_,32 @@ + IMMEDIATE, + QUEUED, + CHECK; ++ } ++ ++ /** ++ * FOR INTERNAL USE ONLY ++ *

++ * Only public for use in {@link net.minecraft.world.level.chunk.storage.ChunkSerializer}. ++ */ ++ @java.lang.Deprecated ++ @javax.annotation.Nullable ++ public final CompoundTag writeCapsToNBT() { ++ return this.serializeCaps(); ++ } ++ ++ /** ++ * FOR INTERNAL USE ONLY ++ *

++ * Only public for use in {@link net.minecraft.world.level.chunk.storage.ChunkSerializer}. ++ */ ++ @java.lang.Deprecated ++ public final void readCapsFromNBT(CompoundTag tag) { ++ this.deserializeCaps(tag); ++ } ++ ++ @Override ++ public Level getWorldForge() { ++ return m_62953_(); + } + + class RebindableTickingBlockEntityWrapper implements TickingBlockEntity { diff --git a/patches/minecraft/net/minecraft/world/level/chunk/PalettedContainer.java.patch b/patches/minecraft/net/minecraft/world/level/chunk/PalettedContainer.java.patch new file mode 100644 index 0000000000..68547df889 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/chunk/PalettedContainer.java.patch @@ -0,0 +1,40 @@ +--- a/net/minecraft/world/level/chunk/PalettedContainer.java ++++ b/net/minecraft/world/level/chunk/PalettedContainer.java +@@ -62,6 +_,9 @@ + } + + private void m_63121_(int p_63122_) { ++ setBits(p_63122_, false); ++ } ++ private void setBits(int p_63122_, boolean forceBits) { + if (p_63122_ != this.f_63076_) { + this.f_63076_ = p_63122_; + if (this.f_63076_ <= 4) { +@@ -72,6 +_,8 @@ + } else { + this.f_63075_ = this.f_63069_; + this.f_63076_ = Mth.m_14163_(this.f_63071_.m_122659_()); ++ if (forceBits) ++ this.f_63076_ = p_63122_; + } + + this.f_63075_.m_6796_(this.f_63074_); +@@ -147,7 +_,7 @@ + this.m_63084_(); + int i = p_63119_.readByte(); + if (this.f_63076_ != i) { +- this.m_63121_(i); ++ this.setBits(i, true); //Forge, Force bit density to fix network issues, resize below if needed. + } + + this.f_63075_.m_5680_(p_63119_); +@@ -156,6 +_,9 @@ + this.m_63120_(); + } + ++ int regSize = Mth.m_14163_(this.f_63071_.m_122659_()); ++ if (this.f_63075_ == f_63069_ && this.f_63076_ != regSize) // Resize bits to fit registry. ++ this.m_7248_(regSize, f_63074_); + } + + public void m_63135_(FriendlyByteBuf p_63136_) { diff --git a/patches/minecraft/net/minecraft/world/level/chunk/ProtoChunk.java.patch b/patches/minecraft/net/minecraft/world/level/chunk/ProtoChunk.java.patch new file mode 100644 index 0000000000..0e22b425b7 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/chunk/ProtoChunk.java.patch @@ -0,0 +1,18 @@ +--- a/net/minecraft/world/level/chunk/ProtoChunk.java ++++ b/net/minecraft/world/level/chunk/ProtoChunk.java +@@ -142,13 +_,13 @@ + if (this.f_63156_[l] == LevelChunk.f_62770_ && p_63218_.m_60713_(Blocks.f_50016_)) { + return p_63218_; + } else { +- if (p_63218_.m_60791_() > 0) { ++ if (p_63218_.getLightEmission(this, p_63217_) > 0) { + this.f_63158_.add(new BlockPos((i & 15) + this.m_7697_().m_45604_(), j, (k & 15) + this.m_7697_().m_45605_())); + } + + LevelChunkSection levelchunksection = this.m_156115_(l); + BlockState blockstate = levelchunksection.m_62986_(i & 15, j & 15, k & 15, p_63218_); +- if (this.f_63153_.m_62427_(ChunkStatus.f_62322_) && p_63218_ != blockstate && (p_63218_.m_60739_(this, p_63217_) != blockstate.m_60739_(this, p_63217_) || p_63218_.m_60791_() != blockstate.m_60791_() || p_63218_.m_60787_() || blockstate.m_60787_())) { ++ if (this.f_63153_.m_62427_(ChunkStatus.f_62322_) && p_63218_ != blockstate && (p_63218_.m_60739_(this, p_63217_) != blockstate.m_60739_(this, p_63217_) || p_63218_.getLightEmission(this, p_63217_) != blockstate.getLightEmission(this, p_63217_) || p_63218_.m_60787_() || blockstate.m_60787_())) { + this.f_63151_.m_142202_(p_63217_); + } + diff --git a/patches/minecraft/net/minecraft/world/level/chunk/storage/ChunkSerializer.java.patch b/patches/minecraft/net/minecraft/world/level/chunk/storage/ChunkSerializer.java.patch new file mode 100644 index 0000000000..5a48c19cfb --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/chunk/storage/ChunkSerializer.java.patch @@ -0,0 +1,60 @@ +--- a/net/minecraft/world/level/chunk/storage/ChunkSerializer.java ++++ b/net/minecraft/world/level/chunk/storage/ChunkSerializer.java +@@ -131,6 +_,7 @@ + chunkaccess = new LevelChunk(p_63458_.m_6018_(), p_63461_, chunkbiomecontainer, upgradedata, ticklist, ticklist1, k1, alevelchunksection, (p_156533_) -> { + m_156522_(p_63458_, compoundtag, p_156533_); + }); ++ if (compoundtag.m_128441_("ForgeCaps")) ((LevelChunk)chunkaccess).readCapsFromNBT(compoundtag.m_128469_("ForgeCaps")); + } else { + ProtoChunk protochunk = new ProtoChunk(p_63461_, upgradedata, alevelchunksection, prototicklist, prototicklist1, p_63458_); + protochunk.m_7329_(chunkbiomecontainer); +@@ -143,7 +_,7 @@ + + if (!flag && protochunk.m_6415_().m_62427_(ChunkStatus.f_62323_)) { + for(BlockPos blockpos : BlockPos.m_121976_(p_63461_.m_45604_(), p_63458_.m_141937_(), p_63461_.m_45605_(), p_63461_.m_45608_(), p_63458_.m_151558_() - 1, p_63461_.m_45609_())) { +- if (chunkaccess.m_8055_(blockpos).m_60791_() != 0) { ++ if (chunkaccess.m_8055_(blockpos).getLightEmission(chunkaccess, blockpos) != 0) { + protochunk.m_63277_(blockpos); + } + } +@@ -166,7 +_,7 @@ + Heightmap.m_64256_(chunkaccess, enumset); + CompoundTag compoundtag4 = compoundtag.m_128469_("Structures"); + chunkaccess.m_8040_(m_156518_(p_63458_, compoundtag4, p_63458_.m_7328_())); +- chunkaccess.m_7946_(m_63471_(p_63461_, compoundtag4)); ++ net.minecraftforge.common.ForgeHooks.fixNullStructureReferences(chunkaccess, m_63471_(p_63461_, compoundtag4)); + if (compoundtag.m_128471_("shouldSave")) { + chunkaccess.m_8092_(true); + } +@@ -182,6 +_,7 @@ + } + + if (chunkstatus$chunktype == ChunkStatus.ChunkType.LEVELCHUNK) { ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.ChunkDataEvent.Load(chunkaccess, p_63462_, chunkstatus$chunktype)); + return new ImposterProtoChunk((LevelChunk)chunkaccess); + } else { + ProtoChunk protochunk1 = (ProtoChunk)chunkaccess; +@@ -215,6 +_,7 @@ + protochunk1.m_63189_(generationstep$carving, BitSet.valueOf(compoundtag5.m_128463_(s1))); + } + ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.ChunkDataEvent.Load(chunkaccess, p_63462_, chunkstatus$chunktype)); + return protochunk1; + } + } +@@ -302,6 +_,15 @@ + } + + compoundtag1.m_128365_("CarvingMasks", compoundtag4); ++ } ++ else { ++ LevelChunk levelChunk = (LevelChunk) p_63456_; ++ try { ++ final CompoundTag capTag = levelChunk.writeCapsToNBT(); ++ if (capTag != null) compoundtag1.m_128365_("ForgeCaps", capTag); ++ } catch (Exception exception) { ++ LogManager.getLogger().error("A capability provider has thrown an exception trying to write state. It will not persist. Report this to the mod author", exception); ++ } + } + + TickList ticklist = p_63456_.m_5782_(); diff --git a/patches/minecraft/net/minecraft/world/level/chunk/storage/EntityStorage.java.patch b/patches/minecraft/net/minecraft/world/level/chunk/storage/EntityStorage.java.patch new file mode 100644 index 0000000000..8487ef8b6e --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/chunk/storage/EntityStorage.java.patch @@ -0,0 +1,15 @@ +--- a/net/minecraft/world/level/chunk/storage/EntityStorage.java ++++ b/net/minecraft/world/level/chunk/storage/EntityStorage.java +@@ -90,8 +_,12 @@ + ListTag listtag = new ListTag(); + p_156559_.m_156792_().forEach((p_156567_) -> { + CompoundTag compoundtag1 = new CompoundTag(); ++ try { + if (p_156567_.m_20223_(compoundtag1)) { + listtag.add(compoundtag1); ++ } ++ } catch (Exception e) { ++ LogManager.getLogger().error("An Entity type {} has thrown an exception trying to write state. It will not persist. Report this to the mod author", p_156567_.m_6095_(), e); + } + + }); 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 new file mode 100644 index 0000000000..aee3c0400a --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/dimension/end/EndDragonFight.java.patch @@ -0,0 +1,41 @@ +--- a/net/minecraft/world/level/dimension/end/EndDragonFight.java ++++ b/net/minecraft/world/level/dimension/end/EndDragonFight.java +@@ -96,6 +_,7 @@ + + this.f_64068_ = p_64080_.m_128471_("DragonKilled"); + this.f_64069_ = p_64080_.m_128471_("PreviouslyKilled"); ++ this.f_64071_ = !p_64080_.m_128471_("LegacyScanPerformed"); // Forge: fix MC-105080 + if (p_64080_.m_128471_("IsRespawning")) { + this.f_64073_ = DragonRespawnAnimation.START; + } +@@ -127,13 +_,14 @@ + compoundtag.m_128379_("NeedsStateScanning", this.f_64071_); + if (this.f_64070_ != null) { + compoundtag.m_128362_("Dragon", this.f_64070_); +- } + + compoundtag.m_128379_("DragonKilled", this.f_64068_); + compoundtag.m_128379_("PreviouslyKilled", this.f_64069_); ++ compoundtag.m_128379_("LegacyScanPerformed", !this.f_64071_); // Forge: fix MC-105080 + if (this.f_64072_ != null) { + compoundtag.m_128365_("ExitPortalLocation", NbtUtils.m_129224_(this.f_64072_)); + } ++ } + + ListTag listtag = new ListTag(); + +@@ -503,6 +_,13 @@ + endcrystal.m_31052_((BlockPos)null); + } + } +- ++ } ++ ++ public void addPlayer(ServerPlayer player) { ++ this.f_64060_.m_6543_(player); ++ } ++ ++ public void removePlayer(ServerPlayer player) { ++ this.f_64060_.m_6539_(player); + } + } diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/DebugLevelSource.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/DebugLevelSource.java.patch new file mode 100644 index 0000000000..9cf70ef48a --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/levelgen/DebugLevelSource.java.patch @@ -0,0 +1,13 @@ +--- a/net/minecraft/world/level/levelgen/DebugLevelSource.java ++++ b/net/minecraft/world/level/levelgen/DebugLevelSource.java +@@ -107,4 +_,10 @@ + + return blockstate; + } ++ ++ public static void initValidStates() { ++ f_64114_ = StreamSupport.stream(Registry.f_122824_.spliterator(), false).flatMap(block -> block.m_49965_().m_61056_().stream()).collect(Collectors.toList()); ++ f_64115_ = Mth.m_14167_(Mth.m_14116_(f_64114_.size())); ++ f_64116_ = Mth.m_14167_((float) (f_64114_.size() / f_64115_)); ++ } + } diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java.patch new file mode 100644 index 0000000000..ba2a5518bb --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java ++++ b/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java +@@ -464,6 +_,9 @@ + } + + public WeightedRandomList m_142184_(Biome p_158433_, StructureFeatureManager p_158434_, MobCategory p_158435_, BlockPos p_158436_) { ++ WeightedRandomList spawns = net.minecraftforge.common.world.StructureSpawnManager.getStructureSpawns(p_158434_, p_158435_, p_158436_); ++ if (spawns != null) return spawns; ++ if (false) {//Forge: We handle these hardcoded cases above in StructureSpawnManager#getStructureSpawns, but allow for insideOnly to be changed and allow for creatures to be spawned in ones other than just the witch hut + if (p_158434_.m_47285_(p_158436_, true, StructureFeature.f_67021_).m_73603_()) { + if (p_158435_ == MobCategory.MONSTER) { + return StructureFeature.f_67021_.m_142494_(); +@@ -486,6 +_,7 @@ + if (p_158434_.m_47285_(p_158436_, true, StructureFeature.f_67025_).m_73603_()) { + return StructureFeature.f_67025_.m_142494_(); + } ++ } + } + + return p_158435_ == MobCategory.UNDERGROUND_WATER_CREATURE && p_158434_.m_47285_(p_158436_, false, StructureFeature.f_67023_).m_73603_() ? StructureFeature.f_67023_.m_160477_() : super.m_142184_(p_158433_, p_158434_, p_158435_, p_158436_); diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch new file mode 100644 index 0000000000..83500d2f8a --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/world/level/levelgen/PatrolSpawner.java ++++ b/net/minecraft/world/level/levelgen/PatrolSpawner.java +@@ -103,6 +_,7 @@ + } + + patrollingmonster.m_6034_((double)p_64566_.m_123341_(), (double)p_64566_.m_123342_(), (double)p_64566_.m_123343_()); ++ if(net.minecraftforge.common.ForgeHooks.canEntitySpawn(patrollingmonster, p_64565_, p_64566_.m_123341_(), p_64566_.m_123342_(), p_64566_.m_123343_(), null, MobSpawnType.PATROL) == -1) return false; + patrollingmonster.m_6518_(p_64565_, p_64565_.m_6436_(p_64566_), MobSpawnType.PATROL, (SpawnGroupData)null, (CompoundTag)null); + p_64565_.m_47205_(patrollingmonster); + return true; diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/PhantomSpawner.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/PhantomSpawner.java.patch new file mode 100644 index 0000000000..4d674c1c99 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/levelgen/PhantomSpawner.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/world/level/levelgen/PhantomSpawner.java ++++ b/net/minecraft/world/level/levelgen/PhantomSpawner.java +@@ -60,6 +_,7 @@ + for(int i1 = 0; i1 < l; ++i1) { + Phantom phantom = EntityType.f_20509_.m_20615_(p_64576_); + phantom.m_20035_(blockpos1, 0.0F, 0.0F); ++ if(net.minecraftforge.common.ForgeHooks.canEntitySpawn(phantom, p_64576_, blockpos1.m_123341_(), blockpos1.m_123342_(), blockpos1.m_123343_(), null, MobSpawnType.NATURAL) == -1) return 0; + spawngroupdata = phantom.m_6518_(p_64576_, difficultyinstance, MobSpawnType.NATURAL, spawngroupdata, (CompoundTag)null); + p_64576_.m_47205_(phantom); + } diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/WorldGenSettings.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/WorldGenSettings.java.patch new file mode 100644 index 0000000000..a6a3cef8a9 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/levelgen/WorldGenSettings.java.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/world/level/levelgen/WorldGenSettings.java ++++ b/net/minecraft/world/level/levelgen/WorldGenSettings.java +@@ -183,7 +_,7 @@ + String s3 = (String)p_64649_.get("level-type"); + String s4 = Optional.ofNullable(s3).map((p_64651_) -> { + return p_64651_.toLowerCase(Locale.ROOT); +- }).orElse("default"); ++ }).orElseGet(net.minecraftforge.common.ForgeHooks::getDefaultWorldType); + p_64649_.put("level-type", s4); + long i = (new Random()).nextLong(); + if (!s1.isEmpty()) { +@@ -201,6 +_,8 @@ + Registry registry = p_64648_.m_175515_(Registry.f_122885_); + Registry registry1 = p_64648_.m_175515_(Registry.f_122878_); + MappedRegistry mappedregistry = DimensionType.m_63921_(registry2, registry, registry1, i); ++ net.minecraftforge.common.world.ForgeWorldType type = net.minecraftforge.registries.ForgeRegistries.WORLD_TYPES.getValue(new net.minecraft.resources.ResourceLocation(s4)); ++ if (type != null) return type.createSettings(p_64648_, i, flag, false, s); + switch(s4) { + case "flat": + JsonObject jsonobject = !s.isEmpty() ? GsonHelper.m_13864_(s) : new JsonObject(); diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/carver/WorldCarver.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/carver/WorldCarver.java.patch new file mode 100644 index 0000000000..7e8b130d74 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/levelgen/carver/WorldCarver.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/levelgen/carver/WorldCarver.java ++++ b/net/minecraft/world/level/levelgen/carver/WorldCarver.java +@@ -27,7 +_,7 @@ + import net.minecraft.world.level.material.Fluids; + import org.apache.commons.lang3.mutable.MutableBoolean; + +-public abstract class WorldCarver { ++public abstract class WorldCarver extends net.minecraftforge.registries.ForgeRegistryEntry> { + public static final WorldCarver f_64974_ = m_65065_("cave", new CaveWorldCarver(CaveCarverConfiguration.f_159154_)); + public static final WorldCarver f_64975_ = m_65065_("nether_cave", new NetherWorldCarver(CaveCarverConfiguration.f_159154_)); + public static final WorldCarver f_64976_ = m_65065_("canyon", new CanyonWorldCarver(CanyonCarverConfiguration.f_158966_)); diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/feature/Feature.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/feature/Feature.java.patch new file mode 100644 index 0000000000..137b389c8e --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/levelgen/feature/Feature.java.patch @@ -0,0 +1,25 @@ +--- a/net/minecraft/world/level/levelgen/feature/Feature.java ++++ b/net/minecraft/world/level/levelgen/feature/Feature.java +@@ -49,7 +_,7 @@ + import net.minecraft.world.level.levelgen.feature.configurations.UnderwaterMagmaConfiguration; + import net.minecraft.world.level.levelgen.feature.configurations.VegetationPatchConfiguration; + +-public abstract class Feature { ++public abstract class Feature extends net.minecraftforge.registries.ForgeRegistryEntry> { + public static final Feature f_65759_ = m_65807_("no_op", new NoOpFeature(NoneFeatureConfiguration.f_67815_)); + public static final Feature f_65760_ = m_65807_("tree", new TreeFeature(TreeConfiguration.f_68184_)); + public static final AbstractFlowerFeature f_65761_ = m_65807_("flower", new DefaultFlowerFeature(RandomPatchConfiguration.f_67902_)); +@@ -157,11 +_,11 @@ + public abstract boolean m_142674_(FeaturePlaceContext p_159749_); + + protected static boolean m_159747_(BlockState p_159748_) { +- return p_159748_.m_60620_(BlockTags.f_13061_); ++ return p_159748_.m_60620_(net.minecraftforge.common.Tags.Blocks.STONE); + } + + public static boolean m_159759_(BlockState p_159760_) { +- return p_159760_.m_60620_(BlockTags.f_144274_); ++ return p_159760_.m_60620_(net.minecraftforge.common.Tags.Blocks.DIRT); + } + + public static boolean m_65788_(LevelSimulatedReader p_65789_, BlockPos p_65790_) { diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/feature/MonsterRoomFeature.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/feature/MonsterRoomFeature.java.patch new file mode 100644 index 0000000000..8084049f0b --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/levelgen/feature/MonsterRoomFeature.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/world/level/levelgen/feature/MonsterRoomFeature.java ++++ b/net/minecraft/world/level/levelgen/feature/MonsterRoomFeature.java +@@ -129,6 +_,6 @@ + } + + private EntityType m_66358_(Random p_66359_) { +- return Util.m_137545_(f_66341_, p_66359_); ++ return net.minecraftforge.common.DungeonHooks.getRandomDungeonMob(p_66359_); + } + } diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/feature/NetherFortressFeature.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/feature/NetherFortressFeature.java.patch new file mode 100644 index 0000000000..b761735cdc --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/levelgen/feature/NetherFortressFeature.java.patch @@ -0,0 +1,14 @@ +--- a/net/minecraft/world/level/levelgen/feature/NetherFortressFeature.java ++++ b/net/minecraft/world/level/levelgen/feature/NetherFortressFeature.java +@@ -33,8 +_,9 @@ + return NetherFortressFeature.NetherBridgeStart::new; + } + +- public WeightedRandomList m_142494_() { +- return f_66381_; ++ @Override ++ public List getDefaultSpawnList() { ++ return f_66381_.m_146338_(); + } + + public static class NetherBridgeStart extends StructureStart { diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/feature/OceanMonumentFeature.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/feature/OceanMonumentFeature.java.patch new file mode 100644 index 0000000000..72aac312a7 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/levelgen/feature/OceanMonumentFeature.java.patch @@ -0,0 +1,14 @@ +--- a/net/minecraft/world/level/levelgen/feature/OceanMonumentFeature.java ++++ b/net/minecraft/world/level/levelgen/feature/OceanMonumentFeature.java +@@ -55,8 +_,9 @@ + return OceanMonumentFeature.OceanMonumentStart::new; + } + +- public WeightedRandomList m_142494_() { +- return f_66469_; ++ @Override ++ public java.util.List getDefaultSpawnList() { ++ return f_66469_.m_146338_(); + } + + public static class OceanMonumentStart extends StructureStart { diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/feature/PillagerOutpostFeature.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/feature/PillagerOutpostFeature.java.patch new file mode 100644 index 0000000000..8af371083c --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/levelgen/feature/PillagerOutpostFeature.java.patch @@ -0,0 +1,14 @@ +--- a/net/minecraft/world/level/levelgen/feature/PillagerOutpostFeature.java ++++ b/net/minecraft/world/level/levelgen/feature/PillagerOutpostFeature.java +@@ -20,8 +_,9 @@ + super(p_66562_, 0, true, true); + } + +- public WeightedRandomList m_142494_() { +- return f_66559_; ++ @Override ++ public java.util.List getDefaultSpawnList() { ++ return f_66559_.m_146338_(); + } + + protected boolean m_142290_(ChunkGenerator p_160197_, BiomeSource p_160198_, long p_160199_, WorldgenRandom p_160200_, ChunkPos p_160201_, Biome p_160202_, ChunkPos p_160203_, JigsawConfiguration p_160204_, LevelHeightAccessor p_160205_) { diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/feature/StructureFeature.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/feature/StructureFeature.java.patch new file mode 100644 index 0000000000..8cfbb94544 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/levelgen/feature/StructureFeature.java.patch @@ -0,0 +1,30 @@ +--- a/net/minecraft/world/level/levelgen/feature/StructureFeature.java ++++ b/net/minecraft/world/level/levelgen/feature/StructureFeature.java +@@ -49,7 +_,7 @@ + import org.apache.logging.log4j.LogManager; + import org.apache.logging.log4j.Logger; + +-public abstract class StructureFeature { ++public abstract class StructureFeature extends net.minecraftforge.registries.ForgeRegistryEntry> implements net.minecraftforge.common.extensions.IForgeStructureFeature { + public static final BiMap> f_67012_ = HashBiMap.create(); + private static final Map, GenerationStep.Decoration> f_67032_ = Maps.newHashMap(); + private static final Logger f_67033_ = LogManager.getLogger(); +@@ -254,11 +_,16 @@ + } + + public WeightedRandomList m_142498_() { +- return MobSpawnSettings.f_151796_; ++ return getSpawnList(net.minecraft.world.entity.MobCategory.MONSTER); + } + + public WeightedRandomList m_160477_() { +- return MobSpawnSettings.f_151796_; ++ return getSpawnList(net.minecraft.world.entity.MobCategory.CREATURE); ++ } ++ ++ @Override ++ public final WeightedRandomList getSpawnList(net.minecraft.world.entity.MobCategory classification) { ++ return net.minecraftforge.common.world.StructureSpawnManager.getSpawnList(this, classification); + } + + public interface StructureStartFactory { diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/feature/SwamplandHutFeature.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/feature/SwamplandHutFeature.java.patch new file mode 100644 index 0000000000..9f10e9203d --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/levelgen/feature/SwamplandHutFeature.java.patch @@ -0,0 +1,21 @@ +--- a/net/minecraft/world/level/levelgen/feature/SwamplandHutFeature.java ++++ b/net/minecraft/world/level/levelgen/feature/SwamplandHutFeature.java +@@ -26,12 +_,14 @@ + return SwamplandHutFeature.FeatureStart::new; + } + +- public WeightedRandomList m_142494_() { +- return f_67169_; ++ @Override ++ public java.util.List getDefaultSpawnList() { ++ return f_67169_.m_146338_(); + } + +- public WeightedRandomList m_142498_() { +- return f_67170_; ++ @Override ++ public java.util.List getDefaultCreatureSpawnList() { ++ return f_67170_.m_146338_(); + } + + public static class FeatureStart extends StructureStart { diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/feature/blockplacers/BlockPlacerType.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/feature/blockplacers/BlockPlacerType.java.patch new file mode 100644 index 0000000000..01780dff14 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/levelgen/feature/blockplacers/BlockPlacerType.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/levelgen/feature/blockplacers/BlockPlacerType.java ++++ b/net/minecraft/world/level/levelgen/feature/blockplacers/BlockPlacerType.java +@@ -3,7 +_,7 @@ + import com.mojang.serialization.Codec; + import net.minecraft.core.Registry; + +-public class BlockPlacerType

{ ++public class BlockPlacerType

extends net.minecraftforge.registries.ForgeRegistryEntry> { + public static final BlockPlacerType f_67487_ = m_67495_("simple_block_placer", SimpleBlockPlacer.f_67528_); + public static final BlockPlacerType f_67488_ = m_67495_("double_plant_placer", DoublePlantPlacer.f_67517_); + public static final BlockPlacerType f_67489_ = m_67495_("column_placer", ColumnPlacer.f_67498_); diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/feature/configurations/TreeConfiguration.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/feature/configurations/TreeConfiguration.java.patch new file mode 100644 index 0000000000..aca52ac182 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/levelgen/feature/configurations/TreeConfiguration.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/world/level/levelgen/feature/configurations/TreeConfiguration.java ++++ b/net/minecraft/world/level/levelgen/feature/configurations/TreeConfiguration.java +@@ -36,6 +_,7 @@ + return p_161230_.f_161215_; + })).apply(p_161228_, TreeConfiguration::new); + }); ++ //TODO: Review this, see if we can hook in the sapling into the Codec + public final BlockStateProvider f_68185_; + public final BlockStateProvider f_161212_; + public final TrunkPlacer f_68190_; diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/feature/foliageplacers/FoliagePlacerType.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/feature/foliageplacers/FoliagePlacerType.java.patch new file mode 100644 index 0000000000..94f0fc1e84 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/levelgen/feature/foliageplacers/FoliagePlacerType.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/levelgen/feature/foliageplacers/FoliagePlacerType.java ++++ b/net/minecraft/world/level/levelgen/feature/foliageplacers/FoliagePlacerType.java +@@ -3,7 +_,7 @@ + import com.mojang.serialization.Codec; + import net.minecraft.core.Registry; + +-public class FoliagePlacerType

{ ++public class FoliagePlacerType

extends net.minecraftforge.registries.ForgeRegistryEntry> { + public static final FoliagePlacerType f_68591_ = m_68605_("blob_foliage_placer", BlobFoliagePlacer.f_68392_); + public static final FoliagePlacerType f_68592_ = m_68605_("spruce_foliage_placer", SpruceFoliagePlacer.f_68713_); + public static final FoliagePlacerType f_68593_ = m_68605_("pine_foliage_placer", PineFoliagePlacer.f_68676_); diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/feature/stateproviders/BlockStateProviderType.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/feature/stateproviders/BlockStateProviderType.java.patch new file mode 100644 index 0000000000..4d19b15173 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/levelgen/feature/stateproviders/BlockStateProviderType.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/levelgen/feature/stateproviders/BlockStateProviderType.java ++++ b/net/minecraft/world/level/levelgen/feature/stateproviders/BlockStateProviderType.java +@@ -3,7 +_,7 @@ + import com.mojang.serialization.Codec; + import net.minecraft.core.Registry; + +-public class BlockStateProviderType

{ ++public class BlockStateProviderType

extends net.minecraftforge.registries.ForgeRegistryEntry> { + public static final BlockStateProviderType f_68752_ = m_68762_("simple_state_provider", SimpleStateProvider.f_68797_); + public static final BlockStateProviderType f_68753_ = m_68762_("weighted_state_provider", WeightedStateProvider.f_68808_); + public static final BlockStateProviderType f_68754_ = m_68762_("plain_flower_provider", PlainFlowerProvider.f_68775_); diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/feature/structures/SinglePoolElement.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/feature/structures/SinglePoolElement.java.patch new file mode 100644 index 0000000000..ec31d575c9 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/levelgen/feature/structures/SinglePoolElement.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/levelgen/feature/structures/SinglePoolElement.java ++++ b/net/minecraft/world/level/levelgen/feature/structures/SinglePoolElement.java +@@ -112,7 +_,7 @@ + if (!structuretemplate.m_74536_(p_69123_, p_69126_, p_69127_, structureplacesettings, p_69130_, 18)) { + return false; + } else { +- for(StructureTemplate.StructureBlockInfo structuretemplate$structureblockinfo : StructureTemplate.m_74517_(p_69123_, p_69126_, p_69127_, structureplacesettings, this.m_69141_(p_69122_, p_69126_, p_69128_, false))) { ++ for(StructureTemplate.StructureBlockInfo structuretemplate$structureblockinfo : StructureTemplate.processBlockInfos(p_69123_, p_69126_, p_69127_, structureplacesettings, this.m_69141_(p_69122_, p_69126_, p_69128_, false), structuretemplate)) { + this.m_69157_(p_69123_, structuretemplate$structureblockinfo, p_69126_, p_69128_, p_69130_, p_69129_); + } + diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/feature/structures/StructureTemplatePool.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/feature/structures/StructureTemplatePool.java.patch new file mode 100644 index 0000000000..c3de9db562 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/levelgen/feature/structures/StructureTemplatePool.java.patch @@ -0,0 +1,33 @@ +--- a/net/minecraft/world/level/levelgen/feature/structures/StructureTemplatePool.java ++++ b/net/minecraft/world/level/levelgen/feature/structures/StructureTemplatePool.java +@@ -106,11 +_,11 @@ + return this.f_69250_.size(); + } + +- public static enum Projection implements StringRepresentable { ++ public static enum Projection implements StringRepresentable, net.minecraftforge.common.IExtensibleEnum { + TERRAIN_MATCHING("terrain_matching", ImmutableList.of(new GravityProcessor(Heightmap.Types.WORLD_SURFACE_WG, -1))), + RIGID("rigid", ImmutableList.of()); + +- public static final Codec f_69281_ = StringRepresentable.m_14350_(StructureTemplatePool.Projection::values, StructureTemplatePool.Projection::m_69295_); ++ public static final Codec f_69281_ = net.minecraftforge.common.IExtensibleEnum.createCodecForExtensibleEnum(StructureTemplatePool.Projection::values, StructureTemplatePool.Projection::m_69295_); + private static final Map f_69282_ = Arrays.stream(values()).collect(Collectors.toMap(StructureTemplatePool.Projection::m_69297_, (p_69294_) -> { + return p_69294_; + })); +@@ -136,6 +_,16 @@ + + public String m_7912_() { + return this.f_69283_; ++ } ++ ++ public static Projection create(String enumName, String p_i50487_3_, ImmutableList p_i50487_4_) { ++ throw new IllegalStateException("Enum not extended"); ++ } ++ ++ @Override ++ @Deprecated ++ public void init() { ++ f_69282_.put(m_69297_(), this); + } + } + } diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/feature/treedecorators/TreeDecoratorType.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/feature/treedecorators/TreeDecoratorType.java.patch new file mode 100644 index 0000000000..55faf71b15 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/levelgen/feature/treedecorators/TreeDecoratorType.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/levelgen/feature/treedecorators/TreeDecoratorType.java ++++ b/net/minecraft/world/level/levelgen/feature/treedecorators/TreeDecoratorType.java +@@ -3,7 +_,7 @@ + import com.mojang.serialization.Codec; + import net.minecraft.core.Registry; + +-public class TreeDecoratorType

{ ++public class TreeDecoratorType

extends net.minecraftforge.registries.ForgeRegistryEntry> { + public static final TreeDecoratorType f_70042_ = m_70052_("trunk_vine", TrunkVineDecorator.f_70055_); + public static final TreeDecoratorType f_70043_ = m_70052_("leave_vine", LeaveVineDecorator.f_69996_); + public static final TreeDecoratorType f_70044_ = m_70052_("cocoa", CocoaDecorator.f_69972_); diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/flat/FlatLevelGeneratorSettings.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/flat/FlatLevelGeneratorSettings.java.patch new file mode 100644 index 0000000000..6b2b15a1f5 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/levelgen/flat/FlatLevelGeneratorSettings.java.patch @@ -0,0 +1,29 @@ +--- a/net/minecraft/world/level/levelgen/flat/FlatLevelGeneratorSettings.java ++++ b/net/minecraft/world/level/levelgen/flat/FlatLevelGeneratorSettings.java +@@ -153,8 +_,16 @@ + biomegenerationsettings$builder.m_47842_(GenerationStep.Decoration.LAKES, Features.f_126876_); + } + ++ Map, ConfiguredStructureFeature> map = new java.util.HashMap<>(f_70349_); ++ net.minecraft.data.BuiltinRegistries.f_123862_.m_123024_().filter(f -> !map.containsKey(f.f_65403_)).forEach(f -> map.put(f.f_65403_, f)); + for(Entry, StructureFeatureConfiguration> entry : this.f_70351_.m_64590_().entrySet()) { +- biomegenerationsettings$builder.m_47849_(biomegenerationsettings.m_47803_(f_70349_.get(entry.getKey()))); ++ if (!map.containsKey(entry.getKey())) { ++ f_70348_.error("FORGE: There's no known StructureFeature for {} when preparing the {} flatworld biome." + ++ " The structure will be skipped and may not spawn." + ++ " Please register your StructureFeatures in the WorldGenRegistries!", entry.getKey().m_67098_(), biome.getRegistryName()); ++ continue; ++ } ++ biomegenerationsettings$builder.m_47849_(biomegenerationsettings.m_47803_(map.get(entry.getKey()))); + } + + boolean flag = (!this.f_70355_ || this.f_70350_.m_7854_(biome).equals(Optional.of(Biomes.f_48173_))) && this.f_70356_; +@@ -180,7 +_,7 @@ + } + } + +- return (new Biome.BiomeBuilder()).m_47597_(biome.m_47530_()).m_47595_(biome.m_47567_()).m_47593_(biome.m_47545_()).m_47607_(biome.m_47551_()).m_47609_(biome.m_47554_()).m_47611_(biome.m_47548_()).m_47603_(biome.m_47557_()).m_47601_(biomegenerationsettings$builder.m_47831_()).m_47605_(biome.m_47518_()).m_47592_(); ++ return (new Biome.BiomeBuilder()).m_47597_(biome.m_47530_()).m_47595_(biome.m_47567_()).m_47593_(biome.m_47545_()).m_47607_(biome.m_47551_()).m_47609_(biome.m_47554_()).m_47611_(biome.m_47548_()).m_47603_(biome.m_47557_()).m_47601_(biomegenerationsettings$builder.m_47831_()).m_47605_(biome.m_47518_()).m_47592_().setRegistryName(biome.getRegistryName()); + } + + public StructureSettings m_70395_() { diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/placement/FeatureDecorator.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/placement/FeatureDecorator.java.patch new file mode 100644 index 0000000000..ddc9ba405a --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/levelgen/placement/FeatureDecorator.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/levelgen/placement/FeatureDecorator.java ++++ b/net/minecraft/world/level/levelgen/placement/FeatureDecorator.java +@@ -13,7 +_,7 @@ + import net.minecraft.world.level.levelgen.feature.configurations.RangeDecoratorConfiguration; + import net.minecraft.world.level.levelgen.placement.nether.CountMultiLayerDecorator; + +-public abstract class FeatureDecorator { ++public abstract class FeatureDecorator extends net.minecraftforge.registries.ForgeRegistryEntry> { + public static final FeatureDecorator f_70681_ = m_70717_("nope", new NopePlacementDecorator(NoneDecoratorConfiguration.f_67810_)); + public static final FeatureDecorator f_70678_ = m_70717_("decorated", new DecoratedDecorator(DecoratedDecoratorConfiguration.f_70570_)); + public static final FeatureDecorator f_70697_ = m_70717_("carving_mask", new CarvingMaskDecorator(CarvingMaskDecoratorConfiguration.f_70441_)); diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch new file mode 100644 index 0000000000..048cebf007 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch @@ -0,0 +1,12 @@ +--- a/net/minecraft/world/level/levelgen/structure/StructurePiece.java ++++ b/net/minecraft/world/level/levelgen/structure/StructurePiece.java +@@ -70,6 +_,9 @@ + } + + public final CompoundTag m_163549_(ServerLevel p_163550_) { ++ if (Registry.f_122843_.m_7981_(this.m_73550_()) == null) { // FORGE: Friendlier error then the Null String error below. ++ throw new RuntimeException("StructurePiece \"" + this.getClass().getName() + "\": \"" + this.m_73550_() + "\" missing ID Mapping, Modder see MapGenStructureIO"); ++ } + CompoundTag compoundtag = new CompoundTag(); + compoundtag.m_128359_("id", Registry.f_122843_.m_7981_(this.m_73550_()).toString()); + BoundingBox.f_162354_.encodeStart(NbtOps.f_128958_, this.f_73383_).resultOrPartial(f_163536_::error).ifPresent((p_163579_) -> { diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/structure/StructureStart.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/structure/StructureStart.java.patch new file mode 100644 index 0000000000..8b7c21e15e --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/levelgen/structure/StructureStart.java.patch @@ -0,0 +1,12 @@ +--- a/net/minecraft/world/level/levelgen/structure/StructureStart.java ++++ b/net/minecraft/world/level/levelgen/structure/StructureStart.java +@@ -96,6 +_,9 @@ + public CompoundTag m_163606_(ServerLevel p_163607_, ChunkPos p_163608_) { + CompoundTag compoundtag = new CompoundTag(); + if (this.m_73603_()) { ++ if (Registry.f_122841_.m_7981_(this.m_73610_()) == null) { // FORGE: This is just a more friendly error instead of the 'Null String' below ++ throw new RuntimeException("StructureStart \"" + this.getClass().getName() + "\": \"" + this.m_73610_() + "\" missing ID Mapping, Modder see MapGenStructureIO"); ++ } + compoundtag.m_128359_("id", Registry.f_122841_.m_7981_(this.m_73610_()).toString()); + compoundtag.m_128405_("ChunkX", p_163608_.f_45578_); + compoundtag.m_128405_("ChunkZ", p_163608_.f_45579_); diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/structure/templatesystem/StructureProcessor.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/structure/templatesystem/StructureProcessor.java.patch new file mode 100644 index 0000000000..a48f683f10 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/levelgen/structure/templatesystem/StructureProcessor.java.patch @@ -0,0 +1,38 @@ +--- a/net/minecraft/world/level/levelgen/structure/templatesystem/StructureProcessor.java ++++ b/net/minecraft/world/level/levelgen/structure/templatesystem/StructureProcessor.java +@@ -6,7 +_,34 @@ + + public abstract class StructureProcessor { + @Nullable +- public abstract StructureTemplate.StructureBlockInfo m_7382_(LevelReader p_74416_, BlockPos p_74417_, BlockPos p_74418_, StructureTemplate.StructureBlockInfo p_74419_, StructureTemplate.StructureBlockInfo p_74420_, StructurePlaceSettings p_74421_); ++ @Deprecated //Forge: Use process below, with the Template context ++ public StructureTemplate.StructureBlockInfo m_7382_(LevelReader p_74416_, BlockPos p_74417_, BlockPos p_74418_, StructureTemplate.StructureBlockInfo p_74419_, StructureTemplate.StructureBlockInfo p_74420_, StructurePlaceSettings p_74421_) { ++ return p_74420_; ++ } + + protected abstract StructureProcessorType m_6953_(); ++ ++ @Nullable ++ public StructureTemplate.StructureBlockInfo process(LevelReader p_74140_, BlockPos p_74141_, BlockPos p_74142_, StructureTemplate.StructureBlockInfo p_74143_, StructureTemplate.StructureBlockInfo p_74144_, StructurePlaceSettings p_74145_, @Nullable StructureTemplate template) { ++ return m_7382_(p_74140_, p_74141_, p_74142_, p_74143_, p_74144_, p_74145_); ++ } ++ ++ /** ++ * FORGE: Add entity processing. ++ *

++ * Use this method to process entities from a structure in much the same way as ++ * blocks, parameters are analogous. ++ * ++ * @param world ++ * @param seedPos ++ * @param rawEntityInfo ++ * @param entityInfo ++ * @param placementSettings ++ * @param template ++ * ++ * @see #process(LevelReader, BlockPos, BlockPos, StructureTemplate.StructureBlockInfo, StructureTemplate.StructureBlockInfo, StructurePlaceSettings, StructureTemplate) ++ */ ++ public StructureTemplate.StructureEntityInfo processEntity(LevelReader world, BlockPos seedPos, StructureTemplate.StructureEntityInfo rawEntityInfo, StructureTemplate.StructureEntityInfo entityInfo, StructurePlaceSettings placementSettings, StructureTemplate template) { ++ return entityInfo; ++ } + } diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch new file mode 100644 index 0000000000..cbfa9f4a83 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch @@ -0,0 +1,103 @@ +--- a/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java ++++ b/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java +@@ -204,6 +_,10 @@ + return m_74593_(p_74565_, p_74564_.m_74401_(), p_74564_.m_74404_(), p_74564_.m_74407_()); + } + ++ public static Vec3 transformedVec3d(StructurePlaceSettings placementIn, Vec3 pos) { ++ return m_74578_(pos, placementIn.m_74401_(), placementIn.m_74404_(), placementIn.m_74407_()); ++ } ++ + public boolean m_74536_(ServerLevelAccessor p_74537_, BlockPos p_74538_, BlockPos p_74539_, StructurePlaceSettings p_74540_, Random p_74541_, int p_74542_) { + if (this.f_74482_.isEmpty()) { + return false; +@@ -221,7 +_,7 @@ + int i1 = Integer.MIN_VALUE; + int j1 = Integer.MIN_VALUE; + +- for(StructureTemplate.StructureBlockInfo structuretemplate$structureblockinfo : m_74517_(p_74537_, p_74538_, p_74539_, p_74540_, list)) { ++ for(StructureTemplate.StructureBlockInfo structuretemplate$structureblockinfo : processBlockInfos(p_74537_, p_74538_, p_74539_, p_74540_, list, this)) { + BlockPos blockpos = structuretemplate$structureblockinfo.f_74675_; + if (boundingbox == null || boundingbox.m_71051_(blockpos)) { + FluidState fluidstate = p_74540_.m_74413_() ? p_74537_.m_6425_(blockpos) : null; +@@ -336,7 +_,7 @@ + } + + if (!p_74540_.m_74408_()) { +- this.m_74523_(p_74537_, p_74538_, p_74540_.m_74401_(), p_74540_.m_74404_(), p_74540_.m_74407_(), boundingbox, p_74540_.m_74414_()); ++ this.addEntitiesToWorld(p_74537_, p_74538_, p_74540_); + } + + return true; +@@ -365,14 +_,19 @@ + }); + } + ++ @Deprecated //Use Forge version + public static List m_74517_(LevelAccessor p_74518_, BlockPos p_74519_, BlockPos p_74520_, StructurePlaceSettings p_74521_, List p_74522_) { ++ return processBlockInfos(p_74518_, p_74519_, p_74520_, p_74521_, p_74522_, null); ++ } ++ ++ public static List processBlockInfos(LevelAccessor p_74518_, BlockPos p_74519_, BlockPos p_74520_, StructurePlaceSettings p_74521_, List p_74522_, @Nullable StructureTemplate template) { + List list = Lists.newArrayList(); + + for(StructureTemplate.StructureBlockInfo structuretemplate$structureblockinfo : p_74522_) { + BlockPos blockpos = m_74563_(p_74521_, structuretemplate$structureblockinfo.f_74675_).m_141952_(p_74519_); + StructureTemplate.StructureBlockInfo structuretemplate$structureblockinfo1 = new StructureTemplate.StructureBlockInfo(blockpos, structuretemplate$structureblockinfo.f_74676_, structuretemplate$structureblockinfo.f_74677_ != null ? structuretemplate$structureblockinfo.f_74677_.m_6426_() : null); + +- for(Iterator iterator = p_74521_.m_74411_().iterator(); structuretemplate$structureblockinfo1 != null && iterator.hasNext(); structuretemplate$structureblockinfo1 = iterator.next().m_7382_(p_74518_, p_74519_, p_74520_, structuretemplate$structureblockinfo, structuretemplate$structureblockinfo1, p_74521_)) { ++ for(Iterator iterator = p_74521_.m_74411_().iterator(); structuretemplate$structureblockinfo1 != null && iterator.hasNext(); structuretemplate$structureblockinfo1 = iterator.next().process(p_74518_, p_74519_, p_74520_, structuretemplate$structureblockinfo, structuretemplate$structureblockinfo1, p_74521_, template)) { + } + + if (structuretemplate$structureblockinfo1 != null) { +@@ -383,13 +_,30 @@ + return list; + } + +- private void m_74523_(ServerLevelAccessor p_74524_, BlockPos p_74525_, Mirror p_74526_, Rotation p_74527_, BlockPos p_74528_, @Nullable BoundingBox p_74529_, boolean p_74530_) { +- for(StructureTemplate.StructureEntityInfo structuretemplate$structureentityinfo : this.f_74483_) { +- BlockPos blockpos = m_74593_(structuretemplate$structureentityinfo.f_74684_, p_74526_, p_74527_, p_74528_).m_141952_(p_74525_); +- if (p_74529_ == null || p_74529_.m_71051_(blockpos)) { ++ public static List processEntityInfos(@Nullable StructureTemplate template, LevelAccessor p_215387_0_, BlockPos p_215387_1_, StructurePlaceSettings p_215387_2_, List p_215387_3_) { ++ List list = Lists.newArrayList(); ++ for(StructureTemplate.StructureEntityInfo entityInfo : p_215387_3_) { ++ Vec3 pos = transformedVec3d(p_215387_2_, entityInfo.f_74683_).m_82549_(Vec3.m_82528_(p_215387_1_)); ++ BlockPos blockpos = m_74563_(p_215387_2_, entityInfo.f_74684_).m_141952_(p_215387_1_); ++ StructureTemplate.StructureEntityInfo info = new StructureTemplate.StructureEntityInfo(pos, blockpos, entityInfo.f_74685_); ++ for (StructureProcessor proc : p_215387_2_.m_74411_()) { ++ info = proc.processEntity(p_215387_0_, p_215387_1_, entityInfo, info, p_215387_2_, template); ++ if (info == null) ++ break; ++ } ++ if (info != null) ++ list.add(info); ++ } ++ return list; ++ } ++ ++ private void addEntitiesToWorld(ServerLevelAccessor p_74524_, BlockPos p_74525_, StructurePlaceSettings placementIn) { ++ for(StructureTemplate.StructureEntityInfo structuretemplate$structureentityinfo : processEntityInfos(this, p_74524_, p_74525_, placementIn, this.f_74483_)) { ++ BlockPos blockpos = m_74593_(structuretemplate$structureentityinfo.f_74684_, placementIn.m_74401_(), placementIn.m_74404_(), placementIn.m_74407_()).m_141952_(p_74525_); ++ blockpos = structuretemplate$structureentityinfo.f_74684_; // FORGE: Position will have already been transformed by processEntityInfos ++ if (placementIn.m_74409_() == null || placementIn.m_74409_().m_71051_(blockpos)) { + CompoundTag compoundtag = structuretemplate$structureentityinfo.f_74685_.m_6426_(); +- Vec3 vec3 = m_74578_(structuretemplate$structureentityinfo.f_74683_, p_74526_, p_74527_, p_74528_); +- Vec3 vec31 = vec3.m_82520_((double)p_74525_.m_123341_(), (double)p_74525_.m_123342_(), (double)p_74525_.m_123343_()); ++ Vec3 vec31 = structuretemplate$structureentityinfo.f_74683_; // FORGE: Position will have already been transformed by processEntityInfos + ListTag listtag = new ListTag(); + listtag.add(DoubleTag.m_128500_(vec31.f_82479_)); + listtag.add(DoubleTag.m_128500_(vec31.f_82480_)); +@@ -397,10 +_,10 @@ + compoundtag.m_128365_("Pos", listtag); + compoundtag.m_128473_("UUID"); + m_74543_(p_74524_, compoundtag).ifPresent((p_74553_) -> { +- float f = p_74553_.m_6961_(p_74526_); +- f = f + (p_74553_.m_146908_() - p_74553_.m_7890_(p_74527_)); ++ float f = p_74553_.m_6961_(placementIn.m_74401_()); ++ f = f + (p_74553_.m_146908_() - p_74553_.m_7890_(placementIn.m_74404_())); + p_74553_.m_7678_(vec31.f_82479_, vec31.f_82480_, vec31.f_82481_, f, p_74553_.m_146909_()); +- if (p_74530_ && p_74553_ instanceof Mob) { ++ if (placementIn.m_74414_() && p_74553_ instanceof Mob) { + ((Mob)p_74553_).m_6518_(p_74524_, p_74524_.m_6436_(new BlockPos(vec31)), MobSpawnType.STRUCTURE, (SpawnGroupData)null, compoundtag); + } + diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/surfacebuilders/SurfaceBuilder.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/surfacebuilders/SurfaceBuilder.java.patch new file mode 100644 index 0000000000..d7121eea2a --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/levelgen/surfacebuilders/SurfaceBuilder.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/levelgen/surfacebuilders/SurfaceBuilder.java ++++ b/net/minecraft/world/level/levelgen/surfacebuilders/SurfaceBuilder.java +@@ -8,7 +_,7 @@ + import net.minecraft.world.level.block.state.BlockState; + import net.minecraft.world.level.chunk.ChunkAccess; + +-public abstract class SurfaceBuilder { ++public abstract class SurfaceBuilder extends net.minecraftforge.registries.ForgeRegistryEntry> { + private static final BlockState f_75193_ = Blocks.f_50493_.m_49966_(); + private static final BlockState f_75194_ = Blocks.f_50440_.m_49966_(); + private static final BlockState f_75195_ = Blocks.f_50599_.m_49966_(); diff --git a/patches/minecraft/net/minecraft/world/level/lighting/BlockLightEngine.java.patch b/patches/minecraft/net/minecraft/world/level/lighting/BlockLightEngine.java.patch new file mode 100644 index 0000000000..58d64ebea4 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/lighting/BlockLightEngine.java.patch @@ -0,0 +1,12 @@ +--- a/net/minecraft/world/level/lighting/BlockLightEngine.java ++++ b/net/minecraft/world/level/lighting/BlockLightEngine.java +@@ -117,4 +_,9 @@ + this.f_75632_.m_75785_(); + this.m_75576_(Long.MAX_VALUE, p_75502_.m_121878_(), 15 - p_75503_, true); + } ++ ++ @Override ++ public int queuedUpdateSize() { ++ return f_75632_.queuedUpdateSize(); ++ } + } diff --git a/patches/minecraft/net/minecraft/world/level/lighting/DynamicGraphMinFixedPoint.java.patch b/patches/minecraft/net/minecraft/world/level/lighting/DynamicGraphMinFixedPoint.java.patch new file mode 100644 index 0000000000..64cb490429 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/lighting/DynamicGraphMinFixedPoint.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/lighting/DynamicGraphMinFixedPoint.java ++++ b/net/minecraft/world/level/lighting/DynamicGraphMinFixedPoint.java +@@ -229,4 +_,8 @@ + protected abstract void m_7351_(long p_75552_, int p_75553_); + + protected abstract int m_6359_(long p_75590_, long p_75591_, int p_75592_); ++ ++ protected int queuedUpdateSize() { ++ return f_75539_.size(); ++ } + } diff --git a/patches/minecraft/net/minecraft/world/level/lighting/LayerLightEngine.java.patch b/patches/minecraft/net/minecraft/world/level/lighting/LayerLightEngine.java.patch new file mode 100644 index 0000000000..d08eff250f --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/lighting/LayerLightEngine.java.patch @@ -0,0 +1,9 @@ +--- a/net/minecraft/world/level/lighting/LayerLightEngine.java ++++ b/net/minecraft/world/level/lighting/LayerLightEngine.java +@@ -214,4 +_,6 @@ + long i = SectionPos.m_123240_(SectionPos.m_123209_(p_75700_.f_45578_, 0, p_75700_.f_45579_)); + this.f_75632_.m_75782_(i, p_75701_); + } ++ ++ public abstract int queuedUpdateSize(); + } diff --git a/patches/minecraft/net/minecraft/world/level/lighting/SkyLightEngine.java.patch b/patches/minecraft/net/minecraft/world/level/lighting/SkyLightEngine.java.patch new file mode 100644 index 0000000000..17283ca17d --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/lighting/SkyLightEngine.java.patch @@ -0,0 +1,12 @@ +--- a/net/minecraft/world/level/lighting/SkyLightEngine.java ++++ b/net/minecraft/world/level/lighting/SkyLightEngine.java +@@ -174,4 +_,9 @@ + public String m_6647_(long p_75853_) { + return super.m_6647_(p_75853_) + (this.f_75632_.m_75890_(p_75853_) ? "*" : ""); + } ++ ++ @Override ++ public int queuedUpdateSize() { ++ return 0; ++ } + } diff --git a/patches/minecraft/net/minecraft/world/level/material/FlowingFluid.java.patch b/patches/minecraft/net/minecraft/world/level/material/FlowingFluid.java.patch new file mode 100644 index 0000000000..6176f21ddf --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/material/FlowingFluid.java.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/world/level/material/FlowingFluid.java ++++ b/net/minecraft/world/level/material/FlowingFluid.java +@@ -159,7 +_,7 @@ + BlockState blockstate = p_76036_.m_8055_(blockpos); + FluidState fluidstate = blockstate.m_60819_(); + if (fluidstate.m_76152_().m_6212_(this) && this.m_76061_(direction, p_76036_, p_76037_, p_76038_, blockpos, blockstate)) { +- if (fluidstate.m_76170_()) { ++ if (fluidstate.m_76170_() && net.minecraftforge.event.ForgeEventFactory.canCreateFluidSource(p_76036_, blockpos, blockstate, this.m_6760_())) { + ++j; + } + +@@ -167,7 +_,7 @@ + } + } + +- if (this.m_6760_() && j >= 2) { ++ if (j >= 2) { + BlockState blockstate1 = p_76036_.m_8055_(p_76037_.m_7495_()); + FluidState fluidstate1 = blockstate1.m_60819_(); + if (blockstate1.m_60767_().m_76333_() || this.m_76096_(fluidstate1)) { diff --git a/patches/minecraft/net/minecraft/fluid/Fluid.java.patch b/patches/minecraft/net/minecraft/world/level/material/Fluid.java.patch similarity index 61% rename from patches/minecraft/net/minecraft/fluid/Fluid.java.patch rename to patches/minecraft/net/minecraft/world/level/material/Fluid.java.patch index deb579db9d..024722b9a0 100644 --- a/patches/minecraft/net/minecraft/fluid/Fluid.java.patch +++ b/patches/minecraft/net/minecraft/world/level/material/Fluid.java.patch @@ -1,22 +1,22 @@ ---- a/net/minecraft/fluid/Fluid.java -+++ b/net/minecraft/fluid/Fluid.java +--- a/net/minecraft/world/level/material/Fluid.java ++++ b/net/minecraft/world/level/material/Fluid.java @@ -18,7 +_,7 @@ - import net.minecraftforge.api.distmarker.Dist; - import net.minecraftforge.api.distmarker.OnlyIn; + import net.minecraft.world.phys.Vec3; + import net.minecraft.world.phys.shapes.VoxelShape; -public abstract class Fluid { +public abstract class Fluid extends net.minecraftforge.registries.ForgeRegistryEntry implements net.minecraftforge.common.extensions.IForgeFluid { - public static final ObjectIntIdentityMap field_207201_d = new ObjectIntIdentityMap<>(); - protected final StateContainer field_207202_e; - private FluidState field_207200_b; -@@ -98,4 +_,26 @@ + public static final IdMapper f_76104_ = new IdMapper<>(); + protected final StateDefinition f_76105_; + private FluidState f_76103_; +@@ -96,6 +_,28 @@ } - public abstract VoxelShape func_215664_b(FluidState p_215664_1_, IBlockReader p_215664_2_, BlockPos p_215664_3_); + public abstract VoxelShape m_7999_(FluidState p_76137_, BlockGetter p_76138_, BlockPos p_76139_); + -+ private final net.minecraftforge.common.util.ReverseTagWrapper reverseTags = new net.minecraftforge.common.util.ReverseTagWrapper<>(this, net.minecraft.tags.FluidTags::func_226157_a_); ++ private final net.minecraftforge.common.util.ReverseTagWrapper reverseTags = new net.minecraftforge.common.util.ReverseTagWrapper<>(this, net.minecraft.tags.FluidTags::m_144299_); + @Override -+ public java.util.Set getTags() { ++ public java.util.Set getTags() { + return reverseTags.getTagNames(); + } + @@ -35,4 +35,6 @@ + forgeFluidAttributes = createAttributes(); + return forgeFluidAttributes; + } - } + + public Optional m_142520_() { + return Optional.empty(); diff --git a/patches/minecraft/net/minecraft/world/level/material/FluidState.java.patch b/patches/minecraft/net/minecraft/world/level/material/FluidState.java.patch new file mode 100644 index 0000000000..b0fb102815 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/material/FluidState.java.patch @@ -0,0 +1,19 @@ +--- a/net/minecraft/world/level/material/FluidState.java ++++ b/net/minecraft/world/level/material/FluidState.java +@@ -18,7 +_,7 @@ + import net.minecraft.world.phys.Vec3; + import net.minecraft.world.phys.shapes.VoxelShape; + +-public final class FluidState extends StateHolder { ++public final class FluidState extends StateHolder implements net.minecraftforge.common.extensions.IForgeFluidState { + public static final Codec f_76146_ = m_61127_(Registry.f_122822_, Fluid::m_76145_).stable(); + public static final int f_164510_ = 9; + public static final int f_164511_ = 8; +@@ -102,6 +_,7 @@ + return this.m_76152_().m_76108_(p_76154_); + } + ++ @Deprecated //Forge: Use more sensitive version + public float m_76190_() { + return this.m_76152_().m_6752_(); + } diff --git a/patches/minecraft/net/minecraft/world/level/material/LavaFluid.java.patch b/patches/minecraft/net/minecraft/world/level/material/LavaFluid.java.patch new file mode 100644 index 0000000000..113709197e --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/material/LavaFluid.java.patch @@ -0,0 +1,29 @@ +--- a/net/minecraft/world/level/material/LavaFluid.java ++++ b/net/minecraft/world/level/material/LavaFluid.java +@@ -72,7 +_,7 @@ + BlockState blockstate = p_76239_.m_8055_(blockpos); + if (blockstate.m_60795_()) { + if (this.m_76227_(p_76239_, blockpos)) { +- p_76239_.m_46597_(blockpos, BaseFireBlock.m_49245_(p_76239_, blockpos)); ++ p_76239_.m_46597_(blockpos, net.minecraftforge.event.ForgeEventFactory.fireFluidPlaceBlockEvent(p_76239_, blockpos, p_76240_, Blocks.f_50083_.m_49966_())); + return; + } + } else if (blockstate.m_60767_().m_76334_()) { +@@ -87,7 +_,7 @@ + } + + if (p_76239_.m_46859_(blockpos1.m_7494_()) && this.m_76245_(p_76239_, blockpos1)) { +- p_76239_.m_46597_(blockpos1.m_7494_(), BaseFireBlock.m_49245_(p_76239_, blockpos1)); ++ p_76239_.m_46597_(blockpos1.m_7494_(), net.minecraftforge.event.ForgeEventFactory.fireFluidPlaceBlockEvent(p_76239_, blockpos1.m_7494_(), p_76240_, Blocks.f_50083_.m_49966_())); + } + } + } +@@ -164,7 +_,7 @@ + FluidState fluidstate = p_76220_.m_6425_(p_76221_); + if (this.m_76108_(FluidTags.f_13132_) && fluidstate.m_76153_(FluidTags.f_13131_)) { + if (p_76222_.m_60734_() instanceof LiquidBlock) { +- p_76220_.m_7731_(p_76221_, Blocks.f_50069_.m_49966_(), 3); ++ p_76220_.m_7731_(p_76221_, net.minecraftforge.event.ForgeEventFactory.fireFluidPlaceBlockEvent(p_76220_, p_76221_, p_76221_, Blocks.f_50069_.m_49966_()), 3); + } + + this.m_76212_(p_76220_, p_76221_); diff --git a/patches/minecraft/net/minecraft/world/level/newbiome/layer/BiomeInitLayer.java.patch b/patches/minecraft/net/minecraft/world/level/newbiome/layer/BiomeInitLayer.java.patch new file mode 100644 index 0000000000..ef5c220f63 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/newbiome/layer/BiomeInitLayer.java.patch @@ -0,0 +1,64 @@ +--- a/net/minecraft/world/level/newbiome/layer/BiomeInitLayer.java ++++ b/net/minecraft/world/level/newbiome/layer/BiomeInitLayer.java +@@ -10,12 +_,13 @@ + private static final int[] f_76688_ = new int[]{4, 3, 5, 1}; + private static final int[] f_76689_ = new int[]{12, 12, 12, 30}; + private int[] f_76690_ = f_76686_; ++ private final boolean legacyDesert; ++ private java.util.List[] biomes = new java.util.ArrayList[net.minecraftforge.common.BiomeManager.BiomeType.values().length]; + + public BiomeInitLayer(boolean p_76693_) { +- if (p_76693_) { +- this.f_76690_ = f_76685_; +- } +- ++ this.legacyDesert = p_76693_; ++ for (net.minecraftforge.common.BiomeManager.BiomeType type : net.minecraftforge.common.BiomeManager.BiomeType.values()) ++ biomes[type.ordinal()] = new java.util.ArrayList<>(net.minecraftforge.common.BiomeManager.getBiomes(type)); + } + + public int m_8006_(Context p_76695_, int p_76696_) { +@@ -28,26 +_,39 @@ + return p_76695_.m_5826_(3) == 0 ? 39 : 38; + } + +- return this.f_76690_[p_76695_.m_5826_(this.f_76690_.length)]; ++ return getBiomeId(net.minecraftforge.common.BiomeManager.BiomeType.DESERT, p_76695_); + case 2: + if (i > 0) { + return 21; + } + +- return f_76687_[p_76695_.m_5826_(f_76687_.length)]; ++ return getBiomeId(net.minecraftforge.common.BiomeManager.BiomeType.WARM, p_76695_); + case 3: + if (i > 0) { + return 32; + } + +- return f_76688_[p_76695_.m_5826_(f_76688_.length)]; ++ return getBiomeId(net.minecraftforge.common.BiomeManager.BiomeType.COOL, p_76695_); + case 4: +- return f_76689_[p_76695_.m_5826_(f_76689_.length)]; ++ return getBiomeId(net.minecraftforge.common.BiomeManager.BiomeType.ICY, p_76695_); + default: + return 14; + } + } else { + return p_76696_; + } ++ } ++ ++ private int getBiomeId(net.minecraftforge.common.BiomeManager.BiomeType type, Context context) { ++ return net.minecraft.data.BuiltinRegistries.f_123865_.m_7447_( ++ net.minecraft.data.BuiltinRegistries.f_123865_.m_6246_(getBiome(type, context))); ++ } ++ protected net.minecraft.resources.ResourceKey getBiome(net.minecraftforge.common.BiomeManager.BiomeType type, Context context) { ++ if (type == net.minecraftforge.common.BiomeManager.BiomeType.DESERT && this.legacyDesert) ++ type = net.minecraftforge.common.BiomeManager.BiomeType.DESERT_LEGACY; ++ java.util.List biomeList = biomes[type.ordinal()]; ++ int totalWeight = net.minecraft.util.WeighedRandom.m_14470_(biomeList); ++ int weight = net.minecraftforge.common.BiomeManager.isTypeListModded(type) ? context.m_5826_(totalWeight) : context.m_5826_(totalWeight / 10) * 10; ++ return net.minecraft.util.WeighedRandom.m_145031_(biomeList, weight).get().getKey(); + } + } diff --git a/patches/minecraft/net/minecraft/pathfinding/PathNodeType.java.patch b/patches/minecraft/net/minecraft/world/level/pathfinder/BlockPathTypes.java.patch similarity index 59% rename from patches/minecraft/net/minecraft/pathfinding/PathNodeType.java.patch rename to patches/minecraft/net/minecraft/world/level/pathfinder/BlockPathTypes.java.patch index 06623f6f15..06eee22430 100644 --- a/patches/minecraft/net/minecraft/pathfinding/PathNodeType.java.patch +++ b/patches/minecraft/net/minecraft/world/level/pathfinder/BlockPathTypes.java.patch @@ -1,12 +1,12 @@ ---- a/net/minecraft/pathfinding/PathNodeType.java -+++ b/net/minecraft/pathfinding/PathNodeType.java -@@ -35,4 +_,13 @@ - public float func_186289_a() { - return this.field_186307_r; +--- a/net/minecraft/world/level/pathfinder/BlockPathTypes.java ++++ b/net/minecraft/world/level/pathfinder/BlockPathTypes.java +@@ -36,4 +_,13 @@ + public float m_77124_() { + return this.f_77117_; } + + @javax.annotation.Nullable -+ public PathNodeType getDanger() { ++ public BlockPathTypes getDanger() { + return (this == DAMAGE_FIRE || this == DANGER_FIRE ) ? DANGER_FIRE : + (this == DAMAGE_CACTUS || this == DANGER_CACTUS) ? DANGER_CACTUS : + (this == DAMAGE_OTHER || this == DANGER_OTHER ) ? DANGER_OTHER : diff --git a/patches/minecraft/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java.patch b/patches/minecraft/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java.patch new file mode 100644 index 0000000000..bfd88f8288 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java ++++ b/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java +@@ -472,6 +_,8 @@ + + protected static BlockPathTypes m_77643_(BlockGetter p_77644_, BlockPos p_77645_) { + BlockState blockstate = p_77644_.m_8055_(p_77645_); ++ BlockPathTypes type = blockstate.getAiPathNodeType(p_77644_, p_77645_); ++ if (type != null) return type; + Block block = blockstate.m_60734_(); + Material material = blockstate.m_60767_(); + if (blockstate.m_60795_()) { diff --git a/patches/minecraft/net/minecraft/world/level/portal/PortalForcer.java.patch b/patches/minecraft/net/minecraft/world/level/portal/PortalForcer.java.patch new file mode 100644 index 0000000000..26ccbe5c21 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/portal/PortalForcer.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/portal/PortalForcer.java ++++ b/net/minecraft/world/level/portal/PortalForcer.java +@@ -19,7 +_,7 @@ + import net.minecraft.world.level.border.WorldBorder; + import net.minecraft.world.level.levelgen.Heightmap; + +-public class PortalForcer { ++public class PortalForcer implements net.minecraftforge.common.util.ITeleporter { + private static final int f_164734_ = 3; + private static final int f_164735_ = 128; + private static final int f_164736_ = 16; diff --git a/patches/minecraft/net/minecraft/world/level/portal/PortalShape.java.patch b/patches/minecraft/net/minecraft/world/level/portal/PortalShape.java.patch new file mode 100644 index 0000000000..411d337509 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/portal/PortalShape.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/portal/PortalShape.java ++++ b/net/minecraft/world/level/portal/PortalShape.java +@@ -24,7 +_,7 @@ + private static final int f_164753_ = 3; + public static final int f_164751_ = 21; + private static final BlockBehaviour.StatePredicate f_77685_ = (p_77720_, p_77721_, p_77722_) -> { +- return p_77720_.m_60713_(Blocks.f_50080_); ++ return p_77720_.isPortalFrame(p_77721_, p_77722_); + }; + private final LevelAccessor f_77686_; + private final Direction.Axis f_77687_; diff --git a/patches/minecraft/net/minecraft/world/storage/MapDecoration.java.patch b/patches/minecraft/net/minecraft/world/level/saveddata/maps/MapDecoration.java.patch similarity index 60% rename from patches/minecraft/net/minecraft/world/storage/MapDecoration.java.patch rename to patches/minecraft/net/minecraft/world/level/saveddata/maps/MapDecoration.java.patch index 805b5e2e85..e1862ead65 100644 --- a/patches/minecraft/net/minecraft/world/storage/MapDecoration.java.patch +++ b/patches/minecraft/net/minecraft/world/level/saveddata/maps/MapDecoration.java.patch @@ -1,7 +1,7 @@ ---- a/net/minecraft/world/storage/MapDecoration.java -+++ b/net/minecraft/world/storage/MapDecoration.java -@@ -82,6 +_,16 @@ - return 31 * i + Objects.hashCode(this.field_204310_e); +--- 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_); } + /** @@ -9,11 +9,10 @@ + * @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 + */ -+ @OnlyIn(Dist.CLIENT) + public boolean render(int index) { + return false; + } + public static enum Type { - PLAYER(false), - FRAME(true), + 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 new file mode 100644 index 0000000000..9d3ede6cf6 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/storage/DimensionDataStorage.java.patch @@ -0,0 +1,16 @@ +--- a/net/minecraft/world/level/storage/DimensionDataStorage.java ++++ b/net/minecraft/world/level/storage/DimensionDataStorage.java +@@ -49,9 +_,13 @@ + @Nullable + public T m_164858_(Function p_164859_, 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_); + this.f_78144_.put(p_164860_, saveddata); ++ } else if (saveddata == null) { ++ this.f_78144_.put(p_164860_, net.minecraftforge.common.util.DummySavedData.DUMMY); ++ return null; + } + + return (T)saveddata; diff --git a/patches/minecraft/net/minecraft/world/level/storage/LevelStorageSource.java.patch b/patches/minecraft/net/minecraft/world/level/storage/LevelStorageSource.java.patch new file mode 100644 index 0000000000..0376b4c72c --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/storage/LevelStorageSource.java.patch @@ -0,0 +1,63 @@ +--- a/net/minecraft/world/level/storage/LevelStorageSource.java ++++ b/net/minecraft/world/level/storage/LevelStorageSource.java +@@ -94,7 +_,7 @@ + } + } + +- Dynamic dynamic1 = p_78206_.update(References.f_16795_, dynamic, p_78207_, SharedConstants.m_136187_().getWorldVersion()); ++ Dynamic dynamic1 = net.minecraftforge.common.ForgeHooks.fixUpDimensionsData(p_78206_.update(References.f_16795_, dynamic, p_78207_, SharedConstants.m_136187_().getWorldVersion())); + DataResult dataresult = WorldGenSettings.f_64600_.parse(dynamic1); + return Pair.of(dataresult.resultOrPartial(Util.m_137489_("WorldGenSettings: ", f_78191_::error)).orElseGet(() -> { + Registry registry = RegistryLookupCodec.m_135622_(Registry.f_122818_).codec().parse(dynamic1).resultOrPartial(Util.m_137489_("Dimension type registry: ", f_78191_::error)).orElseThrow(() -> { +@@ -191,6 +_,10 @@ + } + + static BiFunction m_78247_(DynamicOps p_78248_, DataPackConfig p_78249_) { ++ return getReader(p_78248_, p_78249_, null); ++ } ++ ++ private static BiFunction getReader(DynamicOps p_78248_, DataPackConfig p_78249_, @Nullable LevelStorageAccess levelSave) { + return (p_78214_, p_78215_) -> { + try { + CompoundTag compoundtag = NbtIo.m_128937_(p_78214_); +@@ -202,7 +_,10 @@ + Pair pair = m_78204_(dynamic, p_78215_, i); + LevelVersion levelversion = LevelVersion.m_78390_(dynamic); + LevelSettings levelsettings = LevelSettings.m_46924_(dynamic, p_78249_); +- return PrimaryLevelData.m_78530_(dynamic, p_78215_, i, compoundtag2, levelsettings, levelversion, pair.getFirst(), pair.getSecond()); ++ PrimaryLevelData info = PrimaryLevelData.m_78530_(dynamic, p_78215_, i, compoundtag2, levelsettings, levelversion, pair.getFirst(), pair.getSecond()); ++ if (levelSave != null) ++ net.minecraftforge.fmllegacy.WorldPersistenceHooks.handleWorldDataLoad(levelSave, info, compoundtag); ++ return info; + } catch (Exception exception) { + f_78191_.error("Exception reading {}", p_78214_, exception); + return null; +@@ -319,7 +_,7 @@ + @Nullable + public WorldData m_78280_(DynamicOps p_78281_, DataPackConfig p_78282_) { + this.m_78313_(); +- return LevelStorageSource.this.m_78229_(this.f_78271_.toFile(), LevelStorageSource.m_78247_(p_78281_, p_78282_)); ++ return LevelStorageSource.this.m_78229_(this.f_78271_.toFile(), LevelStorageSource.getReader(p_78281_, p_78282_, this)); + } + + @Nullable +@@ -338,6 +_,8 @@ + CompoundTag compoundtag1 = new CompoundTag(); + compoundtag1.m_128365_("Data", compoundtag); + ++ net.minecraftforge.fmllegacy.WorldPersistenceHooks.handleWorldDataSave(this, p_78292_, compoundtag1); ++ + try { + File file2 = File.createTempFile("level", ".dat", file1); + NbtIo.m_128944_(compoundtag1, file2); +@@ -352,6 +_,10 @@ + + public Optional m_182514_() { + return !this.f_78270_.m_13639_() ? Optional.empty() : Optional.of(this.f_78271_.resolve("icon.png")); ++ } ++ ++ public Path getWorldDir() { ++ return f_78271_; + } + + public void m_78311_() throws IOException { diff --git a/patches/minecraft/net/minecraft/world/level/storage/PlayerDataStorage.java.patch b/patches/minecraft/net/minecraft/world/level/storage/PlayerDataStorage.java.patch new file mode 100644 index 0000000000..521dd6bd3d --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/storage/PlayerDataStorage.java.patch @@ -0,0 +1,28 @@ +--- a/net/minecraft/world/level/storage/PlayerDataStorage.java ++++ b/net/minecraft/world/level/storage/PlayerDataStorage.java +@@ -31,6 +_,7 @@ + File file2 = new File(this.f_78427_, p_78434_.m_20149_() + ".dat"); + File file3 = new File(this.f_78427_, p_78434_.m_20149_() + ".dat_old"); + Util.m_137462_(file2, file1, file3); ++ net.minecraftforge.event.ForgeEventFactory.firePlayerSavingEvent(p_78434_, f_78427_, p_78434_.m_20149_()); + } catch (Exception exception) { + f_78426_.warn("Failed to save player data for {}", (Object)p_78434_.m_7755_().getString()); + } +@@ -54,6 +_,7 @@ + int i = compoundtag.m_128425_("DataVersion", 3) ? compoundtag.m_128451_("DataVersion") : -1; + p_78436_.m_20258_(NbtUtils.m_129213_(this.f_78425_, DataFixTypes.PLAYER, compoundtag, i)); + } ++ net.minecraftforge.event.ForgeEventFactory.firePlayerLoadingEvent(p_78436_, f_78427_, p_78436_.m_20149_()); + + return compoundtag; + } +@@ -71,5 +_,9 @@ + } + + return astring; ++ } ++ ++ public File getPlayerDataFolder() { ++ return f_78427_; + } + } 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 new file mode 100644 index 0000000000..15cd263cc2 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/storage/loot/LootContext.java.patch @@ -0,0 +1,68 @@ +--- a/net/minecraft/world/level/storage/loot/LootContext.java ++++ b/net/minecraft/world/level/storage/loot/LootContext.java +@@ -107,17 +_,47 @@ + return this.f_78909_; + } + ++ // ============================== FORGE START ============================== ++ public int getLootingModifier() { ++ return net.minecraftforge.common.ForgeHooks.getLootingLevel(m_78953_(LootContextParams.f_81455_), m_78953_(LootContextParams.f_81458_), m_78953_(LootContextParams.f_81457_)); ++ } ++ ++ private ResourceLocation queriedLootTableId; ++ ++ private LootContext(Random rand, float luckIn, ServerLevel worldIn, Function lootTableManagerIn, Function p_i225885_5_, Map, Object> parametersIn, Map conditionsIn, ResourceLocation queriedLootTableId) { ++ this(rand, luckIn, worldIn, lootTableManagerIn, p_i225885_5_, parametersIn, conditionsIn); ++ if (queriedLootTableId != null) this.queriedLootTableId = queriedLootTableId; ++ } ++ ++ public void setQueriedLootTableId(ResourceLocation queriedLootTableId) { ++ if (this.queriedLootTableId == null && queriedLootTableId != null) this.queriedLootTableId = queriedLootTableId; ++ } ++ public ResourceLocation getQueriedLootTableId() { ++ return this.queriedLootTableId == null? net.minecraftforge.common.loot.LootTableIdCondition.UNKNOWN_LOOT_TABLE : this.queriedLootTableId; ++ } ++ // =============================== FORGE END =============================== ++ + public static class Builder { + private final ServerLevel f_78955_; + private final Map, Object> f_78956_ = Maps.newIdentityHashMap(); + private final Map f_78957_ = Maps.newHashMap(); + private Random f_78958_; + private float f_78959_; ++ private ResourceLocation queriedLootTableId; // Forge: correctly pass around loot table ID with copy constructor + + public Builder(ServerLevel p_78961_) { + this.f_78955_ = p_78961_; + } + ++ public Builder(LootContext context) { ++ this.f_78955_ = context.f_78909_; ++ this.f_78956_.putAll(context.f_78914_); ++ this.f_78957_.putAll(context.f_78915_); ++ this.f_78958_ = context.f_78907_; ++ this.f_78959_ = context.f_78908_; ++ this.queriedLootTableId = context.queriedLootTableId; ++ } ++ + public LootContext.Builder m_78977_(Random p_78978_) { + this.f_78958_ = p_78978_; + return this; +@@ -190,7 +_,7 @@ + + public LootContext m_78975_(LootContextParamSet p_78976_) { + Set> set = Sets.difference(this.f_78956_.keySet(), p_78976_.m_81398_()); +- if (!set.isEmpty()) { ++ if (false && !set.isEmpty()) { // Forge: Allow mods to pass custom loot parameters (not part of the vanilla loot table) to the loot context. + throw new IllegalArgumentException("Parameters not allowed in this parameter set: " + set); + } else { + Set> set1 = Sets.difference(p_78976_.m_81394_(), this.f_78956_.keySet()); +@@ -203,7 +_,7 @@ + } + + MinecraftServer minecraftserver = this.f_78955_.m_142572_(); +- return new LootContext(random, this.f_78959_, this.f_78955_, minecraftserver.m_129898_()::m_79217_, minecraftserver.m_129899_()::m_79252_, this.f_78956_, this.f_78957_); ++ return new LootContext(random, this.f_78959_, this.f_78955_, minecraftserver.m_129898_()::m_79217_, minecraftserver.m_129899_()::m_79252_, this.f_78956_, this.f_78957_, this.queriedLootTableId); + } + } + } 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 new file mode 100644 index 0000000000..c113ddda6b --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/storage/loot/LootPool.java.patch @@ -0,0 +1,123 @@ +--- a/net/minecraft/world/level/storage/loot/LootPool.java ++++ b/net/minecraft/world/level/storage/loot/LootPool.java +@@ -31,17 +_,19 @@ + import org.apache.commons.lang3.mutable.MutableInt; + + public class LootPool { +- final LootPoolEntryContainer[] f_79023_; +- final LootItemCondition[] f_79024_; ++ private final String name; ++ private final List f_79023_; ++ private final List f_79024_; + private final Predicate f_79025_; + final LootItemFunction[] f_79026_; + private final BiFunction f_79027_; + NumberProvider f_79028_; + NumberProvider f_79029_; + +- LootPool(LootPoolEntryContainer[] p_165128_, LootItemCondition[] p_165129_, LootItemFunction[] p_165130_, NumberProvider p_165131_, NumberProvider p_165132_) { +- this.f_79023_ = p_165128_; +- this.f_79024_ = p_165129_; ++ private LootPool(LootPoolEntryContainer[] p_165128_, LootItemCondition[] p_165129_, LootItemFunction[] p_165130_, NumberProvider p_165131_, NumberProvider p_165132_, String name) { ++ this.name = name; ++ this.f_79023_ = Lists.newArrayList(p_165128_); ++ this.f_79024_ = Lists.newArrayList(p_165129_); + this.f_79025_ = LootItemConditions.m_81834_(p_165129_); + this.f_79026_ = p_165130_; + this.f_79027_ = LootItemFunctions.m_80770_(p_165130_); +@@ -97,21 +_,35 @@ + } + + public void m_79051_(ValidationContext p_79052_) { +- for(int i = 0; i < this.f_79024_.length; ++i) { +- this.f_79024_[i].m_6169_(p_79052_.m_79365_(".condition[" + i + "]")); ++ for(int i = 0; i < this.f_79024_.size(); ++i) { ++ this.f_79024_.get(i).m_6169_(p_79052_.m_79365_(".condition[" + i + "]")); + } + + for(int j = 0; j < this.f_79026_.length; ++j) { + this.f_79026_[j].m_6169_(p_79052_.m_79365_(".functions[" + j + "]")); + } + +- for(int k = 0; k < this.f_79023_.length; ++k) { +- this.f_79023_[k].m_6165_(p_79052_.m_79365_(".entries[" + k + "]")); ++ for(int k = 0; k < this.f_79023_.size(); ++k) { ++ this.f_79023_.get(k).m_6165_(p_79052_.m_79365_(".entries[" + k + "]")); + } + + 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!"); ++ } ++ 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 +_,21 @@ + return this; + } + ++ public LootPool.Builder name(String name) { ++ this.name = name; ++ return this; ++ } ++ ++ public LootPool.Builder bonusRolls(float min, float max) { ++ this.f_79071_ = net.minecraft.world.level.storage.loot.providers.number.UniformGenerator.m_165780_(min, max); ++ 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,19 +_,21 @@ + 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_)); +- if (!ArrayUtils.isEmpty((Object[])p_79094_.f_79024_)) { ++ if (!p_79094_.f_79024_.isEmpty()) { + jsonobject.add("conditions", p_79096_.serialize(p_79094_.f_79024_)); + } + +- if (!ArrayUtils.isEmpty((Object[])p_79094_.f_79026_)) { ++ if (!p_79094_.f_79024_.isEmpty()) { + jsonobject.add("functions", p_79096_.serialize(p_79094_.f_79026_)); + } + 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 new file mode 100644 index 0000000000..b01635d5ee --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/storage/loot/LootTable.java.patch @@ -0,0 +1,103 @@ +--- a/net/minecraft/world/level/storage/loot/LootTable.java ++++ b/net/minecraft/world/level/storage/loot/LootTable.java +@@ -34,13 +_,13 @@ + public static final LootTable f_79105_ = new LootTable(LootContextParamSets.f_81410_, new LootPool[0], new LootItemFunction[0]); + public static final LootContextParamSet f_79106_ = LootContextParamSets.f_81420_; + final LootContextParamSet f_79108_; +- final LootPool[] f_79109_; ++ private final List f_79109_; + final LootItemFunction[] f_79110_; + private final BiFunction f_79111_; + + LootTable(LootContextParamSet p_79114_, LootPool[] p_79115_, LootItemFunction[] p_79116_) { + this.f_79108_ = p_79114_; +- this.f_79109_ = p_79115_; ++ this.f_79109_ = Lists.newArrayList(p_79115_); + this.f_79110_ = p_79116_; + this.f_79111_ = LootItemFunctions.m_80770_(p_79116_); + } +@@ -78,6 +_,7 @@ + + } + ++ @Deprecated //Use other method or manually call ForgeHooks.modifyLoot + public void m_79148_(LootContext p_79149_, Consumer p_79150_) { + this.m_79131_(p_79149_, m_79142_(p_79150_)); + } +@@ -85,6 +_,7 @@ + public List m_79129_(LootContext p_79130_) { + List list = Lists.newArrayList(); + this.m_79148_(p_79130_, list::add); ++ list = net.minecraftforge.common.ForgeHooks.modifyLoot(this.getLootTableId(), list, p_79130_); + return list; + } + +@@ -93,8 +_,8 @@ + } + + 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) { +@@ -176,6 +_,48 @@ + 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"); ++ this.lootTableId = java.util.Objects.requireNonNull(id); ++ } ++ public ResourceLocation getLootTableId() { return this.lootTableId; } ++ ++ public LootPool getPool(String name) { ++ return f_79109_.stream().filter(e -> name.equals(e.getName())).findFirst().orElse(null); ++ } ++ ++ 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 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()); ++ 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(); +@@ -230,7 +_,7 @@ + } + } + +- 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/LootTables.java.patch b/patches/minecraft/net/minecraft/world/level/storage/loot/LootTables.java.patch new file mode 100644 index 0000000000..58e4903373 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/storage/loot/LootTables.java.patch @@ -0,0 +1,13 @@ +--- a/net/minecraft/world/level/storage/loot/LootTables.java ++++ b/net/minecraft/world/level/storage/loot/LootTables.java +@@ -37,8 +_,8 @@ + } + + p_79214_.forEach((p_79198_, p_79199_) -> { +- try { +- LootTable loottable = f_79189_.fromJson(p_79199_, LootTable.class); ++ try (net.minecraft.server.packs.resources.Resource res = p_79215_.m_142591_(getPreparedPath(p_79198_));){ ++ LootTable loottable = net.minecraftforge.common.ForgeHooks.loadLootTable(f_79189_, p_79198_, p_79199_, res == null || !res.m_7816_().equals("Default"), this); + builder.put(p_79198_, loottable); + } catch (Exception exception) { + f_79188_.error("Couldn't parse loot table {}", p_79198_, exception); 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 new file mode 100644 index 0000000000..2ad7438b0c --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/storage/loot/functions/LootingEnchantFunction.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/storage/loot/functions/LootingEnchantFunction.java ++++ b/net/minecraft/world/level/storage/loot/functions/LootingEnchantFunction.java +@@ -43,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) { +- int i = EnchantmentHelper.m_44930_((LivingEntity)entity); ++ int i = p_80790_.getLootingModifier(); + if (i == 0) { + return p_80789_; + } 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 new file mode 100644 index 0000000000..a866765cbf --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/storage/loot/functions/SmeltItemFunction.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/storage/loot/functions/SmeltItemFunction.java ++++ b/net/minecraft/world/level/storage/loot/functions/SmeltItemFunction.java +@@ -32,7 +_,7 @@ + ItemStack itemstack = optional.get().m_8043_(); + if (!itemstack.m_41619_()) { + ItemStack itemstack1 = itemstack.m_41777_(); +- itemstack1.m_41764_(p_81268_.m_41613_()); ++ itemstack1.m_41764_(p_81268_.m_41613_() * itemstack.m_41613_()); //Forge: Support smelting returning multiple + return itemstack1; + } + } 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 new file mode 100644 index 0000000000..325d5fbe68 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/storage/loot/parameters/LootContextParamSets.java.patch @@ -0,0 +1,18 @@ +--- a/net/minecraft/world/level/storage/loot/parameters/LootContextParamSets.java ++++ b/net/minecraft/world/level/storage/loot/parameters/LootContextParamSets.java +@@ -12,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_); ++ p_81452_.m_81408_(LootContextParams.f_81458_); //Forge: Chest Minecarts can have killers. + }); + 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 @@ + }); + 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_); ++ p_81446_.m_81408_(LootContextParams.f_81458_).m_81408_(LootContextParams.f_81455_); //Forge: Allow fisher, and bobber + }); + public static final LootContextParamSet f_81415_ = m_81428_("entity", (p_81444_) -> { + p_81444_.m_81406_(LootContextParams.f_81455_).m_81406_(LootContextParams.f_81460_).m_81406_(LootContextParams.f_81457_).m_81408_(LootContextParams.f_81458_).m_81408_(LootContextParams.f_81459_).m_81408_(LootContextParams.f_81456_); diff --git a/patches/minecraft/net/minecraft/world/level/storage/loot/predicates/LootItemRandomChanceCondition.java.patch b/patches/minecraft/net/minecraft/world/level/storage/loot/predicates/LootItemRandomChanceCondition.java.patch new file mode 100644 index 0000000000..41870a99cc --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/storage/loot/predicates/LootItemRandomChanceCondition.java.patch @@ -0,0 +1,12 @@ +--- a/net/minecraft/world/level/storage/loot/predicates/LootItemRandomChanceCondition.java ++++ b/net/minecraft/world/level/storage/loot/predicates/LootItemRandomChanceCondition.java +@@ -18,7 +_,8 @@ + } + + public boolean test(LootContext p_81930_) { +- return p_81930_.m_78933_().nextFloat() < this.f_81921_; ++ int i = p_81930_.getLootingModifier(); ++ return p_81930_.m_78933_().nextFloat() < this.f_81921_ + (float) i; + } + + public static LootItemCondition.Builder m_81927_(float p_81928_) { 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 new file mode 100644 index 0000000000..ccb805ee97 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/storage/loot/predicates/LootItemRandomChanceWithLootingCondition.java.patch @@ -0,0 +1,16 @@ +--- a/net/minecraft/world/level/storage/loot/predicates/LootItemRandomChanceWithLootingCondition.java ++++ b/net/minecraft/world/level/storage/loot/predicates/LootItemRandomChanceWithLootingCondition.java +@@ -31,12 +_,7 @@ + } + + public boolean test(LootContext p_81967_) { +- Entity entity = p_81967_.m_78953_(LootContextParams.f_81458_); +- int i = 0; +- if (entity instanceof LivingEntity) { +- i = EnchantmentHelper.m_44930_((LivingEntity)entity); +- } +- ++ int i = p_81967_.getLootingModifier(); + return p_81967_.m_78933_().nextFloat() < this.f_81953_ + (float)i * this.f_81954_; + } + diff --git a/patches/minecraft/net/minecraft/world/lighting/BlockLightEngine.java.patch b/patches/minecraft/net/minecraft/world/lighting/BlockLightEngine.java.patch deleted file mode 100644 index 4988318e4c..0000000000 --- a/patches/minecraft/net/minecraft/world/lighting/BlockLightEngine.java.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/net/minecraft/world/lighting/BlockLightEngine.java -+++ b/net/minecraft/world/lighting/BlockLightEngine.java -@@ -117,4 +_,9 @@ - this.field_215627_c.func_215532_c(); - this.func_215469_a(Long.MAX_VALUE, p_215623_1_.func_218275_a(), 15 - p_215623_2_, true); - } -+ -+ @Override -+ public int queuedUpdateSize() { -+ return field_215627_c.queuedUpdateSize(); -+ } - } diff --git a/patches/minecraft/net/minecraft/world/lighting/LevelBasedGraph.java.patch b/patches/minecraft/net/minecraft/world/lighting/LevelBasedGraph.java.patch deleted file mode 100644 index 0f89ba8110..0000000000 --- a/patches/minecraft/net/minecraft/world/lighting/LevelBasedGraph.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/lighting/LevelBasedGraph.java -+++ b/net/minecraft/world/lighting/LevelBasedGraph.java -@@ -228,4 +_,8 @@ - protected abstract void func_215476_a(long p_215476_1_, int p_215476_3_); - - protected abstract int func_215480_b(long p_215480_1_, long p_215480_3_, int p_215480_5_); -+ -+ protected int queuedUpdateSize() { -+ return field_215488_c.size(); -+ } - } diff --git a/patches/minecraft/net/minecraft/world/lighting/LightEngine.java.patch b/patches/minecraft/net/minecraft/world/lighting/LightEngine.java.patch deleted file mode 100644 index b249d6afcf..0000000000 --- a/patches/minecraft/net/minecraft/world/lighting/LightEngine.java.patch +++ /dev/null @@ -1,9 +0,0 @@ ---- a/net/minecraft/world/lighting/LightEngine.java -+++ b/net/minecraft/world/lighting/LightEngine.java -@@ -215,4 +_,6 @@ - long i = SectionPos.func_218169_f(SectionPos.func_218166_b(p_223129_1_.field_77276_a, 0, p_223129_1_.field_77275_b)); - this.field_215627_c.func_223113_c(i, p_223129_2_); - } -+ -+ public abstract int queuedUpdateSize(); - } diff --git a/patches/minecraft/net/minecraft/world/lighting/SkyLightEngine.java.patch b/patches/minecraft/net/minecraft/world/lighting/SkyLightEngine.java.patch deleted file mode 100644 index aa204fb518..0000000000 --- a/patches/minecraft/net/minecraft/world/lighting/SkyLightEngine.java.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/net/minecraft/world/lighting/SkyLightEngine.java -+++ b/net/minecraft/world/lighting/SkyLightEngine.java -@@ -228,4 +_,9 @@ - public String func_215614_b(long p_215614_1_) { - return super.func_215614_b(p_215614_1_) + (this.field_215627_c.func_215549_m(p_215614_1_) ? "*" : ""); - } -+ -+ @Override -+ public int queuedUpdateSize() { -+ return 0; -+ } - } diff --git a/patches/minecraft/net/minecraft/world/raid/Raid.java.patch b/patches/minecraft/net/minecraft/world/raid/Raid.java.patch deleted file mode 100644 index bb2fd3cfce..0000000000 --- a/patches/minecraft/net/minecraft/world/raid/Raid.java.patch +++ /dev/null @@ -1,32 +0,0 @@ ---- a/net/minecraft/world/raid/Raid.java -+++ b/net/minecraft/world/raid/Raid.java -@@ -769,7 +_,7 @@ - } - } - -- static enum WaveMember { -+ public static enum WaveMember implements net.minecraftforge.common.IExtensibleEnum { - VINDICATOR(EntityType.field_200758_ax, new int[]{0, 0, 2, 0, 1, 4, 2, 5}), - EVOKER(EntityType.field_200806_t, new int[]{0, 0, 0, 0, 0, 1, 1, 2}), - PILLAGER(EntityType.field_220350_aJ, new int[]{0, 4, 3, 3, 4, 4, 4, 2}), -@@ -783,6 +_,20 @@ - private WaveMember(EntityType p_i50602_3_, int[] p_i50602_4_) { - this.field_221285_g = p_i50602_3_; - this.field_221286_h = p_i50602_4_; -+ } -+ -+ /** -+ * The waveCountsIn integer decides how many entities of the EntityType defined in typeIn will spawn in each wave. -+ * For example, one ravager will always spawn in wave 3. -+ */ -+ public static WaveMember create(String name, EntityType typeIn, int[] waveCountsIn) { -+ throw new IllegalStateException("Enum not extended"); -+ } -+ -+ @Override -+ @Deprecated -+ public void init() { -+ field_221284_f = values(); - } - } - } diff --git a/patches/minecraft/net/minecraft/world/server/ChunkHolder.java.patch b/patches/minecraft/net/minecraft/world/server/ChunkHolder.java.patch deleted file mode 100644 index b849ab774f..0000000000 --- a/patches/minecraft/net/minecraft/world/server/ChunkHolder.java.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- a/net/minecraft/world/server/ChunkHolder.java -+++ b/net/minecraft/world/server/ChunkHolder.java -@@ -61,6 +_,7 @@ - private final ChunkHolder.IPlayerProvider field_219328_w; - private boolean field_219329_x; - private boolean field_244384_x; -+ Chunk currentlyLoading; //Forge - Used to bypass future chain when loading chunks. - - public ChunkHolder(ChunkPos p_i50716_1_, int p_i50716_2_, WorldLightManager p_i50716_3_, ChunkHolder.IListener p_i50716_4_, ChunkHolder.IPlayerProvider p_i50716_5_) { - this.field_219319_n = p_i50716_1_; -@@ -204,7 +_,7 @@ - } - - private void func_244385_a(World p_244385_1_, BlockPos p_244385_2_, BlockState p_244385_3_) { -- if (p_244385_3_.func_177230_c().func_235695_q_()) { -+ if (p_244385_3_.hasTileEntity()) { - this.func_219305_a(p_244385_1_, p_244385_2_); - } - diff --git a/patches/minecraft/net/minecraft/world/server/ChunkManager.java.patch b/patches/minecraft/net/minecraft/world/server/ChunkManager.java.patch deleted file mode 100644 index b1469b0a67..0000000000 --- a/patches/minecraft/net/minecraft/world/server/ChunkManager.java.patch +++ /dev/null @@ -1,55 +0,0 @@ ---- a/net/minecraft/world/server/ChunkManager.java -+++ b/net/minecraft/world/server/ChunkManager.java -@@ -400,6 +_,7 @@ - if (this.field_219253_g.remove(p_219212_1_, p_219212_3_) && p_219185_5_ != null) { - if (p_219185_5_ instanceof Chunk) { - ((Chunk)p_219185_5_).func_177417_c(false); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.ChunkEvent.Unload((Chunk)p_219185_5_)); - } - - this.func_219229_a(p_219185_5_); -@@ -581,6 +_,8 @@ - chunk.func_217318_w(); - if (this.field_219254_h.add(chunkpos.func_201841_a())) { - chunk.func_177417_c(true); -+ try { -+ p_219200_1_.currentlyLoading = chunk; //Forge - bypass the future chain when getChunk is called, this prevents deadlocks. - this.field_219255_i.func_147448_a(chunk.func_177434_r().values()); - List list = null; - ClassInheritanceMultiMap[] aclassinheritancemultimap = chunk.func_177429_s(); -@@ -601,6 +_,10 @@ - if (list != null) { - list.forEach(chunk::func_76622_b); - } -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.ChunkEvent.Load(chunk)); -+ } finally { -+ p_219200_1_.currentlyLoading = null;//Forge - Stop bypassing the future chain. -+ } - } - - return chunk; -@@ -678,6 +_,7 @@ - - this.field_219255_i.func_217381_Z().func_230035_c_("chunkSave"); - CompoundNBT compoundnbt = ChunkSerializer.func_222645_a(this.field_219255_i, p_219229_1_); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.ChunkDataEvent.Save(p_219229_1_, p_219229_1_.getWorldForge() != null ? p_219229_1_.getWorldForge() : this.field_219255_i, compoundnbt)); - this.func_219100_a(chunkpos, compoundnbt); - this.func_241088_a_(chunkpos, chunkstatus.func_202129_d()); - return true; -@@ -734,6 +_,7 @@ - - protected void func_219199_a(ServerPlayerEntity p_219199_1_, ChunkPos p_219199_2_, IPacket[] p_219199_3_, boolean p_219199_4_, boolean p_219199_5_) { - if (p_219199_1_.field_70170_p == this.field_219255_i) { -+ net.minecraftforge.event.ForgeEventFactory.fireChunkWatch(p_219199_4_, p_219199_5_, p_219199_1_, p_219199_2_, this.field_219255_i); - if (p_219199_5_ && !p_219199_4_) { - ChunkHolder chunkholder = this.func_219219_b(p_219199_2_.func_201841_a()); - if (chunkholder != null) { -@@ -942,7 +_,7 @@ - } - - protected void func_219210_a(Entity p_219210_1_) { -- if (!(p_219210_1_ instanceof EnderDragonPartEntity)) { -+ if (!(p_219210_1_ instanceof net.minecraftforge.entity.PartEntity)) { - EntityType entitytype = p_219210_1_.func_200600_R(); - int i = entitytype.func_233602_m_() * 16; - int j = entitytype.func_220332_l(); diff --git a/patches/minecraft/net/minecraft/world/server/ServerChunkProvider.java.patch b/patches/minecraft/net/minecraft/world/server/ServerChunkProvider.java.patch deleted file mode 100644 index 454d9966ea..0000000000 --- a/patches/minecraft/net/minecraft/world/server/ServerChunkProvider.java.patch +++ /dev/null @@ -1,38 +0,0 @@ ---- a/net/minecraft/world/server/ServerChunkProvider.java -+++ b/net/minecraft/world/server/ServerChunkProvider.java -@@ -125,6 +_,11 @@ - } - } - -+ ChunkHolder chunkholder = this.func_217213_a(i); -+ if (chunkholder != null && chunkholder.currentlyLoading != null) { -+ return chunkholder.currentlyLoading; //Forge - If the requested chunk is loading, bypass the future chain to prevent a deadlock. -+ } -+ - iprofiler.func_230035_c_("getChunkCacheMiss"); - CompletableFuture> completablefuture = this.func_217233_c(p_212849_1_, p_212849_2_, p_212849_3_, p_212849_4_); - this.field_217243_i.func_213161_c(completablefuture::isDone); -@@ -353,7 +_,7 @@ - if (optional1.isPresent()) { - Chunk chunk = optional1.get(); - ChunkPos chunkpos = p_241099_7_.func_219277_h(); -- if (!this.field_217237_a.func_219243_d(chunkpos)) { -+ if (!this.field_217237_a.func_219243_d(chunkpos) || field_217237_a.func_219246_e().shouldForceTicks(chunkpos.func_201841_a())) { - chunk.func_177415_c(chunk.func_177416_w() + j); - if (flag1 && (this.field_217246_l || this.field_217247_m) && this.field_73251_h.func_175723_af().func_177730_a(chunk.func_76632_l())) { - WorldEntitySpawner.func_234979_a_(this.field_73251_h, chunk, worldentityspawner$entitydensitymanager, this.field_217247_m, this.field_217246_l, flag2); -@@ -427,6 +_,14 @@ - - public void func_217222_b(TicketType p_217222_1_, ChunkPos p_217222_2_, int p_217222_3_, T p_217222_4_) { - this.field_217240_d.func_219362_d(p_217222_1_, p_217222_2_, p_217222_3_, p_217222_4_); -+ } -+ -+ public void registerTickingTicket(TicketType type, ChunkPos pos, int distance, T value) { -+ this.field_217240_d.registerTicking(type, pos, distance, value); -+ } -+ -+ public void releaseTickingTicket(TicketType type, ChunkPos pos, int distance, T value) { -+ this.field_217240_d.releaseTicking(type, pos, distance, value); - } - - public void func_217206_a(ChunkPos p_217206_1_, boolean p_217206_2_) { diff --git a/patches/minecraft/net/minecraft/world/server/ServerWorld.java.patch b/patches/minecraft/net/minecraft/world/server/ServerWorld.java.patch deleted file mode 100644 index a1d2e838d8..0000000000 --- a/patches/minecraft/net/minecraft/world/server/ServerWorld.java.patch +++ /dev/null @@ -1,261 +0,0 @@ ---- a/net/minecraft/world/server/ServerWorld.java -+++ b/net/minecraft/world/server/ServerWorld.java -@@ -143,7 +_,7 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; - --public class ServerWorld extends World implements ISeedReader { -+public class ServerWorld extends World implements ISeedReader, net.minecraftforge.common.extensions.IForgeWorldServer { - public static final BlockPos field_241108_a_ = new BlockPos(100, 50, 0); - private static final Logger field_147491_a = LogManager.getLogger(); - private final Int2ObjectMap field_217498_x = new Int2ObjectLinkedOpenHashMap<>(); -@@ -173,6 +_,7 @@ - private final DragonFightManager field_241105_O_; - private final StructureManager field_241106_P_; - private final boolean field_241107_Q_; -+ private net.minecraftforge.common.util.WorldCapabilityData capabilityData; - - public ServerWorld(MinecraftServer p_i241885_1_, Executor p_i241885_2_, SaveFormat.LevelSave p_i241885_3_, IServerWorldInfo p_i241885_4_, RegistryKey p_i241885_5_, DimensionType p_i241885_6_, IChunkStatusListener p_i241885_7_, ChunkGenerator p_i241885_8_, boolean p_i241885_9_, long p_i241885_10_, List p_i241885_12_, boolean p_i241885_13_) { - super(p_i241885_4_, p_i241885_5_, p_i241885_6_, p_i241885_1_::func_213185_aS, false, p_i241885_9_, p_i241885_10_); -@@ -200,7 +_,7 @@ - } else { - this.field_241105_O_ = null; - } -- -+ this.initCapabilities(); - } - - public void func_241113_a_(int p_241113_1_, int p_241113_2_, boolean p_241113_3_, boolean p_241113_4_) { -@@ -296,15 +_,19 @@ - this.field_73061_a.func_184103_al().func_232642_a_(new SChangeGameStatePacket(SChangeGameStatePacket.field_241772_i_, this.field_73017_q), this.func_234923_W_()); - } - -+ /* The function in use here has been replaced in order to only send the weather info to players in the correct dimension, -+ * rather than to all players on the server. This is what causes the client-side rain, as the -+ * client believes that it has started raining locally, rather than in another dimension. -+ */ - if (flag != this.func_72896_J()) { - if (flag) { -- this.field_73061_a.func_184103_al().func_148540_a(new SChangeGameStatePacket(SChangeGameStatePacket.field_241766_c_, 0.0F)); -+ this.field_73061_a.func_184103_al().func_232642_a_(new SChangeGameStatePacket(SChangeGameStatePacket.field_241766_c_, 0.0F), this.func_234923_W_()); - } else { -- this.field_73061_a.func_184103_al().func_148540_a(new SChangeGameStatePacket(SChangeGameStatePacket.field_241765_b_, 0.0F)); -+ this.field_73061_a.func_184103_al().func_232642_a_(new SChangeGameStatePacket(SChangeGameStatePacket.field_241765_b_, 0.0F), this.func_234923_W_()); - } - -- this.field_73061_a.func_184103_al().func_148540_a(new SChangeGameStatePacket(SChangeGameStatePacket.field_241771_h_, this.field_73004_o)); -- this.field_73061_a.func_184103_al().func_148540_a(new SChangeGameStatePacket(SChangeGameStatePacket.field_241772_i_, this.field_73017_q)); -+ this.field_73061_a.func_184103_al().func_232642_a_(new SChangeGameStatePacket(SChangeGameStatePacket.field_241771_h_, this.field_73004_o), this.func_234923_W_()); -+ this.field_73061_a.func_184103_al().func_232642_a_(new SChangeGameStatePacket(SChangeGameStatePacket.field_241772_i_, this.field_73017_q), this.func_234923_W_()); - } - - if (this.field_73068_P && this.field_217491_A.stream().noneMatch((p_241132_0_) -> { -@@ -312,8 +_,8 @@ - })) { - this.field_73068_P = false; - if (this.func_82736_K().func_223586_b(GameRules.field_223607_j)) { -- long l = this.field_72986_A.func_76073_f() + 24000L; -- this.func_241114_a_(l - l % 24000L); -+ long l = this.func_72820_D() + 24000L; -+ this.func_241114_a_(net.minecraftforge.event.ForgeEventFactory.onSleepFinished(this, l - l % 24000L, this.func_72820_D())); - } - - this.func_229856_ab_(); -@@ -338,7 +_,7 @@ - this.func_147488_Z(); - this.field_211159_Q = false; - iprofiler.func_219895_b("entities"); -- boolean flag3 = !this.field_217491_A.isEmpty() || !this.func_217469_z().isEmpty(); -+ boolean flag3 = !this.field_217491_A.isEmpty() || net.minecraftforge.common.world.ForgeChunkManager.hasForcedChunks(this); //Forge: Replace vanilla's has forced chunk check with forge's that checks both the vanilla and forge added ones - if (flag3) { - this.func_82742_i(); - } -@@ -395,7 +_,7 @@ - } - - iprofiler.func_76320_a("tick"); -- if (!entity1.field_70128_L && !(entity1 instanceof EnderDragonPartEntity)) { -+ if (!entity1.field_70128_L && !(entity1 instanceof net.minecraftforge.entity.PartEntity)) { - this.func_217390_a(this::func_217479_a, entity1); - } - -@@ -404,7 +_,7 @@ - if (entity1.field_70128_L) { - this.func_217454_n(entity1); - objectiterator.remove(); -- this.func_217484_g(entity1); -+ this.removeEntityComplete(entity1, entity1 instanceof ServerPlayerEntity); //Forge: Keep cap data until revive. Every other entity removes directly. - } - - iprofiler.func_76319_b(); -@@ -475,6 +_,7 @@ - BlockPos blockpos2 = this.func_205770_a(Heightmap.Type.MOTION_BLOCKING, this.func_217383_a(i, 0, j, 15)); - BlockPos blockpos3 = blockpos2.func_177977_b(); - Biome biome = this.func_226691_t_(blockpos2); -+ if (this.isAreaLoaded(blockpos2, 1)) // Forge: check area to avoid loading neighbors in unloaded chunks - if (biome.func_201848_a(this, blockpos3)) { - this.func_175656_a(blockpos3, Blocks.field_150432_aD.func_176223_P()); - } -@@ -598,9 +_,10 @@ - ++p_217479_1_.field_70173_aa; - IProfiler iprofiler = this.func_217381_Z(); - iprofiler.func_194340_a(() -> { -- return Registry.field_212629_r.func_177774_c(p_217479_1_.func_200600_R()).toString(); -+ return p_217479_1_.func_200600_R().getRegistryName() == null ? p_217479_1_.func_200600_R().toString() : p_217479_1_.func_200600_R().getRegistryName().toString(); - }); - iprofiler.func_230035_c_("tickNonPassenger"); -+ if (p_217479_1_.canUpdate()) - p_217479_1_.func_70071_h_(); - iprofiler.func_76319_b(); - } -@@ -687,6 +_,7 @@ - p_217445_1_.func_200209_c(new TranslationTextComponent("menu.savingChunks")); - } - -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Save(this)); - serverchunkprovider.func_217210_a(p_217445_2_); - } - } -@@ -777,6 +_,7 @@ - } - - private void func_217448_f(ServerPlayerEntity p_217448_1_) { -+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityJoinWorldEvent(p_217448_1_, this))) return; - Entity entity = this.field_175741_N.get(p_217448_1_.func_110124_au()); - if (entity != null) { - field_147491_a.warn("Force-added player with duplicate UUID {}", (Object)p_217448_1_.func_110124_au().toString()); -@@ -801,6 +_,7 @@ - } else if (this.func_217478_l(p_72838_1_)) { - return false; - } else { -+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityJoinWorldEvent(p_72838_1_, this))) return false; - IChunk ichunk = this.func_217353_a(MathHelper.func_76128_c(p_72838_1_.func_226277_ct_() / 16.0D), MathHelper.func_76128_c(p_72838_1_.func_226281_cx_() / 16.0D), ChunkStatus.field_222617_m, p_72838_1_.field_98038_p); - if (!(ichunk instanceof Chunk)) { - return false; -@@ -816,6 +_,7 @@ - if (this.func_217478_l(p_217440_1_)) { - return false; - } else { -+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityJoinWorldEvent(p_217440_1_, this))) return false; - this.func_217465_m(p_217440_1_); - return true; - } -@@ -879,10 +_,14 @@ - - } - -+ @Deprecated //Forge: Use removeEntityComplete(entity,boolean) - public void func_217484_g(Entity p_217484_1_) { -- if (p_217484_1_ instanceof EnderDragonEntity) { -- for(EnderDragonPartEntity enderdragonpartentity : ((EnderDragonEntity)p_217484_1_).func_213404_dT()) { -- enderdragonpartentity.func_70106_y(); -+ removeEntityComplete(p_217484_1_, false); -+ } -+ public void removeEntityComplete(Entity p_217484_1_, boolean keepData) { -+ if (p_217484_1_.isMultipartEntity()) { -+ for(net.minecraftforge.entity.PartEntity enderdragonpartentity : p_217484_1_.getParts()) { -+ enderdragonpartentity.remove(keepData); - } - } - -@@ -898,6 +_,9 @@ - this.field_217495_I.remove(((MobEntity)p_217484_1_).func_70661_as()); - } - -+ p_217484_1_.onRemovedFromWorld(); -+ p_217484_1_.remove(keepData); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityLeaveWorldEvent(p_217484_1_, this)); - } - - private void func_217465_m(Entity p_217465_1_) { -@@ -905,8 +_,8 @@ - this.field_217499_z.add(p_217465_1_); - } else { - this.field_217498_x.put(p_217465_1_.func_145782_y(), p_217465_1_); -- if (p_217465_1_ instanceof EnderDragonEntity) { -- for(EnderDragonPartEntity enderdragonpartentity : ((EnderDragonEntity)p_217465_1_).func_213404_dT()) { -+ if (p_217465_1_.isMultipartEntity()) { -+ for(net.minecraftforge.entity.PartEntity enderdragonpartentity : p_217465_1_.getParts()) { - this.field_217498_x.put(enderdragonpartentity.func_145782_y(), enderdragonpartentity); - } - } -@@ -918,15 +_,19 @@ - } - } - -+ p_217465_1_.onAddedToWorld(); - } - - public void func_217467_h(Entity p_217467_1_) { -+ removeEntity(p_217467_1_, false); -+ } -+ public void removeEntity(Entity p_217467_1_, boolean keepData) { - if (this.field_217492_a) { - throw (IllegalStateException)Util.func_229757_c_(new IllegalStateException("Removing entity while ticking!")); - } else { - this.func_217454_n(p_217467_1_); - this.field_217498_x.remove(p_217467_1_.func_145782_y()); -- this.func_217484_g(p_217467_1_); -+ this.removeEntityComplete(p_217467_1_, keepData); - } - } - -@@ -939,8 +_,11 @@ - } - - public void func_217434_e(ServerPlayerEntity p_217434_1_) { -- p_217434_1_.func_70106_y(); -- this.func_217467_h(p_217434_1_); -+ removePlayer(p_217434_1_, false); -+ } -+ public void removePlayer(ServerPlayerEntity p_217434_1_, boolean keepData) { -+ p_217434_1_.remove(keepData); -+ this.removeEntity(p_217434_1_, keepData); - this.func_72854_c(); - } - -@@ -959,10 +_,20 @@ - } - - public void func_184148_a(@Nullable PlayerEntity p_184148_1_, double p_184148_2_, double p_184148_4_, double p_184148_6_, SoundEvent p_184148_8_, SoundCategory p_184148_9_, float p_184148_10_, float p_184148_11_) { -+ net.minecraftforge.event.entity.PlaySoundAtEntityEvent event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtEntity(p_184148_1_, p_184148_8_, p_184148_9_, p_184148_10_, p_184148_11_); -+ if (event.isCanceled() || event.getSound() == null) return; -+ p_184148_8_ = event.getSound(); -+ p_184148_9_ = event.getCategory(); -+ p_184148_10_ = event.getVolume(); - this.field_73061_a.func_184103_al().func_148543_a(p_184148_1_, p_184148_2_, p_184148_4_, p_184148_6_, p_184148_10_ > 1.0F ? (double)(16.0F * p_184148_10_) : 16.0D, this.func_234923_W_(), new SPlaySoundEffectPacket(p_184148_8_, p_184148_9_, p_184148_2_, p_184148_4_, p_184148_6_, p_184148_10_, p_184148_11_)); - } - - public void func_217384_a(@Nullable PlayerEntity p_217384_1_, Entity p_217384_2_, SoundEvent p_217384_3_, SoundCategory p_217384_4_, float p_217384_5_, float p_217384_6_) { -+ net.minecraftforge.event.entity.PlaySoundAtEntityEvent event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtEntity(p_217384_1_, p_217384_3_, p_217384_4_, p_217384_5_, p_217384_6_); -+ if (event.isCanceled() || event.getSound() == null) return; -+ p_217384_3_ = event.getSound(); -+ p_217384_4_ = event.getCategory(); -+ p_217384_5_ = event.getVolume(); - this.field_73061_a.func_184103_al().func_148543_a(p_217384_1_, p_217384_2_.func_226277_ct_(), p_217384_2_.func_226278_cu_(), p_217384_2_.func_226281_cx_(), p_217384_5_ > 1.0F ? (double)(16.0F * p_217384_5_) : 16.0D, this.func_234923_W_(), new SSpawnMovingSoundEffectPacket(p_217384_3_, p_217384_4_, p_217384_2_, p_217384_5_, p_217384_6_)); - } - -@@ -998,6 +_,7 @@ - - public Explosion func_230546_a_(@Nullable Entity p_230546_1_, @Nullable DamageSource p_230546_2_, @Nullable ExplosionContext p_230546_3_, double p_230546_4_, double p_230546_6_, double p_230546_8_, float p_230546_10_, boolean p_230546_11_, Explosion.Mode p_230546_12_) { - Explosion explosion = new Explosion(this, p_230546_1_, p_230546_2_, p_230546_3_, p_230546_4_, p_230546_6_, p_230546_8_, p_230546_10_, p_230546_11_, p_230546_12_); -+ if (net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this, explosion)) return explosion; - explosion.func_77278_a(); - explosion.func_77279_a(false); - if (p_230546_12_ == Explosion.Mode.NONE) { -@@ -1409,5 +_,15 @@ - BlockPos.func_191531_b(i - 2, j, k - 2, i + 2, j, k + 2).forEach((p_241122_1_) -> { - p_241121_0_.func_175656_a(p_241122_1_, Blocks.field_150343_Z.func_176223_P()); - }); -+ } -+ -+ protected void initCapabilities() { -+ this.gatherCapabilities(); -+ capabilityData = this.func_217481_x().func_215752_a(() -> new net.minecraftforge.common.util.WorldCapabilityData(getCapabilities()), net.minecraftforge.common.util.WorldCapabilityData.ID); -+ capabilityData.setCapabilities(getCapabilities()); -+ } -+ -+ public java.util.stream.Stream getEntities() { -+ return field_217498_x.values().stream(); - } - } diff --git a/patches/minecraft/net/minecraft/world/server/Ticket.java.patch b/patches/minecraft/net/minecraft/world/server/Ticket.java.patch deleted file mode 100644 index 0a00ce0f11..0000000000 --- a/patches/minecraft/net/minecraft/world/server/Ticket.java.patch +++ /dev/null @@ -1,50 +0,0 @@ ---- a/net/minecraft/world/server/Ticket.java -+++ b/net/minecraft/world/server/Ticket.java -@@ -9,9 +_,14 @@ - private long field_219483_d; - - protected Ticket(TicketType p_i226095_1_, int p_i226095_2_, T p_i226095_3_) { -+ this(p_i226095_1_, p_i226095_2_, p_i226095_3_, false); -+ } -+ -+ public Ticket(TicketType p_i226095_1_, int p_i226095_2_, T p_i226095_3_, boolean forceTicks) { - this.field_219480_a = p_i226095_1_; - this.field_219481_b = p_i226095_2_; - this.field_219482_c = p_i226095_3_; -+ this.forceTicks = forceTicks; - } - - public int compareTo(Ticket p_compareTo_1_) { -@@ -31,16 +_,16 @@ - return false; - } else { - Ticket ticket = (Ticket)p_equals_1_; -- return this.field_219481_b == ticket.field_219481_b && Objects.equals(this.field_219480_a, ticket.field_219480_a) && Objects.equals(this.field_219482_c, ticket.field_219482_c); -+ return this.field_219481_b == ticket.field_219481_b && Objects.equals(this.field_219480_a, ticket.field_219480_a) && Objects.equals(this.field_219482_c, ticket.field_219482_c) && this.forceTicks == ticket.forceTicks; - } - } - - public int hashCode() { -- return Objects.hash(this.field_219480_a, this.field_219481_b, this.field_219482_c); -+ return Objects.hash(this.field_219480_a, this.field_219481_b, this.field_219482_c, forceTicks); - } - - public String toString() { -- return "Ticket[" + this.field_219480_a + " " + this.field_219481_b + " (" + this.field_219482_c + ")] at " + this.field_219483_d; -+ return "Ticket[" + this.field_219480_a + " " + this.field_219481_b + " (" + this.field_219482_c + ")] at " + this.field_219483_d + " force ticks " + forceTicks; - } - - public TicketType func_219479_a() { -@@ -58,5 +_,12 @@ - protected boolean func_223182_a(long p_223182_1_) { - long i = this.field_219480_a.func_223184_b(); - return i != 0L && p_223182_1_ - this.field_219483_d > i; -+ } -+ -+ /* ======================================== FORGE START =====================================*/ -+ private final boolean forceTicks; -+ -+ public boolean isForceTicks() { -+ return forceTicks; - } - } diff --git a/patches/minecraft/net/minecraft/world/server/TicketManager.java.patch b/patches/minecraft/net/minecraft/world/server/TicketManager.java.patch deleted file mode 100644 index f786f99812..0000000000 --- a/patches/minecraft/net/minecraft/world/server/TicketManager.java.patch +++ /dev/null @@ -1,63 +0,0 @@ ---- a/net/minecraft/world/server/TicketManager.java -+++ b/net/minecraft/world/server/TicketManager.java -@@ -49,6 +_,8 @@ - private final Executor field_219388_p; - private long field_219389_q; - -+ private final Long2ObjectOpenHashMap>> forcedTickets = new Long2ObjectOpenHashMap<>(); -+ - protected TicketManager(Executor p_i50707_1_, Executor p_i50707_2_) { - ITaskExecutor itaskexecutor = ITaskExecutor.func_213140_a("player ticket throttler", p_i50707_2_::execute); - ChunkTaskPriorityQueueSorter chunktaskpriorityqueuesorter = new ChunkTaskPriorityQueueSorter(ImmutableList.of(itaskexecutor), p_i50707_1_, 4); -@@ -143,6 +_,10 @@ - this.field_219378_f.func_215491_b(p_219347_1_, p_219347_3_.func_219477_b(), true); - } - -+ if (p_219347_3_.isForceTicks()) { -+ SortedArraySet> tickets = forcedTickets.computeIfAbsent(p_219347_1_, e -> SortedArraySet.func_226172_a_(4)); -+ tickets.func_226175_a_(ticket); -+ } - } - - private void func_219349_b(long p_219349_1_, Ticket p_219349_3_) { -@@ -155,6 +_,13 @@ - } - - this.field_219378_f.func_215491_b(p_219349_1_, func_229844_a_(sortedarrayset), false); -+ -+ if (p_219349_3_.isForceTicks()) { -+ SortedArraySet> tickets = forcedTickets.get(p_219349_1_); -+ if (tickets != null) { -+ tickets.remove(p_219349_3_); -+ } -+ } - } - - public void func_219356_a(TicketType p_219356_1_, ChunkPos p_219356_2_, int p_219356_3_, T p_219356_4_) { -@@ -175,6 +_,14 @@ - this.func_219349_b(p_219362_2_.func_201841_a(), ticket); - } - -+ public void registerTicking(TicketType type, ChunkPos pos, int distance, T value) { -+ this.func_219347_a(pos.func_201841_a(), new Ticket<>(type, 33 - distance, value, true)); -+ } -+ -+ public void releaseTicking(TicketType type, ChunkPos pos, int distance, T value) { -+ this.func_219349_b(pos.func_201841_a(), new Ticket<>(type, 33 - distance, value, true)); -+ } -+ - private SortedArraySet> func_229848_e_(long p_229848_1_) { - return this.field_219377_e.computeIfAbsent(p_229848_1_, (p_229851_0_) -> { - return SortedArraySet.func_226172_a_(4); -@@ -240,6 +_,11 @@ - - public String func_225412_c() { - return this.field_219384_l.func_225396_a(); -+ } -+ -+ public boolean shouldForceTicks(long chunkPos) { -+ SortedArraySet> tickets = forcedTickets.get(chunkPos); -+ return tickets != null && !tickets.isEmpty(); - } - - class ChunkTicketTracker extends ChunkDistanceGraph { diff --git a/patches/minecraft/net/minecraft/world/spawner/AbstractSpawner.java.patch b/patches/minecraft/net/minecraft/world/spawner/AbstractSpawner.java.patch deleted file mode 100644 index c882fe4b23..0000000000 --- a/patches/minecraft/net/minecraft/world/spawner/AbstractSpawner.java.patch +++ /dev/null @@ -1,27 +0,0 @@ ---- a/net/minecraft/world/spawner/AbstractSpawner.java -+++ b/net/minecraft/world/spawner/AbstractSpawner.java -@@ -131,11 +_,12 @@ - entity.func_70012_b(entity.func_226277_ct_(), entity.func_226278_cu_(), entity.func_226281_cx_(), world.field_73012_v.nextFloat() * 360.0F, 0.0F); - if (entity instanceof MobEntity) { - MobEntity mobentity = (MobEntity)entity; -- if (!mobentity.func_213380_a(world, SpawnReason.SPAWNER) || !mobentity.func_205019_a(world)) { -+ if (!net.minecraftforge.event.ForgeEventFactory.canEntitySpawnSpawner(mobentity, world, (float)entity.func_226277_ct_(), (float)entity.func_226278_cu_(), (float)entity.func_226281_cx_(), this)) { - continue; - } - - if (this.field_98282_f.func_185277_b().func_186856_d() == 1 && this.field_98282_f.func_185277_b().func_150297_b("id", 8)) { -+ if (!net.minecraftforge.event.ForgeEventFactory.doSpecialSpawn(mobentity, world, (float)entity.func_226277_ct_(), (float)entity.func_226278_cu_(), (float)entity.func_226281_cx_(), this, SpawnReason.SPAWNER)) - ((MobEntity)entity).func_213386_a(serverworld, world.func_175649_E(entity.func_233580_cy_()), SpawnReason.SPAWNER, (ILivingEntityData)null, (CompoundNBT)null); - } - } -@@ -282,5 +_,10 @@ - @OnlyIn(Dist.CLIENT) - public double func_177223_e() { - return this.field_98284_d; -+ } -+ -+ @Nullable -+ public Entity getSpawnerEntity() { -+ return null; - } - } diff --git a/patches/minecraft/net/minecraft/world/spawner/CatSpawner.java.patch b/patches/minecraft/net/minecraft/world/spawner/CatSpawner.java.patch deleted file mode 100644 index 7de34db9f9..0000000000 --- a/patches/minecraft/net/minecraft/world/spawner/CatSpawner.java.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/net/minecraft/world/spawner/CatSpawner.java -+++ b/net/minecraft/world/spawner/CatSpawner.java -@@ -80,8 +_,9 @@ - if (catentity == null) { - return 0; - } else { -+ catentity.func_174828_a(p_221122_1_, 0.0F, 0.0F); // Fix MC-147659: Some witch huts spawn the incorrect cat -+ if(net.minecraftforge.common.ForgeHooks.canEntitySpawn(catentity, p_221122_2_, p_221122_1_.func_177958_n(), p_221122_1_.func_177956_o(), p_221122_1_.func_177952_p(), null, SpawnReason.NATURAL) == -1) return 0; - catentity.func_213386_a(p_221122_2_, p_221122_2_.func_175649_E(p_221122_1_), SpawnReason.NATURAL, (ILivingEntityData)null, (CompoundNBT)null); -- catentity.func_174828_a(p_221122_1_, 0.0F, 0.0F); - p_221122_2_.func_242417_l(catentity); - return 1; - } diff --git a/patches/minecraft/net/minecraft/world/spawner/PatrolSpawner.java.patch b/patches/minecraft/net/minecraft/world/spawner/PatrolSpawner.java.patch deleted file mode 100644 index bef881318e..0000000000 --- a/patches/minecraft/net/minecraft/world/spawner/PatrolSpawner.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/world/spawner/PatrolSpawner.java -+++ b/net/minecraft/world/spawner/PatrolSpawner.java -@@ -101,6 +_,7 @@ - } - - patrollerentity.func_70107_b((double)p_222695_2_.func_177958_n(), (double)p_222695_2_.func_177956_o(), (double)p_222695_2_.func_177952_p()); -+ if(net.minecraftforge.common.ForgeHooks.canEntitySpawn(patrollerentity, p_222695_1_, p_222695_2_.func_177958_n(), p_222695_2_.func_177956_o(), p_222695_2_.func_177952_p(), null, SpawnReason.PATROL) == -1) return false; - patrollerentity.func_213386_a(p_222695_1_, p_222695_1_.func_175649_E(p_222695_2_), SpawnReason.PATROL, (ILivingEntityData)null, (CompoundNBT)null); - p_222695_1_.func_242417_l(patrollerentity); - return true; diff --git a/patches/minecraft/net/minecraft/world/spawner/PhantomSpawner.java.patch b/patches/minecraft/net/minecraft/world/spawner/PhantomSpawner.java.patch deleted file mode 100644 index a4bd2bb9bc..0000000000 --- a/patches/minecraft/net/minecraft/world/spawner/PhantomSpawner.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/world/spawner/PhantomSpawner.java -+++ b/net/minecraft/world/spawner/PhantomSpawner.java -@@ -58,6 +_,7 @@ - for(int i1 = 0; i1 < l; ++i1) { - PhantomEntity phantomentity = EntityType.field_203097_aH.func_200721_a(p_230253_1_); - phantomentity.func_174828_a(blockpos1, 0.0F, 0.0F); -+ if(net.minecraftforge.common.ForgeHooks.canEntitySpawn(phantomentity, p_230253_1_, blockpos1.func_177958_n(), blockpos1.func_177956_o(), blockpos1.func_177952_p(), null, SpawnReason.NATURAL) == -1) return 0; - ilivingentitydata = phantomentity.func_213386_a(p_230253_1_, difficultyinstance, SpawnReason.NATURAL, ilivingentitydata, (CompoundNBT)null); - p_230253_1_.func_242417_l(phantomentity); - } diff --git a/patches/minecraft/net/minecraft/world/spawner/WorldEntitySpawner.java.patch b/patches/minecraft/net/minecraft/world/spawner/WorldEntitySpawner.java.patch deleted file mode 100644 index 0820c81fcb..0000000000 --- a/patches/minecraft/net/minecraft/world/spawner/WorldEntitySpawner.java.patch +++ /dev/null @@ -1,75 +0,0 @@ ---- a/net/minecraft/world/spawner/WorldEntitySpawner.java -+++ b/net/minecraft/world/spawner/WorldEntitySpawner.java -@@ -82,7 +_,7 @@ - } while(mobentity.func_104002_bU() || mobentity.func_213392_I()); - - final Entity entity_f = entity; -- EntityClassification entityclassification = entity.func_200600_R().func_220339_d(); -+ EntityClassification entityclassification = entity.getClassification(true); - if (entityclassification != EntityClassification.MISC) { - BlockPos blockpos = entity.func_233580_cy_(); - long i = ChunkPos.func_77272_a(blockpos.func_177958_n() >> 4, blockpos.func_177952_p() >> 4); -@@ -169,13 +_,15 @@ - } - - mobentity.func_70012_b(d0, (double)i, d1, p_234966_1_.field_73012_v.nextFloat() * 360.0F, 0.0F); -- if (func_234974_a_(p_234966_1_, mobentity, d2)) { -+ int canSpawn = net.minecraftforge.common.ForgeHooks.canEntitySpawn(mobentity, p_234966_1_, d0, i, d1, null, SpawnReason.NATURAL); -+ if (canSpawn != -1 && (canSpawn == 1 || func_234974_a_(p_234966_1_, mobentity, d2))) { -+ if (!net.minecraftforge.event.ForgeEventFactory.doSpecialSpawn(mobentity, p_234966_1_, (float)d0, (float)i, (float)d1, null, SpawnReason.NATURAL)) - ilivingentitydata = mobentity.func_213386_a(p_234966_1_, p_234966_1_.func_175649_E(mobentity.func_233580_cy_()), SpawnReason.NATURAL, ilivingentitydata, (CompoundNBT)null); - ++j; - ++l1; - p_234966_1_.func_242417_l(mobentity); - p_234966_5_.run(mobentity, p_234966_2_); -- if (j >= mobentity.func_70641_bl()) { -+ if (j >= net.minecraftforge.event.ForgeEventFactory.getMaxSpawnPackSize(mobentity)) { - return; - } - -@@ -253,6 +_,7 @@ - return null; - } else { - List list = func_241463_a_(p_234977_0_, p_234977_1_, p_234977_2_, p_234977_3_, p_234977_5_, biome); -+ list = net.minecraftforge.event.ForgeEventFactory.getPotentialSpawns(p_234977_0_, p_234977_3_, p_234977_5_, list); - return list.isEmpty() ? null : WeightedRandom.func_76271_a(p_234977_4_, list); - } - } -@@ -292,6 +_,13 @@ - if (p_209382_0_ == EntitySpawnPlacementRegistry.PlacementType.NO_RESTRICTIONS) { - return true; - } else if (p_209382_3_ != null && p_209382_1_.func_175723_af().func_177746_a(p_209382_2_)) { -+ return p_209382_0_.canSpawnAt(p_209382_1_, p_209382_2_, p_209382_3_); -+ } -+ return false; -+ } -+ -+ public static boolean canSpawnAtBody(EntitySpawnPlacementRegistry.PlacementType p_209382_0_, IWorldReader p_209382_1_, BlockPos p_209382_2_, @Nullable EntityType p_209382_3_) { -+ { - BlockState blockstate = p_209382_1_.func_180495_p(p_209382_2_); - FluidState fluidstate = p_209382_1_.func_204610_c(p_209382_2_); - BlockPos blockpos = p_209382_2_.func_177984_a(); -@@ -304,14 +_,12 @@ - case ON_GROUND: - default: - BlockState blockstate1 = p_209382_1_.func_180495_p(blockpos1); -- if (!blockstate1.func_215688_a(p_209382_1_, blockpos1, p_209382_3_)) { -+ if (!blockstate1.canCreatureSpawn(p_209382_1_, blockpos1, p_209382_0_, p_209382_3_)) { - return false; - } else { - return func_234968_a_(p_209382_1_, p_209382_2_, blockstate, fluidstate, p_209382_3_) && func_234968_a_(p_209382_1_, blockpos, p_209382_1_.func_180495_p(blockpos), p_209382_1_.func_204610_c(blockpos), p_209382_3_); - } - } -- } else { -- return false; - } - } - -@@ -355,6 +_,7 @@ - entity.func_70012_b(d0, (double)blockpos.func_177956_o(), d1, p_77191_4_.nextFloat() * 360.0F, 0.0F); - if (entity instanceof MobEntity) { - MobEntity mobentity = (MobEntity)entity; -+ if (net.minecraftforge.common.ForgeHooks.canEntitySpawn(mobentity, p_77191_0_, d0, blockpos.func_177956_o(), d1, null, SpawnReason.CHUNK_GENERATION) == -1) continue; - if (mobentity.func_213380_a(p_77191_0_, SpawnReason.CHUNK_GENERATION) && mobentity.func_205019_a(p_77191_0_)) { - ilivingentitydata = mobentity.func_213386_a(p_77191_0_, p_77191_0_.func_175649_E(mobentity.func_233580_cy_()), SpawnReason.CHUNK_GENERATION, ilivingentitydata, (CompoundNBT)null); - p_77191_0_.func_242417_l(mobentity); diff --git a/patches/minecraft/net/minecraft/world/storage/DimensionSavedDataManager.java.patch b/patches/minecraft/net/minecraft/world/storage/DimensionSavedDataManager.java.patch deleted file mode 100644 index a79f9cb2c7..0000000000 --- a/patches/minecraft/net/minecraft/world/storage/DimensionSavedDataManager.java.patch +++ /dev/null @@ -1,16 +0,0 @@ ---- a/net/minecraft/world/storage/DimensionSavedDataManager.java -+++ b/net/minecraft/world/storage/DimensionSavedDataManager.java -@@ -47,9 +_,13 @@ - @Nullable - public T func_215753_b(Supplier p_215753_1_, String p_215753_2_) { - WorldSavedData worldsaveddata = this.field_212778_c.get(p_215753_2_); -+ if (worldsaveddata == net.minecraftforge.common.util.DummyWorldSaveData.DUMMY) return null; - if (worldsaveddata == null && !this.field_212778_c.containsKey(p_215753_2_)) { - worldsaveddata = this.func_223409_c(p_215753_1_, p_215753_2_); - this.field_212778_c.put(p_215753_2_, worldsaveddata); -+ } else if (worldsaveddata == null) { -+ this.field_212778_c.put(p_215753_2_, net.minecraftforge.common.util.DummyWorldSaveData.DUMMY); -+ return null; - } - - return (T)worldsaveddata; diff --git a/patches/minecraft/net/minecraft/world/storage/PlayerData.java.patch b/patches/minecraft/net/minecraft/world/storage/PlayerData.java.patch deleted file mode 100644 index 0aeba3aef9..0000000000 --- a/patches/minecraft/net/minecraft/world/storage/PlayerData.java.patch +++ /dev/null @@ -1,28 +0,0 @@ ---- a/net/minecraft/world/storage/PlayerData.java -+++ b/net/minecraft/world/storage/PlayerData.java -@@ -31,6 +_,7 @@ - File file2 = new File(this.field_237333_c_, p_237335_1_.func_189512_bd() + ".dat"); - File file3 = new File(this.field_237333_c_, p_237335_1_.func_189512_bd() + ".dat_old"); - Util.func_240977_a_(file2, file1, file3); -+ net.minecraftforge.event.ForgeEventFactory.firePlayerSavingEvent(p_237335_1_, field_237333_c_, p_237335_1_.func_189512_bd()); - } catch (Exception exception) { - field_237332_b_.warn("Failed to save player data for {}", (Object)p_237335_1_.func_200200_C_().getString()); - } -@@ -54,6 +_,7 @@ - int i = compoundnbt.func_150297_b("DataVersion", 3) ? compoundnbt.func_74762_e("DataVersion") : -1; - p_237336_1_.func_70020_e(NBTUtil.func_210822_a(this.field_237331_a_, DefaultTypeReferences.PLAYER, compoundnbt, i)); - } -+ net.minecraftforge.event.ForgeEventFactory.firePlayerLoadingEvent(p_237336_1_, field_237333_c_, p_237336_1_.func_189512_bd()); - - return compoundnbt; - } -@@ -71,5 +_,9 @@ - } - - return astring; -+ } -+ -+ public File getPlayerDataFolder() { -+ return field_237333_c_; - } - } diff --git a/patches/minecraft/net/minecraft/world/storage/SaveFormat.java.patch b/patches/minecraft/net/minecraft/world/storage/SaveFormat.java.patch deleted file mode 100644 index af35379fe2..0000000000 --- a/patches/minecraft/net/minecraft/world/storage/SaveFormat.java.patch +++ /dev/null @@ -1,63 +0,0 @@ ---- a/net/minecraft/world/storage/SaveFormat.java -+++ b/net/minecraft/world/storage/SaveFormat.java -@@ -95,7 +_,7 @@ - } - } - -- Dynamic dynamic1 = p_237259_1_.update(TypeReferences.field_233375_y_, dynamic, p_237259_2_, SharedConstants.func_215069_a().getWorldVersion()); -+ Dynamic dynamic1 = net.minecraftforge.common.ForgeHooks.fixUpDimensionsData(p_237259_1_.update(TypeReferences.field_233375_y_, dynamic, p_237259_2_, SharedConstants.func_215069_a().getWorldVersion())); - DataResult dataresult = DimensionGeneratorSettings.field_236201_a_.parse(dynamic1); - return Pair.of(dataresult.resultOrPartial(Util.func_240982_a_("WorldGenSettings: ", field_215785_a::error)).orElseGet(() -> { - Registry registry = RegistryLookupCodec.func_244331_a(Registry.field_239698_ad_).codec().parse(dynamic1).resultOrPartial(Util.func_240982_a_("Dimension type registry: ", field_215785_a::error)).orElseThrow(() -> { -@@ -182,6 +_,10 @@ - } - - private static BiFunction func_237270_b_(DynamicOps p_237270_0_, DatapackCodec p_237270_1_) { -+ return getReader(p_237270_0_, p_237270_1_, null); -+ } -+ -+ private static BiFunction getReader(DynamicOps p_237270_0_, DatapackCodec p_237270_1_, @Nullable LevelSave levelSave) { - return (p_242976_2_, p_242976_3_) -> { - try { - CompoundNBT compoundnbt = CompressedStreamTools.func_244263_a(p_242976_2_); -@@ -193,7 +_,10 @@ - Pair pair = func_237259_a_(dynamic, p_242976_3_, i); - VersionData versiondata = VersionData.func_237324_a_(dynamic); - WorldSettings worldsettings = WorldSettings.func_234951_a_(dynamic, p_237270_1_); -- return ServerWorldInfo.func_237369_a_(dynamic, p_242976_3_, i, compoundnbt2, worldsettings, versiondata, pair.getFirst(), pair.getSecond()); -+ ServerWorldInfo info = ServerWorldInfo.func_237369_a_(dynamic, p_242976_3_, i, compoundnbt2, worldsettings, versiondata, pair.getFirst(), pair.getSecond()); -+ if (levelSave != null) -+ net.minecraftforge.fml.WorldPersistenceHooks.handleWorldDataLoad(levelSave, info, compoundnbt); -+ return info; - } catch (Exception exception) { - field_215785_a.error("Exception reading {}", p_242976_2_, exception); - return null; -@@ -314,7 +_,7 @@ - @Nullable - public IServerConfiguration func_237284_a_(DynamicOps p_237284_1_, DatapackCodec p_237284_2_) { - this.func_237301_i_(); -- return SaveFormat.this.func_237266_a_(this.field_237279_c_.toFile(), SaveFormat.func_237270_b_(p_237284_1_, p_237284_2_)); -+ return SaveFormat.this.func_237266_a_(this.field_237279_c_.toFile(), SaveFormat.getReader(p_237284_1_, p_237284_2_, this)); - } - - @Nullable -@@ -335,6 +_,8 @@ - CompoundNBT compoundnbt1 = new CompoundNBT(); - compoundnbt1.func_218657_a("Data", compoundnbt); - -+ net.minecraftforge.fml.WorldPersistenceHooks.handleWorldDataSave(this, p_237288_2_, compoundnbt1); -+ - try { - File file2 = File.createTempFile("level", ".dat", file1); - CompressedStreamTools.func_244264_a(compoundnbt1, file2); -@@ -350,6 +_,10 @@ - public File func_237298_f_() { - this.func_237301_i_(); - return this.field_237279_c_.resolve("icon.png").toFile(); -+ } -+ -+ public Path getWorldDir() { -+ return field_237279_c_; - } - - @OnlyIn(Dist.CLIENT) diff --git a/patches/minecraft/net/minecraft/world/storage/WorldSavedData.java.patch b/patches/minecraft/net/minecraft/world/storage/WorldSavedData.java.patch deleted file mode 100644 index 310c440476..0000000000 --- a/patches/minecraft/net/minecraft/world/storage/WorldSavedData.java.patch +++ /dev/null @@ -1,27 +0,0 @@ ---- a/net/minecraft/world/storage/WorldSavedData.java -+++ b/net/minecraft/world/storage/WorldSavedData.java -@@ -8,7 +_,7 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; - --public abstract class WorldSavedData { -+public abstract class WorldSavedData implements net.minecraftforge.common.util.INBTSerializable { - private static final Logger field_215159_a = LogManager.getLogger(); - private final String field_76190_i; - private boolean field_76189_a; -@@ -51,5 +_,15 @@ - - this.func_76186_a(false); - } -+ } -+ -+ @Override -+ public void deserializeNBT(CompoundNBT nbt) { -+ func_76184_a(nbt); -+ } -+ -+ @Override -+ public CompoundNBT serializeNBT() { -+ return func_189551_b(new CompoundNBT()); - } - } diff --git a/server_files/args.txt b/server_files/args.txt new file mode 100644 index 0000000000..4551706d64 --- /dev/null +++ b/server_files/args.txt @@ -0,0 +1,13 @@ +-p @MODULE_PATH@ +--add-modules @MODULES@ +--add-opens java.base/java.util.jar=cpw.mods.securejarhandler +--add-exports java.base/sun.security.util=cpw.mods.securejarhandler +-DignoreList=@IGNORE_LIST@ +-DlibraryDirectory=libraries +-DlegacyClassPath=@CLASS_PATH@ +cpw.mods.bootstraplauncher.BootstrapLauncher +--launchTarget @TASK@ +--fml.forgeVersion @FORGE_VERSION@ +--fml.mcVersion @MC_VERSION@ +--fml.forgeGroup @FORGE_GROUP@ +--fml.mcpVersion @MCP_VERSION@ \ No newline at end of file diff --git a/server_files/run.bat b/server_files/run.bat new file mode 100644 index 0000000000..4c51bfb6ad --- /dev/null +++ b/server_files/run.bat @@ -0,0 +1,5 @@ +REM Forge requires a configured set of both JVM and program arguments. +REM Add custom JVM arguments to the user_jvm_args.txt +REM Add custom program arguments {such as nogui} to this file at the end of the next line +java @user_jvm_args.txt @libraries/@MAVEN_PATH@/win_args.txt +pause \ No newline at end of file diff --git a/server_files/run.sh b/server_files/run.sh new file mode 100644 index 0000000000..6dc98e04ef --- /dev/null +++ b/server_files/run.sh @@ -0,0 +1,4 @@ +# Forge requires a configured set of both JVM and program arguments. +# Add custom JVM arguments to the user_jvm_args.txt +# Add custom program arguments {such as nogui} to this file at the end of the next line +java @user_jvm_args.txt @libraries/@MAVEN_PATH@/unix_args.txt \ No newline at end of file diff --git a/server_files/user_jvm_args.txt b/server_files/user_jvm_args.txt new file mode 100644 index 0000000000..7fbf8a7ab9 --- /dev/null +++ b/server_files/user_jvm_args.txt @@ -0,0 +1,9 @@ +# Xmx and Xms set the maximum and minimum RAM usage, respectively. +# They can take any number, followed by an M or a G. +# M means Megabyte, G means Gigabyte. +# For example, to set the maximum to 3GB: -Xmx3G +# To set the minimum to 2.5GB: -Xms2500M + +# A good default for a modded server is 4GB. +# Uncomment the next line to set it. +# -Xmx4G \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index b2a6c189c0..4273784394 100644 --- a/settings.gradle +++ b/settings.gradle @@ -5,12 +5,19 @@ pluginManagement { } } -rootProject.name = 'Forge' +rootProject.name = 'ForgeRoot' + +include 'fmlloader' +include 'fmlcore' +include 'mclanguage' +include 'javafmllanguage' 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/fmlcommon/java/net/minecraftforge/fml/core/ModStateProvider.java b/src/fmlcommon/java/net/minecraftforge/fml/core/ModStateProvider.java new file mode 100644 index 0000000000..0efb95c8db --- /dev/null +++ b/src/fmlcommon/java/net/minecraftforge/fml/core/ModStateProvider.java @@ -0,0 +1,61 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.fml.core; + +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.fml.DistExecutor; +import net.minecraftforge.fml.IModLoadingState; +import net.minecraftforge.fml.IModStateProvider; +import net.minecraftforge.fml.ModLoadingPhase; +import net.minecraftforge.fml.ModLoadingStage; +import net.minecraftforge.fml.ModLoadingState; +import net.minecraftforge.fml.config.ConfigTracker; +import net.minecraftforge.fml.config.ModConfig; +import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; +import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; +import net.minecraftforge.fml.event.lifecycle.FMLConstructModEvent; +import net.minecraftforge.fml.event.lifecycle.FMLDedicatedServerSetupEvent; +import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent; +import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent; +import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent; +import net.minecraftforge.fml.loading.FMLPaths; + +import java.util.List; + +public class ModStateProvider implements IModStateProvider { + final ModLoadingState ERROR = ModLoadingState.empty("ERROR", "", ModLoadingPhase.ERROR); + private final ModLoadingState VALIDATE = ModLoadingState.empty("VALIDATE", "", ModLoadingPhase.GATHER); + final ModLoadingState CONSTRUCT = ModLoadingState.withTransition("CONSTRUCT", "VALIDATE", ml->"Constructing %d mods".formatted(ml.size()), ModLoadingPhase.GATHER, new ParallelTransition(ModLoadingStage.CONSTRUCT, FMLConstructModEvent.class)); + private final ModLoadingState CONFIG_LOAD = ModLoadingState.withInline("CONFIG_LOAD", "", ModLoadingPhase.LOAD, ml->{ + DistExecutor.unsafeRunWhenOn(Dist.CLIENT, ()->()-> ConfigTracker.INSTANCE.loadConfigs(ModConfig.Type.CLIENT, FMLPaths.CONFIGDIR.get())); + ConfigTracker.INSTANCE.loadConfigs(ModConfig.Type.COMMON, FMLPaths.CONFIGDIR.get()); + }); + private final ModLoadingState COMMON_SETUP = ModLoadingState.withTransition("COMMON_SETUP", "CONFIG_LOAD", ModLoadingPhase.LOAD, new ParallelTransition(ModLoadingStage.CONSTRUCT, FMLCommonSetupEvent.class)); + private final ModLoadingState SIDED_SETUP = ModLoadingState.withTransition("SIDED_SETUP", "COMMON_SETUP", ModLoadingPhase.LOAD, new ParallelTransition(ModLoadingStage.SIDED_SETUP, DistExecutor.unsafeRunForDist(()->()-> FMLClientSetupEvent.class, ()->()-> FMLDedicatedServerSetupEvent.class))); + private final ModLoadingState ENQUEUE_IMC = ModLoadingState.withTransition("ENQUEUE_IMC", "", ModLoadingPhase.COMPLETE, new ParallelTransition(ModLoadingStage.ENQUEUE_IMC, InterModEnqueueEvent.class)); + private final ModLoadingState PROCESS_IMC = ModLoadingState.withTransition("PROCESS_IMC", "ENQUEUE_IMC",ModLoadingPhase.COMPLETE, new ParallelTransition(ModLoadingStage.PROCESS_IMC, InterModProcessEvent.class)); + private final ModLoadingState COMPLETE = ModLoadingState.withTransition("COMPLETE", "PROCESS_IMC", ml->"completing load of %d mods".formatted(ml.size()), ModLoadingPhase.COMPLETE, new ParallelTransition(ModLoadingStage.COMPLETE, FMLLoadCompleteEvent.class)); + private final ModLoadingState DONE = ModLoadingState.empty("DONE", "", ModLoadingPhase.DONE); + + @Override + public List getAllStates() { + return List.of(ERROR, VALIDATE, CONSTRUCT, CONFIG_LOAD, COMMON_SETUP, SIDED_SETUP, ENQUEUE_IMC, PROCESS_IMC, COMPLETE, DONE); + } +} diff --git a/src/fmlcommon/java/net/minecraftforge/fml/core/ParallelTransition.java b/src/fmlcommon/java/net/minecraftforge/fml/core/ParallelTransition.java new file mode 100644 index 0000000000..d052fc9960 --- /dev/null +++ b/src/fmlcommon/java/net/minecraftforge/fml/core/ParallelTransition.java @@ -0,0 +1,65 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.fml.core; + +import cpw.mods.modlauncher.api.LamdbaExceptionUtils; +import net.minecraftforge.fml.IModStateTransition; +import net.minecraftforge.fml.ModContainer; +import net.minecraftforge.fml.ModLoadingStage; +import net.minecraftforge.fml.ThreadSelector; +import net.minecraftforge.fml.event.lifecycle.ParallelDispatchEvent; + +import java.util.Collections; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Executor; +import java.util.function.BiFunction; +import java.util.function.Supplier; +import java.util.stream.Stream; + +record ParallelTransition(ModLoadingStage stage, Class event) implements IModStateTransition { + @Override + public Supplier>> eventFunctionStream() { + return () -> Stream.of(IModStateTransition.EventGenerator.fromFunction(LamdbaExceptionUtils.rethrowFunction((ModContainer mc) -> event.getConstructor(ModContainer.class, ModLoadingStage.class).newInstance(mc, stage)))); + } + + @Override + public ThreadSelector threadSelector() { + return ThreadSelector.PARALLEL; + } + + @Override + public BiFunction>, CompletableFuture>> finalActivityGenerator() { + return (e, prev) -> prev.thenApplyAsync(t -> { + stage.getDeferredWorkQueue().runTasks(); + return t; + }); + } + + @Override + public BiFunction, CompletableFuture>> preDispatchHook() { + return (t, f) -> CompletableFuture.completedFuture(Collections.emptyList()); + } + + @Override + public BiFunction, CompletableFuture>> postDispatchHook() { + return (t, f) -> CompletableFuture.completedFuture(Collections.emptyList()); + } +} diff --git a/src/fmlcommon/java/net/minecraftforge/fml/event/config/ModConfigEvent.java b/src/fmlcommon/java/net/minecraftforge/fml/event/config/ModConfigEvent.java new file mode 100644 index 0000000000..2004ed9b02 --- /dev/null +++ b/src/fmlcommon/java/net/minecraftforge/fml/event/config/ModConfigEvent.java @@ -0,0 +1,50 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.fml.event.config; + +import net.minecraftforge.eventbus.api.Event; +import net.minecraftforge.fml.config.IConfigEvent; +import net.minecraftforge.fml.config.ModConfig; +import net.minecraftforge.fml.event.IModBusEvent; + +public class ModConfigEvent extends Event implements IModBusEvent, IConfigEvent { + private final ModConfig config; + + ModConfigEvent(final ModConfig config) { + this.config = config; + } + + @Override + public ModConfig getConfig() { + return config; + } + + public static class Loading extends ModConfigEvent { + public Loading(final ModConfig config) { + super(config); + } + } + + public static class Reloading extends ModConfigEvent { + public Reloading(final ModConfig config) { + super(config); + } + } +} diff --git a/src/main/java/net/minecraftforge/fml/event/lifecycle/FMLClientSetupEvent.java b/src/fmlcommon/java/net/minecraftforge/fml/event/lifecycle/FMLClientSetupEvent.java similarity index 78% rename from src/main/java/net/minecraftforge/fml/event/lifecycle/FMLClientSetupEvent.java rename to src/fmlcommon/java/net/minecraftforge/fml/event/lifecycle/FMLClientSetupEvent.java index b2204b1389..663019ed93 100644 --- a/src/main/java/net/minecraftforge/fml/event/lifecycle/FMLClientSetupEvent.java +++ b/src/fmlcommon/java/net/minecraftforge/fml/event/lifecycle/FMLClientSetupEvent.java @@ -19,10 +19,9 @@ package net.minecraftforge.fml.event.lifecycle; -import net.minecraft.client.Minecraft; import net.minecraftforge.fml.ModContainer; +import net.minecraftforge.fml.ModLoadingStage; -import java.util.function.Supplier; /** * This is the second of four commonly called events during mod lifecycle startup. @@ -40,16 +39,8 @@ import java.util.function.Supplier; */ public class FMLClientSetupEvent extends ParallelDispatchEvent { - private final Supplier minecraftSupplier; - - public FMLClientSetupEvent(ModContainer container) + public FMLClientSetupEvent(ModContainer container, ModLoadingStage stage) { - super(container); - minecraftSupplier = Minecraft::getInstance; - } - - public Supplier getMinecraftSupplier() - { - return minecraftSupplier; + super(container, stage); } } diff --git a/src/main/java/net/minecraftforge/fml/event/lifecycle/FMLCommonSetupEvent.java b/src/fmlcommon/java/net/minecraftforge/fml/event/lifecycle/FMLCommonSetupEvent.java similarity index 84% rename from src/main/java/net/minecraftforge/fml/event/lifecycle/FMLCommonSetupEvent.java rename to src/fmlcommon/java/net/minecraftforge/fml/event/lifecycle/FMLCommonSetupEvent.java index 78abcaa8f5..74f4a39067 100644 --- a/src/main/java/net/minecraftforge/fml/event/lifecycle/FMLCommonSetupEvent.java +++ b/src/fmlcommon/java/net/minecraftforge/fml/event/lifecycle/FMLCommonSetupEvent.java @@ -20,8 +20,8 @@ package net.minecraftforge.fml.event.lifecycle; import net.minecraftforge.fml.ModContainer; - -import java.util.function.Consumer; +import net.minecraftforge.fml.DeferredWorkQueue; +import net.minecraftforge.fml.ModLoadingStage; /** * This is the first of four commonly called events during mod initialization. @@ -37,13 +37,13 @@ import java.util.function.Consumer; * Most non-specific mod setup will be performed here. Note that this is a parallel dispatched event - you cannot * interact with game state in this event. * - * @see net.minecraftforge.fml.DeferredWorkQueue to enqueue work to run on the main game thread after this event has + * @see DeferredWorkQueue to enqueue work to run on the main game thread after this event has * completed dispatch */ public class FMLCommonSetupEvent extends ParallelDispatchEvent { - public FMLCommonSetupEvent(final ModContainer container) + public FMLCommonSetupEvent(final ModContainer container, final ModLoadingStage stage) { - super(container); + super(container, stage); } } diff --git a/src/main/java/net/minecraftforge/fml/event/lifecycle/FMLConstructModEvent.java b/src/fmlcommon/java/net/minecraftforge/fml/event/lifecycle/FMLConstructModEvent.java similarity index 84% rename from src/main/java/net/minecraftforge/fml/event/lifecycle/FMLConstructModEvent.java rename to src/fmlcommon/java/net/minecraftforge/fml/event/lifecycle/FMLConstructModEvent.java index ceb9740de9..779f9ccce1 100644 --- a/src/main/java/net/minecraftforge/fml/event/lifecycle/FMLConstructModEvent.java +++ b/src/fmlcommon/java/net/minecraftforge/fml/event/lifecycle/FMLConstructModEvent.java @@ -20,9 +20,10 @@ package net.minecraftforge.fml.event.lifecycle; import net.minecraftforge.fml.ModContainer; +import net.minecraftforge.fml.ModLoadingStage; public class FMLConstructModEvent extends ParallelDispatchEvent { - public FMLConstructModEvent(final ModContainer container) { - super(container); + public FMLConstructModEvent(final ModContainer container, final ModLoadingStage stage) { + super(container, stage); } } diff --git a/src/main/java/net/minecraftforge/fml/event/lifecycle/FMLDedicatedServerSetupEvent.java b/src/fmlcommon/java/net/minecraftforge/fml/event/lifecycle/FMLDedicatedServerSetupEvent.java similarity index 78% rename from src/main/java/net/minecraftforge/fml/event/lifecycle/FMLDedicatedServerSetupEvent.java rename to src/fmlcommon/java/net/minecraftforge/fml/event/lifecycle/FMLDedicatedServerSetupEvent.java index dc992dd383..95125c773d 100644 --- a/src/main/java/net/minecraftforge/fml/event/lifecycle/FMLDedicatedServerSetupEvent.java +++ b/src/fmlcommon/java/net/minecraftforge/fml/event/lifecycle/FMLDedicatedServerSetupEvent.java @@ -19,13 +19,11 @@ package net.minecraftforge.fml.event.lifecycle; -import net.minecraft.server.dedicated.DedicatedServer; import net.minecraftforge.fml.ModContainer; - -import java.util.function.Supplier; +import net.minecraftforge.fml.ModLoadingStage; /** - * This is the second of four commonly called events during mod lifecycle startup. + * This is the second of four commonly called events during mod core startup. * * Called before {@link InterModEnqueueEvent} * Called after {@link FMLCommonSetupEvent} @@ -36,16 +34,16 @@ import java.util.function.Supplier; * * Do dedicated server specific activities with this event. * - * This event is fired before construction of the dedicated server. Use {@link net.minecraftforge.fml.event.server.FMLServerAboutToStartEvent} - * or {@link net.minecraftforge.fml.event.server.FMLServerStartingEvent} to do stuff with the server, in both dedicated + * This event is fired before construction of the dedicated server. Use {@link FMLServerAboutToStartEvent} + * or {@link FMLServerStartingEvent} to do stuff with the server, in both dedicated * and integrated server contexts * * This is a parallel dispatch event. */ public class FMLDedicatedServerSetupEvent extends ParallelDispatchEvent { - public FMLDedicatedServerSetupEvent(ModContainer container) + public FMLDedicatedServerSetupEvent(ModContainer container, ModLoadingStage stage) { - super(container); + super(container, stage); } } diff --git a/src/main/java/net/minecraftforge/fml/event/lifecycle/FMLLoadCompleteEvent.java b/src/fmlcommon/java/net/minecraftforge/fml/event/lifecycle/FMLLoadCompleteEvent.java similarity index 86% rename from src/main/java/net/minecraftforge/fml/event/lifecycle/FMLLoadCompleteEvent.java rename to src/fmlcommon/java/net/minecraftforge/fml/event/lifecycle/FMLLoadCompleteEvent.java index 338b64be52..37852da667 100644 --- a/src/main/java/net/minecraftforge/fml/event/lifecycle/FMLLoadCompleteEvent.java +++ b/src/fmlcommon/java/net/minecraftforge/fml/event/lifecycle/FMLLoadCompleteEvent.java @@ -20,6 +20,7 @@ package net.minecraftforge.fml.event.lifecycle; import net.minecraftforge.fml.ModContainer; +import net.minecraftforge.fml.ModLoadingStage; /** * This is a mostly internal event fired to mod containers that indicates that loading is complete. Mods should not @@ -29,8 +30,8 @@ import net.minecraftforge.fml.ModContainer; */ public class FMLLoadCompleteEvent extends ParallelDispatchEvent { - public FMLLoadCompleteEvent(final ModContainer container) + public FMLLoadCompleteEvent(final ModContainer container, final ModLoadingStage stage) { - super(container); + super(container, stage); } } diff --git a/src/main/java/net/minecraftforge/fml/event/lifecycle/InterModEnqueueEvent.java b/src/fmlcommon/java/net/minecraftforge/fml/event/lifecycle/InterModEnqueueEvent.java similarity index 83% rename from src/main/java/net/minecraftforge/fml/event/lifecycle/InterModEnqueueEvent.java rename to src/fmlcommon/java/net/minecraftforge/fml/event/lifecycle/InterModEnqueueEvent.java index d9a6f7c1b9..5e57a50a27 100644 --- a/src/main/java/net/minecraftforge/fml/event/lifecycle/InterModEnqueueEvent.java +++ b/src/fmlcommon/java/net/minecraftforge/fml/event/lifecycle/InterModEnqueueEvent.java @@ -20,9 +20,10 @@ package net.minecraftforge.fml.event.lifecycle; import net.minecraftforge.fml.ModContainer; +import net.minecraftforge.fml.ModLoadingStage; /** - * This is the third of four commonly called events during mod lifecycle startup. + * This is the third of four commonly called events during mod core startup. * * Called before {@link InterModProcessEvent} * Called after {@link FMLClientSetupEvent} or {@link FMLDedicatedServerSetupEvent} @@ -35,8 +36,8 @@ import net.minecraftforge.fml.ModContainer; public class InterModEnqueueEvent extends ParallelDispatchEvent { - public InterModEnqueueEvent(final ModContainer container) + public InterModEnqueueEvent(final ModContainer container, final ModLoadingStage stage) { - super(container); + super(container, stage); } } diff --git a/src/main/java/net/minecraftforge/fml/event/lifecycle/InterModProcessEvent.java b/src/fmlcommon/java/net/minecraftforge/fml/event/lifecycle/InterModProcessEvent.java similarity index 87% rename from src/main/java/net/minecraftforge/fml/event/lifecycle/InterModProcessEvent.java rename to src/fmlcommon/java/net/minecraftforge/fml/event/lifecycle/InterModProcessEvent.java index 0601f7e7e6..284f924963 100644 --- a/src/main/java/net/minecraftforge/fml/event/lifecycle/InterModProcessEvent.java +++ b/src/fmlcommon/java/net/minecraftforge/fml/event/lifecycle/InterModProcessEvent.java @@ -20,11 +20,10 @@ package net.minecraftforge.fml.event.lifecycle; import net.minecraftforge.fml.ModContainer; - -import java.util.function.Predicate; +import net.minecraftforge.fml.ModLoadingStage; /** - * This is the fourth of four commonly called events during mod lifecycle startup. + * This is the fourth of four commonly called events during mod core startup. * * Called after {@link InterModEnqueueEvent} * @@ -38,8 +37,8 @@ import java.util.function.Predicate; */ public class InterModProcessEvent extends ParallelDispatchEvent { - public InterModProcessEvent(final ModContainer container) + public InterModProcessEvent(final ModContainer container, final ModLoadingStage stage) { - super(container); + super(container, stage); } } diff --git a/src/main/java/net/minecraftforge/fml/event/lifecycle/ModLifecycleEvent.java b/src/fmlcommon/java/net/minecraftforge/fml/event/lifecycle/ModLifecycleEvent.java similarity index 97% rename from src/main/java/net/minecraftforge/fml/event/lifecycle/ModLifecycleEvent.java rename to src/fmlcommon/java/net/minecraftforge/fml/event/lifecycle/ModLifecycleEvent.java index 3434026868..847499b05c 100644 --- a/src/main/java/net/minecraftforge/fml/event/lifecycle/ModLifecycleEvent.java +++ b/src/fmlcommon/java/net/minecraftforge/fml/event/lifecycle/ModLifecycleEvent.java @@ -22,8 +22,8 @@ package net.minecraftforge.fml.event.lifecycle; import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.fml.InterModComms; import net.minecraftforge.fml.ModContainer; +import net.minecraftforge.fml.event.IModBusEvent; -import java.util.Arrays; import java.util.function.Predicate; import java.util.stream.Stream; diff --git a/src/main/java/net/minecraftforge/fml/event/lifecycle/ParallelDispatchEvent.java b/src/fmlcommon/java/net/minecraftforge/fml/event/lifecycle/ParallelDispatchEvent.java similarity index 84% rename from src/main/java/net/minecraftforge/fml/event/lifecycle/ParallelDispatchEvent.java rename to src/fmlcommon/java/net/minecraftforge/fml/event/lifecycle/ParallelDispatchEvent.java index bb65ac66d5..591bc8e241 100644 --- a/src/main/java/net/minecraftforge/fml/event/lifecycle/ParallelDispatchEvent.java +++ b/src/fmlcommon/java/net/minecraftforge/fml/event/lifecycle/ParallelDispatchEvent.java @@ -21,18 +21,22 @@ package net.minecraftforge.fml.event.lifecycle; import net.minecraftforge.fml.DeferredWorkQueue; import net.minecraftforge.fml.ModContainer; +import net.minecraftforge.fml.ModLoadingStage; import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.function.Supplier; public class ParallelDispatchEvent extends ModLifecycleEvent { - public ParallelDispatchEvent(final ModContainer container) { + private final ModLoadingStage modLoadingStage; + + public ParallelDispatchEvent(final ModContainer container, final ModLoadingStage stage) { super(container); + this.modLoadingStage = stage; } private Optional getQueue() { - return DeferredWorkQueue.lookup(Optional.of(getClass())); + return DeferredWorkQueue.lookup(Optional.of(modLoadingStage)); } public CompletableFuture enqueueWork(Runnable work) { diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/FMLClientLaunchProvider.java b/src/fmllauncher/java/net/minecraftforge/fml/loading/FMLClientLaunchProvider.java deleted file mode 100644 index a6f8d28c9d..0000000000 --- a/src/fmllauncher/java/net/minecraftforge/fml/loading/FMLClientLaunchProvider.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fml.loading; - -import cpw.mods.modlauncher.api.IEnvironment; -import cpw.mods.modlauncher.api.ILaunchHandlerService; -import cpw.mods.modlauncher.api.ITransformingClassLoader; -import net.minecraftforge.api.distmarker.Dist; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.Callable; - -public class FMLClientLaunchProvider extends FMLCommonLaunchHandler implements ILaunchHandlerService -{ - private static final Logger LOGGER = LogManager.getLogger(); - - @Override - public String name() - { - return "fmlclient"; - } - - @Override - public Callable launchService(String[] arguments, ITransformingClassLoader launchClassLoader) - { - return () -> { - super.beforeStart(launchClassLoader); - launchClassLoader.addTargetPackageFilter(getPackagePredicate()); - Class.forName("net.minecraft.client.main.Main", true, launchClassLoader.getInstance()).getMethod("main", String[].class).invoke(null, (Object)arguments); - return null; - }; - } - - @SuppressWarnings("unchecked") - @Override - public void setup(final IEnvironment environment, final Map arguments) { - final List mavenRoots = new ArrayList<>((List) arguments.get("mavenRoots")); - final List mods = new ArrayList<>((List) arguments.get("mods")); - mavenRoots.add(LibraryFinder.findLibsPath().toString()); - final String forgeVersion = (String) arguments.get("forgeVersion"); - final String mcVersion = (String) arguments.get("mcVersion"); - final String forgeGroup = (String) arguments.get("forgeGroup"); - mods.add(forgeGroup+":forge:universal:"+mcVersion+"-"+forgeVersion); - // generics are gross yea? - ((Map)arguments).put("mavenRoots", mavenRoots); - ((Map)arguments).put("mods", mods); - } - - @Override - public Dist getDist() - { - return Dist.CLIENT; - } - - @Override - protected String getNaming() { - return "srg"; - } - - @Override - public Path[] getPaths() { - return FMLLoader.getMCPaths(); - } - - @Override - public boolean isProduction() { - return true; - } -} diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/FMLCommonLaunchHandler.java b/src/fmllauncher/java/net/minecraftforge/fml/loading/FMLCommonLaunchHandler.java deleted file mode 100644 index 04a70753b5..0000000000 --- a/src/fmllauncher/java/net/minecraftforge/fml/loading/FMLCommonLaunchHandler.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fml.loading; - -import cpw.mods.modlauncher.api.IEnvironment; -import cpw.mods.modlauncher.api.ITransformingClassLoader; -import cpw.mods.modlauncher.api.ITransformingClassLoaderBuilder; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.fml.loading.moddiscovery.ModFile; -import org.apache.commons.lang3.tuple.Pair; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.io.File; -import java.net.URL; -import java.net.URLConnection; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.*; -import java.util.function.Function; -import java.util.function.Predicate; -import java.util.jar.Manifest; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import static net.minecraftforge.fml.loading.LogMarkers.CORE; -import static net.minecraftforge.fml.loading.LogMarkers.LOADING; - -public abstract class FMLCommonLaunchHandler -{ - private static final Logger LOGGER = LogManager.getLogger(); - private static final List SKIPPACKAGES = Arrays.asList( - // standard libs - "joptsimple.", "org.lwjgl.", "com.mojang.guava.", "com.google.", "org.apache.commons.", "io.netty.", - "org.apache.logging.log4j.", "org.apache.http.", "org.apache.maven.", "org.objectweb.asm.", - "paulscode.sound.", "com.ibm.icu.", "sun.", "javax.", "gnu.trove.", "com.electronwill.nightconfig.", - "net.minecraftforge.fml.loading.", "net.minecraftforge.fml.language.", - "net.minecraftforge.eventbus.", "net.minecraftforge.api.", "com.mojang.util.QueueLogAppender" - ); - - private final List additionalLibraries = new ArrayList<>(); - - protected Predicate getPackagePredicate() { - return cn -> SKIPPACKAGES.stream().noneMatch(cn::startsWith); - } - - public Path getForgePath(final String mcVersion, final String forgeVersion, final String forgeGroup) { - return LibraryFinder.getForgeLibraryPath(mcVersion, forgeVersion, forgeGroup); - } - - public Path[] getMCPaths(final String mcVersion, final String mcpVersion, final String forgeVersion, final String forgeGroup) { - return LibraryFinder.getMCPaths(mcVersion, mcpVersion, forgeVersion, forgeGroup, getDist().isClient() ? "client" : "server"); - } - - public void configureTransformationClassLoader(final ITransformingClassLoaderBuilder builder) { - builder.addTransformationPath(FMLLoader.getForgePath()); - Arrays.stream(FMLLoader.getMCPaths()).forEach(builder::addTransformationPath); - additionalLibraries.forEach(builder::addTransformationPath); - FMLLoader.getLanguageLoadingProvider().getLibraries().forEach(builder::addTransformationPath); - builder.setManifestLocator(getClassLoaderManifestLocatorFunction()); - builder.setResourceEnumeratorLocator(getClassLoaderResourceEnumerationFunction()); - } - - public void setup(final IEnvironment environment, final Map arguments) - { - - } - - public abstract Dist getDist(); - - protected void beforeStart(ITransformingClassLoader launchClassLoader) - { - FMLLoader.beforeStart(launchClassLoader); - } - - protected void processModClassesEnvironmentVariable(final Map>>> arguments) { - final String modClasses = Optional.ofNullable(System.getenv("MOD_CLASSES")).orElse(""); - LOGGER.debug(CORE, "Got mod coordinates {} from env", modClasses); - - // "a/b/;c/d/;" -> "modid%%c:\fish\pepper;modid%%c:\fish2\pepper2\;modid2%%c:\fishy\bums;modid2%%c:\hmm" - final Map> modClassPaths = Arrays.stream(modClasses.split(File.pathSeparator)). - map(inp -> inp.split("%%", 2)).map(this::buildModPair). - collect(Collectors.groupingBy(Pair::getLeft, Collectors.mapping(Pair::getRight, Collectors.toList()))); - - LOGGER.debug(CORE, "Found supplied mod coordinates [{}]", modClassPaths); - - final List>> explodedTargets = arguments.computeIfAbsent("explodedTargets", a -> new ArrayList<>()); - modClassPaths.forEach((modlabel,paths) -> explodedTargets.add(Pair.of(paths.get(0), paths.subList(1, paths.size())))); - } - - private Pair buildModPair(String[] splitString) { - String modid = splitString.length == 1 ? "defaultmodid" : splitString[0]; - Path path = Paths.get(splitString[splitString.length - 1]); - return Pair.of(modid, path); - } - - protected void validatePaths(final Path forgePath, final Path[] mcPaths, String forgeVersion, String mcVersion, String mcpVersion) { - if (!Files.exists(forgePath)) { - LOGGER.fatal(CORE, "Failed to find forge version {} for MC {} at {}", forgeVersion, mcVersion, forgePath); - throw new RuntimeException("Missing forge!"); - } - - Stream.of(mcPaths).forEach(p->{ - if (!Files.exists(p)) { - LOGGER.fatal(CORE, "Failed to find Minecraft resource version {} at {}", mcVersion+"-"+mcpVersion, p); - throw new RuntimeException("Missing minecraft resource!"); - } - }); - - } - - - protected Function> getClassLoaderResourceEnumerationFunction() { - return input->FMLLoader.getLoadingModList().findAllURLsForResource(input); - } - - protected Function> getClassLoaderManifestLocatorFunction() { - return urlConnection -> { - if (urlConnection instanceof ModJarURLHandler.ModJarURLConnection) { - return ((ModJarURLHandler.ModJarURLConnection) urlConnection).getManifest(); - } else { - return Optional.empty(); - } - }; - } - - protected abstract String getNaming(); - - void addLibraries(final List libraries) { - libraries - .stream() - .map(ModFile::getFilePath) - .peek(p->LOGGER.debug(LOADING, "Adding {} as a library to the transforming classloader", p)) - .forEach(additionalLibraries::add); - } - - public boolean isProduction() { - return false; - } - - public boolean isData() { - return false; - }; -} diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/FMLServerLaunchProvider.java b/src/fmllauncher/java/net/minecraftforge/fml/loading/FMLServerLaunchProvider.java deleted file mode 100644 index 4265687d5f..0000000000 --- a/src/fmllauncher/java/net/minecraftforge/fml/loading/FMLServerLaunchProvider.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fml.loading; - -import cpw.mods.modlauncher.api.IEnvironment; -import cpw.mods.modlauncher.api.ILaunchHandlerService; -import cpw.mods.modlauncher.api.ITransformingClassLoader; -import net.minecraftforge.api.distmarker.Dist; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.Callable; - -public class FMLServerLaunchProvider extends FMLCommonLaunchHandler implements ILaunchHandlerService -{ - private static final Logger LOGGER = LogManager.getLogger(); - - @Override - public String name() - { - return "fmlserver"; - } - - @Override - public Callable launchService(String[] arguments, ITransformingClassLoader launchClassLoader) - { - return () -> { - super.beforeStart(launchClassLoader); - launchClassLoader.addTargetPackageFilter(getPackagePredicate()); - Class.forName("net.minecraft.server.Main", true, launchClassLoader.getInstance()).getMethod("main", String[].class).invoke(null, (Object)arguments); - return null; - }; - } - - @SuppressWarnings("unchecked") - @Override - public void setup(final IEnvironment environment, final Map arguments) { - final List mavenRoots = new ArrayList<>((List) arguments.get("mavenRoots")); - final List mods = new ArrayList<>((List) arguments.get("mods")); - mavenRoots.add(LibraryFinder.findLibsPath().toString()); - final String forgeVersion = (String) arguments.get("forgeVersion"); - final String mcVersion = (String) arguments.get("mcVersion"); - final String forgeGroup = (String) arguments.get("forgeGroup"); - mods.add(forgeGroup+":forge:universal:"+mcVersion+"-"+forgeVersion); - // generics are gross yea? - ((Map)arguments).put("mavenRoots", mavenRoots); - ((Map)arguments).put("mods", mods); - } - - @Override - public Dist getDist() - { - return Dist.DEDICATED_SERVER; - } - - @Override - protected String getNaming() { - return "srg"; - } - - @Override - public Path[] getPaths() { - return FMLLoader.getMCPaths(); - } - - @Override - public boolean isProduction() { - return true; - } -} diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/FixSSL.java b/src/fmllauncher/java/net/minecraftforge/fml/loading/FixSSL.java deleted file mode 100644 index 6c20af6481..0000000000 --- a/src/fmllauncher/java/net/minecraftforge/fml/loading/FixSSL.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fml.loading; - -import org.apache.logging.log4j.LogManager; - -import javax.net.ssl.HttpsURLConnection; -import javax.net.ssl.SSLContext; -import javax.net.ssl.TrustManagerFactory; -import java.io.IOException; -import java.io.InputStream; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.security.KeyManagementException; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.cert.Certificate; -import java.security.cert.CertificateException; -import java.util.Collections; -import java.util.Map; -import java.util.stream.Collectors; - -import static cpw.mods.modlauncher.api.LamdbaExceptionUtils.rethrowBiConsumer; -import static cpw.mods.modlauncher.api.LamdbaExceptionUtils.rethrowFunction; -import static net.minecraftforge.fml.loading.LogMarkers.CORE; - - -/** - * This class fixes older Java SSL setups which don't contain the correct root certificates to trust Let's Encrypt - * https endpoints. - * - * It uses a secondary JKS keystore: lekeystore.jks, which contains the two root certificate keys as documented here: - * https://letsencrypt.org/certificates/ - * - * To create the keystore, the following commands were run: - *

- *     keytool -import -alias letsencryptisrgx1 -file isrgrootx1.pem -keystore lekeystore.jks -storetype jks -storepass supersecretpassword -v
- *     keytool -import -alias identrustx3 -file identrustx3.pem -keystore lekeystore.jks -storetype jks -storepass supersecretpassword -v
- * 
- * - * The PEM files were obtained from the above URL. - */ -class FixSSL { - static void fixup() { - try { - final KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType()); - Path ksPath = Paths.get(System.getProperty("java.home"),"lib", "security", "cacerts"); - keyStore.load(Files.newInputStream(ksPath), "changeit".toCharArray()); - final Map jdkTrustStore = Collections.list(keyStore.aliases()).stream().collect(Collectors.toMap(a -> a, rethrowFunction(keyStore::getCertificate))); - - final KeyStore leKS = KeyStore.getInstance(KeyStore.getDefaultType()); - final InputStream leKSFile = FixSSL.class.getResourceAsStream("/lekeystore.jks"); - leKS.load(leKSFile, "supersecretpassword".toCharArray()); - final Map leTrustStore = Collections.list(leKS.aliases()).stream().collect(Collectors.toMap(a -> a, rethrowFunction(leKS::getCertificate))); - - final KeyStore mergedTrustStore = KeyStore.getInstance(KeyStore.getDefaultType()); - mergedTrustStore.load(null, new char[0]); - jdkTrustStore.forEach(rethrowBiConsumer(mergedTrustStore::setCertificateEntry)); - leTrustStore.forEach(rethrowBiConsumer(mergedTrustStore::setCertificateEntry)); - - final TrustManagerFactory instance = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); - instance.init(mergedTrustStore); - final SSLContext tls = SSLContext.getInstance("TLS"); - tls.init(null, instance.getTrustManagers(), null); - HttpsURLConnection.setDefaultSSLSocketFactory(tls.getSocketFactory()); - LogManager.getLogger().info(CORE, "Added Lets Encrypt root certificates as additional trust"); - } catch (KeyStoreException | IOException | NoSuchAlgorithmException | CertificateException | KeyManagementException e) { - LogManager.getLogger().fatal(CORE,"Failed to load lets encrypt certificate. Expect problems", e); - } - - } -} diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/Java9BackportUtils.java b/src/fmllauncher/java/net/minecraftforge/fml/loading/Java9BackportUtils.java deleted file mode 100644 index 11f1c9171a..0000000000 --- a/src/fmllauncher/java/net/minecraftforge/fml/loading/Java9BackportUtils.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fml.loading; - -import java.util.Optional; -import java.util.function.BiConsumer; -import java.util.function.Consumer; -import java.util.function.Function; -import java.util.stream.Collector; -import java.util.stream.Stream; - -public class Java9BackportUtils -{ - public static - Collector flatMapping(Function> mapper, - Collector downstream) { - BiConsumer downstreamAccumulator = downstream.accumulator(); - return Collector.of(downstream.supplier(), - (r, t) -> { - try (Stream result = mapper.apply(t)) { - if (result != null) - result.sequential().forEach(u -> downstreamAccumulator.accept(r, u)); - } - }, - downstream.combiner(), downstream.finisher(), - downstream.characteristics().toArray(new Collector.Characteristics[0])); - } - - public static void ifPresentOrElse(Optional optional, Consumer action, Runnable emptyAction) { - if (optional.isPresent()) { - action.accept(optional.get()); - } else { - emptyAction.run(); - } - } - - public static Stream toStream(final Optional optional) { - return optional.map(Stream::of).orElseGet(Stream::empty); - } -} diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/AbstractJarFileLocator.java b/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/AbstractJarFileLocator.java deleted file mode 100644 index 4da0a25897..0000000000 --- a/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/AbstractJarFileLocator.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fml.loading.moddiscovery; - -import cpw.mods.modlauncher.api.LamdbaExceptionUtils; -import net.minecraftforge.forgespi.locating.IModFile; -import net.minecraftforge.forgespi.locating.IModLocator; -import org.apache.commons.lang3.tuple.Pair; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.io.IOException; -import java.lang.reflect.Method; -import java.nio.file.FileSystem; -import java.nio.file.FileSystems; -import java.nio.file.Files; -import java.nio.file.Path; -import java.security.CodeSigner; -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; -import java.util.function.Consumer; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; -import java.util.jar.Manifest; -import java.util.stream.Stream; -import java.util.zip.ZipError; - -import static net.minecraftforge.fml.loading.LogMarkers.SCAN; - -public abstract class AbstractJarFileLocator implements IModLocator { - private static final Logger LOGGER = LogManager.getLogger(); - protected final Map modJars; - - public AbstractJarFileLocator() { - this.modJars = new HashMap<>(); - } - - protected FileSystem createFileSystem(IModFile modFile) { - try { - return FileSystems.newFileSystem(modFile.getFilePath(), modFile.getClass().getClassLoader()); - } catch (ZipError | IOException e) { - LOGGER.debug(SCAN,"Invalid JAR file {} - no filesystem created", modFile.getFilePath()); - return null; - } - } - - @Override - public Path findPath(final IModFile modFile, final String... path) { - if (path.length < 1) { - throw new IllegalArgumentException("Missing path"); - } - return modJars.get(modFile).getPath("",path); - } - - @Override - public void scanFile(final IModFile file, final Consumer pathConsumer) { - LOGGER.debug(SCAN,"Scan started: {}", file); - FileSystem fs = modJars.get(file); - fs.getRootDirectories().forEach(path -> { - try (Stream files = Files.find(path, Integer.MAX_VALUE, (p, a) -> p.getNameCount() > 0 && p.getFileName().toString().endsWith(".class"))) { - files.forEach(pathConsumer); - } catch (IOException e) { - e.printStackTrace(); - } - }); - LOGGER.debug(SCAN,"Scan finished: {}", file); - } - - static final Method ENSURE_INIT = LamdbaExceptionUtils.uncheck(()->JarFile.class.getDeclaredMethod("ensureInitialization")); - static { - ENSURE_INIT.setAccessible(true); - } - @Override - public Optional findManifest(final Path file) - { - return findManifestAndSigners(file).getKey(); - } - - @Override - public Pair, Optional> findManifestAndSigners(final Path file) { - try (JarFile jf = new JarFile(file.toFile())) - { - final Manifest manifest = jf.getManifest(); - if (manifest!=null) { - final JarEntry jarEntry = jf.getJarEntry(JarFile.MANIFEST_NAME); - LamdbaExceptionUtils.uncheck(() -> ENSURE_INIT.invoke(jf)); - return Pair.of(Optional.of(manifest), Optional.ofNullable(jarEntry.getCodeSigners())); - } - return Pair.of(Optional.empty(), Optional.empty()); - } - catch (IOException e) - { - return Pair.of(Optional.empty(), Optional.empty()); - } - } - - @Override - public boolean isValid(final IModFile modFile) { - return modJars.get(modFile) != null; - } -} diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/ExplodedDirectoryLocator.java b/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/ExplodedDirectoryLocator.java deleted file mode 100644 index 3ea8ce3b23..0000000000 --- a/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/ExplodedDirectoryLocator.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fml.loading.moddiscovery; - -import net.minecraftforge.forgespi.locating.IModFile; -import net.minecraftforge.forgespi.locating.IModLocator; -import org.apache.commons.lang3.tuple.Pair; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.io.IOException; -import java.nio.file.*; -import java.util.*; -import java.util.function.Consumer; -import java.util.jar.Manifest; -import java.util.stream.Stream; - -import static net.minecraftforge.fml.loading.LogMarkers.LOADING; -import static net.minecraftforge.fml.loading.LogMarkers.SCAN; - -public class ExplodedDirectoryLocator implements IModLocator { - private static final Logger LOGGER = LogManager.getLogger(); - private final List>> rootDirs; - private final Map>> mods; - - public ExplodedDirectoryLocator() { - this.rootDirs = new ArrayList<>(); - this.mods = new HashMap<>(); - } - - @Override - public List scanMods() { - final Path modstoml = Paths.get("META-INF", "mods.toml"); - // Collect all the mods.toml files found - rootDirs.forEach(pathPathPair -> { - Path resources = pathPathPair.getLeft(); - Path modtoml = resources.resolve(modstoml); - if (Files.exists(modtoml)) { - LOGGER.debug(LOADING, "Found exploded directory mod manifest at {}", modtoml.toString()); - ModFile mf = ModFile.newFMLInstance(pathPathPair.getLeft(), this); - mods.put(mf, pathPathPair); - } else { - LOGGER.warn(LOADING, "Failed to find exploded resource mods.toml in directory {}", resources.toString()); - } - }); - return new ArrayList<>(mods.keySet()); - } - - @Override - public String name() { - return "exploded directory"; - } - - @Override - public Path findPath(final IModFile modFile, final String... path) { - if (path.length < 1) { - throw new IllegalArgumentException("Missing path"); - } - final Path target = Paths.get(path[0], Arrays.copyOfRange(path, 1, path.length)); - // try right path first (resources) - Path found = mods.get(modFile).getLeft().resolve(target); - if (Files.exists(found)) return found; - // then try left path (classes) - return mods.get(modFile).getRight().stream().map(p->p.resolve(target)).filter(Files::exists). - findFirst().orElse(found); - } - - @Override - public void scanFile(final IModFile modFile, final Consumer pathConsumer) { - LOGGER.debug(SCAN,"Scanning exploded directory {}", modFile.getFilePath().toString()); - final Pair> pathPathPair = mods.get(modFile); - // classes are in the right branch of the pair - pathPathPair.getRight().forEach(path->scanIndividualPath(path, pathConsumer)); - LOGGER.debug(SCAN,"Exploded directory scan complete {}", pathPathPair.getLeft().toString()); - } - - private void scanIndividualPath(final Path path, Consumer pathConsumer) { - if (!Files.exists(path)) return; - LOGGER.debug(SCAN, "Scanning exploded target {}", path.toString()); - try (Stream files = Files.find(path, Integer.MAX_VALUE, (p, a) -> p.getNameCount() > 0 && p.getFileName().toString().endsWith(".class"))) { - files.forEach(pathConsumer); - } catch (IOException e) { - LOGGER.error(SCAN,"Exception scanning {}", path, e); - } - } - @Override - public String toString() - { - return "{ExplodedDir locator}"; - } - - @Override - public Optional findManifest(Path file) - { - return Optional.empty(); - } - - @SuppressWarnings("unchecked") - @Override - public void initArguments(final Map arguments) { - final List>> explodedTargets = ((Map>>>) arguments).get("explodedTargets"); - if (explodedTargets != null && !explodedTargets.isEmpty()) { - rootDirs.addAll(explodedTargets); - } - } - - @Override - public boolean isValid(final IModFile modFile) { - return mods.get(modFile) != null; - } -} diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/ModDiscoverer.java b/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/ModDiscoverer.java deleted file mode 100644 index 0bce6e1f33..0000000000 --- a/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/ModDiscoverer.java +++ /dev/null @@ -1,259 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fml.loading.moddiscovery; - -import cpw.mods.gross.Java9ClassLoaderUtil; -import cpw.mods.modlauncher.Launcher; -import cpw.mods.modlauncher.ServiceLoaderStreamUtils; -import cpw.mods.modlauncher.api.LamdbaExceptionUtils; -import net.minecraftforge.fml.loading.FMLEnvironment; -import net.minecraftforge.fml.loading.FMLLoader; -import net.minecraftforge.fml.loading.LoadingModList; -import net.minecraftforge.fml.loading.ModDirTransformerDiscoverer; -import net.minecraftforge.fml.loading.ModSorter; -import net.minecraftforge.fml.loading.progress.StartupMessageManager; -import net.minecraftforge.forgespi.Environment; -import net.minecraftforge.forgespi.locating.IModFile; -import net.minecraftforge.forgespi.locating.IModLocator; -import org.apache.commons.lang3.tuple.Pair; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; -import java.net.URLClassLoader; -import java.nio.file.FileSystem; -import java.nio.file.FileSystems; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.security.CodeSigner; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import java.util.ServiceLoader; -import java.util.function.Consumer; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; -import java.util.jar.Manifest; -import java.util.stream.Collectors; -import java.util.stream.Stream; -import java.util.zip.ZipError; - -import static net.minecraftforge.fml.loading.LogMarkers.CORE; -import static net.minecraftforge.fml.loading.LogMarkers.SCAN; - - -public class ModDiscoverer { - private static final Path INVALID_PATH = Paths.get("This", "Path", "Should", "Never", "Exist", "Because", "That", "Would", "Be", "Stupid", "CON", "AUX", "/dev/null"); - private static final Logger LOGGER = LogManager.getLogger(); - private final ServiceLoader locators; - private final List locatorList; - private final LocatorClassLoader locatorClassLoader; - - public ModDiscoverer(Map arguments) { - Launcher.INSTANCE.environment().computePropertyIfAbsent(Environment.Keys.MODFOLDERFACTORY.get(), v->ModsFolderLocator::new); - Launcher.INSTANCE.environment().computePropertyIfAbsent(Environment.Keys.MODDIRECTORYFACTORY.get(), v->ModsFolderLocator::new); - Launcher.INSTANCE.environment().computePropertyIfAbsent(Environment.Keys.PROGRESSMESSAGE.get(), v->StartupMessageManager.locatorConsumer().orElseGet(()->s->{})); - locatorClassLoader = new LocatorClassLoader(); - Launcher.INSTANCE.environment().computePropertyIfAbsent(FMLEnvironment.Keys.LOCATORCLASSLOADER.get(), v->locatorClassLoader); - ModDirTransformerDiscoverer.getExtraLocators() - .stream() - .map(LamdbaExceptionUtils.rethrowFunction(p->p.toUri().toURL())) - .forEach(locatorClassLoader::addURL); - locators = ServiceLoader.load(IModLocator.class, locatorClassLoader); - locatorList = ServiceLoaderStreamUtils.toList(this.locators); - locatorList.forEach(l->l.initArguments(arguments)); - locatorList.add(new MinecraftLocator()); - LOGGER.debug(CORE,"Found Mod Locators : {}", ()->locatorList.stream().map(iModLocator -> "("+iModLocator.name() + ":" + iModLocator.getClass().getPackage().getImplementationVersion()+")").collect(Collectors.joining(","))); - } - - ModDiscoverer(List locatorList) { - this.locatorList = locatorList; - this.locatorClassLoader = null; - this.locators = null; - } - - public BackgroundScanHandler discoverMods() { - LOGGER.debug(SCAN,"Scanning for mods and other resources to load. We know {} ways to find mods", locatorList.size()); - final Map> modFiles = locatorList.stream() - .peek(loc -> LOGGER.debug(SCAN,"Trying locator {}", loc)) - .map(IModLocator::scanMods) - .flatMap(Collection::stream) - .peek(mf -> LOGGER.debug(SCAN,"Found mod file {} of type {} with locator {}", mf.getFileName(), mf.getType(), mf.getLocator())) - .peek(mf -> StartupMessageManager.modLoaderConsumer().ifPresent(c->c.accept("Found mod file "+mf.getFileName()+" of type "+mf.getType()))) - .map(ModFile.class::cast) - .collect(Collectors.groupingBy(IModFile::getType)); - - FMLLoader.getLanguageLoadingProvider().addAdditionalLanguages(modFiles.get(IModFile.Type.LANGPROVIDER)); - BackgroundScanHandler backgroundScanHandler = new BackgroundScanHandler(modFiles); - final List mods = modFiles.getOrDefault(IModFile.Type.MOD, Collections.emptyList()); - final List brokenFiles = new ArrayList<>(); - for (Iterator iterator = mods.iterator(); iterator.hasNext(); ) - { - ModFile mod = iterator.next(); - if (!mod.getLocator().isValid(mod) || !mod.identifyMods()) { - LOGGER.warn(SCAN, "File {} has been ignored - it is invalid", mod.getFilePath()); - iterator.remove(); - brokenFiles.add(mod); - } - } - LOGGER.debug(SCAN,"Found {} mod files with {} mods", mods::size, ()->mods.stream().mapToInt(mf -> mf.getModInfos().size()).sum()); - StartupMessageManager.modLoaderConsumer().ifPresent(c->c.accept("Found "+mods.size()+" modfiles to load")); - final LoadingModList loadingModList = ModSorter.sort(mods); - loadingModList.addCoreMods(); - loadingModList.addAccessTransformers(); - loadingModList.addForScanning(backgroundScanHandler); - loadingModList.setBrokenFiles(brokenFiles); - return backgroundScanHandler; - } - - private static class LocatorClassLoader extends URLClassLoader { - LocatorClassLoader() { - super(Java9ClassLoaderUtil.getSystemClassPathURLs(), getSystemClassLoader()); - } - - @Override - protected void addURL(final URL url) { - super.addURL(url); - } - } - private static class MinecraftLocator implements IModLocator { - private final Path mcJar = FMLLoader.getMCPaths()[0]; - private final FileSystem fileSystem; - - MinecraftLocator() { - if (!Files.isDirectory(mcJar)) { - try { - fileSystem = FileSystems.newFileSystem(mcJar, getClass().getClassLoader()); - } catch (ZipError | IOException e) { - LOGGER.fatal(SCAN,"Invalid Minecraft JAR file - no filesystem created"); - throw new RuntimeException(e); - } - } else { - fileSystem = null; - } - } - - @Override - public List scanMods() { - return Collections.singletonList(ModFile.newFMLInstance(mcJar, this)); - } - - @Override - public String name() { - return "minecraft"; - } - - @Override - public Path findPath(final IModFile modFile, final String... path) { - if (path.length == 2 && Objects.equals(path[0], "META-INF")) { - if (Objects.equals(path[1], "mods.toml")) { - final URI jarFileURI; - try { - jarFileURI = getClass().getClassLoader().getResource("minecraftmod.toml").toURI(); - if (Objects.equals(jarFileURI.getScheme(), "jar")) { - // Initialize the filesystem for the forge jar, because otherwise this barfs? - FileSystems.newFileSystem(jarFileURI, new HashMap<>()); - } - } catch (URISyntaxException | IOException e) { - LOGGER.fatal(SCAN, "Unable to read minecraft default mod"); - throw new RuntimeException(e); - } - return Paths.get(jarFileURI); - } else if (Objects.equals(path[1], "coremods.json")) { - return INVALID_PATH; - } - } - if (Files.isDirectory(mcJar)) return findPathDirectory(modFile, path); - return findPathJar(modFile, path); - } - - private Path findPathDirectory(final IModFile modFile, final String... path) { - if (path.length < 1) { - throw new IllegalArgumentException("Missing path"); - } - final Path target = Paths.get(path[0], Arrays.copyOfRange(path, 1, path.length)); - // try right path first (resources) - return mcJar.resolve(target); - } - - private Path findPathJar(final IModFile modFile, final String... path) { - return fileSystem.getPath(path[0], Arrays.copyOfRange(path, 1, path.length)); - } - @Override - public void scanFile(final IModFile modFile, final Consumer pathConsumer) { - LOGGER.debug(SCAN,"Scan started: {}", modFile); - Path path; - if (Files.isDirectory(mcJar)) - path = mcJar; - else - path = fileSystem.getPath("/"); - try (Stream files = Files.find(path, Integer.MAX_VALUE, (p, a) -> p.getNameCount() > 0 && p.getFileName().toString().endsWith(".class"))) { - files.forEach(pathConsumer); - } catch (IOException e) { - e.printStackTrace(); - } - LOGGER.debug(SCAN,"Scan finished: {}", modFile); - } - - @Override - public Pair, Optional> findManifestAndSigners(final Path file) { - if (Files.isDirectory(mcJar)) { - return Pair.of(Optional.empty(), Optional.empty()); - } - try (JarFile jf = new JarFile(mcJar.toFile())) { - final Manifest manifest = jf.getManifest(); - if (manifest!=null) { - final JarEntry jarEntry = jf.getJarEntry(JarFile.MANIFEST_NAME); - LamdbaExceptionUtils.uncheck(() -> AbstractJarFileLocator.ENSURE_INIT.invoke(jf)); - return Pair.of(Optional.of(manifest), Optional.ofNullable(jarEntry.getCodeSigners())); - } - } catch (IOException ioe) { - return Pair.of(Optional.empty(), Optional.empty()); - } - return Pair.of(Optional.empty(), Optional.empty()); - } - - @Override - public Optional findManifest(final Path file) { - return Optional.empty(); - } - - @Override - public void initArguments(final Map arguments) { - // no op - } - - @Override - public boolean isValid(final IModFile modFile) { - return true; - } - } -} diff --git a/src/fmllauncher/resources/META-INF/services/cpw.mods.modlauncher.api.ILaunchHandlerService b/src/fmllauncher/resources/META-INF/services/cpw.mods.modlauncher.api.ILaunchHandlerService deleted file mode 100644 index 9ae15f211c..0000000000 --- a/src/fmllauncher/resources/META-INF/services/cpw.mods.modlauncher.api.ILaunchHandlerService +++ /dev/null @@ -1,2 +0,0 @@ -net.minecraftforge.fml.loading.FMLClientLaunchProvider -net.minecraftforge.fml.loading.FMLServerLaunchProvider diff --git a/src/fmllauncher/resources/minecraftmod.toml b/src/fmllauncher/resources/minecraftmod.toml deleted file mode 100644 index 614b368493..0000000000 --- a/src/fmllauncher/resources/minecraftmod.toml +++ /dev/null @@ -1,13 +0,0 @@ -modLoader="minecraft" -loaderVersion="1" -license="Mojang Studios, All Rights Reserved" -[[mods]] - modId="minecraft" - version="${global.mcVersion}" - displayName="Minecraft" - logoFile="mcplogo.png" - credits="Mojang, deobfuscated by MCP" - authors="MCP: Searge,ProfMobius,IngisKahn,Fesh0r,ZeuX,R4wk,LexManos,Bspkrs" - description=''' - Minecraft, decompiled and deobfuscated with MCP technology - ''' \ No newline at end of file diff --git a/src/generated/resources/data/forge/tags/items/barrels.json b/src/generated/resources/data/forge/tags/items/barrels.json new file mode 100644 index 0000000000..4af754bdec --- /dev/null +++ b/src/generated/resources/data/forge/tags/items/barrels.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "#forge:barrels/wooden" + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/forge/tags/items/barrels/wooden.json b/src/generated/resources/data/forge/tags/items/barrels/wooden.json new file mode 100644 index 0000000000..01825818a4 --- /dev/null +++ b/src/generated/resources/data/forge/tags/items/barrels/wooden.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "minecraft:barrel" + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/loot_tables/blocks/acacia_leaves.json b/src/generated/resources/data/minecraft/loot_tables/blocks/acacia_leaves.json index 88edef3721..de2b04da59 100644 --- a/src/generated/resources/data/minecraft/loot_tables/blocks/acacia_leaves.json +++ b/src/generated/resources/data/minecraft/loot_tables/blocks/acacia_leaves.json @@ -2,7 +2,8 @@ "type": "minecraft:block", "pools": [ { - "rolls": 1, + "rolls": 1.0, + "bonus_rolls": 0.0, "entries": [ { "type": "minecraft:alternatives", @@ -61,7 +62,8 @@ ] }, { - "rolls": 1, + "rolls": 1.0, + "bonus_rolls": 0.0, "entries": [ { "type": "minecraft:item", @@ -82,10 +84,11 @@ { "function": "minecraft:set_count", "count": { + "type": "minecraft:uniform", "min": 1.0, - "max": 2.0, - "type": "minecraft:uniform" - } + "max": 2.0 + }, + "add": false }, { "function": "minecraft:explosion_decay" @@ -122,7 +125,8 @@ ] } } - ] + ], + "functions": [] } ] } \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/loot_tables/blocks/azalea_leaves.json b/src/generated/resources/data/minecraft/loot_tables/blocks/azalea_leaves.json new file mode 100644 index 0000000000..93f279b86d --- /dev/null +++ b/src/generated/resources/data/minecraft/loot_tables/blocks/azalea_leaves.json @@ -0,0 +1,132 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1.0, + "bonus_rolls": 0.0, + "entries": [ + { + "type": "minecraft:alternatives", + "children": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:alternative", + "terms": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "tag": "forge:shears" + } + }, + { + "condition": "minecraft:match_tool", + "predicate": { + "enchantments": [ + { + "enchantment": "minecraft:silk_touch", + "levels": { + "min": 1 + } + } + ] + } + } + ] + } + ], + "name": "minecraft:azalea_leaves" + }, + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:survives_explosion" + }, + { + "condition": "minecraft:table_bonus", + "enchantment": "minecraft:fortune", + "chances": [ + 0.05, + 0.0625, + 0.083333336, + 0.1 + ] + } + ], + "name": "minecraft:azalea" + } + ] + } + ] + }, + { + "rolls": 1.0, + "bonus_rolls": 0.0, + "entries": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:table_bonus", + "enchantment": "minecraft:fortune", + "chances": [ + 0.02, + 0.022222223, + 0.025, + 0.033333335, + 0.1 + ] + } + ], + "functions": [ + { + "function": "minecraft:set_count", + "count": { + "type": "minecraft:uniform", + "min": 1.0, + "max": 2.0 + }, + "add": false + }, + { + "function": "minecraft:explosion_decay" + } + ], + "name": "minecraft:stick" + } + ], + "conditions": [ + { + "condition": "minecraft:inverted", + "term": { + "condition": "minecraft:alternative", + "terms": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "tag": "forge:shears" + } + }, + { + "condition": "minecraft:match_tool", + "predicate": { + "enchantments": [ + { + "enchantment": "minecraft:silk_touch", + "levels": { + "min": 1 + } + } + ] + } + } + ] + } + } + ], + "functions": [] + } + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/loot_tables/blocks/birch_leaves.json b/src/generated/resources/data/minecraft/loot_tables/blocks/birch_leaves.json index 0a36f451b8..0493f6f418 100644 --- a/src/generated/resources/data/minecraft/loot_tables/blocks/birch_leaves.json +++ b/src/generated/resources/data/minecraft/loot_tables/blocks/birch_leaves.json @@ -2,7 +2,8 @@ "type": "minecraft:block", "pools": [ { - "rolls": 1, + "rolls": 1.0, + "bonus_rolls": 0.0, "entries": [ { "type": "minecraft:alternatives", @@ -61,7 +62,8 @@ ] }, { - "rolls": 1, + "rolls": 1.0, + "bonus_rolls": 0.0, "entries": [ { "type": "minecraft:item", @@ -82,10 +84,11 @@ { "function": "minecraft:set_count", "count": { + "type": "minecraft:uniform", "min": 1.0, - "max": 2.0, - "type": "minecraft:uniform" - } + "max": 2.0 + }, + "add": false }, { "function": "minecraft:explosion_decay" @@ -122,7 +125,8 @@ ] } } - ] + ], + "functions": [] } ] } \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/loot_tables/blocks/cobweb.json b/src/generated/resources/data/minecraft/loot_tables/blocks/cobweb.json index f805a361eb..dd9d38acef 100644 --- a/src/generated/resources/data/minecraft/loot_tables/blocks/cobweb.json +++ b/src/generated/resources/data/minecraft/loot_tables/blocks/cobweb.json @@ -2,7 +2,8 @@ "type": "minecraft:block", "pools": [ { - "rolls": 1, + "rolls": 1.0, + "bonus_rolls": 0.0, "entries": [ { "type": "minecraft:alternatives", diff --git a/src/generated/resources/data/minecraft/loot_tables/blocks/dark_oak_leaves.json b/src/generated/resources/data/minecraft/loot_tables/blocks/dark_oak_leaves.json index 9c68891876..23402d820a 100644 --- a/src/generated/resources/data/minecraft/loot_tables/blocks/dark_oak_leaves.json +++ b/src/generated/resources/data/minecraft/loot_tables/blocks/dark_oak_leaves.json @@ -2,7 +2,8 @@ "type": "minecraft:block", "pools": [ { - "rolls": 1, + "rolls": 1.0, + "bonus_rolls": 0.0, "entries": [ { "type": "minecraft:alternatives", @@ -61,7 +62,8 @@ ] }, { - "rolls": 1, + "rolls": 1.0, + "bonus_rolls": 0.0, "entries": [ { "type": "minecraft:item", @@ -82,10 +84,11 @@ { "function": "minecraft:set_count", "count": { + "type": "minecraft:uniform", "min": 1.0, - "max": 2.0, - "type": "minecraft:uniform" - } + "max": 2.0 + }, + "add": false }, { "function": "minecraft:explosion_decay" @@ -122,10 +125,12 @@ ] } } - ] + ], + "functions": [] }, { - "rolls": 1, + "rolls": 1.0, + "bonus_rolls": 0.0, "entries": [ { "type": "minecraft:item", @@ -176,7 +181,8 @@ ] } } - ] + ], + "functions": [] } ] } \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/loot_tables/blocks/dead_bush.json b/src/generated/resources/data/minecraft/loot_tables/blocks/dead_bush.json index 050ffda4b8..1de7671d13 100644 --- a/src/generated/resources/data/minecraft/loot_tables/blocks/dead_bush.json +++ b/src/generated/resources/data/minecraft/loot_tables/blocks/dead_bush.json @@ -2,7 +2,8 @@ "type": "minecraft:block", "pools": [ { - "rolls": 1, + "rolls": 1.0, + "bonus_rolls": 0.0, "entries": [ { "type": "minecraft:alternatives", @@ -25,10 +26,11 @@ { "function": "minecraft:set_count", "count": { + "type": "minecraft:uniform", "min": 0.0, - "max": 2.0, - "type": "minecraft:uniform" - } + "max": 2.0 + }, + "add": false }, { "function": "minecraft:explosion_decay" diff --git a/src/generated/resources/data/minecraft/loot_tables/blocks/fern.json b/src/generated/resources/data/minecraft/loot_tables/blocks/fern.json index 941e6af61c..1526f46377 100644 --- a/src/generated/resources/data/minecraft/loot_tables/blocks/fern.json +++ b/src/generated/resources/data/minecraft/loot_tables/blocks/fern.json @@ -2,7 +2,8 @@ "type": "minecraft:block", "pools": [ { - "rolls": 1, + "rolls": 1.0, + "bonus_rolls": 0.0, "entries": [ { "type": "minecraft:alternatives", diff --git a/src/generated/resources/data/minecraft/loot_tables/blocks/flowering_azalea_leaves.json b/src/generated/resources/data/minecraft/loot_tables/blocks/flowering_azalea_leaves.json new file mode 100644 index 0000000000..11f34be9e7 --- /dev/null +++ b/src/generated/resources/data/minecraft/loot_tables/blocks/flowering_azalea_leaves.json @@ -0,0 +1,132 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1.0, + "bonus_rolls": 0.0, + "entries": [ + { + "type": "minecraft:alternatives", + "children": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:alternative", + "terms": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "tag": "forge:shears" + } + }, + { + "condition": "minecraft:match_tool", + "predicate": { + "enchantments": [ + { + "enchantment": "minecraft:silk_touch", + "levels": { + "min": 1 + } + } + ] + } + } + ] + } + ], + "name": "minecraft:flowering_azalea_leaves" + }, + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:survives_explosion" + }, + { + "condition": "minecraft:table_bonus", + "enchantment": "minecraft:fortune", + "chances": [ + 0.05, + 0.0625, + 0.083333336, + 0.1 + ] + } + ], + "name": "minecraft:flowering_azalea" + } + ] + } + ] + }, + { + "rolls": 1.0, + "bonus_rolls": 0.0, + "entries": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:table_bonus", + "enchantment": "minecraft:fortune", + "chances": [ + 0.02, + 0.022222223, + 0.025, + 0.033333335, + 0.1 + ] + } + ], + "functions": [ + { + "function": "minecraft:set_count", + "count": { + "type": "minecraft:uniform", + "min": 1.0, + "max": 2.0 + }, + "add": false + }, + { + "function": "minecraft:explosion_decay" + } + ], + "name": "minecraft:stick" + } + ], + "conditions": [ + { + "condition": "minecraft:inverted", + "term": { + "condition": "minecraft:alternative", + "terms": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "tag": "forge:shears" + } + }, + { + "condition": "minecraft:match_tool", + "predicate": { + "enchantments": [ + { + "enchantment": "minecraft:silk_touch", + "levels": { + "min": 1 + } + } + ] + } + } + ] + } + } + ], + "functions": [] + } + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/loot_tables/blocks/grass.json b/src/generated/resources/data/minecraft/loot_tables/blocks/grass.json index dd232ebab7..ebdc7d44eb 100644 --- a/src/generated/resources/data/minecraft/loot_tables/blocks/grass.json +++ b/src/generated/resources/data/minecraft/loot_tables/blocks/grass.json @@ -2,7 +2,8 @@ "type": "minecraft:block", "pools": [ { - "rolls": 1, + "rolls": 1.0, + "bonus_rolls": 0.0, "entries": [ { "type": "minecraft:alternatives", diff --git a/src/generated/resources/data/minecraft/loot_tables/blocks/hanging_roots.json b/src/generated/resources/data/minecraft/loot_tables/blocks/hanging_roots.json new file mode 100644 index 0000000000..b12616a055 --- /dev/null +++ b/src/generated/resources/data/minecraft/loot_tables/blocks/hanging_roots.json @@ -0,0 +1,24 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1.0, + "bonus_rolls": 0.0, + "entries": [ + { + "type": "minecraft:item", + "name": "minecraft:hanging_roots" + } + ], + "conditions": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "tag": "forge:shears" + } + } + ], + "functions": [] + } + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/loot_tables/blocks/jungle_leaves.json b/src/generated/resources/data/minecraft/loot_tables/blocks/jungle_leaves.json index 181c7d7aa6..c9328141f2 100644 --- a/src/generated/resources/data/minecraft/loot_tables/blocks/jungle_leaves.json +++ b/src/generated/resources/data/minecraft/loot_tables/blocks/jungle_leaves.json @@ -2,7 +2,8 @@ "type": "minecraft:block", "pools": [ { - "rolls": 1, + "rolls": 1.0, + "bonus_rolls": 0.0, "entries": [ { "type": "minecraft:alternatives", @@ -62,7 +63,8 @@ ] }, { - "rolls": 1, + "rolls": 1.0, + "bonus_rolls": 0.0, "entries": [ { "type": "minecraft:item", @@ -83,10 +85,11 @@ { "function": "minecraft:set_count", "count": { + "type": "minecraft:uniform", "min": 1.0, - "max": 2.0, - "type": "minecraft:uniform" - } + "max": 2.0 + }, + "add": false }, { "function": "minecraft:explosion_decay" @@ -123,7 +126,8 @@ ] } } - ] + ], + "functions": [] } ] } \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/loot_tables/blocks/large_fern.json b/src/generated/resources/data/minecraft/loot_tables/blocks/large_fern.json index 7b70375037..1f5fa417f7 100644 --- a/src/generated/resources/data/minecraft/loot_tables/blocks/large_fern.json +++ b/src/generated/resources/data/minecraft/loot_tables/blocks/large_fern.json @@ -3,6 +3,7 @@ "pools": [ { "rolls": 1.0, + "bonus_rolls": 0.0, "entries": [ { "type": "minecraft:alternatives", @@ -20,7 +21,8 @@ "functions": [ { "function": "minecraft:set_count", - "count": 2 + "count": 2.0, + "add": false } ], "name": "minecraft:fern" @@ -53,7 +55,9 @@ "condition": "minecraft:location_check", "predicate": { "block": { - "block": "minecraft:large_fern", + "blocks": [ + "minecraft:large_fern" + ], "state": { "half": "upper" } @@ -61,10 +65,12 @@ }, "offsetY": 1 } - ] + ], + "functions": [] }, { "rolls": 1.0, + "bonus_rolls": 0.0, "entries": [ { "type": "minecraft:alternatives", @@ -82,7 +88,8 @@ "functions": [ { "function": "minecraft:set_count", - "count": 2 + "count": 2.0, + "add": false } ], "name": "minecraft:fern" @@ -115,7 +122,9 @@ "condition": "minecraft:location_check", "predicate": { "block": { - "block": "minecraft:large_fern", + "blocks": [ + "minecraft:large_fern" + ], "state": { "half": "lower" } @@ -123,7 +132,8 @@ }, "offsetY": -1 } - ] + ], + "functions": [] } ] } \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/loot_tables/blocks/nether_sprouts.json b/src/generated/resources/data/minecraft/loot_tables/blocks/nether_sprouts.json index 7b3c2751ee..661dccdd71 100644 --- a/src/generated/resources/data/minecraft/loot_tables/blocks/nether_sprouts.json +++ b/src/generated/resources/data/minecraft/loot_tables/blocks/nether_sprouts.json @@ -2,7 +2,8 @@ "type": "minecraft:block", "pools": [ { - "rolls": 1, + "rolls": 1.0, + "bonus_rolls": 0.0, "entries": [ { "type": "minecraft:item", @@ -16,7 +17,8 @@ "tag": "forge:shears" } } - ] + ], + "functions": [] } ] } \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/loot_tables/blocks/oak_leaves.json b/src/generated/resources/data/minecraft/loot_tables/blocks/oak_leaves.json index 29827e48b2..f9741d69ea 100644 --- a/src/generated/resources/data/minecraft/loot_tables/blocks/oak_leaves.json +++ b/src/generated/resources/data/minecraft/loot_tables/blocks/oak_leaves.json @@ -2,7 +2,8 @@ "type": "minecraft:block", "pools": [ { - "rolls": 1, + "rolls": 1.0, + "bonus_rolls": 0.0, "entries": [ { "type": "minecraft:alternatives", @@ -61,7 +62,8 @@ ] }, { - "rolls": 1, + "rolls": 1.0, + "bonus_rolls": 0.0, "entries": [ { "type": "minecraft:item", @@ -82,10 +84,11 @@ { "function": "minecraft:set_count", "count": { + "type": "minecraft:uniform", "min": 1.0, - "max": 2.0, - "type": "minecraft:uniform" - } + "max": 2.0 + }, + "add": false }, { "function": "minecraft:explosion_decay" @@ -122,10 +125,12 @@ ] } } - ] + ], + "functions": [] }, { - "rolls": 1, + "rolls": 1.0, + "bonus_rolls": 0.0, "entries": [ { "type": "minecraft:item", @@ -176,7 +181,8 @@ ] } } - ] + ], + "functions": [] } ] } \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/loot_tables/blocks/seagrass.json b/src/generated/resources/data/minecraft/loot_tables/blocks/seagrass.json index ebc23c36e8..6d6a050c1f 100644 --- a/src/generated/resources/data/minecraft/loot_tables/blocks/seagrass.json +++ b/src/generated/resources/data/minecraft/loot_tables/blocks/seagrass.json @@ -2,7 +2,8 @@ "type": "minecraft:block", "pools": [ { - "rolls": 1, + "rolls": 1.0, + "bonus_rolls": 0.0, "entries": [ { "type": "minecraft:item", @@ -16,7 +17,8 @@ "tag": "forge:shears" } } - ] + ], + "functions": [] } ] } \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/loot_tables/blocks/small_dripleaf.json b/src/generated/resources/data/minecraft/loot_tables/blocks/small_dripleaf.json new file mode 100644 index 0000000000..e83528f069 --- /dev/null +++ b/src/generated/resources/data/minecraft/loot_tables/blocks/small_dripleaf.json @@ -0,0 +1,24 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1.0, + "bonus_rolls": 0.0, + "entries": [ + { + "type": "minecraft:item", + "name": "minecraft:small_dripleaf" + } + ], + "conditions": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "tag": "forge:shears" + } + } + ], + "functions": [] + } + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/loot_tables/blocks/spruce_leaves.json b/src/generated/resources/data/minecraft/loot_tables/blocks/spruce_leaves.json index e9c5c6e548..2b6a30f244 100644 --- a/src/generated/resources/data/minecraft/loot_tables/blocks/spruce_leaves.json +++ b/src/generated/resources/data/minecraft/loot_tables/blocks/spruce_leaves.json @@ -2,7 +2,8 @@ "type": "minecraft:block", "pools": [ { - "rolls": 1, + "rolls": 1.0, + "bonus_rolls": 0.0, "entries": [ { "type": "minecraft:alternatives", @@ -61,7 +62,8 @@ ] }, { - "rolls": 1, + "rolls": 1.0, + "bonus_rolls": 0.0, "entries": [ { "type": "minecraft:item", @@ -82,10 +84,11 @@ { "function": "minecraft:set_count", "count": { + "type": "minecraft:uniform", "min": 1.0, - "max": 2.0, - "type": "minecraft:uniform" - } + "max": 2.0 + }, + "add": false }, { "function": "minecraft:explosion_decay" @@ -122,7 +125,8 @@ ] } } - ] + ], + "functions": [] } ] } \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/loot_tables/blocks/tall_grass.json b/src/generated/resources/data/minecraft/loot_tables/blocks/tall_grass.json index 53099b83ef..da92fe7642 100644 --- a/src/generated/resources/data/minecraft/loot_tables/blocks/tall_grass.json +++ b/src/generated/resources/data/minecraft/loot_tables/blocks/tall_grass.json @@ -3,6 +3,7 @@ "pools": [ { "rolls": 1.0, + "bonus_rolls": 0.0, "entries": [ { "type": "minecraft:alternatives", @@ -20,7 +21,8 @@ "functions": [ { "function": "minecraft:set_count", - "count": 2 + "count": 2.0, + "add": false } ], "name": "minecraft:grass" @@ -53,7 +55,9 @@ "condition": "minecraft:location_check", "predicate": { "block": { - "block": "minecraft:tall_grass", + "blocks": [ + "minecraft:tall_grass" + ], "state": { "half": "upper" } @@ -61,10 +65,12 @@ }, "offsetY": 1 } - ] + ], + "functions": [] }, { "rolls": 1.0, + "bonus_rolls": 0.0, "entries": [ { "type": "minecraft:alternatives", @@ -82,7 +88,8 @@ "functions": [ { "function": "minecraft:set_count", - "count": 2 + "count": 2.0, + "add": false } ], "name": "minecraft:grass" @@ -115,7 +122,9 @@ "condition": "minecraft:location_check", "predicate": { "block": { - "block": "minecraft:tall_grass", + "blocks": [ + "minecraft:tall_grass" + ], "state": { "half": "lower" } @@ -123,7 +132,8 @@ }, "offsetY": -1 } - ] + ], + "functions": [] } ] } \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/loot_tables/blocks/tall_seagrass.json b/src/generated/resources/data/minecraft/loot_tables/blocks/tall_seagrass.json index 435870efa4..8be352f97f 100644 --- a/src/generated/resources/data/minecraft/loot_tables/blocks/tall_seagrass.json +++ b/src/generated/resources/data/minecraft/loot_tables/blocks/tall_seagrass.json @@ -3,13 +3,15 @@ "pools": [ { "rolls": 1.0, + "bonus_rolls": 0.0, "entries": [ { "type": "minecraft:item", "functions": [ { "function": "minecraft:set_count", - "count": 2 + "count": 2.0, + "add": false } ], "name": "minecraft:seagrass" @@ -22,7 +24,8 @@ "tag": "forge:shears" } } - ] + ], + "functions": [] } ] } \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/loot_tables/blocks/twisting_vines.json b/src/generated/resources/data/minecraft/loot_tables/blocks/twisting_vines.json index b80165c6cc..efc2afa398 100644 --- a/src/generated/resources/data/minecraft/loot_tables/blocks/twisting_vines.json +++ b/src/generated/resources/data/minecraft/loot_tables/blocks/twisting_vines.json @@ -2,7 +2,8 @@ "type": "minecraft:block", "pools": [ { - "rolls": 1, + "rolls": 1.0, + "bonus_rolls": 0.0, "entries": [ { "type": "minecraft:alternatives", diff --git a/src/generated/resources/data/minecraft/loot_tables/blocks/vine.json b/src/generated/resources/data/minecraft/loot_tables/blocks/vine.json index fc7fa0d6f3..cd7b91ecbe 100644 --- a/src/generated/resources/data/minecraft/loot_tables/blocks/vine.json +++ b/src/generated/resources/data/minecraft/loot_tables/blocks/vine.json @@ -2,7 +2,8 @@ "type": "minecraft:block", "pools": [ { - "rolls": 1, + "rolls": 1.0, + "bonus_rolls": 0.0, "entries": [ { "type": "minecraft:item", @@ -16,7 +17,8 @@ "tag": "forge:shears" } } - ] + ], + "functions": [] } ] } \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/loot_tables/blocks/weeping_vines.json b/src/generated/resources/data/minecraft/loot_tables/blocks/weeping_vines.json index 27d2c62ec3..be3bcbc428 100644 --- a/src/generated/resources/data/minecraft/loot_tables/blocks/weeping_vines.json +++ b/src/generated/resources/data/minecraft/loot_tables/blocks/weeping_vines.json @@ -2,7 +2,8 @@ "type": "minecraft:block", "pools": [ { - "rolls": 1, + "rolls": 1.0, + "bonus_rolls": 0.0, "entries": [ { "type": "minecraft:alternatives", diff --git a/src/generated/resources/data/minecraft/recipes/acacia_fence.json b/src/generated/resources/data/minecraft/recipes/acacia_fence.json index 437fdd65db..554e8a55bf 100644 --- a/src/generated/resources/data/minecraft/recipes/acacia_fence.json +++ b/src/generated/resources/data/minecraft/recipes/acacia_fence.json @@ -6,11 +6,11 @@ "W#W" ], "key": { - "#": { - "tag": "forge:rods/wooden" - }, "W": { "item": "minecraft:acacia_planks" + }, + "#": { + "tag": "forge:rods/wooden" } }, "result": { diff --git a/src/generated/resources/data/minecraft/recipes/acacia_sign.json b/src/generated/resources/data/minecraft/recipes/acacia_sign.json index ea0e20fb38..b37b630d2d 100644 --- a/src/generated/resources/data/minecraft/recipes/acacia_sign.json +++ b/src/generated/resources/data/minecraft/recipes/acacia_sign.json @@ -1,6 +1,6 @@ { "type": "minecraft:crafting_shaped", - "group": "sign", + "group": "wooden_sign", "pattern": [ "###", "###", diff --git a/src/generated/resources/data/minecraft/recipes/birch_fence.json b/src/generated/resources/data/minecraft/recipes/birch_fence.json index a49a70b2b6..63be4c610d 100644 --- a/src/generated/resources/data/minecraft/recipes/birch_fence.json +++ b/src/generated/resources/data/minecraft/recipes/birch_fence.json @@ -6,11 +6,11 @@ "W#W" ], "key": { - "#": { - "tag": "forge:rods/wooden" - }, "W": { "item": "minecraft:birch_planks" + }, + "#": { + "tag": "forge:rods/wooden" } }, "result": { diff --git a/src/generated/resources/data/minecraft/recipes/birch_sign.json b/src/generated/resources/data/minecraft/recipes/birch_sign.json index 959499df37..fc652c51a8 100644 --- a/src/generated/resources/data/minecraft/recipes/birch_sign.json +++ b/src/generated/resources/data/minecraft/recipes/birch_sign.json @@ -1,6 +1,6 @@ { "type": "minecraft:crafting_shaped", - "group": "sign", + "group": "wooden_sign", "pattern": [ "###", "###", diff --git a/src/generated/resources/data/minecraft/recipes/crimson_fence.json b/src/generated/resources/data/minecraft/recipes/crimson_fence.json index a9d3d73765..6ce9b3490c 100644 --- a/src/generated/resources/data/minecraft/recipes/crimson_fence.json +++ b/src/generated/resources/data/minecraft/recipes/crimson_fence.json @@ -6,11 +6,11 @@ "W#W" ], "key": { - "#": { - "tag": "forge:rods/wooden" - }, "W": { "item": "minecraft:crimson_planks" + }, + "#": { + "tag": "forge:rods/wooden" } }, "result": { diff --git a/src/generated/resources/data/minecraft/recipes/crimson_sign.json b/src/generated/resources/data/minecraft/recipes/crimson_sign.json index 886e5e8b79..b5834a279a 100644 --- a/src/generated/resources/data/minecraft/recipes/crimson_sign.json +++ b/src/generated/resources/data/minecraft/recipes/crimson_sign.json @@ -1,6 +1,6 @@ { "type": "minecraft:crafting_shaped", - "group": "sign", + "group": "wooden_sign", "pattern": [ "###", "###", diff --git a/src/generated/resources/data/minecraft/recipes/dark_oak_fence.json b/src/generated/resources/data/minecraft/recipes/dark_oak_fence.json index 7336819a97..73f7737c8a 100644 --- a/src/generated/resources/data/minecraft/recipes/dark_oak_fence.json +++ b/src/generated/resources/data/minecraft/recipes/dark_oak_fence.json @@ -6,11 +6,11 @@ "W#W" ], "key": { - "#": { - "tag": "forge:rods/wooden" - }, "W": { "item": "minecraft:dark_oak_planks" + }, + "#": { + "tag": "forge:rods/wooden" } }, "result": { diff --git a/src/generated/resources/data/minecraft/recipes/dark_oak_sign.json b/src/generated/resources/data/minecraft/recipes/dark_oak_sign.json index 000147ecc0..7787876770 100644 --- a/src/generated/resources/data/minecraft/recipes/dark_oak_sign.json +++ b/src/generated/resources/data/minecraft/recipes/dark_oak_sign.json @@ -1,6 +1,6 @@ { "type": "minecraft:crafting_shaped", - "group": "sign", + "group": "wooden_sign", "pattern": [ "###", "###", diff --git a/src/generated/resources/data/minecraft/recipes/jungle_fence.json b/src/generated/resources/data/minecraft/recipes/jungle_fence.json index c324c192f9..634c0cb9b3 100644 --- a/src/generated/resources/data/minecraft/recipes/jungle_fence.json +++ b/src/generated/resources/data/minecraft/recipes/jungle_fence.json @@ -6,11 +6,11 @@ "W#W" ], "key": { - "#": { - "tag": "forge:rods/wooden" - }, "W": { "item": "minecraft:jungle_planks" + }, + "#": { + "tag": "forge:rods/wooden" } }, "result": { diff --git a/src/generated/resources/data/minecraft/recipes/jungle_sign.json b/src/generated/resources/data/minecraft/recipes/jungle_sign.json index c976a9fb2c..2d088aaaf3 100644 --- a/src/generated/resources/data/minecraft/recipes/jungle_sign.json +++ b/src/generated/resources/data/minecraft/recipes/jungle_sign.json @@ -1,6 +1,6 @@ { "type": "minecraft:crafting_shaped", - "group": "sign", + "group": "wooden_sign", "pattern": [ "###", "###", diff --git a/src/generated/resources/data/minecraft/recipes/mossy_cobblestone_from_moss_block.json b/src/generated/resources/data/minecraft/recipes/mossy_cobblestone_from_moss_block.json new file mode 100644 index 0000000000..220270b874 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipes/mossy_cobblestone_from_moss_block.json @@ -0,0 +1,15 @@ +{ + "type": "minecraft:crafting_shapeless", + "group": "mossy_cobblestone", + "ingredients": [ + { + "tag": "forge:cobblestone" + }, + { + "item": "minecraft:moss_block" + } + ], + "result": { + "item": "minecraft:mossy_cobblestone" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipes/mossy_cobblestone.json b/src/generated/resources/data/minecraft/recipes/mossy_cobblestone_from_vine.json similarity index 87% rename from src/generated/resources/data/minecraft/recipes/mossy_cobblestone.json rename to src/generated/resources/data/minecraft/recipes/mossy_cobblestone_from_vine.json index 5c98e05f2d..454a627c30 100644 --- a/src/generated/resources/data/minecraft/recipes/mossy_cobblestone.json +++ b/src/generated/resources/data/minecraft/recipes/mossy_cobblestone_from_vine.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shapeless", + "group": "mossy_cobblestone", "ingredients": [ { "tag": "forge:cobblestone" diff --git a/src/generated/resources/data/minecraft/recipes/oak_fence.json b/src/generated/resources/data/minecraft/recipes/oak_fence.json index f88346a011..37d4ce46bb 100644 --- a/src/generated/resources/data/minecraft/recipes/oak_fence.json +++ b/src/generated/resources/data/minecraft/recipes/oak_fence.json @@ -6,11 +6,11 @@ "W#W" ], "key": { - "#": { - "tag": "forge:rods/wooden" - }, "W": { "item": "minecraft:oak_planks" + }, + "#": { + "tag": "forge:rods/wooden" } }, "result": { diff --git a/src/generated/resources/data/minecraft/recipes/oak_sign.json b/src/generated/resources/data/minecraft/recipes/oak_sign.json index cef23376b3..d038be3498 100644 --- a/src/generated/resources/data/minecraft/recipes/oak_sign.json +++ b/src/generated/resources/data/minecraft/recipes/oak_sign.json @@ -1,6 +1,6 @@ { "type": "minecraft:crafting_shaped", - "group": "sign", + "group": "wooden_sign", "pattern": [ "###", "###", diff --git a/src/generated/resources/data/minecraft/recipes/spruce_fence.json b/src/generated/resources/data/minecraft/recipes/spruce_fence.json index 4b67416245..e2ddf8e511 100644 --- a/src/generated/resources/data/minecraft/recipes/spruce_fence.json +++ b/src/generated/resources/data/minecraft/recipes/spruce_fence.json @@ -6,11 +6,11 @@ "W#W" ], "key": { - "#": { - "tag": "forge:rods/wooden" - }, "W": { "item": "minecraft:spruce_planks" + }, + "#": { + "tag": "forge:rods/wooden" } }, "result": { diff --git a/src/generated/resources/data/minecraft/recipes/spruce_sign.json b/src/generated/resources/data/minecraft/recipes/spruce_sign.json index 5eb78b6edc..f8c817b31b 100644 --- a/src/generated/resources/data/minecraft/recipes/spruce_sign.json +++ b/src/generated/resources/data/minecraft/recipes/spruce_sign.json @@ -1,6 +1,6 @@ { "type": "minecraft:crafting_shaped", - "group": "sign", + "group": "wooden_sign", "pattern": [ "###", "###", diff --git a/src/generated/resources/data/minecraft/recipes/warped_fence.json b/src/generated/resources/data/minecraft/recipes/warped_fence.json index acbd03dc49..c1bae5ae98 100644 --- a/src/generated/resources/data/minecraft/recipes/warped_fence.json +++ b/src/generated/resources/data/minecraft/recipes/warped_fence.json @@ -6,11 +6,11 @@ "W#W" ], "key": { - "#": { - "tag": "forge:rods/wooden" - }, "W": { "item": "minecraft:warped_planks" + }, + "#": { + "tag": "forge:rods/wooden" } }, "result": { diff --git a/src/generated/resources/data/minecraft/recipes/warped_sign.json b/src/generated/resources/data/minecraft/recipes/warped_sign.json index 46f1d327bb..72b9467429 100644 --- a/src/generated/resources/data/minecraft/recipes/warped_sign.json +++ b/src/generated/resources/data/minecraft/recipes/warped_sign.json @@ -1,6 +1,6 @@ { "type": "minecraft:crafting_shaped", - "group": "sign", + "group": "wooden_sign", "pattern": [ "###", "###", diff --git a/src/generated_test/resources/.cache/cache b/src/generated_test/resources/.cache/cache index 987d9824b2..a1cd4eb2bc 100644 --- a/src/generated_test/resources/.cache/cache +++ b/src/generated_test/resources/.cache/cache @@ -66,7 +66,7 @@ bf2e445b48b024354a69138b20a4a4a8aa5d15d1 assets/minecraft/blockstates/oak_trapdo 9c4cc92efb78811e8d70a383a1a89eb75b69db04 assets/minecraft/blockstates/stone.json 570fdd86046df75a073b759ff7aaf4c4caf43115 assets/minecraft/blockstates/torch.json a012d6d92bab1c91913bd0f2dc0492a0fce916f2 assets/minecraft/blockstates/wall_torch.json -e615d11ed9a452bca5d8b242e733a43ba2df19a3 assets/new_model_loader_test/blockstates/obj_block.json +0a1909376adb28354443930b18fb832ed577f5a0 assets/new_model_loader_test/blockstates/obj_block.json bab7cd04569c8aa63320772acdc3c91a5ceda14a assets/new_model_loader_test/models/block/obj_block.json 9fa44308a52fbc384d5befee4e117531642299fb assets/new_model_loader_test/models/item/item_layers.json 70c8c81f3a157e4d698f213d5c1a13c13eaa5157 assets/new_model_loader_test/models/item/separate_perspective.json @@ -78,8 +78,8 @@ cf16f861eaf5815238c2278eb48bde0688cb73b7 assets/scaffolding_test/blockstates/sca 8c1969250406edfbd470cc06aca4dcccfd6ce682 data/custom_tag_types_test/tags/enchantments/fire.json 44985f1cb0df54b632187ed97a6a443455f1e51c data/custom_tag_types_test/tags/potions/damage.json 9405b72d54aad3f4377035d9707bb9947e9032a3 data/custom_tag_types_test/tags/tile_entity_types/storage.json -4fbaf6f4a3ea05cc071076e27f44ac81f9cc50e3 data/data_gen_test/advancements/conditional.json -66442c8000af9af4ba36109b3c9d09d9ffd57277 data/data_gen_test/advancements/recipes/conditional2.json +806659ba3e9c12797df0fe7211a222795834fdfd data/data_gen_test/advancements/conditional.json +76e760c8e8a1bbd3fb5538bc2d773c117016c0ce data/data_gen_test/advancements/recipes/conditional2.json ed4cbf1a3a2f5d8969f6346fdc9acdbe81d0c919 data/data_gen_test/recipes/conditional.json ca9827bff0a49957e01cf3887ef5131ad8710320 data/data_gen_test/recipes/conditional2.json 8831e79c8d15b1bc00eb29d354bb22b64d9ddcdd data/data_gen_test/tags/blocks/test.json @@ -90,4 +90,4 @@ b0565ce75fc7880be7517e86a218d1ed9d9e346f data/data_gen_test/tags/blocks/things.j f4d3a59005dafa334c835e43ed0047487e17324d data/forge/loot_modifiers/global_loot_modifiers.json 5bd8a05038d2633f89b3b1c5ac319eb4b347b335 data/global_loot_test/loot_modifiers/dungeon_loot.json f65e40b06ce7ad18e053ec88058b951f98ae5f40 data/global_loot_test/loot_modifiers/smelting.json -f991cfd612acf5ce98a43f4771ee04727219ae53 data/global_loot_test/loot_modifiers/wheat_harvest.json +a263b2535439eb5af22cbc9aa48252d8e983eb08 data/global_loot_test/loot_modifiers/wheat_harvest.json diff --git a/src/generated_test/resources/assets/new_model_loader_test/blockstates/obj_block.json b/src/generated_test/resources/assets/new_model_loader_test/blockstates/obj_block.json index 1fb14a4cf7..17580ea855 100644 --- a/src/generated_test/resources/assets/new_model_loader_test/blockstates/obj_block.json +++ b/src/generated_test/resources/assets/new_model_loader_test/blockstates/obj_block.json @@ -1,7 +1,19 @@ { "variants": { - "": { + "facing=north": { "model": "new_model_loader_test:block/obj_block" + }, + "facing=south": { + "model": "new_model_loader_test:block/obj_block", + "y": 180 + }, + "facing=west": { + "model": "new_model_loader_test:block/obj_block", + "y": 270 + }, + "facing=east": { + "model": "new_model_loader_test:block/obj_block", + "y": 90 } } } \ No newline at end of file diff --git a/src/generated_test/resources/data/data_gen_test/advancements/conditional.json b/src/generated_test/resources/data/data_gen_test/advancements/conditional.json index 2f1825f7ce..90bc1b1c78 100644 --- a/src/generated_test/resources/data/data_gen_test/advancements/conditional.json +++ b/src/generated_test/resources/data/data_gen_test/advancements/conditional.json @@ -50,7 +50,9 @@ "conditions": { "items": [ { - "item": "minecraft:dirt" + "items": [ + "minecraft:dirt" + ] } ] } diff --git a/src/generated_test/resources/data/data_gen_test/advancements/recipes/conditional2.json b/src/generated_test/resources/data/data_gen_test/advancements/recipes/conditional2.json index 302cf5ff90..39be991084 100644 --- a/src/generated_test/resources/data/data_gen_test/advancements/recipes/conditional2.json +++ b/src/generated_test/resources/data/data_gen_test/advancements/recipes/conditional2.json @@ -38,7 +38,9 @@ "conditions": { "items": [ { - "item": "minecraft:dirt" + "items": [ + "minecraft:dirt" + ] } ] } diff --git a/src/generated_test/resources/data/global_loot_test/loot_modifiers/wheat_harvest.json b/src/generated_test/resources/data/global_loot_test/loot_modifiers/wheat_harvest.json index fd7ea78945..0f76bb2f47 100644 --- a/src/generated_test/resources/data/global_loot_test/loot_modifiers/wheat_harvest.json +++ b/src/generated_test/resources/data/global_loot_test/loot_modifiers/wheat_harvest.json @@ -3,7 +3,9 @@ { "condition": "minecraft:match_tool", "predicate": { - "item": "minecraft:shears" + "items": [ + "minecraft:shears" + ] } }, { diff --git a/src/main/java/net/minecraftforge/client/CloudRenderHandler.java b/src/main/java/net/minecraftforge/client/CloudRenderHandler.java deleted file mode 100644 index 3e33eea250..0000000000 --- a/src/main/java/net/minecraftforge/client/CloudRenderHandler.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.client; - -import com.mojang.blaze3d.matrix.MatrixStack; -import net.minecraft.client.Minecraft; -import net.minecraft.client.world.ClientWorld; - -/** - * Use {@link ICloudRenderHandler} instead. - * - * todo: remove in 1.17 - */ -@Deprecated -public interface CloudRenderHandler extends IRenderHandler { - @Override - default void render(int ticks, float partialTicks, ClientWorld world, Minecraft mc) {} - - void render(int ticks, float partialTicks, MatrixStack matrixStack, ClientWorld world, Minecraft mc); -} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/client/EffectRenderer.java b/src/main/java/net/minecraftforge/client/EffectRenderer.java new file mode 100644 index 0000000000..1a5f437921 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/EffectRenderer.java @@ -0,0 +1,104 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.client; + +import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.client.gui.GuiComponent; +import net.minecraft.client.gui.screens.inventory.EffectRenderingInventoryScreen; +import net.minecraft.world.effect.MobEffectInstance; + + +public abstract class EffectRenderer +{ + public static final EffectRenderer DUMMY = new EffectRenderer() + { + @Override + public void renderInventoryEffect(MobEffectInstance effect, EffectRenderingInventoryScreen gui, PoseStack mStack, int x, int y, float z) + { + + } + + @Override + public void renderHUDEffect(MobEffectInstance effect, GuiComponent gui, PoseStack mStack, int x, int y, float z, float alpha) + { + + } + }; + + /** + * If the Potion effect should be displayed in the players inventory + * + * @param effect the active PotionEffect + * @return true to display it (default), false to hide it. + */ + public boolean shouldRender(MobEffectInstance effect) + { + return true; + } + + /** + * If the standard PotionEffect text (name and duration) should be drawn when this potion is active. + * + * @param effect the active PotionEffect + * @return true to draw the standard text + */ + public boolean shouldRenderInvText(MobEffectInstance effect) + { + return true; + } + + /** + * If the Potion effect should be displayed in the player's ingame HUD + * + * @param effect the active PotionEffect + * @return true to display it (default), false to hide it. + */ + public boolean shouldRenderHUD(MobEffectInstance effect) + { + return true; + } + + /** + * Called to draw the this Potion onto the player's inventory when it's active. + * This can be used to e.g. render Potion icons from your own texture. + * + * @param effect the active PotionEffect + * @param gui the gui instance + * @param mStack The PoseStack + * @param x the x coordinate + * @param y the y coordinate + * @param z the z level + */ + public abstract void renderInventoryEffect(MobEffectInstance effect, EffectRenderingInventoryScreen gui, PoseStack mStack, int x, int y, float z); + + /** + * Called to draw the this Potion onto the player's ingame HUD when it's active. + * This can be used to e.g. render Potion icons from your own texture. + * + * @param effect the active PotionEffect + * @param gui the gui instance + * @param mStack The PoseStack + * @param x the x coordinate + * @param y the y coordinate + * @param z the z level + * @param alpha the alpha value, blinks when the potion is about to run out + */ + public abstract void renderHUDEffect(MobEffectInstance effect, GuiComponent gui, PoseStack mStack, int x, int y, float z, float alpha); +} diff --git a/src/main/java/net/minecraftforge/client/FluidContainerColorer.java b/src/main/java/net/minecraftforge/client/FluidContainerColorer.java index 2a8d30a12c..8b4431bfc4 100644 --- a/src/main/java/net/minecraftforge/client/FluidContainerColorer.java +++ b/src/main/java/net/minecraftforge/client/FluidContainerColorer.java @@ -21,11 +21,11 @@ package net.minecraftforge.client; import javax.annotation.Nonnull; -import net.minecraft.client.renderer.color.IItemColor; -import net.minecraft.item.ItemStack; +import net.minecraft.client.color.item.ItemColor; +import net.minecraft.world.item.ItemStack; import net.minecraftforge.fluids.FluidUtil; -public class FluidContainerColorer implements IItemColor +public class FluidContainerColorer implements ItemColor { @Override public int getColor(@Nonnull ItemStack stack, int tintIndex) diff --git a/src/main/java/net/minecraftforge/client/ForgeHooksClient.java b/src/main/java/net/minecraftforge/client/ForgeHooksClient.java index 173dbebfc8..5666d619d9 100644 --- a/src/main/java/net/minecraftforge/client/ForgeHooksClient.java +++ b/src/main/java/net/minecraftforge/client/ForgeHooksClient.java @@ -20,68 +20,69 @@ package net.minecraftforge.client; import com.google.common.collect.ImmutableList; -import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.vertex.IVertexBuilder; -import net.minecraft.block.BlockState; -import net.minecraft.client.MainWindow; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.level.block.state.BlockState; +import com.mojang.blaze3d.platform.Window; import net.minecraft.client.Minecraft; -import net.minecraft.client.MouseHelper; -import net.minecraft.client.audio.ISound; -import net.minecraft.client.audio.SoundEngine; -import net.minecraft.client.gui.AbstractGui; -import net.minecraft.client.gui.ClientBossInfo; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.screen.BiomeGeneratorTypeScreens; -import net.minecraft.client.gui.screen.MainMenuScreen; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.network.play.NetworkPlayerInfo; +import net.minecraft.client.MouseHandler; +import net.minecraft.client.resources.sounds.SoundInstance; +import net.minecraft.client.sounds.SoundEngine; +import net.minecraft.client.gui.GuiComponent; +import net.minecraft.client.gui.components.LerpingBossEvent; +import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.screens.worldselection.WorldPreset; +import net.minecraft.client.gui.screens.TitleScreen; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.multiplayer.PlayerInfo; import net.minecraft.client.renderer.*; -import net.minecraft.client.renderer.FogRenderer.FogType; -import net.minecraft.client.renderer.color.BlockColors; -import net.minecraft.client.renderer.color.ItemColors; -import net.minecraft.client.renderer.entity.model.BipedModel; -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.model.ItemCameraTransforms; -import net.minecraft.client.renderer.model.ModelManager; -import net.minecraft.client.renderer.model.RenderMaterial; -import net.minecraft.client.renderer.texture.AtlasTexture; -import net.minecraft.client.renderer.texture.NativeImage; +import net.minecraft.client.renderer.FogRenderer.FogMode; +import net.minecraft.client.color.block.BlockColors; +import net.minecraft.client.color.item.ItemColors; +import net.minecraft.client.model.HumanoidModel; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.renderer.block.model.ItemTransforms; +import net.minecraft.client.resources.model.ModelManager; +import net.minecraft.client.resources.model.Material; +import net.minecraft.client.renderer.texture.TextureAtlas; +import com.mojang.blaze3d.platform.NativeImage; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.renderer.vertex.VertexFormat; -import net.minecraft.client.renderer.vertex.VertexFormatElement; -import net.minecraft.client.renderer.vertex.VertexFormatElement.Usage; -import net.minecraft.client.resources.I18n; -import net.minecraft.client.settings.KeyBinding; -import net.minecraft.entity.Entity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.ai.attributes.ModifiableAttributeInstance; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.fluid.Fluid; -import net.minecraft.fluid.FluidState; -import net.minecraft.inventory.EquipmentSlotType; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.RecipeManager; -import net.minecraft.resources.IResource; -import net.minecraft.resources.IResourceManager; -import net.minecraft.util.Direction; -import net.minecraft.util.Hand; -import net.minecraft.util.MovementInput; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.EntityRayTraceResult; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.math.vector.Matrix3f; -import net.minecraft.util.math.vector.Matrix4f; -import net.minecraft.util.math.vector.TransformationMatrix; -import net.minecraft.util.math.vector.Vector3f; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.util.text.TranslationTextComponent; -import net.minecraft.world.GameType; -import net.minecraft.world.IBlockDisplayReader; -import net.minecraft.world.World; -import net.minecraft.world.gen.settings.DimensionGeneratorSettings; +import com.mojang.blaze3d.vertex.VertexFormat; +import com.mojang.blaze3d.vertex.VertexFormatElement; +import com.mojang.blaze3d.vertex.VertexFormatElement.Usage; +import net.minecraft.client.resources.language.I18n; +import net.minecraft.client.KeyMapping; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.ai.attributes.AttributeInstance; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.RecipeManager; +import net.minecraft.server.packs.resources.Resource; +import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.core.Direction; +import net.minecraft.world.InteractionHand; +import net.minecraft.client.player.Input; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.EntityHitResult; +import net.minecraft.world.phys.HitResult; +import com.mojang.math.Matrix3f; +import com.mojang.math.Matrix4f; +import com.mojang.math.Transformation; +import com.mojang.math.Vector3f; +import net.minecraft.network.chat.Component; +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.world.level.GameType; +import net.minecraft.world.level.BlockAndTintGetter; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.levelgen.WorldGenSettings; import net.minecraftforge.client.event.*; import net.minecraftforge.client.event.sound.PlaySoundEvent; import net.minecraftforge.client.model.ModelLoader; @@ -93,11 +94,10 @@ import net.minecraftforge.common.model.TransformationHelper; import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.fml.ModLoader; import net.minecraftforge.fml.VersionChecker; -import net.minecraftforge.fml.client.registry.ClientRegistry; -import net.minecraftforge.fml.loading.progress.StartupMessageManager; +import net.minecraftforge.fmlclient.registry.ClientRegistry; +import net.minecraftforge.fml.StartupMessageManager; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.resource.ReloadRequirements; -import net.minecraftforge.resource.SelectiveReloadStateHandler; import net.minecraftforge.resource.VanillaResourceType; import net.minecraftforge.versions.forge.ForgeVersion; import org.apache.logging.log4j.LogManager; @@ -125,54 +125,58 @@ import static net.minecraftforge.fml.VersionChecker.Status.BETA_OUTDATED; import static org.lwjgl.opengl.GL11.*; import static org.lwjgl.opengl.GL20.*; +import net.minecraft.client.Camera; +import net.minecraft.client.renderer.block.BlockRenderDispatcher; +import net.minecraft.client.renderer.entity.ItemRenderer; + public class ForgeHooksClient { private static final Logger LOGGER = LogManager.getLogger(); //private static final ResourceLocation ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png"); - public static String getArmorTexture(Entity entity, ItemStack armor, String _default, EquipmentSlotType slot, String type) + public static String getArmorTexture(Entity entity, ItemStack armor, String _default, EquipmentSlot slot, String type) { String result = armor.getItem().getArmorTexture(armor, entity, slot, type); return result != null ? result : _default; } //TODO: Rename to onDrawHighlight - public static boolean onDrawBlockHighlight(WorldRenderer context, ActiveRenderInfo info, RayTraceResult target, float partialTicks, MatrixStack matrix, IRenderTypeBuffer buffers) + public static boolean onDrawBlockHighlight(LevelRenderer context, Camera info, HitResult target, float partialTicks, PoseStack matrix, MultiBufferSource buffers) { switch (target.getType()) { case BLOCK: - if (!(target instanceof BlockRayTraceResult)) return false; - return MinecraftForge.EVENT_BUS.post(new DrawHighlightEvent.HighlightBlock(context, info, target, partialTicks, matrix, buffers)); + if (!(target instanceof BlockHitResult)) return false; + return MinecraftForge.EVENT_BUS.post(new DrawSelectionEvent.HighlightBlock(context, info, target, partialTicks, matrix, buffers)); case ENTITY: - if (!(target instanceof EntityRayTraceResult)) return false; - return MinecraftForge.EVENT_BUS.post(new DrawHighlightEvent.HighlightEntity(context, info, target, partialTicks, matrix, buffers)); + if (!(target instanceof EntityHitResult)) return false; + return MinecraftForge.EVENT_BUS.post(new DrawSelectionEvent.HighlightEntity(context, info, target, partialTicks, matrix, buffers)); default: - return MinecraftForge.EVENT_BUS.post(new DrawHighlightEvent(context, info, target, partialTicks, matrix, buffers)); + return MinecraftForge.EVENT_BUS.post(new DrawSelectionEvent(context, info, target, partialTicks, matrix, buffers)); } } - public static void dispatchRenderLast(WorldRenderer context, MatrixStack mat, float partialTicks, Matrix4f projectionMatrix, long finishTimeNano) + public static void dispatchRenderLast(LevelRenderer context, PoseStack mat, float partialTicks, Matrix4f projectionMatrix, long finishTimeNano) { MinecraftForge.EVENT_BUS.post(new RenderWorldLastEvent(context, mat, partialTicks, projectionMatrix, finishTimeNano)); } - public static boolean renderSpecificFirstPersonHand(Hand hand, MatrixStack mat, IRenderTypeBuffer buffers, int light, float partialTicks, float interpPitch, float swingProgress, float equipProgress, ItemStack stack) + public static boolean renderSpecificFirstPersonHand(InteractionHand hand, PoseStack mat, MultiBufferSource buffers, int light, float partialTicks, float interpPitch, float swingProgress, float equipProgress, ItemStack stack) { return MinecraftForge.EVENT_BUS.post(new RenderHandEvent(hand, mat, buffers, light, partialTicks, interpPitch, swingProgress, equipProgress, stack)); } - public static void onTextureStitchedPre(AtlasTexture map, Set resourceLocations) + public static void onTextureStitchedPre(TextureAtlas map, Set resourceLocations) { StartupMessageManager.mcLoaderConsumer().ifPresent(c->c.accept("Atlas Stitching : "+map.location().toString())); ModLoader.get().postEvent(new TextureStitchEvent.Pre(map, resourceLocations)); // ModelLoader.White.INSTANCE.register(map); // TODO Custom TAS - Atlases.SIGN_MATERIALS.values().stream() + Sheets.SIGN_MATERIALS.values().stream() .filter(rm -> rm.atlasLocation().equals(map.location())) .forEach(rm -> resourceLocations.add(rm.texture())); } - public static void onTextureStitchedPost(AtlasTexture map) + public static void onTextureStitchedPost(TextureAtlas map) { ModLoader.get().postEvent(new TextureStitchEvent.Post(map)); } @@ -194,9 +198,9 @@ public class ForgeHooksClient renderLayer.set(layer); } - public static > A getArmorModel(LivingEntity entityLiving, ItemStack itemStack, EquipmentSlotType slot, A _default) + public static > A getArmorModel(LivingEntity entityLiving, ItemStack itemStack, EquipmentSlot slot, A _default) { - A model = itemStack.getItem().getArmorModel(entityLiving, itemStack, slot, _default); + A model = RenderProperties.get(itemStack).getArmorModel(entityLiving, itemStack, slot, _default); return model == null ? _default : model; } @@ -226,14 +230,14 @@ public class ForgeHooksClient return MinecraftForge.EVENT_BUS.post(new MouseEvent()); } */ - public static float getOffsetFOV(PlayerEntity entity, float fov) + public static float getOffsetFOV(Player entity, float fov) { FOVUpdateEvent fovUpdateEvent = new FOVUpdateEvent(entity, fov); MinecraftForge.EVENT_BUS.post(fovUpdateEvent); return fovUpdateEvent.getNewfov(); } - public static double getFOVModifier(GameRenderer renderer, ActiveRenderInfo info, double renderPartialTicks, double fov) { + public static double getFOVModifier(GameRenderer renderer, Camera info, double renderPartialTicks, double fov) { EntityViewRenderEvent.FOVModifier event = new EntityViewRenderEvent.FOVModifier(renderer, info, renderPartialTicks, fov); MinecraftForge.EVENT_BUS.post(event); return event.getFOV(); @@ -248,22 +252,16 @@ public class ForgeHooksClient //RenderingRegistry.registerBlockHandler(RenderBlockFluid.instance); } - @Deprecated // TODO: Remove in 1.17 - public static void renderMainMenu(MainMenuScreen gui, MatrixStack mStack, FontRenderer font, int width, int height) - { - renderMainMenu(gui, mStack, font, width, height, -1); - } - - public static void renderMainMenu(MainMenuScreen gui, MatrixStack mStack, FontRenderer font, int width, int height, int alpha) + public static void renderMainMenu(TitleScreen gui, PoseStack mStack, Font font, int width, int height, int alpha) { VersionChecker.Status status = ForgeVersion.getStatus(); if (status == BETA || status == BETA_OUTDATED) { // render a warning at the top of the screen, - ITextComponent line = new TranslationTextComponent("forge.update.beta.1", TextFormatting.RED, TextFormatting.RESET).withStyle(TextFormatting.RED); - AbstractGui.drawCenteredString(mStack, font, line, width / 2, 4 + (0 * (font.lineHeight + 1)), 0xFFFFFF | alpha); - line = new TranslationTextComponent("forge.update.beta.2"); - AbstractGui.drawCenteredString(mStack, font, line, width / 2, 4 + (1 * (font.lineHeight + 1)), 0xFFFFFF | alpha); + Component line = new TranslatableComponent("forge.update.beta.1", ChatFormatting.RED, ChatFormatting.RESET).withStyle(ChatFormatting.RED); + GuiComponent.drawCenteredString(mStack, font, line, width / 2, 4 + (0 * (font.lineHeight + 1)), 0xFFFFFF | alpha); + line = new TranslatableComponent("forge.update.beta.2"); + GuiComponent.drawCenteredString(mStack, font, line, width / 2, 4 + (1 * (font.lineHeight + 1)), 0xFFFFFF | alpha); } String line = null; @@ -281,7 +279,7 @@ public class ForgeHooksClient } public static String forgeStatusLine; - public static ISound playSound(SoundEngine manager, ISound sound) + public static SoundInstance playSound(SoundEngine manager, SoundInstance sound) { PlaySoundEvent e = new PlaySoundEvent(manager, sound); MinecraftForge.EVENT_BUS.post(e); @@ -296,33 +294,33 @@ public class ForgeHooksClient return worldRenderPass; } - public static void drawScreen(Screen screen, MatrixStack mStack, int mouseX, int mouseY, float partialTicks) + public static void drawScreen(Screen screen, PoseStack mStack, int mouseX, int mouseY, float partialTicks) { if (!MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.DrawScreenEvent.Pre(screen, mStack, mouseX, mouseY, partialTicks))) screen.render(mStack, mouseX, mouseY, partialTicks); MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.DrawScreenEvent.Post(screen, mStack, mouseX, mouseY, partialTicks)); } - public static float getFogDensity(FogType type, ActiveRenderInfo info, float partial, float density) + public static float getFogDensity(FogMode type, Camera info, float partial, float density) { EntityViewRenderEvent.FogDensity event = new EntityViewRenderEvent.FogDensity(type, info, partial, density); if (MinecraftForge.EVENT_BUS.post(event)) return event.getDensity(); return -1; } - public static void onFogRender(FogType type, ActiveRenderInfo info, float partial, float distance) + public static void onFogRender(FogMode type, Camera info, float partial, float distance) { MinecraftForge.EVENT_BUS.post(new EntityViewRenderEvent.RenderFogEvent(type, info, partial, distance)); } - public static EntityViewRenderEvent.CameraSetup onCameraSetup(GameRenderer renderer, ActiveRenderInfo info, float partial) + public static EntityViewRenderEvent.CameraSetup onCameraSetup(GameRenderer renderer, Camera info, float partial) { EntityViewRenderEvent.CameraSetup event = new EntityViewRenderEvent.CameraSetup(renderer, info, partial, info.getYRot(), info.getXRot(), 0); MinecraftForge.EVENT_BUS.post(event); return event; } - public static void onModelBake(ModelManager modelManager, Map modelRegistry, ModelLoader modelLoader) + public static void onModelBake(ModelManager modelManager, Map modelRegistry, ModelLoader modelLoader) { ModLoader.get().postEvent(new ModelBakeEvent(modelManager, modelRegistry, modelLoader)); modelLoader.onPostBakeEvent(modelRegistry); @@ -335,9 +333,9 @@ public class ForgeHooksClient flipXNormal = new Matrix3f(flipX); } - public static IBakedModel handleCameraTransforms(MatrixStack matrixStack, IBakedModel model, ItemCameraTransforms.TransformType cameraTransformType, boolean leftHandHackery) + public static BakedModel handleCameraTransforms(PoseStack matrixStack, BakedModel model, ItemTransforms.TransformType cameraTransformType, boolean leftHandHackery) { - MatrixStack stack = new MatrixStack(); + PoseStack stack = new PoseStack(); model = model.handlePerspective(cameraTransformType, stack); // If the stack is not empty, the code has added a matrix for us to use. @@ -466,24 +464,24 @@ public class ForgeHooksClient }*/ @SuppressWarnings("deprecation") - public static TextureAtlasSprite[] getFluidSprites(IBlockDisplayReader world, BlockPos pos, FluidState fluidStateIn) + public static TextureAtlasSprite[] getFluidSprites(BlockAndTintGetter world, BlockPos pos, FluidState fluidStateIn) { ResourceLocation overlayTexture = fluidStateIn.getType().getAttributes().getOverlayTexture(); return new TextureAtlasSprite[] { - Minecraft.getInstance().getTextureAtlas(AtlasTexture.LOCATION_BLOCKS).apply(fluidStateIn.getType().getAttributes().getStillTexture(world, pos)), - Minecraft.getInstance().getTextureAtlas(AtlasTexture.LOCATION_BLOCKS).apply(fluidStateIn.getType().getAttributes().getFlowingTexture(world, pos)), - overlayTexture == null ? null : Minecraft.getInstance().getTextureAtlas(AtlasTexture.LOCATION_BLOCKS).apply(overlayTexture), + Minecraft.getInstance().getTextureAtlas(TextureAtlas.LOCATION_BLOCKS).apply(fluidStateIn.getType().getAttributes().getStillTexture(world, pos)), + Minecraft.getInstance().getTextureAtlas(TextureAtlas.LOCATION_BLOCKS).apply(fluidStateIn.getType().getAttributes().getFlowingTexture(world, pos)), + overlayTexture == null ? null : Minecraft.getInstance().getTextureAtlas(TextureAtlas.LOCATION_BLOCKS).apply(overlayTexture), }; } - public static void gatherFluidTextures(Set textures) + public static void gatherFluidTextures(Set textures) { ForgeRegistries.FLUIDS.getValues().stream() .flatMap(ForgeHooksClient::getFluidMaterials) .forEach(textures::add); } - public static Stream getFluidMaterials(Fluid fluid) + public static Stream getFluidMaterials(Fluid fluid) { return fluid.getAttributes().getTextures() .filter(Objects::nonNull) @@ -491,9 +489,9 @@ public class ForgeHooksClient } @SuppressWarnings("deprecation") - public static RenderMaterial getBlockMaterial(ResourceLocation loc) + public static Material getBlockMaterial(ResourceLocation loc) { - return new RenderMaterial(AtlasTexture.LOCATION_BLOCKS, loc); + return new Material(TextureAtlas.LOCATION_BLOCKS, loc); } /** @@ -565,7 +563,7 @@ public class ForgeHooksClient return from.getItem().shouldCauseReequipAnimation(from, to, changed); } - public static RenderGameOverlayEvent.BossInfo bossBarRenderPre(MatrixStack mStack, MainWindow res, ClientBossInfo bossInfo, int x, int y, int increment) + public static RenderGameOverlayEvent.BossInfo bossBarRenderPre(PoseStack mStack, Window res, LerpingBossEvent bossInfo, int x, int y, int increment) { RenderGameOverlayEvent.BossInfo evt = new RenderGameOverlayEvent.BossInfo(mStack, new RenderGameOverlayEvent(mStack, Animation.getPartialTickTime(), res), BOSSINFO, bossInfo, x, y, increment); @@ -573,7 +571,7 @@ public class ForgeHooksClient return evt; } - public static void bossBarRenderPost(MatrixStack mStack, MainWindow res) + public static void bossBarRenderPost(PoseStack mStack, Window res) { MinecraftForge.EVENT_BUS.post(new RenderGameOverlayEvent.Post(mStack, new RenderGameOverlayEvent(mStack, Animation.getPartialTickTime(), res), BOSSINFO)); } @@ -585,7 +583,7 @@ public class ForgeHooksClient return event; } - public static void onClientChangeGameMode(NetworkPlayerInfo info, GameType currentGameMode, GameType newGameMode) + public static void onClientChangeGameMode(PlayerInfo info, GameType currentGameMode, GameType newGameMode) { if (currentGameMode != newGameMode) { @@ -595,24 +593,22 @@ public class ForgeHooksClient } @SuppressWarnings("deprecation") - public static IBakedModel handlePerspective(IBakedModel model, ItemCameraTransforms.TransformType type, MatrixStack stack) + public static BakedModel handlePerspective(BakedModel model, ItemTransforms.TransformType type, PoseStack stack) { - TransformationMatrix tr = TransformationHelper.toTransformation(model.getTransforms().getTransform(type)); + Transformation tr = TransformationHelper.toTransformation(model.getTransforms().getTransform(type)); if(!tr.isIdentity()) { tr.push(stack); } return model; } - public static void onInputUpdate(PlayerEntity player, MovementInput movementInput) + public static void onInputUpdate(Player player, Input movementInput) { MinecraftForge.EVENT_BUS.post(new InputUpdateEvent(player, movementInput)); } public static void refreshResources(Minecraft mc, VanillaResourceType... types) { - SelectiveReloadStateHandler.INSTANCE.beginReload(ReloadRequirements.include(types)); mc.reloadResourcePacks(); - SelectiveReloadStateHandler.INSTANCE.endReload(); } public static boolean onGuiMouseClickedPre(Screen guiScreen, double mouseX, double mouseY, int button) @@ -651,18 +647,18 @@ public class ForgeHooksClient return MinecraftForge.EVENT_BUS.post(event); } - public static boolean onGuiMouseScrollPre(MouseHelper mouseHelper, Screen guiScreen, double scrollDelta) + public static boolean onGuiMouseScrollPre(MouseHandler mouseHelper, Screen guiScreen, double scrollDelta) { - MainWindow mainWindow = guiScreen.getMinecraft().getWindow(); + 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 GuiScreenEvent.MouseScrollEvent.Pre(guiScreen, mouseX, mouseY, scrollDelta); return MinecraftForge.EVENT_BUS.post(event); } - public static boolean onGuiMouseScrollPost(MouseHelper mouseHelper, Screen guiScreen, double scrollDelta) + public static boolean onGuiMouseScrollPost(MouseHandler mouseHelper, Screen guiScreen, double scrollDelta) { - MainWindow mainWindow = guiScreen.getMinecraft().getWindow(); + 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 GuiScreenEvent.MouseScrollEvent.Post(guiScreen, mouseX, mouseY, scrollDelta); @@ -741,9 +737,9 @@ public class ForgeHooksClient MinecraftForge.EVENT_BUS.post(new InputEvent.KeyInputEvent(key, scanCode, action, modifiers)); } - public static boolean onMouseScroll(MouseHelper mouseHelper, double scrollDelta) + public static boolean onMouseScroll(MouseHandler mouseHelper, double scrollDelta) { - Event event = new InputEvent.MouseScrollEvent(scrollDelta, mouseHelper.isLeftPressed(), mouseHelper.isMiddleDown(), mouseHelper.isRightPressed(), mouseHelper.xpos(), mouseHelper.ypos()); + Event event = new InputEvent.MouseScrollEvent(scrollDelta, mouseHelper.isLeftPressed(), mouseHelper.isMiddlePressed(), mouseHelper.isRightPressed(), mouseHelper.xpos(), mouseHelper.ypos()); return MinecraftForge.EVENT_BUS.post(event); } @@ -752,22 +748,22 @@ public class ForgeHooksClient return MinecraftForge.EVENT_BUS.post(new InputEvent.RawMouseEvent(button, action, mods)); } - public static InputEvent.ClickInputEvent onClickInput(int button, KeyBinding keyBinding, Hand hand) + public static InputEvent.ClickInputEvent onClickInput(int button, KeyMapping keyBinding, InteractionHand hand) { InputEvent.ClickInputEvent event = new InputEvent.ClickInputEvent(button, keyBinding, hand); MinecraftForge.EVENT_BUS.post(event); return event; } - public static void drawItemLayered(ItemRenderer renderer, IBakedModel modelIn, ItemStack itemStackIn, MatrixStack matrixStackIn, - IRenderTypeBuffer bufferIn, int combinedLightIn, int combinedOverlayIn, boolean fabulous) + public static void drawItemLayered(ItemRenderer renderer, BakedModel modelIn, ItemStack itemStackIn, PoseStack matrixStackIn, + MultiBufferSource bufferIn, int combinedLightIn, int combinedOverlayIn, boolean fabulous) { - for(com.mojang.datafixers.util.Pair layerModel : modelIn.getLayerModels(itemStackIn, fabulous)) + for(com.mojang.datafixers.util.Pair layerModel : modelIn.getLayerModels(itemStackIn, fabulous)) { - IBakedModel layer = layerModel.getFirst(); + BakedModel layer = layerModel.getFirst(); RenderType rendertype = layerModel.getSecond(); net.minecraftforge.client.ForgeHooksClient.setRenderLayer(rendertype); // neded for compatibility with MultiLayerModels - IVertexBuilder ivertexbuilder; + VertexConsumer ivertexbuilder; if (fabulous) { ivertexbuilder = ItemRenderer.getFoilBufferDirect(bufferIn, rendertype, true, itemStackIn.hasFoil()); @@ -781,7 +777,7 @@ public class ForgeHooksClient public static boolean isNameplateInRenderDistance(Entity entity, double squareDistance) { if (entity instanceof LivingEntity) { - final ModifiableAttributeInstance attribute = ((LivingEntity) entity).getAttribute(ForgeMod.NAMETAG_DISTANCE.get()); + final AttributeInstance attribute = ((LivingEntity) entity).getAttribute(ForgeMod.NAMETAG_DISTANCE.get()); if (attribute != null) { return !(squareDistance > (attribute.getValue() * attribute.getValue())); } @@ -789,13 +785,13 @@ public class ForgeHooksClient return !(squareDistance > 4096.0f); } - public static void renderPistonMovedBlocks(BlockPos pos, BlockState state, MatrixStack stack, IRenderTypeBuffer buffer, World world, boolean checkSides, int combinedOverlay, BlockRendererDispatcher blockRenderer) { + public static void renderPistonMovedBlocks(BlockPos pos, BlockState state, PoseStack stack, MultiBufferSource buffer, Level world, boolean checkSides, int combinedOverlay, BlockRenderDispatcher blockRenderer) { RenderType.chunkBufferLayers().stream() - .filter(t -> RenderTypeLookup.canRenderInLayer(state, t)) + .filter(t -> ItemBlockRenderTypes.canRenderInLayer(state, t)) .forEach(rendertype -> { setRenderLayer(rendertype); - IVertexBuilder ivertexbuilder = buffer.getBuffer(rendertype == RenderType.translucent() ? RenderType.translucentMovingBlock() : rendertype); + VertexConsumer ivertexbuilder = buffer.getBuffer(rendertype == RenderType.translucent() ? RenderType.translucentMovingBlock() : rendertype); blockRenderer.getModelRenderer().tesselateBlock(world, blockRenderer.getBlockModel(state), state, pos, stack, ivertexbuilder, checkSides, new Random(), state.getSeed(pos), combinedOverlay); }); setRenderLayer(null); @@ -806,37 +802,42 @@ public class ForgeHooksClient ForgeWorldTypeScreens.registerTypes(); } - public static BiomeGeneratorTypeScreens.IFactory getBiomeGeneratorTypeScreenFactory(Optional generator, @Nullable BiomeGeneratorTypeScreens.IFactory biomegeneratortypescreens$ifactory) + public static WorldPreset.PresetEditor getBiomeGeneratorTypeScreenFactory(Optional generator, @Nullable WorldPreset.PresetEditor biomegeneratortypescreens$ifactory) { return ForgeWorldTypeScreens.getGeneratorScreenFactory(generator, biomegeneratortypescreens$ifactory); } - public static boolean hasBiomeGeneratorSettingsOptionsScreen(Optional generator) + public static boolean hasBiomeGeneratorSettingsOptionsScreen(Optional generator) { return getBiomeGeneratorTypeScreenFactory(generator, null) != null; } - public static Optional getWorldTypeFromGenerator(DimensionGeneratorSettings dimensionGeneratorSettings) + public static Optional getWorldTypeFromGenerator(WorldGenSettings dimensionGeneratorSettings) { - return BiomeGeneratorTypeScreens.of(dimensionGeneratorSettings); + return WorldPreset.of(dimensionGeneratorSettings); } - public static Optional getDefaultWorldType() + public static Optional getDefaultWorldType() { return Optional.of(ForgeWorldTypeScreens.getDefaultGenerator()); } + public static boolean shouldRender(MobEffectInstance effectInstance) + { + return RenderProperties.getEffectRenderer(effectInstance).shouldRender(effectInstance); + } + @Nullable public static TextureAtlasSprite loadTextureAtlasSprite( - AtlasTexture atlasTexture, - IResourceManager resourceManager, TextureAtlasSprite.Info textureInfo, - IResource resource, + TextureAtlas textureAtlas, + ResourceManager resourceManager, TextureAtlasSprite.Info textureInfo, + Resource resource, int atlasWidth, int atlasHeight, int spriteX, int spriteY, int mipmapLevel, NativeImage image ) { ForgeTextureMetadata metadata = ForgeTextureMetadata.forResource(resource); - return metadata.getLoader() == null ? null : metadata.getLoader().load(atlasTexture, resourceManager, textureInfo, resource, atlasWidth, atlasHeight, spriteX, spriteY, mipmapLevel, image); + return metadata.getLoader() == null ? null : metadata.getLoader().load(textureAtlas, resourceManager, textureInfo, resource, atlasWidth, atlasHeight, spriteX, spriteY, mipmapLevel, image); } } diff --git a/src/main/java/net/minecraftforge/client/ForgeRenderTypes.java b/src/main/java/net/minecraftforge/client/ForgeRenderTypes.java index c13b7f3577..ee8f0206de 100644 --- a/src/main/java/net/minecraftforge/client/ForgeRenderTypes.java +++ b/src/main/java/net/minecraftforge/client/ForgeRenderTypes.java @@ -21,15 +21,14 @@ package net.minecraftforge.client; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.RenderState; -import net.minecraft.client.renderer.RenderState.TextureState; +import net.minecraft.client.renderer.RenderStateShard; +import net.minecraft.client.renderer.RenderStateShard.TextureStateShard; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.RenderType.State; -import net.minecraft.client.renderer.texture.AtlasTexture; +import net.minecraft.client.renderer.texture.TextureAtlas; +import com.mojang.blaze3d.vertex.DefaultVertexFormat; +import com.mojang.blaze3d.vertex.VertexFormat; import net.minecraft.client.renderer.texture.TextureManager; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.client.renderer.vertex.VertexFormat; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.common.util.NonNullLazy; import net.minecraftforge.common.util.NonNullSupplier; import org.lwjgl.opengl.GL11; @@ -38,13 +37,13 @@ import java.util.function.Supplier; @SuppressWarnings("deprecation") public enum ForgeRenderTypes { - ITEM_LAYERED_SOLID(()-> getItemLayeredSolid(AtlasTexture.LOCATION_BLOCKS)), - ITEM_LAYERED_CUTOUT(()-> getItemLayeredCutout(AtlasTexture.LOCATION_BLOCKS)), - ITEM_LAYERED_CUTOUT_MIPPED(()-> getItemLayeredCutoutMipped(AtlasTexture.LOCATION_BLOCKS)), - ITEM_LAYERED_TRANSLUCENT(()-> getItemLayeredTranslucent(AtlasTexture.LOCATION_BLOCKS)), - ITEM_UNSORTED_TRANSLUCENT(()-> getUnsortedTranslucent(AtlasTexture.LOCATION_BLOCKS)), - ITEM_UNLIT_TRANSLUCENT(()-> getUnlitTranslucent(AtlasTexture.LOCATION_BLOCKS)), - ITEM_UNSORTED_UNLIT_TRANSLUCENT(()-> getUnlitTranslucent(AtlasTexture.LOCATION_BLOCKS, false)); + ITEM_LAYERED_SOLID(()-> getItemLayeredSolid(TextureAtlas.LOCATION_BLOCKS)), + ITEM_LAYERED_CUTOUT(()-> getItemLayeredCutout(TextureAtlas.LOCATION_BLOCKS)), + ITEM_LAYERED_CUTOUT_MIPPED(()-> getItemLayeredCutoutMipped(TextureAtlas.LOCATION_BLOCKS)), + ITEM_LAYERED_TRANSLUCENT(()-> getItemLayeredTranslucent(TextureAtlas.LOCATION_BLOCKS)), + ITEM_UNSORTED_TRANSLUCENT(()-> getUnsortedTranslucent(TextureAtlas.LOCATION_BLOCKS)), + ITEM_UNLIT_TRANSLUCENT(()-> getUnlitTranslucent(TextureAtlas.LOCATION_BLOCKS)), + ITEM_UNSORTED_UNLIT_TRANSLUCENT(()-> getUnlitTranslucent(TextureAtlas.LOCATION_BLOCKS, false)); public static boolean enableTextTextureLinearFiltering = false; @@ -150,7 +149,7 @@ public enum ForgeRenderTypes private static class Internal extends RenderType { - private Internal(String name, VertexFormat fmt, int glMode, int size, boolean doCrumbling, boolean depthSorting, Runnable onEnable, Runnable onDisable) + private Internal(String name, VertexFormat fmt, VertexFormat.Mode glMode, int size, boolean doCrumbling, boolean depthSorting, Runnable onEnable, Runnable onDisable) { super(name, fmt, glMode, size, doCrumbling, depthSorting, onEnable, onDisable); throw new IllegalStateException("This class must not be instantiated"); @@ -159,102 +158,102 @@ public enum ForgeRenderTypes public static RenderType unsortedTranslucent(ResourceLocation textureLocation) { final boolean sortingEnabled = false; - State renderState = State.builder() - .setTextureState(new TextureState(textureLocation, false, false)) + CompositeState renderState = CompositeState.builder() + .setTextureState(new TextureStateShard(textureLocation, false, false)) .setTransparencyState(TRANSLUCENT_TRANSPARENCY) - .setDiffuseLightingState(DIFFUSE_LIGHTING) - .setAlphaState(DEFAULT_ALPHA) +// .setDiffuseLightingState(DIFFUSE_LIGHTING) //TODO +// .setAlphaState(DEFAULT_ALPHA) //TODO .setCullState(NO_CULL) .setLightmapState(LIGHTMAP) .setOverlayState(OVERLAY) .createCompositeState(true); - return create("forge_entity_unsorted_translucent", DefaultVertexFormats.NEW_ENTITY, GL11.GL_QUADS, 256, true, sortingEnabled, renderState); + return create("forge_entity_unsorted_translucent", DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, sortingEnabled, renderState); } public static RenderType unlitTranslucent(ResourceLocation textureLocation, boolean sortingEnabled) { - State renderState = State.builder() - .setTextureState(new TextureState(textureLocation, false, false)) + CompositeState renderState = CompositeState.builder() + .setTextureState(new TextureStateShard(textureLocation, false, false)) .setTransparencyState(TRANSLUCENT_TRANSPARENCY) - .setAlphaState(DEFAULT_ALPHA) +// .setAlphaState(DEFAULT_ALPHA) //TODO .setCullState(NO_CULL) .setLightmapState(LIGHTMAP) .setOverlayState(OVERLAY) .createCompositeState(true); - return create("forge_entity_unlit_translucent", DefaultVertexFormats.NEW_ENTITY, GL11.GL_QUADS, 256, true, sortingEnabled, renderState); + return create("forge_entity_unlit_translucent", DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, sortingEnabled, renderState); } public static RenderType layeredItemSolid(ResourceLocation locationIn) { - RenderType.State rendertype$state = RenderType.State.builder() - .setTextureState(new RenderState.TextureState(locationIn, false, false)) + RenderType.CompositeState rendertype$state = RenderType.CompositeState.builder() + .setTextureState(new RenderStateShard.TextureStateShard(locationIn, false, false)) .setTransparencyState(NO_TRANSPARENCY) - .setDiffuseLightingState(DIFFUSE_LIGHTING) +// .setDiffuseLightingState(DIFFUSE_LIGHTING) //TODO .setLightmapState(LIGHTMAP) .setOverlayState(OVERLAY) .createCompositeState(true); - return create("forge_item_entity_solid", DefaultVertexFormats.NEW_ENTITY, 7, 256, true, false, rendertype$state); + return create("forge_item_entity_solid", DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, false, rendertype$state); } public static RenderType layeredItemCutout(ResourceLocation locationIn) { - RenderType.State rendertype$state = RenderType.State.builder() - .setTextureState(new RenderState.TextureState(locationIn, false, false)) + RenderType.CompositeState rendertype$state = RenderType.CompositeState.builder() + .setTextureState(new RenderStateShard.TextureStateShard(locationIn, false, false)) .setTransparencyState(NO_TRANSPARENCY) - .setDiffuseLightingState(DIFFUSE_LIGHTING) - .setAlphaState(DEFAULT_ALPHA) +// .setDiffuseLightingState(DIFFUSE_LIGHTING) //TODO +// .setAlphaState(DEFAULT_ALPHA) //TODO .setLightmapState(LIGHTMAP) .setOverlayState(OVERLAY) .createCompositeState(true); - return create("forge_item_entity_cutout", DefaultVertexFormats.NEW_ENTITY, 7, 256, true, false, rendertype$state); + return create("forge_item_entity_cutout", DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, false, rendertype$state); } public static RenderType layeredItemCutoutMipped(ResourceLocation locationIn) { - RenderType.State rendertype$state = RenderType.State.builder() - .setTextureState(new RenderState.TextureState(locationIn, false, true)) + RenderType.CompositeState rendertype$state = RenderType.CompositeState.builder() + .setTextureState(new RenderStateShard.TextureStateShard(locationIn, false, true)) .setTransparencyState(NO_TRANSPARENCY) - .setDiffuseLightingState(DIFFUSE_LIGHTING) - .setAlphaState(DEFAULT_ALPHA) +// .setDiffuseLightingState(DIFFUSE_LIGHTING) //TODO +// .setAlphaState(DEFAULT_ALPHA) //TODO .setLightmapState(LIGHTMAP) .setOverlayState(OVERLAY) .createCompositeState(true); - return create("forge_item_entity_cutout_mipped", DefaultVertexFormats.NEW_ENTITY, 7, 256, true, false, rendertype$state); + return create("forge_item_entity_cutout_mipped", DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, false, rendertype$state); } public static RenderType layeredItemTranslucent(ResourceLocation locationIn) { - RenderType.State rendertype$state = RenderType.State.builder() - .setTextureState(new RenderState.TextureState(locationIn, false, false)) + RenderType.CompositeState rendertype$state = RenderType.CompositeState.builder() + .setTextureState(new RenderStateShard.TextureStateShard(locationIn, false, false)) .setTransparencyState(TRANSLUCENT_TRANSPARENCY) - .setDiffuseLightingState(DIFFUSE_LIGHTING) - .setAlphaState(DEFAULT_ALPHA) +// .setDiffuseLightingState(DIFFUSE_LIGHTING) //TODO +// .setAlphaState(DEFAULT_ALPHA) //TODO .setLightmapState(LIGHTMAP) .setOverlayState(OVERLAY) .createCompositeState(true); - return create("forge_item_entity_translucent_cull", DefaultVertexFormats.NEW_ENTITY, 7, 256, true, true, rendertype$state); + return create("forge_item_entity_translucent_cull", DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, true, rendertype$state); } public static RenderType getText(ResourceLocation locationIn) { - RenderType.State rendertype$state = RenderType.State.builder() + RenderType.CompositeState rendertype$state = RenderType.CompositeState.builder() .setTextureState(new CustomizableTextureState(locationIn, () -> ForgeRenderTypes.enableTextTextureLinearFiltering, () -> false)) - .setAlphaState(DEFAULT_ALPHA) +// .setAlphaState(DEFAULT_ALPHA) //TODO .setTransparencyState(TRANSLUCENT_TRANSPARENCY) .setLightmapState(LIGHTMAP) .createCompositeState(false); - return create("forge_text", DefaultVertexFormats.POSITION_COLOR_TEX_LIGHTMAP, 7, 256, false, true, rendertype$state); + return create("forge_text", DefaultVertexFormat.POSITION_COLOR_TEX_LIGHTMAP, VertexFormat.Mode.QUADS, 256, false, true, rendertype$state); } public static RenderType getTextSeeThrough(ResourceLocation locationIn) { - RenderType.State rendertype$state = RenderType.State.builder() + RenderType.CompositeState rendertype$state = RenderType.CompositeState.builder() .setTextureState(new CustomizableTextureState(locationIn, () -> ForgeRenderTypes.enableTextTextureLinearFiltering, () -> false)) - .setAlphaState(DEFAULT_ALPHA) +// .setAlphaState(DEFAULT_ALPHA) //TODO .setTransparencyState(TRANSLUCENT_TRANSPARENCY) .setLightmapState(LIGHTMAP) .setDepthTestState(NO_DEPTH_TEST) .setWriteMaskState(COLOR_WRITE) .createCompositeState(false); - return create("forge_text_see_through", DefaultVertexFormats.POSITION_COLOR_TEX_LIGHTMAP, 7, 256, false, true, rendertype$state); + return create("forge_text_see_through", DefaultVertexFormat.POSITION_COLOR_TEX_LIGHTMAP, VertexFormat.Mode.QUADS, 256, false, true, rendertype$state); } } - private static class CustomizableTextureState extends TextureState + private static class CustomizableTextureState extends TextureStateShard { private CustomizableTextureState(ResourceLocation resLoc, Supplier blur, Supplier mipmap) { @@ -264,7 +263,7 @@ public enum ForgeRenderTypes this.mipmap = mipmap.get(); RenderSystem.enableTexture(); TextureManager texturemanager = Minecraft.getInstance().getTextureManager(); - texturemanager.bind(resLoc); + texturemanager.bindForSetup(resLoc); texturemanager.getTexture(resLoc).setFilter(this.blur, this.mipmap); }; } diff --git a/src/main/java/net/minecraftforge/client/ForgeWorldTypeScreens.java b/src/main/java/net/minecraftforge/client/ForgeWorldTypeScreens.java index 5680e09e6f..5853333d94 100644 --- a/src/main/java/net/minecraftforge/client/ForgeWorldTypeScreens.java +++ b/src/main/java/net/minecraftforge/client/ForgeWorldTypeScreens.java @@ -20,13 +20,13 @@ package net.minecraftforge.client; import com.google.common.collect.Maps; -import net.minecraft.client.gui.screen.BiomeGeneratorTypeScreens; -import net.minecraft.util.registry.DynamicRegistries; -import net.minecraft.util.registry.Registry; -import net.minecraft.world.biome.Biome; -import net.minecraft.world.gen.ChunkGenerator; -import net.minecraft.world.gen.DimensionSettings; -import net.minecraft.world.gen.settings.DimensionGeneratorSettings; +import net.minecraft.client.gui.screens.worldselection.WorldPreset; +import net.minecraft.core.RegistryAccess; +import net.minecraft.core.Registry; +import net.minecraft.world.level.biome.Biome; +import net.minecraft.world.level.chunk.ChunkGenerator; +import net.minecraft.world.level.levelgen.NoiseGeneratorSettings; +import net.minecraft.world.level.levelgen.WorldGenSettings; import net.minecraftforge.common.world.ForgeWorldType; import net.minecraftforge.registries.ForgeRegistries; import org.apache.logging.log4j.LogManager; @@ -41,10 +41,10 @@ public class ForgeWorldTypeScreens { private static final Logger LOGGER = LogManager.getLogger(); - private static final Map GENERATORS = Maps.newHashMap(); - private static final Map GENERATOR_SCREEN_FACTORIES = Maps.newHashMap(); + private static final Map GENERATORS = Maps.newHashMap(); + private static final Map GENERATOR_SCREEN_FACTORIES = Maps.newHashMap(); - public static synchronized void registerFactory(ForgeWorldType type, BiomeGeneratorTypeScreens.IFactory factory) + public static synchronized void registerFactory(ForgeWorldType type, WorldPreset.PresetEditor factory) { if (GENERATOR_SCREEN_FACTORIES.containsKey(type)) throw new IllegalStateException("Factory has already been registered for: " + type); @@ -52,25 +52,25 @@ public class ForgeWorldTypeScreens GENERATOR_SCREEN_FACTORIES.put(type, factory); } - static BiomeGeneratorTypeScreens getDefaultGenerator() + static WorldPreset getDefaultGenerator() { ForgeWorldType def = ForgeWorldType.getDefaultWorldType(); if (def == null) { - return BiomeGeneratorTypeScreens.NORMAL; + return WorldPreset.NORMAL; } - BiomeGeneratorTypeScreens gen = GENERATORS.get(def); + WorldPreset gen = GENERATORS.get(def); if (gen == null) { LOGGER.error("The default world type '{}' has not been added to the GUI. Was it registered too late?", def.getRegistryName()); - return BiomeGeneratorTypeScreens.NORMAL; + return WorldPreset.NORMAL; } return gen; } - static BiomeGeneratorTypeScreens.IFactory getGeneratorScreenFactory(Optional generator, @Nullable BiomeGeneratorTypeScreens.IFactory biomegeneratortypescreens$ifactory) + static WorldPreset.PresetEditor getGeneratorScreenFactory(Optional generator, @Nullable WorldPreset.PresetEditor biomegeneratortypescreens$ifactory) { return generator.filter(gen -> gen instanceof GeneratorType) .map(type -> GENERATOR_SCREEN_FACTORIES.get(((GeneratorType)type).getWorldType())) @@ -82,11 +82,11 @@ public class ForgeWorldTypeScreens ForgeRegistries.WORLD_TYPES.forEach(wt -> { GeneratorType gen = new GeneratorType(wt); GENERATORS.put(wt, gen); - BiomeGeneratorTypeScreens.registerGenerator(gen); + WorldPreset.registerGenerator(gen); }); } - private static class GeneratorType extends BiomeGeneratorTypeScreens + private static class GeneratorType extends WorldPreset { private final ForgeWorldType worldType; @@ -103,14 +103,14 @@ public class ForgeWorldTypeScreens @Nonnull @Override - public DimensionGeneratorSettings create(@Nonnull DynamicRegistries.Impl dynamicRegistries, long seed, boolean generateStructures, boolean bonusChest) + public WorldGenSettings create(@Nonnull RegistryAccess.RegistryHolder dynamicRegistries, long seed, boolean generateStructures, boolean bonusChest) { return worldType.createSettings(dynamicRegistries, seed, generateStructures, bonusChest, ""); } @Nonnull @Override - protected ChunkGenerator generator(@Nonnull Registry p_241869_1_, @Nonnull Registry p_241869_2_, long p_241869_3_) + protected ChunkGenerator generator(@Nonnull Registry p_241869_1_, @Nonnull Registry p_241869_2_, long p_241869_3_) { return worldType.createChunkGenerator(p_241869_1_, p_241869_2_, p_241869_3_, ""); } diff --git a/src/main/java/net/minecraftforge/client/IBlockRenderProperties.java b/src/main/java/net/minecraftforge/client/IBlockRenderProperties.java new file mode 100644 index 0000000000..d4b6048b30 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/IBlockRenderProperties.java @@ -0,0 +1,111 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.client; + +import com.mojang.math.Vector3d; +import net.minecraft.client.particle.ParticleEngine; +import net.minecraft.core.BlockPos; +import net.minecraft.world.effect.MobEffects; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.phys.HitResult; + +public interface IBlockRenderProperties +{ + IBlockRenderProperties DUMMY = new IBlockRenderProperties() + { + }; + + /** + * Spawn a digging particle effect in the Level, this is a wrapper + * around EffectRenderer.addBlockHitEffects to allow the block more + * control over the particles. Useful when you have entirely different + * texture sheets for different sides/locations in the Level. + * + * @param state The current state + * @param Level The current Level + * @param target The target the player is looking at {x/y/z/side/sub} + * @param manager A reference to the current particle manager. + * @return True to prevent vanilla digging particles form spawning. + */ + default boolean addHitEffects(BlockState state, Level Level, HitResult target, ParticleEngine manager) + { + return false; + } + + /** + * Spawn particles for when the block is destroyed. Due to the nature + * of how this is invoked, the x/y/z locations are not always guaranteed + * to host your block. So be sure to do proper sanity checks before assuming + * that the location is this block. + * + * @param Level The current Level + * @param pos Position to spawn the particle + * @param manager A reference to the current particle manager. + * @return True to prevent vanilla break particles from spawning. + */ + default boolean addDestroyEffects(BlockState state, Level Level, BlockPos pos, ParticleEngine manager) + { + return false; + } + + /** + * NOT CURRENTLY IMPLEMENTED + *

+ * Use this to change the fog color used when the entity is "inside" a material. + * Vec3d is used here as "r/g/b" 0 - 1 values. + * + * @param Level The Level. + * @param pos The position at the entity viewport. + * @param state The state at the entity viewport. + * @param entity the entity + * @param originalColor The current fog color, You are not expected to use this, Return as the default if applicable. + * @return The new fog color. + */ + default Vector3d getFogColor(BlockState state, LevelReader Level, BlockPos pos, Entity entity, Vector3d originalColor, float partialTicks) + { + if (state.getMaterial() == Material.WATER) + { + float f12 = 0.0F; + + if (entity instanceof LivingEntity) + { + LivingEntity ent = (LivingEntity) entity; + f12 = (float) EnchantmentHelper.getRespiration(ent) * 0.2F; + + if (ent.hasEffect(MobEffects.WATER_BREATHING)) + { + f12 = f12 * 0.3F + 0.6F; + } + } + return new Vector3d(0.02F + f12, 0.02F + f12, 0.2F + f12); + } + else if (state.getMaterial() == Material.LAVA) + { + return new Vector3d(0.6F, 0.1F, 0.0F); + } + return originalColor; + } +} diff --git a/src/main/java/net/minecraftforge/client/ICloudRenderHandler.java b/src/main/java/net/minecraftforge/client/ICloudRenderHandler.java index 4d2cbc2e6f..8cc77d0e1e 100644 --- a/src/main/java/net/minecraftforge/client/ICloudRenderHandler.java +++ b/src/main/java/net/minecraftforge/client/ICloudRenderHandler.java @@ -19,9 +19,9 @@ package net.minecraftforge.client; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; -import net.minecraft.client.world.ClientWorld; +import net.minecraft.client.multiplayer.ClientLevel; /** * Call {@link net.minecraft.client.world.DimensionRenderInfo#setCloudRenderHandler(ICloudRenderHandler)}, obtained from a {@link ClientWorld} with an implementation of this to override all cloud rendering with your own. @@ -29,5 +29,5 @@ import net.minecraft.client.world.ClientWorld; */ @FunctionalInterface public interface ICloudRenderHandler { - void render(int ticks, float partialTicks, MatrixStack matrixStack, ClientWorld world, Minecraft mc, double viewEntityX, double viewEntityY, double viewEntityZ); + void render(int ticks, float partialTicks, PoseStack matrixStack, ClientLevel world, Minecraft mc, double viewEntityX, double viewEntityY, double viewEntityZ); } diff --git a/src/main/java/net/minecraftforge/client/IItemRenderProperties.java b/src/main/java/net/minecraftforge/client/IItemRenderProperties.java new file mode 100644 index 0000000000..c5d2766945 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/IItemRenderProperties.java @@ -0,0 +1,86 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.client; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Font; +import net.minecraft.client.model.HumanoidModel; +import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; + +public interface IItemRenderProperties +{ + IItemRenderProperties DUMMY = new IItemRenderProperties() + { + }; + + /** + * Returns the font renderer used to render tooltips and overlays for this item. + * Returning null will use the standard font renderer. + * + * @param stack The current item stack + * @return A instance of FontRenderer or null to use default + */ + default Font getFont(ItemStack stack) + { + return null; + } + + /** + * Override this method to have an item handle its own armor rendering. + * + * @param entityLiving The entity wearing the armor + * @param itemStack The itemStack to render the model of + * @param armorSlot The slot the armor is in + * @param _default Original armor model. Will have attributes set. + * @return A ModelBiped to render instead of the default + */ + default > A getArmorModel(LivingEntity entityLiving, ItemStack itemStack, EquipmentSlot armorSlot, A _default) + { + return null; + } + + /** + * Called when the client starts rendering the HUD, for whatever item the player + * currently has as a helmet. This is where pumpkins would render there overlay. + * + * @param stack The ItemStack that is equipped + * @param player Reference to the current client entity + * @param width Viewport width + * @param height Viewport height + * @param partialTicks Partial ticks for the renderer, useful for interpolation + */ + default void renderHelmetOverlay(ItemStack stack, Player player, int width, int height, float partialTicks) + { + + } + + /** + * @return This Item's renderer, or the default instance if it does not have + * one. + */ + default BlockEntityWithoutLevelRenderer getItemStackRenderer() + { + return Minecraft.getInstance().getItemRenderer().getBlockEntityRenderer(); + } +} diff --git a/src/main/java/net/minecraftforge/client/ISkyRenderHandler.java b/src/main/java/net/minecraftforge/client/ISkyRenderHandler.java index 37009db7dc..32b3baf71b 100644 --- a/src/main/java/net/minecraftforge/client/ISkyRenderHandler.java +++ b/src/main/java/net/minecraftforge/client/ISkyRenderHandler.java @@ -19,9 +19,9 @@ package net.minecraftforge.client; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; -import net.minecraft.client.world.ClientWorld; +import net.minecraft.client.multiplayer.ClientLevel; /** * Call {@link net.minecraft.client.world.DimensionRenderInfo#setSkyRenderHandler(ISkyRenderHandler)}, obtained from a {@link ClientWorld} with an implementation of this to override all sky rendering with your own. @@ -29,5 +29,5 @@ import net.minecraft.client.world.ClientWorld; */ @FunctionalInterface public interface ISkyRenderHandler { - void render(int ticks, float partialTicks, MatrixStack matrixStack, ClientWorld world, Minecraft mc); + void render(int ticks, float partialTicks, PoseStack matrixStack, ClientLevel world, Minecraft mc); } diff --git a/src/main/java/net/minecraftforge/client/IWeatherParticleRenderHandler.java b/src/main/java/net/minecraftforge/client/IWeatherParticleRenderHandler.java index 16953c9142..36673d08d0 100644 --- a/src/main/java/net/minecraftforge/client/IWeatherParticleRenderHandler.java +++ b/src/main/java/net/minecraftforge/client/IWeatherParticleRenderHandler.java @@ -20,8 +20,8 @@ package net.minecraftforge.client; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.ActiveRenderInfo; -import net.minecraft.client.world.ClientWorld; +import net.minecraft.client.Camera; +import net.minecraft.client.multiplayer.ClientLevel; /** * Call {@link net.minecraft.client.world.DimensionRenderInfo#setWeatherParticleRenderHandler(net.minecraftforge.client.IWeatherParticleRenderHandler)}, obtained from a {@link ClientWorld} with an implementation of this to override all weather particle rendering with your own. @@ -30,5 +30,5 @@ import net.minecraft.client.world.ClientWorld; */ @FunctionalInterface public interface IWeatherParticleRenderHandler { - void render(int ticks, ClientWorld world, Minecraft mc, ActiveRenderInfo activeRenderInfoIn); + void render(int ticks, ClientLevel world, Minecraft mc, Camera activeRenderInfoIn); } diff --git a/src/main/java/net/minecraftforge/client/IWeatherRenderHandler.java b/src/main/java/net/minecraftforge/client/IWeatherRenderHandler.java index f3aad46627..cc16840502 100644 --- a/src/main/java/net/minecraftforge/client/IWeatherRenderHandler.java +++ b/src/main/java/net/minecraftforge/client/IWeatherRenderHandler.java @@ -21,7 +21,7 @@ package net.minecraftforge.client; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.LightTexture; -import net.minecraft.client.world.ClientWorld; +import net.minecraft.client.multiplayer.ClientLevel; /** * Call {@link net.minecraft.client.world.DimensionRenderInfo#setWeatherRenderHandler(IWeatherRenderHandler)}, obtained from a {@link ClientWorld} with an implementation of this to override all weather rendering with your own. @@ -29,5 +29,5 @@ import net.minecraft.client.world.ClientWorld; */ @FunctionalInterface public interface IWeatherRenderHandler { - void render(int ticks, float partialTicks, ClientWorld world, Minecraft mc, LightTexture lightmapIn, double xIn, double yIn, double zIn); + void render(int ticks, float partialTicks, ClientLevel world, Minecraft mc, LightTexture lightmapIn, double xIn, double yIn, double zIn); } diff --git a/src/main/java/net/minecraftforge/client/ItemModelMesherForge.java b/src/main/java/net/minecraftforge/client/ItemModelMesherForge.java index 53d3ffa938..0853df088e 100644 --- a/src/main/java/net/minecraftforge/client/ItemModelMesherForge.java +++ b/src/main/java/net/minecraftforge/client/ItemModelMesherForge.java @@ -26,22 +26,22 @@ import javax.annotation.Nullable; import com.google.common.collect.Maps; -import net.minecraft.client.renderer.ItemModelMesher; -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.model.ModelBakery; -import net.minecraft.client.renderer.model.ModelManager; -import net.minecraft.client.renderer.model.ModelResourceLocation; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; +import net.minecraft.client.renderer.ItemModelShaper; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.resources.model.ModelBakery; +import net.minecraft.client.resources.model.ModelManager; +import net.minecraft.client.resources.model.ModelResourceLocation; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; import net.minecraftforge.registries.IRegistryDelegate; /** * Wrapper around ItemModeMesher that cleans up the internal maps to respect ID remapping. */ -public class ItemModelMesherForge extends ItemModelMesher +public class ItemModelMesherForge extends ItemModelShaper { final Map, ModelResourceLocation> locations = Maps.newHashMap(); - final Map, IBakedModel> models = Maps.newHashMap(); + final Map, BakedModel> models = Maps.newHashMap(); public ItemModelMesherForge(ModelManager manager) { @@ -50,7 +50,7 @@ public class ItemModelMesherForge extends ItemModelMesher @Override @Nullable - public IBakedModel getItemModel(Item item) + public BakedModel getItemModel(Item item) { return models.get(item.delegate); } diff --git a/src/main/java/net/minecraftforge/client/MinecraftForgeClient.java b/src/main/java/net/minecraftforge/client/MinecraftForgeClient.java index 62f0ea00fd..cc3bb7240d 100644 --- a/src/main/java/net/minecraftforge/client/MinecraftForgeClient.java +++ b/src/main/java/net/minecraftforge/client/MinecraftForgeClient.java @@ -40,13 +40,13 @@ import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.chunk.ChunkRenderCache; -import net.minecraft.client.renderer.texture.NativeImage; -import net.minecraft.resources.IResource; -import net.minecraft.resources.IResourceManager; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.client.renderer.chunk.RenderChunkRegion; +import com.mojang.blaze3d.platform.NativeImage; +import net.minecraft.server.packs.resources.Resource; +import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; import net.minecraftforge.client.textures.ITextureAtlasSpriteLoader; public class MinecraftForgeClient @@ -102,20 +102,20 @@ public class MinecraftForgeClient } } - private static final LoadingCache, Optional> regionCache = CacheBuilder.newBuilder() + private static final LoadingCache, Optional> regionCache = CacheBuilder.newBuilder() .maximumSize(500) .concurrencyLevel(5) .expireAfterAccess(1, TimeUnit.SECONDS) - .build(new CacheLoader, Optional>() + .build(new CacheLoader, Optional>() { @Override - public Optional load(Pair key) + public Optional load(Pair key) { - return Optional.ofNullable(ChunkRenderCache.createIfNotEmpty(key.getLeft(), key.getRight().offset(-1, -1, -1), key.getRight().offset(16, 16, 16), 1)); + return Optional.ofNullable(RenderChunkRegion.createIfNotEmpty(key.getLeft(), key.getRight().offset(-1, -1, -1), key.getRight().offset(16, 16, 16), 1)); } }); - public static void onRebuildChunk(World world, BlockPos position, ChunkRenderCache cache) + public static void onRebuildChunk(Level world, BlockPos position, RenderChunkRegion cache) { if (cache == null) regionCache.invalidate(Pair.of(world, position)); @@ -124,12 +124,12 @@ public class MinecraftForgeClient } @Nullable - public static ChunkRenderCache getRegionRenderCache(World world, BlockPos pos) + public static RenderChunkRegion getRegionRenderCache(Level world, BlockPos pos) { return getRegionRenderCacheOptional(world, pos).orElse(null); } - public static Optional getRegionRenderCacheOptional(World world, BlockPos pos) + public static Optional getRegionRenderCacheOptional(Level world, BlockPos pos) { int x = pos.getX() & ~0xF; int y = pos.getY() & ~0xF; @@ -150,13 +150,13 @@ public class MinecraftForgeClient } @Nonnull - public static NativeImage getImageLayer(ResourceLocation resourceLocation, IResourceManager resourceManager) throws IOException + public static NativeImage getImageLayer(ResourceLocation resourceLocation, ResourceManager resourceManager) throws IOException { Supplier supplier = bufferedImageSuppliers.get(resourceLocation); if (supplier != null) return supplier.get(); - IResource iresource1 = resourceManager.getResource(resourceLocation); + Resource iresource1 = resourceManager.getResource(resourceLocation); return NativeImage.read(iresource1.getInputStream()); } diff --git a/src/main/java/net/minecraftforge/client/RenderProperties.java b/src/main/java/net/minecraftforge/client/RenderProperties.java new file mode 100644 index 0000000000..6ebd27970f --- /dev/null +++ b/src/main/java/net/minecraftforge/client/RenderProperties.java @@ -0,0 +1,65 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.client; + +import net.minecraft.world.effect.MobEffect; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; + +public class RenderProperties +{ + public static EffectRenderer getEffectRenderer(MobEffectInstance effectInstance) + { + return getEffectRenderer(effectInstance.getEffect()); + } + + public static EffectRenderer getEffectRenderer(MobEffect effect) + { + return effect.getEffectRendererInternal() instanceof EffectRenderer r ? r : EffectRenderer.DUMMY; + } + + public static IItemRenderProperties get(ItemStack stack) + { + return get(stack.getItem()); + } + + public static IItemRenderProperties get(Item item) + { + return item.getRenderPropertiesInternal() instanceof IItemRenderProperties props ? props : IItemRenderProperties.DUMMY; + } + + public static IBlockRenderProperties get(BlockState state) + { + return get(state.getBlock()); + } + + public static IBlockRenderProperties get(Block block) + { + return block.getRenderPropertiesInternal() instanceof IBlockRenderProperties props ? props : IBlockRenderProperties.DUMMY; + } + + private RenderProperties() + { + // Not instantiable. + } +} diff --git a/src/main/java/net/minecraftforge/client/SkyRenderHandler.java b/src/main/java/net/minecraftforge/client/SkyRenderHandler.java deleted file mode 100644 index fb31ac6ec5..0000000000 --- a/src/main/java/net/minecraftforge/client/SkyRenderHandler.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.client; - -import com.mojang.blaze3d.matrix.MatrixStack; -import net.minecraft.client.Minecraft; -import net.minecraft.client.world.ClientWorld; - -/** - * Use {@link ISkyRenderHandler} instead. - * - * todo: remove in 1.17 - */ -@Deprecated -public interface SkyRenderHandler extends IRenderHandler { - @Override - default void render(int ticks, float partialTicks, ClientWorld world, Minecraft mc) {} - - void render(int ticks, float partialTicks, MatrixStack matrixStack, ClientWorld world, Minecraft mc); - -} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/client/event/ClientChatEvent.java b/src/main/java/net/minecraftforge/client/event/ClientChatEvent.java index 930bc1387d..8a6b9d51c7 100644 --- a/src/main/java/net/minecraftforge/client/event/ClientChatEvent.java +++ b/src/main/java/net/minecraftforge/client/event/ClientChatEvent.java @@ -22,8 +22,6 @@ package net.minecraftforge.client.event; import com.google.common.base.Strings; import net.minecraftforge.eventbus.api.Cancelable; import net.minecraftforge.eventbus.api.Event; -import net.minecraftforge.event.ForgeEventFactory; -import net.minecraftforge.common.MinecraftForge; /** * ClientChatEvent is fired whenever the client is about to send a chat message or command to the server.
diff --git a/src/main/java/net/minecraftforge/client/event/ClientChatReceivedEvent.java b/src/main/java/net/minecraftforge/client/event/ClientChatReceivedEvent.java index c6d832b0cc..fa9b2d40da 100644 --- a/src/main/java/net/minecraftforge/client/event/ClientChatReceivedEvent.java +++ b/src/main/java/net/minecraftforge/client/event/ClientChatReceivedEvent.java @@ -19,8 +19,8 @@ package net.minecraftforge.client.event; -import net.minecraft.util.text.ChatType; -import net.minecraft.util.text.ITextComponent; +import net.minecraft.network.chat.ChatType; +import net.minecraft.network.chat.Component; import net.minecraftforge.eventbus.api.Cancelable; import net.minecraftforge.eventbus.api.Event; @@ -35,24 +35,24 @@ import java.util.UUID; @Cancelable public class ClientChatReceivedEvent extends Event { - private ITextComponent message; + private Component message; private final ChatType type; @Nullable private final UUID senderUUID; - public ClientChatReceivedEvent(ChatType type, ITextComponent message, @Nullable UUID senderUUID) + public ClientChatReceivedEvent(ChatType type, Component message, @Nullable UUID senderUUID) { this.type = type; this.message = message; this.senderUUID = senderUUID; } - public ITextComponent getMessage() + public Component getMessage() { return message; } - public void setMessage(ITextComponent message) + public void setMessage(Component message) { this.message = message; } diff --git a/src/main/java/net/minecraftforge/client/event/ClientPlayerChangeGameModeEvent.java b/src/main/java/net/minecraftforge/client/event/ClientPlayerChangeGameModeEvent.java index 9ae38496e1..5f003869cd 100644 --- a/src/main/java/net/minecraftforge/client/event/ClientPlayerChangeGameModeEvent.java +++ b/src/main/java/net/minecraftforge/client/event/ClientPlayerChangeGameModeEvent.java @@ -19,8 +19,8 @@ package net.minecraftforge.client.event; -import net.minecraft.client.network.play.NetworkPlayerInfo; -import net.minecraft.world.GameType; +import net.minecraft.client.multiplayer.PlayerInfo; +import net.minecraft.world.level.GameType; import net.minecraftforge.eventbus.api.Event; /** @@ -28,18 +28,18 @@ import net.minecraftforge.eventbus.api.Event; */ public class ClientPlayerChangeGameModeEvent extends Event { - private final NetworkPlayerInfo info; + private final PlayerInfo info; private final GameType currentGameMode; private final GameType newGameMode; - public ClientPlayerChangeGameModeEvent(NetworkPlayerInfo info, GameType currentGameMode, GameType newGameMode) + public ClientPlayerChangeGameModeEvent(PlayerInfo info, GameType currentGameMode, GameType newGameMode) { this.info = info; this.currentGameMode = currentGameMode; this.newGameMode = newGameMode; } - public NetworkPlayerInfo getInfo() + public PlayerInfo getInfo() { return info; } diff --git a/src/main/java/net/minecraftforge/client/event/ClientPlayerNetworkEvent.java b/src/main/java/net/minecraftforge/client/event/ClientPlayerNetworkEvent.java index a0bc11cc2d..aa1dd06ead 100644 --- a/src/main/java/net/minecraftforge/client/event/ClientPlayerNetworkEvent.java +++ b/src/main/java/net/minecraftforge/client/event/ClientPlayerNetworkEvent.java @@ -19,9 +19,9 @@ package net.minecraftforge.client.event; -import net.minecraft.client.entity.player.ClientPlayerEntity; -import net.minecraft.client.multiplayer.PlayerController; -import net.minecraft.network.NetworkManager; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.client.multiplayer.MultiPlayerGameMode; +import net.minecraft.network.Connection; import net.minecraftforge.eventbus.api.Event; import javax.annotation.Nullable; @@ -30,15 +30,15 @@ import javax.annotation.Nullable; * Client side player connectivity events. */ public class ClientPlayerNetworkEvent extends Event { - private final PlayerController controller; - private final ClientPlayerEntity player; - private final NetworkManager networkManager; + private final MultiPlayerGameMode controller; + private final LocalPlayer player; + private final Connection networkManager; /** * @return the player controller for the client side */ @Nullable - public PlayerController getController() { + public MultiPlayerGameMode getController() { return controller; } @@ -46,7 +46,7 @@ public class ClientPlayerNetworkEvent extends Event { * @return the player instance (if present - may be null) */ @Nullable - public ClientPlayerEntity getPlayer() { + public LocalPlayer getPlayer() { return player; } @@ -54,11 +54,11 @@ public class ClientPlayerNetworkEvent extends Event { * @return the network connection (if present - may be null) */ @Nullable - public NetworkManager getNetworkManager() { + public Connection getNetworkManager() { return networkManager; } - ClientPlayerNetworkEvent(final PlayerController controller, final ClientPlayerEntity player, final NetworkManager networkManager) { + ClientPlayerNetworkEvent(final MultiPlayerGameMode controller, final LocalPlayer player, final Connection networkManager) { this.controller = controller; this.player = player; this.networkManager = networkManager; @@ -69,7 +69,7 @@ public class ClientPlayerNetworkEvent extends Event { */ public static class LoggedInEvent extends ClientPlayerNetworkEvent { - public LoggedInEvent(final PlayerController controller, final ClientPlayerEntity player, final NetworkManager networkManager) { + public LoggedInEvent(final MultiPlayerGameMode controller, final LocalPlayer player, final Connection networkManager) { super(controller, player, networkManager); } } @@ -79,7 +79,7 @@ public class ClientPlayerNetworkEvent extends Event { */ public static class LoggedOutEvent extends ClientPlayerNetworkEvent { - public LoggedOutEvent(final PlayerController controller, final ClientPlayerEntity player, final NetworkManager networkManager) { + public LoggedOutEvent(final MultiPlayerGameMode controller, final LocalPlayer player, final Connection networkManager) { super(controller, player, networkManager); } } @@ -88,18 +88,18 @@ public class ClientPlayerNetworkEvent extends Event { * Fired when the player object respawns, such as dimension changes. */ public static class RespawnEvent extends ClientPlayerNetworkEvent { - private final ClientPlayerEntity oldPlayer; + private final LocalPlayer oldPlayer; - public RespawnEvent(final PlayerController pc, final ClientPlayerEntity oldPlayer, final ClientPlayerEntity newPlayer, final NetworkManager networkManager) { + public RespawnEvent(final MultiPlayerGameMode pc, final LocalPlayer oldPlayer, final LocalPlayer newPlayer, final Connection networkManager) { super(pc, newPlayer, networkManager); this.oldPlayer = oldPlayer; } - public ClientPlayerEntity getOldPlayer() { + public LocalPlayer getOldPlayer() { return oldPlayer; } - public ClientPlayerEntity getNewPlayer() { + public LocalPlayer getNewPlayer() { return super.getPlayer(); } } diff --git a/src/main/java/net/minecraftforge/client/event/ColorHandlerEvent.java b/src/main/java/net/minecraftforge/client/event/ColorHandlerEvent.java index 225eb19ea0..00296a7aa4 100644 --- a/src/main/java/net/minecraftforge/client/event/ColorHandlerEvent.java +++ b/src/main/java/net/minecraftforge/client/event/ColorHandlerEvent.java @@ -19,10 +19,10 @@ package net.minecraftforge.client.event; -import net.minecraft.client.renderer.color.BlockColors; -import net.minecraft.client.renderer.color.ItemColors; +import net.minecraft.client.color.block.BlockColors; +import net.minecraft.client.color.item.ItemColors; import net.minecraftforge.eventbus.api.Event; -import net.minecraftforge.fml.event.lifecycle.IModBusEvent; +import net.minecraftforge.fml.event.IModBusEvent; /** * Use these events to register block/item diff --git a/src/main/java/net/minecraftforge/client/event/DrawHighlightEvent.java b/src/main/java/net/minecraftforge/client/event/DrawHighlightEvent.java deleted file mode 100644 index 43e26db668..0000000000 --- a/src/main/java/net/minecraftforge/client/event/DrawHighlightEvent.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.client.event; - -import com.mojang.blaze3d.matrix.MatrixStack; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.EntityRayTraceResult; -import net.minecraftforge.eventbus.api.Cancelable; -import net.minecraftforge.eventbus.api.Event; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.client.renderer.ActiveRenderInfo; -import net.minecraft.client.renderer.WorldRenderer; - -/** - * An event called whenever the selection highlight around blocks is about to be rendered. - * Canceling this event stops the selection highlight from being rendered. - * - * TODO: Rename to DrawSelectionEvent - */ -@Cancelable -public class DrawHighlightEvent extends Event -{ - private final WorldRenderer context; - private final ActiveRenderInfo info; - private final RayTraceResult target; - private final float partialTicks; - private final MatrixStack matrix; - private final IRenderTypeBuffer buffers; - - public DrawHighlightEvent(WorldRenderer context, ActiveRenderInfo info, RayTraceResult target, float partialTicks, MatrixStack matrix, IRenderTypeBuffer buffers) - { - this.context = context; - this.info = info; - this.target = target; - this.partialTicks= partialTicks; - this.matrix = matrix; - this.buffers = buffers; - } - - public WorldRenderer getContext() { return context; } - public ActiveRenderInfo getInfo() { return info; } - public RayTraceResult getTarget() { return target; } - public float getPartialTicks() { return partialTicks; } - public MatrixStack getMatrix() { return matrix; } - public IRenderTypeBuffer getBuffers() { return buffers; } - - /** - * A variant of the DrawHighlightEvent only called when a block is highlighted. - */ - @Cancelable - public static class HighlightBlock extends DrawHighlightEvent - { - public HighlightBlock(WorldRenderer context, ActiveRenderInfo info, RayTraceResult target, float partialTicks, MatrixStack matrix, IRenderTypeBuffer buffers) - { - super(context, info, target, partialTicks, matrix, buffers); - } - - @Override - public BlockRayTraceResult getTarget() - { - return (BlockRayTraceResult) super.target; - } - } - - /** - * A variant of the DrawHighlightEvent only called when an entity is highlighted. - * Canceling this event has no effect. - */ - @Cancelable - public static class HighlightEntity extends DrawHighlightEvent - { - public HighlightEntity(WorldRenderer context, ActiveRenderInfo info, RayTraceResult target, float partialTicks, MatrixStack matrix, IRenderTypeBuffer buffers) - { - super(context, info, target, partialTicks, matrix, buffers); - } - - @Override - public EntityRayTraceResult getTarget() - { - return (EntityRayTraceResult) super.target; - } - } -} diff --git a/src/main/java/net/minecraftforge/client/event/DrawSelectionEvent.java b/src/main/java/net/minecraftforge/client/event/DrawSelectionEvent.java new file mode 100644 index 0000000000..146eb18503 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/event/DrawSelectionEvent.java @@ -0,0 +1,99 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.client.event; + +import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.EntityHitResult; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; +import net.minecraft.world.phys.HitResult; +import net.minecraft.client.Camera; +import net.minecraft.client.renderer.LevelRenderer; + +/** + * An event called whenever the selection highlight around a block or entity is about to be rendered. + * Canceling this event stops the selection highlight from being rendered. + */ +@Cancelable +public class DrawSelectionEvent extends Event +{ + private final LevelRenderer context; + private final Camera info; + private final HitResult target; + private final float partialTicks; + private final PoseStack matrix; + private final MultiBufferSource buffers; + + public DrawSelectionEvent(LevelRenderer context, Camera info, HitResult target, float partialTicks, PoseStack matrix, MultiBufferSource buffers) + { + this.context = context; + this.info = info; + this.target = target; + this.partialTicks= partialTicks; + this.matrix = matrix; + this.buffers = buffers; + } + + public LevelRenderer getContext() { return context; } + public Camera getInfo() { return info; } + public HitResult getTarget() { return target; } + public float getPartialTicks() { return partialTicks; } + public PoseStack getMatrix() { return matrix; } + public MultiBufferSource getBuffers() { return buffers; } + + /** + * A variant of the DrawSelectionEvent only called when a block is highlighted. + */ + @Cancelable + public static class HighlightBlock extends DrawSelectionEvent + { + public HighlightBlock(LevelRenderer context, Camera info, HitResult target, float partialTicks, PoseStack matrix, MultiBufferSource buffers) + { + super(context, info, target, partialTicks, matrix, buffers); + } + + @Override + public BlockHitResult getTarget() + { + return (BlockHitResult) super.target; + } + } + + /** + * A variant of the DrawSelectionEvent only called when an entity is highlighted. + * Canceling this event has no effect. + */ + @Cancelable + public static class HighlightEntity extends DrawSelectionEvent + { + public HighlightEntity(LevelRenderer context, Camera info, HitResult target, float partialTicks, PoseStack matrix, MultiBufferSource buffers) + { + super(context, info, target, partialTicks, matrix, buffers); + } + + @Override + public EntityHitResult getTarget() + { + return (EntityHitResult) super.target; + } + } +} diff --git a/src/main/java/net/minecraftforge/client/event/EntityViewRenderEvent.java b/src/main/java/net/minecraftforge/client/event/EntityViewRenderEvent.java index 67b65255bd..42bfd6f9a5 100644 --- a/src/main/java/net/minecraftforge/client/event/EntityViewRenderEvent.java +++ b/src/main/java/net/minecraftforge/client/event/EntityViewRenderEvent.java @@ -20,8 +20,8 @@ package net.minecraftforge.client.event; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.ActiveRenderInfo; -import net.minecraft.client.renderer.FogRenderer.FogType; +import net.minecraft.client.Camera; +import net.minecraft.client.renderer.FogRenderer.FogMode; import net.minecraft.client.renderer.GameRenderer; import net.minecraftforge.eventbus.api.Cancelable; @@ -34,10 +34,10 @@ import net.minecraftforge.eventbus.api.Event.HasResult; public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus.api.Event { private final GameRenderer renderer; - private final ActiveRenderInfo info; + private final Camera info; private final double renderPartialTicks; - public EntityViewRenderEvent(GameRenderer renderer, ActiveRenderInfo info, double renderPartialTicks) + public EntityViewRenderEvent(GameRenderer renderer, Camera info, double renderPartialTicks) { this.renderer = renderer; this.info = info; @@ -49,7 +49,7 @@ public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus. return renderer; } - public ActiveRenderInfo getInfo() + public Camera getInfo() { return info; } @@ -61,15 +61,15 @@ public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus. private static class FogEvent extends EntityViewRenderEvent { - private final FogType type; + private final FogMode type; @SuppressWarnings("resource") - protected FogEvent(FogType type, ActiveRenderInfo info, double renderPartialTicks) + protected FogEvent(FogMode type, Camera info, double renderPartialTicks) { super(Minecraft.getInstance().gameRenderer, info, renderPartialTicks); this.type = type; } - public FogType getType() { return type; } + public FogMode getType() { return type; } } /** @@ -81,7 +81,7 @@ public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus. { private float density; - public FogDensity(FogType type, ActiveRenderInfo info, float partialTicks, float density) + public FogDensity(FogMode type, Camera info, float partialTicks, float density) { super(type, info, partialTicks); this.setDensity(density); @@ -106,7 +106,7 @@ public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus. { private final float farPlaneDistance; - public RenderFogEvent(FogType type, ActiveRenderInfo info, float partialTicks, float distance) + public RenderFogEvent(FogMode type, Camera info, float partialTicks, float distance) { super(type, info, partialTicks); this.farPlaneDistance = distance; @@ -129,7 +129,7 @@ public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus. private float blue; @SuppressWarnings("resource") - public FogColors(ActiveRenderInfo info, float partialTicks, float red, float green, float blue) + public FogColors(Camera info, float partialTicks, float red, float green, float blue) { super(Minecraft.getInstance().gameRenderer, info, partialTicks); this.setRed(red); @@ -154,7 +154,7 @@ public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus. private float pitch; private float roll; - public CameraSetup(GameRenderer renderer, ActiveRenderInfo info, double renderPartialTicks, float yaw, float pitch, float roll) + public CameraSetup(GameRenderer renderer, Camera info, double renderPartialTicks, float yaw, float pitch, float roll) { super(renderer, info, renderPartialTicks); this.setYaw(yaw); @@ -178,7 +178,7 @@ public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus. { private double fov; - public FOVModifier(GameRenderer renderer, ActiveRenderInfo info, double renderPartialTicks, double fov) { + public FOVModifier(GameRenderer renderer, Camera info, double renderPartialTicks, double fov) { super(renderer, info, renderPartialTicks); this.setFOV(fov); } diff --git a/src/main/java/net/minecraftforge/client/event/FOVUpdateEvent.java b/src/main/java/net/minecraftforge/client/event/FOVUpdateEvent.java index aa2ed7ff8f..bbd8345876 100644 --- a/src/main/java/net/minecraftforge/client/event/FOVUpdateEvent.java +++ b/src/main/java/net/minecraftforge/client/event/FOVUpdateEvent.java @@ -20,24 +20,24 @@ package net.minecraftforge.client.event; import net.minecraft.client.Minecraft; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.util.math.MathHelper; +import net.minecraft.world.entity.player.Player; +import net.minecraft.util.Mth; import net.minecraftforge.eventbus.api.Event; public class FOVUpdateEvent extends Event { - private final PlayerEntity entity; + private final Player entity; private final float fov; private float newfov; - public FOVUpdateEvent(PlayerEntity entity, float fov) + public FOVUpdateEvent(Player entity, float fov) { this.entity = entity; this.fov = fov; - this.setNewfov(MathHelper.lerp(Minecraft.getInstance().options.fovEffectScale, 1.0F, fov)); + this.setNewfov(Mth.lerp(Minecraft.getInstance().options.fovEffectScale, 1.0F, fov)); } - public PlayerEntity getEntity() + public Player getEntity() { return entity; } diff --git a/src/main/java/net/minecraftforge/client/event/GuiContainerEvent.java b/src/main/java/net/minecraftforge/client/event/GuiContainerEvent.java index c3cdc34548..b93e86dcfd 100644 --- a/src/main/java/net/minecraftforge/client/event/GuiContainerEvent.java +++ b/src/main/java/net/minecraftforge/client/event/GuiContainerEvent.java @@ -19,8 +19,8 @@ package net.minecraftforge.client.event; -import com.mojang.blaze3d.matrix.MatrixStack; -import net.minecraft.client.gui.screen.inventory.ContainerScreen; +import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; import net.minecraftforge.eventbus.api.Event; /** @@ -29,14 +29,14 @@ import net.minecraftforge.eventbus.api.Event; public class GuiContainerEvent extends Event { - private final ContainerScreen guiContainer; + private final AbstractContainerScreen guiContainer; - public GuiContainerEvent(ContainerScreen guiContainer) + public GuiContainerEvent(AbstractContainerScreen guiContainer) { this.guiContainer = guiContainer; } - public ContainerScreen getGuiContainer() + public AbstractContainerScreen getGuiContainer() { return guiContainer; } @@ -49,7 +49,7 @@ public class GuiContainerEvent extends Event */ public static class DrawForeground extends GuiContainerEvent { - private final MatrixStack mStack; + private final PoseStack mStack; private final int mouseX; private final int mouseY; @@ -61,7 +61,7 @@ public class GuiContainerEvent extends Event * @param mouseX The current X position of the players mouse. * @param mouseY The current Y position of the players mouse. */ - public DrawForeground(ContainerScreen guiContainer, MatrixStack mStack, int mouseX, int mouseY) + public DrawForeground(AbstractContainerScreen guiContainer, PoseStack mStack, int mouseX, int mouseY) { super(guiContainer); this.mStack = mStack; @@ -69,7 +69,7 @@ public class GuiContainerEvent extends Event this.mouseY = mouseY; } - public MatrixStack getMatrixStack() + public PoseStack getMatrixStack() { return mStack; } @@ -91,7 +91,7 @@ public class GuiContainerEvent extends Event */ public static class DrawBackground extends GuiContainerEvent { - private final MatrixStack mStack; + private final PoseStack mStack; private final int mouseX; private final int mouseY; @@ -103,7 +103,7 @@ public class GuiContainerEvent extends Event * @param mouseX The current X position of the players mouse. * @param mouseY The current Y position of the players mouse. */ - public DrawBackground(ContainerScreen guiContainer, MatrixStack mStack, int mouseX, int mouseY) + public DrawBackground(AbstractContainerScreen guiContainer, PoseStack mStack, int mouseX, int mouseY) { super(guiContainer); this.mStack = mStack; @@ -111,7 +111,7 @@ public class GuiContainerEvent extends Event this.mouseY = mouseY; } - public MatrixStack getMatrixStack() + public PoseStack getMatrixStack() { return mStack; } diff --git a/src/main/java/net/minecraftforge/client/event/GuiOpenEvent.java b/src/main/java/net/minecraftforge/client/event/GuiOpenEvent.java index 8fa252aa7c..b4cdd014b0 100644 --- a/src/main/java/net/minecraftforge/client/event/GuiOpenEvent.java +++ b/src/main/java/net/minecraftforge/client/event/GuiOpenEvent.java @@ -21,7 +21,7 @@ package net.minecraftforge.client.event; import net.minecraftforge.eventbus.api.Cancelable; import net.minecraftforge.eventbus.api.Event; -import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.gui.screens.Screen; /** * This event is called before any Gui will open. diff --git a/src/main/java/net/minecraftforge/client/event/GuiScreenEvent.java b/src/main/java/net/minecraftforge/client/event/GuiScreenEvent.java index 6695e31abe..77c7419797 100644 --- a/src/main/java/net/minecraftforge/client/event/GuiScreenEvent.java +++ b/src/main/java/net/minecraftforge/client/event/GuiScreenEvent.java @@ -19,26 +19,21 @@ package net.minecraftforge.client.event; -import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.function.Consumer; -import com.mojang.blaze3d.matrix.MatrixStack; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.IGuiEventListener; +import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.client.gui.components.Widget; +import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraft.client.gui.widget.Widget; -import net.minecraft.client.gui.widget.button.Button; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.util.InputMappings; +import net.minecraft.client.gui.components.AbstractWidget; +import net.minecraft.client.gui.screens.Screen; import net.minecraftforge.eventbus.api.Cancelable; import net.minecraftforge.eventbus.api.Event; -import org.lwjgl.glfw.GLFW; - /** * Event classes for GuiScreen events. * @@ -64,12 +59,12 @@ public class GuiScreenEvent extends Event public static class InitGuiEvent extends GuiScreenEvent { - private Consumer add; - private Consumer remove; + private Consumer add; + private Consumer remove; - private List list; + private List list; - public InitGuiEvent(Screen gui, List list, Consumer add, Consumer remove) + public InitGuiEvent(Screen gui, List list, Consumer add, Consumer remove) { super(gui); this.list = Collections.unmodifiableList(list); @@ -80,17 +75,17 @@ public class GuiScreenEvent extends Event /** * Unmodifiable reference to the list of buttons on the {@link #gui}. */ - public List getWidgetList() + public List getWidgetList() { return list; } - public void addWidget(Widget button) + public void addWidget(GuiEventListener button) { add.accept(button); } - public void removeWidget(Widget button) + public void removeWidget(GuiEventListener button) { remove.accept(button); } @@ -107,7 +102,7 @@ public class GuiScreenEvent extends Event @Cancelable public static class Pre extends InitGuiEvent { - public Pre(Screen gui, List list, Consumer add, Consumer remove) + public Pre(Screen gui, List list, Consumer add, Consumer remove) { super(gui, list, add, remove); } @@ -119,7 +114,7 @@ public class GuiScreenEvent extends Event */ public static class Post extends InitGuiEvent { - public Post(Screen gui, List list, Consumer add, Consumer remove) + public Post(Screen gui, List list, Consumer add, Consumer remove) { super(gui, list, add, remove); } @@ -128,12 +123,12 @@ public class GuiScreenEvent extends Event public static class DrawScreenEvent extends GuiScreenEvent { - private final MatrixStack mStack; + private final PoseStack mStack; private final int mouseX; private final int mouseY; private final float renderPartialTicks; - public DrawScreenEvent(Screen gui, MatrixStack mStack, int mouseX, int mouseY, float renderPartialTicks) + public DrawScreenEvent(Screen gui, PoseStack mStack, int mouseX, int mouseY, float renderPartialTicks) { super(gui); this.mStack = mStack; @@ -145,7 +140,7 @@ public class GuiScreenEvent extends Event /** * The MatrixStack to render with. */ - public MatrixStack getMatrixStack() + public PoseStack getMatrixStack() { return mStack; } @@ -181,7 +176,7 @@ public class GuiScreenEvent extends Event @Cancelable public static class Pre extends DrawScreenEvent { - public Pre(Screen gui, MatrixStack mStack, int mouseX, int mouseY, float renderPartialTicks) + public Pre(Screen gui, PoseStack mStack, int mouseX, int mouseY, float renderPartialTicks) { super(gui, mStack, mouseX, mouseY, renderPartialTicks); } @@ -192,7 +187,7 @@ public class GuiScreenEvent extends Event */ public static class Post extends DrawScreenEvent { - public Post(Screen gui, MatrixStack mStack, int mouseX, int mouseY, float renderPartialTicks) + public Post(Screen gui, PoseStack mStack, int mouseX, int mouseY, float renderPartialTicks) { super(gui, mStack, mouseX, mouseY, renderPartialTicks); } @@ -205,9 +200,9 @@ public class GuiScreenEvent extends Event */ public static class BackgroundDrawnEvent extends GuiScreenEvent { - private final MatrixStack mStack; + private final PoseStack mStack; - public BackgroundDrawnEvent(Screen gui, MatrixStack mStack) + public BackgroundDrawnEvent(Screen gui, PoseStack mStack) { super(gui); this.mStack = mStack; @@ -216,7 +211,7 @@ public class GuiScreenEvent extends Event /** * The MatrixStack to render with. */ - public MatrixStack getMatrixStack() + public PoseStack getMatrixStack() { return mStack; } diff --git a/src/main/java/net/minecraftforge/client/event/InputEvent.java b/src/main/java/net/minecraftforge/client/event/InputEvent.java index 5b459a0c9a..8308213b4b 100644 --- a/src/main/java/net/minecraftforge/client/event/InputEvent.java +++ b/src/main/java/net/minecraftforge/client/event/InputEvent.java @@ -19,14 +19,11 @@ package net.minecraftforge.client.event; -import net.minecraft.client.settings.KeyBinding; -import net.minecraft.client.util.InputMappings; -import net.minecraft.util.Hand; +import net.minecraft.client.KeyMapping; +import net.minecraft.world.InteractionHand; import net.minecraftforge.eventbus.api.Cancelable; import net.minecraftforge.eventbus.api.Event; -import org.lwjgl.glfw.GLFW; - public class InputEvent extends Event { /** @@ -267,10 +264,10 @@ public class InputEvent extends Event public static class ClickInputEvent extends InputEvent { private final int button; - private final KeyBinding keyBinding; - private final Hand hand; + private final KeyMapping keyBinding; + private final InteractionHand hand; private boolean handSwing = true; - public ClickInputEvent(int button, KeyBinding keyBinding, Hand hand) + public ClickInputEvent(int button, KeyMapping keyBinding, InteractionHand hand) { this.button = button; this.keyBinding = keyBinding; @@ -297,7 +294,7 @@ public class InputEvent extends Event * of if either gets canceled. * Will always be MAIN_HAND if this is an attack or pick block input. */ - public Hand getHand() + public InteractionHand getHand() { return hand; } @@ -317,7 +314,7 @@ public class InputEvent extends Event return button == 2; } - public KeyBinding getKeyBinding() + public KeyMapping getKeyBinding() { return keyBinding; } diff --git a/src/main/java/net/minecraftforge/client/event/InputUpdateEvent.java b/src/main/java/net/minecraftforge/client/event/InputUpdateEvent.java index 7b20cf0e1c..ef8ce568c6 100644 --- a/src/main/java/net/minecraftforge/client/event/InputUpdateEvent.java +++ b/src/main/java/net/minecraftforge/client/event/InputUpdateEvent.java @@ -19,8 +19,8 @@ package net.minecraftforge.client.event; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.util.MovementInput; +import net.minecraft.world.entity.player.Player; +import net.minecraft.client.player.Input; import net.minecraftforge.event.entity.player.PlayerEvent; /** @@ -29,15 +29,15 @@ import net.minecraftforge.event.entity.player.PlayerEvent; */ public class InputUpdateEvent extends PlayerEvent { - private final MovementInput movementInput; + private final Input movementInput; - public InputUpdateEvent(PlayerEntity player, MovementInput movementInput) + public InputUpdateEvent(Player player, Input movementInput) { super(player); this.movementInput = movementInput; } - public MovementInput getMovementInput() + public Input getMovementInput() { return movementInput; } diff --git a/src/main/java/net/minecraftforge/client/event/ModelBakeEvent.java b/src/main/java/net/minecraftforge/client/event/ModelBakeEvent.java index 671290c71d..08a68fa28e 100644 --- a/src/main/java/net/minecraftforge/client/event/ModelBakeEvent.java +++ b/src/main/java/net/minecraftforge/client/event/ModelBakeEvent.java @@ -21,13 +21,12 @@ package net.minecraftforge.client.event; import java.util.Map; -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.model.ModelManager; -import net.minecraft.client.renderer.model.ModelResourceLocation; -import net.minecraft.util.ResourceLocation; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.resources.model.ModelManager; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.eventbus.api.Event; -import net.minecraftforge.fml.event.lifecycle.IModBusEvent; +import net.minecraftforge.fml.event.IModBusEvent; /** * Fired when the ModelManager is notified of the resource manager reloading. @@ -37,10 +36,10 @@ import net.minecraftforge.fml.event.lifecycle.IModBusEvent; public class ModelBakeEvent extends Event implements IModBusEvent { private final ModelManager modelManager; - private final Map modelRegistry; + private final Map modelRegistry; private final ModelLoader modelLoader; - public ModelBakeEvent(ModelManager modelManager, Map modelRegistry, ModelLoader modelLoader) + public ModelBakeEvent(ModelManager modelManager, Map modelRegistry, ModelLoader modelLoader) { this.modelManager = modelManager; this.modelRegistry = modelRegistry; @@ -52,7 +51,7 @@ public class ModelBakeEvent extends Event implements IModBusEvent return modelManager; } - public Map getModelRegistry() + public Map getModelRegistry() { return modelRegistry; } diff --git a/src/main/java/net/minecraftforge/client/event/ModelRegistryEvent.java b/src/main/java/net/minecraftforge/client/event/ModelRegistryEvent.java index 8e6e32d434..6dc8025eca 100644 --- a/src/main/java/net/minecraftforge/client/event/ModelRegistryEvent.java +++ b/src/main/java/net/minecraftforge/client/event/ModelRegistryEvent.java @@ -20,7 +20,7 @@ package net.minecraftforge.client.event; import net.minecraftforge.eventbus.api.Event; -import net.minecraftforge.fml.event.lifecycle.IModBusEvent; +import net.minecraftforge.fml.event.IModBusEvent; /** * Fired when the {@link net.minecraftforge.client.model.ModelLoader} is ready to register model loaders diff --git a/src/main/java/net/minecraftforge/client/event/ParticleFactoryRegisterEvent.java b/src/main/java/net/minecraftforge/client/event/ParticleFactoryRegisterEvent.java index bb00b92d91..efa60e5f4f 100644 --- a/src/main/java/net/minecraftforge/client/event/ParticleFactoryRegisterEvent.java +++ b/src/main/java/net/minecraftforge/client/event/ParticleFactoryRegisterEvent.java @@ -20,7 +20,7 @@ package net.minecraftforge.client.event; import net.minecraftforge.eventbus.api.Event; -import net.minecraftforge.fml.event.lifecycle.IModBusEvent; +import net.minecraftforge.fml.event.IModBusEvent; /** * Fired when you should call {@link net.minecraft.client.particle.ParticleManager#registerFactory}. diff --git a/src/main/java/net/minecraftforge/client/event/RecipesUpdatedEvent.java b/src/main/java/net/minecraftforge/client/event/RecipesUpdatedEvent.java index b4455c57f0..aa4ca3b7e6 100644 --- a/src/main/java/net/minecraftforge/client/event/RecipesUpdatedEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RecipesUpdatedEvent.java @@ -19,8 +19,7 @@ package net.minecraftforge.client.event; -import net.minecraft.item.crafting.RecipeManager; -import net.minecraftforge.api.distmarker.Dist; +import net.minecraft.world.item.crafting.RecipeManager; import net.minecraftforge.eventbus.api.Event; /** diff --git a/src/main/java/net/minecraftforge/client/event/RenderBlockOverlayEvent.java b/src/main/java/net/minecraftforge/client/event/RenderBlockOverlayEvent.java index 8ebaabe79d..09f5d006a4 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderBlockOverlayEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderBlockOverlayEvent.java @@ -19,11 +19,11 @@ package net.minecraftforge.client.event; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.core.BlockPos; import net.minecraftforge.eventbus.api.Cancelable; import net.minecraftforge.eventbus.api.Event; @@ -38,13 +38,13 @@ public class RenderBlockOverlayEvent extends Event FIRE, BLOCK, WATER } - private final PlayerEntity player; - private final MatrixStack mat; + private final Player player; + private final PoseStack mat; private final OverlayType overlayType; private final BlockState blockForOverlay; private final BlockPos blockPos; - public RenderBlockOverlayEvent(PlayerEntity player, MatrixStack mat, OverlayType type, BlockState block, BlockPos blockPos) + public RenderBlockOverlayEvent(Player player, PoseStack mat, OverlayType type, BlockState block, BlockPos blockPos) { this.player = player; this.mat = mat; @@ -57,8 +57,8 @@ public class RenderBlockOverlayEvent extends Event /** * The player which the overlay will apply to */ - public PlayerEntity getPlayer() { return player; } - public MatrixStack getMatrixStack() { return mat; } + public Player getPlayer() { return player; } + public PoseStack getMatrixStack() { return mat; } /** * The type of overlay to occur */ diff --git a/src/main/java/net/minecraftforge/client/event/RenderGameOverlayEvent.java b/src/main/java/net/minecraftforge/client/event/RenderGameOverlayEvent.java index 889900fedb..6e5577e0cb 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderGameOverlayEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderGameOverlayEvent.java @@ -21,16 +21,17 @@ package net.minecraftforge.client.event; import java.util.ArrayList; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraftforge.client.gui.IIngameOverlay; import net.minecraftforge.eventbus.api.Cancelable; import net.minecraftforge.eventbus.api.Event; -import net.minecraft.client.MainWindow; -import net.minecraft.client.gui.ClientBossInfo; +import com.mojang.blaze3d.platform.Window; +import net.minecraft.client.gui.components.LerpingBossEvent; @Cancelable public class RenderGameOverlayEvent extends Event { - public MatrixStack getMatrixStack() + public PoseStack getMatrixStack() { return mStack; } @@ -40,7 +41,7 @@ public class RenderGameOverlayEvent extends Event return partialTicks; } - public MainWindow getWindow() + public Window getWindow() { return window; } @@ -53,35 +54,20 @@ public class RenderGameOverlayEvent extends Event public static enum ElementType { ALL, - HELMET, - PORTAL, - CROSSHAIRS, - BOSSHEALTH, // All boss bars + LAYER, BOSSINFO, // Individual boss bar - ARMOR, - HEALTH, - FOOD, - AIR, - HOTBAR, - EXPERIENCE, TEXT, - HEALTHMOUNT, - JUMPBAR, CHAT, PLAYER_LIST, - DEBUG, - POTION_ICONS, - SUBTITLES, - FPS_GRAPH, - VIGNETTE + DEBUG } - private final MatrixStack mStack; + private final PoseStack mStack; private final float partialTicks; - private final MainWindow window; + private final Window window; private final ElementType type; - public RenderGameOverlayEvent(MatrixStack mStack, float partialTicks, MainWindow window) + public RenderGameOverlayEvent(PoseStack mStack, float partialTicks, Window window) { this.mStack = mStack; this.partialTicks = partialTicks; @@ -89,7 +75,7 @@ public class RenderGameOverlayEvent extends Event this.type = null; } - private RenderGameOverlayEvent(MatrixStack mStack, RenderGameOverlayEvent parent, ElementType type) + private RenderGameOverlayEvent(PoseStack mStack, RenderGameOverlayEvent parent, ElementType type) { this.mStack = mStack; this.partialTicks = parent.getPartialTicks(); @@ -99,7 +85,7 @@ public class RenderGameOverlayEvent extends Event public static class Pre extends RenderGameOverlayEvent { - public Pre(MatrixStack mStack, RenderGameOverlayEvent parent, ElementType type) + public Pre(PoseStack mStack, RenderGameOverlayEvent parent, ElementType type) { super(mStack, parent, type); } @@ -107,20 +93,52 @@ public class RenderGameOverlayEvent extends Event public static class Post extends RenderGameOverlayEvent { - public Post(MatrixStack mStack, RenderGameOverlayEvent parent, ElementType type) + public Post(PoseStack mStack, RenderGameOverlayEvent parent, ElementType type) { super(mStack, parent, type); } @Override public boolean isCancelable(){ return false; } } + public static class PreLayer extends Pre + { + private final IIngameOverlay overlay; + + public PreLayer(PoseStack mStack, RenderGameOverlayEvent parent, IIngameOverlay overlay) + { + super(mStack, parent, ElementType.LAYER); + this.overlay = overlay; + } + + public IIngameOverlay getOverlay() + { + return overlay; + } + } + + public static class PostLayer extends Post + { + private final IIngameOverlay overlay; + + public PostLayer(PoseStack mStack, RenderGameOverlayEvent parent, IIngameOverlay overlay) + { + super(mStack, parent, ElementType.LAYER); + this.overlay = overlay; + } + + public IIngameOverlay getOverlay() + { + return overlay; + } + } + public static class BossInfo extends Pre { - private final ClientBossInfo bossInfo; + private final LerpingBossEvent bossInfo; private final int x; private final int y; private int increment; - public BossInfo(MatrixStack mStack, RenderGameOverlayEvent parent, ElementType type, ClientBossInfo bossInfo, int x, int y, int increment) + public BossInfo(PoseStack mStack, RenderGameOverlayEvent parent, ElementType type, LerpingBossEvent bossInfo, int x, int y, int increment) { super(mStack, parent, type); this.bossInfo = bossInfo; @@ -130,9 +148,9 @@ public class RenderGameOverlayEvent extends Event } /** - * @return The {@link BossInfoClient} currently being rendered + * @return The {@link ClientBossInfo} currently being rendered */ - public ClientBossInfo getBossInfo() + public LerpingBossEvent getBossInfo() { return bossInfo; } @@ -175,7 +193,7 @@ public class RenderGameOverlayEvent extends Event { private final ArrayList left; private final ArrayList right; - public Text(MatrixStack mStack, RenderGameOverlayEvent parent, ArrayList left, ArrayList right) + public Text(PoseStack mStack, RenderGameOverlayEvent parent, ArrayList left, ArrayList right) { super(mStack, parent, ElementType.TEXT); this.left = left; @@ -198,7 +216,7 @@ public class RenderGameOverlayEvent extends Event private int posX; private int posY; - public Chat(MatrixStack mStack, RenderGameOverlayEvent parent, int posX, int posY) + public Chat(PoseStack mStack, RenderGameOverlayEvent parent, int posX, int posY) { super(mStack, parent, ElementType.CHAT); this.setPosX(posX); diff --git a/src/main/java/net/minecraftforge/client/event/RenderHandEvent.java b/src/main/java/net/minecraftforge/client/event/RenderHandEvent.java index 772476f713..42f9130645 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderHandEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderHandEvent.java @@ -21,11 +21,11 @@ package net.minecraftforge.client.event; import javax.annotation.Nonnull; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Hand; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.InteractionHand; import net.minecraftforge.eventbus.api.Cancelable; import net.minecraftforge.eventbus.api.Event; @@ -37,9 +37,9 @@ import net.minecraftforge.eventbus.api.Event; @Cancelable public class RenderHandEvent extends Event { - private final Hand hand; - private final MatrixStack mat; - private final IRenderTypeBuffer buffers; + private final InteractionHand hand; + private final PoseStack mat; + private final MultiBufferSource buffers; private final int light; private final float partialTicks; private final float interpolatedPitch; @@ -48,7 +48,7 @@ public class RenderHandEvent extends Event @Nonnull private final ItemStack stack; - public RenderHandEvent(Hand hand, MatrixStack mat, IRenderTypeBuffer buffers, int light, + public RenderHandEvent(InteractionHand hand, PoseStack mat, MultiBufferSource buffers, int light, float partialTicks, float interpolatedPitch, float swingProgress, float equipProgress, @Nonnull ItemStack stack) { @@ -63,17 +63,17 @@ public class RenderHandEvent extends Event this.stack = stack; } - public Hand getHand() + public InteractionHand getHand() { return hand; } - public MatrixStack getMatrixStack() + public PoseStack getMatrixStack() { return mat; } - public IRenderTypeBuffer getBuffers() { + public MultiBufferSource getBuffers() { return buffers; } diff --git a/src/main/java/net/minecraftforge/client/event/RenderItemInFrameEvent.java b/src/main/java/net/minecraftforge/client/event/RenderItemInFrameEvent.java index 5b79d229d5..7da22f19d1 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderItemInFrameEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderItemInFrameEvent.java @@ -19,11 +19,11 @@ package net.minecraftforge.client.event; -import com.mojang.blaze3d.matrix.MatrixStack; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.entity.ItemFrameRenderer; -import net.minecraft.entity.item.ItemFrameEntity; -import net.minecraft.item.ItemStack; +import net.minecraft.world.entity.decoration.ItemFrame; +import net.minecraft.world.item.ItemStack; import net.minecraftforge.eventbus.api.Cancelable; import net.minecraftforge.eventbus.api.Event; @@ -38,14 +38,14 @@ import javax.annotation.Nonnull; public class RenderItemInFrameEvent extends Event { private final ItemStack item; - private final ItemFrameEntity entityItemFrame; + private final ItemFrame entityItemFrame; private final ItemFrameRenderer renderer; - private final MatrixStack matrix; - private final IRenderTypeBuffer buffers; + private final PoseStack matrix; + private final MultiBufferSource buffers; private final int light; - public RenderItemInFrameEvent(ItemFrameEntity itemFrame, ItemFrameRenderer renderItemFrame, MatrixStack matrix, - IRenderTypeBuffer buffers, int light) + public RenderItemInFrameEvent(ItemFrame itemFrame, ItemFrameRenderer renderItemFrame, PoseStack matrix, + MultiBufferSource buffers, int light) { item = itemFrame.getItem(); entityItemFrame = itemFrame; @@ -61,7 +61,7 @@ public class RenderItemInFrameEvent extends Event return item; } - public ItemFrameEntity getEntityItemFrame() + public ItemFrame getEntityItemFrame() { return entityItemFrame; } @@ -71,11 +71,11 @@ public class RenderItemInFrameEvent extends Event return renderer; } - public MatrixStack getMatrix() { + public PoseStack getMatrix() { return matrix; } - public IRenderTypeBuffer getBuffers() { + public MultiBufferSource getBuffers() { return buffers; } diff --git a/src/main/java/net/minecraftforge/client/event/RenderLivingEvent.java b/src/main/java/net/minecraftforge/client/event/RenderLivingEvent.java index 4b9fe42f9d..ee839561e6 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderLivingEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderLivingEvent.java @@ -19,26 +19,26 @@ package net.minecraftforge.client.event; -import com.mojang.blaze3d.matrix.MatrixStack; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraftforge.eventbus.api.Cancelable; import net.minecraftforge.eventbus.api.Event; -import net.minecraft.client.renderer.entity.LivingRenderer; -import net.minecraft.client.renderer.entity.model.EntityModel; -import net.minecraft.entity.LivingEntity; +import net.minecraft.client.renderer.entity.LivingEntityRenderer; +import net.minecraft.client.model.EntityModel; +import net.minecraft.world.entity.LivingEntity; public abstract class RenderLivingEvent> extends Event { private final LivingEntity entity; - private final LivingRenderer renderer; + private final LivingEntityRenderer renderer; private final float partialRenderTick; - private final MatrixStack matrixStack; - private final IRenderTypeBuffer buffers; + private final PoseStack matrixStack; + private final MultiBufferSource buffers; private final int light; - public RenderLivingEvent(LivingEntity entity, LivingRenderer renderer, float partialRenderTick, MatrixStack matrixStack, - IRenderTypeBuffer buffers, int light) + public RenderLivingEvent(LivingEntity entity, LivingEntityRenderer renderer, float partialRenderTick, PoseStack matrixStack, + MultiBufferSource buffers, int light) { this.entity = entity; this.renderer = renderer; @@ -49,23 +49,23 @@ public abstract class RenderLivingEvent getRenderer() { return renderer; } + public LivingEntityRenderer getRenderer() { return renderer; } public float getPartialRenderTick() { return partialRenderTick; } - public MatrixStack getMatrixStack() { return matrixStack; } - public IRenderTypeBuffer getBuffers() { return buffers; } + public PoseStack getMatrixStack() { return matrixStack; } + public MultiBufferSource getBuffers() { return buffers; } public int getLight() { return light; } @Cancelable public static class Pre> extends RenderLivingEvent { - public Pre(LivingEntity entity, LivingRenderer renderer, float partialRenderTick, MatrixStack matrixStack, IRenderTypeBuffer buffers, int light) { + public Pre(LivingEntity entity, LivingEntityRenderer renderer, float partialRenderTick, PoseStack matrixStack, MultiBufferSource buffers, int light) { super(entity, renderer, partialRenderTick, matrixStack, buffers, light); } } public static class Post> extends RenderLivingEvent { - public Post(LivingEntity entity, LivingRenderer renderer, float partialRenderTick, MatrixStack matrixStack, IRenderTypeBuffer buffers, int light) { + public Post(LivingEntity entity, LivingEntityRenderer renderer, float partialRenderTick, PoseStack matrixStack, MultiBufferSource buffers, int light) { super(entity, renderer, partialRenderTick, matrixStack, buffers, light); } } diff --git a/src/main/java/net/minecraftforge/client/event/RenderNameplateEvent.java b/src/main/java/net/minecraftforge/client/event/RenderNameplateEvent.java index 7eedfb0271..296aef91ed 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderNameplateEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderNameplateEvent.java @@ -19,12 +19,11 @@ package net.minecraftforge.client.event; -import com.mojang.blaze3d.matrix.MatrixStack; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.entity.EntityRenderer; -import net.minecraft.entity.Entity; -import net.minecraft.util.text.ITextComponent; -import net.minecraftforge.common.MinecraftForge; +import net.minecraft.world.entity.Entity; +import net.minecraft.network.chat.Component; import net.minecraftforge.event.entity.EntityEvent; import net.minecraftforge.eventbus.api.Event; @@ -53,15 +52,15 @@ import net.minecraftforge.eventbus.api.Event; public class RenderNameplateEvent extends EntityEvent { - private ITextComponent nameplateContent; - private final ITextComponent originalContent; + private Component nameplateContent; + private final Component originalContent; private final EntityRenderer entityRenderer; - private final MatrixStack matrixStack; - private final IRenderTypeBuffer renderTypeBuffer; + private final PoseStack matrixStack; + private final MultiBufferSource renderTypeBuffer; private final int packedLight; private final float partialTicks; - public RenderNameplateEvent(Entity entity, ITextComponent content, EntityRenderer entityRenderer, MatrixStack matrixStack, IRenderTypeBuffer renderTypeBuffer, int packedLight, float partialTicks) + public RenderNameplateEvent(Entity entity, Component content, EntityRenderer entityRenderer, PoseStack matrixStack, MultiBufferSource renderTypeBuffer, int packedLight, float partialTicks) { super(entity); this.originalContent = content; @@ -76,7 +75,7 @@ public class RenderNameplateEvent extends EntityEvent /** * Sets the content that is to be rendered on the name plate/tag */ - public void setContent(ITextComponent contents) + public void setContent(Component contents) { this.nameplateContent = contents; } @@ -84,7 +83,7 @@ public class RenderNameplateEvent extends EntityEvent /** * The content being rendered on the name plate/tag */ - public ITextComponent getContent() + public Component getContent() { return this.nameplateContent; } @@ -92,7 +91,7 @@ public class RenderNameplateEvent extends EntityEvent /** * The original content being rendered on the name plate/tag */ - public ITextComponent getOriginalContent() + public Component getOriginalContent() { return this.originalContent; } @@ -108,7 +107,7 @@ public class RenderNameplateEvent extends EntityEvent /** * The matrix stack used during the rendering of the name plate/tag */ - public MatrixStack getMatrixStack() + public PoseStack getMatrixStack() { return this.matrixStack; } @@ -116,7 +115,7 @@ public class RenderNameplateEvent extends EntityEvent /** * The render type buffer used during the rendering of the name plate/tag */ - public IRenderTypeBuffer getRenderTypeBuffer() + public MultiBufferSource getRenderTypeBuffer() { return this.renderTypeBuffer; } diff --git a/src/main/java/net/minecraftforge/client/event/RenderPlayerEvent.java b/src/main/java/net/minecraftforge/client/event/RenderPlayerEvent.java index ff2f5795c9..1cbac73774 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderPlayerEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderPlayerEvent.java @@ -19,22 +19,22 @@ package net.minecraftforge.client.event; -import com.mojang.blaze3d.matrix.MatrixStack; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraftforge.eventbus.api.Cancelable; -import net.minecraft.client.renderer.entity.PlayerRenderer; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.client.renderer.entity.player.PlayerRenderer; +import net.minecraft.world.entity.player.Player; import net.minecraftforge.event.entity.player.PlayerEvent; public abstract class RenderPlayerEvent extends PlayerEvent { private final PlayerRenderer renderer; private final float partialRenderTick; - private final MatrixStack stack; - private final IRenderTypeBuffer buffers; + private final PoseStack stack; + private final MultiBufferSource buffers; private final int light; - public RenderPlayerEvent(PlayerEntity player, PlayerRenderer renderer, float partialRenderTick, MatrixStack stack, IRenderTypeBuffer buffers, int light) + public RenderPlayerEvent(Player player, PlayerRenderer renderer, float partialRenderTick, PoseStack stack, MultiBufferSource buffers, int light) { super(player); this.renderer = renderer; @@ -46,21 +46,21 @@ public abstract class RenderPlayerEvent extends PlayerEvent public PlayerRenderer getRenderer() { return renderer; } public float getPartialRenderTick() { return partialRenderTick; } - public MatrixStack getMatrixStack() { return stack; } - public IRenderTypeBuffer getBuffers() { return buffers; } + public PoseStack getMatrixStack() { return stack; } + public MultiBufferSource getBuffers() { return buffers; } public int getLight() { return light; } @Cancelable public static class Pre extends RenderPlayerEvent { - public Pre(PlayerEntity player, PlayerRenderer renderer, float tick, MatrixStack stack, IRenderTypeBuffer buffers, int light) { + public Pre(Player player, PlayerRenderer renderer, float tick, PoseStack stack, MultiBufferSource buffers, int light) { super(player, renderer, tick, stack, buffers, light); } } public static class Post extends RenderPlayerEvent { - public Post(PlayerEntity player, PlayerRenderer renderer, float tick, MatrixStack stack, IRenderTypeBuffer buffers, int light) { + public Post(Player player, PlayerRenderer renderer, float tick, PoseStack stack, MultiBufferSource buffers, int light) { super(player, renderer, tick, stack, buffers, light); } } diff --git a/src/main/java/net/minecraftforge/client/event/RenderTooltipEvent.java b/src/main/java/net/minecraftforge/client/event/RenderTooltipEvent.java index b3c869ac51..3269576fcd 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderTooltipEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderTooltipEvent.java @@ -24,13 +24,10 @@ import java.util.List; import javax.annotation.Nonnull; -import com.mojang.blaze3d.matrix.MatrixStack; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.text.ITextProperties; -import net.minecraftforge.event.entity.player.ItemTooltipEvent; -import net.minecraftforge.eventbus.api.Cancelable; -import net.minecraftforge.eventbus.api.Event; +import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.client.gui.Font; +import net.minecraft.world.item.ItemStack; +import net.minecraft.network.chat.FormattedText; /** * A set of events which are fired at various points during tooltip rendering. @@ -48,13 +45,13 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api { @Nonnull protected final ItemStack stack; - protected final List lines; - protected final MatrixStack matrixStack; + protected final List lines; + protected final PoseStack matrixStack; protected int x; protected int y; - protected FontRenderer fr; + protected Font fr; - public RenderTooltipEvent(@Nonnull ItemStack stack, @Nonnull List lines, MatrixStack matrixStack, int x, int y, @Nonnull FontRenderer fr) + public RenderTooltipEvent(@Nonnull ItemStack stack, @Nonnull List lines, PoseStack matrixStack, int x, int y, @Nonnull Font fr) { this.stack = stack; this.lines = Collections.unmodifiableList(lines); // Leave editing to ItemTooltipEvent @@ -79,7 +76,7 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api * @return An unmodifiable list of strings. Use {@link ItemTooltipEvent} to modify tooltip text. */ @Nonnull - public List getLines() + public List getLines() { return lines; } @@ -87,7 +84,7 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api /** * @return The MatrixStack of the current rendering context */ - public MatrixStack getMatrixStack() + public PoseStack getMatrixStack() { return matrixStack; } @@ -112,7 +109,7 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api * @return The {@link FontRenderer} instance the current render is using. */ @Nonnull - public FontRenderer getFontRenderer() + public Font getFontRenderer() { return fr; } @@ -129,7 +126,7 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api private int screenHeight; private int maxWidth; - public Pre(@Nonnull ItemStack stack, @Nonnull List lines, MatrixStack matrixStack, int x, int y, int screenWidth, int screenHeight, int maxWidth, @Nonnull FontRenderer fr) + public Pre(@Nonnull ItemStack stack, @Nonnull List lines, PoseStack matrixStack, int x, int y, int screenWidth, int screenHeight, int maxWidth, @Nonnull Font fr) { super(stack, lines, matrixStack, x, y, fr); this.screenWidth = screenWidth; @@ -176,7 +173,7 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api /** * Sets the {@link FontRenderer} to be used to render text. */ - public void setFontRenderer(@Nonnull FontRenderer fr) + public void setFontRenderer(@Nonnull Font fr) { this.fr = fr; } @@ -212,7 +209,7 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api private final int width; private final int height; - public Post(@Nonnull ItemStack stack, @Nonnull List textLines, MatrixStack matrixStack,int x, int y, @Nonnull FontRenderer fr, int width, int height) + public Post(@Nonnull ItemStack stack, @Nonnull List textLines, PoseStack matrixStack,int x, int y, @Nonnull Font fr, int width, int height) { super(stack, textLines, matrixStack, x, y, fr); this.width = width; @@ -241,7 +238,7 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api */ public static class PostBackground extends Post { - public PostBackground(@Nonnull ItemStack stack, @Nonnull List textLines, MatrixStack matrixStack, int x, int y, @Nonnull FontRenderer fr, int width, int height) + public PostBackground(@Nonnull ItemStack stack, @Nonnull List textLines, PoseStack matrixStack, int x, int y, @Nonnull Font fr, int width, int height) { super(stack, textLines, matrixStack, x, y, fr, width, height); } } @@ -250,7 +247,7 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api */ public static class PostText extends Post { - public PostText(@Nonnull ItemStack stack, @Nonnull List textLines, MatrixStack matrixStack, int x, int y, @Nonnull FontRenderer fr, int width, int height) + public PostText(@Nonnull ItemStack stack, @Nonnull List textLines, PoseStack matrixStack, int x, int y, @Nonnull Font fr, int width, int height) { super(stack, textLines, matrixStack, x, y, fr, width, height); } } @@ -266,7 +263,7 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api private int borderStart; private int borderEnd; - public Color(@Nonnull ItemStack stack, @Nonnull List textLines, MatrixStack matrixStack, int x, int y, @Nonnull FontRenderer fr, int background, int borderStart, + public Color(@Nonnull ItemStack stack, @Nonnull List textLines, PoseStack matrixStack, int x, int y, @Nonnull Font fr, int background, int borderStart, int borderEnd) { super(stack, textLines, matrixStack, x, y, fr); diff --git a/src/main/java/net/minecraftforge/client/event/RenderWorldLastEvent.java b/src/main/java/net/minecraftforge/client/event/RenderWorldLastEvent.java index d5546a51f4..fda93493f6 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderWorldLastEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderWorldLastEvent.java @@ -19,20 +19,20 @@ package net.minecraftforge.client.event; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.util.math.vector.Matrix4f; +import net.minecraft.client.renderer.LevelRenderer; +import com.mojang.math.Matrix4f; public class RenderWorldLastEvent extends net.minecraftforge.eventbus.api.Event { - private final WorldRenderer context; - private final MatrixStack mat; + private final LevelRenderer context; + private final PoseStack mat; private final float partialTicks; private final Matrix4f projectionMatrix; private final long finishTimeNano; - public RenderWorldLastEvent(WorldRenderer context, MatrixStack mat, float partialTicks, Matrix4f projectionMatrix, long finishTimeNano) + public RenderWorldLastEvent(LevelRenderer context, PoseStack mat, float partialTicks, Matrix4f projectionMatrix, long finishTimeNano) { this.context = context; this.mat = mat; @@ -41,12 +41,12 @@ public class RenderWorldLastEvent extends net.minecraftforge.eventbus.api.Event this.finishTimeNano = finishTimeNano; } - public WorldRenderer getContext() + public LevelRenderer getContext() { return context; } - public MatrixStack getMatrixStack() + public PoseStack getMatrixStack() { return mat; } diff --git a/src/main/java/net/minecraftforge/client/event/ScreenshotEvent.java b/src/main/java/net/minecraftforge/client/event/ScreenshotEvent.java index 576d99d3f8..ec1cb5f221 100644 --- a/src/main/java/net/minecraftforge/client/event/ScreenshotEvent.java +++ b/src/main/java/net/minecraftforge/client/event/ScreenshotEvent.java @@ -19,9 +19,9 @@ package net.minecraftforge.client.event; -import net.minecraft.client.renderer.texture.NativeImage; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; +import com.mojang.blaze3d.platform.NativeImage; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; import net.minecraftforge.eventbus.api.Cancelable; import net.minecraftforge.eventbus.api.Event; @@ -41,12 +41,12 @@ import java.io.IOException; public class ScreenshotEvent extends Event { - public static final ITextComponent DEFAULT_CANCEL_REASON = new StringTextComponent("Screenshot canceled"); + public static final Component DEFAULT_CANCEL_REASON = new TextComponent("Screenshot canceled"); private NativeImage image; private File screenshotFile; - private ITextComponent resultMessage = null; + private Component resultMessage = null; public ScreenshotEvent(NativeImage image, File screenshotFile) { @@ -72,17 +72,17 @@ public class ScreenshotEvent extends Event this.screenshotFile = screenshotFile; } - public ITextComponent getResultMessage() + public Component getResultMessage() { return resultMessage; } - public void setResultMessage(ITextComponent resultMessage) + public void setResultMessage(Component resultMessage) { this.resultMessage = resultMessage; } - public ITextComponent getCancelMessage() + public Component getCancelMessage() { return getResultMessage() != null ? getResultMessage() : DEFAULT_CANCEL_REASON; } diff --git a/src/main/java/net/minecraftforge/client/event/TextureStitchEvent.java b/src/main/java/net/minecraftforge/client/event/TextureStitchEvent.java index 944fc66923..067182c313 100644 --- a/src/main/java/net/minecraftforge/client/event/TextureStitchEvent.java +++ b/src/main/java/net/minecraftforge/client/event/TextureStitchEvent.java @@ -19,24 +19,24 @@ package net.minecraftforge.client.event; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.eventbus.api.Event; -import net.minecraft.client.renderer.texture.AtlasTexture; -import net.minecraftforge.fml.event.lifecycle.IModBusEvent; +import net.minecraft.client.renderer.texture.TextureAtlas; +import net.minecraftforge.fml.event.IModBusEvent; import java.util.Set; public class TextureStitchEvent extends Event implements IModBusEvent { - private final AtlasTexture map; + private final TextureAtlas map; - public TextureStitchEvent(AtlasTexture map) + public TextureStitchEvent(TextureAtlas map) { this.map = map; } - public AtlasTexture getMap() + public TextureAtlas getMap() { return map; } @@ -49,7 +49,7 @@ public class TextureStitchEvent extends Event implements IModBusEvent { private final Set sprites; - public Pre(AtlasTexture map, Set sprites) + public Pre(TextureAtlas map, Set sprites) { super(map); this.sprites = sprites; @@ -70,6 +70,6 @@ public class TextureStitchEvent extends Event implements IModBusEvent */ public static class Post extends TextureStitchEvent { - public Post(AtlasTexture map){ super(map); } + public Post(TextureAtlas map){ super(map); } } } diff --git a/src/main/java/net/minecraftforge/client/event/sound/PlaySoundEvent.java b/src/main/java/net/minecraftforge/client/event/sound/PlaySoundEvent.java index 60150f0e4a..57661ebefa 100644 --- a/src/main/java/net/minecraftforge/client/event/sound/PlaySoundEvent.java +++ b/src/main/java/net/minecraftforge/client/event/sound/PlaySoundEvent.java @@ -19,8 +19,8 @@ package net.minecraftforge.client.event.sound; -import net.minecraft.client.audio.ISound; -import net.minecraft.client.audio.SoundEngine; +import net.minecraft.client.resources.sounds.SoundInstance; +import net.minecraft.client.sounds.SoundEngine; /*** * Raised when the SoundManager tries to play a normal sound. @@ -31,10 +31,10 @@ import net.minecraft.client.audio.SoundEngine; public class PlaySoundEvent extends SoundEvent { private final String name; - private final ISound sound; - private ISound result; + private final SoundInstance sound; + private SoundInstance result; - public PlaySoundEvent(SoundEngine manager, ISound sound) + public PlaySoundEvent(SoundEngine manager, SoundInstance sound) { super(manager); this.sound = sound; @@ -47,17 +47,17 @@ public class PlaySoundEvent extends SoundEvent return name; } - public ISound getSound() + public SoundInstance getSound() { return sound; } - public ISound getResultSound() + public SoundInstance getResultSound() { return result; } - public void setResultSound(ISound result) + public void setResultSound(SoundInstance result) { this.result = result; } diff --git a/src/main/java/net/minecraftforge/client/event/sound/PlaySoundSourceEvent.java b/src/main/java/net/minecraftforge/client/event/sound/PlaySoundSourceEvent.java index 2954d122d6..c07f4d0425 100644 --- a/src/main/java/net/minecraftforge/client/event/sound/PlaySoundSourceEvent.java +++ b/src/main/java/net/minecraftforge/client/event/sound/PlaySoundSourceEvent.java @@ -19,14 +19,14 @@ package net.minecraftforge.client.event.sound; -import net.minecraft.client.audio.ISound; -import net.minecraft.client.audio.SoundEngine; -import net.minecraft.client.audio.SoundSource; +import net.minecraft.client.resources.sounds.SoundInstance; +import net.minecraft.client.sounds.SoundEngine; +import com.mojang.blaze3d.audio.Channel; import net.minecraftforge.client.event.sound.SoundEvent.SoundSourceEvent; public class PlaySoundSourceEvent extends SoundSourceEvent { - public PlaySoundSourceEvent(SoundEngine manager, ISound sound, SoundSource source) + public PlaySoundSourceEvent(SoundEngine manager, SoundInstance sound, Channel source) { super(manager, sound, source); } diff --git a/src/main/java/net/minecraftforge/client/event/sound/PlayStreamingSourceEvent.java b/src/main/java/net/minecraftforge/client/event/sound/PlayStreamingSourceEvent.java index 8e2634d489..943fd2bfe7 100644 --- a/src/main/java/net/minecraftforge/client/event/sound/PlayStreamingSourceEvent.java +++ b/src/main/java/net/minecraftforge/client/event/sound/PlayStreamingSourceEvent.java @@ -19,14 +19,14 @@ package net.minecraftforge.client.event.sound; -import net.minecraft.client.audio.ISound; -import net.minecraft.client.audio.SoundEngine; -import net.minecraft.client.audio.SoundSource; +import net.minecraft.client.resources.sounds.SoundInstance; +import net.minecraft.client.sounds.SoundEngine; +import com.mojang.blaze3d.audio.Channel; import net.minecraftforge.client.event.sound.SoundEvent.SoundSourceEvent; public class PlayStreamingSourceEvent extends SoundSourceEvent { - public PlayStreamingSourceEvent(SoundEngine manager, ISound sound, SoundSource source) + public PlayStreamingSourceEvent(SoundEngine manager, SoundInstance sound, Channel source) { super(manager, sound, source); } diff --git a/src/main/java/net/minecraftforge/client/event/sound/SoundEvent.java b/src/main/java/net/minecraftforge/client/event/sound/SoundEvent.java index 48a6052d14..13a6e783fb 100644 --- a/src/main/java/net/minecraftforge/client/event/sound/SoundEvent.java +++ b/src/main/java/net/minecraftforge/client/event/sound/SoundEvent.java @@ -19,10 +19,9 @@ package net.minecraftforge.client.event.sound; -import net.minecraftforge.eventbus.api.Event; -import net.minecraft.client.audio.ISound; -import net.minecraft.client.audio.SoundEngine; -import net.minecraft.client.audio.SoundSource; +import net.minecraft.client.resources.sounds.SoundInstance; +import net.minecraft.client.sounds.SoundEngine; +import com.mojang.blaze3d.audio.Channel; public class SoundEvent extends net.minecraftforge.eventbus.api.Event { @@ -39,11 +38,11 @@ public class SoundEvent extends net.minecraftforge.eventbus.api.Event public static class SoundSourceEvent extends SoundEvent { - private final ISound sound; - private final SoundSource source; + private final SoundInstance sound; + private final Channel source; private final String name; - public SoundSourceEvent(SoundEngine manager, ISound sound, SoundSource source) + public SoundSourceEvent(SoundEngine manager, SoundInstance sound, Channel source) { super(manager); this.name = sound.getLocation().getPath(); @@ -51,12 +50,12 @@ public class SoundEvent extends net.minecraftforge.eventbus.api.Event this.source = source; } - public ISound getSound() + public SoundInstance getSound() { return sound; } - public SoundSource getSource() + public Channel getSource() { return source; } diff --git a/src/main/java/net/minecraftforge/client/event/sound/SoundLoadEvent.java b/src/main/java/net/minecraftforge/client/event/sound/SoundLoadEvent.java index c0cf6fc841..269004b0a2 100644 --- a/src/main/java/net/minecraftforge/client/event/sound/SoundLoadEvent.java +++ b/src/main/java/net/minecraftforge/client/event/sound/SoundLoadEvent.java @@ -19,8 +19,8 @@ package net.minecraftforge.client.event.sound; -import net.minecraft.client.audio.SoundEngine; -import net.minecraftforge.fml.event.lifecycle.IModBusEvent; +import net.minecraft.client.sounds.SoundEngine; +import net.minecraftforge.fml.event.IModBusEvent; /** * Raised by the SoundManager.loadSoundSettings, this would be a good place for diff --git a/src/main/java/net/minecraftforge/client/event/sound/SoundSetupEvent.java b/src/main/java/net/minecraftforge/client/event/sound/SoundSetupEvent.java index 55ed5596e1..a0c0a319fb 100644 --- a/src/main/java/net/minecraftforge/client/event/sound/SoundSetupEvent.java +++ b/src/main/java/net/minecraftforge/client/event/sound/SoundSetupEvent.java @@ -19,7 +19,7 @@ package net.minecraftforge.client.event.sound; -import net.minecraft.client.audio.SoundEngine; +import net.minecraft.client.sounds.SoundEngine; /** * This event is raised by the SoundManager when it does its first setup of the diff --git a/src/main/java/net/minecraftforge/client/extensions/IForgeBakedModel.java b/src/main/java/net/minecraftforge/client/extensions/IForgeBakedModel.java index 0eb333d89b..3ddc5bc280 100644 --- a/src/main/java/net/minecraftforge/client/extensions/IForgeBakedModel.java +++ b/src/main/java/net/minecraftforge/client/extensions/IForgeBakedModel.java @@ -26,36 +26,36 @@ import java.util.Random; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.datafixers.util.Pair; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.RenderTypeLookup; -import net.minecraft.client.renderer.model.BakedQuad; -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.model.ItemCameraTransforms; +import net.minecraft.client.renderer.ItemBlockRenderTypes; +import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.renderer.block.model.ItemTransforms; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockDisplayReader; +import net.minecraft.world.item.ItemStack; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockAndTintGetter; import net.minecraftforge.client.model.data.IModelData; public interface IForgeBakedModel { - default IBakedModel getBakedModel() + private BakedModel self() { - return (IBakedModel) this; + return (BakedModel) this; } @Nonnull default List getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData extraData) { - return getBakedModel().getQuads(state, side, rand); + return self().getQuads(state, side, rand); } - default boolean isAmbientOcclusion(BlockState state) { return getBakedModel().useAmbientOcclusion(); } + default boolean isAmbientOcclusion(BlockState state) { return self().useAmbientOcclusion(); } /** * Override to tell the new model loader that it shouldn't wrap this model @@ -66,19 +66,19 @@ public interface IForgeBakedModel * Returns the pair of the model for the given perspective, and the matrix that * should be applied to the GL state before rendering it (matrix may be null). */ - default IBakedModel handlePerspective(ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat) + default BakedModel handlePerspective(ItemTransforms.TransformType cameraTransformType, PoseStack poseStack) { - return net.minecraftforge.client.ForgeHooksClient.handlePerspective(getBakedModel(), cameraTransformType, mat); + return net.minecraftforge.client.ForgeHooksClient.handlePerspective(self(), cameraTransformType, poseStack); } - default @Nonnull IModelData getModelData(@Nonnull IBlockDisplayReader world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull IModelData tileData) + default @Nonnull IModelData getModelData(@Nonnull BlockAndTintGetter world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull IModelData tileData) { return tileData; } - default TextureAtlasSprite getParticleTexture(@Nonnull IModelData data) + default TextureAtlasSprite getParticleIcon(@Nonnull IModelData data) { - return getBakedModel().getParticleIcon(); + return self().getParticleIcon(); } /** @@ -92,8 +92,8 @@ public interface IForgeBakedModel /** * If {@see isLayered()} returns true, this is called to get the list of layers to draw. */ - default List> getLayerModels(ItemStack itemStack, boolean fabulous) + default List> getLayerModels(ItemStack itemStack, boolean fabulous) { - return Collections.singletonList(Pair.of(getBakedModel(), RenderTypeLookup.getRenderType(itemStack, fabulous))); + return Collections.singletonList(Pair.of(self(), ItemBlockRenderTypes.getRenderType(itemStack, fabulous))); } } diff --git a/src/main/java/net/minecraftforge/client/extensions/IForgeKeybinding.java b/src/main/java/net/minecraftforge/client/extensions/IForgeKeyMapping.java similarity index 73% rename from src/main/java/net/minecraftforge/client/extensions/IForgeKeybinding.java rename to src/main/java/net/minecraftforge/client/extensions/IForgeKeyMapping.java index 0d0fef9802..eed9afbf95 100644 --- a/src/main/java/net/minecraftforge/client/extensions/IForgeKeybinding.java +++ b/src/main/java/net/minecraftforge/client/extensions/IForgeKeyMapping.java @@ -21,28 +21,28 @@ package net.minecraftforge.client.extensions; import javax.annotation.Nonnull; -import net.minecraft.client.settings.KeyBinding; -import net.minecraft.client.util.InputMappings; +import net.minecraft.client.KeyMapping; +import com.mojang.blaze3d.platform.InputConstants; import net.minecraftforge.client.settings.IKeyConflictContext; import net.minecraftforge.client.settings.KeyModifier; -public interface IForgeKeybinding +public interface IForgeKeyMapping { - default KeyBinding getKeyBinding() { return (KeyBinding) this; } + private KeyMapping self() { return (KeyMapping) this; } - @Nonnull InputMappings.Input getKey(); + @Nonnull InputConstants.Key getKey(); /** * Checks that the key conflict context and modifier are active, and that the keyCode matches this binding. */ - default boolean isActiveAndMatches(InputMappings.Input keyCode) + default boolean isActiveAndMatches(InputConstants.Key keyCode) { - return keyCode != InputMappings.UNKNOWN && keyCode.equals(getKey()) && getKeyConflictContext().isActive() && getKeyModifier().isActive(getKeyConflictContext()); + return keyCode != InputConstants.UNKNOWN && keyCode.equals(getKey()) && getKeyConflictContext().isActive() && getKeyModifier().isActive(getKeyConflictContext()); } default void setToDefault() { - setKeyModifierAndCode(getKeyModifierDefault(), getKeyBinding().getDefaultKey()); + setKeyModifierAndCode(getKeyModifierDefault(), self().getDefaultKey()); } void setKeyConflictContext(IKeyConflictContext keyConflictContext); @@ -53,7 +53,7 @@ public interface IForgeKeybinding KeyModifier getKeyModifier(); - void setKeyModifierAndCode(KeyModifier keyModifier, InputMappings.Input keyCode); + void setKeyModifierAndCode(KeyModifier keyModifier, InputConstants.Key keyCode); default boolean isConflictContextAndModifierActive() { @@ -63,7 +63,7 @@ public interface IForgeKeybinding /** * Returns true when one of the bindings' key codes conflicts with the other's modifier. */ - default boolean hasKeyCodeModifierConflict(KeyBinding other) + default boolean hasKeyCodeModifierConflict(KeyMapping other) { if (getKeyConflictContext().conflicts(other.getKeyConflictContext()) || other.getKeyConflictContext().conflicts(getKeyConflictContext())) { diff --git a/src/main/java/net/minecraftforge/client/extensions/IForgeModelTransform.java b/src/main/java/net/minecraftforge/client/extensions/IForgeModelState.java similarity index 86% rename from src/main/java/net/minecraftforge/client/extensions/IForgeModelTransform.java rename to src/main/java/net/minecraftforge/client/extensions/IForgeModelState.java index 9e5af244bd..c6174e110c 100644 --- a/src/main/java/net/minecraftforge/client/extensions/IForgeModelTransform.java +++ b/src/main/java/net/minecraftforge/client/extensions/IForgeModelState.java @@ -19,13 +19,13 @@ package net.minecraftforge.client.extensions; -import net.minecraft.util.math.vector.TransformationMatrix; +import com.mojang.math.Transformation; /** * An {@code IModelState} is a function from model part to a transformation that should be applied * when that part is baked, thus representing the current "state" of the model and its parts. */ -public interface IForgeModelTransform +public interface IForgeModelState { /** * @param part Part of the model we are wanting to transform. An empty optional means @@ -33,8 +33,8 @@ public interface IForgeModelTransform * @return A transformation to apply to the part, if any. The coordinate system of the transform * is determined by the part type. */ - default TransformationMatrix getPartTransformation(Object part) + default Transformation getPartTransformation(Object part) { - return TransformationMatrix.identity(); + return Transformation.identity(); } } diff --git a/src/main/java/net/minecraftforge/client/extensions/IForgeRenderChunk.java b/src/main/java/net/minecraftforge/client/extensions/IForgeRenderChunk.java index d0ab814919..891348137e 100644 --- a/src/main/java/net/minecraftforge/client/extensions/IForgeRenderChunk.java +++ b/src/main/java/net/minecraftforge/client/extensions/IForgeRenderChunk.java @@ -19,9 +19,9 @@ package net.minecraftforge.client.extensions; -import net.minecraft.client.renderer.chunk.ChunkRenderCache; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.client.renderer.chunk.RenderChunkRegion; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; public interface IForgeRenderChunk { @@ -38,8 +38,8 @@ public interface IForgeRenderChunk * the cache a 20x20x20 cube, for a total of 8000 states in the cache. * @return new RegionRenderCache instance */ - default ChunkRenderCache createRegionRenderCache(World world, BlockPos from, BlockPos to, int subtract) + default RenderChunkRegion createRegionRenderCache(Level world, BlockPos from, BlockPos to, int subtract) { - return ChunkRenderCache.createIfNotEmpty(world, from, to, subtract); + return RenderChunkRegion.createIfNotEmpty(world, from, to, subtract); } } diff --git a/src/main/java/net/minecraftforge/client/extensions/IForgeTextureAtlasSprite.java b/src/main/java/net/minecraftforge/client/extensions/IForgeTextureAtlasSprite.java index eedc9a3f9b..10034ff91b 100644 --- a/src/main/java/net/minecraftforge/client/extensions/IForgeTextureAtlasSprite.java +++ b/src/main/java/net/minecraftforge/client/extensions/IForgeTextureAtlasSprite.java @@ -25,8 +25,8 @@ import java.util.function.Function; import com.google.common.collect.ImmutableList; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.resources.IResourceManager; -import net.minecraft.util.ResourceLocation; +import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.resources.ResourceLocation; public interface IForgeTextureAtlasSprite { @@ -35,7 +35,7 @@ public interface IForgeTextureAtlasSprite * @deprecated See {@link net.minecraftforge.client.textures.ITextureAtlasSpriteLoader} */ @Deprecated - default boolean hasCustomLoader(IResourceManager manager, ResourceLocation location) + default boolean hasCustomLoader(ResourceManager manager, ResourceLocation location) { return false; } @@ -44,7 +44,7 @@ public interface IForgeTextureAtlasSprite * @deprecated See {@link net.minecraftforge.client.textures.ITextureAtlasSpriteLoader} */ @Deprecated - default boolean load(IResourceManager manager, ResourceLocation location, Function textureGetter) + default boolean load(ResourceManager manager, ResourceLocation location, Function textureGetter) { return true; } diff --git a/src/main/java/net/minecraftforge/client/extensions/IForgeTransformationMatrix.java b/src/main/java/net/minecraftforge/client/extensions/IForgeTransformation.java similarity index 52% rename from src/main/java/net/minecraftforge/client/extensions/IForgeTransformationMatrix.java rename to src/main/java/net/minecraftforge/client/extensions/IForgeTransformation.java index 52aaee8044..91501cf490 100644 --- a/src/main/java/net/minecraftforge/client/extensions/IForgeTransformationMatrix.java +++ b/src/main/java/net/minecraftforge/client/extensions/IForgeTransformation.java @@ -19,79 +19,62 @@ package net.minecraftforge.client.extensions; -import com.mojang.blaze3d.matrix.MatrixStack; -import net.minecraft.util.Direction; -import net.minecraft.util.math.vector.*; +import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.core.Direction; -/* - * Replacement interface for ModelRotation to allow custom transformations of vanilla models. - * You should probably use TRSRTransformation directly. - */ -public interface IForgeTransformationMatrix +import com.mojang.math.Matrix4f; +import com.mojang.math.Transformation; +import com.mojang.math.Vector3f; +import com.mojang.math.Vector4f; + +public interface IForgeTransformation { - default TransformationMatrix getTransformaion() + private Transformation self() { - return (TransformationMatrix)this; + return (Transformation)this; } default boolean isIdentity() { - return getTransformaion().equals(TransformationMatrix.identity()); + return self().equals(Transformation.identity()); } - default void push(MatrixStack stack) + default void push(PoseStack stack) { stack.pushPose(); - Vector3f trans = getTransformaion().getTranslation(); + Vector3f trans = self().getTranslation(); stack.translate(trans.x(), trans.y(), trans.z()); - stack.mulPose(getTransformaion().getLeftRotation()); + stack.mulPose(self().getLeftRotation()); - Vector3f scale = getTransformaion().getScale(); + Vector3f scale = self().getScale(); stack.scale(scale.x(), scale.y(), scale.z()); - stack.mulPose(getTransformaion().getRightRot()); + stack.mulPose(self().getRightRotation()); } - default TransformationMatrix compose(TransformationMatrix other) - { - if (getTransformaion().isIdentity()) return other; - if (other.isIdentity()) return getTransformaion(); - Matrix4f m = getTransformaion().getMatrix(); - m.multiply(other.getMatrix()); - return new TransformationMatrix(m); - } - - default TransformationMatrix inverse() - { - if (isIdentity()) return getTransformaion(); - Matrix4f m = getTransformaion().getMatrix().copy(); - m.invert(); - return new TransformationMatrix(m); - } - default void transformPosition(Vector4f position) { - position.transform(getTransformaion().getMatrix()); + position.transform(self().getMatrix()); } default void transformNormal(Vector3f normal) { - normal.transform(getTransformaion().getNormalMatrix()); + normal.transform(self().getNormalMatrix()); normal.normalize(); } default Direction rotateTransform(Direction facing) { - return Direction.rotate(getTransformaion().getMatrix(), facing); + return Direction.rotate(self().getMatrix(), facing); } /** * convert transformation from assuming center-block system to opposing-corner-block system */ - default TransformationMatrix blockCenterToCorner() + default Transformation blockCenterToCorner() { return applyOrigin(new Vector3f(.5f, .5f, .5f)); } @@ -99,7 +82,7 @@ public interface IForgeTransformationMatrix /** * convert transformation from assuming opposing-corner-block system to center-block system */ - default TransformationMatrix blockCornerToCenter() + default Transformation blockCornerToCenter() { return applyOrigin(new Vector3f(-.5f, -.5f, -.5f)); } @@ -109,9 +92,9 @@ public interface IForgeTransformationMatrix * Can be used for switching between coordinate systems. * Parameter is relative to the current origin. */ - default TransformationMatrix applyOrigin(Vector3f origin) { - TransformationMatrix transform = getTransformaion(); - if (transform.isIdentity()) return TransformationMatrix.identity(); + default Transformation applyOrigin(Vector3f origin) { + Transformation transform = self(); + if (transform.isIdentity()) return Transformation.identity(); Matrix4f ret = transform.getMatrix(); Matrix4f tmp = Matrix4f.createTranslateMatrix(origin.x(), origin.y(), origin.z()); @@ -119,6 +102,6 @@ public interface IForgeTransformationMatrix tmp.setIdentity(); tmp.setTranslation(-origin.x(), -origin.y(), -origin.z()); ret.multiply(tmp); - return new TransformationMatrix(ret); + return new Transformation(ret); } } diff --git a/src/main/java/net/minecraftforge/client/extensions/IForgeVertexBuilder.java b/src/main/java/net/minecraftforge/client/extensions/IForgeVertexConsumer.java similarity index 65% rename from src/main/java/net/minecraftforge/client/extensions/IForgeVertexBuilder.java rename to src/main/java/net/minecraftforge/client/extensions/IForgeVertexConsumer.java index 3b5d8186d8..757efdac7d 100644 --- a/src/main/java/net/minecraftforge/client/extensions/IForgeVertexBuilder.java +++ b/src/main/java/net/minecraftforge/client/extensions/IForgeVertexConsumer.java @@ -19,13 +19,11 @@ package net.minecraftforge.client.extensions; -import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.vertex.IVertexBuilder; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; -import net.minecraft.client.renderer.LightTexture; -import net.minecraft.client.renderer.model.BakedQuad; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.util.math.vector.*; +import net.minecraft.client.renderer.block.model.BakedQuad; +import com.mojang.blaze3d.vertex.DefaultVertexFormat; import net.minecraftforge.client.model.pipeline.LightUtil; import org.lwjgl.system.MemoryStack; @@ -34,37 +32,41 @@ import java.nio.Buffer; import java.nio.ByteBuffer; import java.nio.IntBuffer; -public interface IForgeVertexBuilder +import com.mojang.math.Matrix3f; +import com.mojang.math.Matrix4f; +import com.mojang.math.Vector3f; +import com.mojang.math.Vector4f; +import net.minecraft.core.Vec3i; + +public interface IForgeVertexConsumer { - default IVertexBuilder getVertexBuilder() { return (IVertexBuilder)this; } - - // Copy of addQuad, but enables tinting and per-vertex alpha - default void addVertexData(MatrixStack.Entry matrixStack, BakedQuad bakedQuad, float red, float green, float blue, int lightmapCoord, int overlayColor, boolean readExistingColor) { - addVertexData(matrixStack, bakedQuad, red, green, blue, 1.0f, lightmapCoord, overlayColor, readExistingColor); + // Copy of putBulkData, but enables tinting and per-vertex alpha + default void putBulkData(PoseStack.Pose matrixStack, BakedQuad bakedQuad, float red, float green, float blue, int lightmapCoord, int overlayColor, boolean readExistingColor) { + putBulkData(matrixStack, bakedQuad, red, green, blue, 1.0f, lightmapCoord, overlayColor, readExistingColor); } - // Copy of addQuad with alpha support - default void addVertexData(MatrixStack.Entry matrixEntry, BakedQuad bakedQuad, float red, float green, float blue, float alpha, int lightmapCoord, int overlayColor) { - addVertexData(matrixEntry, bakedQuad, new float[]{1.0F, 1.0F, 1.0F, 1.0F}, red, green, blue, alpha, new int[]{lightmapCoord, lightmapCoord, lightmapCoord, lightmapCoord}, overlayColor, false); + // Copy of putBulkData with alpha support + default void putBulkData(PoseStack.Pose matrixEntry, BakedQuad bakedQuad, float red, float green, float blue, float alpha, int lightmapCoord, int overlayColor) { + putBulkData(matrixEntry, bakedQuad, new float[]{1.0F, 1.0F, 1.0F, 1.0F}, red, green, blue, alpha, new int[]{lightmapCoord, lightmapCoord, lightmapCoord, lightmapCoord}, overlayColor, false); } - // Copy of addQuad with alpha support - default void addVertexData(MatrixStack.Entry matrixEntry, BakedQuad bakedQuad, float red, float green, float blue, float alpha, int lightmapCoord, int overlayColor, boolean readExistingColor) { - addVertexData(matrixEntry, bakedQuad, new float[]{1.0F, 1.0F, 1.0F, 1.0F}, red, green, blue, alpha, new int[]{lightmapCoord, lightmapCoord, lightmapCoord, lightmapCoord}, overlayColor, readExistingColor); + // Copy of putBulkData with alpha support + default void putBulkData(PoseStack.Pose matrixEntry, BakedQuad bakedQuad, float red, float green, float blue, float alpha, int lightmapCoord, int overlayColor, boolean readExistingColor) { + putBulkData(matrixEntry, bakedQuad, new float[]{1.0F, 1.0F, 1.0F, 1.0F}, red, green, blue, alpha, new int[]{lightmapCoord, lightmapCoord, lightmapCoord, lightmapCoord}, overlayColor, readExistingColor); } - // Copy of addQuad with alpha support - default void addVertexData(MatrixStack.Entry matrixEntry, BakedQuad bakedQuad, float[] baseBrightness, float red, float green, float blue, float alpha, int[] lightmapCoords, int overlayCoords, boolean readExistingColor) { + // Copy of putBulkData with alpha support + default void putBulkData(PoseStack.Pose matrixEntry, BakedQuad bakedQuad, float[] baseBrightness, float red, float green, float blue, float alpha, int[] lightmapCoords, int overlayCoords, boolean readExistingColor) { int[] aint = bakedQuad.getVertices(); - Vector3i faceNormal = bakedQuad.getDirection().getNormal(); + Vec3i faceNormal = bakedQuad.getDirection().getNormal(); Vector3f normal = new Vector3f((float)faceNormal.getX(), (float)faceNormal.getY(), (float)faceNormal.getZ()); Matrix4f matrix4f = matrixEntry.pose(); normal.transform(matrixEntry.normal()); - int intSize = DefaultVertexFormats.BLOCK.getIntegerSize(); + int intSize = DefaultVertexFormat.BLOCK.getIntegerSize(); int vertexCount = aint.length / intSize; try (MemoryStack memorystack = MemoryStack.stackPush()) { - ByteBuffer bytebuffer = memorystack.malloc(DefaultVertexFormats.BLOCK.getVertexSize()); + ByteBuffer bytebuffer = memorystack.malloc(DefaultVertexFormat.BLOCK.getVertexSize()); IntBuffer intbuffer = bytebuffer.asIntBuffer(); for(int v = 0; v < vertexCount; ++v) { @@ -99,7 +101,7 @@ public interface IForgeVertexBuilder Vector4f pos = new Vector4f(f, f1, f2, 1.0F); pos.transform(matrix4f); applyBakedNormals(normal, bytebuffer, matrixEntry.normal()); - ((IVertexBuilder)this).vertex(pos.x(), pos.y(), pos.z(), cr, cg, cb, ca, f9, f10, overlayCoords, lightmapCoord, normal.x(), normal.y(), normal.z()); + ((VertexConsumer)this).vertex(pos.x(), pos.y(), pos.z(), cr, cg, cb, ca, f9, f10, overlayCoords, lightmapCoord, normal.x(), normal.y(), normal.z()); } } } diff --git a/src/main/java/net/minecraftforge/client/gui/ForgeIngameGui.java b/src/main/java/net/minecraftforge/client/gui/ForgeIngameGui.java index 9885179d6f..92dad2d3f6 100644 --- a/src/main/java/net/minecraftforge/client/gui/ForgeIngameGui.java +++ b/src/main/java/net/minecraftforge/client/gui/ForgeIngameGui.java @@ -24,81 +24,314 @@ import static net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType import java.util.ArrayList; import java.util.List; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.AbstractGui; -import net.minecraft.client.gui.IngameGui; -import net.minecraft.client.gui.overlay.DebugOverlayGui; -import net.minecraft.client.network.play.ClientPlayNetHandler; -import net.minecraft.client.resources.I18n; -import net.minecraft.entity.Entity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.ai.attributes.Attributes; -import net.minecraft.entity.ai.attributes.ModifiableAttributeInstance; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.block.Blocks; -import net.minecraft.potion.Effects; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.scoreboard.ScoreObjective; -import net.minecraft.scoreboard.ScorePlayerTeam; -import net.minecraft.scoreboard.Scoreboard; +import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.GuiComponent; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.components.DebugScreenOverlay; +import net.minecraft.client.multiplayer.ClientPacketListener; +import net.minecraft.client.renderer.GameRenderer; +import net.minecraft.client.resources.language.I18n; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.ai.attributes.Attributes; +import net.minecraft.world.entity.ai.attributes.AttributeInstance; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.effect.MobEffects; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.scores.Objective; +import net.minecraft.world.scores.PlayerTeam; +import net.minecraft.world.scores.Scoreboard; import net.minecraft.tags.FluidTags; -import net.minecraft.util.FoodStats; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.StringUtils; -import net.minecraft.util.Util; -import net.minecraft.util.math.MathHelper; -import net.minecraft.world.GameType; +import net.minecraft.world.food.FoodData; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.StringUtil; +import net.minecraft.Util; +import net.minecraft.util.Mth; +import net.minecraft.world.level.GameType; +import net.minecraftforge.client.RenderProperties; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; import net.minecraftforge.common.MinecraftForge; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.lwjgl.opengl.GL11; import com.mojang.blaze3d.systems.RenderSystem; +import javax.annotation.Nullable; + @SuppressWarnings("deprecation") -public class ForgeIngameGui extends IngameGui +public class ForgeIngameGui extends Gui { - //private static final ResourceLocation VIGNETTE = new ResourceLocation("textures/misc/vignette.png"); - //private static final ResourceLocation WIDGITS = new ResourceLocation("textures/gui/widgets.png"); - //private static final ResourceLocation PUMPKIN_BLUR = new ResourceLocation("textures/misc/pumpkinblur.png"); + private static final Logger LOGGER = LogManager.getLogger(); private static final int WHITE = 0xFFFFFF; - //Flags to toggle the rendering of certain aspects of the HUD, valid conditions - //must be met for them to render normally. If those conditions are met, but this flag - //is false, they will not be rendered. - public static boolean renderVignette = true; - public static boolean renderHelmet = true; - public static boolean renderPortal = true; - public static boolean renderSpectatorTooltip = true; - public static boolean renderHotbar = true; - public static boolean renderCrosshairs = true; - public static boolean renderBossHealth = true; - public static boolean renderHealth = true; - public static boolean renderArmor = true; - public static boolean renderFood = true; - public static boolean renderHealthMount = true; - public static boolean renderAir = true; - public static boolean renderExperiance = true; - public static boolean renderJumpBar = true; - public static boolean renderObjective = true; - - public static int left_height = 39; - public static int right_height = 39; /* * If the Euclidian distance to the moused-over block in meters is less than this value, the "Looking at" text will appear on the debug overlay. */ public static double rayTraceDistance = 20.0D; - private FontRenderer fontrenderer = null; + public int left_height = 39; + public int right_height = 39; + + private Font fontrenderer = null; private RenderGameOverlayEvent eventParent; - //private static final String MC_VERSION = MinecraftForge.MC_VERSION; + private GuiOverlayDebugForge debugOverlay; + public void setupOverlayRenderState(boolean blend, boolean depthText) + { + setupOverlayRenderState(blend, depthText, Gui.GUI_ICONS_LOCATION); + } + + public void setupOverlayRenderState(boolean blend, boolean depthTest, @Nullable ResourceLocation texture) + { + if (blend) + { + RenderSystem.enableBlend(); + RenderSystem.defaultBlendFunc(); + } + else + { + RenderSystem.disableBlend(); + } + + if (depthTest) + { + RenderSystem.enableDepthTest(); + } + else + { + RenderSystem.disableDepthTest(); + } + + if (texture != null) + { + RenderSystem.enableTexture(); + bind(texture); + } + else + { + RenderSystem.disableTexture(); + } + + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); + RenderSystem.setShader(GameRenderer::getPositionTexShader); + } + + public static final IIngameOverlay VIGNETTE_ELEMENT = OverlayRegistry.registerOverlayTop("Vignette", (gui, mStack, partialTicks, screenWidth, screenHeight) -> { + if (Minecraft.useFancyGraphics()) + { + gui.setupOverlayRenderState(true, false); + gui.renderVignette(gui.minecraft.getCameraEntity()); + } + }); + + public static final IIngameOverlay SPYGLASS_ELEMENT = OverlayRegistry.registerOverlayTop("Spyglass", (gui, mStack, partialTicks, screenWidth, screenHeight) -> { + gui.setupOverlayRenderState(true, false); + gui.renderSpyglassOverlay(); + }); + + public static final IIngameOverlay HELMET_ELEMENT = OverlayRegistry.registerOverlayTop("Helmet", (gui, mStack, partialTicks, screenWidth, screenHeight) -> { + gui.setupOverlayRenderState(true, false); + gui.renderHelmet(partialTicks, mStack); + }); + + public static final IIngameOverlay FROSTBITE_ELEMENT = OverlayRegistry.registerOverlayTop("Frostbite", (gui, mStack, partialTicks, screenWidth, screenHeight) -> { + gui.setupOverlayRenderState(true, false); + gui.renderFrostbite(mStack); + }); + + public static final IIngameOverlay PORTAL_ELEMENT = OverlayRegistry.registerOverlayTop("Portal", (gui, mStack, partialTicks, screenWidth, screenHeight) -> { + + if (!gui.minecraft.player.hasEffect(MobEffects.CONFUSION)) + { + gui.setupOverlayRenderState(true, false); + gui.renderPortalOverlay(partialTicks); + } + + }); + + public static final IIngameOverlay HOTBAR_ELEMENT = OverlayRegistry.registerOverlayTop("Hotbar", (gui, mStack, partialTicks, screenWidth, screenHeight) -> { + if (!gui.minecraft.options.hideGui) + { + gui.setupOverlayRenderState(true, false); + if (gui.minecraft.gameMode.getPlayerMode() == GameType.SPECTATOR) + { + gui.spectatorGui.renderHotbar(mStack, partialTicks); + } + else + { + gui.renderHotbar(partialTicks, mStack); + } + } + }); + + public static final IIngameOverlay CROSSHAIR_ELEMENT = OverlayRegistry.registerOverlayTop("Crosshair", (gui, mStack, partialTicks, screenWidth, screenHeight) -> { + if (!gui.minecraft.options.hideGui) + { + gui.setupOverlayRenderState(true, false); + gui.setBlitOffset(-90); + + gui.renderCrosshair(mStack); + } + }); + + public static final IIngameOverlay BOSS_HEALTH_ELEMENT = OverlayRegistry.registerOverlayTop("Boss Health", (gui, mStack, partialTicks, screenWidth, screenHeight) -> { + if (!gui.minecraft.options.hideGui) + { + gui.setupOverlayRenderState(true, false); + gui.setBlitOffset(-90); + + gui.renderBossHealth(mStack); + } + }); + + public static final IIngameOverlay PLAYER_HEALTH_ELEMENT = OverlayRegistry.registerOverlayTop("Player Health", (gui, mStack, partialTicks, screenWidth, screenHeight) -> { + if (!gui.minecraft.options.hideGui && gui.shouldDrawSurvivalElements()) + { + gui.setupOverlayRenderState(true, false); + gui.renderHealth(screenWidth, screenHeight, mStack); + } + }); + + public static final IIngameOverlay ARMOR_LEVEL_ELEMENT = OverlayRegistry.registerOverlayTop("Armor Level",(gui, mStack, partialTicks, screenWidth, screenHeight) -> { + if (!gui.minecraft.options.hideGui && gui.shouldDrawSurvivalElements()) + { + gui.setupOverlayRenderState(true, false); + gui.renderArmor(mStack, screenWidth, screenHeight); + } + }); + + public static final IIngameOverlay FOOD_LEVEL_ELEMENT = OverlayRegistry.registerOverlayTop("Food Level", (gui, mStack, partialTicks, screenWidth, screenHeight) -> { + boolean isMounted = gui.minecraft.player.getVehicle() instanceof LivingEntity; + if (!isMounted && !gui.minecraft.options.hideGui && gui.shouldDrawSurvivalElements()) + { + gui.setupOverlayRenderState(true, false); + gui.renderFood(screenWidth, screenHeight, mStack); + } + }); + + public static final IIngameOverlay MOUNT_HEALTH_ELEMENT = OverlayRegistry.registerOverlayTop("Mount Health", (gui, mStack, partialTicks, screenWidth, screenHeight) -> { + if (!gui.minecraft.options.hideGui && gui.shouldDrawSurvivalElements()) + { + gui.setupOverlayRenderState(true, false); + gui.renderHealthMount(screenWidth, screenHeight, mStack); + } + }); + + public static final IIngameOverlay AIR_LEVEL_ELEMENT = OverlayRegistry.registerOverlayTop("Air Level", (gui, mStack, partialTicks, screenWidth, screenHeight) -> { + if (!gui.minecraft.options.hideGui && gui.shouldDrawSurvivalElements()) + { + gui.setupOverlayRenderState(true, false); + gui.renderAir(screenWidth, screenHeight, mStack); + } + }); + + public static final IIngameOverlay JUMP_BAR_ELEMENT = OverlayRegistry.registerOverlayTop("Jump Bar", (gui, mStack, partialTicks, screenWidth, screenHeight) -> { + if (gui.minecraft.player.isRidingJumpable() && !gui.minecraft.options.hideGui) + { + gui.setupOverlayRenderState(true, false); + gui.renderJumpMeter(mStack, screenWidth / 2 - 91); + } + }); + + public static final IIngameOverlay EXPERIENCE_BAR_ELEMENT = OverlayRegistry.registerOverlayTop("Experience Bar", (gui, mStack, partialTicks, screenWidth, screenHeight) -> { + if (!gui.minecraft.player.isRidingJumpable() && !gui.minecraft.options.hideGui) + { + gui.setupOverlayRenderState(true, false); + gui.renderExperience(screenWidth / 2 - 91, mStack); + } + }); + + public static final IIngameOverlay ITEM_NAME_ELEMENT = OverlayRegistry.registerOverlayTop("Item Name", (gui, mStack, partialTicks, screenWidth, screenHeight) -> { + if (!gui.minecraft.options.hideGui) + { + gui.setupOverlayRenderState(true, false); + if (gui.minecraft.options.heldItemTooltips && gui.minecraft.gameMode.getPlayerMode() != GameType.SPECTATOR) { + gui.renderSelectedItemName(mStack); + } else if (gui.minecraft.player.isSpectator()) { + gui.spectatorGui.renderTooltip(mStack); + } + } + }); + + public static final IIngameOverlay SLEEP_FADE_ELEMENT = OverlayRegistry.registerOverlayTop("Sleep Fade", (gui, mStack, partialTicks, screenWidth, screenHeight) -> { + gui.renderSleepFade(screenWidth, screenHeight, mStack); + }); + + public static final IIngameOverlay HUD_TEXT_ELEMENT = OverlayRegistry.registerOverlayTop("Text Columns", (gui, mStack, partialTicks, screenWidth, screenHeight) -> { + gui.renderHUDText(screenWidth, screenHeight, mStack); + }); + + public static final IIngameOverlay FPS_GRAPH_ELEMENT = OverlayRegistry.registerOverlayTop("FPS Graph", (gui, mStack, partialTicks, screenWidth, screenHeight) -> { + gui.renderFPSGraph(mStack); + }); + + public static final IIngameOverlay POTION_ICONS_ELEMENT = OverlayRegistry.registerOverlayTop("Potion Icons", (gui, mStack, partialTicks, screenWidth, screenHeight) -> { + gui.renderEffects(mStack); + }); + + public static final IIngameOverlay RECORD_OVERLAY_ELEMENT = OverlayRegistry.registerOverlayTop("Record", (gui, mStack, partialTicks, screenWidth, screenHeight) -> { + if (!gui.minecraft.options.hideGui) + { + gui.renderRecordOverlay(screenWidth, screenHeight, partialTicks, mStack); + } + }); + + public static final IIngameOverlay SUBTITLES_ELEMENT = OverlayRegistry.registerOverlayTop("Subtitles", (gui, mStack, partialTicks, screenWidth, screenHeight) -> { + if (!gui.minecraft.options.hideGui) + { + gui.renderSubtitles(mStack); + } + }); + + public static final IIngameOverlay TITLE_TEXT_ELEMENT = OverlayRegistry.registerOverlayTop("Title Text", (gui, mStack, partialTicks, screenWidth, screenHeight) -> { + if (!gui.minecraft.options.hideGui) + { + gui.renderTitle(screenWidth, screenHeight, partialTicks, mStack); + } + }); + + public static final IIngameOverlay SCOREBOARD_ELEMENT = OverlayRegistry.registerOverlayTop("Scoreboard", (gui, mStack, partialTicks, screenWidth, screenHeight) -> { + + Scoreboard scoreboard = gui.minecraft.level.getScoreboard(); + Objective objective = null; + PlayerTeam scoreplayerteam = scoreboard.getPlayersTeam(gui.minecraft.player.getScoreboardName()); + if (scoreplayerteam != null) + { + int slot = scoreplayerteam.getColor().getId(); + if (slot >= 0) objective = scoreboard.getDisplayObjective(3 + slot); + } + Objective scoreobjective1 = objective != null ? objective : scoreboard.getDisplayObjective(1); + if (scoreobjective1 != null) + { + gui.displayScoreboardSidebar(mStack, scoreobjective1); + } + }); + + public static final IIngameOverlay CHAT_PANEL_ELEMENT = OverlayRegistry.registerOverlayTop("Chat History", (gui, mStack, partialTicks, screenWidth, screenHeight) -> { + + RenderSystem.enableBlend(); + RenderSystem.blendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); + + gui.renderChat(screenWidth, screenHeight, mStack); + }); + + public static final IIngameOverlay PLAYER_LIST_ELEMENT = OverlayRegistry.registerOverlayTop("Player List", (gui, mStack, partialTicks, screenWidth, screenHeight) -> { + + RenderSystem.enableBlend(); + RenderSystem.blendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); + + gui.renderPlayerList(screenWidth, screenHeight, mStack); + }); + public ForgeIngameGui(Minecraft mc) { super(mc); @@ -106,202 +339,103 @@ public class ForgeIngameGui extends IngameGui } @Override - public void render(MatrixStack mStack, float partialTicks) + public void render(PoseStack pStack, float partialTicks) { this.screenWidth = this.minecraft.getWindow().getGuiScaledWidth(); this.screenHeight = this.minecraft.getWindow().getGuiScaledHeight(); - eventParent = new RenderGameOverlayEvent(mStack, partialTicks, this.minecraft.getWindow()); - renderHealthMount = minecraft.player.getVehicle() instanceof LivingEntity; - renderFood = !renderHealthMount; - renderJumpBar = minecraft.player.isRidingJumpable(); + eventParent = new RenderGameOverlayEvent(pStack, partialTicks, this.minecraft.getWindow()); right_height = 39; left_height = 39; - if (pre(ALL, mStack)) return; + if (pre(ALL, pStack)) return; fontrenderer = minecraft.font; - //mc.entityRenderer.setupOverlayRendering(); - RenderSystem.enableBlend(); - if (renderVignette && Minecraft.useFancyGraphics()) - { - renderVignette(minecraft.getCameraEntity()); - } - else - { - RenderSystem.enableDepthTest(); - RenderSystem.defaultBlendFunc(); - } - if (renderHelmet) renderHelmet(partialTicks, mStack); + this.random.setSeed(tickCount * 312871L); - if (renderPortal && !minecraft.player.hasEffect(Effects.CONFUSION)) - { - renderPortalOverlay(partialTicks); - } - - if (this.minecraft.gameMode.getPlayerMode() == GameType.SPECTATOR) - { - if (renderSpectatorTooltip) spectatorGui.renderHotbar(mStack, partialTicks); - } - else if (!this.minecraft.options.hideGui) - { - if (renderHotbar) renderHotbar(partialTicks, mStack); - } - - if (!this.minecraft.options.hideGui) { - RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); - setBlitOffset(-90); - random.setSeed((long)(tickCount * 312871)); - - if (renderCrosshairs) renderCrosshair(mStack); - if (renderBossHealth) renderBossHealth(mStack); - - RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); - if (this.minecraft.gameMode.canHurtPlayer() && this.minecraft.getCameraEntity() instanceof PlayerEntity) + OverlayRegistry.orderedEntries().forEach(entry -> { + try { - if (renderHealth) renderHealth(this.screenWidth, this.screenHeight, mStack); - if (renderArmor) renderArmor(mStack, this.screenWidth, this.screenHeight); - if (renderFood) renderFood(this.screenWidth, this.screenHeight, mStack); - if (renderHealthMount) renderHealthMount(this.screenWidth, this.screenHeight, mStack); - if (renderAir) renderAir(this.screenWidth, this.screenHeight, mStack); + if (!entry.isEnabled()) return; + IIngameOverlay overlay = entry.getOverlay(); + if (pre(overlay, pStack)) return; + overlay.render(this, pStack, partialTicks, screenWidth, screenHeight); + post(overlay, pStack); } - - if (renderJumpBar) + catch(Exception e) { - renderJumpMeter(mStack, this.screenWidth / 2 - 91); + LOGGER.error("Error rendering overlay '{}'", entry.getDisplayName(), e); } - else if (renderExperiance) - { - renderExperience(this.screenWidth / 2 - 91, mStack); - } - if (this.minecraft.options.heldItemTooltips && this.minecraft.gameMode.getPlayerMode() != GameType.SPECTATOR) { - this.renderSelectedItemName(mStack); - } else if (this.minecraft.player.isSpectator()) { - this.spectatorGui.renderTooltip(mStack); - } - } + }); - renderSleepFade(this.screenWidth, this.screenHeight, mStack); + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); - renderHUDText(this.screenWidth, this.screenHeight, mStack); - renderFPSGraph(mStack); - renderEffects(mStack); - if (!minecraft.options.hideGui) { - renderRecordOverlay(this.screenWidth, this.screenHeight, partialTicks, mStack); - renderSubtitles(mStack); - renderTitle(this.screenWidth, this.screenHeight, partialTicks, mStack); - } - - - Scoreboard scoreboard = this.minecraft.level.getScoreboard(); - ScoreObjective objective = null; - ScorePlayerTeam scoreplayerteam = scoreboard.getPlayersTeam(minecraft.player.getScoreboardName()); - if (scoreplayerteam != null) - { - int slot = scoreplayerteam.getColor().getId(); - if (slot >= 0) objective = scoreboard.getDisplayObjective(3 + slot); - } - ScoreObjective scoreobjective1 = objective != null ? objective : scoreboard.getDisplayObjective(1); - if (renderObjective && scoreobjective1 != null) - { - this.displayScoreboardSidebar(mStack, scoreobjective1); - } - - RenderSystem.enableBlend(); - RenderSystem.blendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); - RenderSystem.disableAlphaTest(); - - renderChat(this.screenWidth, this.screenHeight, mStack); - - renderPlayerList(this.screenWidth, this.screenHeight, mStack); - - RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); - RenderSystem.enableAlphaTest(); - - post(ALL, mStack); + post(ALL, pStack); } - @Override - protected void renderCrosshair(MatrixStack mStack) + public boolean shouldDrawSurvivalElements() { - if (pre(CROSSHAIRS, mStack)) return; - bind(AbstractGui.GUI_ICONS_LOCATION); - RenderSystem.enableBlend(); - RenderSystem.enableAlphaTest(); - super.renderCrosshair(mStack); - post(CROSSHAIRS, mStack); + return minecraft.gameMode.canHurtPlayer() && minecraft.getCameraEntity() instanceof Player; } - @Override - protected void renderEffects(MatrixStack mStack) + protected void renderSubtitles(PoseStack mStack) { - if (pre(POTION_ICONS, mStack)) return; - super.renderEffects(mStack); - post(POTION_ICONS, mStack); - } - - protected void renderSubtitles(MatrixStack mStack) - { - if (pre(SUBTITLES, mStack)) return; this.subtitleOverlay.render(mStack); - post(SUBTITLES, mStack); } - protected void renderBossHealth(MatrixStack mStack) + protected void renderBossHealth(PoseStack mStack) { - if (pre(BOSSHEALTH, mStack)) return; - bind(AbstractGui.GUI_ICONS_LOCATION); + bind(GuiComponent.GUI_ICONS_LOCATION); RenderSystem.defaultBlendFunc(); minecraft.getProfiler().push("bossHealth"); - RenderSystem.enableBlend(); this.bossOverlay.render(mStack); - RenderSystem.disableBlend(); minecraft.getProfiler().pop(); - post(BOSSHEALTH, mStack); } - @Override - protected void renderVignette(Entity entity) + private void renderSpyglassOverlay() { - MatrixStack mStack = new MatrixStack(); - if (pre(VIGNETTE, mStack)) + float deltaFrame = this.minecraft.getDeltaFrameTime(); + this.scopeScale = Mth.lerp(0.5F * deltaFrame, this.scopeScale, 1.125F); + if (this.minecraft.options.getCameraType().isFirstPerson()) { - // Need to put this here, since Vanilla assumes this state after the vignette was rendered. - RenderSystem.enableDepthTest(); - RenderSystem.defaultBlendFunc(); - return; + if (this.minecraft.player.isScoping()) + { + this.renderSpyglassOverlay(this.scopeScale); + } else + { + this.scopeScale = 0.5F; + } } - super.renderVignette(entity); - post(VIGNETTE, mStack); } - - private void renderHelmet(float partialTicks, MatrixStack mStack) + private void renderHelmet(float partialTicks, PoseStack mStack) { - if (pre(HELMET, mStack)) return; - - ItemStack itemstack = this.minecraft.player.inventory.getArmor(3); + ItemStack itemstack = this.minecraft.player.getInventory().getArmor(3); if (this.minecraft.options.getCameraType().isFirstPerson() && !itemstack.isEmpty()) { Item item = itemstack.getItem(); if (item == Blocks.CARVED_PUMPKIN.asItem()) { - renderPumpkin(); + renderTextureOverlay(PUMPKIN_BLUR_LOCATION, 1.0F); } else { - item.renderHelmetOverlay(itemstack, minecraft.player, this.screenWidth, this.screenHeight, partialTicks); + RenderProperties.get(item).renderHelmetOverlay(itemstack, minecraft.player, this.screenWidth, this.screenHeight, partialTicks); } } - - post(HELMET, mStack); } - protected void renderArmor(MatrixStack mStack, int width, int height) + private void renderFrostbite(PoseStack pStack) + { + if (this.minecraft.player.getTicksFrozen() > 0) { + this.renderTextureOverlay(POWDER_SNOW_OUTLINE_LOCATION, this.minecraft.player.getPercentFrozen()); + } + } + + protected void renderArmor(PoseStack mStack, int width, int height) { - if (pre(ARMOR, mStack)) return; minecraft.getProfiler().push("armor"); RenderSystem.enableBlend(); @@ -329,47 +463,23 @@ public class ForgeIngameGui extends IngameGui RenderSystem.disableBlend(); minecraft.getProfiler().pop(); - post(ARMOR, mStack); } @Override protected void renderPortalOverlay(float partialTicks) { - MatrixStack mStack = new MatrixStack(); - if (pre(PORTAL, mStack)) return; - - float f1 = minecraft.player.oPortalTime + (minecraft.player.portalTime - minecraft.player.oPortalTime) * partialTicks; + float f1 = Mth.lerp(partialTicks, this.minecraft.player.oPortalTime, this.minecraft.player.portalTime); if (f1 > 0.0F) { super.renderPortalOverlay(f1); } - - post(PORTAL, mStack); } - @Override - protected void renderHotbar(float partialTicks, MatrixStack mStack) + protected void renderAir(int width, int height, PoseStack mStack) { - if (pre(HOTBAR, mStack)) return; - - if (minecraft.gameMode.getPlayerMode() == GameType.SPECTATOR) - { - this.spectatorGui.renderHotbar(mStack, partialTicks); - } - else - { - super.renderHotbar(partialTicks, mStack); - } - - post(HOTBAR, mStack); - } - - protected void renderAir(int width, int height, MatrixStack mStack) - { - if (pre(AIR, mStack)) return; minecraft.getProfiler().push("air"); - PlayerEntity player = (PlayerEntity)this.minecraft.getCameraEntity(); + Player player = (Player)this.minecraft.getCameraEntity(); RenderSystem.enableBlend(); int left = width / 2 + 91; int top = height - right_height; @@ -377,8 +487,8 @@ public class ForgeIngameGui extends IngameGui int air = player.getAirSupply(); if (player.isEyeInFluid(FluidTags.WATER) || air < 300) { - int full = MathHelper.ceil((double)(air - 2) * 10.0D / 300.0D); - int partial = MathHelper.ceil((double)air * 10.0D / 300.0D) - full; + 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) { @@ -389,18 +499,16 @@ public class ForgeIngameGui extends IngameGui RenderSystem.disableBlend(); minecraft.getProfiler().pop(); - post(AIR, mStack); } - public void renderHealth(int width, int height, MatrixStack mStack) + public void renderHealth(int width, int height, PoseStack pStack) { bind(GUI_ICONS_LOCATION); - if (pre(HEALTH, mStack)) return; minecraft.getProfiler().push("health"); RenderSystem.enableBlend(); - PlayerEntity player = (PlayerEntity)this.minecraft.getCameraEntity(); - int health = MathHelper.ceil(player.getHealth()); + Player player = (Player)this.minecraft.getCameraEntity(); + int health = Mth.ceil(player.getHealth()); boolean highlight = healthBlinkTime > (long)tickCount && (healthBlinkTime - (long)tickCount) / 3L %2L == 1L; if (health < this.lastHealth && player.invulnerableTime > 0) @@ -424,11 +532,11 @@ public class ForgeIngameGui extends IngameGui this.lastHealth = health; int healthLast = this.displayHealth; - ModifiableAttributeInstance attrMaxHealth = player.getAttribute(Attributes.MAX_HEALTH); - float healthMax = (float)attrMaxHealth.getValue(); - float absorb = MathHelper.ceil(player.getAbsorptionAmount()); + AttributeInstance attrMaxHealth = player.getAttribute(Attributes.MAX_HEALTH); + float healthMax = Math.max((float)attrMaxHealth.getValue(), Math.max(healthLast, health)); + int absorb = Mth.ceil(player.getAbsorptionAmount()); - int healthRows = MathHelper.ceil((healthMax + absorb) / 2.0F / 10.0F); + int healthRows = Mth.ceil((healthMax + absorb) / 2.0F / 10.0F); int rowHeight = Math.max(10 - (healthRows - 2), 3); this.random.setSeed((long)(tickCount * 312871)); @@ -439,78 +547,29 @@ public class ForgeIngameGui extends IngameGui if (rowHeight != 10) left_height += 10 - rowHeight; int regen = -1; - if (player.hasEffect(Effects.REGENERATION)) + if (player.hasEffect(MobEffects.REGENERATION)) { - regen = tickCount % 25; + regen = this.tickCount % Mth.ceil(healthMax + 5.0F); } - final int TOP = 9 * (minecraft.level.getLevelData().isHardcore() ? 5 : 0); - final int BACKGROUND = (highlight ? 25 : 16); - int MARGIN = 16; - if (player.hasEffect(Effects.POISON)) MARGIN += 36; - else if (player.hasEffect(Effects.WITHER)) MARGIN += 72; - float absorbRemaining = absorb; - - for (int i = MathHelper.ceil((healthMax + absorb) / 2.0F) - 1; i >= 0; --i) - { - //int b0 = (highlight ? 1 : 0); - int row = MathHelper.ceil((float)(i + 1) / 10.0F) - 1; - int x = left + i % 10 * 8; - int y = top - row * rowHeight; - - if (health <= 4) y += random.nextInt(2); - if (i == regen) y -= 2; - - blit(mStack, x, y, BACKGROUND, TOP, 9, 9); - - if (highlight) - { - if (i * 2 + 1 < healthLast) - blit(mStack, x, y, MARGIN + 54, TOP, 9, 9); //6 - else if (i * 2 + 1 == healthLast) - blit(mStack, x, y, MARGIN + 63, TOP, 9, 9); //7 - } - - if (absorbRemaining > 0.0F) - { - if (absorbRemaining == absorb && absorb % 2.0F == 1.0F) - { - blit(mStack, x, y, MARGIN + 153, TOP, 9, 9); //17 - absorbRemaining -= 1.0F; - } - else - { - blit(mStack, x, y, MARGIN + 144, TOP, 9, 9); //16 - absorbRemaining -= 2.0F; - } - } - else - { - if (i * 2 + 1 < health) - blit(mStack, x, y, MARGIN + 36, TOP, 9, 9); //4 - else if (i * 2 + 1 == health) - blit(mStack, x, y, MARGIN + 45, TOP, 9, 9); //5 - } - } + this.renderHearts(pStack, player, left, top, rowHeight, regen, healthMax, health, healthLast, absorb, highlight); RenderSystem.disableBlend(); minecraft.getProfiler().pop(); - post(HEALTH, mStack); } - public void renderFood(int width, int height, MatrixStack mStack) + public void renderFood(int width, int height, PoseStack mStack) { - if (pre(FOOD, mStack)) return; minecraft.getProfiler().push("food"); - PlayerEntity player = (PlayerEntity)this.minecraft.getCameraEntity(); + Player player = (Player)this.minecraft.getCameraEntity(); RenderSystem.enableBlend(); int left = width / 2 + 91; int top = height - right_height; right_height += 10; boolean unused = false;// Unused flag in vanilla, seems to be part of a 'fade out' mechanic - FoodStats stats = minecraft.player.getFoodData(); + FoodData stats = minecraft.player.getFoodData(); int level = stats.getFoodLevel(); for (int i = 0; i < 10; ++i) @@ -521,7 +580,7 @@ public class ForgeIngameGui extends IngameGui int icon = 16; byte background = 0; - if (minecraft.player.hasEffect(Effects.HUNGER)) + if (minecraft.player.hasEffect(MobEffects.HUNGER)) { icon += 36; background = 13; @@ -542,16 +601,15 @@ public class ForgeIngameGui extends IngameGui } RenderSystem.disableBlend(); minecraft.getProfiler().pop(); - post(FOOD, mStack); } - protected void renderSleepFade(int width, int height, MatrixStack mStack) + protected void renderSleepFade(int width, int height, PoseStack mStack) { if (minecraft.player.getSleepTimer() > 0) { minecraft.getProfiler().push("sleep"); RenderSystem.disableDepthTest(); - RenderSystem.disableAlphaTest(); + // RenderSystem.disableAlphaTest(); int sleepTime = minecraft.player.getSleepTimer(); float opacity = (float)sleepTime / 100.0F; @@ -562,17 +620,16 @@ public class ForgeIngameGui extends IngameGui int color = (int)(220.0F * opacity) << 24 | 1052704; fill(mStack, 0, 0, width, height, color); - RenderSystem.enableAlphaTest(); + // RenderSystem.enableAlphaTest(); RenderSystem.enableDepthTest(); minecraft.getProfiler().pop(); } } - protected void renderExperience(int x, MatrixStack mStack) + protected void renderExperience(int x, PoseStack mStack) { bind(GUI_ICONS_LOCATION); - if (pre(EXPERIENCE, mStack)) return; - RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.disableBlend(); if (minecraft.gameMode.hasExperience()) @@ -580,16 +637,13 @@ public class ForgeIngameGui extends IngameGui super.renderExperienceBar(mStack, x); } RenderSystem.enableBlend(); - RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); - - post(EXPERIENCE, mStack); + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); } @Override - public void renderJumpMeter(MatrixStack mStack, int x) + public void renderJumpMeter(PoseStack mStack, int x) { bind(GUI_ICONS_LOCATION); - if (pre(JUMPBAR, mStack)) return; GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.disableBlend(); @@ -598,11 +652,9 @@ public class ForgeIngameGui extends IngameGui RenderSystem.enableBlend(); minecraft.getProfiler().pop(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - - post(JUMPBAR, mStack); } - protected void renderHUDText(int width, int height, MatrixStack mStack) + protected void renderHUDText(int width, int height, PoseStack mStack) { minecraft.getProfiler().push("forgeHudText"); RenderSystem.defaultBlendFunc(); @@ -618,7 +670,7 @@ public class ForgeIngameGui extends IngameGui } else { - listR.add(I18n.get("demo.remainingTime", StringUtils.formatTickDuration((int)(120500L - time)))); + listR.add(I18n.get("demo.remainingTime", StringUtil.formatTickDuration((int)(120500L - time)))); } } @@ -658,16 +710,15 @@ public class ForgeIngameGui extends IngameGui post(TEXT, mStack); } - protected void renderFPSGraph(MatrixStack mStack) + protected void renderFPSGraph(PoseStack mStack) { - if (this.minecraft.options.renderDebug && this.minecraft.options.renderFpsChart && !pre(FPS_GRAPH, mStack)) + if (this.minecraft.options.renderDebug && this.minecraft.options.renderFpsChart) { this.debugOverlay.render(mStack); - post(FPS_GRAPH, mStack); } } - protected void renderRecordOverlay(int width, int height, float partialTicks, MatrixStack mStack) + protected void renderRecordOverlay(int width, int height, float partialTicks, PoseStack pStack) { if (overlayMessageTime > 0) { @@ -678,22 +729,22 @@ public class ForgeIngameGui extends IngameGui if (opacity > 8) { - RenderSystem.pushMatrix(); - RenderSystem.translatef((float)(width / 2), (float)(height - 68), 0.0F); + pStack.pushPose(); + pStack.translate(width / 2D, height - 68, 0.0D); RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); - int color = (animateOverlayMessageColor ? MathHelper.hsvToRgb(hue / 50.0F, 0.7F, 0.6F) & WHITE : WHITE); - drawBackdrop(mStack, fontrenderer, -4, fontrenderer.width(overlayMessageString), 16777215 | (opacity << 24)); - fontrenderer.draw(mStack, overlayMessageString.getVisualOrderText(), -fontrenderer.width(overlayMessageString) / 2, -4, color | (opacity << 24)); + int color = (animateOverlayMessageColor ? Mth.hsvToRgb(hue / 50.0F, 0.7F, 0.6F) & WHITE : WHITE); + drawBackdrop(pStack, fontrenderer, -4, fontrenderer.width(overlayMessageString), 16777215 | (opacity << 24)); + fontrenderer.draw(pStack, overlayMessageString.getVisualOrderText(), -fontrenderer.width(overlayMessageString) / 2, -4, color | (opacity << 24)); RenderSystem.disableBlend(); - RenderSystem.popMatrix(); + pStack.popPose(); } minecraft.getProfiler().pop(); } } - protected void renderTitle(int width, int height, float partialTicks, MatrixStack mStack) + protected void renderTitle(int width, int height, float partialTicks, PoseStack pStack) { if (title != null && titleTime > 0) { @@ -708,55 +759,55 @@ public class ForgeIngameGui extends IngameGui } if (titleTime <= titleFadeOutTime) opacity = (int)(age * 255.0F / (float)this.titleFadeOutTime); - opacity = MathHelper.clamp(opacity, 0, 255); + opacity = Mth.clamp(opacity, 0, 255); if (opacity > 8) { - RenderSystem.pushMatrix(); - RenderSystem.translatef((float)(width / 2), (float)(height / 2), 0.0F); + pStack.pushPose(); + pStack.translate(width / 2D, height / 2D, 0.0D); RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); - RenderSystem.pushMatrix(); - RenderSystem.scalef(4.0F, 4.0F, 4.0F); + pStack.pushPose(); + pStack.scale(4.0F, 4.0F, 4.0F); int l = opacity << 24 & -16777216; - this.getFont().drawShadow(mStack, this.title.getVisualOrderText(), (float)(-this.getFont().width(this.title) / 2), -10.0F, 16777215 | l); - RenderSystem.popMatrix(); + this.getFont().drawShadow(pStack, this.title.getVisualOrderText(), (float)(-this.getFont().width(this.title) / 2), -10.0F, 16777215 | l); + pStack.popPose(); if (this.subtitle != null) { - RenderSystem.pushMatrix(); - RenderSystem.scalef(2.0F, 2.0F, 2.0F); - this.getFont().drawShadow(mStack, this.subtitle.getVisualOrderText(), (float)(-this.getFont().width(this.subtitle) / 2), 5.0F, 16777215 | l); - RenderSystem.popMatrix(); + pStack.pushPose(); + pStack.scale(2.0F, 2.0F, 2.0F); + this.getFont().drawShadow(pStack, this.subtitle.getVisualOrderText(), (float)(-this.getFont().width(this.subtitle) / 2), 5.0F, 16777215 | l); + pStack.popPose(); } RenderSystem.disableBlend(); - RenderSystem.popMatrix(); + pStack.popPose(); } this.minecraft.getProfiler().pop(); } } - protected void renderChat(int width, int height, MatrixStack mStack) + protected void renderChat(int width, int height, PoseStack pStack) { minecraft.getProfiler().push("chat"); - RenderGameOverlayEvent.Chat event = new RenderGameOverlayEvent.Chat(mStack, eventParent, 0, height - 48); + RenderGameOverlayEvent.Chat event = new RenderGameOverlayEvent.Chat(pStack, eventParent, 0, height - 48); if (MinecraftForge.EVENT_BUS.post(event)) return; - RenderSystem.pushMatrix(); - RenderSystem.translatef((float) event.getPosX(), (float) event.getPosY(), 0.0F); - chat.render(mStack, tickCount); - RenderSystem.popMatrix(); + pStack.pushPose(); + pStack.translate(event.getPosX(), event.getPosY(), 0.0D); + chat.render(pStack, tickCount); + pStack.popPose(); - post(CHAT, mStack); + post(CHAT, pStack); minecraft.getProfiler().pop(); } - protected void renderPlayerList(int width, int height, MatrixStack mStack) + protected void renderPlayerList(int width, int height, PoseStack mStack) { - ScoreObjective scoreobjective = this.minecraft.level.getScoreboard().getDisplayObjective(0); - ClientPlayNetHandler handler = minecraft.player.connection; + Objective scoreobjective = this.minecraft.level.getScoreboard().getDisplayObjective(0); + ClientPacketListener handler = minecraft.player.connection; if (minecraft.options.keyPlayerList.isDown() && (!minecraft.isLocalServer() || handler.getOnlinePlayers().size() > 1 || scoreobjective != null)) { @@ -771,16 +822,14 @@ public class ForgeIngameGui extends IngameGui } } - protected void renderHealthMount(int width, int height, MatrixStack mStack) + protected void renderHealthMount(int width, int height, PoseStack mStack) { - PlayerEntity player = (PlayerEntity)minecraft.getCameraEntity(); + Player player = (Player)minecraft.getCameraEntity(); Entity tmp = player.getVehicle(); if (!(tmp instanceof LivingEntity)) return; bind(GUI_ICONS_LOCATION); - if (pre(HEALTHMOUNT, mStack)) return; - boolean unused = false; int left_align = width / 2 + 91; @@ -819,24 +868,31 @@ public class ForgeIngameGui extends IngameGui right_height += 10; } RenderSystem.disableBlend(); - post(HEALTHMOUNT, mStack); } //Helper macros - private boolean pre(ElementType type, MatrixStack mStack) + private boolean pre(ElementType type, PoseStack mStack) { return MinecraftForge.EVENT_BUS.post(new RenderGameOverlayEvent.Pre(mStack, eventParent, type)); } - private void post(ElementType type, MatrixStack mStack) + private void post(ElementType type, PoseStack mStack) { MinecraftForge.EVENT_BUS.post(new RenderGameOverlayEvent.Post(mStack, eventParent, type)); } + private boolean pre(IIngameOverlay overlay, PoseStack mStack) + { + return MinecraftForge.EVENT_BUS.post(new RenderGameOverlayEvent.PreLayer(mStack, eventParent, overlay)); + } + private void post(IIngameOverlay overlay, PoseStack mStack) + { + MinecraftForge.EVENT_BUS.post(new RenderGameOverlayEvent.PostLayer(mStack, eventParent, overlay)); + } private void bind(ResourceLocation res) { - minecraft.getTextureManager().bind(res); + RenderSystem.setShaderTexture(0, res); } - private class GuiOverlayDebugForge extends DebugOverlayGui + private class GuiOverlayDebugForge extends DebugScreenOverlay { private Minecraft mc; private GuiOverlayDebugForge(Minecraft mc) @@ -850,8 +906,8 @@ public class ForgeIngameGui extends IngameGui this.block = entity.pick(rayTraceDistance, 0.0F, false); this.liquid = entity.pick(rayTraceDistance, 0.0F, true); } - @Override protected void drawGameInformation(MatrixStack mStack){} - @Override protected void drawSystemInformation(MatrixStack mStack){} + @Override protected void drawGameInformation(PoseStack mStack){} + @Override protected void drawSystemInformation(PoseStack mStack){} private List getLeft() { List ret = this.getGameInformation(); diff --git a/src/main/java/net/minecraftforge/client/WeatherRenderHandler.java b/src/main/java/net/minecraftforge/client/gui/IIngameOverlay.java similarity index 77% rename from src/main/java/net/minecraftforge/client/WeatherRenderHandler.java rename to src/main/java/net/minecraftforge/client/gui/IIngameOverlay.java index bf10cbeef0..f4dab75b87 100644 --- a/src/main/java/net/minecraftforge/client/WeatherRenderHandler.java +++ b/src/main/java/net/minecraftforge/client/gui/IIngameOverlay.java @@ -17,13 +17,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.client; +package net.minecraftforge.client.gui; -/** - * Use {@link IWeatherRenderHandler} instead. - * - * todo: remove in 1.17 - */ -@Deprecated -public interface WeatherRenderHandler extends IRenderHandler { -} \ No newline at end of file +import com.mojang.blaze3d.vertex.PoseStack; + +public interface IIngameOverlay +{ + void render(ForgeIngameGui gui, PoseStack mStack, float partialTicks, int width, int height); +} diff --git a/src/main/java/net/minecraftforge/client/gui/NotificationModUpdateScreen.java b/src/main/java/net/minecraftforge/client/gui/NotificationModUpdateScreen.java index 8417755c81..1f89813639 100644 --- a/src/main/java/net/minecraftforge/client/gui/NotificationModUpdateScreen.java +++ b/src/main/java/net/minecraftforge/client/gui/NotificationModUpdateScreen.java @@ -19,20 +19,19 @@ package net.minecraftforge.client.gui; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.systems.RenderSystem; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.widget.button.Button; -import net.minecraft.client.gui.screen.MainMenuScreen; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.client.gui.components.Button; +import net.minecraft.client.gui.screens.TitleScreen; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.network.chat.TranslatableComponent; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.loading.FMLConfig; import net.minecraftforge.versions.forge.ForgeVersion; import net.minecraftforge.fml.VersionChecker; -import net.minecraftforge.fml.client.ClientModLoader; +import net.minecraftforge.fmlclient.ClientModLoader; import net.minecraftforge.api.distmarker.Dist; @OnlyIn(Dist.CLIENT) @@ -47,7 +46,7 @@ public class NotificationModUpdateScreen extends Screen public NotificationModUpdateScreen(Button modButton) { - super(new TranslationTextComponent("forge.menu.updatescreen.title")); + super(new TranslatableComponent("forge.menu.updatescreen.title")); this.modButton = modButton; } @@ -66,15 +65,14 @@ public class NotificationModUpdateScreen extends Screen @SuppressWarnings("deprecation") @Override - public void render(MatrixStack mStack, int mouseX, int mouseY, float partialTicks) + public void render(PoseStack mStack, int mouseX, int mouseY, float partialTicks) { if (showNotification == null || !showNotification.shouldDraw() || !FMLConfig.runVersionCheck()) { return; } - Minecraft.getInstance().getTextureManager().bind(VERSION_CHECK_ICONS); - RenderSystem.color4f(1, 1, 1, 1); + RenderSystem.setShaderTexture(0, VERSION_CHECK_ICONS); int x = modButton.x; int y = modButton.y; @@ -84,7 +82,7 @@ public class NotificationModUpdateScreen extends Screen blit(mStack, x + w - (h / 2 + 4), y + (h / 2 - 4), showNotification.getSheetOffset() * 8, (showNotification.isAnimated() && ((System.currentTimeMillis() / 800 & 1) == 1)) ? 8 : 0, 8, 8, 64, 16); } - public static NotificationModUpdateScreen init(MainMenuScreen guiMainMenu, Button modButton) + public static NotificationModUpdateScreen init(TitleScreen guiMainMenu, Button modButton) { NotificationModUpdateScreen notificationModUpdateScreen = new NotificationModUpdateScreen(modButton); notificationModUpdateScreen.resize(guiMainMenu.getMinecraft(), guiMainMenu.width, guiMainMenu.height); diff --git a/src/main/java/net/minecraftforge/client/gui/OverlayRegistry.java b/src/main/java/net/minecraftforge/client/gui/OverlayRegistry.java new file mode 100644 index 0000000000..5e253f2a00 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/gui/OverlayRegistry.java @@ -0,0 +1,200 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.client.gui; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +public class OverlayRegistry +{ + /** + * Adds a new overlay entry to the registry, placed at the beginning of the list. + * Call from {@link net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent}. No need for enqueueWork. + * @param displayName A string for debug purposes, used primarily in exception traces coming from the overlays. + * @param overlay An instance, lambda or method reference for the logic used in rendering the overlay. + * @return The same object passed into the {@code overlay} parameter. + */ + public static synchronized IIngameOverlay registerOverlayBottom(@Nonnull String displayName, @Nonnull IIngameOverlay overlay) + { + return registerOverlay(-1, null, displayName, overlay); + } + + /** + * Adds a new overlay entry to the registry, placed before the {@code other} parameter in the list. + * Call from {@link net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent}. No need for enqueueWork. + * @param other The overlay to insert before. The overlay must be registered. + * @param displayName A string for debug purposes, used primarily in exception traces coming from the overlays. + * @param overlay An instance, lambda or method reference for the logic used in rendering the overlay. + * @return The same object passed into the {@code overlay} parameter. + */ + public static synchronized IIngameOverlay registerOverlayBelow(@Nonnull IIngameOverlay other, @Nonnull String displayName, @Nonnull IIngameOverlay overlay) + { + return registerOverlay(-1, other, displayName, overlay); + } + + /** + * Adds a new overlay entry to the registry, placed after the {@code other} parameter in the list. + * Call from {@link net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent}. No need for enqueueWork. + * @param other The overlay to insert after. The overlay must be registered. + * @param displayName A string for debug purposes, used primarily in exception traces coming from the overlays. + * @param overlay An instance, lambda or method reference for the logic used in rendering the overlay. + * @return The same object passed into the {@code overlay} parameter. + */ + public static synchronized IIngameOverlay registerOverlayAbove(@Nonnull IIngameOverlay other, @Nonnull String displayName, @Nonnull IIngameOverlay overlay) + { + return registerOverlay(1, other, displayName, overlay); + } + + /** + * Adds a new overlay entry to the registry, placed at the end of the list. + * Call from {@link net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent}. No need for enqueueWork. + * @param displayName A string for debug purposes, used primarily in exception traces coming from the overlays. + * @param overlay An instance, lambda or method reference for the logic used in rendering the overlay. + * @return The same object passed into the {@code overlay} parameter. + */ + public static synchronized IIngameOverlay registerOverlayTop(@Nonnull String displayName, @Nonnull IIngameOverlay overlay) + { + return registerOverlay(1, null, displayName, overlay); + } + + private static IIngameOverlay registerOverlay(int sort, @Nullable IIngameOverlay other, @Nonnull String displayName, @Nonnull IIngameOverlay overlay) + { + OverlayEntry entry = overlays.get(overlay); + + if (entry != null) + { + overlaysOrdered.remove(entry); + } + + int insertAt = overlays.size(); + if (other == null) + { + if (sort < 0) + insertAt = 0; + } + else + { + for (int i = 0; i < overlaysOrdered.size(); i++) + { + OverlayEntry ov = overlaysOrdered.get(i); + if (ov.getOverlay() == other) + { + if (sort < 0) insertAt = i; + else insertAt = i+1; + break; + } + } + } + + entry = new OverlayEntry(overlay, displayName); + + overlaysOrdered.add(insertAt, entry); + overlays.put(overlay, entry); + + return overlay; + } + + /** + * Enables or disables an overlay. This is preferred over removing overlays. + * @param overlay The overlay object to enable or disable + * @param enable The new state + */ + public static synchronized void enableOverlay(@Nonnull IIngameOverlay overlay, boolean enable) + { + OverlayEntry entry = overlays.get(overlay); + if (entry != null) + { + entry.setEnabled(enable); + } + } + + /** + * Returns the information on a registered overlay. + * @param overlay The overlay to obtain the information for. + * @return The registration entry for this overlay. + */ + @Nullable + public static synchronized OverlayEntry getEntry(@Nonnull IIngameOverlay overlay) + { + return overlays.get(overlay); + } + + /** + * @return Returns an unmodifiable view of the ordered list of entries. + */ + public static List orderedEntries() + { + return Collections.unmodifiableList(overlaysOrdered); + } + + private static final Map overlays = Maps.newHashMap(); + private static final List overlaysOrdered = Lists.newArrayList(); + + public static class OverlayEntry { + private final IIngameOverlay overlay; + private final String displayName; + private boolean enabled = true; + + public OverlayEntry(IIngameOverlay overlay, String displayName) + { + this.overlay = overlay; + this.displayName = displayName; + } + + /** + * @return Returns the overlay renderer. + */ + public IIngameOverlay getOverlay() + { + return overlay; + } + + /** + * @return Returns the debug name for this entry. + */ + public String getDisplayName() + { + return displayName; + } + + /** + * @return Returns true if the entry will be rendered. + */ + public boolean isEnabled() + { + return enabled; + } + + /** + * For internal use. Call via {@link #enableOverlay(IIngameOverlay, boolean)}. + */ + private void setEnabled(boolean enabled) + { + this.enabled = enabled; + } + } + +} diff --git a/src/main/java/net/minecraftforge/client/gui/ScrollPanel.java b/src/main/java/net/minecraftforge/client/gui/ScrollPanel.java index 7e5b7122e7..731b162201 100644 --- a/src/main/java/net/minecraftforge/client/gui/ScrollPanel.java +++ b/src/main/java/net/minecraftforge/client/gui/ScrollPanel.java @@ -22,22 +22,20 @@ package net.minecraftforge.client.gui; import java.util.Collections; import java.util.List; +import com.mojang.blaze3d.vertex.*; +import net.minecraft.client.renderer.GameRenderer; import org.lwjgl.opengl.GL11; -import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.AbstractGui; -import net.minecraft.client.gui.FocusableGui; -import net.minecraft.client.gui.IGuiEventListener; -import net.minecraft.client.gui.IRenderable; -import net.minecraft.client.renderer.BufferBuilder; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraftforge.fml.client.gui.GuiUtils; +import net.minecraft.client.gui.GuiComponent; +import net.minecraft.client.gui.components.events.AbstractContainerEventHandler; +import net.minecraft.client.gui.components.events.GuiEventListener; +import net.minecraft.client.gui.components.Widget; +import net.minecraftforge.fmlclient.gui.GuiUtils; -public abstract class ScrollPanel extends FocusableGui implements IRenderable +public abstract class ScrollPanel extends AbstractContainerEventHandler implements Widget { private final Minecraft client; protected final int width; @@ -76,7 +74,7 @@ public abstract class ScrollPanel extends FocusableGui implements IRenderable * @param mouseY * @param mouseX */ - protected abstract void drawPanel(MatrixStack mStack, int entryRight, int relativeY, Tessellator tess, int mouseX, int mouseY); + protected abstract void drawPanel(PoseStack mStack, int entryRight, int relativeY, Tesselator tess, int mouseX, int mouseY); protected boolean clickPanel(double mouseX, double mouseY, int button) { return false; } @@ -184,11 +182,11 @@ public abstract class ScrollPanel extends FocusableGui implements IRenderable @SuppressWarnings("deprecation") @Override - public void render(MatrixStack matrix, int mouseX, int mouseY, float partialTicks) + public void render(PoseStack matrix, int mouseX, int mouseY, float partialTicks) { this.drawBackground(); - Tessellator tess = Tessellator.getInstance(); + Tesselator tess = Tesselator.getInstance(); BufferBuilder worldr = tess.getBuilder(); double scale = client.getWindow().getGuiScale(); @@ -202,12 +200,10 @@ public abstract class ScrollPanel extends FocusableGui implements IRenderable } else // Draw dark dirt background { - RenderSystem.disableLighting(); - RenderSystem.disableFog(); - this.client.getTextureManager().bind(AbstractGui.BACKGROUND_LOCATION); - RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); + RenderSystem.setShader(GameRenderer::getPositionTexColorShader); + RenderSystem.setShaderTexture(0, GuiComponent.BACKGROUND_LOCATION); final float texScale = 32.0F; - worldr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR); + worldr.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); worldr.vertex(this.left, this.bottom, 0.0D).uv(this.left / texScale, (this.bottom + (int)this.scrollDistance) / texScale).color(0x20, 0x20, 0x20, 0xFF).endVertex(); worldr.vertex(this.right, this.bottom, 0.0D).uv(this.right / texScale, (this.bottom + (int)this.scrollDistance) / texScale).color(0x20, 0x20, 0x20, 0xFF).endVertex(); worldr.vertex(this.right, this.top, 0.0D).uv(this.right / texScale, (this.top + (int)this.scrollDistance) / texScale).color(0x20, 0x20, 0x20, 0xFF).endVertex(); @@ -231,20 +227,21 @@ public abstract class ScrollPanel extends FocusableGui implements IRenderable barTop = this.top; } + RenderSystem.setShader(GameRenderer::getPositionTexColorShader); RenderSystem.disableTexture(); - worldr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR); + worldr.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); worldr.vertex(barLeft, this.bottom, 0.0D).uv(0.0F, 1.0F).color(0x00, 0x00, 0x00, 0xFF).endVertex(); worldr.vertex(barLeft + barWidth, this.bottom, 0.0D).uv(1.0F, 1.0F).color(0x00, 0x00, 0x00, 0xFF).endVertex(); worldr.vertex(barLeft + barWidth, this.top, 0.0D).uv(1.0F, 0.0F).color(0x00, 0x00, 0x00, 0xFF).endVertex(); worldr.vertex(barLeft, this.top, 0.0D).uv(0.0F, 0.0F).color(0x00, 0x00, 0x00, 0xFF).endVertex(); tess.end(); - worldr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR); + worldr.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); worldr.vertex(barLeft, barTop + barHeight, 0.0D).uv(0.0F, 1.0F).color(0x80, 0x80, 0x80, 0xFF).endVertex(); worldr.vertex(barLeft + barWidth, barTop + barHeight, 0.0D).uv(1.0F, 1.0F).color(0x80, 0x80, 0x80, 0xFF).endVertex(); worldr.vertex(barLeft + barWidth, barTop, 0.0D).uv(1.0F, 0.0F).color(0x80, 0x80, 0x80, 0xFF).endVertex(); worldr.vertex(barLeft, barTop, 0.0D).uv(0.0F, 0.0F).color(0x80, 0x80, 0x80, 0xFF).endVertex(); tess.end(); - worldr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR); + worldr.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); worldr.vertex(barLeft, barTop + barHeight - 1, 0.0D).uv(0.0F, 1.0F).color(0xC0, 0xC0, 0xC0, 0xFF).endVertex(); worldr.vertex(barLeft + barWidth - 1, barTop + barHeight - 1, 0.0D).uv(1.0F, 1.0F).color(0xC0, 0xC0, 0xC0, 0xFF).endVertex(); worldr.vertex(barLeft + barWidth - 1, barTop, 0.0D).uv(1.0F, 0.0F).color(0xC0, 0xC0, 0xC0, 0xFF).endVertex(); @@ -253,19 +250,17 @@ public abstract class ScrollPanel extends FocusableGui implements IRenderable } RenderSystem.enableTexture(); - RenderSystem.shadeModel(GL11.GL_FLAT); - RenderSystem.enableAlphaTest(); RenderSystem.disableBlend(); GL11.glDisable(GL11.GL_SCISSOR_TEST); } - protected void drawGradientRect(MatrixStack mStack, int left, int top, int right, int bottom, int color1, int color2) + protected void drawGradientRect(PoseStack mStack, int left, int top, int right, int bottom, int color1, int color2) { GuiUtils.drawGradientRect(mStack.last().pose(), 0, 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/model/BakedItemModel.java b/src/main/java/net/minecraftforge/client/model/BakedItemModel.java index 015eb72650..2c4a96c815 100644 --- a/src/main/java/net/minecraftforge/client/model/BakedItemModel.java +++ b/src/main/java/net/minecraftforge/client/model/BakedItemModel.java @@ -26,26 +26,26 @@ import java.util.Random; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import com.mojang.blaze3d.matrix.MatrixStack; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.vector.TransformationMatrix; -import net.minecraft.client.renderer.model.BakedQuad; -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; -import net.minecraft.client.renderer.model.ItemOverrideList; +import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.world.level.block.state.BlockState; +import com.mojang.math.Transformation; +import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType; +import net.minecraft.client.renderer.block.model.ItemOverrides; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.util.Direction; +import net.minecraft.core.Direction; -public class BakedItemModel implements IBakedModel +public class BakedItemModel implements BakedModel { protected final ImmutableList quads; protected final TextureAtlasSprite particle; - protected final ImmutableMap transforms; - protected final ItemOverrideList overrides; - protected final IBakedModel guiModel; + protected final ImmutableMap transforms; + protected final ItemOverrides overrides; + protected final BakedModel guiModel; protected final boolean isSideLit; - public BakedItemModel(ImmutableList quads, TextureAtlasSprite particle, ImmutableMap transforms, ItemOverrideList overrides, boolean untransformed, boolean isSideLit) + public BakedItemModel(ImmutableList quads, TextureAtlasSprite particle, ImmutableMap transforms, ItemOverrides overrides, boolean untransformed, boolean isSideLit) { this.quads = quads; this.particle = particle; @@ -55,9 +55,9 @@ public class BakedItemModel implements IBakedModel this.guiModel = untransformed && hasGuiIdentity(transforms) ? new BakedGuiItemModel<>(this) : null; } - private static boolean hasGuiIdentity(ImmutableMap transforms) + private static boolean hasGuiIdentity(ImmutableMap transforms) { - TransformationMatrix guiTransform = transforms.get(TransformType.GUI); + Transformation guiTransform = transforms.get(TransformType.GUI); return guiTransform == null || guiTransform.isIdentity(); } @@ -66,7 +66,7 @@ public class BakedItemModel implements IBakedModel @Override public boolean usesBlockLight() { return isSideLit; } @Override public boolean isCustomRenderer() { return false; } @Override public TextureAtlasSprite getParticleIcon() { return particle; } - @Override public ItemOverrideList getOverrides() { return overrides; } + @Override public ItemOverrides getOverrides() { return overrides; } @Override public List getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) @@ -79,13 +79,13 @@ public class BakedItemModel implements IBakedModel } @Override - public IBakedModel handlePerspective(TransformType type, MatrixStack mat) + public BakedModel handlePerspective(TransformType type, PoseStack poseStack) { if (type == TransformType.GUI && this.guiModel != null) { - return this.guiModel.handlePerspective(type, mat); + return this.guiModel.handlePerspective(type, poseStack); } - return PerspectiveMapWrapper.handlePerspective(this, transforms, type, mat); + return PerspectiveMapWrapper.handlePerspective(this, transforms, type, poseStack); } public static class BakedGuiItemModel extends BakedModelWrapper @@ -123,13 +123,13 @@ public class BakedItemModel implements IBakedModel } @Override - public IBakedModel handlePerspective(TransformType type, MatrixStack mat) + public BakedModel handlePerspective(TransformType type, PoseStack poseStack) { if (type == TransformType.GUI) { - return PerspectiveMapWrapper.handlePerspective(this, originalModel.transforms, type, mat); + return PerspectiveMapWrapper.handlePerspective(this, originalModel.transforms, type, poseStack); } - return this.originalModel.handlePerspective(type, mat); + return this.originalModel.handlePerspective(type, poseStack); } } } diff --git a/src/main/java/net/minecraftforge/client/model/BakedModelWrapper.java b/src/main/java/net/minecraftforge/client/model/BakedModelWrapper.java index 09b62497ee..e420655abd 100644 --- a/src/main/java/net/minecraftforge/client/model/BakedModelWrapper.java +++ b/src/main/java/net/minecraftforge/client/model/BakedModelWrapper.java @@ -24,19 +24,19 @@ import javax.annotation.Nullable; import java.util.List; import java.util.Random; -import com.mojang.blaze3d.matrix.MatrixStack; -import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.model.BakedQuad; -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.model.ItemCameraTransforms; -import net.minecraft.client.renderer.model.ItemOverrideList; +import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.renderer.block.model.ItemTransforms; +import net.minecraft.client.renderer.block.model.ItemOverrides; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockDisplayReader; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockAndTintGetter; import net.minecraftforge.client.model.data.IModelData; -public abstract class BakedModelWrapper implements IBakedModel +public abstract class BakedModelWrapper implements BakedModel { protected final T originalModel; @@ -88,13 +88,13 @@ public abstract class BakedModelWrapper implements IBaked } @Override - public ItemCameraTransforms getTransforms() + public ItemTransforms getTransforms() { return originalModel.getTransforms(); } @Override - public ItemOverrideList getOverrides() + public ItemOverrides getOverrides() { return originalModel.getOverrides(); } @@ -106,15 +106,15 @@ public abstract class BakedModelWrapper implements IBaked } @Override - public IBakedModel handlePerspective(ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat) + public BakedModel handlePerspective(ItemTransforms.TransformType cameraTransformType, PoseStack poseStack) { - return originalModel.handlePerspective(cameraTransformType, mat); + return originalModel.handlePerspective(cameraTransformType, poseStack); } @Override - public TextureAtlasSprite getParticleTexture(@Nonnull IModelData data) + public TextureAtlasSprite getParticleIcon(@Nonnull IModelData data) { - return originalModel.getParticleTexture(data); + return originalModel.getParticleIcon(data); } @Nonnull @@ -126,7 +126,7 @@ public abstract class BakedModelWrapper implements IBaked @Nonnull @Override - public IModelData getModelData(@Nonnull IBlockDisplayReader world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull IModelData tileData) + public IModelData getModelData(@Nonnull BlockAndTintGetter world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull IModelData tileData) { return originalModel.getModelData(world, pos, state, tileData); } diff --git a/src/main/java/net/minecraftforge/client/model/BlockModelConfiguration.java b/src/main/java/net/minecraftforge/client/model/BlockModelConfiguration.java index 2a6b0d508d..f54a3375aa 100644 --- a/src/main/java/net/minecraftforge/client/model/BlockModelConfiguration.java +++ b/src/main/java/net/minecraftforge/client/model/BlockModelConfiguration.java @@ -20,9 +20,8 @@ package net.minecraftforge.client.model; import com.mojang.datafixers.util.Pair; -import net.minecraft.client.renderer.model.*; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.client.model.geometry.IModelGeometry; import net.minecraftforge.client.model.geometry.IModelGeometryPart; @@ -30,6 +29,15 @@ import javax.annotation.Nullable; import java.util.*; import java.util.function.Function; +import net.minecraft.client.renderer.block.model.BlockModel; +import net.minecraft.client.renderer.block.model.ItemOverrides; +import net.minecraft.client.renderer.block.model.ItemTransforms; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.resources.model.Material; +import net.minecraft.client.resources.model.ModelBakery; +import net.minecraft.client.resources.model.ModelState; +import net.minecraft.client.resources.model.UnbakedModel; + public class BlockModelConfiguration implements IModelConfiguration { public final BlockModel owner; @@ -37,7 +45,7 @@ public class BlockModelConfiguration implements IModelConfiguration @Nullable private IModelGeometry customGeometry; @Nullable - private IModelTransform customModelState; + private ModelState customModelState; public BlockModelConfiguration(BlockModel owner) { @@ -46,7 +54,7 @@ public class BlockModelConfiguration implements IModelConfiguration @Nullable @Override - public IUnbakedModel getOwnerModel() + public UnbakedModel getOwnerModel() { return owner; } @@ -74,12 +82,12 @@ public class BlockModelConfiguration implements IModelConfiguration } @Nullable - public IModelTransform getCustomModelState() + public ModelState getCustomModelState() { return owner.parent != null && customModelState == null ? owner.parent.customData.getCustomModelState() : customModelState; } - public void setCustomModelState(IModelTransform modelState) + public void setCustomModelState(ModelState modelState) { this.customModelState = modelState; } @@ -99,7 +107,7 @@ public class BlockModelConfiguration implements IModelConfiguration } @Override - public RenderMaterial resolveTexture(String name) + public Material resolveTexture(String name) { return owner.getMaterial(name); } @@ -122,19 +130,19 @@ public class BlockModelConfiguration implements IModelConfiguration } @Override - public ItemCameraTransforms getCameraTransforms() + public ItemTransforms getCameraTransforms() { return owner.getTransforms(); } @Override - public IModelTransform getCombinedTransform() + public ModelState getCombinedTransform() { - IModelTransform state = getCustomModelState(); + ModelState state = getCustomModelState(); return state != null - ? new SimpleModelTransform(PerspectiveMapWrapper.getTransformsWithFallback(state, getCameraTransforms()), state.getRotation()) - : new SimpleModelTransform(PerspectiveMapWrapper.getTransforms(getCameraTransforms())); + ? new SimpleModelState(PerspectiveMapWrapper.getTransformsWithFallback(state, getCameraTransforms()), state.getRotation()) + : new SimpleModelState(PerspectiveMapWrapper.getTransforms(getCameraTransforms())); } public void copyFrom(BlockModelConfiguration other) @@ -144,14 +152,14 @@ public class BlockModelConfiguration implements IModelConfiguration this.visibilityData.copyFrom(other.visibilityData); } - public Collection getTextureDependencies(Function modelGetter, Set> missingTextureErrors) + public Collection getTextureDependencies(Function modelGetter, Set> missingTextureErrors) { IModelGeometry geometry = getCustomGeometry(); return geometry == null ? Collections.emptySet() : geometry.getTextures(this, modelGetter, missingTextureErrors); } - public IBakedModel bake(ModelBakery bakery, Function bakedTextureGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) + public BakedModel bake(ModelBakery bakery, Function bakedTextureGetter, ModelState modelTransform, ItemOverrides overrides, ResourceLocation modelLocation) { IModelGeometry geometry = getCustomGeometry(); if (geometry == null) diff --git a/src/main/java/net/minecraftforge/client/model/CompositeModel.java b/src/main/java/net/minecraftforge/client/model/CompositeModel.java index 3144bfd036..07fe9185ff 100644 --- a/src/main/java/net/minecraftforge/client/model/CompositeModel.java +++ b/src/main/java/net/minecraftforge/client/model/CompositeModel.java @@ -23,16 +23,15 @@ import com.google.common.collect.ImmutableMap; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.datafixers.util.Pair; -import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.model.*; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.resources.IResourceManager; -import net.minecraft.util.Direction; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockDisplayReader; +import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.core.Direction; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockAndTintGetter; import net.minecraftforge.client.model.data.*; import net.minecraftforge.client.model.geometry.IModelGeometryPart; import net.minecraftforge.client.model.geometry.IMultipartModelGeometry; @@ -42,17 +41,27 @@ import javax.annotation.Nullable; import java.util.*; import java.util.function.Function; +import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.renderer.block.model.BlockModel; +import net.minecraft.client.renderer.block.model.ItemOverrides; +import net.minecraft.client.renderer.block.model.ItemTransforms; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.resources.model.Material; +import net.minecraft.client.resources.model.ModelBakery; +import net.minecraft.client.resources.model.ModelState; +import net.minecraft.client.resources.model.UnbakedModel; + public class CompositeModel implements IDynamicBakedModel { - private final ImmutableMap bakedParts; + private final ImmutableMap bakedParts; private final boolean isAmbientOcclusion; private final boolean isGui3d; private final boolean isSideLit; private final TextureAtlasSprite particle; - private final ItemOverrideList overrides; - private final IModelTransform transforms; + private final ItemOverrides overrides; + private final ModelState transforms; - public CompositeModel(boolean isGui3d, boolean isSideLit, boolean isAmbientOcclusion, TextureAtlasSprite particle, ImmutableMap bakedParts, IModelTransform combinedTransform, ItemOverrideList overrides) + public CompositeModel(boolean isGui3d, boolean isSideLit, boolean isAmbientOcclusion, TextureAtlasSprite particle, ImmutableMap bakedParts, ModelState combinedTransform, ItemOverrides overrides) { this.bakedParts = bakedParts; this.isAmbientOcclusion = isAmbientOcclusion; @@ -68,7 +77,7 @@ public class CompositeModel implements IDynamicBakedModel public List getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData extraData) { List quads = new ArrayList<>(); - for(Map.Entry entry : bakedParts.entrySet()) + for(Map.Entry entry : bakedParts.entrySet()) { quads.addAll(entry.getValue().getQuads(state, side, rand, CompositeModelData.get(extraData, entry.getKey()))); } @@ -77,10 +86,10 @@ public class CompositeModel implements IDynamicBakedModel @Nonnull @Override - public IModelData getModelData(@Nonnull IBlockDisplayReader world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull IModelData tileData) + public IModelData getModelData(@Nonnull BlockAndTintGetter world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull IModelData tileData) { CompositeModelData composite = new CompositeModelData(); - for(Map.Entry entry : bakedParts.entrySet()) + for(Map.Entry entry : bakedParts.entrySet()) { composite.putSubmodelData(entry.getKey(), entry.getValue().getModelData(world, pos, state, ModelDataWrapper.wrap(tileData))); } @@ -118,7 +127,7 @@ public class CompositeModel implements IDynamicBakedModel } @Override - public ItemOverrideList getOverrides() + public ItemOverrides getOverrides() { return overrides; } @@ -130,13 +139,13 @@ public class CompositeModel implements IDynamicBakedModel } @Override - public IBakedModel handlePerspective(ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat) + public BakedModel handlePerspective(ItemTransforms.TransformType cameraTransformType, PoseStack poseStack) { - return PerspectiveMapWrapper.handlePerspective(this, transforms, cameraTransformType, mat); + return PerspectiveMapWrapper.handlePerspective(this, transforms, cameraTransformType, poseStack); } @Nullable - public IBakedModel getPart(String name) + public BakedModel getPart(String name) { return bakedParts.get(name); } @@ -145,9 +154,9 @@ public class CompositeModel implements IDynamicBakedModel { private final String name; private final BlockModel model; - private final IModelTransform modelTransform; + private final ModelState modelTransform; - private Submodel(String name, BlockModel model, IModelTransform modelTransform) + private Submodel(String name, BlockModel model, ModelState modelTransform) { this.name = name; this.model = model; @@ -161,19 +170,19 @@ public class CompositeModel implements IDynamicBakedModel } @Override - public void addQuads(IModelConfiguration owner, IModelBuilder modelBuilder, ModelBakery bakery, Function spriteGetter, IModelTransform modelTransform, ResourceLocation modelLocation) + public void addQuads(IModelConfiguration owner, IModelBuilder modelBuilder, ModelBakery bakery, Function spriteGetter, ModelState modelTransform, ResourceLocation modelLocation) { throw new UnsupportedOperationException("Attempted to call adQuads on a Submodel instance. Please don't."); } - public IBakedModel bakeModel(ModelBakery bakery, Function spriteGetter, IModelTransform modelTransform, ResourceLocation modelLocation) + public BakedModel bakeModel(ModelBakery bakery, Function spriteGetter, ModelState modelTransform, ResourceLocation modelLocation) { - return model.bake(bakery, spriteGetter, new ModelTransformComposition(this.modelTransform, modelTransform, + return model.bake(bakery, spriteGetter, new CompositeModelState(this.modelTransform, modelTransform, this.modelTransform.isUvLocked() || modelTransform.isUvLocked()), modelLocation); } @Override - public Collection getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors) + public Collection getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors) { return model.getMaterials(modelGetter, missingTextureErrors); } @@ -201,12 +210,12 @@ public class CompositeModel implements IDynamicBakedModel } @Override - public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) + public BakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function spriteGetter, ModelState modelTransform, ItemOverrides overrides, ResourceLocation modelLocation) { - RenderMaterial particleLocation = owner.resolveTexture("particle"); + Material particleLocation = owner.resolveTexture("particle"); TextureAtlasSprite particle = spriteGetter.apply(particleLocation); - ImmutableMap.Builder bakedParts = ImmutableMap.builder(); + ImmutableMap.Builder bakedParts = ImmutableMap.builder(); for(Map.Entry part : parts.entrySet()) { Submodel submodel = part.getValue(); @@ -218,9 +227,9 @@ public class CompositeModel implements IDynamicBakedModel } @Override - public Collection getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors) + public Collection getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors) { - Set textures = new HashSet<>(); + Set textures = new HashSet<>(); for(Submodel part : parts.values()) { textures.addAll(part.getTextures(owner, modelGetter, missingTextureErrors)); @@ -236,7 +245,7 @@ public class CompositeModel implements IDynamicBakedModel private Loader() {} @Override - public void onResourceManagerReload(IResourceManager resourceManager) + public void onResourceManagerReload(ResourceManager resourceManager) { } @@ -250,7 +259,7 @@ public class CompositeModel implements IDynamicBakedModel for(Map.Entry part : modelContents.get("parts").getAsJsonObject().entrySet()) { // TODO: Allow customizing state? If so, how? - IModelTransform modelTransform = SimpleModelTransform.IDENTITY; + ModelState modelTransform = SimpleModelState.IDENTITY; parts.put(part.getKey(), new Submodel( part.getKey(), deserializationContext.deserialize(part.getValue(), BlockModel.class), diff --git a/src/main/java/net/minecraftforge/client/model/ModelTransformComposition.java b/src/main/java/net/minecraftforge/client/model/CompositeModelState.java similarity index 74% rename from src/main/java/net/minecraftforge/client/model/ModelTransformComposition.java rename to src/main/java/net/minecraftforge/client/model/CompositeModelState.java index 965de543aa..f66ab5781c 100644 --- a/src/main/java/net/minecraftforge/client/model/ModelTransformComposition.java +++ b/src/main/java/net/minecraftforge/client/model/CompositeModelState.java @@ -20,24 +20,24 @@ package net.minecraftforge.client.model; import com.google.common.base.Objects; -import net.minecraft.util.math.vector.TransformationMatrix; -import net.minecraft.client.renderer.model.IModelTransform; +import com.mojang.math.Transformation; +import net.minecraft.client.resources.model.ModelState; /** * An {@link IModelTransform} that combines the transforms from two child {@link IModelTransform}. */ -public class ModelTransformComposition implements IModelTransform +public class CompositeModelState implements ModelState { - private final IModelTransform first; - private final IModelTransform second; + private final ModelState first; + private final ModelState second; private final boolean uvLock; - public ModelTransformComposition(IModelTransform first, IModelTransform second) + public CompositeModelState(ModelState first, ModelState second) { this(first, second, false); } - public ModelTransformComposition(IModelTransform first, IModelTransform second, boolean uvLock) + public CompositeModelState(ModelState first, ModelState second, boolean uvLock) { this.first = first; this.second = second; @@ -51,13 +51,13 @@ public class ModelTransformComposition implements IModelTransform } @Override - public TransformationMatrix getRotation() + public Transformation getRotation() { return first.getRotation().compose(second.getRotation()); } @Override - public TransformationMatrix getPartTransformation(Object part) + public Transformation getPartTransformation(Object part) { return first.getPartTransformation(part).compose(second.getPartTransformation(part)); } @@ -73,7 +73,7 @@ public class ModelTransformComposition implements IModelTransform { return false; } - ModelTransformComposition that = (ModelTransformComposition) o; + CompositeModelState that = (CompositeModelState) o; return Objects.equal(first, that.first) && Objects.equal(second, that.second); } diff --git a/src/main/java/net/minecraftforge/client/model/DynamicBucketModel.java b/src/main/java/net/minecraftforge/client/model/DynamicBucketModel.java index 7bf4ca8be3..93a05f88f5 100644 --- a/src/main/java/net/minecraftforge/client/model/DynamicBucketModel.java +++ b/src/main/java/net/minecraftforge/client/model/DynamicBucketModel.java @@ -23,19 +23,18 @@ import com.google.common.collect.*; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonObject; import com.mojang.datafixers.util.Pair; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.util.math.vector.Quaternion; -import net.minecraft.util.math.vector.TransformationMatrix; -import net.minecraft.client.renderer.model.*; -import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; +import net.minecraft.client.multiplayer.ClientLevel; +import com.mojang.math.Quaternion; +import com.mojang.math.Transformation; +import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.entity.LivingEntity; -import net.minecraft.fluid.Fluid; -import net.minecraft.fluid.Fluids; -import net.minecraft.item.ItemStack; -import net.minecraft.resources.IResourceManager; -import net.minecraft.util.Direction; -import net.minecraft.util.ResourceLocation; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.item.ItemStack; +import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.core.Direction; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.client.ForgeHooksClient; import net.minecraftforge.client.model.geometry.IModelGeometry; import net.minecraftforge.fluids.FluidUtil; @@ -51,6 +50,14 @@ import java.util.*; import java.util.function.Function; import java.util.function.Predicate; +import net.minecraft.client.renderer.block.model.ItemOverrides; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.resources.model.BlockModelRotation; +import net.minecraft.client.resources.model.Material; +import net.minecraft.client.resources.model.ModelBakery; +import net.minecraft.client.resources.model.ModelState; +import net.minecraft.client.resources.model.UnbakedModel; + public final class DynamicBucketModel implements IModelGeometry { private static final Logger LOGGER = LogManager.getLogger(); @@ -94,20 +101,20 @@ public final class DynamicBucketModel implements IModelGeometry spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) + public BakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function spriteGetter, ModelState modelTransform, ItemOverrides overrides, ResourceLocation modelLocation) { - RenderMaterial particleLocation = owner.isTexturePresent("particle") ? owner.resolveTexture("particle") : null; - RenderMaterial baseLocation = owner.isTexturePresent("base") ? owner.resolveTexture("base") : null; - RenderMaterial fluidMaskLocation = owner.isTexturePresent("fluid") ? owner.resolveTexture("fluid") : null; - RenderMaterial coverLocation = owner.isTexturePresent("cover") ? owner.resolveTexture("cover") : null; + Material particleLocation = owner.isTexturePresent("particle") ? owner.resolveTexture("particle") : null; + Material baseLocation = owner.isTexturePresent("base") ? owner.resolveTexture("base") : null; + Material fluidMaskLocation = owner.isTexturePresent("fluid") ? owner.resolveTexture("fluid") : null; + Material coverLocation = owner.isTexturePresent("cover") ? owner.resolveTexture("cover") : null; - IModelTransform transformsFromModel = owner.getCombinedTransform(); + ModelState transformsFromModel = owner.getCombinedTransform(); TextureAtlasSprite fluidSprite = fluid != Fluids.EMPTY ? spriteGetter.apply(ForgeHooksClient.getBlockMaterial(fluid.getAttributes().getStillTexture())) : null; TextureAtlasSprite coverSprite = (coverLocation != null && (!coverIsMask || baseLocation != null)) ? spriteGetter.apply(coverLocation) : null; - ImmutableMap transformMap = - PerspectiveMapWrapper.getTransforms(new ModelTransformComposition(transformsFromModel, modelTransform)); + ImmutableMap transformMap = + PerspectiveMapWrapper.getTransforms(new CompositeModelState(transformsFromModel, modelTransform)); TextureAtlasSprite particleSprite = particleLocation != null ? spriteGetter.apply(particleLocation) : null; @@ -117,12 +124,12 @@ public final class DynamicBucketModel implements IModelGeometry getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors) + public Collection getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors) { - Set texs = Sets.newHashSet(); + Set texs = Sets.newHashSet(); if (owner.isTexturePresent("particle")) texs.add(owner.resolveTexture("particle")); if (owner.isTexturePresent("base")) texs.add(owner.resolveTexture("base")); @@ -192,13 +199,7 @@ public final class DynamicBucketModel implements IModelGeometry resourcePredicate) + public void onResourceManagerReload(ResourceManager resourceManager) { // no need to clear cache since we create a new model instance } @@ -242,15 +243,15 @@ public final class DynamicBucketModel implements IModelGeometry cache = Maps.newHashMap(); // contains all the baked models since they'll never change - private final ItemOverrideList nested; + private final Map cache = Maps.newHashMap(); // contains all the baked models since they'll never change + private final ItemOverrides nested; private final ModelBakery bakery; private final IModelConfiguration owner; private final DynamicBucketModel parent; - private ContainedFluidOverrideHandler(ItemOverrideList nested, ModelBakery bakery, IModelConfiguration owner, DynamicBucketModel parent) + private ContainedFluidOverrideHandler(ItemOverrides nested, ModelBakery bakery, IModelConfiguration owner, DynamicBucketModel parent) { this.nested = nested; this.bakery = bakery; @@ -259,9 +260,9 @@ public final class DynamicBucketModel implements IModelGeometry { @@ -271,7 +272,7 @@ public final class DynamicBucketModel implements IModelGeometry { public static final FluidModel WATER = new FluidModel(Fluids.WATER); @@ -72,13 +79,13 @@ public final class FluidModel implements IModelGeometry } @Override - public Collection getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors) + public Collection getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors) { return ForgeHooksClient.getFluidMaterials(fluid).collect(Collectors.toList()); } @Override - public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) + public BakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function spriteGetter, ModelState modelTransform, ItemOverrides overrides, ResourceLocation modelLocation) { FluidAttributes attrs = fluid.getAttributes(); return new CachingBakedFluid( @@ -121,7 +128,7 @@ public final class FluidModel implements IModelGeometry } }); - public CachingBakedFluid(TransformationMatrix transformation, ImmutableMap transforms, ResourceLocation modelLocation, int color, TextureAtlasSprite still, TextureAtlasSprite flowing, Optional overlay, boolean gas, Optional stateOption) + public CachingBakedFluid(Transformation transformation, ImmutableMap transforms, ResourceLocation modelLocation, int color, TextureAtlasSprite still, TextureAtlasSprite flowing, Optional overlay, boolean gas, Optional stateOption) { super(transformation, transforms, modelLocation, color, still, flowing, overlay, gas, stateOption.isPresent(), getCorners(stateOption), getFlow(stateOption), getOverlay(stateOption)); } @@ -166,7 +173,7 @@ public final class FluidModel implements IModelGeometry if (flow == null) flow = -1000f; } int flowRound = (int) Math.round(Math.toDegrees(flow)); - flowRound = MathHelper.clamp(flowRound, -1000, 1000); + flowRound = Mth.clamp(flowRound, -1000, 1000); return flowRound; } @@ -226,14 +233,14 @@ public final class FluidModel implements IModelGeometry } } - private static class BakedFluid implements IBakedModel + private static class BakedFluid implements BakedModel { private static final int x[] = { 0, 0, 1, 1 }; private static final int z[] = { 0, 1, 1, 0 }; private static final float eps = 1e-3f; - protected final TransformationMatrix transformation; - protected final ImmutableMap transforms; + protected final Transformation transformation; + protected final ImmutableMap transforms; protected final ResourceLocation modelLocation; protected final int color; protected final TextureAtlasSprite still, flowing; @@ -241,7 +248,7 @@ public final class FluidModel implements IModelGeometry protected final boolean gas; protected final ImmutableMap> faceQuads; - public BakedFluid(TransformationMatrix transformation, ImmutableMap transforms, ResourceLocation modelLocation, int color, TextureAtlasSprite still, TextureAtlasSprite flowing, Optional overlay, boolean gas, boolean statePresent, int[] cornerRound, int flowRound, boolean[] sideOverlays) + public BakedFluid(Transformation transformation, ImmutableMap transforms, ResourceLocation modelLocation, int color, TextureAtlasSprite still, TextureAtlasSprite flowing, Optional overlay, boolean gas, boolean statePresent, int[] cornerRound, int flowRound, boolean[] sideOverlays) { this.transformation = transformation; this.transforms = transforms; @@ -281,8 +288,8 @@ public final class FluidModel implements IModelGeometry TextureAtlasSprite topSprite = isFlowing ? flowing : still; float scale = isFlowing ? 4f : 8f; - float c = MathHelper.cos(flow) * scale; - float s = MathHelper.sin(flow) * scale; + float c = Mth.cos(flow) * scale; + float s = Mth.sin(flow) * scale; // top Direction top = gas ? Direction.DOWN : Direction.UP; @@ -387,7 +394,7 @@ public final class FluidModel implements IModelGeometry private void putVertex(IVertexConsumer consumer, Direction side, boolean offset, float x, float y, float z, float u, float v) { - VertexFormat format = DefaultVertexFormats.BLOCK; + VertexFormat format = DefaultVertexFormat.BLOCK; ImmutableList elements = format.getElements(); for(int e = 0; e < elements.size(); e++) { @@ -463,9 +470,9 @@ public final class FluidModel implements IModelGeometry } @Override - public ItemOverrideList getOverrides() + public ItemOverrides getOverrides() { - return ItemOverrideList.EMPTY; + return ItemOverrides.EMPTY; } @Override @@ -475,9 +482,9 @@ public final class FluidModel implements IModelGeometry } @Override - public IBakedModel handlePerspective(TransformType type, MatrixStack mat) + public BakedModel handlePerspective(TransformType type, PoseStack poseStack) { - return PerspectiveMapWrapper.handlePerspective(this, transforms, type, mat); + return PerspectiveMapWrapper.handlePerspective(this, transforms, type, poseStack); } } } diff --git a/src/main/java/net/minecraftforge/client/model/IModelBuilder.java b/src/main/java/net/minecraftforge/client/model/IModelBuilder.java index 9ce9b57119..df4bb69170 100644 --- a/src/main/java/net/minecraftforge/client/model/IModelBuilder.java +++ b/src/main/java/net/minecraftforge/client/model/IModelBuilder.java @@ -19,16 +19,16 @@ package net.minecraftforge.client.model; -import net.minecraft.client.renderer.model.BakedQuad; -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.model.ItemOverrideList; -import net.minecraft.client.renderer.model.SimpleBakedModel; +import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.renderer.block.model.ItemOverrides; +import net.minecraft.client.resources.model.SimpleBakedModel; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.util.Direction; +import net.minecraft.core.Direction; public interface IModelBuilder> { - static IModelBuilder of(IModelConfiguration owner, ItemOverrideList overrides, TextureAtlasSprite particle) + static IModelBuilder of(IModelConfiguration owner, ItemOverrides overrides, TextureAtlasSprite particle) { return new Simple(new SimpleBakedModel.Builder(owner, overrides).particle(particle)); } @@ -36,7 +36,7 @@ public interface IModelBuilder> T addFaceQuad(Direction facing, BakedQuad quad); T addGeneralQuad(BakedQuad quad); - IBakedModel build(); + BakedModel build(); class Simple implements IModelBuilder { final SimpleBakedModel.Builder builder; @@ -61,7 +61,7 @@ public interface IModelBuilder> } @Override - public IBakedModel build() + public BakedModel build() { return builder.build(); } diff --git a/src/main/java/net/minecraftforge/client/model/IModelConfiguration.java b/src/main/java/net/minecraftforge/client/model/IModelConfiguration.java index 3124326f34..cd0031bf01 100644 --- a/src/main/java/net/minecraftforge/client/model/IModelConfiguration.java +++ b/src/main/java/net/minecraftforge/client/model/IModelConfiguration.java @@ -19,10 +19,10 @@ package net.minecraftforge.client.model; -import net.minecraft.client.renderer.model.IModelTransform; -import net.minecraft.client.renderer.model.IUnbakedModel; -import net.minecraft.client.renderer.model.ItemCameraTransforms; -import net.minecraft.client.renderer.model.RenderMaterial; +import net.minecraft.client.resources.model.ModelState; +import net.minecraft.client.resources.model.UnbakedModel; +import net.minecraft.client.renderer.block.model.ItemTransforms; +import net.minecraft.client.resources.model.Material; import net.minecraftforge.client.model.geometry.IModelGeometryPart; import javax.annotation.Nullable; @@ -37,7 +37,7 @@ public interface IModelConfiguration { * If available, gets the owning model (usually BlockModel) of this configuration */ @Nullable - IUnbakedModel getOwnerModel(); + UnbakedModel getOwnerModel(); /** * @return The name of the model being baked, for logging and cache purposes. @@ -55,7 +55,7 @@ public interface IModelConfiguration { * @param name The name of a texture channel. * @return The location of the texture, or the missing texture if not found. */ - RenderMaterial resolveTexture(String name); + Material resolveTexture(String name); /** * @return True if the item is a 3D model, false if it's a generated item model. @@ -79,12 +79,12 @@ public interface IModelConfiguration { * Gets the vanilla camera transforms data. * Do not use for non-vanilla code. For general usage, prefer getCombinedState. */ - ItemCameraTransforms getCameraTransforms(); + ItemTransforms getCameraTransforms(); /** * @return The combined transformation state including vanilla and forge transforms data. */ - IModelTransform getCombinedTransform(); + ModelState getCombinedTransform(); /** * Queries the visibility information for the model parts. diff --git a/src/main/java/net/minecraftforge/client/model/IModelLoader.java b/src/main/java/net/minecraftforge/client/model/IModelLoader.java index 696c792d4d..b3e0f2467d 100644 --- a/src/main/java/net/minecraftforge/client/model/IModelLoader.java +++ b/src/main/java/net/minecraftforge/client/model/IModelLoader.java @@ -21,33 +21,15 @@ package net.minecraftforge.client.model; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonObject; -import net.minecraft.resources.IResourceManager; +import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.server.packs.resources.ResourceManagerReloadListener; import net.minecraftforge.client.model.geometry.IModelGeometry; import net.minecraftforge.resource.IResourceType; -import net.minecraftforge.resource.ISelectiveResourceReloadListener; import net.minecraftforge.resource.VanillaResourceType; import java.util.function.Predicate; -public interface IModelLoader> extends ISelectiveResourceReloadListener +public interface IModelLoader> extends ResourceManagerReloadListener { - @Override - default IResourceType getResourceType() - { - return VanillaResourceType.MODELS; - } - - @Override - void onResourceManagerReload(IResourceManager resourceManager); - - @Override - default void onResourceManagerReload(IResourceManager resourceManager, Predicate resourcePredicate) - { - if (resourcePredicate.test(getResourceType())) - { - onResourceManagerReload(resourceManager); - } - } - T read(JsonDeserializationContext deserializationContext, JsonObject modelContents); } diff --git a/src/main/java/net/minecraftforge/client/model/ItemLayerModel.java b/src/main/java/net/minecraftforge/client/model/ItemLayerModel.java index f9e30aa481..11831fc3bf 100644 --- a/src/main/java/net/minecraftforge/client/model/ItemLayerModel.java +++ b/src/main/java/net/minecraftforge/client/model/ItemLayerModel.java @@ -25,15 +25,14 @@ import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonObject; import com.mojang.datafixers.util.Pair; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.model.*; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.renderer.vertex.VertexFormat; -import net.minecraft.client.renderer.vertex.VertexFormatElement; -import net.minecraft.resources.IResourceManager; -import net.minecraft.util.Direction; -import net.minecraft.util.JSONUtils; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.vector.TransformationMatrix; +import com.mojang.blaze3d.vertex.VertexFormat; +import com.mojang.blaze3d.vertex.VertexFormatElement; +import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.core.Direction; +import net.minecraft.util.GsonHelper; +import net.minecraft.resources.ResourceLocation; +import com.mojang.math.Transformation; import net.minecraftforge.client.ForgeRenderTypes; import net.minecraftforge.client.model.geometry.IModelGeometry; import net.minecraftforge.client.model.pipeline.BakedQuadBuilder; @@ -44,6 +43,15 @@ import javax.annotation.Nullable; import java.util.*; import java.util.function.Function; +import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.renderer.block.model.ItemOverrides; +import net.minecraft.client.renderer.block.model.ItemTransforms; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.resources.model.Material; +import net.minecraft.client.resources.model.ModelBakery; +import net.minecraft.client.resources.model.ModelState; +import net.minecraft.client.resources.model.UnbakedModel; + /** * Forge reimplementation of vanilla {@link ItemModelGenerator}, i.e. builtin/generated models, * with the following changes: @@ -59,7 +67,7 @@ public final class ItemLayerModel implements IModelGeometry private static final Direction[] HORIZONTALS = {Direction.UP, Direction.DOWN}; private static final Direction[] VERTICALS = {Direction.WEST, Direction.EAST}; - private ImmutableList textures; + private ImmutableList textures; private final ImmutableSet fullbrightLayers; public ItemLayerModel() @@ -67,20 +75,20 @@ public final class ItemLayerModel implements IModelGeometry this(null, ImmutableSet.of()); } - public ItemLayerModel(ImmutableList textures) + public ItemLayerModel(ImmutableList textures) { this(textures, ImmutableSet.of()); } - public ItemLayerModel(@Nullable ImmutableList textures, ImmutableSet fullbrightLayers) + public ItemLayerModel(@Nullable ImmutableList textures, ImmutableSet fullbrightLayers) { this.textures = textures; this.fullbrightLayers = fullbrightLayers; } - private static ImmutableList getTextures(IModelConfiguration model) + private static ImmutableList getTextures(IModelConfiguration model) { - ImmutableList.Builder builder = ImmutableList.builder(); + ImmutableList.Builder builder = ImmutableList.builder(); for(int i = 0; model.isTexturePresent("layer" + i); i++) { builder.add(model.resolveTexture("layer" + i)); @@ -89,13 +97,13 @@ public final class ItemLayerModel implements IModelGeometry } @Override - public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, - Function spriteGetter, IModelTransform modelTransform, - ItemOverrideList overrides, ResourceLocation modelLocation) + public BakedModel bake(IModelConfiguration owner, ModelBakery bakery, + Function spriteGetter, ModelState modelTransform, + ItemOverrides overrides, ResourceLocation modelLocation) { - ImmutableMap transformMap = - PerspectiveMapWrapper.getTransforms(new ModelTransformComposition(owner.getCombinedTransform(), modelTransform)); - TransformationMatrix transform = modelTransform.getRotation(); + ImmutableMap transformMap = + PerspectiveMapWrapper.getTransforms(new CompositeModelState(owner.getCombinedTransform(), modelTransform)); + Transformation transform = modelTransform.getRotation(); TextureAtlasSprite particle = spriteGetter.apply( owner.isTexturePresent("particle") ? owner.resolveTexture("particle") : textures.get(0) ); @@ -116,12 +124,12 @@ public final class ItemLayerModel implements IModelGeometry return isFullbright ? ForgeRenderTypes.ITEM_UNSORTED_UNLIT_TRANSLUCENT.get() : ForgeRenderTypes.ITEM_UNSORTED_TRANSLUCENT.get(); } - public static ImmutableList getQuadsForSprites(List textures, TransformationMatrix transform, Function spriteGetter) + public static ImmutableList getQuadsForSprites(List textures, Transformation transform, Function spriteGetter) { return getQuadsForSprites(textures, transform, spriteGetter, Collections.emptySet()); } - public static ImmutableList getQuadsForSprites(List textures, TransformationMatrix transform, Function spriteGetter, Set fullbrights) + public static ImmutableList getQuadsForSprites(List textures, Transformation transform, Function spriteGetter, Set fullbrights) { ImmutableList.Builder builder = ImmutableList.builder(); for(int i = 0; i < textures.size(); i++) @@ -132,12 +140,12 @@ public final class ItemLayerModel implements IModelGeometry return builder.build(); } - public static ImmutableList getQuadsForSprite(int tint, TextureAtlasSprite sprite, TransformationMatrix transform) + public static ImmutableList getQuadsForSprite(int tint, TextureAtlasSprite sprite, Transformation transform) { return getQuadsForSprite(tint, sprite, transform, false); } - public static ImmutableList getQuadsForSprite(int tint, TextureAtlasSprite sprite, TransformationMatrix transform, boolean fullbright) + public static ImmutableList getQuadsForSprite(int tint, TextureAtlasSprite sprite, Transformation transform, boolean fullbright) { ImmutableList.Builder builder = ImmutableList.builder(); @@ -313,7 +321,7 @@ public final class ItemLayerModel implements IModelGeometry } @Override - public Collection getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors) + public Collection getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors) { textures = getTextures(owner); return textures; @@ -351,7 +359,7 @@ public final class ItemLayerModel implements IModelGeometry } } - private static BakedQuad buildSideQuad(TransformationMatrix transform, Direction side, int tint, TextureAtlasSprite sprite, int u, int v, int size, boolean fullbright) + private static BakedQuad buildSideQuad(Transformation transform, Direction side, int tint, TextureAtlasSprite sprite, int u, int v, int size, boolean fullbright) { final float eps = 1e-2f; @@ -404,7 +412,7 @@ public final class ItemLayerModel implements IModelGeometry return side.getAxis() == Direction.Axis.Y ? side.getOpposite() : side; } - private static BakedQuad buildQuad(TransformationMatrix transform, Direction side, TextureAtlasSprite sprite, int tint, boolean fullbright, + private static BakedQuad buildQuad(Transformation transform, Direction side, TextureAtlasSprite sprite, int tint, boolean fullbright, float x0, float y0, float z0, float u0, float v0, float x1, float y1, float z1, float u1, float v1, float x2, float y2, float z2, float u2, float v2, @@ -473,7 +481,7 @@ public final class ItemLayerModel implements IModelGeometry public static final Loader INSTANCE = new Loader(); @Override - public void onResourceManagerReload(IResourceManager resourceManager) + public void onResourceManagerReload(ResourceManager resourceManager) { // nothing to do } @@ -484,7 +492,7 @@ public final class ItemLayerModel implements IModelGeometry ImmutableSet.Builder fullbrightLayers = ImmutableSet.builder(); if (modelContents.has("fullbright_layers")) { - JsonArray arr = JSONUtils.getAsJsonArray(modelContents, "fullbright_layers"); + JsonArray arr = GsonHelper.getAsJsonArray(modelContents, "fullbright_layers"); for(int i=0;i> layerModels; - private final ImmutableMap cameraTransforms; + private final ItemOverrides overrides; + private final ImmutableList> layerModels; + private final ImmutableMap cameraTransforms; public ItemMultiLayerBakedModel(boolean smoothLighting, boolean shadedInGui, boolean sideLit, - TextureAtlasSprite particle, ItemOverrideList overrides, - ImmutableMap cameraTransforms, - ImmutableList> layerModels) + TextureAtlasSprite particle, ItemOverrides overrides, + ImmutableMap cameraTransforms, + ImmutableList> layerModels) { this.smoothLighting = smoothLighting; this.shadedInGui = shadedInGui; @@ -106,7 +106,7 @@ public class ItemMultiLayerBakedModel implements IDynamicBakedModel } @Override - public ItemOverrideList getOverrides() + public ItemOverrides getOverrides() { return overrides; } @@ -118,9 +118,9 @@ public class ItemMultiLayerBakedModel implements IDynamicBakedModel } @Override - public IBakedModel handlePerspective(ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat) + public BakedModel handlePerspective(ItemTransforms.TransformType cameraTransformType, PoseStack poseStack) { - return PerspectiveMapWrapper.handlePerspective(this, cameraTransforms, cameraTransformType, mat); + return PerspectiveMapWrapper.handlePerspective(this, cameraTransforms, cameraTransformType, poseStack); } //@Override @@ -130,29 +130,29 @@ public class ItemMultiLayerBakedModel implements IDynamicBakedModel } //@Override - public List> getLayerModels(ItemStack itemStack, boolean fabulous) + public List> getLayerModels(ItemStack itemStack, boolean fabulous) { return layerModels; } - public static Builder builder(IModelConfiguration owner, TextureAtlasSprite particle, ItemOverrideList overrides, - ImmutableMap cameraTransforms) + public static Builder builder(IModelConfiguration owner, TextureAtlasSprite particle, ItemOverrides overrides, + ImmutableMap cameraTransforms) { return new Builder(owner, particle, overrides, cameraTransforms); } public static class Builder { - private final ImmutableList.Builder> builder = ImmutableList.builder(); + private final ImmutableList.Builder> builder = ImmutableList.builder(); private final List quads = Lists.newArrayList(); - private final ItemOverrideList overrides; - private final ImmutableMap cameraTransforms; + private final ItemOverrides overrides; + private final ImmutableMap cameraTransforms; private final IModelConfiguration owner; private TextureAtlasSprite particle; private RenderType lastRt = null; - private Builder(IModelConfiguration owner, TextureAtlasSprite particle, ItemOverrideList overrides, - ImmutableMap cameraTransforms) + private Builder(IModelConfiguration owner, TextureAtlasSprite particle, ItemOverrides overrides, + ImmutableMap cameraTransforms) { this.owner = owner; this.particle = particle; @@ -160,9 +160,9 @@ public class ItemMultiLayerBakedModel implements IDynamicBakedModel this.cameraTransforms = cameraTransforms; } - private void addLayer(ImmutableList.Builder> builder, List quads, RenderType rt) + private void addLayer(ImmutableList.Builder> builder, List quads, RenderType rt) { - IBakedModel model = new BakedItemModel(ImmutableList.copyOf(quads), particle, ImmutableMap.of(), ItemOverrideList.EMPTY, true, owner.isSideLit()); + BakedModel model = new BakedItemModel(ImmutableList.copyOf(quads), particle, ImmutableMap.of(), ItemOverrides.EMPTY, true, owner.isSideLit()); builder.add(Pair.of(model, rt)); } @@ -199,7 +199,7 @@ public class ItemMultiLayerBakedModel implements IDynamicBakedModel return this; } - public IBakedModel build() + public BakedModel build() { if (quads.size() > 0) { diff --git a/src/main/java/net/minecraftforge/client/model/ItemTextureQuadConverter.java b/src/main/java/net/minecraftforge/client/model/ItemTextureQuadConverter.java index 06c39715db..020e266026 100644 --- a/src/main/java/net/minecraftforge/client/model/ItemTextureQuadConverter.java +++ b/src/main/java/net/minecraftforge/client/model/ItemTextureQuadConverter.java @@ -21,12 +21,12 @@ package net.minecraftforge.client.model; import com.google.common.collect.Lists; -import net.minecraft.client.renderer.model.BakedQuad; +import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.renderer.vertex.VertexFormat; -import net.minecraft.client.renderer.vertex.VertexFormatElement; -import net.minecraft.util.Direction; -import net.minecraft.util.math.vector.TransformationMatrix; +import com.mojang.blaze3d.vertex.VertexFormat; +import com.mojang.blaze3d.vertex.VertexFormatElement; +import net.minecraft.core.Direction; +import com.mojang.math.Transformation; import net.minecraftforge.client.model.pipeline.BakedQuadBuilder; import net.minecraftforge.client.model.pipeline.IVertexConsumer; import net.minecraftforge.client.model.pipeline.TRSRTransformer; @@ -52,11 +52,11 @@ public final class ItemTextureQuadConverter * @param sprite The texture whose UVs shall be used * @return The generated quads. */ - public static List convertTexture(TransformationMatrix transform, TextureAtlasSprite template, TextureAtlasSprite sprite, float z, Direction facing, int color, int tint) + public static List convertTexture(Transformation transform, TextureAtlasSprite template, TextureAtlasSprite sprite, float z, Direction facing, int color, int tint) { return convertTexture(transform, template, sprite, z, facing, color, tint, 0); } - public static List convertTexture(TransformationMatrix transform, TextureAtlasSprite template, TextureAtlasSprite sprite, float z, Direction facing, int color, int tint, int luminosity) + public static List convertTexture(Transformation transform, TextureAtlasSprite template, TextureAtlasSprite sprite, float z, Direction facing, int color, int tint, int luminosity) { List horizontal = convertTextureHorizontal(transform, template, sprite, z, facing, color, tint, luminosity); List vertical = convertTextureVertical(transform, template, sprite, z, facing, color, tint, luminosity); @@ -68,11 +68,11 @@ public final class ItemTextureQuadConverter * Scans a texture and converts it into a list of horizontal strips stacked on top of each other. * The height of the strips is as big as possible. */ - public static List convertTextureHorizontal(TransformationMatrix transform, TextureAtlasSprite template, TextureAtlasSprite sprite, float z, Direction facing, int color, int tint) + public static List convertTextureHorizontal(Transformation transform, TextureAtlasSprite template, TextureAtlasSprite sprite, float z, Direction facing, int color, int tint) { return convertTextureHorizontal(transform, template, sprite, z, facing, color, tint, 0); } - public static List convertTextureHorizontal(TransformationMatrix transform, TextureAtlasSprite template, TextureAtlasSprite sprite, float z, Direction facing, int color, int tint, int luminosity) + public static List convertTextureHorizontal(Transformation transform, TextureAtlasSprite template, TextureAtlasSprite sprite, float z, Direction facing, int color, int tint, int luminosity) { int w = template.getWidth(); int h = template.getHeight(); @@ -150,11 +150,11 @@ public final class ItemTextureQuadConverter * Scans a texture and converts it into a list of vertical strips stacked next to each other from left to right. * The width of the strips is as big as possible. */ - public static List convertTextureVertical(TransformationMatrix transform, TextureAtlasSprite template, TextureAtlasSprite sprite, float z, Direction facing, int color, int tint) + public static List convertTextureVertical(Transformation transform, TextureAtlasSprite template, TextureAtlasSprite sprite, float z, Direction facing, int color, int tint) { return convertTextureVertical(transform, template, sprite, z, facing, color, tint, 0); } - public static List convertTextureVertical(TransformationMatrix transform, TextureAtlasSprite template, TextureAtlasSprite sprite, float z, Direction facing, int color, int tint, int luminosity) + public static List convertTextureVertical(Transformation transform, TextureAtlasSprite template, TextureAtlasSprite sprite, float z, Direction facing, int color, int tint, int luminosity) { int w = template.getWidth(); int h = template.getHeight(); @@ -237,11 +237,11 @@ public final class ItemTextureQuadConverter * Generates a Front/Back quad for an itemmodel. Therefore only supports facing NORTH and SOUTH. * Coordinates are [0,16] to match the usual coordinates used in TextureAtlasSprites */ - public static BakedQuad genQuad(TransformationMatrix transform, float x1, float y1, float x2, float y2, float z, TextureAtlasSprite sprite, Direction facing, int color, int tint) + public static BakedQuad genQuad(Transformation transform, float x1, float y1, float x2, float y2, float z, TextureAtlasSprite sprite, Direction facing, int color, int tint) { return genQuad(transform, x1, y1, x2, y2, z, sprite, facing, color, tint, 0); } - public static BakedQuad genQuad(TransformationMatrix transform, float x1, float y1, float x2, float y2, float z, TextureAtlasSprite sprite, Direction facing, int color, int tint, int luminosity) + public static BakedQuad genQuad(Transformation transform, float x1, float y1, float x2, float y2, float z, TextureAtlasSprite sprite, Direction facing, int color, int tint, int luminosity) { float u1 = sprite.getU(x1); float v1 = sprite.getV(y1); @@ -260,7 +260,7 @@ public final class ItemTextureQuadConverter return putQuad(transform, facing, sprite, color, tint, x1, y1, x2, y2, z, u1, v1, u2, v2, luminosity); } - private static BakedQuad putQuad(TransformationMatrix transform, Direction side, TextureAtlasSprite sprite, int color, int tint, + private static BakedQuad putQuad(Transformation transform, Direction side, TextureAtlasSprite sprite, int color, int tint, float x1, float y1, float x2, float y2, float z, float u1, float v1, float u2, float v2, int luminosity) { diff --git a/src/main/java/net/minecraftforge/client/model/ModelDataManager.java b/src/main/java/net/minecraftforge/client/model/ModelDataManager.java index 5e1c61435d..ea6e8b554b 100644 --- a/src/main/java/net/minecraftforge/client/model/ModelDataManager.java +++ b/src/main/java/net/minecraftforge/client/model/ModelDataManager.java @@ -31,10 +31,10 @@ import javax.annotation.Nullable; import com.google.common.base.Preconditions; import net.minecraft.client.Minecraft; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.ChunkPos; -import net.minecraft.world.World; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.model.data.IModelData; import net.minecraftforge.event.world.ChunkEvent; @@ -45,13 +45,13 @@ import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus; @EventBusSubscriber(modid = "forge", bus = Bus.FORGE, value = Dist.CLIENT) public class ModelDataManager { - private static WeakReference currentWorld = new WeakReference<>(null); + private static WeakReference currentWorld = new WeakReference<>(null); private static final Map> needModelDataRefresh = new ConcurrentHashMap<>(); private static final Map> modelDataCache = new ConcurrentHashMap<>(); - private static void cleanCaches(World world) + private static void cleanCaches(Level world) { Preconditions.checkNotNull(world, "World must not be null"); Preconditions.checkArgument(world == Minecraft.getInstance().level, "Cannot use model data for a world other than the current client world"); @@ -63,17 +63,17 @@ public class ModelDataManager } } - public static void requestModelDataRefresh(TileEntity te) + public static void requestModelDataRefresh(BlockEntity te) { Preconditions.checkNotNull(te, "Tile entity must not be null"); - World world = te.getLevel(); + Level world = te.getLevel(); cleanCaches(world); needModelDataRefresh.computeIfAbsent(new ChunkPos(te.getBlockPos()), $ -> Collections.synchronizedSet(new HashSet<>())) .add(te.getBlockPos()); } - private static void refreshModelData(World world, ChunkPos chunk) + private static void refreshModelData(Level world, ChunkPos chunk) { cleanCaches(world); Set needUpdate = needModelDataRefresh.remove(chunk); @@ -83,7 +83,7 @@ public class ModelDataManager Map data = modelDataCache.computeIfAbsent(chunk, $ -> new ConcurrentHashMap<>()); for (BlockPos pos : needUpdate) { - TileEntity toUpdate = world.getBlockEntity(pos); + BlockEntity toUpdate = world.getBlockEntity(pos); if (toUpdate != null && !toUpdate.isRemoved()) { data.put(pos, toUpdate.getModelData()); @@ -106,12 +106,12 @@ public class ModelDataManager modelDataCache.remove(chunk); } - public static @Nullable IModelData getModelData(World world, BlockPos pos) + public static @Nullable IModelData getModelData(Level world, BlockPos pos) { return getModelData(world, new ChunkPos(pos)).get(pos); } - public static Map getModelData(World world, ChunkPos pos) + public static Map getModelData(Level world, ChunkPos pos) { Preconditions.checkArgument(world.isClientSide, "Cannot request model data for server world"); refreshModelData(world, pos); diff --git a/src/main/java/net/minecraftforge/client/model/ModelLoader.java b/src/main/java/net/minecraftforge/client/model/ModelLoader.java index cd7cfdf824..3f5cbcb963 100644 --- a/src/main/java/net/minecraftforge/client/model/ModelLoader.java +++ b/src/main/java/net/minecraftforge/client/model/ModelLoader.java @@ -23,15 +23,12 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.color.BlockColors; -import net.minecraft.client.renderer.model.*; -import net.minecraft.client.renderer.texture.MissingTextureSprite; +import net.minecraft.client.color.block.BlockColors; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.renderer.texture.AtlasTexture; -import net.minecraft.profiler.IProfiler; -import net.minecraft.resources.IResourceManager; -import net.minecraft.util.ResourceLocation; +import net.minecraft.client.renderer.texture.TextureAtlas; +import net.minecraft.util.profiling.ProfilerFiller; +import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.logging.ModelLoaderErrorMessage; import java.util.function.Function; @@ -44,11 +41,17 @@ import javax.annotation.Nullable; import static net.minecraftforge.fml.Logging.MODELLOADING; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.resources.model.Material; +import net.minecraft.client.resources.model.ModelBakery; +import net.minecraft.client.resources.model.ModelResourceLocation; +import net.minecraft.client.resources.model.UnbakedModel; + public final class ModelLoader extends ModelBakery { private static final Logger LOGGER = LogManager.getLogger(); private final Map loadingExceptions = Maps.newHashMap(); - private IUnbakedModel missingModel = null; + private UnbakedModel missingModel = null; private boolean isLoading = false; @@ -65,7 +68,7 @@ public final class ModelLoader extends ModelBakery return isLoading; } - public ModelLoader(IResourceManager manager, BlockColors colours, IProfiler profiler, int maxMipmapLevel) + public ModelLoader(ResourceManager manager, BlockColors colours, ProfilerFiller profiler, int maxMipmapLevel) { super(manager, colours, false); instance = this; @@ -107,7 +110,7 @@ public final class ModelLoader extends ModelBakery return new ResourceLocation(model.getNamespace(), model.getPath() + ".json"); } - protected IUnbakedModel getMissingModel() + protected UnbakedModel getMissingModel() { if (missingModel == null) { @@ -126,7 +129,7 @@ public final class ModelLoader extends ModelBakery /** * Use this if you don't care about the exception and want some model anyway. */ - public IUnbakedModel getModelOrMissing(ResourceLocation location) + public UnbakedModel getModelOrMissing(ResourceLocation location) { try { @@ -141,7 +144,7 @@ public final class ModelLoader extends ModelBakery /** * Use this if you want the model, but need to log the error. */ - public IUnbakedModel getModelOrLogError(ResourceLocation location, String error) + public UnbakedModel getModelOrLogError(ResourceLocation location, String error) { try { @@ -163,7 +166,7 @@ public final class ModelLoader extends ModelBakery { if (instance == null) { - instance = new RenderMaterial(AtlasTexture.LOCATION_BLOCKS, LOCATION).sprite(); + instance = new Material(TextureAtlas.LOCATION_BLOCKS, LOCATION).sprite(); } return instance; } @@ -228,9 +231,9 @@ public final class ModelLoader extends ModelBakery /** * Internal, do not use. */ - public void onPostBakeEvent(Map modelRegistry) + public void onPostBakeEvent(Map modelRegistry) { - IBakedModel missingModel = modelRegistry.get(MISSING_MODEL_LOCATION); + BakedModel missingModel = modelRegistry.get(MISSING_MODEL_LOCATION); for(Map.Entry entry : loadingExceptions.entrySet()) { // ignoring pure ResourceLocation arguments, all things we care about pass ModelResourceLocation @@ -238,7 +241,7 @@ public final class ModelLoader extends ModelBakery { LOGGER.debug(MODELLOADING, ()-> new ModelLoaderErrorMessage((ModelResourceLocation)entry.getKey(), entry.getValue())); final ModelResourceLocation location = (ModelResourceLocation)entry.getKey(); - final IBakedModel model = modelRegistry.get(location); + final BakedModel model = modelRegistry.get(location); if(model == null) { modelRegistry.put(location, missingModel); @@ -258,17 +261,17 @@ public final class ModelLoader extends ModelBakery } */ - private static final Function DEFAULT_MODEL_GETTER = (rl) -> ModelLoader.instance().getModelOrMissing(rl); + private static final Function DEFAULT_MODEL_GETTER = (rl) -> ModelLoader.instance().getModelOrMissing(rl); /** * Get the default texture getter the models will be baked with. */ - public static Function defaultTextureGetter() + public static Function defaultTextureGetter() { - return RenderMaterial::sprite; + return Material::sprite; } - public static Function defaultModelGetter() + public static Function defaultModelGetter() { return DEFAULT_MODEL_GETTER; } diff --git a/src/main/java/net/minecraftforge/client/model/ModelLoaderRegistry.java b/src/main/java/net/minecraftforge/client/model/ModelLoaderRegistry.java index 55201af2d6..3bce50652b 100644 --- a/src/main/java/net/minecraftforge/client/model/ModelLoaderRegistry.java +++ b/src/main/java/net/minecraftforge/client/model/ModelLoaderRegistry.java @@ -26,17 +26,15 @@ import com.google.common.collect.Sets; import com.google.gson.*; import com.mojang.datafixers.util.Pair; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.model.*; -import net.minecraft.client.renderer.texture.AtlasTexture; -import net.minecraft.client.renderer.texture.MissingTextureSprite; +import net.minecraft.client.renderer.texture.TextureAtlas; +import net.minecraft.client.renderer.texture.MissingTextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.resources.IReloadableResourceManager; -import net.minecraft.resources.IResourceManager; -import net.minecraft.util.Direction; -import net.minecraft.util.JSONUtils; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.vector.TransformationMatrix; -import net.minecraftforge.client.event.ModelRegistryEvent; +import net.minecraft.server.packs.resources.ReloadableResourceManager; +import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.core.Direction; +import net.minecraft.util.GsonHelper; +import net.minecraft.resources.ResourceLocation; +import com.mojang.math.Transformation; import net.minecraftforge.client.model.geometry.IModelGeometry; import net.minecraftforge.client.model.geometry.ISimpleModelGeometry; import net.minecraftforge.client.model.obj.OBJLoader; @@ -50,6 +48,20 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; +import net.minecraft.client.renderer.block.model.BlockElement; +import net.minecraft.client.renderer.block.model.BlockElementFace; +import net.minecraft.client.renderer.block.model.BlockFaceUV; +import net.minecraft.client.renderer.block.model.BlockModel; +import net.minecraft.client.renderer.block.model.ItemModelGenerator; +import net.minecraft.client.renderer.block.model.ItemOverride; +import net.minecraft.client.renderer.block.model.ItemTransform; +import net.minecraft.client.renderer.block.model.ItemTransforms; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.resources.model.Material; +import net.minecraft.client.resources.model.ModelBakery; +import net.minecraft.client.resources.model.ModelState; +import net.minecraft.client.resources.model.UnbakedModel; + /** * Central hub for custom model loaders. */ @@ -102,7 +114,7 @@ public class ModelLoaderRegistry synchronized(loaders) { loaders.put(id, loader); - ((IReloadableResourceManager) Minecraft.getInstance().getResourceManager()).registerReloadListener(loader); + ((ReloadableResourceManager) Minecraft.getInstance().getResourceManager()).registerReloadListener(loader); } } @@ -133,7 +145,7 @@ public class ModelLoaderRegistry return null; } - ResourceLocation loader = new ResourceLocation(JSONUtils.getAsString(object,"loader")); + ResourceLocation loader = new ResourceLocation(GsonHelper.getAsString(object,"loader")); return getModel(loader, deserializationContext, object); } @@ -153,7 +165,7 @@ public class ModelLoaderRegistry private static final Pattern FILESYSTEM_PATH_TO_RESLOC = Pattern.compile("(?:.*[\\\\/]assets[\\\\/](?[a-z_-]+)[\\\\/]textures[\\\\/])?(?[a-z_\\\\/-]+)\\.png"); - public static RenderMaterial resolveTexture(@Nullable String tex, IModelConfiguration owner) + public static Material resolveTexture(@Nullable String tex, IModelConfiguration owner) { if (tex == null) return blockMaterial(WHITE_TEXTURE); @@ -176,19 +188,19 @@ public class ModelLoaderRegistry } @SuppressWarnings("deprecation") - public static RenderMaterial blockMaterial(String location) + public static Material blockMaterial(String location) { - return new RenderMaterial(AtlasTexture.LOCATION_BLOCKS, new ResourceLocation(location)); + return new Material(TextureAtlas.LOCATION_BLOCKS, new ResourceLocation(location)); } @SuppressWarnings("deprecation") - public static RenderMaterial blockMaterial(ResourceLocation location) + public static Material blockMaterial(ResourceLocation location) { - return new RenderMaterial(AtlasTexture.LOCATION_BLOCKS, location); + return new Material(TextureAtlas.LOCATION_BLOCKS, location); } @Nullable - public static IModelTransform deserializeModelTransforms(JsonDeserializationContext deserializationContext, JsonObject modelData) + public static ModelState deserializeModelTransforms(JsonDeserializationContext deserializationContext, JsonObject modelData) { if (!modelData.has("transform")) return null; @@ -196,14 +208,14 @@ public class ModelLoaderRegistry return deserializeTransform(deserializationContext, modelData.get("transform")).orElse(null); } - public static Optional deserializeTransform(JsonDeserializationContext context, JsonElement transformData) + public static Optional deserializeTransform(JsonDeserializationContext context, JsonElement transformData) { if (!transformData.isJsonObject()) { try { - TransformationMatrix base = context.deserialize(transformData, TransformationMatrix.class); - return Optional.of(new SimpleModelTransform(ImmutableMap.of(), base.blockCenterToCorner())); + Transformation base = context.deserialize(transformData, Transformation.class); + return Optional.of(new SimpleModelState(ImmutableMap.of(), base.blockCenterToCorner())); } catch (JsonParseException e) { @@ -213,20 +225,20 @@ public class ModelLoaderRegistry else { JsonObject transform = transformData.getAsJsonObject(); - EnumMap transforms = Maps.newEnumMap(ItemCameraTransforms.TransformType.class); + EnumMap transforms = Maps.newEnumMap(ItemTransforms.TransformType.class); - deserializeTRSR(context, transforms, transform, "thirdperson", ItemCameraTransforms.TransformType.THIRD_PERSON_RIGHT_HAND); - deserializeTRSR(context, transforms, transform, "thirdperson_righthand", ItemCameraTransforms.TransformType.THIRD_PERSON_RIGHT_HAND); - deserializeTRSR(context, transforms, transform, "thirdperson_lefthand", ItemCameraTransforms.TransformType.THIRD_PERSON_LEFT_HAND); + deserializeTRSR(context, transforms, transform, "thirdperson", ItemTransforms.TransformType.THIRD_PERSON_RIGHT_HAND); + deserializeTRSR(context, transforms, transform, "thirdperson_righthand", ItemTransforms.TransformType.THIRD_PERSON_RIGHT_HAND); + deserializeTRSR(context, transforms, transform, "thirdperson_lefthand", ItemTransforms.TransformType.THIRD_PERSON_LEFT_HAND); - deserializeTRSR(context, transforms, transform, "firstperson", ItemCameraTransforms.TransformType.FIRST_PERSON_RIGHT_HAND); - deserializeTRSR(context, transforms, transform, "firstperson_righthand", ItemCameraTransforms.TransformType.FIRST_PERSON_RIGHT_HAND); - deserializeTRSR(context, transforms, transform, "firstperson_lefthand", ItemCameraTransforms.TransformType.FIRST_PERSON_LEFT_HAND); + deserializeTRSR(context, transforms, transform, "firstperson", ItemTransforms.TransformType.FIRST_PERSON_RIGHT_HAND); + deserializeTRSR(context, transforms, transform, "firstperson_righthand", ItemTransforms.TransformType.FIRST_PERSON_RIGHT_HAND); + deserializeTRSR(context, transforms, transform, "firstperson_lefthand", ItemTransforms.TransformType.FIRST_PERSON_LEFT_HAND); - deserializeTRSR(context, transforms, transform, "head", ItemCameraTransforms.TransformType.HEAD); - deserializeTRSR(context, transforms, transform, "gui", ItemCameraTransforms.TransformType.GUI); - deserializeTRSR(context, transforms, transform, "ground", ItemCameraTransforms.TransformType.GROUND); - deserializeTRSR(context, transforms, transform, "fixed", ItemCameraTransforms.TransformType.FIXED); + deserializeTRSR(context, transforms, transform, "head", ItemTransforms.TransformType.HEAD); + deserializeTRSR(context, transforms, transform, "gui", ItemTransforms.TransformType.GUI); + deserializeTRSR(context, transforms, transform, "ground", ItemTransforms.TransformType.GROUND); + deserializeTRSR(context, transforms, transform, "fixed", ItemTransforms.TransformType.FIXED); int k = transform.entrySet().size(); if(transform.has("matrix")) k--; @@ -239,32 +251,32 @@ public class ModelLoaderRegistry { throw new JsonParseException("transform: allowed keys: 'thirdperson', 'firstperson', 'gui', 'head', 'matrix', 'translation', 'rotation', 'scale', 'post-rotation', 'origin'"); } - TransformationMatrix base = TransformationMatrix.identity(); + Transformation base = Transformation.identity(); if(!transform.entrySet().isEmpty()) { - base = context.deserialize(transform, TransformationMatrix.class); + base = context.deserialize(transform, Transformation.class); } - IModelTransform state = new SimpleModelTransform(Maps.immutableEnumMap(transforms), base); + ModelState state = new SimpleModelState(Maps.immutableEnumMap(transforms), base); return Optional.of(state); } } - private static void deserializeTRSR(JsonDeserializationContext context, EnumMap transforms, JsonObject transform, String name, ItemCameraTransforms.TransformType itemCameraTransform) + private static void deserializeTRSR(JsonDeserializationContext context, EnumMap transforms, JsonObject transform, String name, ItemTransforms.TransformType itemCameraTransform) { if(transform.has(name)) { - TransformationMatrix t = context.deserialize(transform.remove(name), TransformationMatrix.class); + Transformation t = context.deserialize(transform.remove(name), Transformation.class); transforms.put(itemCameraTransform, t.blockCenterToCorner()); } } - public static IBakedModel bakeHelper(BlockModel blockModel, ModelBakery modelBakery, BlockModel otherModel, Function spriteGetter, IModelTransform modelTransform, ResourceLocation modelLocation, boolean guiLight3d) + public static BakedModel bakeHelper(BlockModel blockModel, ModelBakery modelBakery, BlockModel otherModel, Function spriteGetter, ModelState modelTransform, ResourceLocation modelLocation, boolean guiLight3d) { - IBakedModel model; + BakedModel model; IModelGeometry customModel = blockModel.customData.getCustomGeometry(); - IModelTransform customModelState = blockModel.customData.getCustomModelState(); + ModelState customModelState = blockModel.customData.getCustomModelState(); if (customModelState != null) - modelTransform = new ModelTransformComposition(modelTransform, customModelState, modelTransform.isUvLocked()); + modelTransform = new CompositeModelState(modelTransform, customModelState, modelTransform.isUvLocked()); if (customModel != null) model = customModel.bake(blockModel.customData, modelBakery, spriteGetter, modelTransform, blockModel.getOverrides(modelBakery, otherModel, spriteGetter), modelLocation); @@ -288,19 +300,19 @@ public class ModelLoaderRegistry public static class VanillaProxy implements ISimpleModelGeometry { - private final List elements; + private final List elements; - public VanillaProxy(List list) + public VanillaProxy(List list) { this.elements = list; } @Override - public void addQuads(IModelConfiguration owner, IModelBuilder modelBuilder, ModelBakery bakery, Function spriteGetter, IModelTransform modelTransform, ResourceLocation modelLocation) + public void addQuads(IModelConfiguration owner, IModelBuilder modelBuilder, ModelBakery bakery, Function spriteGetter, ModelState modelTransform, ResourceLocation modelLocation) { - for(BlockPart blockpart : elements) { + for(BlockElement blockpart : elements) { for(Direction direction : blockpart.faces.keySet()) { - BlockPartFace blockpartface = blockpart.faces.get(direction); + BlockElementFace blockpartface = blockpart.faces.get(direction); TextureAtlasSprite textureatlassprite1 = spriteGetter.apply(owner.resolveTexture(blockpartface.texture)); if (blockpartface.cullForDirection == null) { modelBuilder.addGeneralQuad(BlockModel.makeBakedQuad(blockpart, blockpartface, textureatlassprite1, direction, modelTransform, modelLocation)); @@ -314,14 +326,14 @@ public class ModelLoaderRegistry } @Override - public Collection getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors) + public Collection getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors) { - Set textures = Sets.newHashSet(); + Set textures = Sets.newHashSet(); - for(BlockPart part : elements) { - for(BlockPartFace face : part.faces.values()) { - RenderMaterial texture = owner.resolveTexture(face.texture); - if (Objects.equals(texture, MissingTextureSprite.getLocation().toString())) { + for(BlockElement part : elements) { + for(BlockElementFace face : part.faces.values()) { + Material texture = owner.resolveTexture(face.texture); + if (Objects.equals(texture, MissingTextureAtlasSprite.getLocation().toString())) { missingTextureErrors.add(Pair.of(face.texture, owner.getModelName())); } @@ -341,7 +353,7 @@ public class ModelLoaderRegistry } @Override - public void onResourceManagerReload(IResourceManager resourceManager) + public void onResourceManagerReload(ResourceManager resourceManager) { } @@ -349,15 +361,15 @@ public class ModelLoaderRegistry @Override public VanillaProxy read(JsonDeserializationContext deserializationContext, JsonObject modelContents) { - List list = this.getModelElements(deserializationContext, modelContents); + List list = this.getModelElements(deserializationContext, modelContents); return new VanillaProxy(list); } - private List getModelElements(JsonDeserializationContext deserializationContext, JsonObject object) { - List list = Lists.newArrayList(); + private List getModelElements(JsonDeserializationContext deserializationContext, JsonObject object) { + List list = Lists.newArrayList(); if (object.has("elements")) { - for(JsonElement jsonelement : JSONUtils.getAsJsonArray(object, "elements")) { - list.add(deserializationContext.deserialize(jsonelement, BlockPart.class)); + for(JsonElement jsonelement : GsonHelper.getAsJsonArray(object, "elements")) { + list.add(deserializationContext.deserialize(jsonelement, BlockElement.class)); } } @@ -370,13 +382,13 @@ public class ModelLoaderRegistry { public static final Gson INSTANCE = (new GsonBuilder()) .registerTypeAdapter(BlockModel.class, new ExpandedBlockModelDeserializer()) - .registerTypeAdapter(BlockPart.class, new BlockPart.Deserializer()) - .registerTypeAdapter(BlockPartFace.class, new BlockPartFace.Deserializer()) + .registerTypeAdapter(BlockElement.class, new BlockElement.Deserializer()) + .registerTypeAdapter(BlockElementFace.class, new BlockElementFace.Deserializer()) .registerTypeAdapter(BlockFaceUV.class, new BlockFaceUV.Deserializer()) - .registerTypeAdapter(ItemTransformVec3f.class, new ItemTransformVec3f.Deserializer()) - .registerTypeAdapter(ItemCameraTransforms.class, new ItemCameraTransforms.Deserializer()) + .registerTypeAdapter(ItemTransform.class, new ItemTransform.Deserializer()) + .registerTypeAdapter(ItemTransforms.class, new ItemTransforms.Deserializer()) .registerTypeAdapter(ItemOverride.class, new ItemOverride.Deserializer()) - .registerTypeAdapter(TransformationMatrix.class, new TransformationHelper.Deserializer()) + .registerTypeAdapter(Transformation.class, new TransformationHelper.Deserializer()) .create(); public BlockModel deserialize(JsonElement element, Type targetType, JsonDeserializationContext deserializationContext) throws JsonParseException { @@ -384,13 +396,13 @@ public class ModelLoaderRegistry JsonObject jsonobject = element.getAsJsonObject(); IModelGeometry geometry = deserializeGeometry(deserializationContext, jsonobject); - List elements = model.getElements(); + List elements = model.getElements(); if (geometry != null) { elements.clear(); model.customData.setCustomGeometry(geometry); } - IModelTransform modelState = deserializeModelTransforms(deserializationContext, jsonobject); + ModelState modelState = deserializeModelTransforms(deserializationContext, jsonobject); if (modelState != null) { model.customData.setCustomModelState(modelState); @@ -398,7 +410,7 @@ public class ModelLoaderRegistry if (jsonobject.has("visibility")) { - JsonObject visibility = JSONUtils.getAsJsonObject(jsonobject, "visibility"); + JsonObject visibility = GsonHelper.getAsJsonObject(jsonobject, "visibility"); for(Map.Entry part : visibility.entrySet()) { model.customData.visibilityData.setVisibilityState(part.getKey(), part.getValue().getAsBoolean()); diff --git a/src/main/java/net/minecraftforge/client/model/MultiLayerModel.java b/src/main/java/net/minecraftforge/client/model/MultiLayerModel.java index a3b2058ae2..6991b087d9 100644 --- a/src/main/java/net/minecraftforge/client/model/MultiLayerModel.java +++ b/src/main/java/net/minecraftforge/client/model/MultiLayerModel.java @@ -27,20 +27,18 @@ import javax.annotation.Nullable; import com.google.common.collect.*; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonObject; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.datafixers.util.Pair; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.renderer.RenderType; -import net.minecraft.util.math.vector.TransformationMatrix; -import net.minecraft.client.renderer.model.*; -import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; +import com.mojang.math.Transformation; +import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.item.ItemStack; -import net.minecraft.resources.IResourceManager; -import net.minecraft.util.Direction; -import net.minecraft.util.JSONUtils; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.client.ForgeRenderTypes; +import net.minecraft.world.item.ItemStack; +import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.core.Direction; +import net.minecraft.util.GsonHelper; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.client.model.data.IDynamicBakedModel; @@ -52,6 +50,15 @@ import org.apache.logging.log4j.Logger; import java.util.function.Function; import java.util.stream.Collectors; +import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.renderer.block.model.BlockModel; +import net.minecraft.client.renderer.block.model.ItemOverrides; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.resources.model.Material; +import net.minecraft.client.resources.model.ModelBakery; +import net.minecraft.client.resources.model.ModelState; +import net.minecraft.client.resources.model.UnbakedModel; + /** * A model that can be rendered in multiple {@link RenderType}. */ @@ -59,35 +66,35 @@ public final class MultiLayerModel implements IModelGeometry { private static final Logger LOGGER = LogManager.getLogger(); - private final ImmutableList> models; + private final ImmutableList> models; private final boolean convertRenderTypes; - public MultiLayerModel(Map models) + public MultiLayerModel(Map models) { this(models.entrySet().stream().map(kv -> Pair.of(kv.getKey(), kv.getValue())).collect(ImmutableList.toImmutableList()), true); } - public MultiLayerModel(ImmutableList> models, boolean convertRenderTypes) + public MultiLayerModel(ImmutableList> models, boolean convertRenderTypes) { this.models = models; this.convertRenderTypes = convertRenderTypes; } @Override - public Collection getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors) + public Collection getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors) { - Set materials = Sets.newHashSet(); + Set materials = Sets.newHashSet(); materials.add(owner.resolveTexture("particle")); - for (Pair m : models) + for (Pair m : models) materials.addAll(m.getSecond().getMaterials(modelGetter, missingTextureErrors)); return materials; } - private static ImmutableList> buildModels(List> models, IModelTransform modelTransform, - ModelBakery bakery, Function spriteGetter, ResourceLocation modelLocation) + private static ImmutableList> buildModels(List> models, ModelState modelTransform, + ModelBakery bakery, Function spriteGetter, ResourceLocation modelLocation) { - ImmutableList.Builder> builder = ImmutableList.builder(); - for(Pair entry : models) + ImmutableList.Builder> builder = ImmutableList.builder(); + for(Pair entry : models) { builder.add(Pair.of(entry.getFirst(), entry.getSecond().bake(bakery, spriteGetter, modelTransform, modelLocation))); } @@ -95,33 +102,33 @@ public final class MultiLayerModel implements IModelGeometry } @Override - public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) + public BakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function spriteGetter, ModelState modelTransform, ItemOverrides overrides, ResourceLocation modelLocation) { return new MultiLayerBakedModel( owner.useSmoothLighting(), owner.isShadedInGui(), owner.isSideLit(), spriteGetter.apply(owner.resolveTexture("particle")), overrides, convertRenderTypes, buildModels(models, modelTransform, bakery, spriteGetter, modelLocation), - PerspectiveMapWrapper.getTransforms(new ModelTransformComposition(owner.getCombinedTransform(), modelTransform)) + PerspectiveMapWrapper.getTransforms(new CompositeModelState(owner.getCombinedTransform(), modelTransform)) ); } private static final class MultiLayerBakedModel implements IDynamicBakedModel { - private final ImmutableMap models; - private final ImmutableMap cameraTransforms; + private final ImmutableMap models; + private final ImmutableMap cameraTransforms; protected final boolean ambientOcclusion; protected final boolean gui3d; protected final boolean isSideLit; protected final TextureAtlasSprite particle; - protected final ItemOverrideList overrides; + protected final ItemOverrides overrides; private final List missing = ImmutableList.of(); private final boolean convertRenderTypes; - private final List> itemLayers; + private final List> itemLayers; public MultiLayerBakedModel( - boolean ambientOcclusion, boolean isGui3d, boolean isSideLit, TextureAtlasSprite particle, ItemOverrideList overrides, - boolean convertRenderTypes, List> models, - ImmutableMap cameraTransforms) + boolean ambientOcclusion, boolean isGui3d, boolean isSideLit, TextureAtlasSprite particle, ItemOverrides overrides, + boolean convertRenderTypes, List> models, + ImmutableMap cameraTransforms) { this.isSideLit = isSideLit; this.cameraTransforms = cameraTransforms; @@ -146,7 +153,7 @@ public final class MultiLayerModel implements IModelGeometry if (layer == null) { ImmutableList.Builder builder = ImmutableList.builder(); - for (IBakedModel model : models.values()) + for (BakedModel model : models.values()) { builder.addAll(model.getQuads(state, side, rand, extraData)); } @@ -204,15 +211,15 @@ public final class MultiLayerModel implements IModelGeometry } @Override - public IBakedModel handlePerspective(TransformType cameraTransformType, MatrixStack mat) + public BakedModel handlePerspective(TransformType cameraTransformType, PoseStack poseStack) { - return PerspectiveMapWrapper.handlePerspective(this, cameraTransforms, cameraTransformType, mat); + return PerspectiveMapWrapper.handlePerspective(this, cameraTransforms, cameraTransformType, poseStack); } @Override - public ItemOverrideList getOverrides() + public ItemOverrides getOverrides() { - return ItemOverrideList.EMPTY; + return ItemOverrides.EMPTY; } @Override @@ -222,18 +229,19 @@ public final class MultiLayerModel implements IModelGeometry } @Override - public List> getLayerModels(ItemStack itemStack, boolean fabulous) + public List> getLayerModels(ItemStack itemStack, boolean fabulous) { return itemLayers; } public static BiMap ITEM_RENDER_TYPE_MAPPING = HashBiMap.create(); - static { + // TODO ForgeRenderTypes +/* static { ITEM_RENDER_TYPE_MAPPING.put(RenderType.solid(), ForgeRenderTypes.ITEM_LAYERED_SOLID.get()); ITEM_RENDER_TYPE_MAPPING.put(RenderType.cutout(), ForgeRenderTypes.ITEM_LAYERED_CUTOUT.get()); ITEM_RENDER_TYPE_MAPPING.put(RenderType.cutoutMipped(), ForgeRenderTypes.ITEM_LAYERED_CUTOUT_MIPPED.get()); ITEM_RENDER_TYPE_MAPPING.put(RenderType.translucent(), ForgeRenderTypes.ITEM_LAYERED_TRANSLUCENT.get()); - } + }*/ } public static final class Loader implements IModelLoader @@ -251,7 +259,7 @@ public final class MultiLayerModel implements IModelGeometry private Loader() {} @Override - public void onResourceManagerReload(IResourceManager resourceManager) + public void onResourceManagerReload(ResourceManager resourceManager) { } @@ -259,17 +267,17 @@ public final class MultiLayerModel implements IModelGeometry @Override public MultiLayerModel read(JsonDeserializationContext deserializationContext, JsonObject modelContents) { - ImmutableList.Builder> builder = ImmutableList.builder(); - JsonObject layersObject = JSONUtils.getAsJsonObject(modelContents, "layers"); + ImmutableList.Builder> builder = ImmutableList.builder(); + JsonObject layersObject = GsonHelper.getAsJsonObject(modelContents, "layers"); for(Map.Entry layer : BLOCK_LAYERS.entrySet()) // block layers { String layerName = layer.getKey(); // mc overrides toString to return the ID for the layer if(layersObject.has(layerName)) { - builder.add(Pair.of(layer.getValue(), deserializationContext.deserialize(JSONUtils.getAsJsonObject(layersObject, layerName), BlockModel.class))); + builder.add(Pair.of(layer.getValue(), deserializationContext.deserialize(GsonHelper.getAsJsonObject(layersObject, layerName), BlockModel.class))); } } - boolean convertRenderTypes = JSONUtils.getAsBoolean(modelContents, "convert_render_types", true); + boolean convertRenderTypes = GsonHelper.getAsBoolean(modelContents, "convert_render_types", true); return new MultiLayerModel(builder.build(), convertRenderTypes); } } diff --git a/src/main/java/net/minecraftforge/client/model/PerspectiveMapWrapper.java b/src/main/java/net/minecraftforge/client/model/PerspectiveMapWrapper.java index 065d8a408c..b97e852228 100644 --- a/src/main/java/net/minecraftforge/client/model/PerspectiveMapWrapper.java +++ b/src/main/java/net/minecraftforge/client/model/PerspectiveMapWrapper.java @@ -24,16 +24,14 @@ import java.util.Random; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import com.mojang.blaze3d.matrix.MatrixStack; -import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.model.*; +import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.entity.LivingEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Direction; -import net.minecraft.util.math.vector.TransformationMatrix; -import net.minecraft.world.World; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.core.Direction; +import com.mojang.math.Transformation; import net.minecraftforge.client.model.data.IDynamicBakedModel; import net.minecraftforge.client.model.data.IModelData; import net.minecraftforge.common.model.TransformationHelper; @@ -41,29 +39,36 @@ import net.minecraftforge.common.model.TransformationHelper; import javax.annotation.Nullable; import java.util.List; +import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.renderer.block.model.ItemOverride; +import net.minecraft.client.renderer.block.model.ItemOverrides; +import net.minecraft.client.renderer.block.model.ItemTransforms; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.resources.model.ModelState; + public class PerspectiveMapWrapper implements IDynamicBakedModel { - private final IBakedModel parent; - private final ImmutableMap transforms; + private final BakedModel parent; + private final ImmutableMap transforms; private final OverrideListWrapper overrides = new OverrideListWrapper(); - public PerspectiveMapWrapper(IBakedModel parent, ImmutableMap transforms) + public PerspectiveMapWrapper(BakedModel parent, ImmutableMap transforms) { this.parent = parent; this.transforms = transforms; } - public PerspectiveMapWrapper(IBakedModel parent, IModelTransform state) + public PerspectiveMapWrapper(BakedModel parent, ModelState state) { this(parent, getTransforms(state)); } - public static ImmutableMap getTransforms(IModelTransform state) + public static ImmutableMap getTransforms(ModelState state) { - EnumMap map = new EnumMap<>(ItemCameraTransforms.TransformType.class); - for(ItemCameraTransforms.TransformType type : ItemCameraTransforms.TransformType.values()) + EnumMap map = new EnumMap<>(ItemTransforms.TransformType.class); + for(ItemTransforms.TransformType type : ItemTransforms.TransformType.values()) { - TransformationMatrix tr = state.getPartTransformation(type); + Transformation tr = state.getPartTransformation(type); if(!tr.isIdentity()) { map.put(type, tr); @@ -73,10 +78,10 @@ public class PerspectiveMapWrapper implements IDynamicBakedModel } @SuppressWarnings("deprecation") - public static ImmutableMap getTransforms(ItemCameraTransforms transforms) + public static ImmutableMap getTransforms(ItemTransforms transforms) { - EnumMap map = new EnumMap<>(ItemCameraTransforms.TransformType.class); - for(ItemCameraTransforms.TransformType type : ItemCameraTransforms.TransformType.values()) + EnumMap map = new EnumMap<>(ItemTransforms.TransformType.class); + for(ItemTransforms.TransformType type : ItemTransforms.TransformType.values()) { if (transforms.hasTransform(type)) { @@ -87,12 +92,12 @@ public class PerspectiveMapWrapper implements IDynamicBakedModel } @SuppressWarnings("deprecation") - public static ImmutableMap getTransformsWithFallback(IModelTransform state, ItemCameraTransforms transforms) + public static ImmutableMap getTransformsWithFallback(ModelState state, ItemTransforms transforms) { - EnumMap map = new EnumMap<>(ItemCameraTransforms.TransformType.class); - for(ItemCameraTransforms.TransformType type : ItemCameraTransforms.TransformType.values()) + EnumMap map = new EnumMap<>(ItemTransforms.TransformType.class); + for(ItemTransforms.TransformType type : ItemTransforms.TransformType.values()) { - TransformationMatrix tr = state.getPartTransformation(type); + Transformation tr = state.getPartTransformation(type); if(!tr.isIdentity()) { map.put(type, tr); @@ -105,9 +110,9 @@ public class PerspectiveMapWrapper implements IDynamicBakedModel return ImmutableMap.copyOf(map); } - public static IBakedModel handlePerspective(IBakedModel model, ImmutableMap transforms, ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat) + public static BakedModel handlePerspective(BakedModel model, ImmutableMap transforms, ItemTransforms.TransformType cameraTransformType, PoseStack mat) { - TransformationMatrix tr = transforms.getOrDefault(cameraTransformType, TransformationMatrix.identity()); + Transformation tr = transforms.getOrDefault(cameraTransformType, Transformation.identity()); if (!tr.isIdentity()) { tr.push(mat); @@ -115,9 +120,9 @@ public class PerspectiveMapWrapper implements IDynamicBakedModel return model; } - public static IBakedModel handlePerspective(IBakedModel model, IModelTransform state, ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat) + public static BakedModel handlePerspective(BakedModel model, ModelState state, ItemTransforms.TransformType cameraTransformType, PoseStack mat) { - TransformationMatrix tr = state.getPartTransformation(cameraTransformType); + Transformation tr = state.getPartTransformation(cameraTransformType); if (!tr.isIdentity()) { tr.push(mat); @@ -132,14 +137,14 @@ public class PerspectiveMapWrapper implements IDynamicBakedModel @Override public boolean isCustomRenderer() { return parent.isCustomRenderer(); } @Override public TextureAtlasSprite getParticleIcon() { return parent.getParticleIcon(); } @SuppressWarnings("deprecation") - @Override public ItemCameraTransforms getTransforms() { return parent.getTransforms(); } + @Override public ItemTransforms getTransforms() { return parent.getTransforms(); } @Override public List getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand, IModelData extraData) { return parent.getQuads(state, side, rand, extraData); } @Override - public ItemOverrideList getOverrides() + public ItemOverrides getOverrides() { return overrides; } @@ -151,12 +156,12 @@ public class PerspectiveMapWrapper implements IDynamicBakedModel } @Override - public IBakedModel handlePerspective(ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat) + public BakedModel handlePerspective(ItemTransforms.TransformType cameraTransformType, PoseStack poseStack) { - return handlePerspective(this, transforms, cameraTransformType, mat); + return handlePerspective(this, transforms, cameraTransformType, poseStack); } - private class OverrideListWrapper extends ItemOverrideList + private class OverrideListWrapper extends ItemOverrides { public OverrideListWrapper() { @@ -165,14 +170,14 @@ public class PerspectiveMapWrapper implements IDynamicBakedModel @Nullable @Override - public IBakedModel resolve(IBakedModel model, ItemStack stack, @Nullable ClientWorld worldIn, @Nullable LivingEntity entityIn) + public BakedModel resolve(BakedModel model, ItemStack stack, @Nullable ClientLevel worldIn, @Nullable LivingEntity entityIn, int seed) { - model = parent.getOverrides().resolve(parent, stack, worldIn, entityIn); + model = parent.getOverrides().resolve(parent, stack, worldIn, entityIn, seed); return new PerspectiveMapWrapper(model, transforms); } @Override - public ImmutableList getOverrides() + public ImmutableList getOverrides() { return parent.getOverrides().getOverrides(); } diff --git a/src/main/java/net/minecraftforge/client/model/QuadTransformer.java b/src/main/java/net/minecraftforge/client/model/QuadTransformer.java index 792c4f98cf..2d501411af 100644 --- a/src/main/java/net/minecraftforge/client/model/QuadTransformer.java +++ b/src/main/java/net/minecraftforge/client/model/QuadTransformer.java @@ -25,28 +25,28 @@ import java.util.List; import com.google.common.collect.Lists; -import net.minecraft.util.math.vector.TransformationMatrix; -import net.minecraft.util.math.vector.Vector3f; -import net.minecraft.util.math.vector.Vector4f; -import net.minecraft.client.renderer.model.BakedQuad; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.client.renderer.vertex.VertexFormat; -import net.minecraft.client.renderer.vertex.VertexFormatElement; +import com.mojang.math.Transformation; +import com.mojang.math.Vector3f; +import com.mojang.math.Vector4f; +import net.minecraft.client.renderer.block.model.BakedQuad; +import com.mojang.blaze3d.vertex.DefaultVertexFormat; +import com.mojang.blaze3d.vertex.VertexFormat; +import com.mojang.blaze3d.vertex.VertexFormatElement; public class QuadTransformer { - private static final int POSITION = findPositionOffset(DefaultVertexFormats.BLOCK); - private static final int NORMAL = findNormalOffset(DefaultVertexFormats.BLOCK); - private final TransformationMatrix transform; + private static final int POSITION = findPositionOffset(DefaultVertexFormat.BLOCK); + private static final int NORMAL = findNormalOffset(DefaultVertexFormat.BLOCK); + private final Transformation transform; - public QuadTransformer(TransformationMatrix transform) + public QuadTransformer(Transformation transform) { this.transform = transform; } private void processVertices(int[] inData, int[] outData) { - int stride = DefaultVertexFormats.BLOCK.getVertexSize(); + int stride = DefaultVertexFormat.BLOCK.getVertexSize(); int count = (inData.length * 4) / stride; for (int i=0;i { private final BlockModel baseModel; - private final ImmutableMap perspectives; + private final ImmutableMap perspectives; - public SeparatePerspectiveModel(BlockModel baseModel, ImmutableMap perspectives) + public SeparatePerspectiveModel(BlockModel baseModel, ImmutableMap perspectives) { this.baseModel = baseModel; this.perspectives = perspectives; } @Override - public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) + public net.minecraft.client.resources.model.BakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function spriteGetter, ModelState modelTransform, ItemOverrides overrides, ResourceLocation modelLocation) { return new BakedModel( owner.useSmoothLighting(), owner.isShadedInGui(), owner.isSideLit(), @@ -65,26 +77,26 @@ public class SeparatePerspectiveModel implements IModelGeometry getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors) + public Collection getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors) { - Set textures = Sets.newHashSet(); + Set textures = Sets.newHashSet(); textures.addAll(baseModel.getMaterials(modelGetter, missingTextureErrors)); for(BlockModel model : perspectives.values()) textures.addAll(model.getMaterials(modelGetter, missingTextureErrors)); return textures; } - public static class BakedModel implements IBakedModel + public static class BakedModel implements net.minecraft.client.resources.model.BakedModel { private final boolean isAmbientOcclusion; private final boolean isGui3d; private final boolean isSideLit; private final TextureAtlasSprite particle; - private final ItemOverrideList overrides; - private final IBakedModel baseModel; - private final ImmutableMap perspectives; + private final ItemOverrides overrides; + private final net.minecraft.client.resources.model.BakedModel baseModel; + private final ImmutableMap perspectives; - public BakedModel(boolean isAmbientOcclusion, boolean isGui3d, boolean isSideLit, TextureAtlasSprite particle, ItemOverrideList overrides, IBakedModel baseModel, ImmutableMap perspectives) + public BakedModel(boolean isAmbientOcclusion, boolean isGui3d, boolean isSideLit, TextureAtlasSprite particle, ItemOverrides overrides, net.minecraft.client.resources.model.BakedModel baseModel, ImmutableMap perspectives) { this.isAmbientOcclusion = isAmbientOcclusion; this.isGui3d = isGui3d; @@ -132,7 +144,7 @@ public class SeparatePerspectiveModel implements IModelGeometry PERSPECTIVES = ImmutableBiMap.builder() - .put("none", ItemCameraTransforms.TransformType.NONE) - .put("third_person_left_hand", ItemCameraTransforms.TransformType.THIRD_PERSON_LEFT_HAND) - .put("third_person_right_hand", ItemCameraTransforms.TransformType.THIRD_PERSON_RIGHT_HAND) - .put("first_person_left_hand", ItemCameraTransforms.TransformType.FIRST_PERSON_LEFT_HAND) - .put("first_person_right_hand", ItemCameraTransforms.TransformType.FIRST_PERSON_RIGHT_HAND) - .put("head", ItemCameraTransforms.TransformType.HEAD) - .put("gui", ItemCameraTransforms.TransformType.GUI) - .put("ground", ItemCameraTransforms.TransformType.GROUND) - .put("fixed", ItemCameraTransforms.TransformType.FIXED) + public static final ImmutableBiMap PERSPECTIVES = ImmutableBiMap.builder() + .put("none", ItemTransforms.TransformType.NONE) + .put("third_person_left_hand", ItemTransforms.TransformType.THIRD_PERSON_LEFT_HAND) + .put("third_person_right_hand", ItemTransforms.TransformType.THIRD_PERSON_RIGHT_HAND) + .put("first_person_left_hand", ItemTransforms.TransformType.FIRST_PERSON_LEFT_HAND) + .put("first_person_right_hand", ItemTransforms.TransformType.FIRST_PERSON_RIGHT_HAND) + .put("head", ItemTransforms.TransformType.HEAD) + .put("gui", ItemTransforms.TransformType.GUI) + .put("ground", ItemTransforms.TransformType.GROUND) + .put("fixed", ItemTransforms.TransformType.FIXED) .build(); @Override - public void onResourceManagerReload(IResourceManager resourceManager) - { - // Not used + public void onResourceManagerReload(final ResourceManager p_10758_) { + } @Override public SeparatePerspectiveModel read(JsonDeserializationContext deserializationContext, JsonObject modelContents) { - BlockModel baseModel = deserializationContext.deserialize(JSONUtils.getAsJsonObject(modelContents, "base"), BlockModel.class); + BlockModel baseModel = deserializationContext.deserialize(GsonHelper.getAsJsonObject(modelContents, "base"), BlockModel.class); - JsonObject perspectiveData = JSONUtils.getAsJsonObject(modelContents, "perspectives"); + JsonObject perspectiveData = GsonHelper.getAsJsonObject(modelContents, "perspectives"); - ImmutableMap.Builder perspectives = ImmutableMap.builder(); - for(Map.Entry perspective : PERSPECTIVES.entrySet()) + ImmutableMap.Builder perspectives = ImmutableMap.builder(); + for(Map.Entry perspective : PERSPECTIVES.entrySet()) { if (perspectiveData.has(perspective.getKey())) { - BlockModel perspectiveModel = deserializationContext.deserialize(JSONUtils.getAsJsonObject(perspectiveData, perspective.getKey()), BlockModel.class); + BlockModel perspectiveModel = deserializationContext.deserialize(GsonHelper.getAsJsonObject(perspectiveData, perspective.getKey()), BlockModel.class); perspectives.put(perspective.getValue(), perspectiveModel); } } diff --git a/src/main/java/net/minecraftforge/client/model/SimpleModelTransform.java b/src/main/java/net/minecraftforge/client/model/SimpleModelState.java similarity index 56% rename from src/main/java/net/minecraftforge/client/model/SimpleModelTransform.java rename to src/main/java/net/minecraftforge/client/model/SimpleModelState.java index f5797cb737..404f64999f 100644 --- a/src/main/java/net/minecraftforge/client/model/SimpleModelTransform.java +++ b/src/main/java/net/minecraftforge/client/model/SimpleModelState.java @@ -19,46 +19,46 @@ package net.minecraftforge.client.model; -import net.minecraft.client.renderer.model.IModelTransform; +import net.minecraft.client.resources.model.ModelState; import com.google.common.collect.ImmutableMap; -import net.minecraft.util.math.vector.TransformationMatrix; +import com.mojang.math.Transformation; /** * Simple implementation of IModelState via a map and a default value. */ -public final class SimpleModelTransform implements IModelTransform +public final class SimpleModelState implements ModelState { - public static final SimpleModelTransform IDENTITY = new SimpleModelTransform(TransformationMatrix.identity()); + public static final SimpleModelState IDENTITY = new SimpleModelState(Transformation.identity()); - private final ImmutableMap map; - private final TransformationMatrix base; + private final ImmutableMap map; + private final Transformation base; - public SimpleModelTransform(ImmutableMap map) + public SimpleModelState(ImmutableMap map) { - this(map, TransformationMatrix.identity()); + this(map, Transformation.identity()); } - public SimpleModelTransform(TransformationMatrix base) + public SimpleModelState(Transformation base) { this(ImmutableMap.of(), base); } - public SimpleModelTransform(ImmutableMap map, TransformationMatrix base) + public SimpleModelState(ImmutableMap map, Transformation base) { this.map = map; this.base = base; } @Override - public TransformationMatrix getRotation() + public Transformation getRotation() { return base; } @Override - public TransformationMatrix getPartTransformation(Object part) + public Transformation getPartTransformation(Object part) { - return map.getOrDefault(part, TransformationMatrix.identity()); + return map.getOrDefault(part, Transformation.identity()); } } diff --git a/src/main/java/net/minecraftforge/client/model/animation/Animation.java b/src/main/java/net/minecraftforge/client/model/animation/Animation.java index f67325ef43..2cf1fd1c08 100644 --- a/src/main/java/net/minecraftforge/client/model/animation/Animation.java +++ b/src/main/java/net/minecraftforge/client/model/animation/Animation.java @@ -19,7 +19,7 @@ package net.minecraftforge.client.model.animation; -import net.minecraft.world.World; +import net.minecraft.world.level.Level; import java.lang.ref.WeakReference; @@ -30,12 +30,12 @@ public enum Animation private float clientPartialTickTime; private static long epochTime; - private static WeakReference worldRef; + private static WeakReference worldRef; /** * Get the global world time for the current tick, in seconds. */ - public static float getWorldTime(World world) + public static float getWorldTime(Level world) { return getWorldTime(world, 0); } @@ -43,7 +43,7 @@ public enum Animation /** * Get the global world time for the current tick + partial tick progress, in seconds. */ - public static float getWorldTime(World world, float tickProgress) + public static float getWorldTime(Level world, float tickProgress) { if (worldRef == null || worldRef.get() != world) { diff --git a/src/main/java/net/minecraftforge/client/model/animation/TileEntityRendererAnimation.java b/src/main/java/net/minecraftforge/client/model/animation/AnimationBlockEntityRenderer.java similarity index 64% rename from src/main/java/net/minecraftforge/client/model/animation/TileEntityRendererAnimation.java rename to src/main/java/net/minecraftforge/client/model/animation/AnimationBlockEntityRenderer.java index e80b18095b..4a1ba3f7a5 100644 --- a/src/main/java/net/minecraftforge/client/model/animation/TileEntityRendererAnimation.java +++ b/src/main/java/net/minecraftforge/client/model/animation/AnimationBlockEntityRenderer.java @@ -21,19 +21,19 @@ package net.minecraftforge.client.model.animation; import java.util.Random; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.Atlases; -import net.minecraft.client.renderer.BlockRendererDispatcher; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.tileentity.TileEntityRenderer; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockDisplayReader; +import net.minecraft.client.renderer.Sheets; +import net.minecraft.client.renderer.block.BlockRenderDispatcher; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockAndTintGetter; import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.client.model.ModelDataManager; import net.minecraftforge.client.model.data.IModelData; @@ -47,17 +47,12 @@ import net.minecraftforge.common.util.LazyOptional; /** * Generic {@link TileGameRenderer} that works with the Forge model system and animations. */ -public class TileEntityRendererAnimation extends TileEntityRenderer implements IEventHandler +public class AnimationBlockEntityRenderer implements BlockEntityRenderer, IEventHandler { - public TileEntityRendererAnimation(TileEntityRendererDispatcher rendererDispatcherIn) - { - super(rendererDispatcherIn); - } - - protected static BlockRendererDispatcher blockRenderer; + protected static BlockRenderDispatcher blockRenderer; @Override - public void render(T te, float partialTick, MatrixStack mat, IRenderTypeBuffer renderer, int light, int otherlight) + public void render(T te, float partialTick, PoseStack mat, MultiBufferSource renderer, int light, int otherlight) { LazyOptional cap = te.getCapability(CapabilityAnimation.ANIMATION_CAPABILITY); if(!cap.isPresent()) @@ -66,10 +61,10 @@ public class TileEntityRendererAnimation extends TileEntit } if(blockRenderer == null) blockRenderer = Minecraft.getInstance().getBlockRenderer(); BlockPos pos = te.getBlockPos(); - IBlockDisplayReader world = MinecraftForgeClient.getRegionRenderCacheOptional(te.getLevel(), pos) - .map(IBlockDisplayReader.class::cast).orElseGet(() -> te.getLevel()); + BlockAndTintGetter world = MinecraftForgeClient.getRegionRenderCacheOptional(te.getLevel(), pos) + .map(BlockAndTintGetter.class::cast).orElseGet(() -> te.getLevel()); BlockState state = world.getBlockState(pos); - IBakedModel model = blockRenderer.getBlockModelShaper().getBlockModel(state); + BakedModel model = blockRenderer.getBlockModelShaper().getBlockModel(state); IModelData data = model.getModelData(world, pos, state, ModelDataManager.getModelData(te.getLevel(), pos)); if (data.hasProperty(Properties.AnimationProperty)) { @@ -82,7 +77,7 @@ public class TileEntityRendererAnimation extends TileEntit // TODO: caching? data.setData(Properties.AnimationProperty, pair.getLeft()); - blockRenderer.getModelRenderer().renderModel(world, model, state, pos, mat, renderer.getBuffer(Atlases.solidBlockSheet()), false, new Random(), 42, light, data); + blockRenderer.getModelRenderer().tesselateBlock(world, model, state, pos, mat, renderer.getBuffer(Sheets.solidBlockSheet()), false, new Random(), 42, light, data); }); } } diff --git a/src/main/java/net/minecraftforge/client/model/animation/AnimationItemOverrideList.java b/src/main/java/net/minecraftforge/client/model/animation/AnimationItemOverrideList.java index 98cdfc57e9..2bb53ba3c6 100644 --- a/src/main/java/net/minecraftforge/client/model/animation/AnimationItemOverrideList.java +++ b/src/main/java/net/minecraftforge/client/model/animation/AnimationItemOverrideList.java @@ -25,33 +25,43 @@ import java.util.function.Function; import javax.annotation.Nullable; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.model.*; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.entity.LivingEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.World; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.Level; import net.minecraftforge.client.model.ModelLoader; -import net.minecraftforge.client.model.ModelTransformComposition; +import net.minecraftforge.client.model.CompositeModelState; import net.minecraftforge.common.model.animation.CapabilityAnimation; -public final class AnimationItemOverrideList extends ItemOverrideList +import net.minecraft.client.renderer.block.model.ItemOverride; +import net.minecraft.client.renderer.block.model.ItemOverrides; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.resources.model.Material; +import net.minecraft.client.resources.model.ModelBakery; +import net.minecraft.client.resources.model.ModelState; +import net.minecraft.client.resources.model.UnbakedModel; + +public final class AnimationItemOverrideList extends ItemOverrides { private final ModelBakery bakery; - private final IUnbakedModel model; + private final UnbakedModel model; private final ResourceLocation modelLoc; - private final IModelTransform state; + private final ModelState state; - private final Function bakedTextureGetter; + private final Function bakedTextureGetter; - public AnimationItemOverrideList(ModelBakery bakery, IUnbakedModel model, ResourceLocation modelLoc, IModelTransform state, Function bakedTextureGetter, ItemOverrideList overrides) + //TODO, Mojang now bakes overrides, figure out how to reverse them. +/* + public AnimationItemOverrideList(ModelBakery bakery, UnbakedModel model, ResourceLocation modelLoc, ModelState state, Function bakedTextureGetter, ItemOverrides overrides) { this(bakery, model, modelLoc, state, bakedTextureGetter, overrides.getOverrides().reverse()); } +*/ - public AnimationItemOverrideList(ModelBakery bakery, IUnbakedModel model, ResourceLocation modelLoc, IModelTransform state, Function bakedTextureGetter, List overrides) + public AnimationItemOverrideList(ModelBakery bakery, UnbakedModel model, ResourceLocation modelLoc, ModelState state, Function bakedTextureGetter, List overrides) { super(bakery, model, ModelLoader.defaultModelGetter(), bakedTextureGetter, overrides); this.bakery = bakery; @@ -63,12 +73,12 @@ public final class AnimationItemOverrideList extends ItemOverrideList @SuppressWarnings("resource") @Override - public IBakedModel resolve(IBakedModel originalModel, ItemStack stack, @Nullable ClientWorld world, @Nullable LivingEntity entity) + public BakedModel resolve(BakedModel originalModel, ItemStack stack, @Nullable ClientLevel world, @Nullable LivingEntity entity, int seed) { return stack.getCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null) .map(asm -> { - World w = world; + Level w = world; // TODO caching? if(w == null && entity != null) { @@ -81,7 +91,7 @@ public final class AnimationItemOverrideList extends ItemOverrideList return asm.apply(Animation.getWorldTime(world, Animation.getPartialTickTime())).getLeft(); }) // TODO where should uvlock data come from? - .map(state -> model.bake(bakery, bakedTextureGetter, new ModelTransformComposition(state, this.state), modelLoc)) - .orElseGet(() -> super.resolve(originalModel, stack, world, entity)); + .map(state -> model.bake(bakery, bakedTextureGetter, new CompositeModelState(state, this.state), modelLoc)) + .orElseGet(() -> super.resolve(originalModel, stack, world, entity, seed)); } } diff --git a/src/main/java/net/minecraftforge/client/model/animation/ModelBlockAnimation.java b/src/main/java/net/minecraftforge/client/model/animation/ModelBlockAnimation.java index 539ccb9c80..9f9d1e08b7 100644 --- a/src/main/java/net/minecraftforge/client/model/animation/ModelBlockAnimation.java +++ b/src/main/java/net/minecraftforge/client/model/animation/ModelBlockAnimation.java @@ -33,19 +33,19 @@ import java.util.TreeMap; import javax.annotation.Nullable; -import net.minecraft.client.renderer.model.IModelTransform; -import net.minecraft.util.math.vector.Matrix4f; -import net.minecraft.util.math.vector.Quaternion; -import net.minecraft.util.math.vector.TransformationMatrix; -import net.minecraft.util.math.vector.Vector3f; +import net.minecraft.client.resources.model.ModelState; +import com.mojang.math.Matrix4f; +import com.mojang.math.Quaternion; +import com.mojang.math.Transformation; +import com.mojang.math.Vector3f; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import net.minecraft.client.renderer.model.BlockPart; -import net.minecraft.resources.IResource; -import net.minecraft.resources.IResourceManager; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.MathHelper; +import net.minecraft.client.renderer.block.model.BlockElement; +import net.minecraft.server.packs.resources.Resource; +import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Mth; import net.minecraftforge.client.model.animation.ModelBlockAnimation.Parameter.Interpolation; import net.minecraftforge.client.model.animation.ModelBlockAnimation.Parameter.Type; import net.minecraftforge.client.model.animation.ModelBlockAnimation.Parameter.Variable; @@ -326,7 +326,7 @@ public class ModelBlockAnimation } @Override - public TransformationMatrix apply(float time) + public Transformation apply(float time) { time -= Math.floor(time); Vector3f translation = new Vector3f(0, 0, 0); @@ -338,7 +338,7 @@ public class ModelBlockAnimation { int length = loop ? var.samples.length : (var.samples.length - 1); float timeScaled = time * length; - int s1 = MathHelper.clamp((int)Math.round(Math.floor(timeScaled)), 0, length - 1); + int s1 = Mth.clamp((int)Math.round(Math.floor(timeScaled)), 0, length - 1); float progress = timeScaled - s1; int s2 = s1 + 1; if(s2 == length && loop) s2 = 0; @@ -409,10 +409,10 @@ public class ModelBlockAnimation } } Quaternion rot = new Quaternion(rotation_axis, rotation_angle, false); - TransformationMatrix base = new TransformationMatrix(translation, rot, scale, null); + Transformation base = new Transformation(translation, rot, scale, null); Vector3f negOrigin = origin.copy(); negOrigin.mul(-1,-1,-1); - base = new TransformationMatrix(origin, null, null, null).compose(base).compose(new TransformationMatrix(negOrigin, null, null, null)); + base = new Transformation(origin, null, null, null).compose(base).compose(new Transformation(negOrigin, null, null, null)); return base.blockCenterToCorner(); } } @@ -428,9 +428,9 @@ public class ModelBlockAnimation } @Override - public TransformationMatrix getInvBindPose() + public Transformation getInvBindPose() { - return TransformationMatrix.identity(); + return Transformation.identity(); } @Override @@ -517,13 +517,13 @@ public class ModelBlockAnimation } @Nullable - public TransformationMatrix getPartTransform(IModelTransform state, BlockPart part, int i) + public Transformation getPartTransform(ModelState state, BlockElement part, int i) { return getPartTransform(state, i); } @Nullable - public TransformationMatrix getPartTransform(IModelTransform state, int i) + public Transformation getPartTransform(ModelState state, int i) { ImmutableCollection infos = getJoint(i); if(!infos.isEmpty()) @@ -535,7 +535,7 @@ public class ModelBlockAnimation if(info.getWeights().containsKey(i)) { ModelBlockAnimation.MBJoint joint = new ModelBlockAnimation.MBJoint(info.getName()); - TransformationMatrix trOp = state.getPartTransformation(joint); + Transformation trOp = state.getPartTransformation(joint); if(!trOp.isIdentity()) { float w = info.getWeights().get(i)[0]; @@ -549,7 +549,7 @@ public class ModelBlockAnimation if(weight > 1e-5) { m.multiply(1f / weight); - return new TransformationMatrix(m); + return new Transformation(m); } } return null; @@ -558,11 +558,11 @@ public class ModelBlockAnimation /** * Load armature associated with a vanilla model. */ - public static ModelBlockAnimation loadVanillaAnimation(IResourceManager manager, ResourceLocation armatureLocation) + public static ModelBlockAnimation loadVanillaAnimation(ResourceManager manager, ResourceLocation armatureLocation) { try { - try (IResource resource = manager.getResource(armatureLocation)) + try (Resource resource = manager.getResource(armatureLocation)) { ModelBlockAnimation mba = mbaGson.fromJson(new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8), ModelBlockAnimation.class); //String json = mbaGson.toJson(mba); diff --git a/src/main/java/net/minecraftforge/client/model/animation/package-info.java b/src/main/java/net/minecraftforge/client/model/animation/package-info.java index 0ec8803141..b6b6656129 100644 --- a/src/main/java/net/minecraftforge/client/model/animation/package-info.java +++ b/src/main/java/net/minecraftforge/client/model/animation/package-info.java @@ -21,5 +21,6 @@ @MethodsReturnNonnullByDefault package net.minecraftforge.client.model.animation; -import mcp.MethodsReturnNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; + import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/java/net/minecraftforge/client/model/b3d/B3DClip.java b/src/main/java/net/minecraftforge/client/model/b3d/B3DClip.java index fd381e3204..f8e0f60119 100644 --- a/src/main/java/net/minecraftforge/client/model/b3d/B3DClip.java +++ b/src/main/java/net/minecraftforge/client/model/b3d/B3DClip.java @@ -19,7 +19,7 @@ package net.minecraftforge.client.model.b3d; -import net.minecraft.util.math.vector.TransformationMatrix; +import com.mojang.math.Transformation; import net.minecraftforge.client.model.b3d.B3DLoader.NodeJoint; import net.minecraftforge.client.model.b3d.B3DModel.Key; import net.minecraftforge.client.model.b3d.B3DModel.Node; @@ -63,25 +63,25 @@ public enum B3DClip implements IClip } @Override - public TransformationMatrix apply(float time) + public Transformation apply(float time) { - TransformationMatrix ret = TransformationMatrix.identity(); + Transformation ret = Transformation.identity(); if(node.getAnimation() == null) { - return ret.compose(new TransformationMatrix(node.getPos(), node.getRot(), node.getScale(), null)); + return ret.compose(new Transformation(node.getPos(), node.getRot(), node.getScale(), null)); } int start = Math.max(1, (int)Math.round(Math.floor(time))); int end = Math.min(start + 1, (int)Math.round(Math.ceil(time))); float progress = time - (float)Math.floor(time); Key keyStart = node.getAnimation().getKeys().get(start, node); Key keyEnd = node.getAnimation().getKeys().get(end, node); - TransformationMatrix startTr = keyStart == null ? null : new TransformationMatrix(keyStart.getPos(), keyStart.getRot(),keyStart.getScale(), null); - TransformationMatrix endTr = keyEnd == null ? null : new TransformationMatrix(keyEnd.getPos(), keyEnd.getRot(),keyEnd.getScale(), null); + Transformation startTr = keyStart == null ? null : new Transformation(keyStart.getPos(), keyStart.getRot(),keyStart.getScale(), null); + Transformation endTr = keyEnd == null ? null : new Transformation(keyEnd.getPos(), keyEnd.getRot(),keyEnd.getScale(), null); if(keyStart == null) { if(keyEnd == null) { - ret = ret.compose(new TransformationMatrix(node.getPos(), node.getRot(), node.getScale(), null)); + ret = ret.compose(new Transformation(node.getPos(), node.getRot(), node.getScale(), null)); } // TODO animated TRSRTransformation for speed? else diff --git a/src/main/java/net/minecraftforge/client/model/b3d/B3DLoader.java b/src/main/java/net/minecraftforge/client/model/b3d/B3DLoader.java index 4ccde90e02..d2989461a4 100644 --- a/src/main/java/net/minecraftforge/client/model/b3d/B3DLoader.java +++ b/src/main/java/net/minecraftforge/client/model/b3d/B3DLoader.java @@ -37,18 +37,16 @@ import java.util.stream.Collectors; import javax.annotation.Nullable; -import com.mojang.blaze3d.matrix.MatrixStack; -import net.minecraft.util.math.vector.Matrix4f; -import net.minecraft.util.math.vector.TransformationMatrix; -import net.minecraft.util.math.vector.Vector3f; -import net.minecraft.client.renderer.model.*; -import net.minecraft.client.renderer.texture.AtlasTexture; -import net.minecraft.client.renderer.texture.MissingTextureSprite; -import net.minecraft.client.renderer.vertex.VertexFormatElement; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.math.Matrix4f; +import com.mojang.math.Transformation; +import com.mojang.math.Vector3f; +import net.minecraft.client.renderer.texture.TextureAtlas; +import net.minecraft.client.renderer.texture.MissingTextureAtlasSprite; +import com.mojang.blaze3d.vertex.VertexFormatElement; import net.minecraftforge.client.model.*; import net.minecraftforge.common.model.*; import net.minecraftforge.resource.IResourceType; -import net.minecraftforge.resource.ISelectiveResourceReloadListener; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.tuple.Triple; import org.apache.logging.log4j.LogManager; @@ -64,14 +62,14 @@ import com.google.common.collect.ImmutableSet; import com.google.gson.JsonElement; import com.google.gson.JsonParser; -import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.resources.IResource; -import net.minecraft.resources.IResourceManager; -import net.minecraft.util.Direction; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.MathHelper; +import net.minecraft.server.packs.resources.Resource; +import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.core.Direction; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Mth; import net.minecraftforge.client.model.b3d.B3DModel.Animation; import net.minecraftforge.client.model.b3d.B3DModel.Face; import net.minecraftforge.client.model.b3d.B3DModel.Key; @@ -87,6 +85,14 @@ import net.minecraftforge.common.model.animation.IClip; import net.minecraftforge.common.model.animation.IJoint; import net.minecraftforge.common.property.Properties; +import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.renderer.block.model.ItemOverrides; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.resources.model.Material; +import net.minecraft.client.resources.model.ModelBakery; +import net.minecraft.client.resources.model.ModelState; +import net.minecraft.client.resources.model.UnbakedModel; + /* * Loader for Blitz3D models. * To enable for your mod call instance.addDomain(modId). @@ -94,30 +100,23 @@ import net.minecraftforge.common.property.Properties; */ // TODO: Implement as a new model loader @SuppressWarnings("unused") -public enum B3DLoader implements ISelectiveResourceReloadListener +public enum B3DLoader { INSTANCE; private static final Logger LOGGER = LogManager.getLogger(); - private IResourceManager manager; + private ResourceManager manager; private final Set enabledDomains = new HashSet<>(); private final Map cache = new HashMap<>(); - @Override - public void onResourceManagerReload(IResourceManager manager, Predicate resourcePredicate) - { - this.manager = manager; - cache.clear(); - } - - public IUnbakedModel loadModel(ResourceLocation modelLocation) throws Exception + public UnbakedModel loadModel(ResourceLocation modelLocation) throws Exception { ResourceLocation file = new ResourceLocation(modelLocation.getNamespace(), modelLocation.getPath()); if(!cache.containsKey(file)) { - IResource resource = null; + Resource resource = null; try { try @@ -155,7 +154,7 @@ public enum B3DLoader implements ISelectiveResourceReloadListener return new ModelWrapper(modelLocation, model, ImmutableSet.of(model.getRoot().getName()), true, true, true, 1); } - public static final class B3DState implements IModelTransform + public static final class B3DState implements ModelState { @Nullable private final Animation animation; @@ -163,14 +162,14 @@ public enum B3DLoader implements ISelectiveResourceReloadListener private final int nextFrame; private final float progress; @Nullable - private final IModelTransform parent; + private final ModelState parent; public B3DState(@Nullable Animation animation, int frame) { this(animation, frame, frame, 0); } - public B3DState(@Nullable Animation animation, int frame, IModelTransform parent) + public B3DState(@Nullable Animation animation, int frame, ModelState parent) { this(animation, frame, frame, 0, parent); } @@ -180,17 +179,17 @@ public enum B3DLoader implements ISelectiveResourceReloadListener this(animation, frame, nextFrame, progress, null); } - public B3DState(@Nullable Animation animation, int frame, int nextFrame, float progress, @Nullable IModelTransform parent) + public B3DState(@Nullable Animation animation, int frame, int nextFrame, float progress, @Nullable ModelState parent) { this.animation = animation; this.frame = frame; this.nextFrame = nextFrame; - this.progress = MathHelper.clamp(progress, 0, 1); + this.progress = Mth.clamp(progress, 0, 1); this.parent = getParent(parent); } @Nullable - private IModelTransform getParent(@Nullable IModelTransform parent) + private ModelState getParent(@Nullable ModelState parent) { if (parent == null) return null; else if (parent instanceof B3DState) return ((B3DState)parent).parent; @@ -219,33 +218,33 @@ public enum B3DLoader implements ISelectiveResourceReloadListener } @Nullable - public IModelTransform getParent() + public ModelState getParent() { return parent; } @Override - public TransformationMatrix getRotation() + public Transformation getRotation() { if(parent != null) { return parent.getRotation(); } - return TransformationMatrix.identity(); + return Transformation.identity(); } @Override - public TransformationMatrix getPartTransformation(Object part) + public Transformation getPartTransformation(Object part) { // TODO make more use of Optional if(!(part instanceof NodeJoint)) { - return TransformationMatrix.identity(); + return Transformation.identity(); } Node node = ((NodeJoint)part).getNode(); - TransformationMatrix nodeTransform; + Transformation nodeTransform; if(progress < 1e-5 || frame == nextFrame) { nodeTransform = getNodeMatrix(node, frame); @@ -266,31 +265,31 @@ public enum B3DLoader implements ISelectiveResourceReloadListener return nodeTransform; } - private static LoadingCache, Integer>, TransformationMatrix> cache = CacheBuilder.newBuilder() + private static LoadingCache, Integer>, Transformation> cache = CacheBuilder.newBuilder() .maximumSize(16384) .expireAfterAccess(2, TimeUnit.MINUTES) - .build(new CacheLoader, Integer>, TransformationMatrix>() + .build(new CacheLoader, Integer>, Transformation>() { @Override - public TransformationMatrix load(Triple, Integer> key) throws Exception + public Transformation load(Triple, Integer> key) throws Exception { return getNodeMatrix(key.getLeft(), key.getMiddle(), key.getRight()); } }); - public TransformationMatrix getNodeMatrix(Node node) + public Transformation getNodeMatrix(Node node) { return getNodeMatrix(node, frame); } - public TransformationMatrix getNodeMatrix(Node node, int frame) + public Transformation getNodeMatrix(Node node, int frame) { return cache.getUnchecked(Triple.of(animation, node, frame)); } - public static TransformationMatrix getNodeMatrix(@Nullable Animation animation, Node node, int frame) + public static Transformation getNodeMatrix(@Nullable Animation animation, Node node, int frame) { - TransformationMatrix ret = TransformationMatrix.identity(); + Transformation ret = Transformation.identity(); Key key = null; if(animation != null) key = animation.getKeys().get(frame, node); else if(node.getAnimation() != null) key = node.getAnimation().getKeys().get(frame, node); @@ -300,13 +299,13 @@ public enum B3DLoader implements ISelectiveResourceReloadListener if(parent != null) { // parent model-global current pose - TransformationMatrix pm = cache.getUnchecked(Triple.of(animation, node.getParent(), frame)); + Transformation pm = cache.getUnchecked(Triple.of(animation, node.getParent(), frame)); ret = ret.compose(pm); // joint offset in the parent coords - ret = ret.compose(new TransformationMatrix(parent.getPos(), parent.getRot(), parent.getScale(), null)); + ret = ret.compose(new Transformation(parent.getPos(), parent.getRot(), parent.getScale(), null)); } // current node local pose - ret = ret.compose(new TransformationMatrix(key.getPos(), key.getRot(), key.getScale(), null)); + ret = ret.compose(new Transformation(key.getPos(), key.getRot(), key.getScale(), null)); // this part moved inside the model // inverse bind of the current node /*Matrix4f rm = new TRSRTransformation(node.getPos(), node.getRot(), node.getScale(), null).getMatrix(); @@ -320,7 +319,7 @@ public enum B3DLoader implements ISelectiveResourceReloadListener ret = ret.compose(new TRSRTransformation(rm)); }*/ // TODO cache - TransformationMatrix invBind = new NodeJoint(node).getInvBindPose(); + Transformation invBind = new NodeJoint(node).getInvBindPose(); ret = ret.compose(invBind); } else @@ -329,14 +328,14 @@ public enum B3DLoader implements ISelectiveResourceReloadListener if(parent != null) { // parent model-global current pose - TransformationMatrix pm = cache.getUnchecked(Triple.of(animation, node.getParent(), frame)); + Transformation pm = cache.getUnchecked(Triple.of(animation, node.getParent(), frame)); ret = ret.compose(pm); // joint offset in the parent coords - ret = ret.compose(new TransformationMatrix(parent.getPos(), parent.getRot(), parent.getScale(), null)); + ret = ret.compose(new Transformation(parent.getPos(), parent.getRot(), parent.getScale(), null)); } - ret = ret.compose(new TransformationMatrix(node.getPos(), node.getRot(), node.getScale(), null)); + ret = ret.compose(new Transformation(node.getPos(), node.getRot(), node.getScale(), null)); // TODO cache - TransformationMatrix invBind = new NodeJoint(node).getInvBindPose(); + Transformation invBind = new NodeJoint(node).getInvBindPose(); ret = ret.compose(invBind); } return ret; @@ -353,15 +352,15 @@ public enum B3DLoader implements ISelectiveResourceReloadListener } @Override - public TransformationMatrix getInvBindPose() + public Transformation getInvBindPose() { - Matrix4f m = new TransformationMatrix(node.getPos(), node.getRot(), node.getScale(), null).getMatrix(); + Matrix4f m = new Transformation(node.getPos(), node.getRot(), node.getScale(), null).getMatrix(); m.invert(); - TransformationMatrix pose = new TransformationMatrix(m); + Transformation pose = new Transformation(m); if(node.getParent() != null) { - TransformationMatrix parent = new NodeJoint(node.getParent()).getInvBindPose(); + Transformation parent = new NodeJoint(node.getParent()).getInvBindPose(); pose = pose.compose(parent); } return pose; @@ -397,7 +396,7 @@ public enum B3DLoader implements ISelectiveResourceReloadListener } } - private static final class ModelWrapper implements IUnbakedModel + private static final class ModelWrapper implements UnbakedModel { private final ResourceLocation modelLocation; private final B3DModel model; @@ -447,10 +446,10 @@ public enum B3DLoader implements ISelectiveResourceReloadListener @SuppressWarnings("deprecation") @Override - public Collection getMaterials(Function modelGetter, Set> missingTextureErrors) + public Collection getMaterials(Function modelGetter, Set> missingTextureErrors) { return textures.values().stream().filter(loc -> !loc.startsWith("#")) - .map(t -> new RenderMaterial(AtlasTexture.LOCATION_BLOCKS, new ResourceLocation(t))) + .map(t -> new Material(TextureAtlas.LOCATION_BLOCKS, new ResourceLocation(t))) .collect(Collectors.toList()); } @@ -463,10 +462,10 @@ public enum B3DLoader implements ISelectiveResourceReloadListener @SuppressWarnings("deprecation") @Nullable @Override - public IBakedModel bake(ModelBakery bakery, Function spriteGetter, IModelTransform modelTransform, ResourceLocation modelLocation) + public BakedModel bake(ModelBakery bakery, Function spriteGetter, ModelState modelTransform, ResourceLocation modelLocation) { ImmutableMap.Builder builder = ImmutableMap.builder(); - TextureAtlasSprite missing = spriteGetter.apply(new RenderMaterial(AtlasTexture.LOCATION_BLOCKS, MissingTextureSprite.getLocation())); + TextureAtlasSprite missing = spriteGetter.apply(new Material(TextureAtlas.LOCATION_BLOCKS, MissingTextureAtlasSprite.getLocation())); for(Map.Entry e : textures.entrySet()) { if(e.getValue().startsWith("#")) @@ -476,7 +475,7 @@ public enum B3DLoader implements ISelectiveResourceReloadListener } else { - builder.put(e.getKey(), spriteGetter.apply(new RenderMaterial(AtlasTexture.LOCATION_BLOCKS, new ResourceLocation(e.getValue())))); + builder.put(e.getKey(), spriteGetter.apply(new Material(TextureAtlas.LOCATION_BLOCKS, new ResourceLocation(e.getValue())))); } } builder.put("missingno", missing); @@ -570,7 +569,7 @@ public enum B3DLoader implements ISelectiveResourceReloadListener return Optional.empty(); } - public IModelTransform getDefaultState() + public ModelState getDefaultState() { return new B3DState(model.getRoot().getAnimation(), defaultKey, defaultKey, 0); } @@ -597,7 +596,7 @@ public enum B3DLoader implements ISelectiveResourceReloadListener private static final class BakedWrapper implements IDynamicBakedModel { private final Node node; - private final IModelTransform state; + private final ModelState state; private final boolean smooth; private final boolean gui3d; private final boolean isSideLit; @@ -607,7 +606,7 @@ public enum B3DLoader implements ISelectiveResourceReloadListener private ImmutableList quads; - public BakedWrapper(final Node node, final IModelTransform state, final boolean smooth, final boolean gui3d, boolean isSideLit, final ImmutableSet meshes, final ImmutableMap textures) + public BakedWrapper(final Node node, final ModelState state, final boolean smooth, final boolean gui3d, boolean isSideLit, final ImmutableSet meshes, final ImmutableMap textures) { this(node, state, smooth, gui3d, isSideLit, meshes, textures, CacheBuilder.newBuilder() .maximumSize(128) @@ -617,7 +616,7 @@ public enum B3DLoader implements ISelectiveResourceReloadListener @Override public B3DState load(Integer frame) throws Exception { - IModelTransform parent = state; + ModelState parent = state; Animation newAnimation = node.getAnimation(); if(parent instanceof B3DState) { @@ -629,7 +628,7 @@ public enum B3DLoader implements ISelectiveResourceReloadListener })); } - public BakedWrapper(Node node, IModelTransform state, boolean smooth, boolean gui3d, boolean isSideLit, ImmutableSet meshes, ImmutableMap textures, LoadingCache cache) + public BakedWrapper(Node node, ModelState state, boolean smooth, boolean gui3d, boolean isSideLit, ImmutableSet meshes, ImmutableMap textures, LoadingCache cache) { this.node = node; this.state = state; @@ -645,12 +644,12 @@ public enum B3DLoader implements ISelectiveResourceReloadListener public List getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand, IModelData data) { if(side != null) return ImmutableList.of(); - IModelTransform modelState = this.state; - IModelTransform newState = data.getData(Properties.AnimationProperty); + ModelState modelState = this.state; + ModelState newState = data.getData(Properties.AnimationProperty); if(newState != null) { // FIXME: should animation state handle the parent state, or should it remain here? - IModelTransform parent = this.state; + ModelState parent = this.state; if(parent instanceof B3DState) { B3DState ps = (B3DState)parent; @@ -662,7 +661,7 @@ public enum B3DLoader implements ISelectiveResourceReloadListener } else { - modelState = new ModelTransformComposition(parent, newState); + modelState = new CompositeModelState(parent, newState); } } if(quads == null) @@ -681,7 +680,7 @@ public enum B3DLoader implements ISelectiveResourceReloadListener return quads; } - private void generateQuads(ImmutableList.Builder builder, Node node, final IModelTransform state, ImmutableList path) + private void generateQuads(ImmutableList.Builder builder, Node node, final ModelState state, ImmutableList path) { ImmutableList.Builder pathBuilder = ImmutableList.builder(); pathBuilder.addAll(path); @@ -696,13 +695,13 @@ public enum B3DLoader implements ISelectiveResourceReloadListener Mesh mesh = (Mesh)node.getKind(); Collection faces = mesh.bake(new Function, Matrix4f>() { - private final TransformationMatrix global = state.getRotation(); - private final LoadingCache, TransformationMatrix> localCache = CacheBuilder.newBuilder() + private final Transformation global = state.getRotation(); + private final LoadingCache, Transformation> localCache = CacheBuilder.newBuilder() .maximumSize(32) - .build(new CacheLoader, TransformationMatrix>() + .build(new CacheLoader, Transformation>() { @Override - public TransformationMatrix load(Node node) throws Exception + public Transformation load(Node node) throws Exception { return state.getPartTransformation(new NodeJoint(node)); } @@ -825,16 +824,16 @@ public enum B3DLoader implements ISelectiveResourceReloadListener } @Override - public IBakedModel handlePerspective(TransformType cameraTransformType, MatrixStack mat) + public BakedModel handlePerspective(TransformType cameraTransformType, PoseStack poseStack) { - return PerspectiveMapWrapper.handlePerspective(this, state, cameraTransformType, mat); + return PerspectiveMapWrapper.handlePerspective(this, state, cameraTransformType, poseStack); } @Override - public ItemOverrideList getOverrides() + public ItemOverrides getOverrides() { // TODO handle items - return ItemOverrideList.EMPTY; + return ItemOverrides.EMPTY; } } } diff --git a/src/main/java/net/minecraftforge/client/model/b3d/B3DModel.java b/src/main/java/net/minecraftforge/client/model/b3d/B3DModel.java index 6853b85347..3d8076254b 100644 --- a/src/main/java/net/minecraftforge/client/model/b3d/B3DModel.java +++ b/src/main/java/net/minecraftforge/client/model/b3d/B3DModel.java @@ -39,7 +39,6 @@ import java.util.Set; import javax.annotation.Nullable; -import net.minecraft.util.math.vector.*; import net.minecraftforge.versions.forge.ForgeVersion; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.tuple.Pair; @@ -58,6 +57,13 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableTable; import com.google.common.collect.Table; +import com.mojang.math.Matrix4f; +import com.mojang.math.Quaternion; +import com.mojang.math.Transformation; +import com.mojang.math.Vector3f; +import com.mojang.math.Vector4f; +import net.minecraft.world.phys.Vec2; + public class B3DModel { static final Logger logger = LogManager.getLogger(ForgeVersion.MOD_ID + ".B3DModel"); @@ -248,8 +254,8 @@ public class B3DModel String path = readString(); int flags = buf.getInt(); int blend = buf.getInt(); - Vector2f pos = new Vector2f(buf.getFloat(), buf.getFloat()); - Vector2f scale = new Vector2f(buf.getFloat(), buf.getFloat()); + Vec2 pos = new Vec2(buf.getFloat(), buf.getFloat()); + Vec2 scale = new Vec2(buf.getFloat(), buf.getFloat()); float rot = buf.getFloat(); ret.add(new Texture(path, flags, blend, pos, scale, rot)); } @@ -528,15 +534,15 @@ public class B3DModel public static class Texture { - public static final Texture White = new Texture("builtin/white", 0, 0, new Vector2f(0, 0), new Vector2f(1, 1), 0); + public static final Texture White = new Texture("builtin/white", 0, 0, new Vec2(0, 0), new Vec2(1, 1), 0); private final String path; private final int flags; private final int blend; - private final Vector2f pos; - private final Vector2f scale; + private final Vec2 pos; + private final Vec2 scale; private final float rot; - public Texture(String path, int flags, int blend, Vector2f pos, Vector2f scale, float rot) + public Texture(String path, int flags, int blend, Vec2 pos, Vec2 scale, float rot) { this.path = path; this.flags = flags; @@ -561,12 +567,12 @@ public class B3DModel return blend; } - public Vector2f getPos() + public Vec2 getPos() { return pos; } - public Vector2f getScale() + public Vec2 getScale() { return scale; } @@ -677,7 +683,7 @@ public class B3DModel else t.setIdentity(); } - TransformationMatrix trsr = new TransformationMatrix(t); + Transformation trsr = new Transformation(t); // pos Vector4f pos = new Vector4f(this.pos); diff --git a/src/main/java/net/minecraftforge/client/model/b3d/package-info.java b/src/main/java/net/minecraftforge/client/model/b3d/package-info.java index b7e7d9372f..3dc2706e38 100644 --- a/src/main/java/net/minecraftforge/client/model/b3d/package-info.java +++ b/src/main/java/net/minecraftforge/client/model/b3d/package-info.java @@ -21,5 +21,6 @@ @MethodsReturnNonnullByDefault package net.minecraftforge.client.model.b3d; -import mcp.MethodsReturnNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; + import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/java/net/minecraftforge/client/model/data/IDynamicBakedModel.java b/src/main/java/net/minecraftforge/client/model/data/IDynamicBakedModel.java index 3ad03432a5..a52b091ca7 100644 --- a/src/main/java/net/minecraftforge/client/model/data/IDynamicBakedModel.java +++ b/src/main/java/net/minecraftforge/client/model/data/IDynamicBakedModel.java @@ -25,15 +25,15 @@ import java.util.Random; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.model.BakedQuad; -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.util.Direction; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.core.Direction; /** * Convenience interface with default implementation of {@link IBakedModel#getQuads(net.minecraft.block.BlockState, net.minecraft.util.Direction, java.util.Random)}. */ -public interface IDynamicBakedModel extends IBakedModel +public interface IDynamicBakedModel extends BakedModel { @Override default @Nonnull List getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand) diff --git a/src/main/java/net/minecraftforge/client/model/data/MultipartModelData.java b/src/main/java/net/minecraftforge/client/model/data/MultipartModelData.java index 89cde4d1c1..a640cd4f95 100644 --- a/src/main/java/net/minecraftforge/client/model/data/MultipartModelData.java +++ b/src/main/java/net/minecraftforge/client/model/data/MultipartModelData.java @@ -19,10 +19,10 @@ package net.minecraftforge.client.model.data; -import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockDisplayReader; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockAndTintGetter; import org.apache.commons.lang3.tuple.Pair; import javax.annotation.Nullable; @@ -35,14 +35,14 @@ public class MultipartModelData implements IModelData { public static final ModelProperty MULTIPART_DATA = new ModelProperty<>(); - public static IModelData create(List, IBakedModel>> selectors, IBlockDisplayReader world, BlockPos pos, BlockState state, IModelData tileData) + public static IModelData create(List, BakedModel>> selectors, BlockAndTintGetter world, BlockPos pos, BlockState state, IModelData tileData) { MultipartModelData multipartData = new MultipartModelData(tileData); - for (Pair, IBakedModel> selector : selectors) + for (Pair, BakedModel> selector : selectors) { if (selector.getLeft().test(state)) { - IBakedModel part = selector.getRight(); + BakedModel part = selector.getRight(); IModelData partData = part.getModelData(world, pos, state, tileData); multipartData.setPartData(part, partData); } @@ -50,7 +50,7 @@ public class MultipartModelData implements IModelData return multipartData; } - public static IModelData resolve(IBakedModel part, IModelData modelData) + public static IModelData resolve(BakedModel part, IModelData modelData) { MultipartModelData multipartData = modelData.getData(MultipartModelData.MULTIPART_DATA); if (multipartData != null) @@ -59,20 +59,20 @@ public class MultipartModelData implements IModelData } private final IModelData tileData; - private final Map partData = new HashMap<>(); + private final Map partData = new HashMap<>(); public MultipartModelData(IModelData tileData) { this.tileData = tileData; } - public void setPartData(IBakedModel part, IModelData data) + public void setPartData(BakedModel part, IModelData data) { partData.put(part, data); } @Nullable - public IModelData getPartData(IBakedModel part, final IModelData defaultData) + public IModelData getPartData(BakedModel part, final IModelData defaultData) { return partData.getOrDefault(part, defaultData); } diff --git a/src/main/java/net/minecraftforge/client/model/generators/BlockModelBuilder.java b/src/main/java/net/minecraftforge/client/model/generators/BlockModelBuilder.java index 51b4abb88d..15e6078106 100644 --- a/src/main/java/net/minecraftforge/client/model/generators/BlockModelBuilder.java +++ b/src/main/java/net/minecraftforge/client/model/generators/BlockModelBuilder.java @@ -19,7 +19,7 @@ package net.minecraftforge.client.model.generators; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.common.data.ExistingFileHelper; /** diff --git a/src/main/java/net/minecraftforge/client/model/generators/BlockStateProvider.java b/src/main/java/net/minecraftforge/client/model/generators/BlockStateProvider.java index c659003958..1ec839ffdd 100644 --- a/src/main/java/net/minecraftforge/client/model/generators/BlockStateProvider.java +++ b/src/main/java/net/minecraftforge/client/model/generators/BlockStateProvider.java @@ -42,41 +42,41 @@ import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.DoorBlock; -import net.minecraft.block.FenceBlock; -import net.minecraft.block.FenceGateBlock; -import net.minecraft.block.FourWayBlock; -import net.minecraft.block.PaneBlock; -import net.minecraft.block.RotatedPillarBlock; -import net.minecraft.block.SixWayBlock; -import net.minecraft.block.SlabBlock; -import net.minecraft.block.StairsBlock; -import net.minecraft.block.TrapDoorBlock; -import net.minecraft.block.WallBlock; -import net.minecraft.block.WallHeight; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.DoorBlock; +import net.minecraft.world.level.block.FenceBlock; +import net.minecraft.world.level.block.FenceGateBlock; +import net.minecraft.world.level.block.CrossCollisionBlock; +import net.minecraft.world.level.block.IronBarsBlock; +import net.minecraft.world.level.block.RotatedPillarBlock; +import net.minecraft.world.level.block.PipeBlock; +import net.minecraft.world.level.block.SlabBlock; +import net.minecraft.world.level.block.StairBlock; +import net.minecraft.world.level.block.TrapDoorBlock; +import net.minecraft.world.level.block.WallBlock; +import net.minecraft.world.level.block.state.properties.WallSide; import net.minecraft.data.DataGenerator; -import net.minecraft.data.DirectoryCache; -import net.minecraft.data.IDataProvider; -import net.minecraft.state.Property; -import net.minecraft.state.properties.AttachFace; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.state.properties.DoorHingeSide; -import net.minecraft.state.properties.DoubleBlockHalf; -import net.minecraft.state.properties.Half; -import net.minecraft.state.properties.SlabType; -import net.minecraft.state.properties.StairsShape; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; +import net.minecraft.data.HashCache; +import net.minecraft.data.DataProvider; +import net.minecraft.world.level.block.state.properties.Property; +import net.minecraft.world.level.block.state.properties.AttachFace; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.DoorHingeSide; +import net.minecraft.world.level.block.state.properties.DoubleBlockHalf; +import net.minecraft.world.level.block.state.properties.Half; +import net.minecraft.world.level.block.state.properties.SlabType; +import net.minecraft.world.level.block.state.properties.StairsShape; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; import net.minecraftforge.common.data.ExistingFileHelper; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; /** * Data provider for blockstate files. Extends {@link BlockModelProvider} so that * blockstates and their referenced models can be provided in tandem. */ -public abstract class BlockStateProvider implements IDataProvider { +public abstract class BlockStateProvider implements DataProvider { private static final Logger LOGGER = LogManager.getLogger(); private static final Gson GSON = (new GsonBuilder()).setPrettyPrinting().disableHtmlEscaping().create(); @@ -101,7 +101,7 @@ public abstract class BlockStateProvider implements IDataProvider { } @Override - public void run(DirectoryCache cache) throws IOException { + public void run(HashCache cache) throws IOException { models().clear(); itemModels().clear(); registeredBlocks.clear(); @@ -292,35 +292,35 @@ public abstract class BlockStateProvider implements IDataProvider { }); } - public void stairsBlock(StairsBlock block, ResourceLocation texture) { + public void stairsBlock(StairBlock block, ResourceLocation texture) { stairsBlock(block, texture, texture, texture); } - public void stairsBlock(StairsBlock block, String name, ResourceLocation texture) { + public void stairsBlock(StairBlock block, String name, ResourceLocation texture) { stairsBlock(block, name, texture, texture, texture); } - public void stairsBlock(StairsBlock block, ResourceLocation side, ResourceLocation bottom, ResourceLocation top) { + public void stairsBlock(StairBlock block, ResourceLocation side, ResourceLocation bottom, ResourceLocation top) { stairsBlockInternal(block, block.getRegistryName().toString(), side, bottom, top); } - public void stairsBlock(StairsBlock block, String name, ResourceLocation side, ResourceLocation bottom, ResourceLocation top) { + public void stairsBlock(StairBlock block, String name, ResourceLocation side, ResourceLocation bottom, ResourceLocation top) { stairsBlockInternal(block, name + "_stairs", side, bottom, top); } - private void stairsBlockInternal(StairsBlock block, String baseName, ResourceLocation side, ResourceLocation bottom, ResourceLocation top) { + private void stairsBlockInternal(StairBlock block, String baseName, ResourceLocation side, ResourceLocation bottom, ResourceLocation top) { ModelFile stairs = models().stairs(baseName, side, bottom, top); ModelFile stairsInner = models().stairsInner(baseName + "_inner", side, bottom, top); ModelFile stairsOuter = models().stairsOuter(baseName + "_outer", side, bottom, top); stairsBlock(block, stairs, stairsInner, stairsOuter); } - public void stairsBlock(StairsBlock block, ModelFile stairs, ModelFile stairsInner, ModelFile stairsOuter) { + public void stairsBlock(StairBlock block, ModelFile stairs, ModelFile stairsInner, ModelFile stairsOuter) { getVariantBuilder(block) .forAllStatesExcept(state -> { - Direction facing = state.getValue(StairsBlock.FACING); - Half half = state.getValue(StairsBlock.HALF); - StairsShape shape = state.getValue(StairsBlock.SHAPE); + Direction facing = state.getValue(StairBlock.FACING); + Half half = state.getValue(StairBlock.HALF); + StairsShape shape = state.getValue(StairBlock.SHAPE); int yRot = (int) facing.getClockWise().toYRot(); // Stairs model is rotated 90 degrees clockwise for some reason if (shape == StairsShape.INNER_LEFT || shape == StairsShape.OUTER_LEFT) { yRot += 270; // Left facing stairs are rotated 90 degrees clockwise @@ -336,7 +336,7 @@ public abstract class BlockStateProvider implements IDataProvider { .rotationY(yRot) .uvLock(uvlock) .build(); - }, StairsBlock.WATERLOGGED); + }, StairBlock.WATERLOGGED); } public void slabBlock(SlabBlock block, ResourceLocation doubleslab, ResourceLocation texture) { @@ -354,14 +354,14 @@ public abstract class BlockStateProvider implements IDataProvider { .partialState().with(SlabBlock.TYPE, SlabType.DOUBLE).addModels(new ConfiguredModel(doubleslab)); } - public void fourWayBlock(FourWayBlock block, ModelFile post, ModelFile side) { + public void fourWayBlock(CrossCollisionBlock block, ModelFile post, ModelFile side) { MultiPartBlockStateBuilder builder = getMultipartBuilder(block) .part().modelFile(post).addModel().end(); fourWayMultipart(builder, side); } public void fourWayMultipart(MultiPartBlockStateBuilder builder, ModelFile side) { - SixWayBlock.PROPERTY_BY_DIRECTION.entrySet().forEach(e -> { + PipeBlock.PROPERTY_BY_DIRECTION.entrySet().forEach(e -> { Direction dir = e.getKey(); if (dir.getAxis().isHorizontal()) { builder.part().modelFile(side).rotationY((((int) dir.toYRot()) + 180) % 360).uvLock(true).addModel() @@ -424,7 +424,7 @@ public abstract class BlockStateProvider implements IDataProvider { wallBlock(block, models().wallPost(baseName + "_post", texture), models().wallSide(baseName + "_side", texture), models().wallSideTall(baseName + "_side_tall", texture)); } - public static final ImmutableMap> WALL_PROPS = ImmutableMap.>builder() + public static final ImmutableMap> WALL_PROPS = ImmutableMap.>builder() .put(Direction.EAST, BlockStateProperties.EAST_WALL) .put(Direction.NORTH, BlockStateProperties.NORTH_WALL) .put(Direction.SOUTH, BlockStateProperties.SOUTH_WALL) @@ -438,12 +438,12 @@ public abstract class BlockStateProvider implements IDataProvider { WALL_PROPS.entrySet().stream() .filter(e -> e.getKey().getAxis().isHorizontal()) .forEach(e -> { - wallSidePart(builder, side, e, WallHeight.LOW); - wallSidePart(builder, sideTall, e, WallHeight.TALL); + wallSidePart(builder, side, e, WallSide.LOW); + wallSidePart(builder, sideTall, e, WallSide.TALL); }); } - private void wallSidePart(MultiPartBlockStateBuilder builder, ModelFile model, Map.Entry> entry, WallHeight height) { + private void wallSidePart(MultiPartBlockStateBuilder builder, ModelFile model, Map.Entry> entry, WallSide height) { builder.part() .modelFile(model) .rotationY((((int) entry.getKey().toYRot()) + 180) % 360) @@ -452,15 +452,15 @@ public abstract class BlockStateProvider implements IDataProvider { .condition(entry.getValue(), height); } - public void paneBlock(PaneBlock block, ResourceLocation pane, ResourceLocation edge) { + public void paneBlock(IronBarsBlock block, ResourceLocation pane, ResourceLocation edge) { paneBlockInternal(block, block.getRegistryName().toString(), pane, edge); } - public void paneBlock(PaneBlock block, String name, ResourceLocation pane, ResourceLocation edge) { + public void paneBlock(IronBarsBlock block, String name, ResourceLocation pane, ResourceLocation edge) { paneBlockInternal(block, name + "_pane", pane, edge); } - private void paneBlockInternal(PaneBlock block, String baseName, ResourceLocation pane, ResourceLocation edge) { + private void paneBlockInternal(IronBarsBlock block, String baseName, ResourceLocation pane, ResourceLocation edge) { ModelFile post = models().panePost(baseName + "_post", pane, edge); ModelFile side = models().paneSide(baseName + "_side", pane, edge); ModelFile sideAlt = models().paneSideAlt(baseName + "_side_alt", pane, edge); @@ -469,10 +469,10 @@ public abstract class BlockStateProvider implements IDataProvider { paneBlock(block, post, side, sideAlt, noSide, noSideAlt); } - public void paneBlock(PaneBlock block, ModelFile post, ModelFile side, ModelFile sideAlt, ModelFile noSide, ModelFile noSideAlt) { + public void paneBlock(IronBarsBlock block, ModelFile post, ModelFile side, ModelFile sideAlt, ModelFile noSide, ModelFile noSideAlt) { MultiPartBlockStateBuilder builder = getMultipartBuilder(block) .part().modelFile(post).addModel().end(); - SixWayBlock.PROPERTY_BY_DIRECTION.entrySet().forEach(e -> { + PipeBlock.PROPERTY_BY_DIRECTION.entrySet().forEach(e -> { Direction dir = e.getKey(); if (dir.getAxis().isHorizontal()) { boolean alt = dir == Direction.SOUTH; @@ -554,13 +554,13 @@ public abstract class BlockStateProvider implements IDataProvider { }, TrapDoorBlock.POWERED, TrapDoorBlock.WATERLOGGED); } - private void saveBlockState(DirectoryCache cache, JsonObject stateJson, Block owner) { + private void saveBlockState(HashCache cache, JsonObject stateJson, Block owner) { ResourceLocation blockName = Preconditions.checkNotNull(owner.getRegistryName()); Path mainOutput = generator.getOutputFolder(); String pathSuffix = "assets/" + blockName.getNamespace() + "/blockstates/" + blockName.getPath() + ".json"; Path outputPath = mainOutput.resolve(pathSuffix); try { - IDataProvider.save(GSON, cache, stateJson, outputPath); + DataProvider.save(GSON, cache, stateJson, outputPath); } catch (IOException e) { LOGGER.error("Couldn't save blockstate to {}", outputPath, e); } diff --git a/src/main/java/net/minecraftforge/client/model/generators/ConfiguredModel.java b/src/main/java/net/minecraftforge/client/model/generators/ConfiguredModel.java index 74fe5ae666..d84146fb0c 100644 --- a/src/main/java/net/minecraftforge/client/model/generators/ConfiguredModel.java +++ b/src/main/java/net/minecraftforge/client/model/generators/ConfiguredModel.java @@ -31,7 +31,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ObjectArrays; import com.google.gson.JsonObject; -import net.minecraft.client.renderer.model.ModelRotation; +import net.minecraft.client.resources.model.BlockModelRotation; import net.minecraftforge.client.model.generators.MultiPartBlockStateBuilder.PartBuilder; import net.minecraftforge.client.model.generators.VariantBlockStateBuilder.PartialBlockstate; @@ -135,7 +135,7 @@ public final class ConfiguredModel { } static void checkRotation(int rotationX, int rotationY) { - Preconditions.checkArgument(ModelRotation.by(rotationX, rotationY) != null, "Invalid model rotation x=%d, y=%d", rotationX, rotationY); + Preconditions.checkArgument(BlockModelRotation.by(rotationX, rotationY) != null, "Invalid model rotation x=%d, y=%d", rotationX, rotationY); } static void checkWeight(int weight) { @@ -166,7 +166,7 @@ public final class ConfiguredModel { return new Builder<>(); } - static Builder builder(VariantBlockStateBuilder outer, VariantBlockStateBuilder.PartialBlockstate state) { + static Builder builder(VariantBlockStateBuilder outer, PartialBlockstate state) { return new Builder<>(models -> outer.setModels(state, models), ImmutableList.of()); } diff --git a/src/main/java/net/minecraftforge/client/model/generators/CustomLoaderBuilder.java b/src/main/java/net/minecraftforge/client/model/generators/CustomLoaderBuilder.java index 65155b6499..337b4d53e8 100644 --- a/src/main/java/net/minecraftforge/client/model/generators/CustomLoaderBuilder.java +++ b/src/main/java/net/minecraftforge/client/model/generators/CustomLoaderBuilder.java @@ -21,7 +21,7 @@ package net.minecraftforge.client.model.generators; import com.google.common.base.Preconditions; import com.google.gson.JsonObject; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.common.data.ExistingFileHelper; import java.util.LinkedHashMap; diff --git a/src/main/java/net/minecraftforge/client/model/generators/ItemModelBuilder.java b/src/main/java/net/minecraftforge/client/model/generators/ItemModelBuilder.java index 6eb4ae4a08..6de5ac4577 100644 --- a/src/main/java/net/minecraftforge/client/model/generators/ItemModelBuilder.java +++ b/src/main/java/net/minecraftforge/client/model/generators/ItemModelBuilder.java @@ -28,7 +28,7 @@ import com.google.common.base.Preconditions; import com.google.gson.JsonArray; import com.google.gson.JsonObject; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.common.data.ExistingFileHelper; /** diff --git a/src/main/java/net/minecraftforge/client/model/generators/ModelBuilder.java b/src/main/java/net/minecraftforge/client/model/generators/ModelBuilder.java index 3f85c998f9..4c60bd7080 100644 --- a/src/main/java/net/minecraftforge/client/model/generators/ModelBuilder.java +++ b/src/main/java/net/minecraftforge/client/model/generators/ModelBuilder.java @@ -37,18 +37,19 @@ import com.google.gson.Gson; import com.google.gson.JsonArray; import com.google.gson.JsonObject; -import net.minecraft.client.renderer.model.BlockFaceUV; -import net.minecraft.client.renderer.model.BlockModel.GuiLight; -import net.minecraft.client.renderer.model.BlockPart; -import net.minecraft.client.renderer.model.BlockPartFace; -import net.minecraft.client.renderer.model.BlockPartRotation; -import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; -import net.minecraft.client.renderer.model.ItemTransformVec3f; -import net.minecraft.client.renderer.texture.MissingTextureSprite; -import net.minecraft.util.Direction; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3f; +import net.minecraft.client.renderer.block.model.BlockFaceUV; +import net.minecraft.client.renderer.block.model.BlockModel.GuiLight; +import net.minecraft.client.renderer.block.model.BlockElement; +import net.minecraft.client.renderer.block.model.BlockElementFace; +import net.minecraft.client.renderer.block.model.BlockElementRotation; +import net.minecraft.client.renderer.block.model.ItemTransforms; +import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType; +import net.minecraft.client.renderer.block.model.ItemTransform; +import net.minecraft.client.renderer.texture.MissingTextureAtlasSprite; +import net.minecraft.core.Direction; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Mth; +import com.mojang.math.Vector3f; import net.minecraftforge.common.data.ExistingFileHelper; /** @@ -238,20 +239,20 @@ public class ModelBuilder> extends ModelFile { root.addProperty("gui_light", this.guiLight.getSerializedName()); } - Map transforms = this.transforms.build(); + Map transforms = this.transforms.build(); if (!transforms.isEmpty()) { JsonObject display = new JsonObject(); - for (Entry e : transforms.entrySet()) { + for (Entry e : transforms.entrySet()) { JsonObject transform = new JsonObject(); - ItemTransformVec3f vec = e.getValue(); - if (vec.equals(ItemTransformVec3f.NO_TRANSFORM)) continue; - if (!vec.rotation.equals(ItemTransformVec3f.Deserializer.DEFAULT_ROTATION)) { + ItemTransform vec = e.getValue(); + if (vec.equals(ItemTransform.NO_TRANSFORM)) continue; + if (!vec.rotation.equals(ItemTransform.Deserializer.DEFAULT_ROTATION)) { transform.add("rotation", serializeVector3f(vec.rotation)); } - if (!vec.translation.equals(ItemTransformVec3f.Deserializer.DEFAULT_TRANSLATION)) { + if (!vec.translation.equals(ItemTransform.Deserializer.DEFAULT_TRANSLATION)) { transform.add("translation", serializeVector3f(e.getValue().translation)); } - if (!vec.scale.equals(ItemTransformVec3f.Deserializer.DEFAULT_SCALE)) { + if (!vec.scale.equals(ItemTransform.Deserializer.DEFAULT_SCALE)) { transform.add("scale", serializeVector3f(e.getValue().scale)); } display.add(e.getKey().name, transform); @@ -291,7 +292,7 @@ public class ModelBuilder> extends ModelFile { JsonObject faces = new JsonObject(); for (Direction dir : Direction.values()) { - BlockPartFace face = part.faces.get(dir); + BlockElementFace face = part.faces.get(dir); if (face == null) continue; JsonObject faceObj = new JsonObject(); @@ -489,10 +490,10 @@ public class ModelBuilder> extends ModelFile { return ($, f) -> f.texture(texture); } - BlockPart build() { - Map faces = this.faces.entrySet().stream() + BlockElement build() { + Map faces = this.faces.entrySet().stream() .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().build(), (k1, k2) -> { throw new IllegalArgumentException(); }, LinkedHashMap::new)); - return new BlockPart(from, to, faces, rotation == null ? null : rotation.build(), shade); + return new BlockElement(from, to, faces, rotation == null ? null : rotation.build(), shade); } public T end() { return self(); } @@ -501,7 +502,7 @@ public class ModelBuilder> extends ModelFile { private Direction cullface; private int tintindex = -1; - private String texture = MissingTextureSprite.getLocation().toString(); + private String texture = MissingTextureAtlasSprite.getLocation().toString(); private float[] uvs; private FaceRotation rotation = FaceRotation.ZERO; @@ -550,11 +551,11 @@ public class ModelBuilder> extends ModelFile { return this; } - BlockPartFace build() { + BlockElementFace build() { if (this.texture == null) { throw new IllegalStateException("A model face must have a texture"); } - return new BlockPartFace(cullface, tintindex, texture, new BlockFaceUV(uvs, rotation.rotation)); + return new BlockElementFace(cullface, tintindex, texture, new BlockFaceUV(uvs, rotation.rotation)); } public ElementBuilder end() { return ElementBuilder.this; } @@ -590,7 +591,7 @@ public class ModelBuilder> extends ModelFile { */ public RotationBuilder angle(float angle) { // Same logic from BlockPart.Deserializer#parseAngle - Preconditions.checkArgument(angle == 0.0F || MathHelper.abs(angle) == 22.5F || MathHelper.abs(angle) == 45.0F, "Invalid rotation %f found, only -45/-22.5/0/22.5/45 allowed", angle); + Preconditions.checkArgument(angle == 0.0F || Mth.abs(angle) == 22.5F || Mth.abs(angle) == 45.0F, "Invalid rotation %f found, only -45/-22.5/0/22.5/45 allowed", angle); this.angle = angle; return this; } @@ -600,8 +601,8 @@ public class ModelBuilder> extends ModelFile { return this; } - BlockPartRotation build() { - return new BlockPartRotation(origin, axis, angle, rescale); + BlockElementRotation build() { + return new BlockElementRotation(origin, axis, angle, rescale); } public ElementBuilder end() { return ElementBuilder.this; } @@ -660,7 +661,7 @@ public class ModelBuilder> extends ModelFile { return transforms.computeIfAbsent(type, TransformVecBuilder::new); } - Map build() { + Map build() { return this.transforms.entrySet().stream() .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().build(), (k1, k2) -> { throw new IllegalArgumentException(); }, LinkedHashMap::new)); } @@ -669,9 +670,9 @@ public class ModelBuilder> extends ModelFile { public class TransformVecBuilder { - private Vector3f rotation = new Vector3f(); - private Vector3f translation = new Vector3f(); - private Vector3f scale = new Vector3f(); + private Vector3f rotation = ItemTransform.Deserializer.DEFAULT_ROTATION.copy(); + private Vector3f translation = ItemTransform.Deserializer.DEFAULT_TRANSLATION.copy(); + private Vector3f scale = ItemTransform.Deserializer.DEFAULT_SCALE.copy(); TransformVecBuilder(Perspective type) { // param unused for functional match @@ -696,8 +697,8 @@ public class ModelBuilder> extends ModelFile { return this; } - ItemTransformVec3f build() { - return new ItemTransformVec3f(rotation, translation, scale); + ItemTransform build() { + return new ItemTransform(rotation, translation, scale); } public TransformsBuilder end() { return TransformsBuilder.this; } diff --git a/src/main/java/net/minecraftforge/client/model/generators/ModelFile.java b/src/main/java/net/minecraftforge/client/model/generators/ModelFile.java index 645a98d530..d6d0c1a302 100644 --- a/src/main/java/net/minecraftforge/client/model/generators/ModelFile.java +++ b/src/main/java/net/minecraftforge/client/model/generators/ModelFile.java @@ -21,7 +21,7 @@ package net.minecraftforge.client.model.generators; import com.google.common.base.Preconditions; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.common.data.ExistingFileHelper; public abstract class ModelFile { diff --git a/src/main/java/net/minecraftforge/client/model/generators/ModelProvider.java b/src/main/java/net/minecraftforge/client/model/generators/ModelProvider.java index e6092b6974..799c557b58 100644 --- a/src/main/java/net/minecraftforge/client/model/generators/ModelProvider.java +++ b/src/main/java/net/minecraftforge/client/model/generators/ModelProvider.java @@ -32,21 +32,21 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import net.minecraft.data.DataGenerator; -import net.minecraft.data.DirectoryCache; -import net.minecraft.data.IDataProvider; -import net.minecraft.resources.ResourcePackType; -import net.minecraft.util.ResourceLocation; +import net.minecraft.data.HashCache; +import net.minecraft.data.DataProvider; +import net.minecraft.server.packs.PackType; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.common.data.ExistingFileHelper; import net.minecraftforge.common.data.ExistingFileHelper.ResourceType; -public abstract class ModelProvider> implements IDataProvider { +public abstract class ModelProvider> implements DataProvider { public static final String BLOCK_FOLDER = "block"; public static final String ITEM_FOLDER = "item"; - protected static final ResourceType TEXTURE = new ResourceType(ResourcePackType.CLIENT_RESOURCES, ".png", "textures"); - protected static final ResourceType MODEL = new ResourceType(ResourcePackType.CLIENT_RESOURCES, ".json", "models"); - protected static final ResourceType MODEL_WITH_EXTENSION = new ResourceType(ResourcePackType.CLIENT_RESOURCES, "", "models"); + protected static final ResourceType TEXTURE = new ResourceType(PackType.CLIENT_RESOURCES, ".png", "textures"); + protected static final ResourceType MODEL = new ResourceType(PackType.CLIENT_RESOURCES, ".json", "models"); + protected static final ResourceType MODEL_WITH_EXTENSION = new ResourceType(PackType.CLIENT_RESOURCES, "", "models"); private static final Gson GSON = (new GsonBuilder()).setPrettyPrinting().create(); protected final DataGenerator generator; @@ -363,17 +363,17 @@ public abstract class ModelProvider> implements IDataP } @Override - public void run(DirectoryCache cache) throws IOException { + public void run(HashCache cache) throws IOException { clear(); registerModels(); generateAll(cache); } - protected void generateAll(DirectoryCache cache) { + protected void generateAll(HashCache cache) { for (T model : generatedModels.values()) { Path target = getPath(model); try { - IDataProvider.save(GSON, cache, model.toJson(), target); + DataProvider.save(GSON, cache, model.toJson(), target); } catch (IOException e) { throw new RuntimeException(e); } diff --git a/src/main/java/net/minecraftforge/client/model/generators/MultiPartBlockStateBuilder.java b/src/main/java/net/minecraftforge/client/model/generators/MultiPartBlockStateBuilder.java index a3c33c9104..5c9f958a59 100644 --- a/src/main/java/net/minecraftforge/client/model/generators/MultiPartBlockStateBuilder.java +++ b/src/main/java/net/minecraftforge/client/model/generators/MultiPartBlockStateBuilder.java @@ -32,8 +32,8 @@ import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import net.minecraft.block.Block; -import net.minecraft.state.Property; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.properties.Property; public final class MultiPartBlockStateBuilder implements IGeneratedBlockstate { diff --git a/src/main/java/net/minecraftforge/client/model/generators/VariantBlockStateBuilder.java b/src/main/java/net/minecraftforge/client/model/generators/VariantBlockStateBuilder.java index 5fc04b0f67..5177abae09 100644 --- a/src/main/java/net/minecraftforge/client/model/generators/VariantBlockStateBuilder.java +++ b/src/main/java/net/minecraftforge/client/model/generators/VariantBlockStateBuilder.java @@ -42,9 +42,9 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.gson.JsonObject; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.state.Property; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.Property; import net.minecraftforge.client.model.generators.BlockStateProvider.ConfiguredModelList; /** diff --git a/src/main/java/net/minecraftforge/client/model/generators/loaders/CompositeModelBuilder.java b/src/main/java/net/minecraftforge/client/model/generators/loaders/CompositeModelBuilder.java index e847ed228c..6249f8fc3d 100644 --- a/src/main/java/net/minecraftforge/client/model/generators/loaders/CompositeModelBuilder.java +++ b/src/main/java/net/minecraftforge/client/model/generators/loaders/CompositeModelBuilder.java @@ -21,8 +21,7 @@ package net.minecraftforge.client.model.generators.loaders; import com.google.common.base.Preconditions; import com.google.gson.JsonObject; -import net.minecraft.fluid.Fluid; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.client.model.generators.CustomLoaderBuilder; import net.minecraftforge.client.model.generators.ModelBuilder; import net.minecraftforge.common.data.ExistingFileHelper; diff --git a/src/main/java/net/minecraftforge/client/model/generators/loaders/DynamicBucketModelBuilder.java b/src/main/java/net/minecraftforge/client/model/generators/loaders/DynamicBucketModelBuilder.java index f3b96b9011..df7b67f331 100644 --- a/src/main/java/net/minecraftforge/client/model/generators/loaders/DynamicBucketModelBuilder.java +++ b/src/main/java/net/minecraftforge/client/model/generators/loaders/DynamicBucketModelBuilder.java @@ -21,8 +21,8 @@ package net.minecraftforge.client.model.generators.loaders; import com.google.common.base.Preconditions; import com.google.gson.JsonObject; -import net.minecraft.fluid.Fluid; -import net.minecraft.util.ResourceLocation; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.client.model.generators.CustomLoaderBuilder; import net.minecraftforge.client.model.generators.ModelBuilder; import net.minecraftforge.common.data.ExistingFileHelper; diff --git a/src/main/java/net/minecraftforge/client/model/generators/loaders/ItemLayersModelBuilder.java b/src/main/java/net/minecraftforge/client/model/generators/loaders/ItemLayersModelBuilder.java index 49e4cfa085..f43fb0b150 100644 --- a/src/main/java/net/minecraftforge/client/model/generators/loaders/ItemLayersModelBuilder.java +++ b/src/main/java/net/minecraftforge/client/model/generators/loaders/ItemLayersModelBuilder.java @@ -22,7 +22,7 @@ package net.minecraftforge.client.model.generators.loaders; import com.google.common.base.Preconditions; import com.google.gson.JsonArray; import com.google.gson.JsonObject; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.client.model.generators.CustomLoaderBuilder; import net.minecraftforge.client.model.generators.ModelBuilder; import net.minecraftforge.common.data.ExistingFileHelper; diff --git a/src/main/java/net/minecraftforge/client/model/generators/loaders/MultiLayerModelBuilder.java b/src/main/java/net/minecraftforge/client/model/generators/loaders/MultiLayerModelBuilder.java index 67bcf85bc5..3322d96c4b 100644 --- a/src/main/java/net/minecraftforge/client/model/generators/loaders/MultiLayerModelBuilder.java +++ b/src/main/java/net/minecraftforge/client/model/generators/loaders/MultiLayerModelBuilder.java @@ -22,7 +22,7 @@ package net.minecraftforge.client.model.generators.loaders; import com.google.common.base.Preconditions; import com.google.gson.JsonObject; import net.minecraft.client.renderer.RenderType; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.client.model.MultiLayerModel; import net.minecraftforge.client.model.generators.CustomLoaderBuilder; import net.minecraftforge.client.model.generators.ModelBuilder; diff --git a/src/main/java/net/minecraftforge/client/model/generators/loaders/OBJLoaderBuilder.java b/src/main/java/net/minecraftforge/client/model/generators/loaders/OBJLoaderBuilder.java index 173545eea7..3a45aa9412 100644 --- a/src/main/java/net/minecraftforge/client/model/generators/loaders/OBJLoaderBuilder.java +++ b/src/main/java/net/minecraftforge/client/model/generators/loaders/OBJLoaderBuilder.java @@ -21,8 +21,8 @@ package net.minecraftforge.client.model.generators.loaders; import com.google.common.base.Preconditions; import com.google.gson.JsonObject; -import net.minecraft.resources.ResourcePackType; -import net.minecraft.util.ResourceLocation; +import net.minecraft.server.packs.PackType; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.client.model.generators.CustomLoaderBuilder; import net.minecraftforge.client.model.generators.ModelBuilder; import net.minecraftforge.common.data.ExistingFileHelper; @@ -49,7 +49,7 @@ public class OBJLoaderBuilder> extends CustomLoaderBui public OBJLoaderBuilder modelLocation(ResourceLocation modelLocation) { Preconditions.checkNotNull(modelLocation, "modelLocation must not be null"); - Preconditions.checkArgument(existingFileHelper.exists(modelLocation, ResourcePackType.CLIENT_RESOURCES), + Preconditions.checkArgument(existingFileHelper.exists(modelLocation, PackType.CLIENT_RESOURCES), "OBJ Model %s does not exist in any known resource pack", modelLocation); this.modelLocation = modelLocation; return this; @@ -82,7 +82,7 @@ public class OBJLoaderBuilder> extends CustomLoaderBui public OBJLoaderBuilder overrideMaterialLibrary(ResourceLocation materialLibraryOverrideLocation) { Preconditions.checkNotNull(materialLibraryOverrideLocation, "materialLibraryOverrideLocation must not be null"); - Preconditions.checkArgument(existingFileHelper.exists(materialLibraryOverrideLocation, ResourcePackType.CLIENT_RESOURCES), + Preconditions.checkArgument(existingFileHelper.exists(materialLibraryOverrideLocation, PackType.CLIENT_RESOURCES), "OBJ Model %s does not exist in any known resource pack", materialLibraryOverrideLocation); this.materialLibraryOverrideLocation = materialLibraryOverrideLocation; return this; diff --git a/src/main/java/net/minecraftforge/client/model/generators/loaders/SeparatePerspectiveModelBuilder.java b/src/main/java/net/minecraftforge/client/model/generators/loaders/SeparatePerspectiveModelBuilder.java index ef2354d4c4..8248517623 100644 --- a/src/main/java/net/minecraftforge/client/model/generators/loaders/SeparatePerspectiveModelBuilder.java +++ b/src/main/java/net/minecraftforge/client/model/generators/loaders/SeparatePerspectiveModelBuilder.java @@ -21,9 +21,8 @@ package net.minecraftforge.client.model.generators.loaders; import com.google.common.base.Preconditions; import com.google.gson.JsonObject; -import net.minecraft.client.renderer.model.ItemCameraTransforms; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.client.model.MultiLayerModel; +import net.minecraft.client.renderer.block.model.ItemTransforms; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.client.model.SeparatePerspectiveModel; import net.minecraftforge.client.model.generators.CustomLoaderBuilder; import net.minecraftforge.client.model.generators.ModelBuilder; @@ -54,7 +53,7 @@ public class SeparatePerspectiveModelBuilder> extends return this; } - public SeparatePerspectiveModelBuilder perspective(ItemCameraTransforms.TransformType perspective, T modelBuilder) + public SeparatePerspectiveModelBuilder perspective(ItemTransforms.TransformType perspective, T modelBuilder) { Preconditions.checkNotNull(perspective, "layer must not be null"); Preconditions.checkArgument(SeparatePerspectiveModel.Loader.PERSPECTIVES.containsValue(perspective), "perspective is not included in SeparatePerspectiveModel. New mc version?"); diff --git a/src/main/java/net/minecraftforge/client/model/geometry/IModelGeometry.java b/src/main/java/net/minecraftforge/client/model/geometry/IModelGeometry.java index 41329f1870..9839ebf03b 100644 --- a/src/main/java/net/minecraftforge/client/model/geometry/IModelGeometry.java +++ b/src/main/java/net/minecraftforge/client/model/geometry/IModelGeometry.java @@ -20,9 +20,8 @@ package net.minecraftforge.client.model.geometry; import com.mojang.datafixers.util.Pair; -import net.minecraft.client.renderer.model.*; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.client.model.IModelConfiguration; import java.util.Collection; @@ -31,6 +30,13 @@ import java.util.Optional; import java.util.Set; import java.util.function.Function; +import net.minecraft.client.renderer.block.model.ItemOverrides; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.resources.model.Material; +import net.minecraft.client.resources.model.ModelBakery; +import net.minecraft.client.resources.model.ModelState; +import net.minecraft.client.resources.model.UnbakedModel; + /** * General interface for any model that can be baked, superset of vanilla {@link net.minecraft.client.renderer.model.IUnbakedModel}. * Models can be baked to different vertex formats and with different state. @@ -45,7 +51,7 @@ public interface IModelGeometry> return Optional.empty(); } - IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation); + BakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function spriteGetter, ModelState modelTransform, ItemOverrides overrides, ResourceLocation modelLocation); - Collection getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors); + Collection getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors); } diff --git a/src/main/java/net/minecraftforge/client/model/geometry/IModelGeometryPart.java b/src/main/java/net/minecraftforge/client/model/geometry/IModelGeometryPart.java index cdb6ccf19f..a401574544 100644 --- a/src/main/java/net/minecraftforge/client/model/geometry/IModelGeometryPart.java +++ b/src/main/java/net/minecraftforge/client/model/geometry/IModelGeometryPart.java @@ -20,12 +20,12 @@ package net.minecraftforge.client.model.geometry; import com.mojang.datafixers.util.Pair; -import net.minecraft.client.renderer.model.IModelTransform; -import net.minecraft.client.renderer.model.IUnbakedModel; -import net.minecraft.client.renderer.model.ModelBakery; -import net.minecraft.client.renderer.model.RenderMaterial; +import net.minecraft.client.resources.model.ModelState; +import net.minecraft.client.resources.model.UnbakedModel; +import net.minecraft.client.resources.model.ModelBakery; +import net.minecraft.client.resources.model.Material; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.client.model.IModelBuilder; import net.minecraftforge.client.model.IModelConfiguration; @@ -38,9 +38,9 @@ public interface IModelGeometryPart { String name(); - void addQuads(IModelConfiguration owner, IModelBuilder modelBuilder, ModelBakery bakery, Function spriteGetter, IModelTransform modelTransform, ResourceLocation modelLocation); + void addQuads(IModelConfiguration owner, IModelBuilder modelBuilder, ModelBakery bakery, Function spriteGetter, ModelState modelTransform, ResourceLocation modelLocation); - default Collection getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors) { + default Collection getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors) { // No texture dependencies return Collections.emptyList(); } diff --git a/src/main/java/net/minecraftforge/client/model/geometry/IMultipartModelGeometry.java b/src/main/java/net/minecraftforge/client/model/geometry/IMultipartModelGeometry.java index 1f4aaf8ed0..490668d2c1 100644 --- a/src/main/java/net/minecraftforge/client/model/geometry/IMultipartModelGeometry.java +++ b/src/main/java/net/minecraftforge/client/model/geometry/IMultipartModelGeometry.java @@ -21,12 +21,12 @@ package net.minecraftforge.client.model.geometry; import com.google.common.collect.Sets; import com.mojang.datafixers.util.Pair; -import net.minecraft.client.renderer.model.IModelTransform; -import net.minecraft.client.renderer.model.IUnbakedModel; -import net.minecraft.client.renderer.model.ModelBakery; -import net.minecraft.client.renderer.model.RenderMaterial; +import net.minecraft.client.resources.model.ModelState; +import net.minecraft.client.resources.model.UnbakedModel; +import net.minecraft.client.resources.model.ModelBakery; +import net.minecraft.client.resources.model.Material; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.client.model.IModelBuilder; import net.minecraftforge.client.model.IModelConfiguration; @@ -43,16 +43,16 @@ public interface IMultipartModelGeometry> e Optional getPart(String name); @Override - default void addQuads(IModelConfiguration owner, IModelBuilder modelBuilder, ModelBakery bakery, Function spriteGetter, IModelTransform modelTransform, ResourceLocation modelLocation) + default void addQuads(IModelConfiguration owner, IModelBuilder modelBuilder, ModelBakery bakery, Function spriteGetter, ModelState modelTransform, ResourceLocation modelLocation) { getParts().stream().filter(part -> owner.getPartVisibility(part)) .forEach(part -> part.addQuads(owner, modelBuilder, bakery, spriteGetter, modelTransform, modelLocation)); } @Override - default Collection getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors) + default Collection getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors) { - Set combined = Sets.newHashSet(); + Set combined = Sets.newHashSet(); for (IModelGeometryPart part : getParts()) combined.addAll(part.getTextures(owner, modelGetter, missingTextureErrors)); return combined; diff --git a/src/main/java/net/minecraftforge/client/model/geometry/ISimpleModelGeometry.java b/src/main/java/net/minecraftforge/client/model/geometry/ISimpleModelGeometry.java index 64e001c79b..66fc4b3207 100644 --- a/src/main/java/net/minecraftforge/client/model/geometry/ISimpleModelGeometry.java +++ b/src/main/java/net/minecraftforge/client/model/geometry/ISimpleModelGeometry.java @@ -20,9 +20,8 @@ package net.minecraftforge.client.model.geometry; import com.mojang.datafixers.util.Pair; -import net.minecraft.client.renderer.model.*; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.client.model.IModelBuilder; import net.minecraftforge.client.model.IModelConfiguration; @@ -30,10 +29,17 @@ import java.util.Collection; import java.util.Set; import java.util.function.Function; +import net.minecraft.client.renderer.block.model.ItemOverrides; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.resources.model.Material; +import net.minecraft.client.resources.model.ModelBakery; +import net.minecraft.client.resources.model.ModelState; +import net.minecraft.client.resources.model.UnbakedModel; + public interface ISimpleModelGeometry> extends IModelGeometry { @Override - default IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) + default BakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function spriteGetter, ModelState modelTransform, ItemOverrides overrides, ResourceLocation modelLocation) { TextureAtlasSprite particle = spriteGetter.apply(owner.resolveTexture("particle")); @@ -44,8 +50,8 @@ public interface ISimpleModelGeometry> extends return builder.build(); } - void addQuads(IModelConfiguration owner, IModelBuilder modelBuilder, ModelBakery bakery, Function spriteGetter, IModelTransform modelTransform, ResourceLocation modelLocation); + void addQuads(IModelConfiguration owner, IModelBuilder modelBuilder, ModelBakery bakery, Function spriteGetter, ModelState modelTransform, ResourceLocation modelLocation); @Override - Collection getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors); + Collection getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors); } diff --git a/src/main/java/net/minecraftforge/client/model/obj/LineReader.java b/src/main/java/net/minecraftforge/client/model/obj/LineReader.java index 135a1e676a..10460e4888 100644 --- a/src/main/java/net/minecraftforge/client/model/obj/LineReader.java +++ b/src/main/java/net/minecraftforge/client/model/obj/LineReader.java @@ -21,7 +21,7 @@ package net.minecraftforge.client.model.obj; import com.google.common.base.Charsets; import joptsimple.internal.Strings; -import net.minecraft.resources.IResource; +import net.minecraft.server.packs.resources.Resource; import javax.annotation.Nullable; import java.io.BufferedReader; @@ -36,7 +36,7 @@ public class LineReader implements AutoCloseable InputStreamReader lineStream; BufferedReader lineReader; - public LineReader(IResource resource) + public LineReader(Resource resource) { this.lineStream = new InputStreamReader(resource.getInputStream(), Charsets.UTF_8); this.lineReader = new BufferedReader(lineStream); diff --git a/src/main/java/net/minecraftforge/client/model/obj/MaterialLibrary.java b/src/main/java/net/minecraftforge/client/model/obj/MaterialLibrary.java index d478606a26..2d1b9ea911 100644 --- a/src/main/java/net/minecraftforge/client/model/obj/MaterialLibrary.java +++ b/src/main/java/net/minecraftforge/client/model/obj/MaterialLibrary.java @@ -21,7 +21,7 @@ package net.minecraftforge.client.model.obj; import com.google.common.collect.Maps; import joptsimple.internal.Strings; -import net.minecraft.util.math.vector.Vector4f; +import com.mojang.math.Vector4f; import java.io.IOException; import java.util.Arrays; diff --git a/src/main/java/net/minecraftforge/client/model/obj/OBJLoader.java b/src/main/java/net/minecraftforge/client/model/obj/OBJLoader.java index fb8a90814b..f5e7be9616 100644 --- a/src/main/java/net/minecraftforge/client/model/obj/OBJLoader.java +++ b/src/main/java/net/minecraftforge/client/model/obj/OBJLoader.java @@ -23,15 +23,14 @@ import com.google.common.collect.Maps; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonObject; import net.minecraft.client.Minecraft; -import net.minecraft.resources.IResource; -import net.minecraft.resources.IResourceManager; -import net.minecraft.util.JSONUtils; -import net.minecraft.util.ResourceLocation; +import net.minecraft.server.packs.resources.Resource; +import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.util.GsonHelper; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.client.model.IModelLoader; import javax.annotation.Nullable; import java.io.FileNotFoundException; -import java.io.IOException; import java.util.*; public class OBJLoader implements IModelLoader @@ -41,10 +40,10 @@ public class OBJLoader implements IModelLoader private final Map modelCache = Maps.newHashMap(); private final Map materialCache = Maps.newHashMap(); - private IResourceManager manager = Minecraft.getInstance().getResourceManager(); + private ResourceManager manager = Minecraft.getInstance().getResourceManager(); @Override - public void onResourceManagerReload(IResourceManager resourceManager) + public void onResourceManagerReload(ResourceManager resourceManager) { modelCache.clear(); materialCache.clear(); @@ -59,12 +58,12 @@ public class OBJLoader implements IModelLoader String modelLocation = modelContents.get("model").getAsString(); - boolean detectCullableFaces = JSONUtils.getAsBoolean(modelContents, "detectCullableFaces", true); - boolean diffuseLighting = JSONUtils.getAsBoolean(modelContents, "diffuseLighting", false); - boolean flipV = JSONUtils.getAsBoolean(modelContents, "flip-v", false); - boolean ambientToFullbright = JSONUtils.getAsBoolean(modelContents, "ambientToFullbright", true); + boolean detectCullableFaces = GsonHelper.getAsBoolean(modelContents, "detectCullableFaces", true); + boolean diffuseLighting = GsonHelper.getAsBoolean(modelContents, "diffuseLighting", false); + boolean flipV = GsonHelper.getAsBoolean(modelContents, "flip-v", false); + boolean ambientToFullbright = GsonHelper.getAsBoolean(modelContents, "ambientToFullbright", true); @Nullable - String materialLibraryOverrideLocation = modelContents.has("materialLibraryOverride") ? JSONUtils.getAsString(modelContents, "materialLibraryOverride") : null; + String materialLibraryOverrideLocation = modelContents.has("materialLibraryOverride") ? GsonHelper.getAsString(modelContents, "materialLibraryOverride") : null; return loadModel(new OBJModel.ModelSettings(new ResourceLocation(modelLocation), detectCullableFaces, diffuseLighting, flipV, ambientToFullbright, materialLibraryOverrideLocation)); } @@ -73,7 +72,7 @@ public class OBJLoader implements IModelLoader { return modelCache.computeIfAbsent(settings, (data) -> { - try(IResource resource = manager.getResource(settings.modelLocation); + try(Resource resource = manager.getResource(settings.modelLocation); LineReader rdr = new LineReader(resource)) { return new OBJModel(rdr, settings); @@ -92,7 +91,7 @@ public class OBJLoader implements IModelLoader public MaterialLibrary loadMaterialLibrary(ResourceLocation materialLocation) { return materialCache.computeIfAbsent(materialLocation, (location) -> { - try(IResource resource = manager.getResource(location); + try(Resource resource = manager.getResource(location); LineReader rdr = new LineReader(resource)) { return new MaterialLibrary(rdr); diff --git a/src/main/java/net/minecraftforge/client/model/obj/OBJModel.java b/src/main/java/net/minecraftforge/client/model/obj/OBJModel.java index 0ea8a45602..77b6e802d3 100644 --- a/src/main/java/net/minecraftforge/client/model/obj/OBJModel.java +++ b/src/main/java/net/minecraftforge/client/model/obj/OBJModel.java @@ -24,16 +24,15 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import joptsimple.internal.Strings; -import net.minecraft.client.renderer.model.*; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.renderer.vertex.VertexFormatElement; -import net.minecraft.util.Direction; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.TransformationMatrix; -import net.minecraft.util.math.vector.Vector2f; -import net.minecraft.util.math.vector.Vector3f; -import net.minecraft.util.math.vector.Vector4f; +import com.mojang.blaze3d.vertex.VertexFormatElement; +import net.minecraft.core.Direction; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Mth; +import com.mojang.math.Transformation; +import net.minecraft.world.phys.Vec2; +import com.mojang.math.Vector3f; +import com.mojang.math.Vector4f; import net.minecraftforge.client.model.*; import net.minecraftforge.client.model.geometry.IModelGeometryPart; import net.minecraftforge.client.model.geometry.IMultipartModelGeometry; @@ -48,20 +47,26 @@ import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; +import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.resources.model.Material; +import net.minecraft.client.resources.model.ModelBakery; +import net.minecraft.client.resources.model.ModelState; +import net.minecraft.client.resources.model.UnbakedModel; + public class OBJModel implements IMultipartModelGeometry { private static Vector4f COLOR_WHITE = new Vector4f(1, 1, 1, 1); - private static Vector2f[] DEFAULT_COORDS = { - new Vector2f(0, 0), - new Vector2f(0, 1), - new Vector2f(1, 1), - new Vector2f(1, 0), + private static Vec2[] DEFAULT_COORDS = { + new Vec2(0, 0), + new Vec2(0, 1), + new Vec2(1, 1), + new Vec2(1, 0), }; private final Map parts = Maps.newHashMap(); private final List positions = Lists.newArrayList(); - private final List texCoords = Lists.newArrayList(); + private final List texCoords = Lists.newArrayList(); private final List normals = Lists.newArrayList(); private final List colors = Lists.newArrayList(); @@ -295,12 +300,12 @@ public class OBJModel implements IMultipartModelGeometry } } - public static Vector2f parseVector2(String[] line) + public static Vec2 parseVector2(String[] line) { switch (line.length) { - case 1: return new Vector2f(0,0); - case 2: return new Vector2f(Float.parseFloat(line[1]), 0); - default: return new Vector2f(Float.parseFloat(line[1]), Float.parseFloat(line[2])); + case 1: return new Vec2(0,0); + case 2: return new Vec2(Float.parseFloat(line[1]), 0); + default: return new Vec2(Float.parseFloat(line[1]), Float.parseFloat(line[2])); } } @@ -337,7 +342,7 @@ public class OBJModel implements IMultipartModelGeometry return Optional.ofNullable(parts.get(name)); } - private Pair makeQuad(int[][] indices, int tintIndex, Vector4f colorTint, Vector4f ambientColor, TextureAtlasSprite texture, TransformationMatrix transform) + private Pair makeQuad(int[][] indices, int tintIndex, Vector4f colorTint, Vector4f ambientColor, TextureAtlasSprite texture, Transformation transform) { boolean needsNormalRecalculation = false; for (int[] ints : indices) @@ -365,11 +370,11 @@ public class OBJModel implements IMultipartModelGeometry builder.setQuadTint(tintIndex); - Vector2f uv2 = new Vector2f(0, 0); + Vec2 uv2 = new Vec2(0, 0); if (ambientToFullbright) { int fakeLight = (int) ((ambientColor.x() + ambientColor.y() + ambientColor.z()) * 15 / 3.0f); - uv2 = new Vector2f((fakeLight << 4) / 32767.0f, (fakeLight << 4) / 32767.0f); + uv2 = new Vec2((fakeLight << 4) / 32767.0f, (fakeLight << 4) / 32767.0f); builder.setApplyDiffuseLighting(fakeLight == 0); } else @@ -379,14 +384,14 @@ public class OBJModel implements IMultipartModelGeometry boolean hasTransform = !transform.isIdentity(); // The incoming transform is referenced on the center of the block, but our coords are referenced on the corner - TransformationMatrix transformation = hasTransform ? transform.blockCenterToCorner() : transform; + Transformation transformation = hasTransform ? transform.blockCenterToCorner() : transform; for(int i=0;i<4;i++) { int[] index = indices[Math.min(i,indices.length-1)]; Vector3f pos0 = positions.get(index[0]); Vector4f position = new Vector4f(pos0); - Vector2f texCoord = index.length >= 2 && texCoords.size() > 0 ? texCoords.get(index[1]) : DEFAULT_COORDS[i]; + Vec2 texCoord = index.length >= 2 && texCoords.size() > 0 ? texCoords.get(index[1]) : DEFAULT_COORDS[i]; Vector3f norm0 = !needsNormalRecalculation && index.length >= 3 && normals.size() > 0 ? normals.get(index[2]) : faceNormal; Vector3f normal = norm0; Vector4f color = index.length >= 4 && colors.size() > 0 ? colors.get(index[3]) : COLOR_WHITE; @@ -411,50 +416,50 @@ public class OBJModel implements IMultipartModelGeometry Direction cull = null; if (detectCullableFaces) { - if (MathHelper.equal(pos[0].x(), 0) && // vertex.position.x - MathHelper.equal(pos[1].x(), 0) && - MathHelper.equal(pos[2].x(), 0) && - MathHelper.equal(pos[3].x(), 0) && + if (Mth.equal(pos[0].x(), 0) && // vertex.position.x + Mth.equal(pos[1].x(), 0) && + Mth.equal(pos[2].x(), 0) && + Mth.equal(pos[3].x(), 0) && norm[0].x() < 0) // vertex.normal.x { cull = Direction.WEST; } - else if (MathHelper.equal(pos[0].x(), 1) && // vertex.position.x - MathHelper.equal(pos[1].x(), 1) && - MathHelper.equal(pos[2].x(), 1) && - MathHelper.equal(pos[3].x(), 1) && + else if (Mth.equal(pos[0].x(), 1) && // vertex.position.x + Mth.equal(pos[1].x(), 1) && + Mth.equal(pos[2].x(), 1) && + Mth.equal(pos[3].x(), 1) && norm[0].x() > 0) // vertex.normal.x { cull = Direction.EAST; } - else if (MathHelper.equal(pos[0].z(), 0) && // vertex.position.z - MathHelper.equal(pos[1].z(), 0) && - MathHelper.equal(pos[2].z(), 0) && - MathHelper.equal(pos[3].z(), 0) && + else if (Mth.equal(pos[0].z(), 0) && // vertex.position.z + Mth.equal(pos[1].z(), 0) && + Mth.equal(pos[2].z(), 0) && + Mth.equal(pos[3].z(), 0) && norm[0].z() < 0) // vertex.normal.z { cull = Direction.NORTH; // can never remember } - else if (MathHelper.equal(pos[0].z(), 1) && // vertex.position.z - MathHelper.equal(pos[1].z(), 1) && - MathHelper.equal(pos[2].z(), 1) && - MathHelper.equal(pos[3].z(), 1) && + else if (Mth.equal(pos[0].z(), 1) && // vertex.position.z + Mth.equal(pos[1].z(), 1) && + Mth.equal(pos[2].z(), 1) && + Mth.equal(pos[3].z(), 1) && norm[0].z() > 0) // vertex.normal.z { cull = Direction.SOUTH; } - else if (MathHelper.equal(pos[0].y(), 0) && // vertex.position.y - MathHelper.equal(pos[1].y(), 0) && - MathHelper.equal(pos[2].y(), 0) && - MathHelper.equal(pos[3].y(), 0) && + else if (Mth.equal(pos[0].y(), 0) && // vertex.position.y + Mth.equal(pos[1].y(), 0) && + Mth.equal(pos[2].y(), 0) && + Mth.equal(pos[3].y(), 0) && norm[0].y() < 0) // vertex.normal.z { cull = Direction.DOWN; // can never remember } - else if (MathHelper.equal(pos[0].y(), 1) && // vertex.position.y - MathHelper.equal(pos[1].y(), 1) && - MathHelper.equal(pos[2].y(), 1) && - MathHelper.equal(pos[3].y(), 1) && + else if (Mth.equal(pos[0].y(), 1) && // vertex.position.y + Mth.equal(pos[1].y(), 1) && + Mth.equal(pos[2].y(), 1) && + Mth.equal(pos[3].y(), 1) && norm[0].y() > 0) // vertex.normal.y { cull = Direction.UP; @@ -464,7 +469,7 @@ public class OBJModel implements IMultipartModelGeometry return Pair.of(builder.build(), cull); } - private void putVertexData(IVertexConsumer consumer, Vector4f position0, Vector2f texCoord0, Vector3f normal0, Vector4f color0, Vector2f uv2, TextureAtlasSprite texture) + private void putVertexData(IVertexConsumer consumer, Vector4f position0, Vec2 texCoord0, Vector3f normal0, Vector4f color0, Vec2 uv2, TextureAtlasSprite texture) { ImmutableList elements = consumer.getVertexFormat().getElements(); for(int j=0;j } @Override - public void addQuads(IModelConfiguration owner, IModelBuilder modelBuilder, ModelBakery bakery, Function spriteGetter, IModelTransform modelTransform, ResourceLocation modelLocation) + public void addQuads(IModelConfiguration owner, IModelBuilder modelBuilder, ModelBakery bakery, Function spriteGetter, ModelState modelTransform, ResourceLocation modelLocation) { for(ModelMesh mesh : meshes) { @@ -546,7 +551,7 @@ public class OBJModel implements IMultipartModelGeometry } @Override - public Collection getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors) + public Collection getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors) { return meshes.stream().map(mesh -> ModelLoaderRegistry.resolveTexture(mesh.mat.diffuseColorMap, owner)).collect(Collectors.toSet()); } @@ -567,7 +572,7 @@ public class OBJModel implements IMultipartModelGeometry } @Override - public void addQuads(IModelConfiguration owner, IModelBuilder modelBuilder, ModelBakery bakery, Function spriteGetter, IModelTransform modelTransform, ResourceLocation modelLocation) + public void addQuads(IModelConfiguration owner, IModelBuilder modelBuilder, ModelBakery bakery, Function spriteGetter, ModelState modelTransform, ResourceLocation modelLocation) { super.addQuads(owner, modelBuilder, bakery, spriteGetter, modelTransform, modelLocation); @@ -576,9 +581,9 @@ public class OBJModel implements IMultipartModelGeometry } @Override - public Collection getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors) + public Collection getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors) { - Set combined = Sets.newHashSet(); + Set combined = Sets.newHashSet(); combined.addAll(super.getTextures(owner, modelGetter, missingTextureErrors)); for (IModelGeometryPart part : getParts()) combined.addAll(part.getTextures(owner, modelGetter, missingTextureErrors)); diff --git a/src/main/java/net/minecraftforge/client/model/obj/package-info.java b/src/main/java/net/minecraftforge/client/model/obj/package-info.java index 5b7343e421..cacdb966a8 100644 --- a/src/main/java/net/minecraftforge/client/model/obj/package-info.java +++ b/src/main/java/net/minecraftforge/client/model/obj/package-info.java @@ -21,5 +21,6 @@ @MethodsReturnNonnullByDefault package net.minecraftforge.client.model.obj; -import mcp.MethodsReturnNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; + import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/java/net/minecraftforge/client/model/package-info.java b/src/main/java/net/minecraftforge/client/model/package-info.java index a0afcad0bc..a7ef5365aa 100644 --- a/src/main/java/net/minecraftforge/client/model/package-info.java +++ b/src/main/java/net/minecraftforge/client/model/package-info.java @@ -21,5 +21,6 @@ @MethodsReturnNonnullByDefault package net.minecraftforge.client.model; -import mcp.MethodsReturnNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; + import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/java/net/minecraftforge/client/model/pipeline/BakedQuadBuilder.java b/src/main/java/net/minecraftforge/client/model/pipeline/BakedQuadBuilder.java index 7c0fd8d96e..7d877205d7 100644 --- a/src/main/java/net/minecraftforge/client/model/pipeline/BakedQuadBuilder.java +++ b/src/main/java/net/minecraftforge/client/model/pipeline/BakedQuadBuilder.java @@ -21,12 +21,12 @@ package net.minecraftforge.client.model.pipeline; import com.google.common.collect.ImmutableList; -import net.minecraft.client.renderer.model.BakedQuad; +import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.client.renderer.vertex.VertexFormat; -import net.minecraft.client.renderer.vertex.VertexFormatElement; -import net.minecraft.util.Direction; +import com.mojang.blaze3d.vertex.DefaultVertexFormat; +import com.mojang.blaze3d.vertex.VertexFormat; +import com.mojang.blaze3d.vertex.VertexFormatElement; +import net.minecraft.core.Direction; /** * Allows easier building of BakedQuad objects. During building, data is stored @@ -34,7 +34,7 @@ import net.minecraft.util.Direction; */ public class BakedQuadBuilder implements IVertexConsumer { - private static final int SIZE = DefaultVertexFormats.BLOCK.getElements().size(); + private static final int SIZE = DefaultVertexFormat.BLOCK.getElements().size(); private final float[][][] unpackedData = new float[4][SIZE][4]; private int tint = -1; @@ -62,7 +62,7 @@ public class BakedQuadBuilder implements IVertexConsumer @Override public VertexFormat getVertexFormat() { - return DefaultVertexFormats.BLOCK; + return DefaultVertexFormat.BLOCK; } @Override @@ -134,7 +134,7 @@ public class BakedQuadBuilder implements IVertexConsumer float tS = tX > tY ? tX : tY; float ep = 1f / (tS * 0x100); int uve = 0; - ImmutableList elements = DefaultVertexFormats.BLOCK.getElements(); + ImmutableList elements = DefaultVertexFormat.BLOCK.getElements(); while(uve < elements.size()) { VertexFormatElement e = elements.get(uve); @@ -182,12 +182,12 @@ public class BakedQuadBuilder implements IVertexConsumer } } } - int[] packed = new int[DefaultVertexFormats.BLOCK.getIntegerSize() * 4]; + int[] packed = new int[DefaultVertexFormat.BLOCK.getIntegerSize() * 4]; for (int v = 0; v < 4; v++) { for (int e = 0; e < SIZE; e++) { - LightUtil.pack(unpackedData[v][e], packed, DefaultVertexFormats.BLOCK, v, e); + LightUtil.pack(unpackedData[v][e], packed, DefaultVertexFormat.BLOCK, v, e); } } return new BakedQuad(packed, tint, orientation, texture, applyDiffuseLighting); diff --git a/src/main/java/net/minecraftforge/client/model/pipeline/BlockInfo.java b/src/main/java/net/minecraftforge/client/model/pipeline/BlockInfo.java index d595e41098..6baab67489 100644 --- a/src/main/java/net/minecraftforge/client/model/pipeline/BlockInfo.java +++ b/src/main/java/net/minecraftforge/client/model/pipeline/BlockInfo.java @@ -19,24 +19,23 @@ package net.minecraftforge.client.model.pipeline; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; import net.minecraft.client.renderer.LightTexture; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.client.renderer.color.BlockColors; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.VoxelShapes; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.IBlockDisplayReader; +import net.minecraft.client.renderer.LevelRenderer; +import net.minecraft.client.color.block.BlockColors; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.shapes.Shapes; +import net.minecraft.world.level.BlockAndTintGetter; public class BlockInfo { private static final Direction[] SIDES = Direction.values(); private final BlockColors colors; - private IBlockDisplayReader world; + private BlockAndTintGetter world; private BlockState state; private BlockPos blockPos; @@ -72,7 +71,7 @@ public class BlockInfo { } - public void setWorld(IBlockDisplayReader world) + public void setWorld(BlockAndTintGetter world) { this.world = world; cachedTint = -1; @@ -122,7 +121,7 @@ public class BlockInfo BlockPos pos = blockPos.offset(x - 1, y - 1, z - 1); BlockState state = world.getBlockState(pos); t[x][y][z] = state.getLightBlock(world, pos) < 15; - int brightness = WorldRenderer.getLightColor(world, pos); + int brightness = LevelRenderer.getLightColor(world, pos); s[x][y][z] = LightTexture.sky(brightness); b[x][y][z] = LightTexture.block(brightness); ao[x][y][z] = state.getShadeBrightness(world, pos); @@ -137,7 +136,7 @@ public class BlockInfo BlockState thisStateShape = this.state.canOcclude() && this.state.useShapeForLightOcclusion() ? this.state : Blocks.AIR.defaultBlockState(); BlockState otherStateShape = state.canOcclude() && state.useShapeForLightOcclusion() ? state : Blocks.AIR.defaultBlockState(); - if(state.getLightBlock(world, pos) == 15 || VoxelShapes.faceShapeOccludes(thisStateShape.getFaceOcclusionShape(world, blockPos, side), otherStateShape.getFaceOcclusionShape(world, pos, side.getOpposite()))) + if(state.getLightBlock(world, pos) == 15 || Shapes.faceShapeOccludes(thisStateShape.getFaceOcclusionShape(world, blockPos, side), otherStateShape.getFaceOcclusionShape(world, pos, side.getOpposite()))) { int x = side.getStepX() + 1; int y = side.getStepY() + 1; @@ -190,16 +189,16 @@ public class BlockInfo public void updateFlatLighting() { full = Block.isShapeFullBlock(state.getCollisionShape(world, blockPos)); - packed[0] = WorldRenderer.getLightColor(world, blockPos); + packed[0] = LevelRenderer.getLightColor(world, blockPos); for (Direction side : SIDES) { int i = side.ordinal() + 1; - packed[i] = WorldRenderer.getLightColor(world, blockPos.relative(side)); + packed[i] = LevelRenderer.getLightColor(world, blockPos.relative(side)); } } - public IBlockDisplayReader getWorld() + public BlockAndTintGetter getWorld() { return world; } diff --git a/src/main/java/net/minecraftforge/client/model/pipeline/ForgeBlockModelRenderer.java b/src/main/java/net/minecraftforge/client/model/pipeline/ForgeBlockModelRenderer.java index 4db5339a94..2753af7da1 100644 --- a/src/main/java/net/minecraftforge/client/model/pipeline/ForgeBlockModelRenderer.java +++ b/src/main/java/net/minecraftforge/client/model/pipeline/ForgeBlockModelRenderer.java @@ -22,21 +22,21 @@ package net.minecraftforge.client.model.pipeline; import java.util.List; import java.util.Random; -import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.vertex.IVertexBuilder; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.BlockModelRenderer; -import net.minecraft.client.renderer.model.BakedQuad; -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.color.BlockColors; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockDisplayReader; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.client.renderer.block.ModelBlockRenderer; +import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.color.block.BlockColors; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockAndTintGetter; import net.minecraftforge.client.model.data.IModelData; import net.minecraftforge.common.ForgeConfig; -public class ForgeBlockModelRenderer extends BlockModelRenderer +public class ForgeBlockModelRenderer extends ModelBlockRenderer { private final ThreadLocal lighterFlat; private final ThreadLocal lighterSmooth; @@ -51,7 +51,7 @@ public class ForgeBlockModelRenderer extends BlockModelRenderer } @Override - public boolean renderModelFlat(IBlockDisplayReader world, IBakedModel model, BlockState state, BlockPos pos, MatrixStack matrixStack, IVertexBuilder buffer, boolean checkSides, Random rand, long seed, int combinedOverlayIn, IModelData modelData) + public boolean tesselateWithoutAO(BlockAndTintGetter world, BakedModel model, BlockState state, BlockPos pos, PoseStack matrixStack, VertexConsumer buffer, boolean checkSides, Random rand, long seed, int combinedOverlayIn, IModelData modelData) { if(ForgeConfig.CLIENT.experimentalForgeLightPipelineEnabled.get()) { @@ -66,12 +66,12 @@ public class ForgeBlockModelRenderer extends BlockModelRenderer } else { - return super.renderModelFlat(world, model, state, pos, matrixStack, buffer, checkSides, rand, seed, combinedOverlayIn, modelData); + return super.tesselateWithoutAO(world, model, state, pos, matrixStack, buffer, checkSides, rand, seed, combinedOverlayIn, modelData); } } @Override - public boolean renderModelSmooth(IBlockDisplayReader world, IBakedModel model, BlockState state, BlockPos pos, MatrixStack matrixStack, IVertexBuilder buffer, boolean checkSides, Random rand, long seed, int combinedOverlayIn, IModelData modelData) + public boolean tesselateWithAO(BlockAndTintGetter world, BakedModel model, BlockState state, BlockPos pos, PoseStack matrixStack, VertexConsumer buffer, boolean checkSides, Random rand, long seed, int combinedOverlayIn, IModelData modelData) { if(ForgeConfig.CLIENT.experimentalForgeLightPipelineEnabled.get()) { @@ -86,11 +86,11 @@ public class ForgeBlockModelRenderer extends BlockModelRenderer } else { - return super.renderModelSmooth(world, model, state, pos, matrixStack, buffer, checkSides, rand, seed, combinedOverlayIn, modelData); + return super.tesselateWithAO(world, model, state, pos, matrixStack, buffer, checkSides, rand, seed, combinedOverlayIn, modelData); } } - public static boolean render(VertexLighterFlat lighter, IBlockDisplayReader world, IBakedModel model, BlockState state, BlockPos pos, MatrixStack matrixStack, boolean checkSides, Random rand, long seed, IModelData modelData) + public static boolean render(VertexLighterFlat lighter, BlockAndTintGetter world, BakedModel model, BlockState state, BlockPos pos, PoseStack matrixStack, boolean checkSides, Random rand, long seed, IModelData modelData) { lighter.setWorld(world); lighter.setState(state); @@ -113,7 +113,7 @@ public class ForgeBlockModelRenderer extends BlockModelRenderer quads = model.getQuads(state, side, rand, modelData); if(!quads.isEmpty()) { - if(!checkSides || Block.shouldRenderFace(state, world, pos, side)) + if(!checkSides || Block.shouldRenderFace(state, world, pos, side, pos.relative(side))) { if(empty) lighter.updateBlockInfo(); empty = false; diff --git a/src/main/java/net/minecraftforge/client/model/pipeline/IVertexConsumer.java b/src/main/java/net/minecraftforge/client/model/pipeline/IVertexConsumer.java index 902d98162d..aac8426b85 100644 --- a/src/main/java/net/minecraftforge/client/model/pipeline/IVertexConsumer.java +++ b/src/main/java/net/minecraftforge/client/model/pipeline/IVertexConsumer.java @@ -20,8 +20,8 @@ package net.minecraftforge.client.model.pipeline; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.renderer.vertex.VertexFormat; -import net.minecraft.util.Direction; +import com.mojang.blaze3d.vertex.VertexFormat; +import net.minecraft.core.Direction; /** * Assumes that the data length is not less than e.getElements().size(). diff --git a/src/main/java/net/minecraftforge/client/model/pipeline/LightUtil.java b/src/main/java/net/minecraftforge/client/model/pipeline/LightUtil.java index 847290cb51..53c77847d0 100644 --- a/src/main/java/net/minecraftforge/client/model/pipeline/LightUtil.java +++ b/src/main/java/net/minecraftforge/client/model/pipeline/LightUtil.java @@ -24,11 +24,11 @@ import java.util.concurrent.ConcurrentMap; import org.apache.commons.lang3.tuple.Pair; -import net.minecraft.client.renderer.model.BakedQuad; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.client.renderer.vertex.VertexFormat; -import net.minecraft.client.renderer.vertex.VertexFormatElement; -import net.minecraft.util.Direction; +import net.minecraft.client.renderer.block.model.BakedQuad; +import com.mojang.blaze3d.vertex.DefaultVertexFormat; +import com.mojang.blaze3d.vertex.VertexFormat; +import com.mojang.blaze3d.vertex.VertexFormatElement; +import net.minecraft.core.Direction; public class LightUtil { @@ -96,7 +96,7 @@ public class LightUtil consumer.setApplyDiffuseLighting(quad.isShade()); float[] data = new float[4]; VertexFormat formatFrom = consumer.getVertexFormat(); - VertexFormat formatTo = DefaultVertexFormats.BLOCK; + VertexFormat formatTo = DefaultVertexFormat.BLOCK; int countFrom = formatFrom.getElements().size(); int countTo = formatTo.getElements().size(); int[] eMap = mapFormats(formatFrom, formatTo); @@ -118,8 +118,8 @@ public class LightUtil } // TODO: probably useless now, remove? - private static final VertexFormat DEFAULT_FROM = VertexLighterFlat.withNormal(DefaultVertexFormats.BLOCK); - private static final VertexFormat DEFAULT_TO = DefaultVertexFormats.BLOCK; + private static final VertexFormat DEFAULT_FROM = VertexLighterFlat.withNormal(DefaultVertexFormat.BLOCK); + private static final VertexFormat DEFAULT_TO = DefaultVertexFormat.BLOCK; private static final int[] DEFAULT_MAPPING = generateMapping(DEFAULT_FROM, DEFAULT_TO); public static int[] mapFormats(VertexFormat from, VertexFormat to) { diff --git a/src/main/java/net/minecraftforge/client/model/pipeline/QuadGatheringTransformer.java b/src/main/java/net/minecraftforge/client/model/pipeline/QuadGatheringTransformer.java index 0c1cf61586..18bcd09cf8 100644 --- a/src/main/java/net/minecraftforge/client/model/pipeline/QuadGatheringTransformer.java +++ b/src/main/java/net/minecraftforge/client/model/pipeline/QuadGatheringTransformer.java @@ -19,7 +19,7 @@ package net.minecraftforge.client.model.pipeline; -import net.minecraft.client.renderer.vertex.VertexFormat; +import com.mojang.blaze3d.vertex.VertexFormat; public abstract class QuadGatheringTransformer implements IVertexConsumer { diff --git a/src/main/java/net/minecraftforge/client/model/pipeline/TRSRTransformer.java b/src/main/java/net/minecraftforge/client/model/pipeline/TRSRTransformer.java index e9e9ba79db..8f0834bbe4 100644 --- a/src/main/java/net/minecraftforge/client/model/pipeline/TRSRTransformer.java +++ b/src/main/java/net/minecraftforge/client/model/pipeline/TRSRTransformer.java @@ -19,15 +19,15 @@ package net.minecraftforge.client.model.pipeline; -import net.minecraft.util.math.vector.TransformationMatrix; -import net.minecraft.util.math.vector.Vector3f; -import net.minecraft.util.math.vector.Vector4f; +import com.mojang.math.Transformation; +import com.mojang.math.Vector3f; +import com.mojang.math.Vector4f; public class TRSRTransformer extends VertexTransformer { - private final TransformationMatrix transform; + private final Transformation transform; - public TRSRTransformer(IVertexConsumer parent, TransformationMatrix transform) + public TRSRTransformer(IVertexConsumer parent, Transformation transform) { super(parent); this.transform = transform; diff --git a/src/main/java/net/minecraftforge/client/model/pipeline/TransformerConsumer.java b/src/main/java/net/minecraftforge/client/model/pipeline/TransformerConsumer.java index 0f13b9803e..fbd78d2b8a 100644 --- a/src/main/java/net/minecraftforge/client/model/pipeline/TransformerConsumer.java +++ b/src/main/java/net/minecraftforge/client/model/pipeline/TransformerConsumer.java @@ -19,7 +19,7 @@ package net.minecraftforge.client.model.pipeline; -import net.minecraft.client.renderer.vertex.VertexFormat; +import com.mojang.blaze3d.vertex.VertexFormat; public abstract class TransformerConsumer implements IVertexConsumer { private IVertexConsumer parent; diff --git a/src/main/java/net/minecraftforge/client/model/pipeline/VertexBufferConsumer.java b/src/main/java/net/minecraftforge/client/model/pipeline/VertexBufferConsumer.java index 10029e52d1..5f794eca36 100644 --- a/src/main/java/net/minecraftforge/client/model/pipeline/VertexBufferConsumer.java +++ b/src/main/java/net/minecraftforge/client/model/pipeline/VertexBufferConsumer.java @@ -19,23 +19,23 @@ package net.minecraftforge.client.model.pipeline; -import com.mojang.blaze3d.vertex.IVertexBuilder; +import com.mojang.blaze3d.vertex.VertexConsumer; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.client.renderer.vertex.VertexFormat; -import net.minecraft.util.Direction; +import com.mojang.blaze3d.vertex.DefaultVertexFormat; +import com.mojang.blaze3d.vertex.VertexFormat; +import net.minecraft.core.Direction; /** * Assumes VertexFormatElement is present in the BufferBuilder's vertex format. */ public class VertexBufferConsumer implements IVertexConsumer { - private IVertexBuilder renderer; + private VertexConsumer renderer; public VertexBufferConsumer() {} - public VertexBufferConsumer(IVertexBuilder buffer) + public VertexBufferConsumer(VertexConsumer buffer) { setBuffer(buffer); } @@ -43,7 +43,7 @@ public class VertexBufferConsumer implements IVertexConsumer @Override public final VertexFormat getVertexFormat() { - return DefaultVertexFormats.BLOCK; + return DefaultVertexFormat.BLOCK; } @Override @@ -82,7 +82,7 @@ public class VertexBufferConsumer implements IVertexConsumer } } - public void setBuffer(IVertexBuilder buffer) + public void setBuffer(VertexConsumer buffer) { this.renderer = buffer; } diff --git a/src/main/java/net/minecraftforge/client/model/pipeline/VertexLighterFlat.java b/src/main/java/net/minecraftforge/client/model/pipeline/VertexLighterFlat.java index 9d23fe6254..62bec781b9 100644 --- a/src/main/java/net/minecraftforge/client/model/pipeline/VertexLighterFlat.java +++ b/src/main/java/net/minecraftforge/client/model/pipeline/VertexLighterFlat.java @@ -20,24 +20,27 @@ package net.minecraftforge.client.model.pipeline; import java.util.List; +import java.util.Map; import java.util.Objects; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.google.common.collect.Maps; +import com.mojang.blaze3d.vertex.PoseStack; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.renderer.LightTexture; -import net.minecraft.client.renderer.color.BlockColors; +import net.minecraft.client.color.block.BlockColors; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.client.renderer.vertex.VertexFormat; -import net.minecraft.client.renderer.vertex.VertexFormatElement; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3f; -import net.minecraft.util.math.vector.Vector4f; -import net.minecraft.world.IBlockDisplayReader; +import com.mojang.blaze3d.vertex.DefaultVertexFormat; +import com.mojang.blaze3d.vertex.VertexFormat; +import com.mojang.blaze3d.vertex.VertexFormatElement; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import com.mojang.math.Vector3f; +import com.mojang.math.Vector4f; +import net.minecraft.world.level.BlockAndTintGetter; public class VertexLighterFlat extends QuadGatheringTransformer { @@ -45,7 +48,7 @@ public class VertexLighterFlat extends QuadGatheringTransformer // TODO 1.16/1.17 possibly refactor out the need for the "unpacked" format entirely. It's creating more headaches than solutions. // This mess reverses the conversion to float bits done in LightUtil.unpack - private static final int LIGHTMAP_PACKING_FACTOR = ((256 << (8 * (DefaultVertexFormats.ELEMENT_UV2.getType().getSize() - 1))) - 1) >>> 1; + private static final int LIGHTMAP_PACKING_FACTOR = ((256 << (8 * (DefaultVertexFormat.ELEMENT_UV2.getType().getSize() - 1))) - 1) >>> 1; // Max lightmap value, for rescaling private static final int LIGHTMAP_MAX = 0xF0; // Inlined factor for rescaling input lightmap values, "rounded" up to the next float value to avoid precision loss when result is truncated to int @@ -61,7 +64,7 @@ public class VertexLighterFlat extends QuadGatheringTransformer protected int lightmapIndex = -1; protected VertexFormat baseFormat; - protected MatrixStack.Entry pose; + protected PoseStack.Pose pose; public VertexLighterFlat(BlockColors colors) { @@ -75,7 +78,7 @@ public class VertexLighterFlat extends QuadGatheringTransformer setVertexFormat(parent.getVertexFormat()); } - public void setTransform(final MatrixStack.Entry pose) + public void setTransform(final PoseStack.Pose pose) { this.pose = pose; } @@ -130,8 +133,8 @@ public class VertexLighterFlat extends QuadGatheringTransformer static VertexFormat withNormal(VertexFormat format) { //This is the case in 99.99%. Cache the value, so we don't have to redo it every time, and the speed up the equals check in LightUtil - if (format == DefaultVertexFormats.BLOCK) - return DefaultVertexFormats.BLOCK; + if (format == DefaultVertexFormat.BLOCK) + return DefaultVertexFormat.BLOCK; return withNormalUncached(format); } @@ -139,9 +142,9 @@ public class VertexLighterFlat extends QuadGatheringTransformer { if (format == null || format.hasNormal()) return format; - List l = Lists.newArrayList(format.getElements()); - l.add(NORMAL_4F); - return new VertexFormat(ImmutableList.copyOf(l)); + Map m = Maps.newHashMap(format.getElementMapping()); + m.put("Normal", NORMAL_4F); + return new VertexFormat(ImmutableMap.copyOf(m)); } @Override @@ -309,7 +312,7 @@ public class VertexLighterFlat extends QuadGatheringTransformer this.diffuse = diffuse; } - public void setWorld(IBlockDisplayReader world) + public void setWorld(BlockAndTintGetter world) { blockInfo.setWorld(world); } diff --git a/src/main/java/net/minecraftforge/client/model/pipeline/VertexLighterSmoothAo.java b/src/main/java/net/minecraftforge/client/model/pipeline/VertexLighterSmoothAo.java index 97701fa10d..df06477701 100644 --- a/src/main/java/net/minecraftforge/client/model/pipeline/VertexLighterSmoothAo.java +++ b/src/main/java/net/minecraftforge/client/model/pipeline/VertexLighterSmoothAo.java @@ -19,8 +19,8 @@ package net.minecraftforge.client.model.pipeline; -import net.minecraft.client.renderer.color.BlockColors; -import net.minecraft.util.math.MathHelper; +import net.minecraft.client.color.block.BlockColors; +import net.minecraft.util.Mth; public class VertexLighterSmoothAo extends VertexLighterFlat @@ -139,7 +139,7 @@ public class VertexLighterSmoothAo extends VertexLighterFlat } l /= s; - l = MathHelper.clamp(l, 0, 1); + l = Mth.clamp(l, 0, 1); return l; } @@ -164,7 +164,7 @@ public class VertexLighterSmoothAo extends VertexLighterFlat a += ao[sx - 0][sy - 0][sz - 1] * (0 + x) * (0 + y) * (1 - z); a += ao[sx - 0][sy - 0][sz - 0] * (0 + x) * (0 + y) * (0 + z); - a = MathHelper.clamp(a, 0, 1); + a = Mth.clamp(a, 0, 1); return a; } diff --git a/src/main/java/net/minecraftforge/client/model/pipeline/VertexTransformer.java b/src/main/java/net/minecraftforge/client/model/pipeline/VertexTransformer.java index 4d24a2eb35..5305483aaa 100644 --- a/src/main/java/net/minecraftforge/client/model/pipeline/VertexTransformer.java +++ b/src/main/java/net/minecraftforge/client/model/pipeline/VertexTransformer.java @@ -20,8 +20,8 @@ package net.minecraftforge.client.model.pipeline; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.renderer.vertex.VertexFormat; -import net.minecraft.util.Direction; +import com.mojang.blaze3d.vertex.VertexFormat; +import net.minecraft.core.Direction; public class VertexTransformer implements IVertexConsumer { diff --git a/src/main/java/net/minecraftforge/client/model/pipeline/package-info.java b/src/main/java/net/minecraftforge/client/model/pipeline/package-info.java index dc9a769f68..c1978a0d94 100644 --- a/src/main/java/net/minecraftforge/client/model/pipeline/package-info.java +++ b/src/main/java/net/minecraftforge/client/model/pipeline/package-info.java @@ -21,5 +21,6 @@ @MethodsReturnNonnullByDefault package net.minecraftforge.client.model.pipeline; -import mcp.MethodsReturnNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; + import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/java/net/minecraftforge/client/settings/IKeyConflictContext.java b/src/main/java/net/minecraftforge/client/settings/IKeyConflictContext.java index 42d5ba5a8b..0984c2dfae 100644 --- a/src/main/java/net/minecraftforge/client/settings/IKeyConflictContext.java +++ b/src/main/java/net/minecraftforge/client/settings/IKeyConflictContext.java @@ -19,8 +19,6 @@ package net.minecraftforge.client.settings; -import net.minecraft.client.settings.KeyBinding; - /** * Defines the context that a {@link KeyBinding} is used. * Key conflicts occur when a {@link KeyBinding} has the same {@link IKeyConflictContext} and has conflicting modifiers and keyCodes. diff --git a/src/main/java/net/minecraftforge/client/settings/KeyBindingMap.java b/src/main/java/net/minecraftforge/client/settings/KeyBindingMap.java index 59935c908b..0c679b0c59 100644 --- a/src/main/java/net/minecraftforge/client/settings/KeyBindingMap.java +++ b/src/main/java/net/minecraftforge/client/settings/KeyBindingMap.java @@ -19,8 +19,8 @@ package net.minecraftforge.client.settings; -import net.minecraft.client.settings.KeyBinding; -import net.minecraft.client.util.InputMappings; +import net.minecraft.client.KeyMapping; +import com.mojang.blaze3d.platform.InputConstants; import javax.annotation.Nullable; import java.util.ArrayList; @@ -32,7 +32,7 @@ import java.util.Map; public class KeyBindingMap { - private static final EnumMap>> map = new EnumMap<>(KeyModifier.class); + private static final EnumMap>> map = new EnumMap<>(KeyModifier.class); static { for (KeyModifier modifier : KeyModifier.values()) @@ -42,12 +42,12 @@ public class KeyBindingMap } @Nullable - public KeyBinding lookupActive(InputMappings.Input keyCode) + public KeyMapping lookupActive(InputConstants.Key keyCode) { KeyModifier activeModifier = KeyModifier.getActiveModifier(); if (!activeModifier.matches(keyCode)) { - KeyBinding binding = getBinding(keyCode, activeModifier); + KeyMapping binding = getBinding(keyCode, activeModifier); if (binding != null) { return binding; @@ -57,12 +57,12 @@ public class KeyBindingMap } @Nullable - private KeyBinding getBinding(InputMappings.Input keyCode, KeyModifier keyModifier) + private KeyMapping getBinding(InputConstants.Key keyCode, KeyModifier keyModifier) { - Collection bindings = map.get(keyModifier).get(keyCode); + Collection bindings = map.get(keyModifier).get(keyCode); if (bindings != null) { - for (KeyBinding binding : bindings) + for (KeyMapping binding : bindings) { if (binding.isActiveAndMatches(keyCode)) { @@ -73,12 +73,12 @@ public class KeyBindingMap return null; } - public List lookupAll(InputMappings.Input keyCode) + public List lookupAll(InputConstants.Key keyCode) { - List matchingBindings = new ArrayList(); - for (Map> bindingsMap : map.values()) + List matchingBindings = new ArrayList(); + for (Map> bindingsMap : map.values()) { - Collection bindings = bindingsMap.get(keyCode); + Collection bindings = bindingsMap.get(keyCode); if (bindings != null) { matchingBindings.addAll(bindings); @@ -87,25 +87,25 @@ public class KeyBindingMap return matchingBindings; } - public void addKey(InputMappings.Input keyCode, KeyBinding keyBinding) + public void addKey(InputConstants.Key keyCode, KeyMapping keyBinding) { KeyModifier keyModifier = keyBinding.getKeyModifier(); - Map> bindingsMap = map.get(keyModifier); - Collection bindingsForKey = bindingsMap.get(keyCode); + Map> bindingsMap = map.get(keyModifier); + Collection bindingsForKey = bindingsMap.get(keyCode); if (bindingsForKey == null) { - bindingsForKey = new ArrayList(); + bindingsForKey = new ArrayList(); bindingsMap.put(keyCode, bindingsForKey); } bindingsForKey.add(keyBinding); } - public void removeKey(KeyBinding keyBinding) + public void removeKey(KeyMapping keyBinding) { KeyModifier keyModifier = keyBinding.getKeyModifier(); - InputMappings.Input keyCode = keyBinding.getKey(); - Map> bindingsMap = map.get(keyModifier); - Collection bindingsForKey = bindingsMap.get(keyCode); + InputConstants.Key keyCode = keyBinding.getKey(); + Map> bindingsMap = map.get(keyModifier); + Collection bindingsForKey = bindingsMap.get(keyCode); if (bindingsForKey != null) { bindingsForKey.remove(keyBinding); @@ -118,7 +118,7 @@ public class KeyBindingMap public void clearMap() { - for (Map> bindings : map.values()) + for (Map> bindings : map.values()) { bindings.clear(); } diff --git a/src/main/java/net/minecraftforge/client/settings/KeyModifier.java b/src/main/java/net/minecraftforge/client/settings/KeyModifier.java index 8517cb3fb8..090d45ed9b 100644 --- a/src/main/java/net/minecraftforge/client/settings/KeyModifier.java +++ b/src/main/java/net/minecraftforge/client/settings/KeyModifier.java @@ -24,18 +24,17 @@ import java.util.function.Supplier; import javax.annotation.Nullable; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.resources.I18n; -import net.minecraft.client.util.InputMappings; +import net.minecraft.client.gui.screens.Screen; +import com.mojang.blaze3d.platform.InputConstants; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TranslatableComponent; import org.lwjgl.glfw.GLFW; public enum KeyModifier { CONTROL { @Override - public boolean matches(InputMappings.Input key) + public boolean matches(InputConstants.Key key) { int keyCode = key.getValue(); if (Minecraft.ON_OSX) @@ -55,15 +54,15 @@ public enum KeyModifier { } @Override - public ITextComponent getCombinedName(InputMappings.Input key, Supplier defaultLogic) + public Component getCombinedName(InputConstants.Key key, Supplier defaultLogic) { String localizationFormatKey = Minecraft.ON_OSX ? "forge.controlsgui.control.mac" : "forge.controlsgui.control"; - return new TranslationTextComponent(localizationFormatKey, defaultLogic.get()); + return new TranslatableComponent(localizationFormatKey, defaultLogic.get()); } }, SHIFT { @Override - public boolean matches(InputMappings.Input key) + public boolean matches(InputConstants.Key key) { return key.getValue() == GLFW.GLFW_KEY_LEFT_SHIFT || key.getValue() == GLFW.GLFW_KEY_RIGHT_SHIFT; } @@ -75,14 +74,14 @@ public enum KeyModifier { } @Override - public ITextComponent getCombinedName(InputMappings.Input key, Supplier defaultLogic) + public Component getCombinedName(InputConstants.Key key, Supplier defaultLogic) { - return new TranslationTextComponent("forge.controlsgui.shift", defaultLogic.get()); + return new TranslatableComponent("forge.controlsgui.shift", defaultLogic.get()); } }, ALT { @Override - public boolean matches(InputMappings.Input key) + public boolean matches(InputConstants.Key key) { return key.getValue() == GLFW.GLFW_KEY_LEFT_ALT || key.getValue() == GLFW.GLFW_KEY_RIGHT_ALT; } @@ -94,14 +93,14 @@ public enum KeyModifier { } @Override - public ITextComponent getCombinedName(InputMappings.Input keyCode, Supplier defaultLogic) + public Component getCombinedName(InputConstants.Key keyCode, Supplier defaultLogic) { - return new TranslationTextComponent("forge.controlsgui.alt", defaultLogic.get()); + return new TranslatableComponent("forge.controlsgui.alt", defaultLogic.get()); } }, NONE { @Override - public boolean matches(InputMappings.Input key) + public boolean matches(InputConstants.Key key) { return false; } @@ -123,7 +122,7 @@ public enum KeyModifier { } @Override - public ITextComponent getCombinedName(InputMappings.Input key, Supplier defaultLogic) + public Component getCombinedName(InputConstants.Key key, Supplier defaultLogic) { return defaultLogic.get(); } @@ -143,7 +142,7 @@ public enum KeyModifier { return NONE; } - public static boolean isKeyCodeModifier(InputMappings.Input key) + public static boolean isKeyCodeModifier(InputConstants.Key key) { for (KeyModifier keyModifier : MODIFIER_VALUES) { @@ -167,9 +166,9 @@ public enum KeyModifier { } } - public abstract boolean matches(InputMappings.Input key); + public abstract boolean matches(InputConstants.Key key); public abstract boolean isActive(@Nullable IKeyConflictContext conflictContext); - public abstract ITextComponent getCombinedName(InputMappings.Input key, Supplier defaultLogic); + public abstract Component getCombinedName(InputConstants.Key key, Supplier defaultLogic); } diff --git a/src/main/java/net/minecraftforge/client/textures/ForgeTextureMetadata.java b/src/main/java/net/minecraftforge/client/textures/ForgeTextureMetadata.java index 976ac1dae4..62c3e28c0e 100644 --- a/src/main/java/net/minecraftforge/client/textures/ForgeTextureMetadata.java +++ b/src/main/java/net/minecraftforge/client/textures/ForgeTextureMetadata.java @@ -22,10 +22,10 @@ package net.minecraftforge.client.textures; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import net.minecraft.resources.IResource; -import net.minecraft.resources.data.IMetadataSectionSerializer; -import net.minecraft.util.JSONUtils; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.packs.metadata.MetadataSectionSerializer; +import net.minecraft.server.packs.resources.Resource; +import net.minecraft.util.GsonHelper; import net.minecraftforge.client.MinecraftForgeClient; import com.google.gson.JsonObject; @@ -40,9 +40,9 @@ public final class ForgeTextureMetadata { public static final ForgeTextureMetadata EMPTY = new ForgeTextureMetadata(null); - public static final IMetadataSectionSerializer SERIALIZER = new Serializer(); + public static final MetadataSectionSerializer SERIALIZER = new Serializer(); - public static ForgeTextureMetadata forResource(IResource resource) + public static ForgeTextureMetadata forResource(Resource resource) { ForgeTextureMetadata metadata = resource.getMetadata(SERIALIZER); return metadata == null ? EMPTY : metadata; @@ -62,7 +62,7 @@ public final class ForgeTextureMetadata return loader; } - private static final class Serializer implements IMetadataSectionSerializer + private static final class Serializer implements MetadataSectionSerializer { @Override @@ -80,7 +80,7 @@ public final class ForgeTextureMetadata ITextureAtlasSpriteLoader loader; if (json.has("loader")) { - ResourceLocation loaderName = new ResourceLocation(JSONUtils.getAsString(json, "loader")); + ResourceLocation loaderName = new ResourceLocation(GsonHelper.getAsString(json, "loader")); loader = MinecraftForgeClient.getTextureAtlasSpriteLoader(loaderName); if (loader == null) { diff --git a/src/main/java/net/minecraftforge/client/textures/ITextureAtlasSpriteLoader.java b/src/main/java/net/minecraftforge/client/textures/ITextureAtlasSpriteLoader.java index a1ddabffb0..28bc2d6138 100644 --- a/src/main/java/net/minecraftforge/client/textures/ITextureAtlasSpriteLoader.java +++ b/src/main/java/net/minecraftforge/client/textures/ITextureAtlasSpriteLoader.java @@ -21,12 +21,12 @@ package net.minecraftforge.client.textures; import javax.annotation.Nonnull; -import net.minecraft.client.renderer.texture.AtlasTexture; -import net.minecraft.client.renderer.texture.NativeImage; +import com.mojang.blaze3d.platform.NativeImage; +import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.resources.IResource; -import net.minecraft.resources.IResourceManager; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.packs.resources.Resource; +import net.minecraft.server.packs.resources.ResourceManager; /** * A loader for custom TextureAtlasSprite implementations.
@@ -48,9 +48,9 @@ public interface ITextureAtlasSpriteLoader */ @Nonnull TextureAtlasSprite load( - AtlasTexture atlas, - IResourceManager resourceManager, TextureAtlasSprite.Info textureInfo, - IResource resource, + TextureAtlas atlas, + ResourceManager resourceManager, TextureAtlasSprite.Info textureInfo, + Resource resource, int atlasWidth, int atlasHeight, int spriteX, int spriteY, int mipmapLevel, NativeImage image diff --git a/src/main/java/net/minecraftforge/common/AdvancementLoadFix.java b/src/main/java/net/minecraftforge/common/AdvancementLoadFix.java index da63cb49d5..484dd4b416 100644 --- a/src/main/java/net/minecraftforge/common/AdvancementLoadFix.java +++ b/src/main/java/net/minecraftforge/common/AdvancementLoadFix.java @@ -24,7 +24,7 @@ import com.google.common.graph.GraphBuilder; import com.google.common.graph.MutableGraph; import net.minecraft.advancements.Advancement; import net.minecraft.advancements.AdvancementProgress; -import net.minecraft.advancements.PlayerAdvancements; +import net.minecraft.server.PlayerAdvancements; import net.minecraftforge.fml.loading.toposort.TopologicalSort; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; diff --git a/src/main/java/net/minecraftforge/common/BasicTrade.java b/src/main/java/net/minecraftforge/common/BasicTrade.java index 4f8aaa3741..d6ec355f3a 100644 --- a/src/main/java/net/minecraftforge/common/BasicTrade.java +++ b/src/main/java/net/minecraftforge/common/BasicTrade.java @@ -23,17 +23,17 @@ import java.util.Random; import javax.annotation.Nullable; -import net.minecraft.entity.Entity; -import net.minecraft.entity.merchant.villager.VillagerTrades.ITrade; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.item.MerchantOffer; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.npc.VillagerTrades.ItemListing; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.trading.MerchantOffer; /** * A default, exposed implementation of ITrade. All of the other implementations of ITrade (in VillagerTrades) are not public. * This class contains everything needed to make a MerchantOffer, the actual "trade" object shown in trading guis. */ -public class BasicTrade implements ITrade +public class BasicTrade implements ItemListing { protected final ItemStack price; diff --git a/src/main/java/net/minecraftforge/common/BiomeDictionary.java b/src/main/java/net/minecraftforge/common/BiomeDictionary.java index 9ff27c4c19..c96cb8ca4f 100644 --- a/src/main/java/net/minecraftforge/common/BiomeDictionary.java +++ b/src/main/java/net/minecraftforge/common/BiomeDictionary.java @@ -29,15 +29,16 @@ import javax.annotation.Nullable; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import net.minecraft.world.biome.Biomes; -import net.minecraft.util.RegistryKey; -import net.minecraft.util.registry.Registry; -import net.minecraft.world.biome.*; +import net.minecraft.world.level.biome.Biomes; +import net.minecraft.resources.ResourceKey; +import net.minecraft.core.Registry; import static net.minecraftforge.common.BiomeDictionary.Type.*; import net.minecraftforge.registries.ForgeRegistries; import com.google.common.collect.ImmutableList; +import net.minecraft.world.level.biome.Biome; + public class BiomeDictionary { private static final boolean DEBUG = false; @@ -103,8 +104,8 @@ public class BiomeDictionary private final String name; private final List subTypes; - private final Set> biomes = new HashSet<>(); - private final Set> biomesUn = Collections.unmodifiableSet(biomes); + private final Set> biomes = new HashSet<>(); + private final Set> biomesUn = Collections.unmodifiableSet(biomes); private Type(String name, Type... subTypes) { @@ -164,17 +165,17 @@ public class BiomeDictionary } @Nullable - public static Type fromVanilla(Biome.Category category) + public static Type fromVanilla(Biome.BiomeCategory category) { - if (category == Biome.Category.NONE) + if (category == Biome.BiomeCategory.NONE) return null; - if (category == Biome.Category.THEEND) + if (category == Biome.BiomeCategory.THEEND) return VOID; return getType(category.name()); } } - private static final Map, BiomeInfo> biomeInfoMap = new HashMap<>(); + private static final Map, BiomeInfo> biomeInfoMap = new HashMap<>(); private static class BiomeInfo { @@ -192,7 +193,7 @@ public class BiomeDictionary * Adds the given types to the biome. * */ - public static void addTypes(RegistryKey biome, Type... types) + public static void addTypes(ResourceKey biome, Type... types) { Collection supertypes = listSupertypes(types); Collections.addAll(supertypes, types); @@ -212,7 +213,7 @@ public class BiomeDictionary * */ @Nonnull - public static Set> getBiomes(Type type) + public static Set> getBiomes(Type type) { return type.biomesUn; } @@ -222,7 +223,7 @@ public class BiomeDictionary * */ @Nonnull - public static Set getTypes(RegistryKey biome) + public static Set getTypes(ResourceKey biome) { return getBiomeInfo(biome).typesUn; } @@ -232,7 +233,7 @@ public class BiomeDictionary * * @return returns true if a common type is found, false otherwise */ - public static boolean areSimilar(RegistryKey biomeA, RegistryKey biomeB) + public static boolean areSimilar(ResourceKey biomeA, ResourceKey biomeB) { Set typesA = getTypes(biomeA); Set typesB = getTypes(biomeB); @@ -243,7 +244,7 @@ public class BiomeDictionary * Checks if the given type has been added to the given biome. * */ - public static boolean hasType(RegistryKey biome, Type type) + public static boolean hasType(ResourceKey biome, Type type) { return getTypes(biome).contains(type); } @@ -252,13 +253,13 @@ public class BiomeDictionary * Checks if any type has been added to the given biome. * */ - public static boolean hasAnyType(RegistryKey biome) + public static boolean hasAnyType(ResourceKey biome) { return !getBiomeInfo(biome).types.isEmpty(); } //Internal implementation - private static BiomeInfo getBiomeInfo(RegistryKey biome) + private static BiomeInfo getBiomeInfo(ResourceKey biome) { return biomeInfoMap.computeIfAbsent(biome, k -> new BiomeInfo()); } @@ -372,7 +373,7 @@ public class BiomeDictionary Type.byName.forEach((name, type) -> buf.append(" ").append(type.name).append(": ") .append(type.biomes.stream() - .map(RegistryKey::location) + .map(ResourceKey::location) .sorted((a,b) -> a.compareNamespaced(b)) .map(Object::toString) .collect(Collectors.joining(", ")) @@ -381,11 +382,11 @@ public class BiomeDictionary ); boolean missing = false; - List> all = StreamSupport.stream(ForgeRegistries.BIOMES.spliterator(), false) - .map(b -> RegistryKey.create(Registry.BIOME_REGISTRY, b.getRegistryName())) + List> all = StreamSupport.stream(ForgeRegistries.BIOMES.spliterator(), false) + .map(b -> ResourceKey.create(Registry.BIOME_REGISTRY, b.getRegistryName())) .sorted().collect(Collectors.toList()); - for (RegistryKey key : all) { + for (ResourceKey key : all) { if (!biomeInfoMap.containsKey(key)) { if (!missing) { buf.append("Missing:\n"); diff --git a/src/main/java/net/minecraftforge/common/BiomeManager.java b/src/main/java/net/minecraftforge/common/BiomeManager.java index 1145fef9ae..8a3f479ea7 100644 --- a/src/main/java/net/minecraftforge/common/BiomeManager.java +++ b/src/main/java/net/minecraftforge/common/BiomeManager.java @@ -27,16 +27,16 @@ import java.util.List; import com.google.common.collect.ImmutableList; -import net.minecraft.world.biome.Biomes; -import net.minecraft.util.RegistryKey; -import net.minecraft.util.WeightedRandom; -import net.minecraft.world.biome.Biome; +import net.minecraft.world.level.biome.Biomes; +import net.minecraft.resources.ResourceKey; +import net.minecraft.util.WeighedRandom; +import net.minecraft.world.level.biome.Biome; public class BiomeManager { private static TrackedList[] biomes = setupBiomes(); - private static final List> additionalOverworldBiomes = new ArrayList<>(); - private static final List> additionalOverworldBiomesView = Collections.unmodifiableList(additionalOverworldBiomes); + private static final List> additionalOverworldBiomes = new ArrayList<>(); + private static final List> additionalOverworldBiomesView = Collections.unmodifiableList(additionalOverworldBiomes); private static TrackedList[] setupBiomes() { @@ -103,7 +103,7 @@ public class BiomeManager /** * Add biomes that you add to the overworld without using {@link BiomeManager#addBiome(BiomeType, BiomeEntry)} */ - public static void addAdditionalOverworldBiomes(RegistryKey biome) + public static void addAdditionalOverworldBiomes(ResourceKey biome) { if (!"minecraft".equals(biome.location().getNamespace()) && additionalOverworldBiomes.stream().noneMatch(entry -> entry.location().equals(biome.location()))) { @@ -133,7 +133,7 @@ public class BiomeManager /** * @return list of biomes that might be generated in the overworld in addition to the vanilla biomes */ - public static List> getAdditionalOverworldBiomes() + public static List> getAdditionalOverworldBiomes() { return additionalOverworldBiomesView; } @@ -157,17 +157,17 @@ public class BiomeManager DESERT, DESERT_LEGACY, WARM, COOL, ICY; } - public static class BiomeEntry extends WeightedRandom.Item + public static class BiomeEntry extends WeighedRandom.WeighedRandomItem { - private final RegistryKey key; + private final ResourceKey key; - public BiomeEntry(RegistryKey key, int weight) + public BiomeEntry(ResourceKey key, int weight) { super(weight); this.key = key; } - public RegistryKey getKey() + public ResourceKey getKey() { return this.key; } diff --git a/src/main/java/net/minecraftforge/common/DungeonHooks.java b/src/main/java/net/minecraftforge/common/DungeonHooks.java index 7bc9b8b69c..c583bf429d 100644 --- a/src/main/java/net/minecraftforge/common/DungeonHooks.java +++ b/src/main/java/net/minecraftforge/common/DungeonHooks.java @@ -23,8 +23,8 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.Random; -import net.minecraft.entity.EntityType; -import net.minecraft.util.WeightedRandom; +import net.minecraft.world.entity.EntityType; +import net.minecraft.util.WeighedRandom; public class DungeonHooks { @@ -93,12 +93,12 @@ public class DungeonHooks */ public static EntityType getRandomDungeonMob(Random rand) { - DungeonMob mob = WeightedRandom.getRandomItem(rand, dungeonMobs); + DungeonMob mob = WeighedRandom.getRandomItem(rand, dungeonMobs).orElseThrow(); return mob.type; } - public static class DungeonMob extends WeightedRandom.Item + public static class DungeonMob extends WeighedRandom.WeighedRandomItem { public final EntityType type; public DungeonMob(int weight, EntityType type) diff --git a/src/main/java/net/minecraftforge/common/FarmlandWaterManager.java b/src/main/java/net/minecraftforge/common/FarmlandWaterManager.java index bdcb7599e3..995a3370d9 100644 --- a/src/main/java/net/minecraftforge/common/FarmlandWaterManager.java +++ b/src/main/java/net/minecraftforge/common/FarmlandWaterManager.java @@ -21,13 +21,13 @@ package net.minecraftforge.common; import com.google.common.base.Preconditions; import com.google.common.collect.MapMaker; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.ChunkPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.IWorldReader; -import net.minecraft.world.World; -import net.minecraft.world.chunk.IChunk; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraftforge.common.ticket.AABBTicket; import net.minecraftforge.common.ticket.ChunkTicketManager; import net.minecraftforge.common.ticket.SimpleTicket; @@ -42,7 +42,7 @@ import java.util.WeakHashMap; public class FarmlandWaterManager { private static final boolean DEBUG = Boolean.parseBoolean(System.getProperty("forge.debugFarmlandWaterManager", "false")); - private static final Map>> customWaterHandler = new WeakHashMap<>(); + private static final Map>> customWaterHandler = new WeakHashMap<>(); private static final Logger LOGGER = LogManager.getLogger(); /** @@ -58,11 +58,11 @@ public class FarmlandWaterManager * @return The ticket for your requested region. */ @SuppressWarnings("unchecked") - public static> T addCustomTicket(World world, T ticket, ChunkPos masterChunk, ChunkPos... additionalChunks) + public static> T addCustomTicket(Level world, T ticket, ChunkPos masterChunk, ChunkPos... additionalChunks) { Preconditions.checkArgument(!world.isClientSide, "Water region is only determined server-side"); - Map> ticketMap = customWaterHandler.computeIfAbsent(world, id -> new MapMaker().weakValues().makeMap()); - ChunkTicketManager[] additionalTickets = new ChunkTicketManager[additionalChunks.length]; + Map> ticketMap = customWaterHandler.computeIfAbsent(world, id -> new MapMaker().weakValues().makeMap()); + ChunkTicketManager[] additionalTickets = new ChunkTicketManager[additionalChunks.length]; for (int i = 0; i < additionalChunks.length; i++) additionalTickets[i] = ticketMap.computeIfAbsent(additionalChunks[i], ChunkTicketManager::new); ticket.setManager(ticketMap.computeIfAbsent(masterChunk, ChunkTicketManager::new), additionalTickets); @@ -81,7 +81,7 @@ public class FarmlandWaterManager * @param aabb The region where blocks should be watered * @return The ticket for your requested region. */ - public static AABBTicket addAABBTicket(World world, AxisAlignedBB aabb) + public static AABBTicket addAABBTicket(Level world, AABB aabb) { if (DEBUG) LOGGER.info("FarmlandWaterManager: New AABBTicket, aabb={}", aabb); @@ -115,7 +115,7 @@ public class FarmlandWaterManager return addCustomTicket(world, new AABBTicket(aabb), masterPos, posSet.toArray(new ChunkPos[0])); } - private static double getDistanceSq(ChunkPos pos, Vector3d vec3d) + private static double getDistanceSq(ChunkPos pos, Vec3 vec3d) { //See ChunkPos#getDistanceSq double d0 = (double)(pos.x * 16 + 8); @@ -129,13 +129,13 @@ public class FarmlandWaterManager * Tests if a block is in a region that is watered by blocks. This does not check vanilla water, see {@link net.minecraft.block.FarmlandBlock#hasWater(IWorldReader, BlockPos)} * @return true if there is a ticket with an AABB that includes your block */ - public static boolean hasBlockWaterTicket(IWorldReader world, BlockPos pos) + public static boolean hasBlockWaterTicket(LevelReader world, BlockPos pos) { - ChunkTicketManager ticketManager = getTicketManager(new ChunkPos(pos.getX() >> 4, pos.getZ() >> 4), world); + ChunkTicketManager ticketManager = getTicketManager(new ChunkPos(pos.getX() >> 4, pos.getZ() >> 4), world); if (ticketManager != null) { - Vector3d posAsVec3d = new Vector3d(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5); - for (SimpleTicket ticket : ticketManager.getTickets()) { + Vec3 posAsVec3d = new Vec3(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5); + for (SimpleTicket ticket : ticketManager.getTickets()) { if (ticket.matches(posAsVec3d)) return true; } @@ -143,9 +143,9 @@ public class FarmlandWaterManager return false; } - static void removeTickets(IChunk chunk) + static void removeTickets(ChunkAccess chunk) { - ChunkTicketManager ticketManager = getTicketManager(chunk.getPos(), chunk.getWorldForge()); + ChunkTicketManager ticketManager = getTicketManager(chunk.getPos(), chunk.getWorldForge()); if (ticketManager != null) { if (DEBUG) @@ -156,9 +156,9 @@ public class FarmlandWaterManager } } - private static ChunkTicketManager getTicketManager(ChunkPos pos, IWorldReader world) { + private static ChunkTicketManager getTicketManager(ChunkPos pos, LevelReader world) { Preconditions.checkArgument(!world.isClientSide(), "Water region is only determined server-side"); - Map> ticketMap = customWaterHandler.get(world); + Map> ticketMap = customWaterHandler.get(world); if (ticketMap == null) { return null; diff --git a/src/main/java/net/minecraftforge/common/ForgeConfig.java b/src/main/java/net/minecraftforge/common/ForgeConfig.java index f0cdf314df..d8d814ca01 100644 --- a/src/main/java/net/minecraftforge/common/ForgeConfig.java +++ b/src/main/java/net/minecraftforge/common/ForgeConfig.java @@ -19,10 +19,10 @@ package net.minecraftforge.common; -import static net.minecraftforge.fml.loading.LogMarkers.FORGEMOD; +import static net.minecraftforge.fml.Logging.FORGEMOD; import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.config.ModConfig; +import net.minecraftforge.fml.event.config.ModConfigEvent; import org.apache.commons.lang3.tuple.Pair; import org.apache.logging.log4j.LogManager; @@ -34,7 +34,7 @@ public class ForgeConfig { public static class Server { public final BooleanValue removeErroringEntities; - public final BooleanValue removeErroringTileEntities; + public final BooleanValue removeErroringBlockEntities; public final BooleanValue fullBoundingBoxLadders; @@ -60,11 +60,11 @@ public class ForgeConfig .worldRestart() .define("removeErroringEntities", false); - removeErroringTileEntities = builder - .comment("Set this to true to remove any TileEntity that throws an error in its update method instead of closing the server and reporting a crash log. BE WARNED THIS COULD SCREW UP EVERYTHING USE SPARINGLY WE ARE NOT RESPONSIBLE FOR DAMAGES.") - .translation("forge.configgui.removeErroringTileEntities") + removeErroringBlockEntities = builder + .comment("Set this to true to remove any BlockEntity that throws an error in its update method instead of closing the server and reporting a crash log. BE WARNED THIS COULD SCREW UP EVERYTHING USE SPARINGLY WE ARE NOT RESPONSIBLE FOR DAMAGES.") + .translation("forge.configgui.removeErroringBlockEntities") .worldRestart() - .define("removeErroringTileEntities", false); + .define("removeErroringBlockEntities", false); fullBoundingBoxLadders = builder .comment("Set this to true to check the entire entity's collision bounding box for ladders instead of just the block they are in. Causes noticeable differences in mechanics so default is vanilla behavior. Default: false.") @@ -237,12 +237,12 @@ public class ForgeConfig } @SubscribeEvent - public static void onLoad(final ModConfig.Loading configEvent) { + public static void onLoad(final ModConfigEvent.Loading configEvent) { LogManager.getLogger().debug(FORGEMOD, "Loaded forge config file {}", configEvent.getConfig().getFileName()); } @SubscribeEvent - public static void onFileChange(final ModConfig.Reloading configEvent) { + public static void onFileChange(final ModConfigEvent.Reloading configEvent) { LogManager.getLogger().debug(FORGEMOD, "Forge config just got changed on the file system!"); } diff --git a/src/main/java/net/minecraftforge/common/ForgeConfigSpec.java b/src/main/java/net/minecraftforge/common/ForgeConfigSpec.java index 03910fcb73..de16df496b 100644 --- a/src/main/java/net/minecraftforge/common/ForgeConfigSpec.java +++ b/src/main/java/net/minecraftforge/common/ForgeConfigSpec.java @@ -44,7 +44,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import com.google.common.annotations.VisibleForTesting; -import net.minecraft.util.SharedConstants; +import net.minecraftforge.fml.config.IConfigSpec; import net.minecraftforge.fml.loading.FMLEnvironment; import org.apache.commons.lang3.tuple.Pair; import org.apache.logging.log4j.LogManager; @@ -68,7 +68,7 @@ import com.google.common.collect.ObjectArrays; * Like {@link com.electronwill.nightconfig.core.ConfigSpec} except in builder format, and extended to accept comments, language keys, * and other things Forge configs would find useful. */ -public class ForgeConfigSpec extends UnmodifiableConfigWrapper //TODO: Remove extends and pipe everything through getSpec/getValues? +public class ForgeConfigSpec extends UnmodifiableConfigWrapper implements IConfigSpec//TODO: Remove extends and pipe everything through getSpec/getValues? { private Map, String> levelComments = new HashMap<>(); @@ -101,6 +101,11 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper clazz; - public void setComment(String... value) { this.comment = value == null ? new String[] {""} : value; } // TODO 1.17: this should throw an IllegalStateException in future + public void setComment(String... value) + { + validate(value == null, "Passed in null value for comment"); + this.comment = value; + } public boolean hasComment() { return this.comment.length > 0; } public String[] getComment() { return this.comment; } public String buildComment() { return LINE_JOINER.join(comment); } @@ -793,8 +802,7 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper { - @VisibleForTesting - static boolean USE_CACHES = true; + private static boolean USE_CACHES = true; private final Builder parent; private final List path; diff --git a/src/main/java/net/minecraftforge/common/ForgeHooks.java b/src/main/java/net/minecraftforge/common/ForgeHooks.java index d1a77bcc22..6c735561fc 100644 --- a/src/main/java/net/minecraftforge/common/ForgeHooks.java +++ b/src/main/java/net/minecraftforge/common/ForgeHooks.java @@ -55,85 +55,77 @@ import javax.annotation.Nullable; import it.unimi.dsi.fastutil.longs.LongSet; import net.minecraft.advancements.Advancement; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.entity.ai.attributes.Attribute; -import net.minecraft.entity.ai.attributes.AttributeModifier; -import net.minecraft.entity.ai.attributes.AttributeModifierMap; -import net.minecraft.entity.ai.attributes.GlobalEntityTypeAttributes; -import net.minecraft.fluid.*; -import net.minecraft.inventory.EquipmentSlotType; -import net.minecraft.item.crafting.IRecipeType; -import net.minecraft.loot.LootContext; -import net.minecraft.loot.LootTable; -import net.minecraft.loot.LootTableManager; -import net.minecraft.tags.ITag; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.entity.ai.attributes.Attribute; +import net.minecraft.world.entity.ai.attributes.AttributeModifier; +import net.minecraft.world.entity.ai.attributes.AttributeSupplier; +import net.minecraft.world.entity.ai.attributes.DefaultAttributes; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.LootTable; +import net.minecraft.world.level.storage.loot.LootTables; +import net.minecraft.tags.Tag; import net.minecraft.util.*; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.MobEntity; -import net.minecraft.entity.SpawnReason; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.item.minecart.ContainerMinecartEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.block.Blocks; -import net.minecraft.inventory.container.RepairContainer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.Item; -import net.minecraft.item.AxeItem; -import net.minecraft.item.BucketItem; -import net.minecraft.item.EnchantedBookItem; -import net.minecraft.item.HoeItem; -import net.minecraft.item.PickaxeItem; -import net.minecraft.item.PotionItem; -import net.minecraft.item.ShovelItem; -import net.minecraft.item.SpawnEggItem; -import net.minecraft.item.ItemStack; -import net.minecraft.item.TippedArrowItem; -import net.minecraft.item.ItemUseContext; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.ListNBT; -import net.minecraft.network.play.ServerPlayNetHandler; -import net.minecraft.network.IPacket; -import net.minecraft.network.datasync.IDataSerializer; -import net.minecraft.network.play.server.SChangeBlockPacket; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionUtils; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.Mob; +import net.minecraft.world.entity.MobSpawnType; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.vehicle.AbstractMinecartContainer; +import net.minecraft.world.entity.player.Player; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.inventory.AnvilMenu; +import net.minecraft.world.Container; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.BucketItem; +import net.minecraft.world.item.EnchantedBookItem; +import net.minecraft.world.item.PotionItem; +import net.minecraft.world.item.SpawnEggItem; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.TippedArrowItem; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.server.network.ServerGamePacketListenerImpl; +import net.minecraft.network.protocol.Packet; +import net.minecraft.network.syncher.EntityDataSerializer; +import net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket; +import net.minecraft.world.item.alchemy.Potion; +import net.minecraft.world.item.alchemy.PotionUtils; import net.minecraft.stats.Stats; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.registry.DynamicRegistries; -import net.minecraft.util.registry.Registry; -import net.minecraft.util.registry.SimpleRegistry; -import net.minecraft.util.registry.WorldSettingsImport; -import net.minecraft.util.registry.WorldGenSettingsExport; -import net.minecraft.util.text.*; +import net.minecraft.world.phys.Vec3; +import net.minecraft.core.RegistryAccess; +import net.minecraft.core.Registry; +import net.minecraft.core.MappedRegistry; +import net.minecraft.resources.RegistryReadOps; +import net.minecraft.resources.RegistryWriteOps; import net.minecraft.world.*; -import net.minecraft.world.chunk.IChunk; -import net.minecraft.world.gen.DimensionSettings; -import net.minecraft.world.gen.feature.structure.Structure; -import net.minecraft.world.gen.settings.DimensionGeneratorSettings; -import net.minecraft.world.spawner.AbstractSpawner; -import net.minecraft.tileentity.FurnaceTileEntity; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.EntityRayTraceResult; -import net.minecraft.util.text.event.ClickEvent; -import net.minecraft.world.biome.Biome; -import net.minecraft.world.biome.BiomeAmbience; -import net.minecraft.world.biome.BiomeGenerationSettings; -import net.minecraft.world.biome.MobSpawnInfo; +import net.minecraft.world.level.chunk.ChunkAccess; +import net.minecraft.world.level.levelgen.NoiseGeneratorSettings; +import net.minecraft.world.level.levelgen.feature.StructureFeature; +import net.minecraft.world.level.levelgen.WorldGenSettings; +import net.minecraft.world.level.BaseSpawner; +import net.minecraft.world.level.block.entity.FurnaceBlockEntity; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.EntityHitResult; +import net.minecraft.network.chat.ClickEvent; +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; @@ -174,8 +166,8 @@ import net.minecraftforge.event.world.NoteBlockEvent; import net.minecraftforge.eventbus.api.Event.Result; import net.minecraftforge.fluids.FluidAttributes; import net.minecraftforge.fml.ModLoader; -import net.minecraftforge.fml.common.ObfuscationReflectionHelper; -import net.minecraftforge.fml.packs.ResourcePackLoader; +import net.minecraftforge.fml.util.ObfuscationReflectionHelper; +import net.minecraftforge.fmllegacy.packs.ResourcePackLoader; import net.minecraftforge.registries.DataSerializerEntry; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.ForgeRegistry; @@ -188,6 +180,30 @@ import org.apache.logging.log4j.Marker; import org.apache.logging.log4j.MarkerManager; import org.apache.logging.log4j.util.TriConsumer; +import net.minecraft.ChatFormatting; +import net.minecraft.core.Direction; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.network.chat.TextColor; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.GameType; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.block.state.pattern.BlockInWorld; +import net.minecraft.world.level.dimension.DimensionType; +import net.minecraft.world.level.dimension.LevelStem; +import net.minecraft.world.level.material.EmptyFluid; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.level.material.LavaFluid; +import net.minecraft.world.level.material.WaterFluid; + public class ForgeHooks { private static final Logger LOGGER = LogManager.getLogger(); @@ -203,7 +219,7 @@ public class ForgeHooks return false; } - public static boolean canHarvestBlock(@Nonnull BlockState state, @Nonnull PlayerEntity player, @Nonnull IBlockReader world, @Nonnull BlockPos pos) + public static boolean canHarvestBlock(@Nonnull BlockState state, @Nonnull Player player, @Nonnull BlockGetter world, @Nonnull BlockPos pos) { //state = state.getActualState(world, pos); if (!state.requiresCorrectToolForDrops()) @@ -221,7 +237,7 @@ public class ForgeHooks return ForgeEventFactory.doPlayerHarvestCheck(player, state, toolLevel >= state.getHarvestLevel()); } - public static boolean isToolEffective(IWorldReader world, BlockPos pos, @Nonnull ItemStack stack) + public static boolean isToolEffective(LevelReader world, BlockPos pos, @Nonnull ItemStack stack) { BlockState state = world.getBlockState(pos); //state = state.getActualState(world, pos); @@ -240,20 +256,6 @@ public class ForgeHooks return; toolInit = true; - Set blocks = getPrivateValue(PickaxeItem.class, null, 0); - blocks.forEach(block -> blockToolSetter.accept(block, ToolType.PICKAXE, 0)); - blocks = getPrivateValue(ShovelItem.class, null, 0); - blocks.forEach(block -> blockToolSetter.accept(block, ToolType.SHOVEL, 0)); - //Axes check Materials and Blocks now. - Set materials = getPrivateValue(AxeItem.class, null, 0); - for (Block block : ForgeRegistries.BLOCKS) - if (materials.contains(block.defaultBlockState().getMaterial())) - blockToolSetter.accept(block, ToolType.AXE, 0); - blocks = getPrivateValue(AxeItem.class, null, 1); - blocks.forEach(block -> blockToolSetter.accept(block, ToolType.AXE, 0)); - blocks = getPrivateValue(HoeItem.class, null, 0); - blocks.forEach(block -> blockToolSetter.accept(block, ToolType.HOE, 0)); - //This is taken from PickaxeItem, if that changes update here. for (Block block : new Block[]{Blocks.OBSIDIAN, Blocks.CRYING_OBSIDIAN, Blocks.NETHERITE_BLOCK, Blocks.RESPAWN_ANCHOR, Blocks.ANCIENT_DEBRIS}) blockToolSetter.accept(block, ToolType.PICKAXE, 3); @@ -267,21 +269,21 @@ public class ForgeHooks * Called when a player uses 'pick block', calls new Entity and Block hooks. */ @SuppressWarnings("resource") - public static boolean onPickBlock(RayTraceResult target, PlayerEntity player, World world) + public static boolean onPickBlock(HitResult target, Player player, Level world) { ItemStack result = ItemStack.EMPTY; - boolean isCreative = player.abilities.instabuild; - TileEntity te = null; + boolean isCreative = player.getAbilities().instabuild; + BlockEntity te = null; - if (target.getType() == RayTraceResult.Type.BLOCK) + if (target.getType() == HitResult.Type.BLOCK) { - BlockPos pos = ((BlockRayTraceResult)target).getBlockPos(); + BlockPos pos = ((BlockHitResult)target).getBlockPos(); BlockState state = world.getBlockState(pos); - if (state.isAir(world, pos)) + if (state.isAir()) return false; - if (isCreative && Screen.hasControlDown() && state.hasTileEntity()) + if (isCreative && Screen.hasControlDown() && state.hasBlockEntity()) te = world.getBlockEntity(pos); result = state.getPickBlock(target, world, pos, player); @@ -289,9 +291,9 @@ public class ForgeHooks if (result.isEmpty()) LOGGER.warn("Picking on: [{}] {} gave null item", target.getType(), state.getBlock().getRegistryName()); } - else if (target.getType() == RayTraceResult.Type.ENTITY) + else if (target.getType() == HitResult.Type.ENTITY) { - Entity entity = ((EntityRayTraceResult)target).getEntity(); + Entity entity = ((EntityHitResult)target).getEntity(); result = entity.getPickedResult(target); if (result.isEmpty()) @@ -306,15 +308,15 @@ public class ForgeHooks if (isCreative) { - player.inventory.setPickedItem(result); - Minecraft.getInstance().gameMode.handleCreativeModeItemAdd(player.getItemInHand(Hand.MAIN_HAND), 36 + player.inventory.selected); + player.getInventory().setPickedItem(result); + Minecraft.getInstance().gameMode.handleCreativeModeItemAdd(player.getItemInHand(InteractionHand.MAIN_HAND), 36 + player.getInventory().selected); return true; } - int slot = player.inventory.findSlotMatchingItem(result); + int slot = player.getInventory().findSlotMatchingItem(result); if (slot != -1) { - if (PlayerInventory.isHotbarSlot(slot)) - player.inventory.selected = slot; + if (Inventory.isHotbarSlot(slot)) + player.getInventory().selected = slot; else Minecraft.getInstance().gameMode.handlePickItem(slot); return true; @@ -342,7 +344,7 @@ public class ForgeHooks public static boolean onLivingAttack(LivingEntity entity, DamageSource src, float amount) { - return entity instanceof PlayerEntity || !MinecraftForge.EVENT_BUS.post(new LivingAttackEvent(entity, src, amount)); + return entity instanceof Player || !MinecraftForge.EVENT_BUS.post(new LivingAttackEvent(entity, src, amount)); } public static boolean onPlayerAttack(LivingEntity entity, DamageSource src, float amount) @@ -403,28 +405,15 @@ public class ForgeHooks return event.getLootingLevel(); } - /** - * TODO 1.17 remove - * Unused - */ - @Deprecated - public static double getPlayerVisibilityDistance(PlayerEntity player, double xzDistance, double maxXZDistance) - { - PlayerEvent.Visibility event = new PlayerEvent.Visibility(player); - MinecraftForge.EVENT_BUS.post(event); - double value = event.getVisibilityModifier() * xzDistance; - return value >= maxXZDistance ? maxXZDistance : value; - } - public static double getEntityVisibilityMultiplier(LivingEntity entity, Entity lookingEntity, double originalMultiplier){ LivingEvent.LivingVisibilityEvent event = new LivingEvent.LivingVisibilityEvent(entity, lookingEntity, originalMultiplier); MinecraftForge.EVENT_BUS.post(event); return Math.max(0,event.getVisibilityModifier()); } - public static boolean isLivingOnLadder(@Nonnull BlockState state, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull LivingEntity entity) + public static boolean isLivingOnLadder(@Nonnull BlockState state, @Nonnull Level world, @Nonnull BlockPos pos, @Nonnull LivingEntity entity) { - boolean isSpectator = (entity instanceof PlayerEntity && ((PlayerEntity)entity).isSpectator()); + boolean isSpectator = (entity instanceof Player && ((Player)entity).isSpectator()); if (isSpectator) return false; if (!ForgeConfig.SERVER.fullBoundingBoxLadders.get()) { @@ -432,10 +421,10 @@ public class ForgeHooks } else { - AxisAlignedBB bb = entity.getBoundingBox(); - int mX = MathHelper.floor(bb.minX); - int mY = MathHelper.floor(bb.minY); - int mZ = MathHelper.floor(bb.minZ); + AABB bb = entity.getBoundingBox(); + int mX = Mth.floor(bb.minX); + int mY = Mth.floor(bb.minY); + int mZ = Mth.floor(bb.minZ); for (int y2 = mY; y2 < bb.maxY; y2++) { for (int x2 = mX; x2 < bb.maxX; x2++) @@ -461,7 +450,7 @@ public class ForgeHooks } @Nullable - public static ItemEntity onPlayerTossEvent(@Nonnull PlayerEntity player, @Nonnull ItemStack item, boolean includeName) + public static ItemEntity onPlayerTossEvent(@Nonnull Player player, @Nonnull ItemStack item, boolean includeName) { player.captureDrops(Lists.newArrayList()); ItemEntity ret = player.drop(item, false, includeName); @@ -480,7 +469,7 @@ public class ForgeHooks } @Nullable - public static ITextComponent onServerChatEvent(ServerPlayNetHandler net, String raw, ITextComponent comp) + public static Component onServerChatEvent(ServerGamePacketListenerImpl net, String raw, Component comp) { ServerChatEvent event = new ServerChatEvent(net.player, raw, comp); if (MinecraftForge.EVENT_BUS.post(event)) @@ -497,13 +486,13 @@ public class ForgeHooks "((?:[a-z0-9]{2,}:\\/\\/)?(?:(?:[0-9]{1,3}\\.){3}[0-9]{1,3}|(?:[-\\w_]{1,}\\.[a-z]{2,}?))(?::[0-9]{1,5})?.*?(?=[!\"\u00A7 \n]|$))", Pattern.CASE_INSENSITIVE); - public static ITextComponent newChatWithLinks(String string){ return newChatWithLinks(string, true); } - public static ITextComponent newChatWithLinks(String string, boolean allowMissingHeader) + public static Component newChatWithLinks(String string){ return newChatWithLinks(string, true); } + public static Component newChatWithLinks(String string, boolean allowMissingHeader) { // Includes ipv4 and domain pattern // Matches an ip (xx.xxx.xx.xxx) or a domain (something.com) with or // without a protocol or path. - IFormattableTextComponent ichat = null; + MutableComponent ichat = null; Matcher matcher = URL_PATTERN.matcher(string); int lastEnd = 0; @@ -518,13 +507,13 @@ public class ForgeHooks if (part.length() > 0) { if (ichat == null) - ichat = new StringTextComponent(part); + ichat = new TextComponent(part); else ichat.append(part); } lastEnd = end; String url = string.substring(start, end); - IFormattableTextComponent link = new StringTextComponent(url); + MutableComponent link = new TextComponent(url); try { @@ -534,7 +523,7 @@ public class ForgeHooks if (!allowMissingHeader) { if (ichat == null) - ichat = new StringTextComponent(url); + ichat = new TextComponent(url); else ichat.append(url); continue; @@ -545,29 +534,29 @@ public class ForgeHooks catch (URISyntaxException e) { // Bad syntax bail out! - if (ichat == null) ichat = new StringTextComponent(url); + if (ichat == null) ichat = new TextComponent(url); else ichat.append(url); continue; } // Set the click event and append the link. ClickEvent click = new ClickEvent(ClickEvent.Action.OPEN_URL, url); - link.setStyle(link.getStyle().withClickEvent(click).setUnderlined(true).withColor(Color.fromLegacyFormat(TextFormatting.BLUE))); + link.setStyle(link.getStyle().withClickEvent(click).setUnderlined(true).withColor(TextColor.fromLegacyFormat(ChatFormatting.BLUE))); if (ichat == null) - ichat = new StringTextComponent(""); + ichat = new TextComponent(""); ichat.append(link); } // Append the rest of the message. String end = string.substring(lastEnd); if (ichat == null) - ichat = new StringTextComponent(end); + ichat = new TextComponent(end); else if (end.length() > 0) - ichat.append(new StringTextComponent(string.substring(lastEnd))); + ichat.append(new TextComponent(string.substring(lastEnd))); return ichat; } - public static int onBlockBreakEvent(World world, GameType gameType, ServerPlayerEntity entityPlayer, BlockPos pos) + public static int onBlockBreakEvent(Level world, GameType gameType, ServerPlayer entityPlayer, BlockPos pos) { // Logic from tryHarvestBlock for pre-canceling the event boolean preCancelEvent = false; @@ -584,7 +573,7 @@ public class ForgeHooks if (!entityPlayer.mayBuild()) { - if (itemstack.isEmpty() || !itemstack.hasAdventureModeBreakTagForBlock(world.getTagManager(), new CachedBlockInfo(world, pos, false))) + if (itemstack.isEmpty() || !itemstack.hasAdventureModeBreakTagForBlock(world.getTagManager(), new BlockInWorld(world, pos, false))) preCancelEvent = true; } } @@ -592,7 +581,7 @@ public class ForgeHooks // Tell client the block is gone immediately then process events if (world.getBlockEntity(pos) == null) { - entityPlayer.connection.send(new SChangeBlockPacket(DUMMY_WORLD, pos)); + entityPlayer.connection.send(new ClientboundBlockUpdatePacket(DUMMY_WORLD, pos)); } // Post the block break event @@ -605,13 +594,13 @@ public class ForgeHooks if (event.isCanceled()) { // Let the client know the block still exists - entityPlayer.connection.send(new SChangeBlockPacket(world, pos)); + entityPlayer.connection.send(new ClientboundBlockUpdatePacket(world, pos)); // Update any tile entity data for this block - TileEntity tileentity = world.getBlockEntity(pos); - if (tileentity != null) + BlockEntity blockEntity = world.getBlockEntity(pos); + if (blockEntity != null) { - IPacket pkt = tileentity.getUpdatePacket(); + Packet pkt = blockEntity.getUpdatePacket(); if (pkt != null) { entityPlayer.connection.send(pkt); @@ -621,19 +610,19 @@ public class ForgeHooks return event.isCanceled() ? -1 : event.getExpToDrop(); } - public static ActionResultType onPlaceItemIntoWorld(@Nonnull ItemUseContext context) + public static InteractionResult onPlaceItemIntoWorld(@Nonnull UseOnContext context) { ItemStack itemstack = context.getItemInHand(); - World world = context.getLevel(); + Level world = context.getLevel(); - PlayerEntity player = context.getPlayer(); - if (player != null && !player.abilities.mayBuild && !itemstack.hasAdventureModePlaceTagForBlock(world.getTagManager(), new CachedBlockInfo(world, context.getClickedPos(), false))) - return ActionResultType.PASS; + Player player = context.getPlayer(); + if (player != null && !player.getAbilities().mayBuild && !itemstack.hasAdventureModePlaceTagForBlock(world.getTagManager(), new BlockInWorld(world, context.getClickedPos(), false))) + return InteractionResult.PASS; // handle all placement events here Item item = itemstack.getItem(); int size = itemstack.getCount(); - CompoundNBT nbt = null; + CompoundTag nbt = null; if (itemstack.getTag() != null) nbt = itemstack.getTag().copy(); @@ -641,7 +630,7 @@ public class ForgeHooks world.captureBlockSnapshots = true; ItemStack copy = itemstack.copy(); - ActionResultType ret = itemstack.getItem().useOn(context); + InteractionResult ret = itemstack.getItem().useOn(context); if (itemstack.isEmpty()) ForgeEventFactory.onPlayerDestroyItem(player, copy, context.getHand()); @@ -651,7 +640,7 @@ public class ForgeHooks { // save new item data int newSize = itemstack.getCount(); - CompoundNBT newNBT = null; + CompoundTag newNBT = null; if (itemstack.getTag() != null) { newNBT = itemstack.getTag().copy(); @@ -678,7 +667,7 @@ public class ForgeHooks if (eventResult) { - ret = ActionResultType.FAIL; // cancel placement + ret = InteractionResult.FAIL; // cancel placement // revert back all captured blocks for (BlockSnapshot blocksnapshot : Lists.reverse(blockSnapshots)) { @@ -711,13 +700,7 @@ public class ForgeHooks return ret; } - @Deprecated // TODO: Remove 1.17 - Use player-contextual version below. - public static boolean onAnvilChange(RepairContainer container, @Nonnull ItemStack left, @Nonnull ItemStack right, IInventory outputSlot, String name, int baseCost) - { - return onAnvilChange(container, left, right, outputSlot, name, baseCost, null); - } - - public static boolean onAnvilChange(RepairContainer container, @Nonnull ItemStack left, @Nonnull ItemStack right, IInventory outputSlot, String name, int baseCost, PlayerEntity player) + public static boolean onAnvilChange(AnvilMenu container, @Nonnull ItemStack left, @Nonnull ItemStack right, Container outputSlot, String name, int baseCost, Player player) { AnvilUpdateEvent e = new AnvilUpdateEvent(left, right, name, baseCost, player); if (MinecraftForge.EVENT_BUS.post(e)) return false; @@ -729,19 +712,19 @@ public class ForgeHooks return false; } - public static float onAnvilRepair(PlayerEntity player, @Nonnull ItemStack output, @Nonnull ItemStack left, @Nonnull ItemStack right) + public static float onAnvilRepair(Player player, @Nonnull ItemStack output, @Nonnull ItemStack left, @Nonnull ItemStack right) { AnvilRepairEvent e = new AnvilRepairEvent(player, left, right, output); MinecraftForge.EVENT_BUS.post(e); return e.getBreakChance(); } - private static ThreadLocal craftingPlayer = new ThreadLocal(); - public static void setCraftingPlayer(PlayerEntity player) + private static ThreadLocal craftingPlayer = new ThreadLocal(); + public static void setCraftingPlayer(Player player) { craftingPlayer.set(player); } - public static PlayerEntity getCraftingPlayer() + public static Player getCraftingPlayer() { return craftingPlayer.get(); } @@ -761,88 +744,80 @@ public class ForgeHooks return ItemStack.EMPTY; } - public static boolean onPlayerAttackTarget(PlayerEntity player, Entity target) + public static boolean onPlayerAttackTarget(Player player, Entity target) { if (MinecraftForge.EVENT_BUS.post(new AttackEntityEvent(player, target))) return false; ItemStack stack = player.getMainHandItem(); return stack.isEmpty() || !stack.getItem().onLeftClickEntity(stack, player, target); } - public static boolean onTravelToDimension(Entity entity, RegistryKey dimension) + public static boolean onTravelToDimension(Entity entity, ResourceKey dimension) { EntityTravelToDimensionEvent event = new EntityTravelToDimensionEvent(entity, dimension); MinecraftForge.EVENT_BUS.post(event); if (event.isCanceled()) { // Revert variable back to true as it would have been set to false - if (entity instanceof ContainerMinecartEntity) + if (entity instanceof AbstractMinecartContainer) { - ((ContainerMinecartEntity) entity).dropContentsWhenDead(true); + ((AbstractMinecartContainer) entity).dropContentsWhenDead(true); } } return !event.isCanceled(); } - public static ActionResultType onInteractEntityAt(PlayerEntity player, Entity entity, RayTraceResult ray, Hand hand) + public static InteractionResult onInteractEntityAt(Player player, Entity entity, HitResult ray, InteractionHand hand) { - Vector3d vec3d = ray.getLocation().subtract(entity.position()); + Vec3 vec3d = ray.getLocation().subtract(entity.position()); return onInteractEntityAt(player, entity, vec3d, hand); } - public static ActionResultType onInteractEntityAt(PlayerEntity player, Entity entity, Vector3d vec3d, Hand hand) + public static InteractionResult onInteractEntityAt(Player player, Entity entity, Vec3 vec3d, InteractionHand hand) { PlayerInteractEvent.EntityInteractSpecific evt = new PlayerInteractEvent.EntityInteractSpecific(player, hand, entity, vec3d); MinecraftForge.EVENT_BUS.post(evt); return evt.isCanceled() ? evt.getCancellationResult() : null; } - public static ActionResultType onInteractEntity(PlayerEntity player, Entity entity, Hand hand) + public static InteractionResult onInteractEntity(Player player, Entity entity, InteractionHand hand) { PlayerInteractEvent.EntityInteract evt = new PlayerInteractEvent.EntityInteract(player, hand, entity); MinecraftForge.EVENT_BUS.post(evt); return evt.isCanceled() ? evt.getCancellationResult() : null; } - public static ActionResultType onItemRightClick(PlayerEntity player, Hand hand) + public static InteractionResult onItemRightClick(Player player, InteractionHand hand) { PlayerInteractEvent.RightClickItem evt = new PlayerInteractEvent.RightClickItem(player, hand); MinecraftForge.EVENT_BUS.post(evt); return evt.isCanceled() ? evt.getCancellationResult() : null; } - public static PlayerInteractEvent.LeftClickBlock onLeftClickBlock(PlayerEntity player, BlockPos pos, Direction face) + public static PlayerInteractEvent.LeftClickBlock onLeftClickBlock(Player player, BlockPos pos, Direction face) { PlayerInteractEvent.LeftClickBlock evt = new PlayerInteractEvent.LeftClickBlock(player, pos, face); MinecraftForge.EVENT_BUS.post(evt); return evt; } - @Deprecated //Use RayTraceResult version. TODO: Remove 1.17 - public static PlayerInteractEvent.RightClickBlock onRightClickBlock(PlayerEntity player, Hand hand, BlockPos pos, Direction face) - { - PlayerInteractEvent.RightClickBlock evt = new PlayerInteractEvent.RightClickBlock(player, hand, pos, face); - MinecraftForge.EVENT_BUS.post(evt); - return evt; - } - - public static PlayerInteractEvent.RightClickBlock onRightClickBlock(PlayerEntity player, Hand hand, BlockPos pos, BlockRayTraceResult hitVec) + public static PlayerInteractEvent.RightClickBlock onRightClickBlock(Player player, InteractionHand hand, BlockPos pos, BlockHitResult hitVec) { PlayerInteractEvent.RightClickBlock evt = new PlayerInteractEvent.RightClickBlock(player, hand, pos, hitVec); MinecraftForge.EVENT_BUS.post(evt); return evt; } - public static void onEmptyClick(PlayerEntity player, Hand hand) + public static void onEmptyClick(Player player, InteractionHand hand) { MinecraftForge.EVENT_BUS.post(new PlayerInteractEvent.RightClickEmpty(player, hand)); } - public static void onEmptyLeftClick(PlayerEntity player) + public static void onEmptyLeftClick(Player player) { MinecraftForge.EVENT_BUS.post(new PlayerInteractEvent.LeftClickEmpty(player)); } - public static boolean onChangeGameMode(PlayerEntity player, GameType currentGameMode, GameType newGameMode) + public static boolean onChangeGameMode(Player player, GameType currentGameMode, GameType newGameMode) { if (currentGameMode != newGameMode) { @@ -865,7 +840,7 @@ public class ForgeHooks } @Nullable - public static LootTable loadLootTable(Gson gson, ResourceLocation name, JsonElement data, boolean custom, LootTableManager lootTableManager) + public static LootTable loadLootTable(Gson gson, ResourceLocation name, JsonElement data, boolean custom, LootTables lootTableManager) { Deque que = lootContext.get(); if (que == null) @@ -934,10 +909,10 @@ public class ForgeHooks @FunctionalInterface public interface BiomeCallbackFunction { - Biome apply(final Biome.Climate climate, final Biome.Category category, final Float depth, final Float scale, final BiomeAmbience effects, final BiomeGenerationSettings gen, final MobSpawnInfo spawns); + Biome apply(final Biome.ClimateSettings climate, final Biome.BiomeCategory category, final Float depth, final Float scale, final BiomeSpecialEffects effects, final BiomeGenerationSettings gen, final MobSpawnSettings spawns); } - public static Biome enhanceBiome(@Nullable final ResourceLocation name, final Biome.Climate climate, final Biome.Category category, final Float depth, final Float scale, final BiomeAmbience effects, final BiomeGenerationSettings gen, final MobSpawnInfo spawns, final RecordCodecBuilder.Instance codec, final BiomeCallbackFunction callback) + public static Biome enhanceBiome(@Nullable final ResourceLocation name, final Biome.ClimateSettings climate, final Biome.BiomeCategory category, final Float depth, final Float scale, final BiomeSpecialEffects effects, final BiomeGenerationSettings gen, final MobSpawnSettings spawns, final RecordCodecBuilder.Instance codec, final BiomeCallbackFunction callback) { BiomeGenerationSettingsBuilder genBuilder = new BiomeGenerationSettingsBuilder(gen); MobSpawnInfoBuilder spawnBuilder = new MobSpawnInfoBuilder(spawns); @@ -996,7 +971,7 @@ public class ForgeHooks ctx.resetPoolCtx(); if (json.has("name")) - return JSONUtils.getAsString(json, "name"); + return GsonHelper.getAsString(json, "name"); if (ctx.custom) return "custom#" + json.hashCode(); //We don't care about custom ones modders shouldn't be editing them! @@ -1015,36 +990,36 @@ public class ForgeHooks ctx.entryCount++; if (json.has("entryName")) - return ctx.validateEntryName(JSONUtils.getAsString(json, "entryName")); + return ctx.validateEntryName(GsonHelper.getAsString(json, "entryName")); if (ctx.custom) return "custom#" + json.hashCode(); //We don't care about custom ones modders shouldn't be editing them! String name = null; if ("item".equals(type)) - name = JSONUtils.getAsString(json, "name"); + name = GsonHelper.getAsString(json, "name"); else if ("loot_table".equals(type)) - name = JSONUtils.getAsString(json, "name"); + name = GsonHelper.getAsString(json, "name"); else if ("empty".equals(type)) name = "empty"; return ctx.validateEntryName(name); } - public static boolean onCropsGrowPre(World worldIn, BlockPos pos, BlockState state, boolean def) + public static boolean onCropsGrowPre(Level worldIn, BlockPos pos, BlockState state, boolean def) { BlockEvent ev = new BlockEvent.CropGrowEvent.Pre(worldIn,pos,state); MinecraftForge.EVENT_BUS.post(ev); return (ev.getResult() == net.minecraftforge.eventbus.api.Event.Result.ALLOW || (ev.getResult() == net.minecraftforge.eventbus.api.Event.Result.DEFAULT && def)); } - public static void onCropsGrowPost(World worldIn, BlockPos pos, BlockState state) + public static void onCropsGrowPost(Level worldIn, BlockPos pos, BlockState state) { MinecraftForge.EVENT_BUS.post(new BlockEvent.CropGrowEvent.Post(worldIn, pos, state, worldIn.getBlockState(pos))); } @Nullable - public static CriticalHitEvent getCriticalHit(PlayerEntity player, Entity target, boolean vanillaCritical, float damageModifier) + public static CriticalHitEvent getCriticalHit(Player player, Entity target, boolean vanillaCritical, float damageModifier) { CriticalHitEvent hitResult = new CriticalHitEvent(player, target, damageModifier, vanillaCritical); MinecraftForge.EVENT_BUS.post(hitResult); @@ -1055,7 +1030,7 @@ public class ForgeHooks return null; } - public static void onAdvancement(ServerPlayerEntity player, Advancement advancement) + public static void onAdvancement(ServerPlayer player, Advancement advancement) { MinecraftForge.EVENT_BUS.post(new AdvancementEvent(player, advancement)); } @@ -1063,7 +1038,7 @@ public class ForgeHooks /** * Hook to fire {@link ItemAttributeModifierEvent}. Modders should use {@link ItemStack#getAttributeModifiers(EquipmentSlotType)} instead. */ - public static Multimap getAttributeModifiers(ItemStack stack, EquipmentSlotType equipmentSlot, Multimap attributes) + public static Multimap getAttributeModifiers(ItemStack stack, EquipmentSlot equipmentSlot, Multimap attributes) { ItemAttributeModifierEvent event = new ItemAttributeModifierEvent(stack, equipmentSlot, attributes); MinecraftForge.EVENT_BUS.post(event); @@ -1083,10 +1058,10 @@ public class ForgeHooks { if (item instanceof EnchantedBookItem) { - ListNBT enchantmentsNbt = EnchantedBookItem.getEnchantments(itemStack); + ListTag enchantmentsNbt = EnchantedBookItem.getEnchantments(itemStack); if (enchantmentsNbt.size() == 1) { - CompoundNBT nbttagcompound = enchantmentsNbt.getCompound(0); + CompoundTag nbttagcompound = enchantmentsNbt.getCompound(0); ResourceLocation resourceLocation = ResourceLocation.tryParse(nbttagcompound.getString("id")); if (resourceLocation != null && ForgeRegistries.ENCHANTMENTS.containsKey(resourceLocation)) { @@ -1115,7 +1090,7 @@ public class ForgeHooks return modId; } - public static boolean onFarmlandTrample(World world, BlockPos pos, BlockState state, float fallDistance, Entity entity) + public static boolean onFarmlandTrample(Level world, BlockPos pos, BlockState state, float fallDistance, Entity entity) { if (entity.canTrample(state, pos, fallDistance)) { @@ -1149,10 +1124,10 @@ public class ForgeHooks } private static final DummyBlockReader DUMMY_WORLD = new DummyBlockReader(); - private static class DummyBlockReader implements IBlockReader { + private static class DummyBlockReader implements BlockGetter { @Override - public TileEntity getBlockEntity(BlockPos pos) { + public BlockEntity getBlockEntity(BlockPos pos) { return null; } @@ -1166,58 +1141,54 @@ public class ForgeHooks return Fluids.EMPTY.defaultFluidState(); } + @Override + public int getHeight() { + return 0; + } + + @Override + public int getMinBuildHeight() { + return 0; + } } - public static int onNoteChange(World world, BlockPos pos, BlockState state, int old, int _new) { + public static int onNoteChange(Level world, BlockPos pos, BlockState state, int old, int _new) { NoteBlockEvent.Change event = new NoteBlockEvent.Change(world, pos, state, old, _new); if (MinecraftForge.EVENT_BUS.post(event)) return -1; return event.getVanillaNoteId(); } - public static int canEntitySpawn(MobEntity entity, IWorld world, double x, double y, double z, AbstractSpawner spawner, SpawnReason spawnReason) { + public static int canEntitySpawn(Mob entity, LevelAccessor world, double x, double y, double z, BaseSpawner spawner, MobSpawnType spawnReason) { Result res = ForgeEventFactory.canEntitySpawn(entity, world, x, y, z, null, spawnReason); return res == Result.DEFAULT ? 0 : res == Result.DENY ? -1 : 1; } - public static void deserializeTagAdditions(List list, JsonObject json, List allList) + public static void deserializeTagAdditions(List list, JsonObject json, List allList) { - //TODO 1.17 remove parsing the forge added "optional" array. Still here for compatibility with previously created tags. - if (json.has("optional")) - { - for (JsonElement entry : JSONUtils.getAsJsonArray(json, "optional")) - { - String s = JSONUtils.convertToString(entry, "value"); - if (!s.startsWith("#")) - list.add(new ITag.OptionalItemEntry(new ResourceLocation(s))); - else - list.add(new ITag.OptionalTagEntry(new ResourceLocation(s.substring(1)))); - } - } - if (json.has("remove")) { - for (JsonElement entry : JSONUtils.getAsJsonArray(json, "remove")) + for (JsonElement entry : GsonHelper.getAsJsonArray(json, "remove")) { - String s = JSONUtils.convertToString(entry, "value"); - ITag.ITagEntry dummy; + String s = GsonHelper.convertToString(entry, "value"); + Tag.Entry dummy; if (!s.startsWith("#")) - dummy = new ITag.ItemEntry(new ResourceLocation(s)); + dummy = new Tag.ElementEntry(new ResourceLocation(s)); else - dummy = new ITag.TagEntry(new ResourceLocation(s.substring(1))); + dummy = new Tag.TagEntry(new ResourceLocation(s.substring(1))); allList.removeIf(e -> e.getEntry().equals(dummy)); } } } - private static final Map, DataSerializerEntry> serializerEntries = GameData.getSerializerMap(); + private static final Map, DataSerializerEntry> serializerEntries = GameData.getSerializerMap(); //private static final ForgeRegistry serializerRegistry = (ForgeRegistry) ForgeRegistries.DATA_SERIALIZERS; // Do not reimplement this ^ it introduces a chicken-egg scenario by classloading registries during bootstrap @Nullable - public static IDataSerializer getSerializer(int id, IntIdentityHashBiMap> vanilla) + public static EntityDataSerializer getSerializer(int id, CrudeIncrementalIntIdentityHashBiMap> vanilla) { - IDataSerializer serializer = vanilla.byId(id); + EntityDataSerializer serializer = vanilla.byId(id); if (serializer == null) { DataSerializerEntry entry = ((ForgeRegistry)ForgeRegistries.DATA_SERIALIZERS).getValue(id); @@ -1226,7 +1197,7 @@ public class ForgeHooks return serializer; } - public static int getSerializerId(IDataSerializer serializer, IntIdentityHashBiMap> vanilla) + public static int getSerializerId(EntityDataSerializer serializer, CrudeIncrementalIntIdentityHashBiMap> vanilla) { int id = vanilla.getId(serializer); if (id < 0) @@ -1237,7 +1208,7 @@ public class ForgeHooks return id; } - public static boolean canEntityDestroy(World world, BlockPos pos, LivingEntity entity) + public static boolean canEntityDestroy(Level world, BlockPos pos, LivingEntity entity) { BlockState state = world.getBlockState(pos); return ForgeEventFactory.getMobGriefingEvent(world, entity) && state.canEntityDestroy(world, pos, entity) && ForgeEventFactory.onEntityDestroyBlock(entity, pos, state); @@ -1245,16 +1216,10 @@ public class ForgeHooks private static final Map, Integer> VANILLA_BURNS = new HashMap<>(); - @Deprecated // use variant with IRecipeType - public static int getBurnTime(ItemStack stack) - { - return getBurnTime(stack, null); - } - /** * Gets the burn time of this itemstack. */ - public static int getBurnTime(ItemStack stack, @Nullable IRecipeType recipeType) + public static int getBurnTime(ItemStack stack, @Nullable RecipeType recipeType) { if (stack.isEmpty()) { @@ -1272,7 +1237,7 @@ public class ForgeHooks public static synchronized void updateBurns() { VANILLA_BURNS.clear(); - FurnaceTileEntity.getFuel().entrySet().forEach(e -> VANILLA_BURNS.put(e.getKey().delegate, e.getValue())); + FurnaceBlockEntity.getFuel().entrySet().forEach(e -> VANILLA_BURNS.put(e.getKey().delegate, e.getValue())); } /** @@ -1336,7 +1301,7 @@ public class ForgeHooks * When a structure mod is removed, this map may contain null keys. This will make the world unable to save if this persists. * If we remove a structure from the save data in this way, we then mark the chunk for saving */ - public static void fixNullStructureReferences(IChunk chunk, Map, LongSet> structureReferences) + public static void fixNullStructureReferences(ChunkAccess chunk, Map, LongSet> structureReferences) { if (structureReferences.remove(null) != null) { @@ -1349,7 +1314,7 @@ public class ForgeHooks private static final String DIMENSIONS_KEY = "dimensions"; private static final String SEED_KEY = "seed"; //No to static init! - private static final LazyValue>> CODEC = new LazyValue<>(() -> SimpleRegistry.dataPackCodec(Registry.LEVEL_STEM_REGISTRY, Lifecycle.stable(), Dimension.CODEC).xmap(Dimension::sortMap, Function.identity())); + private static final LazyLoadedValue>> CODEC = new LazyLoadedValue<>(() -> MappedRegistry.dataPackCodec(Registry.LEVEL_STEM_REGISTRY, Lifecycle.stable(), LevelStem.CODEC).xmap(LevelStem::sortMap, Function.identity())); /** * Restores previously "deleted" dimensions to the world. @@ -1357,10 +1322,10 @@ public class ForgeHooks */ public static Dynamic fixUpDimensionsData(Dynamic data) { - if(!(data.getOps() instanceof WorldSettingsImport)) + if(!(data.getOps() instanceof RegistryReadOps)) return data; - WorldSettingsImport ops = (WorldSettingsImport) data.getOps(); + RegistryReadOps ops = (RegistryReadOps) data.getOps(); Dynamic dymData = data.get(DIMENSIONS_KEY).orElseEmptyMap(); Dynamic withInjected = dymData.asMapOpt().map(current -> { @@ -1371,7 +1336,7 @@ public class ForgeHooks if (!currentDimNames.containsAll(VANILLA_DIMS)) { LOGGER.warn("Detected missing vanilla dimensions from the world!"); - DynamicRegistries regs = ObfuscationReflectionHelper.getPrivateValue(WorldSettingsImport.class, ops, "field_240872_" + "d_"); + RegistryAccess regs = ObfuscationReflectionHelper.getPrivateValue(RegistryReadOps.class, ops, "f_13563" + "6_"); if (regs == null) // should not happen, but it could after a MC version update. throw new RuntimeException("Could not access dynamic registries using reflection. " + "The world was detected to have missing vanilla dimensions and the attempted fix did not work."); @@ -1379,30 +1344,30 @@ public class ForgeHooks long seed = data.get(SEED_KEY).get().result().map(d -> d.asLong(0L)).orElse(0L); Registry biomeReg = regs.registryOrThrow(Registry.BIOME_REGISTRY); Registry typeReg = regs.registryOrThrow(Registry.DIMENSION_TYPE_REGISTRY); - Registry noiseReg = regs.registryOrThrow(Registry.NOISE_GENERATOR_SETTINGS_REGISTRY); + Registry noiseReg = regs.registryOrThrow(Registry.NOISE_GENERATOR_SETTINGS_REGISTRY); //Loads the default nether and end - SimpleRegistry dimReg = DimensionType.defaultDimensions(typeReg, biomeReg, noiseReg, seed); + MappedRegistry dimReg = DimensionType.defaultDimensions(typeReg, biomeReg, noiseReg, seed); //Loads the default overworld - dimReg = DimensionGeneratorSettings.withOverworld(typeReg, dimReg, DimensionGeneratorSettings.makeDefaultOverworld(biomeReg, noiseReg, seed)); + dimReg = WorldGenSettings.withOverworld(typeReg, dimReg, WorldGenSettings.makeDefaultOverworld(biomeReg, noiseReg, seed)); // Encode and decode the registry. This adds any dimensions from datapacks (see SimpleRegistryCodec#decode), but only the vanilla overrides are needed. // This assumes that the datapacks for the vanilla dimensions have not changed since they were "deleted" // If they did, this will be seen in newly generated chunks. // Since this is to fix an older world, from before the fixes by forge, there is no way to know the state of the dimension when it was "deleted". - dimReg = CODEC.get().encodeStart(WorldGenSettingsExport.create(ops, regs), dimReg).flatMap(t -> CODEC.get().parse(ops, t)).result().orElse(dimReg); + dimReg = CODEC.get().encodeStart(RegistryWriteOps.create(ops, regs), dimReg).flatMap(t -> CODEC.get().parse(ops, t)).result().orElse(dimReg); for (String name : VANILLA_DIMS) { if (currentDimNames.contains(name)) continue; - Dimension dim = dimReg.get(new ResourceLocation(name)); + LevelStem dim = dimReg.get(new ResourceLocation(name)); if (dim == null) { LOGGER.error("The world is missing dimension: " + name + ", but the attempt to re-inject it failed."); continue; } LOGGER.info("Fixing world: re-injected dimension: " + name); - Optional dimT = Dimension.CODEC.encodeStart(WorldGenSettingsExport.create(ops, regs), dim).resultOrPartial(s->{}); + Optional dimT = LevelStem.CODEC.encodeStart(RegistryWriteOps.create(ops, regs), dim).resultOrPartial(s->{}); if (dimT.isPresent()) currentList.add(Pair.of(name, dimT.get())); else @@ -1417,10 +1382,10 @@ public class ForgeHooks return data.set(DIMENSIONS_KEY, withInjected); } - private static final Map, AttributeModifierMap> FORGE_ATTRIBUTES = new HashMap<>(); + private static final Map, AttributeSupplier> FORGE_ATTRIBUTES = new HashMap<>(); /** FOR INTERNAL USE ONLY, DO NOT CALL DIRECTLY */ @Deprecated - public static Map, AttributeModifierMap> getAttributesView() + public static Map, AttributeSupplier> getAttributesView() { return Collections.unmodifiableMap(FORGE_ATTRIBUTES); } @@ -1429,7 +1394,7 @@ public class ForgeHooks * ONLY EXISTS FOR LEGACY REASONS SHOULD BE REMOVED IN 1.17 */ @Deprecated /// Internal use only, Remove in 1.17 - public static AttributeModifierMap putAttributesOld(EntityType type, AttributeModifierMap map) + public static AttributeSupplier putAttributesOld(EntityType type, AttributeSupplier map) { LOGGER.warn("Called deprecated GlobalEntityTypeAttributes#put for {}, use EntityAttributeCreationEvent instead.", type.getRegistryName()); return FORGE_ATTRIBUTES.put(type, map); @@ -1440,13 +1405,13 @@ public class ForgeHooks public static void modifyAttributes() { ModLoader.get().postEvent(new EntityAttributeCreationEvent(FORGE_ATTRIBUTES)); - Map, AttributeModifierMap.MutableAttribute> finalMap = new HashMap<>(); + Map, AttributeSupplier.Builder> finalMap = new HashMap<>(); ModLoader.get().postEvent(new EntityAttributeModificationEvent(finalMap)); finalMap.forEach((k, v) -> { - AttributeModifierMap modifiers = GlobalEntityTypeAttributes.getSupplier(k); - AttributeModifierMap.MutableAttribute newMutable = modifiers != null ? new AttributeModifierMap.MutableAttribute(modifiers) : new AttributeModifierMap.MutableAttribute(); + AttributeSupplier modifiers = DefaultAttributes.getSupplier(k); + AttributeSupplier.Builder newMutable = modifiers != null ? new AttributeSupplier.Builder(modifiers) : new AttributeSupplier.Builder(); newMutable.combine(v); FORGE_ATTRIBUTES.put(k, newMutable.build()); }); diff --git a/src/main/java/net/minecraftforge/common/ForgeInternalHandler.java b/src/main/java/net/minecraftforge/common/ForgeInternalHandler.java index 340e63a4b8..7a901267c0 100644 --- a/src/main/java/net/minecraftforge/common/ForgeInternalHandler.java +++ b/src/main/java/net/minecraftforge/common/ForgeInternalHandler.java @@ -19,14 +19,13 @@ package net.minecraftforge.common; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.concurrent.ThreadTaskExecutor; -import net.minecraft.util.concurrent.TickDelayedTask; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.util.thread.BlockableEventLoop; +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; @@ -40,10 +39,9 @@ import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.event.TagsUpdatedEvent; import net.minecraftforge.event.TickEvent; import net.minecraftforge.event.TickEvent.ClientTickEvent; -import net.minecraftforge.event.TickEvent.Phase; import net.minecraftforge.event.TickEvent.ServerTickEvent; import net.minecraftforge.fml.LogicalSide; -import net.minecraftforge.fml.LogicalSidedProvider; +import net.minecraftforge.fmllegacy.LogicalSidedProvider; import net.minecraftforge.server.command.ForgeCommand; import net.minecraftforge.server.command.ConfigCommand; @@ -62,10 +60,10 @@ public class ForgeInternalHandler Entity newEntity = item.createEntity(event.getWorld(), entity, stack); if (newEntity != null) { - entity.remove(); + entity.remove(false); event.setCanceled(true); - ThreadTaskExecutor executor = LogicalSidedProvider.WORKQUEUE.get(event.getWorld().isClientSide ? LogicalSide.CLIENT : LogicalSide.SERVER); - executor.tell(new TickDelayedTask(0, () -> event.getWorld().addFreshEntity(newEntity))); + BlockableEventLoop executor = LogicalSidedProvider.WORKQUEUE.get(event.getWorld().isClientSide ? LogicalSide.CLIENT : LogicalSide.SERVER); + executor.tell(new TickTask(0, () -> event.getWorld().addFreshEntity(newEntity))); } } } @@ -75,8 +73,8 @@ public class ForgeInternalHandler @SubscribeEvent(priority = EventPriority.HIGHEST) public void onDimensionUnload(WorldEvent.Unload event) { - if (event.getWorld() instanceof ServerWorld) - FakePlayerFactory.unloadWorld((ServerWorld) event.getWorld()); + if (event.getWorld() instanceof ServerLevel) + FakePlayerFactory.unloadWorld((ServerLevel) event.getWorld()); } @SubscribeEvent diff --git a/src/main/java/net/minecraftforge/common/ForgeMod.java b/src/main/java/net/minecraftforge/common/ForgeMod.java index 9006672ddc..71b5a46d13 100644 --- a/src/main/java/net/minecraftforge/common/ForgeMod.java +++ b/src/main/java/net/minecraftforge/common/ForgeMod.java @@ -19,17 +19,17 @@ package net.minecraftforge.common; -import net.minecraft.command.arguments.ArgumentSerializer; -import net.minecraft.command.arguments.ArgumentTypes; -import net.minecraft.command.arguments.IArgumentSerializer; -import net.minecraft.entity.ai.attributes.Attribute; -import net.minecraft.entity.ai.attributes.RangedAttribute; -import net.minecraft.fluid.Fluid; -import net.minecraft.item.Items; -import net.minecraft.util.SoundEvent; -import net.minecraft.util.registry.Registry; -import net.minecraft.world.storage.IServerConfiguration; -import net.minecraft.world.storage.SaveFormat; +import net.minecraft.commands.synchronization.EmptyArgumentSerializer; +import net.minecraft.commands.synchronization.ArgumentTypes; +import net.minecraft.commands.synchronization.ArgumentSerializer; +import net.minecraft.world.entity.ai.attributes.Attribute; +import net.minecraft.world.entity.ai.attributes.RangedAttribute; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.item.Items; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.core.Registry; +import net.minecraft.world.level.storage.WorldData; +import net.minecraft.world.level.storage.LevelStorageSource; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.ForgeHooksClient; import net.minecraftforge.common.data.ExistingFileHelper; @@ -43,10 +43,15 @@ import net.minecraftforge.fluids.ForgeFlowingFluid; import net.minecraftforge.fml.*; import net.minecraftforge.fml.config.ModConfig; import net.minecraftforge.fml.event.lifecycle.*; -import net.minecraftforge.fml.event.server.FMLServerStoppingEvent; +import net.minecraftforge.fmllegacy.FMLWorldPersistenceHook; +import net.minecraftforge.fmllegacy.RegistryObject; +import net.minecraftforge.fmllegacy.WorldPersistenceHooks; +import net.minecraftforge.fmllegacy.event.lifecycle.FMLModIdMappingEvent; +import net.minecraftforge.fmllegacy.network.FMLNetworkConstants; +import net.minecraftforge.fmlserverevents.FMLServerStoppingEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.fml.loading.FMLEnvironment; -import net.minecraftforge.fml.loading.progress.StartupMessageManager; +import net.minecraftforge.forge.event.lifecycle.GatherDataEvent; import net.minecraftforge.network.VanillaPacketSplitter; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.server.command.EnumArgument; @@ -55,15 +60,14 @@ import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.versions.forge.ForgeVersion; import net.minecraftforge.versions.mcp.MCPVersion; -import org.apache.commons.lang3.tuple.Pair; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import net.minecraft.data.DataGenerator; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.item.crafting.IRecipeSerializer; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.ResourceLocation; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeSerializer; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.common.crafting.CompoundIngredient; import net.minecraftforge.common.crafting.ConditionalRecipe; import net.minecraftforge.common.crafting.CraftingHelper; @@ -132,11 +136,16 @@ public class ForgeMod implements WorldPersistenceHooks.WorldPersistenceHook LOGGER.info(FORGEMOD,"Forge mod loading, version {}, for MC {} with MCP {}", ForgeVersion.getVersion(), MCPVersion.getMCVersion(), MCPVersion.getMCPVersion()); INSTANCE = this; MinecraftForge.initialize(); - CrashReportExtender.registerCrashCallable("Crash Report UUID", ()-> { + CrashReportCallables.registerCrashCallable("Crash Report UUID", ()-> { final UUID uuid = UUID.randomUUID(); LOGGER.fatal("Preparing crash report with UUID {}", uuid); return uuid.toString(); }); + + LOGGER.debug(FORGEMOD, "Loading Network data for FML net version: {}", FMLNetworkConstants.init()); + CrashReportCallables.registerCrashCallable("FML", ForgeVersion::getSpec); + CrashReportCallables.registerCrashCallable("Forge", ()->ForgeVersion.getGroup()+":"+ForgeVersion.getVersion()); + WorldPersistenceHooks.addHook(this); WorldPersistenceHooks.addHook(new FMLWorldPersistenceHook()); final IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); @@ -153,7 +162,7 @@ public class ForgeMod implements WorldPersistenceHooks.WorldPersistenceHook ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, ForgeConfig.commonSpec); modEventBus.register(ForgeConfig.class); // Forge does not display problems when the remote is not matching. - ModLoadingContext.get().registerExtensionPoint(ExtensionPoint.DISPLAYTEST, ()-> Pair.of(()->"ANY", (remote, isServer)-> true)); + ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class, ()->new IExtensionPoint.DisplayTest(()->"ANY", (remote, isServer)-> true)); StartupMessageManager.addModMessage("Forge version "+ForgeVersion.getVersion()); MinecraftForge.EVENT_BUS.addListener(VillagerTradingManager::loadTrades); @@ -178,8 +187,8 @@ public class ForgeMod implements WorldPersistenceHooks.WorldPersistenceHook @SuppressWarnings({"unchecked", "rawtypes"}) private void registerArgumentTypes() { - ArgumentTypes.register("forge:enum", EnumArgument.class, (IArgumentSerializer) new EnumArgument.Serializer()); - ArgumentTypes.register("forge:modid", ModIdArgument.class, new ArgumentSerializer<>(ModIdArgument::modIdArgument)); + ArgumentTypes.register("forge:enum", EnumArgument.class, (ArgumentSerializer) new EnumArgument.Serializer()); + ArgumentTypes.register("forge:modid", ModIdArgument.class, new EmptyArgumentSerializer<>(ModIdArgument::modIdArgument)); } public void loadComplete(FMLLoadCompleteEvent event) @@ -194,10 +203,10 @@ public class ForgeMod implements WorldPersistenceHooks.WorldPersistenceHook } @Override - public CompoundNBT getDataForWriting(SaveFormat.LevelSave levelSave, IServerConfiguration serverInfo) + public CompoundTag getDataForWriting(LevelStorageSource.LevelStorageAccess levelSave, WorldData serverInfo) { - CompoundNBT forgeData = new CompoundNBT(); - CompoundNBT dims = new CompoundNBT(); + CompoundTag forgeData = new CompoundTag(); + CompoundTag dims = new CompoundTag(); //TODO Dimensions // DimensionManager.writeRegistry(dims); if (!dims.isEmpty()) @@ -206,7 +215,7 @@ public class ForgeMod implements WorldPersistenceHooks.WorldPersistenceHook } @Override - public void readData(SaveFormat.LevelSave levelSave, IServerConfiguration serverInfo, CompoundNBT tag) + public void readData(LevelStorageSource.LevelStorageAccess levelSave, WorldData serverInfo, CompoundTag tag) { //TODO Dimensions // if (tag.contains("dims", 10)) @@ -274,7 +283,7 @@ public class ForgeMod implements WorldPersistenceHooks.WorldPersistenceHook } @SubscribeEvent //ModBus, can't use addListener due to nested genetics. - public void registerRecipeSerialziers(RegistryEvent.Register> event) + public void registerRecipeSerialziers(RegistryEvent.Register> event) { CraftingHelper.register(AndCondition.Serializer.INSTANCE); CraftingHelper.register(FalseCondition.Serializer.INSTANCE); @@ -289,7 +298,7 @@ public class ForgeMod implements WorldPersistenceHooks.WorldPersistenceHook CraftingHelper.register(new ResourceLocation("forge", "nbt"), NBTIngredient.Serializer.INSTANCE); CraftingHelper.register(new ResourceLocation("minecraft", "item"), VanillaIngredientSerializer.INSTANCE); - event.getRegistry().register(new ConditionalRecipe.Serializer>().setRegistryName(new ResourceLocation("forge", "conditional"))); + event.getRegistry().register(new ConditionalRecipe.Serializer>().setRegistryName(new ResourceLocation("forge", "conditional"))); } diff --git a/src/main/java/net/minecraftforge/common/ForgeTagHandler.java b/src/main/java/net/minecraftforge/common/ForgeTagHandler.java index 11b7c3b240..a385513ee6 100644 --- a/src/main/java/net/minecraftforge/common/ForgeTagHandler.java +++ b/src/main/java/net/minecraftforge/common/ForgeTagHandler.java @@ -33,21 +33,18 @@ import java.util.concurrent.Executor; import java.util.function.Supplier; import java.util.stream.Collectors; import javax.annotation.Nullable; -import net.minecraft.block.Block; -import net.minecraft.entity.EntityType; -import net.minecraft.fluid.Fluid; -import net.minecraft.item.Item; -import net.minecraft.resources.IResourceManager; -import net.minecraft.tags.ITag; -import net.minecraft.tags.ITag.INamedTag; -import net.minecraft.tags.ITagCollection; -import net.minecraft.tags.ITagCollectionSupplier; -import net.minecraft.tags.TagCollectionReader; -import net.minecraft.tags.TagRegistry; -import net.minecraft.tags.TagRegistryManager; -import net.minecraft.util.ResourceLocation; +import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.tags.Tag; +import net.minecraft.tags.Tag.Named; +import net.minecraft.tags.TagCollection; +import net.minecraft.tags.TagContainer; +import net.minecraft.tags.TagLoader; +import net.minecraft.tags.StaticTagHelper; +import net.minecraft.tags.StaticTags; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.common.Tags.IOptionalNamedTag; -import net.minecraftforge.fml.network.FMLPlayMessages.SyncCustomTagTypes; +import net.minecraftforge.common.extensions.IForgeTagContainer; +import net.minecraftforge.fmllegacy.network.FMLPlayMessages.SyncCustomTagTypes; import net.minecraftforge.registries.ForgeRegistry; import net.minecraftforge.registries.IForgeRegistry; import net.minecraftforge.registries.IForgeRegistryEntry; @@ -58,14 +55,14 @@ import org.apache.logging.log4j.Logger; public class ForgeTagHandler { private static final Logger LOGGER = LogManager.getLogger(); - private static Map> customTagTypes = Collections.emptyMap(); + private static Map> customTagTypes = Collections.emptyMap(); private static Set customTagTypeNames = Collections.emptySet(); private static boolean tagTypesSet = false; @Nullable - private static > TagRegistry getTagRegistry(IForgeRegistry registry) + private static > StaticTagHelper getTagRegistry(IForgeRegistry registry) { - return (TagRegistry) TagRegistryManager.get(registry.getRegistryName()); + return (StaticTagHelper) StaticTags.get(registry.getRegistryName()); } private static void validateRegistrySupportsTags(IForgeRegistry registry) @@ -86,16 +83,16 @@ public class ForgeTagHandler * @param Type of the registry * @return A named tag */ - public static > ITag.INamedTag makeWrapperTag(IForgeRegistry registry, ResourceLocation name) + public static > Named makeWrapperTag(IForgeRegistry registry, ResourceLocation name) { validateRegistrySupportsTags(registry); if (tagTypesSet) { - TagRegistry tagRegistry = getTagRegistry(registry); + StaticTagHelper tagRegistry = getTagRegistry(registry); if (tagRegistry == null) throw new IllegalArgumentException("Registry " + registry.getRegistryName() + " does not support tag types."); return tagRegistry.bind(name.toString()); } - return TagRegistry.createDelayedTag(registry.getRegistryName(), name); + return StaticTagHelper.createDelayedTag(registry.getRegistryName(), name); } /** @@ -127,11 +124,11 @@ public class ForgeTagHandler validateRegistrySupportsTags(registry); if (tagTypesSet) { - TagRegistry tagRegistry = getTagRegistry(registry); + StaticTagHelper tagRegistry = getTagRegistry(registry); if (tagRegistry == null) throw new IllegalArgumentException("Registry " + registry.getRegistryName() + " does not support tag types."); return tagRegistry.createOptional(name, defaults); } - return TagRegistry.createDelayedOptional(registry.getRegistryName(), name, defaults); + return StaticTagHelper.createDelayedOptional(registry.getRegistryName(), name, defaults); } /** @@ -144,7 +141,7 @@ public class ForgeTagHandler * @implNote This method only errors instantly if tag types have already been set, otherwise the error is delayed until after registries finish initializing * and we can validate if the custom registry really does support custom tags. */ - public static > ITag.INamedTag makeWrapperTag(ResourceLocation registryName, ResourceLocation name) + public static > Named makeWrapperTag(ResourceLocation registryName, ResourceLocation name) { if (tagTypesSet) { @@ -152,7 +149,7 @@ public class ForgeTagHandler if (registry == null) throw new IllegalArgumentException("Could not find registry named: " + registryName); return makeWrapperTag(registry, name); } - return TagRegistry.createDelayedTag(registryName, name); + return StaticTagHelper.createDelayedTag(registryName, name); } /** @@ -189,7 +186,7 @@ public class ForgeTagHandler if (registry == null) throw new IllegalArgumentException("Could not find registry named: " + registryName); return createOptionalTag(registry, name, defaults); } - return TagRegistry.createDelayedOptional(registryName, name, defaults); + return StaticTagHelper.createDelayedOptional(registryName, name, defaults); } /** @@ -203,9 +200,9 @@ public class ForgeTagHandler /** * Gets a map of registry name to tag collection for all custom tag types. * - * @apiNote Prefer interacting with this via the current {@link ITagCollectionSupplier} and using one of the forge extension getCustomTypeCollection methods + * @apiNote Prefer interacting with this via the current {@link IForgeTagContainer} and using one of the forge extension getCustomTypeCollection methods */ - public static Map> getCustomTagTypes() + public static Map> getCustomTagTypes() { return customTagTypes; } @@ -225,7 +222,7 @@ public class ForgeTagHandler // Note: If this ends up being a hotspot due to lots of mods having lots of statically registered tags // that get loaded/registered before the new registry event is fired/processed everywhere then this // potentially should end up being moved into an async processor. - TagRegistry.performDelayedAdd(); + StaticTagHelper.performDelayedAdd(); } /** @@ -233,16 +230,16 @@ public class ForgeTagHandler * * @apiNote Internal: For use by NetworkTagManager */ - public static Map> createCustomTagTypeReaders() + public static Map> createCustomTagTypeReaders() { LOGGER.debug("Gathering custom tag collection reader from types."); - ImmutableMap.Builder> builder = ImmutableMap.builder(); + ImmutableMap.Builder> builder = ImmutableMap.builder(); for (ResourceLocation registryName : customTagTypeNames) { ForgeRegistry registry = RegistryManager.ACTIVE.getRegistry(registryName); if (registry != null && registry.getTagFolder() != null) { - builder.put(registryName, new TagCollectionReader<>(rl -> Optional.ofNullable(registry.getValue(rl)), "tags/" + registry.getTagFolder(), registryName.getPath())); + builder.put(registryName, new TagLoader<>(rl -> Optional.ofNullable(registry.getValue(rl)), "tags/" + registry.getTagFolder())); } } return builder.build(); @@ -255,22 +252,22 @@ public class ForgeTagHandler */ public static void resetCachedTagCollections(boolean makeEmpty, boolean withOptional) { - ImmutableMap.Builder> builder = ImmutableMap.builder(); + ImmutableMap.Builder> builder = ImmutableMap.builder(); for (ResourceLocation registryName : customTagTypeNames) { - TagRegistry tagRegistry = TagRegistryManager.get(registryName); + StaticTagHelper tagRegistry = StaticTags.get(registryName); if (tagRegistry != null) { if (makeEmpty) { if (withOptional) - builder.put(registryName, tagRegistry.reinjectOptionalTags(ITagCollection.of(Collections.emptyMap()))); + builder.put(registryName, tagRegistry.reinjectOptionalTags(TagCollection.of(Collections.emptyMap()))); else - builder.put(registryName, ITagCollection.of(Collections.emptyMap())); + builder.put(registryName, TagCollection.of(Collections.emptyMap())); } else { - builder.put(registryName, ITagCollection.of(tagRegistry.getWrappers().stream().distinct().collect(Collectors.toMap(INamedTag::getName, namedTag -> namedTag)))); + builder.put(registryName, TagCollection.of(tagRegistry.getWrappers().stream().distinct().collect(Collectors.toMap(Named::getName, namedTag -> namedTag)))); } } } @@ -282,7 +279,7 @@ public class ForgeTagHandler * * @apiNote Internal: For use by TagCollectionManager */ - public static ITagCollectionSupplier populateTagCollectionManager(ITagCollection blockTags, ITagCollection itemTags, ITagCollection fluidTags, ITagCollection> entityTypeTags) + public static void populateTagCollectionManager() { //Default the tag collections resetCachedTagCollections(false, false); @@ -290,7 +287,6 @@ public class ForgeTagHandler { LOGGER.debug("Populated the TagCollectionManager with {} extra types", customTagTypes.size()); } - return ITagCollectionSupplier.of(blockTags, itemTags, fluidTags, entityTypeTags); } /** @@ -300,10 +296,10 @@ public class ForgeTagHandler */ public static void updateCustomTagTypes(List tagCollectionReaders) { - ImmutableMap.Builder> builder = ImmutableMap.builder(); + ImmutableMap.Builder> builder = ImmutableMap.builder(); for (TagCollectionReaderInfo info : tagCollectionReaders) { - builder.put(info.tagType, info.reader.load(info.tagBuilders)); + builder.put(info.tagType, info.reader.build(info.tagBuilders)); } customTagTypes = builder.build(); } @@ -324,12 +320,14 @@ public class ForgeTagHandler * * @apiNote Internal: For use by NetworkTagManager */ - public static CompletableFuture> getCustomTagTypeReloadResults(IResourceManager resourceManager, Executor backgroundExecutor, Map> readers) + public static CompletableFuture> getCustomTagTypeReloadResults(ResourceManager resourceManager, Executor backgroundExecutor, Map> readers) { CompletableFuture> customResults = CompletableFuture.completedFuture(new ArrayList<>()); - for (Map.Entry> entry : readers.entrySet()) + for (Entry> entry : readers.entrySet()) { - customResults = customResults.thenCombine(entry.getValue().prepare(resourceManager, backgroundExecutor), (results, result) -> { + CompletableFuture> collectionFuture = + CompletableFuture.supplyAsync(() -> entry.getValue().load(resourceManager), backgroundExecutor); + customResults = customResults.thenCombine(collectionFuture, (results, result) -> { results.add(new TagCollectionReaderInfo(entry.getKey(), entry.getValue(), result)); return results; }); @@ -344,71 +342,47 @@ public class ForgeTagHandler */ public static void reinjectOptionalTagsCustomTypes() { - ImmutableMap.Builder> builder = ImmutableMap.builder(); - for (Entry> entry : customTagTypes.entrySet()) + ImmutableMap.Builder> builder = ImmutableMap.builder(); + for (Entry> entry : customTagTypes.entrySet()) { ResourceLocation registry = entry.getKey(); - TagRegistry tagRegistry = TagRegistryManager.get(registry); - ITagCollection tagCollection = entry.getValue(); - builder.put(registry, tagRegistry == null ? tagCollection : tagRegistry.reinjectOptionalTags((ITagCollection) tagCollection)); + StaticTagHelper tagRegistry = StaticTags.get(registry); + TagCollection tagCollection = entry.getValue(); + builder.put(registry, tagRegistry == null ? tagCollection : tagRegistry.reinjectOptionalTags((TagCollection) tagCollection)); } customTagTypes = builder.build(); } /** - * Gets an {@link ITagCollectionSupplier} with empty custom tag type collections to allow for checking if the client is requiring any tags of custom tag types. + * Gets an {@link IForgeTagContainer} with empty custom tag type collections to allow for checking if the client is requiring any tags of custom tag types. * * @apiNote Internal: For use with validating missing tags when connecting to a vanilla server */ - public static ITagCollectionSupplier withNoCustom(ITagCollectionSupplier tagCollectionSupplier) + public static TagContainer withNoCustom(TagContainer tagCollectionSupplier) { - ImmutableMap.Builder> builder = ImmutableMap.builder(); + ImmutableMap.Builder> builder = ImmutableMap.builder(); for (ResourceLocation registryName : customTagTypeNames) { - TagRegistry tagRegistry = TagRegistryManager.get(registryName); + StaticTagHelper tagRegistry = StaticTags.get(registryName); if (tagRegistry != null) { - builder.put(registryName, ITagCollection.of(Collections.emptyMap())); + builder.put(registryName, TagCollection.of(Collections.emptyMap())); } } return withSpecificCustom(tagCollectionSupplier, builder.build()); } /** - * Gets an {@link ITagCollectionSupplier} with specific custom tag types for testing if any tags are missing. + * Gets an {@link IForgeTagContainer} with specific custom tag types for testing if any tags are missing. * * @apiNote Internal */ - public static ITagCollectionSupplier withSpecificCustom(ITagCollectionSupplier tagCollectionSupplier, Map> customTagTypes) + public static TagContainer withSpecificCustom(TagContainer tagCollectionSupplier, Map> customTagTypes) { - return new ITagCollectionSupplier() + return new TagContainer(tagCollectionSupplier.collections) { @Override - public ITagCollection getBlocks() - { - return tagCollectionSupplier.getBlocks(); - } - - @Override - public ITagCollection getItems() - { - return tagCollectionSupplier.getItems(); - } - - @Override - public ITagCollection getFluids() - { - return tagCollectionSupplier.getFluids(); - } - - @Override - public ITagCollection> getEntityTypes() - { - return tagCollectionSupplier.getEntityTypes(); - } - - @Override - public Map> getCustomTagTypes() + public Map> getCustomTagTypes() { return customTagTypes; } @@ -424,10 +398,10 @@ public class ForgeTagHandler { private final ResourceLocation tagType; - private final TagCollectionReader reader; - private final Map tagBuilders; + private final TagLoader reader; + private final Map tagBuilders; - private TagCollectionReaderInfo(ResourceLocation tagType, TagCollectionReader reader, Map tagBuilders) + private TagCollectionReaderInfo(ResourceLocation tagType, TagLoader reader, Map tagBuilders) { this.tagType = tagType; this.reader = reader; diff --git a/src/main/java/net/minecraftforge/common/IExtensibleEnum.java b/src/main/java/net/minecraftforge/common/IExtensibleEnum.java index 0464f77d49..cd4d5e4b98 100644 --- a/src/main/java/net/minecraftforge/common/IExtensibleEnum.java +++ b/src/main/java/net/minecraftforge/common/IExtensibleEnum.java @@ -20,7 +20,7 @@ package net.minecraftforge.common; import com.mojang.serialization.Codec; -import net.minecraft.util.IStringSerializable; +import net.minecraft.util.StringRepresentable; import java.util.function.Function; import java.util.function.Supplier; @@ -57,7 +57,7 @@ public interface IExtensibleEnum /** * Use this instead of {@link IStringSerializable#createEnumCodec(Supplier, Function)} for extensible enums because this not cache the enum values on construction */ - static & IStringSerializable> Codec createCodecForExtensibleEnum(Supplier valuesSupplier, Function enumValueFromNameFunction) { - return IStringSerializable.fromStringResolver(Enum::ordinal, (id) -> valuesSupplier.get()[id], enumValueFromNameFunction); + static & StringRepresentable> Codec createCodecForExtensibleEnum(Supplier valuesSupplier, Function enumValueFromNameFunction) { + return StringRepresentable.fromStringResolver(Enum::ordinal, (id) -> valuesSupplier.get()[id], enumValueFromNameFunction); } } diff --git a/src/main/java/net/minecraftforge/common/IForgeShearable.java b/src/main/java/net/minecraftforge/common/IForgeShearable.java index 8974b4c6e5..49444601ab 100644 --- a/src/main/java/net/minecraftforge/common/IForgeShearable.java +++ b/src/main/java/net/minecraftforge/common/IForgeShearable.java @@ -22,10 +22,10 @@ package net.minecraftforge.common; import java.util.Collections; import java.util.List; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -49,7 +49,7 @@ public interface IForgeShearable * @param pos Block's position in world. * @return If this is shearable, and onSheared should be called. */ - default boolean isShearable(@Nonnull ItemStack item, World world, BlockPos pos) + default boolean isShearable(@Nonnull ItemStack item, Level world, BlockPos pos) { return true; } @@ -73,7 +73,7 @@ public interface IForgeShearable * @return A List containing all items from this shearing. May be empty. */ @Nonnull - default List onSheared(@Nullable PlayerEntity player, @Nonnull ItemStack item, World world, BlockPos pos, int fortune) + default List onSheared(@Nullable Player player, @Nonnull ItemStack item, Level world, BlockPos pos, int fortune) { return Collections.emptyList(); } diff --git a/src/main/java/net/minecraftforge/common/IMinecartCollisionHandler.java b/src/main/java/net/minecraftforge/common/IMinecartCollisionHandler.java index b766bf6352..6bb04ba66a 100644 --- a/src/main/java/net/minecraftforge/common/IMinecartCollisionHandler.java +++ b/src/main/java/net/minecraftforge/common/IMinecartCollisionHandler.java @@ -19,9 +19,9 @@ package net.minecraftforge.common; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.minecart.AbstractMinecartEntity; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.vehicle.AbstractMinecart; /** * This class defines a replacement for the default minecart collision code. @@ -38,7 +38,7 @@ public interface IMinecartCollisionHandler * @param cart The cart that called the collision. * @param other The object it collided with. */ - void onEntityCollision(AbstractMinecartEntity cart, Entity other); + void onEntityCollision(AbstractMinecart cart, Entity other); /** * This function replaced the function of the same name in EntityMinecart. @@ -48,7 +48,7 @@ public interface IMinecartCollisionHandler * @param other The entity requesting the collision box. * @return The collision box or null. */ - AxisAlignedBB getCollisionBox(AbstractMinecartEntity cart, Entity other); + AABB getCollisionBox(AbstractMinecart cart, Entity other); /** * This function is used to define the box used for detecting minecart collisions. @@ -56,7 +56,7 @@ public interface IMinecartCollisionHandler * @param cart The cart for which the collision box was requested. * @return The collision box, cannot be null. */ - AxisAlignedBB getMinecartCollisionBox(AbstractMinecartEntity cart); + AABB getMinecartCollisionBox(AbstractMinecart cart); /** * This function replaces the function of the same name in EntityMinecart. @@ -64,6 +64,6 @@ public interface IMinecartCollisionHandler * @param cart The cart for which the bounding box was requested. * @return The bounding box or null. */ - AxisAlignedBB getBoundingBox(AbstractMinecartEntity cart); + AABB getBoundingBox(AbstractMinecart cart); } diff --git a/src/main/java/net/minecraftforge/common/IPlantable.java b/src/main/java/net/minecraftforge/common/IPlantable.java index 2f8734ef82..8329ea266b 100644 --- a/src/main/java/net/minecraftforge/common/IPlantable.java +++ b/src/main/java/net/minecraftforge/common/IPlantable.java @@ -19,18 +19,18 @@ package net.minecraftforge.common; -import net.minecraft.block.CropsBlock; -import net.minecraft.block.FlowerBlock; -import net.minecraft.block.SaplingBlock; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; +import net.minecraft.world.level.block.CropBlock; +import net.minecraft.world.level.block.FlowerBlock; +import net.minecraft.world.level.block.SaplingBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; public interface IPlantable { - default PlantType getPlantType(IBlockReader world, BlockPos pos) { - if (this instanceof CropsBlock) return PlantType.CROP; + default PlantType getPlantType(BlockGetter world, BlockPos pos) { + if (this instanceof CropBlock) return PlantType.CROP; if (this instanceof SaplingBlock) return PlantType.PLAINS; if (this instanceof FlowerBlock) return PlantType.PLAINS; if (this == Blocks.DEAD_BUSH) return PlantType.DESERT; @@ -42,5 +42,5 @@ public interface IPlantable return net.minecraftforge.common.PlantType.PLAINS; } - BlockState getPlant(IBlockReader world, BlockPos pos); + BlockState getPlant(BlockGetter world, BlockPos pos); } diff --git a/src/main/java/net/minecraftforge/common/MinecraftForge.java b/src/main/java/net/minecraftforge/common/MinecraftForge.java index f60d15ec4f..3fcd81ac9f 100644 --- a/src/main/java/net/minecraftforge/common/MinecraftForge.java +++ b/src/main/java/net/minecraftforge/common/MinecraftForge.java @@ -21,7 +21,6 @@ package net.minecraftforge.common; import net.minecraftforge.eventbus.api.BusBuilder; import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraft.crash.CrashReport; import net.minecraftforge.versions.forge.ForgeVersion; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; diff --git a/src/main/java/net/minecraftforge/common/PlantType.java b/src/main/java/net/minecraftforge/common/PlantType.java index d13da6ea49..49d513ac75 100644 --- a/src/main/java/net/minecraftforge/common/PlantType.java +++ b/src/main/java/net/minecraftforge/common/PlantType.java @@ -19,11 +19,6 @@ package net.minecraftforge.common; -import net.minecraft.block.BlockState; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; - import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.regex.Pattern; diff --git a/src/main/java/net/minecraftforge/common/Tags.java b/src/main/java/net/minecraftforge/common/Tags.java index 2dfadbe1bf..5923a5fdbc 100644 --- a/src/main/java/net/minecraftforge/common/Tags.java +++ b/src/main/java/net/minecraftforge/common/Tags.java @@ -19,15 +19,15 @@ package net.minecraftforge.common; -import net.minecraft.block.Block; -import net.minecraft.fluid.Fluid; -import net.minecraft.item.DyeColor; -import net.minecraft.item.Item; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.item.Item; import net.minecraft.tags.BlockTags; import net.minecraft.tags.FluidTags; import net.minecraft.tags.ItemTags; -import net.minecraft.util.ResourceLocation; -import net.minecraft.tags.ITag.INamedTag; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.Tag.Named; public class Tags { @@ -307,7 +307,7 @@ public class Tags } } - public interface IOptionalNamedTag extends INamedTag + public interface IOptionalNamedTag extends Named { /** * Returns true if the current state is defaulted. This means we have connected to a server that does not contain this tag. diff --git a/src/main/java/net/minecraftforge/common/VillagerTradingManager.java b/src/main/java/net/minecraftforge/common/VillagerTradingManager.java index e7c0998287..839f163c3b 100644 --- a/src/main/java/net/minecraftforge/common/VillagerTradingManager.java +++ b/src/main/java/net/minecraftforge/common/VillagerTradingManager.java @@ -26,26 +26,26 @@ import java.util.Map; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; -import net.minecraft.entity.merchant.villager.VillagerProfession; -import net.minecraft.entity.merchant.villager.VillagerTrades; -import net.minecraft.entity.merchant.villager.VillagerTrades.ITrade; -import net.minecraft.util.NonNullList; +import net.minecraft.world.entity.npc.VillagerProfession; +import net.minecraft.world.entity.npc.VillagerTrades; +import net.minecraft.world.entity.npc.VillagerTrades.ItemListing; +import net.minecraft.core.NonNullList; import net.minecraftforge.event.village.VillagerTradesEvent; import net.minecraftforge.event.village.WandererTradesEvent; -import net.minecraftforge.fml.event.server.FMLServerAboutToStartEvent; +import net.minecraftforge.fmlserverevents.FMLServerAboutToStartEvent; import net.minecraftforge.registries.ForgeRegistries; public class VillagerTradingManager { - private static final Map> VANILLA_TRADES = new HashMap<>(); - private static final Int2ObjectMap WANDERER_TRADES = new Int2ObjectOpenHashMap<>(); + private static final Map> VANILLA_TRADES = new HashMap<>(); + private static final Int2ObjectMap WANDERER_TRADES = new Int2ObjectOpenHashMap<>(); static { VillagerTrades.TRADES.entrySet().forEach(e -> { - Int2ObjectMap copy = new Int2ObjectOpenHashMap<>(); + Int2ObjectMap copy = new Int2ObjectOpenHashMap<>(); e.getValue().int2ObjectEntrySet().forEach(ent -> copy.put(ent.getIntKey(), Arrays.copyOf(ent.getValue(), ent.getValue().length))); VANILLA_TRADES.put(e.getKey(), copy); }); @@ -63,13 +63,13 @@ public class VillagerTradingManager */ private static void postWandererEvent() { - List generic = NonNullList.create(); - List rare = NonNullList.create(); + List generic = NonNullList.create(); + List rare = NonNullList.create(); Arrays.stream(WANDERER_TRADES.get(1)).forEach(generic::add); Arrays.stream(WANDERER_TRADES.get(2)).forEach(rare::add); MinecraftForge.EVENT_BUS.post(new WandererTradesEvent(generic, rare)); - VillagerTrades.WANDERING_TRADER_TRADES.put(1, generic.toArray(new ITrade[0])); - VillagerTrades.WANDERING_TRADER_TRADES.put(2, rare.toArray(new ITrade[0])); + VillagerTrades.WANDERING_TRADER_TRADES.put(1, generic.toArray(new ItemListing[0])); + VillagerTrades.WANDERING_TRADER_TRADES.put(2, rare.toArray(new ItemListing[0])); } /** @@ -79,8 +79,8 @@ public class VillagerTradingManager { for (VillagerProfession prof : ForgeRegistries.PROFESSIONS) { - Int2ObjectMap trades = VANILLA_TRADES.getOrDefault(prof, new Int2ObjectOpenHashMap<>()); - Int2ObjectMap> mutableTrades = new Int2ObjectOpenHashMap<>(); + Int2ObjectMap trades = VANILLA_TRADES.getOrDefault(prof, new Int2ObjectOpenHashMap<>()); + Int2ObjectMap> mutableTrades = new Int2ObjectOpenHashMap<>(); for (int i = 1; i < 6; i++) { mutableTrades.put(i, NonNullList.create()); @@ -90,8 +90,8 @@ public class VillagerTradingManager Arrays.stream(e.getValue()).forEach(mutableTrades.get(e.getIntKey())::add); }); MinecraftForge.EVENT_BUS.post(new VillagerTradesEvent(mutableTrades, prof)); - Int2ObjectMap newTrades = new Int2ObjectOpenHashMap<>(); - mutableTrades.int2ObjectEntrySet().forEach(e -> newTrades.put(e.getIntKey(), e.getValue().toArray(new ITrade[0]))); + Int2ObjectMap newTrades = new Int2ObjectOpenHashMap<>(); + mutableTrades.int2ObjectEntrySet().forEach(e -> newTrades.put(e.getIntKey(), e.getValue().toArray(new ItemListing[0]))); VillagerTrades.TRADES.put(prof, newTrades); } } diff --git a/src/main/java/net/minecraftforge/common/animation/Event.java b/src/main/java/net/minecraftforge/common/animation/Event.java index 2fd8d9959b..a587327426 100644 --- a/src/main/java/net/minecraftforge/common/animation/Event.java +++ b/src/main/java/net/minecraftforge/common/animation/Event.java @@ -55,7 +55,7 @@ public final class Event implements Comparable @Override public int compareTo(Event event) { - return new Float(offset).compareTo(event.offset); + return Float.compare(offset, event.offset); } @Override diff --git a/src/main/java/net/minecraftforge/common/animation/TimeValues.java b/src/main/java/net/minecraftforge/common/animation/TimeValues.java index 43cc060fae..fe240e91ae 100644 --- a/src/main/java/net/minecraftforge/common/animation/TimeValues.java +++ b/src/main/java/net/minecraftforge/common/animation/TimeValues.java @@ -22,7 +22,7 @@ package net.minecraftforge.common.animation; import java.io.IOException; import java.util.regex.Pattern; -import net.minecraft.util.IStringSerializable; +import net.minecraft.util.StringRepresentable; import java.util.function.Function; import com.google.common.base.Objects; @@ -41,7 +41,7 @@ import javax.annotation.Nullable; */ public final class TimeValues { - public static enum IdentityValue implements ITimeValue, IStringSerializable + public static enum IdentityValue implements ITimeValue, StringRepresentable { INSTANCE; @@ -231,7 +231,7 @@ public final class TimeValues } } - public static final class ParameterValue implements ITimeValue, IStringSerializable + public static final class ParameterValue implements ITimeValue, StringRepresentable { private final String parameterName; private final Function valueResolver; @@ -344,9 +344,9 @@ public final class TimeValues write(out, p.f); out.endArray(); } - else if(parameter instanceof IStringSerializable) + else if(parameter instanceof StringRepresentable) { - out.value("#" + ((IStringSerializable)parameter).getSerializedName()); + out.value("#" + ((StringRepresentable)parameter).getSerializedName()); } } diff --git a/src/main/java/net/minecraftforge/common/brewing/BrewingRecipe.java b/src/main/java/net/minecraftforge/common/brewing/BrewingRecipe.java index 20ead9a87a..f87c3ec099 100644 --- a/src/main/java/net/minecraftforge/common/brewing/BrewingRecipe.java +++ b/src/main/java/net/minecraftforge/common/brewing/BrewingRecipe.java @@ -19,8 +19,8 @@ package net.minecraftforge.common.brewing; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Ingredient; import javax.annotation.Nonnull; diff --git a/src/main/java/net/minecraftforge/common/brewing/BrewingRecipeRegistry.java b/src/main/java/net/minecraftforge/common/brewing/BrewingRecipeRegistry.java index afde7f8214..f9b84b8caa 100644 --- a/src/main/java/net/minecraftforge/common/brewing/BrewingRecipeRegistry.java +++ b/src/main/java/net/minecraftforge/common/brewing/BrewingRecipeRegistry.java @@ -22,9 +22,9 @@ package net.minecraftforge.common.brewing; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.util.NonNullList; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.core.NonNullList; public class BrewingRecipeRegistry { diff --git a/src/main/java/net/minecraftforge/common/brewing/IBrewingRecipe.java b/src/main/java/net/minecraftforge/common/brewing/IBrewingRecipe.java index cb4928ac92..7ec78694ab 100644 --- a/src/main/java/net/minecraftforge/common/brewing/IBrewingRecipe.java +++ b/src/main/java/net/minecraftforge/common/brewing/IBrewingRecipe.java @@ -19,7 +19,7 @@ package net.minecraftforge.common.brewing; -import net.minecraft.item.ItemStack; +import net.minecraft.world.item.ItemStack; public interface IBrewingRecipe { diff --git a/src/main/java/net/minecraftforge/common/brewing/VanillaBrewingRecipe.java b/src/main/java/net/minecraftforge/common/brewing/VanillaBrewingRecipe.java index e486da09f8..d1f3df3ef7 100644 --- a/src/main/java/net/minecraftforge/common/brewing/VanillaBrewingRecipe.java +++ b/src/main/java/net/minecraftforge/common/brewing/VanillaBrewingRecipe.java @@ -19,10 +19,10 @@ package net.minecraftforge.common.brewing; -import net.minecraft.item.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.potion.PotionBrewing; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.alchemy.PotionBrewing; /** * Used in BrewingRecipeRegistry to maintain the vanilla behaviour. diff --git a/src/main/java/net/minecraftforge/common/brewing/package-info.java b/src/main/java/net/minecraftforge/common/brewing/package-info.java index f770b92f4d..c287cbca31 100644 --- a/src/main/java/net/minecraftforge/common/brewing/package-info.java +++ b/src/main/java/net/minecraftforge/common/brewing/package-info.java @@ -21,5 +21,6 @@ @MethodsReturnNonnullByDefault package net.minecraftforge.common.brewing; -import mcp.MethodsReturnNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; + import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/java/net/minecraftforge/common/capabilities/Capability.java b/src/main/java/net/minecraftforge/common/capabilities/Capability.java index 76da13af5a..6caa3765bd 100644 --- a/src/main/java/net/minecraftforge/common/capabilities/Capability.java +++ b/src/main/java/net/minecraftforge/common/capabilities/Capability.java @@ -19,16 +19,9 @@ package net.minecraftforge.common.capabilities; -import java.util.concurrent.Callable; - -import com.google.common.base.Throwables; - -import net.minecraft.nbt.INBT; -import net.minecraft.util.Direction; import net.minecraftforge.common.util.LazyOptional; import javax.annotation.Nonnull; -import javax.annotation.Nullable; /** * This is the core holder object Capabilities. @@ -39,104 +32,12 @@ import javax.annotation.Nullable; */ public class Capability { - public static interface IStorage - { - /** - * Serialize the capability instance to a NBTTag. - * This allows for a central implementation of saving the data. - * - * It is important to note that it is up to the API defining - * the capability what requirements the 'instance' value must have. - * - * Due to the possibility of manipulating internal data, some - * implementations MAY require that the 'instance' be an instance - * of the 'default' implementation. - * - * Review the API docs for more info. - * - * @param capability The Capability being stored. - * @param instance An instance of that capabilities interface. - * @param side The side of the object the instance is associated with. - * @return a NBT holding the data. Null if no data needs to be stored. - */ - @Nullable - INBT writeNBT(Capability capability, T instance, Direction side); - - /** - * Read the capability instance from a NBT tag. - * - * This allows for a central implementation of saving the data. - * - * It is important to note that it is up to the API defining - * the capability what requirements the 'instance' value must have. - * - * Due to the possibility of manipulating internal data, some - * implementations MAY require that the 'instance' be an instance - * of the 'default' implementation. - * - * Review the API docs for more info. * - * - * @param capability The Capability being stored. - * @param instance An instance of that capabilities interface. - * @param side The side of the object the instance is associated with. - * @param nbt A NBT holding the data. Must not be null, as doesn't make sense to call this function with nothing to read... - */ - void readNBT(Capability capability, T instance, Direction side, INBT nbt); - } - /** * @return The unique name of this capability, typically this is * the fully qualified class name for the target interface. */ public String getName() { return name; } - /** - * @return An instance of the default storage handler. You can safely use this store your default implementation in NBT. - */ - public IStorage getStorage() { return storage; } - - /** - * Quick access to the IStorage's readNBT. - * See {@link IStorage#readNBT(Capability, Object, EnumFacing, NBTBase)} for documentation. - */ - public void readNBT(T instance, Direction side, INBT nbt) - { - storage.readNBT(this, instance, side, nbt); - } - - /** - * Quick access to the IStorage's writeNBT. - * See {@link IStorage#writeNBT(Capability, Object, EnumFacing)} for documentation. - */ - @Nullable - public INBT writeNBT(T instance, Direction side) - { - return storage.writeNBT(this, instance, side); - } - - /** - * A NEW instance of the default implementation. - * - * If it important to note that if you want to use the default storage - * you may be required to use this exact implementation. - * Refer to the owning API of the Capability in question. - * - * @return A NEW instance of the default implementation. - */ - @Nullable - public T getDefaultInstance() - { - try - { - return this.factory.call(); - } - catch (Exception e) - { - Throwables.throwIfUnchecked(e); - throw new RuntimeException(e); - } - } - public @Nonnull LazyOptional orEmpty(Capability toCheck, LazyOptional inst) { return this == toCheck ? inst.cast() : LazyOptional.empty(); @@ -144,13 +45,9 @@ public class Capability // INTERNAL private final String name; - private final IStorage storage; - private final Callable factory; - Capability(String name, IStorage storage, Callable factory) + Capability(String name) { this.name = name; - this.storage = storage; - this.factory = factory; } } diff --git a/src/main/java/net/minecraftforge/common/capabilities/CapabilityDispatcher.java b/src/main/java/net/minecraftforge/common/capabilities/CapabilityDispatcher.java index bb9f244934..307e1f260b 100644 --- a/src/main/java/net/minecraftforge/common/capabilities/CapabilityDispatcher.java +++ b/src/main/java/net/minecraftforge/common/capabilities/CapabilityDispatcher.java @@ -27,11 +27,11 @@ import java.util.Map; import com.google.common.collect.Lists; -import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.nbt.INBT; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.Direction; -import net.minecraft.util.ResourceLocation; +import net.minecraft.MethodsReturnNonnullByDefault; +import net.minecraft.nbt.Tag; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.core.Direction; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.common.util.INBTSerializable; import net.minecraftforge.common.util.LazyOptional; @@ -47,10 +47,10 @@ import net.minecraftforge.common.util.LazyOptional; */ @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault -public final class CapabilityDispatcher implements INBTSerializable, ICapabilityProvider +public final class CapabilityDispatcher implements INBTSerializable, ICapabilityProvider { private ICapabilityProvider[] caps; - private INBTSerializable[] writers; + private INBTSerializable[] writers; private String[] names; private final List listeners; @@ -63,7 +63,7 @@ public final class CapabilityDispatcher implements INBTSerializable public CapabilityDispatcher(Map list, List listeners, @Nullable ICapabilityProvider parent) { List lstCaps = Lists.newArrayList(); - List> lstWriters = Lists.newArrayList(); + List> lstWriters = Lists.newArrayList(); List lstNames = Lists.newArrayList(); this.listeners = listeners; @@ -72,7 +72,7 @@ public final class CapabilityDispatcher implements INBTSerializable lstCaps.add(parent); if (parent instanceof INBTSerializable) { - lstWriters.add((INBTSerializable)parent); + lstWriters.add((INBTSerializable)parent); lstNames.add("Parent"); } } @@ -83,7 +83,7 @@ public final class CapabilityDispatcher implements INBTSerializable lstCaps.add(prov); if (prov instanceof INBTSerializable) { - lstWriters.add((INBTSerializable)prov); + lstWriters.add((INBTSerializable)prov); lstNames.add(entry.getKey().toString()); } } @@ -119,9 +119,9 @@ public final class CapabilityDispatcher implements INBTSerializable } @Override - public CompoundNBT serializeNBT() + public CompoundTag serializeNBT() { - CompoundNBT nbt = new CompoundNBT(); + CompoundTag nbt = new CompoundTag(); for (int x = 0; x < writers.length; x++) { nbt.put(names[x], writers[x].serializeNBT()); @@ -130,7 +130,7 @@ public final class CapabilityDispatcher implements INBTSerializable } @Override - public void deserializeNBT(CompoundNBT nbt) + public void deserializeNBT(CompoundTag nbt) { for (int x = 0; x < writers.length; x++) { diff --git a/src/main/java/net/minecraftforge/common/capabilities/CapabilityManager.java b/src/main/java/net/minecraftforge/common/capabilities/CapabilityManager.java index 8df882fd9e..538dd6b39d 100644 --- a/src/main/java/net/minecraftforge/common/capabilities/CapabilityManager.java +++ b/src/main/java/net/minecraftforge/common/capabilities/CapabilityManager.java @@ -29,7 +29,6 @@ import java.util.IdentityHashMap; import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.concurrent.Callable; import net.minecraftforge.forgespi.language.ModFileScanData; import org.apache.logging.log4j.LogManager; @@ -53,15 +52,11 @@ public enum CapabilityManager * To retrieve the Capability instance, use the @CapabilityInject annotation. * This method is safe to call during parallel mod loading. * - * @param type The Interface to be registered - * @param storage A default implementation of the storage handler. - * @param factory A Factory that will produce new instances of the default implementation. + * @param type The class type to be registered */ - public void register(Class type, Capability.IStorage storage, Callable factory) + public void register(Class type) { Objects.requireNonNull(type,"Attempted to register a capability with invalid type"); - Objects.requireNonNull(storage,"Attempted to register a capability with no storage implementation"); - Objects.requireNonNull(factory,"Attempted to register a capability with no default implementation factory"); String realName = type.getName().intern(); Capability cap; @@ -72,7 +67,7 @@ public enum CapabilityManager throw new IllegalArgumentException("Cannot register a capability implementation multiple times : "+ realName); } - cap = new Capability<>(realName, storage, factory); + cap = new Capability<>(realName); providers.put(realName, cap); } @@ -87,7 +82,7 @@ public enum CapabilityManager final List capabilities = data.stream() .map(ModFileScanData::getAnnotations) .flatMap(Collection::stream) - .filter(a -> CAP_INJECT.equals(a.getAnnotationType())) + .filter(a -> CAP_INJECT.equals(a.annotationType())) .collect(Collectors.toList()); final IdentityHashMap, Object>>> m = new IdentityHashMap<>(); capabilities.forEach(entry -> attachCapabilityToMethod(m, entry)); @@ -96,9 +91,9 @@ public enum CapabilityManager private static void attachCapabilityToMethod(Map, Object>>> cbs, ModFileScanData.AnnotationData entry) { - final String targetClass = entry.getClassType().getClassName(); - final String targetName = entry.getMemberName(); - Type type = (Type)entry.getAnnotationData().get("value"); + final String targetClass = entry.clazz().getClassName(); + final String targetName = entry.memberName(); + Type type = (Type)entry.annotationData().get("value"); if (type == null) { LOGGER.warn(CAPABILITIES,"Unable to inject capability at {}.{} (Invalid Annotation)", targetClass, targetName); @@ -108,7 +103,7 @@ public enum CapabilityManager List, Object>> list = cbs.computeIfAbsent(capabilityName, k -> new ArrayList<>()); - if (entry.getMemberName().indexOf('(') > 0) + if (entry.memberName().indexOf('(') > 0) { list.add(input -> { try diff --git a/src/main/java/net/minecraftforge/common/capabilities/CapabilityProvider.java b/src/main/java/net/minecraftforge/common/capabilities/CapabilityProvider.java index 4d68e3a782..f8ba1ae905 100644 --- a/src/main/java/net/minecraftforge/common/capabilities/CapabilityProvider.java +++ b/src/main/java/net/minecraftforge/common/capabilities/CapabilityProvider.java @@ -22,9 +22,9 @@ package net.minecraftforge.common.capabilities; import javax.annotation.Nonnull; import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; -import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.Direction; +import net.minecraft.MethodsReturnNonnullByDefault; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.core.Direction; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.event.ForgeEventFactory; @@ -78,7 +78,7 @@ public abstract class CapabilityProvider> implem } } - protected final @Nullable CompoundNBT serializeCaps() + protected final @Nullable CompoundTag serializeCaps() { final CapabilityDispatcher disp = getCapabilities(); if (disp != null) @@ -88,7 +88,7 @@ public abstract class CapabilityProvider> implem return null; } - protected final void deserializeCaps(CompoundNBT tag) + protected final void deserializeCaps(CompoundTag tag) { final CapabilityDispatcher disp = getCapabilities(); if (disp != null) diff --git a/src/main/java/net/minecraftforge/common/capabilities/ICapabilityProvider.java b/src/main/java/net/minecraftforge/common/capabilities/ICapabilityProvider.java index eb81895255..b39466f7ef 100644 --- a/src/main/java/net/minecraftforge/common/capabilities/ICapabilityProvider.java +++ b/src/main/java/net/minecraftforge/common/capabilities/ICapabilityProvider.java @@ -22,7 +22,7 @@ package net.minecraftforge.common.capabilities; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import net.minecraft.util.Direction; +import net.minecraft.core.Direction; import net.minecraftforge.common.util.LazyOptional; public interface ICapabilityProvider diff --git a/src/main/java/net/minecraftforge/common/capabilities/ICapabilitySerializable.java b/src/main/java/net/minecraftforge/common/capabilities/ICapabilitySerializable.java index 709a669621..26e3e2d5e6 100644 --- a/src/main/java/net/minecraftforge/common/capabilities/ICapabilitySerializable.java +++ b/src/main/java/net/minecraftforge/common/capabilities/ICapabilitySerializable.java @@ -19,8 +19,8 @@ package net.minecraftforge.common.capabilities; -import net.minecraft.nbt.INBT; +import net.minecraft.nbt.Tag; import net.minecraftforge.common.util.INBTSerializable; //Just a mix of the two, useful in patches to lower the size. -public interface ICapabilitySerializable extends ICapabilityProvider, INBTSerializable{} +public interface ICapabilitySerializable extends ICapabilityProvider, INBTSerializable{} diff --git a/src/main/java/net/minecraftforge/common/command/EntitySelectorManager.java b/src/main/java/net/minecraftforge/common/command/EntitySelectorManager.java index cd4f0d0342..7b7f9574a8 100644 --- a/src/main/java/net/minecraftforge/common/command/EntitySelectorManager.java +++ b/src/main/java/net/minecraftforge/common/command/EntitySelectorManager.java @@ -22,8 +22,8 @@ package net.minecraftforge.common.command; import com.mojang.brigadier.StringReader; import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.suggestion.SuggestionsBuilder; -import net.minecraft.command.arguments.EntitySelector; -import net.minecraft.command.arguments.EntitySelectorParser; +import net.minecraft.commands.arguments.selector.EntitySelector; +import net.minecraft.commands.arguments.selector.EntitySelectorParser; import java.util.Arrays; import java.util.HashMap; diff --git a/src/main/java/net/minecraftforge/common/command/IEntitySelectorType.java b/src/main/java/net/minecraftforge/common/command/IEntitySelectorType.java index 5091227bb6..200ebb9f59 100644 --- a/src/main/java/net/minecraftforge/common/command/IEntitySelectorType.java +++ b/src/main/java/net/minecraftforge/common/command/IEntitySelectorType.java @@ -20,9 +20,9 @@ package net.minecraftforge.common.command; import com.mojang.brigadier.exceptions.CommandSyntaxException; -import net.minecraft.command.arguments.EntitySelector; -import net.minecraft.command.arguments.EntitySelectorParser; -import net.minecraft.util.text.ITextComponent; +import net.minecraft.commands.arguments.selector.EntitySelector; +import net.minecraft.commands.arguments.selector.EntitySelectorParser; +import net.minecraft.network.chat.Component; /** * Implementations of this interface can be registered using {@link EntitySelectorManager#register} @@ -40,5 +40,5 @@ public interface IEntitySelectorType /** * Returns an {@link ITextComponent} containing a short description for this selector type. */ - ITextComponent getSuggestionTooltip(); + Component getSuggestionTooltip(); } diff --git a/src/main/java/net/minecraftforge/common/crafting/CompoundIngredient.java b/src/main/java/net/minecraftforge/common/crafting/CompoundIngredient.java index 87d5718938..24858bebf7 100644 --- a/src/main/java/net/minecraftforge/common/crafting/CompoundIngredient.java +++ b/src/main/java/net/minecraftforge/common/crafting/CompoundIngredient.java @@ -37,9 +37,9 @@ import com.google.gson.JsonSyntaxException; import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntComparators; import it.unimi.dsi.fastutil.ints.IntList; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.network.PacketBuffer; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.network.FriendlyByteBuf; public class CompoundIngredient extends Ingredient { @@ -147,7 +147,7 @@ public class CompoundIngredient extends Ingredient public static final Serializer INSTANCE = new Serializer(); @Override - public CompoundIngredient parse(PacketBuffer buffer) + public CompoundIngredient parse(FriendlyByteBuf buffer) { return new CompoundIngredient(Stream.generate(() -> Ingredient.fromNetwork(buffer)).limit(buffer.readVarInt()).collect(Collectors.toList())); } @@ -159,7 +159,7 @@ public class CompoundIngredient extends Ingredient } @Override - public void write(PacketBuffer buffer, CompoundIngredient ingredient) + public void write(FriendlyByteBuf buffer, CompoundIngredient ingredient) { buffer.writeVarInt(ingredient.children.size()); ingredient.children.forEach(c -> c.toNetwork(buffer)); diff --git a/src/main/java/net/minecraftforge/common/crafting/ConditionalAdvancement.java b/src/main/java/net/minecraftforge/common/crafting/ConditionalAdvancement.java index 6540684094..12d3c77270 100644 --- a/src/main/java/net/minecraftforge/common/crafting/ConditionalAdvancement.java +++ b/src/main/java/net/minecraftforge/common/crafting/ConditionalAdvancement.java @@ -30,8 +30,8 @@ import com.google.gson.JsonObject; import com.google.gson.JsonSyntaxException; import net.minecraft.advancements.Advancement; -import net.minecraft.data.IFinishedRecipe; -import net.minecraft.util.JSONUtils; +import net.minecraft.data.recipes.FinishedRecipe; +import net.minecraft.util.GsonHelper; import net.minecraftforge.common.crafting.conditions.ICondition; import javax.annotation.Nullable; @@ -55,7 +55,7 @@ public class ConditionalAdvancement */ @Nullable public static JsonObject processConditional(JsonObject json) { - JsonArray entries = JSONUtils.getAsJsonArray(json, "advancements", null); + JsonArray entries = GsonHelper.getAsJsonArray(json, "advancements", null); if (entries == null) { return CraftingHelper.processConditions(json, "conditions") ? json : null; @@ -66,8 +66,8 @@ public class ConditionalAdvancement { if (!ele.isJsonObject()) throw new JsonSyntaxException("Invalid advancement entry at index " + idx + " Must be JsonObject"); - if (CraftingHelper.processConditions(JSONUtils.getAsJsonArray(ele.getAsJsonObject(), "conditions"))) - return JSONUtils.getAsJsonObject(ele.getAsJsonObject(), "advancement"); + if (CraftingHelper.processConditions(GsonHelper.getAsJsonArray(ele.getAsJsonObject(), "conditions"))) + return GsonHelper.getAsJsonObject(ele.getAsJsonObject(), "advancement"); idx++; } return null; @@ -102,7 +102,7 @@ public class ConditionalAdvancement return addAdvancement(advancement::serializeToJson); } - public Builder addAdvancement(IFinishedRecipe fromRecipe) + public Builder addAdvancement(FinishedRecipe fromRecipe) { return addAdvancement(fromRecipe::serializeAdvancement); } diff --git a/src/main/java/net/minecraftforge/common/crafting/ConditionalRecipe.java b/src/main/java/net/minecraftforge/common/crafting/ConditionalRecipe.java index 772e7920a9..eeac635328 100644 --- a/src/main/java/net/minecraftforge/common/crafting/ConditionalRecipe.java +++ b/src/main/java/net/minecraftforge/common/crafting/ConditionalRecipe.java @@ -28,13 +28,13 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonSyntaxException; -import net.minecraft.data.IFinishedRecipe; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.item.crafting.IRecipeSerializer; -import net.minecraft.item.crafting.RecipeManager; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.JSONUtils; -import net.minecraft.util.ResourceLocation; +import net.minecraft.data.recipes.FinishedRecipe; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeSerializer; +import net.minecraft.world.item.crafting.RecipeManager; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.util.GsonHelper; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.common.crafting.conditions.ICondition; import net.minecraftforge.registries.ObjectHolder; @@ -43,19 +43,19 @@ import javax.annotation.Nullable; public class ConditionalRecipe { @ObjectHolder("forge:conditional") - public static final IRecipeSerializer> SERIALZIER = null; + public static final RecipeSerializer> SERIALZIER = null; public static Builder builder() { return new Builder(); } - public static class Serializer> implements IRecipeSerializer + public static class Serializer> implements RecipeSerializer { private ResourceLocation name; @Override - public IRecipeSerializer setRegistryName(ResourceLocation name) + public RecipeSerializer setRegistryName(ResourceLocation name) { this.name = name; return this; @@ -68,9 +68,9 @@ public class ConditionalRecipe } @Override - public Class> getRegistryType() + public Class> getRegistryType() { - return Serializer.>castClass(IRecipeSerializer.class); + return Serializer.>castClass(RecipeSerializer.class); } @SuppressWarnings("unchecked") // Need this wrapper, because generics @@ -83,28 +83,28 @@ public class ConditionalRecipe @Override public T fromJson(ResourceLocation recipeId, JsonObject json) { - JsonArray items = JSONUtils.getAsJsonArray(json, "recipes"); + JsonArray items = GsonHelper.getAsJsonArray(json, "recipes"); int idx = 0; for (JsonElement ele : items) { if (!ele.isJsonObject()) throw new JsonSyntaxException("Invalid recipes entry at index " + idx + " Must be JsonObject"); - if (CraftingHelper.processConditions(JSONUtils.getAsJsonArray(ele.getAsJsonObject(), "conditions"))) - return (T)RecipeManager.fromJson(recipeId, JSONUtils.getAsJsonObject(ele.getAsJsonObject(), "recipe")); + if (CraftingHelper.processConditions(GsonHelper.getAsJsonArray(ele.getAsJsonObject(), "conditions"))) + return (T)RecipeManager.fromJson(recipeId, GsonHelper.getAsJsonObject(ele.getAsJsonObject(), "recipe")); idx++; } return null; } //Should never get here as we return one of the recipes we wrap. - @Override public T fromNetwork(ResourceLocation recipeId, PacketBuffer buffer) { return null; } - @Override public void toNetwork(PacketBuffer buffer, T recipe) {} + @Override public T fromNetwork(ResourceLocation recipeId, FriendlyByteBuf buffer) { return null; } + @Override public void toNetwork(FriendlyByteBuf buffer, T recipe) {} } public static class Builder { private List conditions = new ArrayList<>(); - private List recipes = new ArrayList<>(); + private List recipes = new ArrayList<>(); private ResourceLocation advId; private ConditionalAdvancement.Builder adv; @@ -116,13 +116,13 @@ public class ConditionalRecipe return this; } - public Builder addRecipe(Consumer> callable) + public Builder addRecipe(Consumer> callable) { callable.accept(this::addRecipe); return this; } - public Builder addRecipe(IFinishedRecipe recipe) + public Builder addRecipe(FinishedRecipe recipe) { if (currentConditions.isEmpty()) throw new IllegalStateException("Can not add a recipe with no conditions."); @@ -168,12 +168,12 @@ public class ConditionalRecipe return this; } - public void build(Consumer consumer, String namespace, String path) + public void build(Consumer consumer, String namespace, String path) { build(consumer, new ResourceLocation(namespace, path)); } - public void build(Consumer consumer, ResourceLocation id) + public void build(Consumer consumer, ResourceLocation id) { if (!currentConditions.isEmpty()) throw new IllegalStateException("Invalid ConditionalRecipe builder, Orphaned conditions"); @@ -189,15 +189,15 @@ public class ConditionalRecipe } } - private static class Finished implements IFinishedRecipe + private static class Finished implements FinishedRecipe { private final ResourceLocation id; private final List conditions; - private final List recipes; + private final List recipes; private final ResourceLocation advId; private final ConditionalAdvancement.Builder adv; - private Finished(ResourceLocation id, List conditions, List recipes, @Nullable ResourceLocation advId, @Nullable ConditionalAdvancement.Builder adv) + private Finished(ResourceLocation id, List conditions, List recipes, @Nullable ResourceLocation advId, @Nullable ConditionalAdvancement.Builder adv) { this.id = id; this.conditions = conditions; @@ -230,7 +230,7 @@ public class ConditionalRecipe } @Override - public IRecipeSerializer getType() + public RecipeSerializer getType() { return SERIALZIER; } diff --git a/src/main/java/net/minecraftforge/common/crafting/CraftingHelper.java b/src/main/java/net/minecraftforge/common/crafting/CraftingHelper.java index 6e19cbaecc..28b2b3c30c 100644 --- a/src/main/java/net/minecraftforge/common/crafting/CraftingHelper.java +++ b/src/main/java/net/minecraftforge/common/crafting/CraftingHelper.java @@ -36,16 +36,16 @@ import com.google.gson.JsonObject; import com.google.gson.JsonSyntaxException; import com.mojang.brigadier.exceptions.CommandSyntaxException; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +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.JsonToNBT; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.JSONUtils; -import net.minecraft.util.ResourceLocation; +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; import org.apache.logging.log4j.LogManager; @@ -85,7 +85,7 @@ public class CraftingHelper { return ingredients.inverse().get(serializer); } - public static void write(PacketBuffer 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(); @@ -100,7 +100,7 @@ public class CraftingHelper serializer.write(buffer, ingredient); } - public static Ingredient getIngredient(ResourceLocation type, PacketBuffer buffer) + public static Ingredient getIngredient(ResourceLocation type, FriendlyByteBuf buffer) { IIngredientSerializer serializer = ingredients.get(type); if (serializer == null) @@ -144,7 +144,7 @@ public class CraftingHelper JsonObject obj = (JsonObject)json; - String type = JSONUtils.getAsString(obj, "type", "minecraft:item"); + String type = GsonHelper.getAsString(obj, "type", "minecraft:item"); if (type.isEmpty()) throw new JsonSyntaxException("Ingredient type can not be an empty string"); @@ -157,7 +157,7 @@ public class CraftingHelper public static ItemStack getItemStack(JsonObject json, boolean readNBT) { - String itemName = JSONUtils.getAsString(json, "item"); + String itemName = GsonHelper.getAsString(json, "item"); Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(itemName)); @@ -170,13 +170,13 @@ public class CraftingHelper try { JsonElement element = json.get("nbt"); - CompoundNBT nbt; + CompoundTag nbt; if(element.isJsonObject()) - nbt = JsonToNBT.parseTag(GSON.toJson(element)); + nbt = TagParser.parseTag(GSON.toJson(element)); else - nbt = JsonToNBT.parseTag(JSONUtils.convertToString(element, "nbt")); + nbt = TagParser.parseTag(GsonHelper.convertToString(element, "nbt")); - CompoundNBT tmp = new CompoundNBT(); + CompoundTag tmp = new CompoundTag(); if (nbt.contains("ForgeCaps")) { tmp.put("ForgeCaps", nbt.get("ForgeCaps")); @@ -185,7 +185,7 @@ public class CraftingHelper tmp.put("tag", nbt); tmp.putString("id", itemName); - tmp.putInt("Count", JSONUtils.getAsInt(json, "count", 1)); + tmp.putInt("Count", GsonHelper.getAsInt(json, "count", 1)); return ItemStack.of(tmp); } @@ -195,12 +195,12 @@ public class CraftingHelper } } - return new ItemStack(item, JSONUtils.getAsInt(json, "count", 1)); + return new ItemStack(item, GsonHelper.getAsInt(json, "count", 1)); } public static boolean processConditions(JsonObject json, String memberName) { - return !json.has(memberName) || processConditions(JSONUtils.getAsJsonArray(json, memberName)); + return !json.has(memberName) || processConditions(GsonHelper.getAsJsonArray(json, memberName)); } public static boolean processConditions(JsonArray conditions) @@ -219,7 +219,7 @@ public class CraftingHelper public static ICondition getCondition(JsonObject json) { - ResourceLocation type = new ResourceLocation(JSONUtils.getAsString(json, "type")); + ResourceLocation type = new ResourceLocation(GsonHelper.getAsString(json, "type")); IConditionSerializer serializer = conditions.get(type); if (serializer == null) throw new JsonSyntaxException("Unknown condition type: " + type.toString()); diff --git a/src/main/java/net/minecraftforge/common/crafting/IIngredientSerializer.java b/src/main/java/net/minecraftforge/common/crafting/IIngredientSerializer.java index 401e9c862a..3346a13196 100644 --- a/src/main/java/net/minecraftforge/common/crafting/IIngredientSerializer.java +++ b/src/main/java/net/minecraftforge/common/crafting/IIngredientSerializer.java @@ -21,14 +21,14 @@ package net.minecraftforge.common.crafting; import com.google.gson.JsonObject; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.network.PacketBuffer; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.network.FriendlyByteBuf; public interface IIngredientSerializer { - T parse(PacketBuffer buffer); + T parse(FriendlyByteBuf buffer); T parse(JsonObject json); - void write(PacketBuffer buffer, T ingredient); + void write(FriendlyByteBuf buffer, T ingredient); } diff --git a/src/main/java/net/minecraftforge/common/crafting/IRecipeContainer.java b/src/main/java/net/minecraftforge/common/crafting/IRecipeContainer.java index 6e5cfc4e53..9c067c50ea 100644 --- a/src/main/java/net/minecraftforge/common/crafting/IRecipeContainer.java +++ b/src/main/java/net/minecraftforge/common/crafting/IRecipeContainer.java @@ -19,8 +19,8 @@ package net.minecraftforge.common.crafting; -import net.minecraft.inventory.CraftResultInventory; -import net.minecraft.inventory.CraftingInventory; +import net.minecraft.world.inventory.ResultContainer; +import net.minecraft.world.inventory.CraftingContainer; /** * This interface is to be implemented on Container objects. @@ -34,12 +34,12 @@ public interface IRecipeContainer * The equivalent for {@link ContainerWorkbench} is {@link ContainerWorkbench#craftResult}. * The equivalent for {@link ContainerPlayer} is {@link ContainerPlayer#craftResult}. */ - CraftResultInventory getCraftResult(); + ResultContainer getCraftResult(); /** * The crafting matrix of your container, where ingredients go for crafting. * The equivalent for {@link ContainerWorkbench} is {@link ContainerWorkbench#craftMatrix}. * The equivalent for {@link ContainerPlayer} is {@link ContainerPlayer#craftMatrix}. */ - CraftingInventory getCraftMatrix(); + CraftingContainer getCraftMatrix(); } diff --git a/src/main/java/net/minecraftforge/common/crafting/IShapedRecipe.java b/src/main/java/net/minecraftforge/common/crafting/IShapedRecipe.java index 6316ea4ecb..c1f05de0b6 100644 --- a/src/main/java/net/minecraftforge/common/crafting/IShapedRecipe.java +++ b/src/main/java/net/minecraftforge/common/crafting/IShapedRecipe.java @@ -19,15 +19,15 @@ package net.minecraftforge.common.crafting; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.crafting.IRecipe; +import net.minecraft.world.Container; +import net.minecraft.world.item.crafting.Recipe; /** * Used to mark a recipe that shape matters so that the 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 IRecipe +public interface IShapedRecipe extends Recipe { int getRecipeWidth(); int getRecipeHeight(); diff --git a/src/main/java/net/minecraftforge/common/crafting/NBTIngredient.java b/src/main/java/net/minecraftforge/common/crafting/NBTIngredient.java index 288ed3a42a..c8c0fec69f 100644 --- a/src/main/java/net/minecraftforge/common/crafting/NBTIngredient.java +++ b/src/main/java/net/minecraftforge/common/crafting/NBTIngredient.java @@ -26,16 +26,16 @@ import javax.annotation.Nullable; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.network.PacketBuffer; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.network.FriendlyByteBuf; public class NBTIngredient extends Ingredient { private final ItemStack stack; protected NBTIngredient(ItemStack stack) { - super(Stream.of(new Ingredient.SingleItemList(stack))); + super(Stream.of(new Ingredient.ItemValue(stack))); this.stack = stack; } @@ -77,7 +77,7 @@ public class NBTIngredient extends Ingredient public static final Serializer INSTANCE = new Serializer(); @Override - public NBTIngredient parse(PacketBuffer buffer) { + public NBTIngredient parse(FriendlyByteBuf buffer) { return new NBTIngredient(buffer.readItem()); } @@ -87,7 +87,7 @@ public class NBTIngredient extends Ingredient } @Override - public void write(PacketBuffer buffer, NBTIngredient ingredient) { + public void write(FriendlyByteBuf buffer, NBTIngredient ingredient) { buffer.writeItem(ingredient.stack); } } diff --git a/src/main/java/net/minecraftforge/common/crafting/StackList.java b/src/main/java/net/minecraftforge/common/crafting/StackList.java index 8abce5a6d5..ec9fed6dcd 100644 --- a/src/main/java/net/minecraftforge/common/crafting/StackList.java +++ b/src/main/java/net/minecraftforge/common/crafting/StackList.java @@ -25,10 +25,10 @@ import java.util.Collections; import com.google.gson.JsonArray; import com.google.gson.JsonObject; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient.IItemList; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Ingredient.Value; -public class StackList implements IItemList +public class StackList implements Value { private Collection items; public StackList(Collection items) diff --git a/src/main/java/net/minecraftforge/common/crafting/VanillaIngredientSerializer.java b/src/main/java/net/minecraftforge/common/crafting/VanillaIngredientSerializer.java index d8e4644e1d..c9fe489700 100644 --- a/src/main/java/net/minecraftforge/common/crafting/VanillaIngredientSerializer.java +++ b/src/main/java/net/minecraftforge/common/crafting/VanillaIngredientSerializer.java @@ -23,17 +23,17 @@ import java.util.stream.Stream; import com.google.gson.JsonObject; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.network.PacketBuffer; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.network.FriendlyByteBuf; public class VanillaIngredientSerializer implements IIngredientSerializer { public static final VanillaIngredientSerializer INSTANCE = new VanillaIngredientSerializer(); - public Ingredient parse(PacketBuffer buffer) + public Ingredient parse(FriendlyByteBuf buffer) { - return Ingredient.fromValues(Stream.generate(() -> new Ingredient.SingleItemList(buffer.readItem())).limit(buffer.readVarInt())); + return Ingredient.fromValues(Stream.generate(() -> new Ingredient.ItemValue(buffer.readItem())).limit(buffer.readVarInt())); } public Ingredient parse(JsonObject json) @@ -41,7 +41,7 @@ public class VanillaIngredientSerializer implements IIngredientSerializer children = new ArrayList<>(); - for (JsonElement j : JSONUtils.getAsJsonArray(json, "values")) + for (JsonElement j : GsonHelper.getAsJsonArray(json, "values")) { if (!j.isJsonObject()) throw new JsonSyntaxException("And condition values must be an array of JsonObjects"); diff --git a/src/main/java/net/minecraftforge/common/crafting/conditions/FalseCondition.java b/src/main/java/net/minecraftforge/common/crafting/conditions/FalseCondition.java index 11182f2c16..7c1368afb0 100644 --- a/src/main/java/net/minecraftforge/common/crafting/conditions/FalseCondition.java +++ b/src/main/java/net/minecraftforge/common/crafting/conditions/FalseCondition.java @@ -20,7 +20,7 @@ package net.minecraftforge.common.crafting.conditions; import com.google.gson.JsonObject; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; public final class FalseCondition implements ICondition { diff --git a/src/main/java/net/minecraftforge/common/crafting/conditions/ICondition.java b/src/main/java/net/minecraftforge/common/crafting/conditions/ICondition.java index 47e0da5610..d006af4731 100644 --- a/src/main/java/net/minecraftforge/common/crafting/conditions/ICondition.java +++ b/src/main/java/net/minecraftforge/common/crafting/conditions/ICondition.java @@ -19,7 +19,7 @@ package net.minecraftforge.common.crafting.conditions; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; public interface ICondition { diff --git a/src/main/java/net/minecraftforge/common/crafting/conditions/IConditionSerializer.java b/src/main/java/net/minecraftforge/common/crafting/conditions/IConditionSerializer.java index 8b20d2de13..62b0a88193 100644 --- a/src/main/java/net/minecraftforge/common/crafting/conditions/IConditionSerializer.java +++ b/src/main/java/net/minecraftforge/common/crafting/conditions/IConditionSerializer.java @@ -21,7 +21,7 @@ package net.minecraftforge.common.crafting.conditions; import com.google.gson.JsonObject; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; public interface IConditionSerializer { diff --git a/src/main/java/net/minecraftforge/common/crafting/conditions/ItemExistsCondition.java b/src/main/java/net/minecraftforge/common/crafting/conditions/ItemExistsCondition.java index cf0c45aeaa..d58f40049d 100644 --- a/src/main/java/net/minecraftforge/common/crafting/conditions/ItemExistsCondition.java +++ b/src/main/java/net/minecraftforge/common/crafting/conditions/ItemExistsCondition.java @@ -21,8 +21,8 @@ package net.minecraftforge.common.crafting.conditions; import com.google.gson.JsonObject; -import net.minecraft.util.JSONUtils; -import net.minecraft.util.ResourceLocation; +import net.minecraft.util.GsonHelper; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.registries.ForgeRegistries; public class ItemExistsCondition implements ICondition @@ -76,7 +76,7 @@ public class ItemExistsCondition implements ICondition @Override public ItemExistsCondition read(JsonObject json) { - return new ItemExistsCondition(new ResourceLocation(JSONUtils.getAsString(json, "item"))); + return new ItemExistsCondition(new ResourceLocation(GsonHelper.getAsString(json, "item"))); } @Override diff --git a/src/main/java/net/minecraftforge/common/crafting/conditions/ModLoadedCondition.java b/src/main/java/net/minecraftforge/common/crafting/conditions/ModLoadedCondition.java index 55b1999577..a3dd1cfbf4 100644 --- a/src/main/java/net/minecraftforge/common/crafting/conditions/ModLoadedCondition.java +++ b/src/main/java/net/minecraftforge/common/crafting/conditions/ModLoadedCondition.java @@ -21,8 +21,8 @@ package net.minecraftforge.common.crafting.conditions; import com.google.gson.JsonObject; -import net.minecraft.util.JSONUtils; -import net.minecraft.util.ResourceLocation; +import net.minecraft.util.GsonHelper; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.fml.ModList; public class ModLoadedCondition implements ICondition @@ -66,7 +66,7 @@ public class ModLoadedCondition implements ICondition @Override public ModLoadedCondition read(JsonObject json) { - return new ModLoadedCondition(JSONUtils.getAsString(json, "modid")); + return new ModLoadedCondition(GsonHelper.getAsString(json, "modid")); } @Override diff --git a/src/main/java/net/minecraftforge/common/crafting/conditions/NotCondition.java b/src/main/java/net/minecraftforge/common/crafting/conditions/NotCondition.java index d11c19759e..a1a1f5d26a 100644 --- a/src/main/java/net/minecraftforge/common/crafting/conditions/NotCondition.java +++ b/src/main/java/net/minecraftforge/common/crafting/conditions/NotCondition.java @@ -20,8 +20,8 @@ package net.minecraftforge.common.crafting.conditions; import com.google.gson.JsonObject; -import net.minecraft.util.JSONUtils; -import net.minecraft.util.ResourceLocation; +import net.minecraft.util.GsonHelper; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.common.crafting.CraftingHelper; public class NotCondition implements ICondition @@ -65,7 +65,7 @@ public class NotCondition implements ICondition @Override public NotCondition read(JsonObject json) { - return new NotCondition(CraftingHelper.getCondition(JSONUtils.getAsJsonObject(json, "value"))); + return new NotCondition(CraftingHelper.getCondition(GsonHelper.getAsJsonObject(json, "value"))); } @Override diff --git a/src/main/java/net/minecraftforge/common/crafting/conditions/OrCondition.java b/src/main/java/net/minecraftforge/common/crafting/conditions/OrCondition.java index 9346fde570..8f8183d211 100644 --- a/src/main/java/net/minecraftforge/common/crafting/conditions/OrCondition.java +++ b/src/main/java/net/minecraftforge/common/crafting/conditions/OrCondition.java @@ -28,8 +28,8 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonSyntaxException; -import net.minecraft.util.JSONUtils; -import net.minecraft.util.ResourceLocation; +import net.minecraft.util.GsonHelper; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.common.crafting.CraftingHelper; public class OrCondition implements ICondition @@ -92,7 +92,7 @@ public class OrCondition implements ICondition public OrCondition read(JsonObject json) { List children = new ArrayList<>(); - for (JsonElement j : JSONUtils.getAsJsonArray(json, "values")) + for (JsonElement j : GsonHelper.getAsJsonArray(json, "values")) { if (!j.isJsonObject()) throw new JsonSyntaxException("Or condition values must be an array of JsonObjects"); diff --git a/src/main/java/net/minecraftforge/common/crafting/conditions/TagEmptyCondition.java b/src/main/java/net/minecraftforge/common/crafting/conditions/TagEmptyCondition.java index c8165cdf54..318203f33e 100644 --- a/src/main/java/net/minecraftforge/common/crafting/conditions/TagEmptyCondition.java +++ b/src/main/java/net/minecraftforge/common/crafting/conditions/TagEmptyCondition.java @@ -21,11 +21,12 @@ package net.minecraftforge.common.crafting.conditions; import com.google.gson.JsonObject; -import net.minecraft.item.Item; -import net.minecraft.tags.ITag; -import net.minecraft.tags.TagCollectionManager; -import net.minecraft.util.JSONUtils; -import net.minecraft.util.ResourceLocation; +import net.minecraft.core.Registry; +import net.minecraft.world.item.Item; +import net.minecraft.tags.Tag; +import net.minecraft.tags.SerializationTags; +import net.minecraft.util.GsonHelper; +import net.minecraft.resources.ResourceLocation; public class TagEmptyCondition implements ICondition { @@ -56,7 +57,7 @@ public class TagEmptyCondition implements ICondition @Override public boolean test() { - ITag tag = TagCollectionManager.getInstance().getItems().getTag(tag_name); + Tag tag = SerializationTags.getInstance().getOrEmpty(Registry.ITEM_REGISTRY).getTag(tag_name); return tag == null || tag.getValues().isEmpty(); } @@ -79,7 +80,7 @@ public class TagEmptyCondition implements ICondition @Override public TagEmptyCondition read(JsonObject json) { - return new TagEmptyCondition(new ResourceLocation(JSONUtils.getAsString(json, "tag"))); + return new TagEmptyCondition(new ResourceLocation(GsonHelper.getAsString(json, "tag"))); } @Override diff --git a/src/main/java/net/minecraftforge/common/crafting/conditions/TrueCondition.java b/src/main/java/net/minecraftforge/common/crafting/conditions/TrueCondition.java index 06f5887223..b37252e78a 100644 --- a/src/main/java/net/minecraftforge/common/crafting/conditions/TrueCondition.java +++ b/src/main/java/net/minecraftforge/common/crafting/conditions/TrueCondition.java @@ -21,7 +21,7 @@ package net.minecraftforge.common.crafting.conditions; import com.google.gson.JsonObject; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; public final class TrueCondition implements ICondition { diff --git a/src/main/java/net/minecraftforge/common/crafting/package-info.java b/src/main/java/net/minecraftforge/common/crafting/package-info.java index 6e93be07e1..74e317e99f 100644 --- a/src/main/java/net/minecraftforge/common/crafting/package-info.java +++ b/src/main/java/net/minecraftforge/common/crafting/package-info.java @@ -22,5 +22,6 @@ @MethodsReturnNonnullByDefault package net.minecraftforge.common.crafting; -import mcp.MethodsReturnNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; + import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/java/net/minecraftforge/common/data/ExistingFileHelper.java b/src/main/java/net/minecraftforge/common/data/ExistingFileHelper.java index 1969aa6a46..6456c03a91 100644 --- a/src/main/java/net/minecraftforge/common/data/ExistingFileHelper.java +++ b/src/main/java/net/minecraftforge/common/data/ExistingFileHelper.java @@ -23,37 +23,39 @@ import java.io.File; import java.io.IOException; import java.nio.file.Path; import java.util.Collection; -import java.util.Collections; import java.util.Set; import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; -import net.minecraft.data.IDataProvider; -import net.minecraft.client.resources.ResourceIndex; -import net.minecraft.client.resources.VirtualAssetsPack; -import net.minecraft.resources.FilePack; -import net.minecraft.resources.FolderPack; -import net.minecraft.resources.IResource; -import net.minecraft.resources.IResourceManager; -import net.minecraft.resources.IResourcePack; -import net.minecraft.resources.ResourcePackType; -import net.minecraft.resources.SimpleReloadableResourceManager; -import net.minecraft.resources.VanillaPack; -import net.minecraft.util.ResourceLocation; +import net.minecraft.client.resources.ClientPackSource; +import net.minecraft.client.resources.AssetIndex; +import net.minecraft.client.resources.DefaultClientPackResources; +import net.minecraft.data.DataProvider; +import net.minecraft.data.HashCache; +import net.minecraft.server.packs.FilePackResources; +import net.minecraft.server.packs.FolderPackResources; +import net.minecraft.server.packs.repository.ServerPacksSource; +import net.minecraft.server.packs.resources.Resource; +import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.server.packs.PackResources; +import net.minecraft.server.packs.PackType; +import net.minecraft.server.packs.resources.SimpleReloadableResourceManager; +import net.minecraft.server.packs.VanillaPackResources; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.client.model.generators.ModelBuilder; import net.minecraftforge.fml.ModList; -import net.minecraftforge.fml.event.lifecycle.GatherDataEvent; -import net.minecraftforge.fml.loading.moddiscovery.ModFileInfo; -import net.minecraftforge.fml.packs.ModFileResourcePack; +import net.minecraftforge.forge.event.lifecycle.GatherDataEvent; +import net.minecraftforge.fmllegacy.packs.ModFileResourcePack; +import net.minecraftforge.forgespi.language.IModFileInfo; import javax.annotation.Nullable; /** * Enables data providers to check if other data files currently exist. The * instance provided in the {@link GatherDataEvent} utilizes the standard - * resources (via {@link VanillaPack}), forge's resources, as well as any + * resources (via {@link VanillaPackResources}), forge's resources, as well as any * extra resource packs passed in via the {@code --existing} argument, * or mod resources via the {@code --existing-mod} argument. */ @@ -61,7 +63,7 @@ public class ExistingFileHelper { public interface IResourceType { - ResourcePackType getPackType(); + PackType getPackType(); String getSuffix(); @@ -70,16 +72,16 @@ public class ExistingFileHelper { public static class ResourceType implements IResourceType { - final ResourcePackType packType; + final PackType packType; final String suffix, prefix; - public ResourceType(ResourcePackType type, String suffix, String prefix) { + public ResourceType(PackType type, String suffix, String prefix) { this.packType = type; this.suffix = suffix; this.prefix = prefix; } @Override - public ResourcePackType getPackType() { return packType; } + public PackType getPackType() { return packType; } @Override public String getSuffix() { return suffix; } @@ -90,12 +92,7 @@ public class ExistingFileHelper { private final SimpleReloadableResourceManager clientResources, serverData; private final boolean enable; - private final Multimap generated = HashMultimap.create(); - - @Deprecated//TODO: Remove in 1.17 - public ExistingFileHelper(Collection existingPacks, boolean enable) { - this(existingPacks, Collections.emptySet(), enable); - } + private final Multimap generated = HashMultimap.create(); /** * Create a new helper. This should probably NOT be used by mods, as @@ -108,33 +105,29 @@ public class ExistingFileHelper { * @param existingPacks * @param existingMods * @param enable + * @param assetIndex + * @param assetsDir */ - @Deprecated // TODO: Remove in 1.17 - public ExistingFileHelper(Collection existingPacks, Set existingMods, boolean enable) { - this(existingPacks, existingMods, enable, null, null); - } - public ExistingFileHelper(Collection existingPacks, final Set existingMods, boolean enable, @Nullable final String assetIndex, @Nullable final File assetsDir) { - this.clientResources = new SimpleReloadableResourceManager(ResourcePackType.CLIENT_RESOURCES); - this.serverData = new SimpleReloadableResourceManager(ResourcePackType.SERVER_DATA); + this.clientResources = new SimpleReloadableResourceManager(PackType.CLIENT_RESOURCES); + this.serverData = new SimpleReloadableResourceManager(PackType.SERVER_DATA); - this.clientResources.add(new VanillaPack("minecraft", "realms")); + this.clientResources.add(new VanillaPackResources(ClientPackSource.BUILT_IN, "minecraft", "realms")); if (assetIndex != null && assetsDir != null) { - this.clientResources.add(new VirtualAssetsPack(new ResourceIndex(assetsDir, assetIndex))); + this.clientResources.add(new DefaultClientPackResources(ClientPackSource.BUILT_IN, new AssetIndex(assetsDir, assetIndex))); } - this.serverData.add(new VanillaPack("minecraft")); - + this.serverData.add(new VanillaPackResources(ServerPacksSource.BUILT_IN_METADATA, "minecraft")); for (Path existing : existingPacks) { File file = existing.toFile(); - IResourcePack pack = file.isDirectory() ? new FolderPack(file) : new FilePack(file); + PackResources pack = file.isDirectory() ? new FolderPackResources(file) : new FilePackResources(file); this.clientResources.add(pack); this.serverData.add(pack); } for (String existingMod : existingMods) { - ModFileInfo modFileInfo = ModList.get().getModFileById(existingMod); + IModFileInfo modFileInfo = ModList.get().getModFileById(existingMod); if (modFileInfo != null) { - IResourcePack pack = new ModFileResourcePack(modFileInfo.getFile()); + PackResources pack = new ModFileResourcePack(modFileInfo.getFile()); this.clientResources.add(pack); this.serverData.add(pack); } @@ -142,8 +135,8 @@ public class ExistingFileHelper { this.enable = enable; } - private IResourceManager getManager(ResourcePackType packType) { - return packType == ResourcePackType.CLIENT_RESOURCES ? clientResources : serverData; + private ResourceManager getManager(PackType packType) { + return packType == PackType.CLIENT_RESOURCES ? clientResources : serverData; } private ResourceLocation getLocation(ResourceLocation base, String suffix, String prefix) { @@ -159,7 +152,7 @@ public class ExistingFileHelper { * @return {@code true} if the resource exists in any pack, {@code false} * otherwise */ - public boolean exists(ResourceLocation loc, ResourcePackType packType) { + public boolean exists(ResourceLocation loc, PackType packType) { if (!enable) { return true; } @@ -195,7 +188,7 @@ public class ExistingFileHelper { * @return {@code true} if the resource exists in any pack, {@code false} * otherwise */ - public boolean exists(ResourceLocation loc, ResourcePackType packType, String pathSuffix, String pathPrefix) { + public boolean exists(ResourceLocation loc, PackType packType, String pathSuffix, String pathPrefix) { return exists(getLocation(loc, pathSuffix, pathPrefix), packType); } @@ -206,7 +199,7 @@ public class ExistingFileHelper { *

* This should be called by data providers immediately when a new data object is * created, i.e. not during - * {@link IDataProvider#act(net.minecraft.data.DirectoryCache) act} but instead + * {@link DataProvider#run(net.minecraft.data.HashCache) run} but instead * when the "builder" (or whatever intermediate object) is created, such as a * {@link ModelBuilder}. *

@@ -227,7 +220,7 @@ public class ExistingFileHelper { *

* This should be called by data providers immediately when a new data object is * created, i.e. not during - * {@link IDataProvider#act(net.minecraft.data.DirectoryCache) act} but instead + * {@link DataProvider#run(HashCache) run} but instead * when the "builder" (or whatever intermediate object) is created, such as a * {@link ModelBuilder}. *

@@ -241,17 +234,17 @@ public class ExistingFileHelper { * @param pathPrefix a string to append before the path, before a slash, e.g. * {@code "models"} */ - public void trackGenerated(ResourceLocation loc, ResourcePackType packType, String pathSuffix, String pathPrefix) { + public void trackGenerated(ResourceLocation loc, PackType packType, String pathSuffix, String pathPrefix) { this.generated.put(packType, getLocation(loc, pathSuffix, pathPrefix)); } @VisibleForTesting - public IResource getResource(ResourceLocation loc, ResourcePackType packType, String pathSuffix, String pathPrefix) throws IOException { + public Resource getResource(ResourceLocation loc, PackType packType, String pathSuffix, String pathPrefix) throws IOException { return getResource(getLocation(loc, pathSuffix, pathPrefix), packType); } @VisibleForTesting - public IResource getResource(ResourceLocation loc, ResourcePackType packType) throws IOException { + public Resource getResource(ResourceLocation loc, PackType packType) throws IOException { return getManager(packType).getResource(loc); } diff --git a/src/main/java/net/minecraftforge/common/data/ForgeBlockTagsProvider.java b/src/main/java/net/minecraftforge/common/data/ForgeBlockTagsProvider.java index 2c4dd3b692..19e82a2d7f 100644 --- a/src/main/java/net/minecraftforge/common/data/ForgeBlockTagsProvider.java +++ b/src/main/java/net/minecraftforge/common/data/ForgeBlockTagsProvider.java @@ -20,22 +20,22 @@ package net.minecraftforge.common.data; import net.minecraft.data.DataGenerator; -import net.minecraft.item.DyeColor; +import net.minecraft.world.item.DyeColor; import net.minecraft.tags.BlockTags; -import net.minecraft.tags.ITag; -import net.minecraft.util.ResourceLocation; +import net.minecraft.tags.Tag; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.common.Tags; import net.minecraftforge.registries.ForgeRegistries; -import net.minecraft.block.Block; -import net.minecraft.block.Blocks; -import net.minecraft.data.BlockTagsProvider; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.data.tags.BlockTagsProvider; import static net.minecraftforge.common.Tags.Blocks.*; import java.util.Locale; import java.util.function.Consumer; -public class ForgeBlockTagsProvider extends BlockTagsProvider +public final class ForgeBlockTagsProvider extends BlockTagsProvider { public ForgeBlockTagsProvider(DataGenerator gen, ExistingFileHelper existingFileHelper) { @@ -97,13 +97,13 @@ public class ForgeBlockTagsProvider extends BlockTagsProvider tag(STORAGE_BLOCKS_NETHERITE).add(Blocks.NETHERITE_BLOCK); } - private void addColored(Consumer consumer, ITag.INamedTag group, String pattern) + private void addColored(Consumer consumer, Tag.Named group, String pattern) { String prefix = group.getName().getPath().toUpperCase(Locale.ENGLISH) + '_'; for (DyeColor color : DyeColor.values()) { ResourceLocation key = new ResourceLocation("minecraft", pattern.replace("{color}", color.getName())); - ITag.INamedTag tag = getForgeTag(prefix + color.getName()); + Tag.Named tag = getForgeTag(prefix + color.getName()); Block block = ForgeRegistries.BLOCKS.getValue(key); if (block == null || block == Blocks.AIR) throw new IllegalStateException("Unknown vanilla block: " + key.toString()); @@ -113,12 +113,12 @@ public class ForgeBlockTagsProvider extends BlockTagsProvider } @SuppressWarnings("unchecked") - private ITag.INamedTag getForgeTag(String name) + private Tag.Named getForgeTag(String name) { try { name = name.toUpperCase(Locale.ENGLISH); - return (ITag.INamedTag)Tags.Blocks.class.getDeclaredField(name).get(null); + return (Tag.Named)Tags.Blocks.class.getDeclaredField(name).get(null); } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) { diff --git a/src/main/java/net/minecraftforge/common/data/ForgeFluidTagsProvider.java b/src/main/java/net/minecraftforge/common/data/ForgeFluidTagsProvider.java index c5315b1b48..53c30cc94d 100644 --- a/src/main/java/net/minecraftforge/common/data/ForgeFluidTagsProvider.java +++ b/src/main/java/net/minecraftforge/common/data/ForgeFluidTagsProvider.java @@ -20,12 +20,12 @@ package net.minecraftforge.common.data; import net.minecraft.data.DataGenerator; -import net.minecraft.data.FluidTagsProvider; +import net.minecraft.data.tags.FluidTagsProvider; import net.minecraftforge.common.ForgeMod; import static net.minecraftforge.common.Tags.Fluids.MILK; -public class ForgeFluidTagsProvider extends FluidTagsProvider +public final class ForgeFluidTagsProvider extends FluidTagsProvider { public ForgeFluidTagsProvider(DataGenerator gen, ExistingFileHelper existingFileHelper) { diff --git a/src/main/java/net/minecraftforge/common/data/ForgeItemTagsProvider.java b/src/main/java/net/minecraftforge/common/data/ForgeItemTagsProvider.java index f25b77b663..d345cb887f 100644 --- a/src/main/java/net/minecraftforge/common/data/ForgeItemTagsProvider.java +++ b/src/main/java/net/minecraftforge/common/data/ForgeItemTagsProvider.java @@ -22,19 +22,19 @@ package net.minecraftforge.common.data; import java.util.Locale; import java.util.function.Consumer; -import net.minecraft.block.Block; -import net.minecraft.data.BlockTagsProvider; +import net.minecraft.world.level.block.Block; +import net.minecraft.data.tags.BlockTagsProvider; import net.minecraft.data.DataGenerator; -import net.minecraft.data.ItemTagsProvider; -import net.minecraft.item.DyeColor; -import net.minecraft.item.Item; -import net.minecraft.item.Items; -import net.minecraft.tags.ITag; -import net.minecraft.util.ResourceLocation; +import net.minecraft.data.tags.ItemTagsProvider; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.Items; +import net.minecraft.tags.Tag; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.common.Tags; import net.minecraftforge.registries.ForgeRegistries; -public class ForgeItemTagsProvider extends ItemTagsProvider +public final class ForgeItemTagsProvider extends ItemTagsProvider { public ForgeItemTagsProvider(DataGenerator gen, BlockTagsProvider blockTagProvider, ExistingFileHelper existingFileHelper) { @@ -141,13 +141,13 @@ public class ForgeItemTagsProvider extends ItemTagsProvider tag(Tags.Items.STRING).add(Items.STRING); } - private void addColored(Consumer> consumer, ITag.INamedTag group, String pattern) + private void addColored(Consumer> consumer, Tag.Named group, String pattern) { String prefix = group.getName().getPath().toUpperCase(Locale.ENGLISH) + '_'; for (DyeColor color : DyeColor.values()) { ResourceLocation key = new ResourceLocation("minecraft", pattern.replace("{color}", color.getName())); - ITag.INamedTag tag = getForgeItemTag(prefix + color.getName()); + Tag.Named tag = getForgeItemTag(prefix + color.getName()); Item item = ForgeRegistries.ITEMS.getValue(key); if (item == null || item == Items.AIR) throw new IllegalStateException("Unknown vanilla item: " + key.toString()); @@ -156,26 +156,26 @@ public class ForgeItemTagsProvider extends ItemTagsProvider } } - private void func_240521_a_Colored(ITag.INamedTag blockGroup, ITag.INamedTag itemGroup) + private void func_240521_a_Colored(Tag.Named blockGroup, Tag.Named itemGroup) { String blockPre = blockGroup.getName().getPath().toUpperCase(Locale.ENGLISH) + '_'; String itemPre = itemGroup.getName().getPath().toUpperCase(Locale.ENGLISH) + '_'; for (DyeColor color : DyeColor.values()) { - ITag.INamedTag from = getForgeBlockTag(blockPre + color.getName()); - ITag.INamedTag to = getForgeItemTag(itemPre + color.getName()); + Tag.Named from = getForgeBlockTag(blockPre + color.getName()); + Tag.Named to = getForgeItemTag(itemPre + color.getName()); copy(from, to); } copy(getForgeBlockTag(blockPre + "colorless"), getForgeItemTag(itemPre + "colorless")); } @SuppressWarnings("unchecked") - private ITag.INamedTag getForgeBlockTag(String name) + private Tag.Named getForgeBlockTag(String name) { try { name = name.toUpperCase(Locale.ENGLISH); - return (ITag.INamedTag)Tags.Blocks.class.getDeclaredField(name).get(null); + return (Tag.Named)Tags.Blocks.class.getDeclaredField(name).get(null); } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) { @@ -184,12 +184,12 @@ public class ForgeItemTagsProvider extends ItemTagsProvider } @SuppressWarnings("unchecked") - private ITag.INamedTag getForgeItemTag(String name) + private Tag.Named getForgeItemTag(String name) { try { name = name.toUpperCase(Locale.ENGLISH); - return (ITag.INamedTag)Tags.Items.class.getDeclaredField(name).get(null); + return (Tag.Named)Tags.Items.class.getDeclaredField(name).get(null); } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) { diff --git a/src/main/java/net/minecraftforge/common/data/ForgeLootTableProvider.java b/src/main/java/net/minecraftforge/common/data/ForgeLootTableProvider.java index 85752d483e..5ebd566738 100644 --- a/src/main/java/net/minecraftforge/common/data/ForgeLootTableProvider.java +++ b/src/main/java/net/minecraftforge/common/data/ForgeLootTableProvider.java @@ -20,47 +20,54 @@ package net.minecraftforge.common.data; import com.mojang.datafixers.util.Pair; -import net.minecraft.advancements.criterion.ItemPredicate; +import net.minecraft.advancements.critereon.ItemPredicate; import net.minecraft.data.DataGenerator; -import net.minecraft.data.LootTableProvider; -import net.minecraft.item.Item; -import net.minecraft.item.Items; -import net.minecraft.tags.ITag; -import net.minecraft.util.ResourceLocation; -import net.minecraft.loot.*; -import net.minecraft.loot.conditions.Alternative; -import net.minecraft.loot.conditions.ILootCondition; -import net.minecraft.loot.conditions.Inverted; -import net.minecraft.loot.conditions.MatchTool; +import net.minecraft.data.loot.LootTableProvider; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.Items; +import net.minecraft.tags.Tag; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.storage.loot.predicates.AlternativeLootItemCondition; +import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; +import net.minecraft.world.level.storage.loot.predicates.InvertedLootItemCondition; +import net.minecraft.world.level.storage.loot.predicates.MatchTool; import net.minecraftforge.common.Tags; -import net.minecraftforge.fml.common.ObfuscationReflectionHelper; +import net.minecraftforge.fml.util.ObfuscationReflectionHelper; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.function.BiConsumer; import java.util.function.Consumer; import java.util.function.Supplier; import java.util.stream.Collectors; +import net.minecraft.world.level.storage.loot.LootPool; +import net.minecraft.world.level.storage.loot.LootTable; +import net.minecraft.world.level.storage.loot.ValidationContext; +import net.minecraft.world.level.storage.loot.entries.CompositeEntryBase; +import net.minecraft.world.level.storage.loot.entries.LootPoolEntryContainer; +import net.minecraft.world.level.storage.loot.parameters.LootContextParamSet; + /** * Currently used only for replacing shears item to shears tag */ -public class ForgeLootTableProvider extends LootTableProvider { +public final class ForgeLootTableProvider extends LootTableProvider { public ForgeLootTableProvider(DataGenerator gen) { super(gen); } @Override - protected void validate(Map map, ValidationTracker validationtracker) { + protected void validate(Map map, ValidationContext validationtracker) { // do not validate against all registered loot tables } @Override - protected List>>, LootParameterSet>> getTables() { + protected List>>, LootContextParamSet>> getTables() { return super.getTables().stream().map(pair -> { // provides new consumer with filtering only changed loot tables and replacing condition item to condition tag - return new Pair>>, LootParameterSet>(() -> replaceAndFilterChangesOnly(pair.getFirst().get()), pair.getSecond()); + return new Pair>>, LootContextParamSet>(() -> replaceAndFilterChangesOnly(pair.getFirst().get()), pair.getSecond()); }).collect(Collectors.toList()); } @@ -72,12 +79,12 @@ public class ForgeLootTableProvider extends LootTableProvider { }); } - private boolean findAndReplaceInLootTableBuilder(LootTable.Builder builder, Item from, ITag.INamedTag to) { - List lootPools = ObfuscationReflectionHelper.getPrivateValue(LootTable.Builder.class, builder, "field_216041" + "_a"); + private boolean findAndReplaceInLootTableBuilder(LootTable.Builder builder, Item from, Tag.Named to) { + List lootPools = ObfuscationReflectionHelper.getPrivateValue(LootTable.Builder.class, builder, "f_7915" + "6_"); boolean found = false; if (lootPools == null) { - throw new IllegalStateException(LootTable.Builder.class.getName() + " is missing field field_216041" + "_a"); + throw new IllegalStateException(LootTable.Builder.class.getName() + " is missing field f_7915" + "6_"); } for (LootPool lootPool : lootPools) { @@ -89,39 +96,39 @@ public class ForgeLootTableProvider extends LootTableProvider { return found; } - private boolean findAndReplaceInLootPool(LootPool lootPool, Item from, ITag.INamedTag to) { - List lootEntries = ObfuscationReflectionHelper.getPrivateValue(LootPool.class, lootPool, "field_186453" +"_a"); - List lootConditions = ObfuscationReflectionHelper.getPrivateValue(LootPool.class, lootPool, "field_186454" + "_b"); + private boolean findAndReplaceInLootPool(LootPool lootPool, Item from, Tag.Named to) { + List lootEntries = ObfuscationReflectionHelper.getPrivateValue(LootPool.class, lootPool, "f_7902" +"3_"); + List lootConditions = ObfuscationReflectionHelper.getPrivateValue(LootPool.class, lootPool, "f_7902" + "4_"); boolean found = false; if (lootEntries == null) { - throw new IllegalStateException(LootPool.class.getName() + " is missing field field_186453" + "_a"); + throw new IllegalStateException(LootPool.class.getName() + " is missing field f_7902" + "3_"); } - for (LootEntry lootEntry : lootEntries) { - if (lootEntry instanceof ParentedLootEntry) { - if (findAndReplaceInParentedLootEntry((ParentedLootEntry) lootEntry, from, to)) { + for (LootPoolEntryContainer lootEntry : lootEntries) { + if (lootEntry instanceof CompositeEntryBase) { + if (findAndReplaceInParentedLootEntry((CompositeEntryBase) lootEntry, from, to)) { found = true; } } } if (lootConditions == null) { - throw new IllegalStateException(LootPool.class.getName() + " is missing field field_186454" + "_b"); + throw new IllegalStateException(LootPool.class.getName() + " is missing field f_7902" + "4_"); } for (int i = 0; i < lootConditions.size(); i++) { - ILootCondition lootCondition = lootConditions.get(i); + LootItemCondition lootCondition = lootConditions.get(i); if (lootCondition instanceof MatchTool && checkMatchTool((MatchTool) lootCondition, from)) { lootConditions.set(i, MatchTool.toolMatches(ItemPredicate.Builder.item().of(to)).build()); found = true; - } else if (lootCondition instanceof Inverted) { - ILootCondition invLootCondition = ObfuscationReflectionHelper.getPrivateValue(Inverted.class, (Inverted) lootCondition, "field_215981" + "_a"); + } else if (lootCondition instanceof InvertedLootItemCondition) { + LootItemCondition invLootCondition = ObfuscationReflectionHelper.getPrivateValue(InvertedLootItemCondition.class, (InvertedLootItemCondition) lootCondition, "f_8168" + "1_"); if (invLootCondition instanceof MatchTool && checkMatchTool((MatchTool) invLootCondition, from)) { - lootConditions.set(i, Inverted.invert(MatchTool.toolMatches(ItemPredicate.Builder.item().of(to))).build()); + lootConditions.set(i, InvertedLootItemCondition.invert(MatchTool.toolMatches(ItemPredicate.Builder.item().of(to))).build()); found = true; - } else if (invLootCondition instanceof Alternative && findAndReplaceInAlternative((Alternative) invLootCondition, from, to)) { + } else if (invLootCondition instanceof AlternativeLootItemCondition && findAndReplaceInAlternative((AlternativeLootItemCondition) invLootCondition, from, to)) { found = true; } } @@ -130,15 +137,15 @@ public class ForgeLootTableProvider extends LootTableProvider { return found; } - private boolean findAndReplaceInParentedLootEntry(ParentedLootEntry entry, Item from, ITag.INamedTag to) { - LootEntry[] lootEntries = ObfuscationReflectionHelper.getPrivateValue(ParentedLootEntry.class, entry, "field_216147" + "_c"); + private boolean findAndReplaceInParentedLootEntry(CompositeEntryBase entry, Item from, Tag.Named to) { + LootPoolEntryContainer[] lootEntries = ObfuscationReflectionHelper.getPrivateValue(CompositeEntryBase.class, entry, "f_7942" + "8_"); boolean found = false; if (lootEntries == null) { - throw new IllegalStateException(ParentedLootEntry.class.getName() + " is missing field field_216147" + "_c"); + throw new IllegalStateException(CompositeEntryBase.class.getName() + " is missing field f_7942" + "8_"); } - for (LootEntry lootEntry : lootEntries) { + for (LootPoolEntryContainer lootEntry : lootEntries) { if (findAndReplaceInLootEntry(lootEntry, from, to)) { found = true; } @@ -147,16 +154,16 @@ public class ForgeLootTableProvider extends LootTableProvider { return found; } - private boolean findAndReplaceInLootEntry(LootEntry entry, Item from, ITag.INamedTag to) { - ILootCondition[] lootConditions = ObfuscationReflectionHelper.getPrivateValue(LootEntry.class, entry, "field_216144" + "_d"); + private boolean findAndReplaceInLootEntry(LootPoolEntryContainer entry, Item from, Tag.Named to) { + LootItemCondition[] lootConditions = ObfuscationReflectionHelper.getPrivateValue(LootPoolEntryContainer.class, entry, "f_7963" + "6_"); boolean found = false; if (lootConditions == null) { - throw new IllegalStateException(LootEntry.class.getName() + " is missing field field_216144" + "_d"); + throw new IllegalStateException(LootPoolEntryContainer.class.getName() + " is missing field f_7963" + "6_"); } for (int i = 0; i < lootConditions.length; i++) { - if (lootConditions[i] instanceof Alternative && findAndReplaceInAlternative((Alternative) lootConditions[i], from, to)) { + if (lootConditions[i] instanceof AlternativeLootItemCondition && findAndReplaceInAlternative((AlternativeLootItemCondition) lootConditions[i], from, to)) { found = true; } else if (lootConditions[i] instanceof MatchTool && checkMatchTool((MatchTool) lootConditions[i], from)) { lootConditions[i] = MatchTool.toolMatches(ItemPredicate.Builder.item().of(to)).build(); @@ -167,12 +174,12 @@ public class ForgeLootTableProvider extends LootTableProvider { return found; } - private boolean findAndReplaceInAlternative(Alternative alternative, Item from, ITag.INamedTag to) { - ILootCondition[] lootConditions = ObfuscationReflectionHelper.getPrivateValue(Alternative.class, alternative, "field_215962" + "_a"); + private boolean findAndReplaceInAlternative(AlternativeLootItemCondition alternative, Item from, Tag.Named to) { + LootItemCondition[] lootConditions = ObfuscationReflectionHelper.getPrivateValue(AlternativeLootItemCondition.class, alternative, "f_8146" + "8_"); boolean found = false; if (lootConditions == null) { - throw new IllegalStateException(Alternative.class.getName() + " is missing field field_215962" + "_a"); + throw new IllegalStateException(AlternativeLootItemCondition.class.getName() + " is missing field f_8146" + "8_"); } for (int i = 0; i < lootConditions.length; i++) { @@ -186,8 +193,8 @@ public class ForgeLootTableProvider extends LootTableProvider { } private boolean checkMatchTool(MatchTool lootCondition, Item expected) { - ItemPredicate predicate = ObfuscationReflectionHelper.getPrivateValue(MatchTool.class, lootCondition, "field_216014" + "_a"); - Item item = ObfuscationReflectionHelper.getPrivateValue(ItemPredicate.class, predicate, "field_192496" + "_b"); - return item != null && item.equals(expected); + ItemPredicate predicate = ObfuscationReflectionHelper.getPrivateValue(MatchTool.class, lootCondition, "f_8199" + "3_"); + Set items = ObfuscationReflectionHelper.getPrivateValue(ItemPredicate.class, predicate, "f_15142" + "7_"); + return items != null && items.contains(expected); } } diff --git a/src/main/java/net/minecraftforge/common/data/ForgeRecipeProvider.java b/src/main/java/net/minecraftforge/common/data/ForgeRecipeProvider.java index 02d324e199..aedc0ba12c 100644 --- a/src/main/java/net/minecraftforge/common/data/ForgeRecipeProvider.java +++ b/src/main/java/net/minecraftforge/common/data/ForgeRecipeProvider.java @@ -31,28 +31,28 @@ import java.util.function.Consumer; import com.google.gson.JsonObject; -import net.minecraft.block.Blocks; +import net.minecraft.world.level.block.Blocks; import net.minecraft.data.DataGenerator; -import net.minecraft.data.DirectoryCache; -import net.minecraft.data.IFinishedRecipe; -import net.minecraft.data.RecipeProvider; -import net.minecraft.data.ShapedRecipeBuilder; -import net.minecraft.data.ShapelessRecipeBuilder; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.item.crafting.Ingredient.IItemList; -import net.minecraft.item.crafting.Ingredient.TagList; -import net.minecraft.item.crafting.Ingredient.SingleItemList; -import net.minecraft.tags.ITag; -import net.minecraft.util.IItemProvider; -import net.minecraft.util.ResourceLocation; +import net.minecraft.data.HashCache; +import net.minecraft.data.recipes.FinishedRecipe; +import net.minecraft.data.recipes.RecipeProvider; +import net.minecraft.data.recipes.ShapedRecipeBuilder; +import net.minecraft.data.recipes.ShapelessRecipeBuilder; +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.minecraft.world.item.crafting.Ingredient.Value; +import net.minecraft.world.item.crafting.Ingredient.TagValue; +import net.minecraft.world.item.crafting.Ingredient.ItemValue; +import net.minecraft.tags.Tag; +import net.minecraft.world.level.ItemLike; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.common.Tags; -public class ForgeRecipeProvider extends RecipeProvider +public final class ForgeRecipeProvider extends RecipeProvider { - private Map> replacements = new HashMap<>(); + private Map> replacements = new HashMap<>(); private Set excludes = new HashSet<>(); public ForgeRecipeProvider(DataGenerator generatorIn) @@ -60,18 +60,18 @@ public class ForgeRecipeProvider extends RecipeProvider super(generatorIn); } - private void exclude(IItemProvider item) + private void exclude(ItemLike item) { excludes.add(item.asItem().getRegistryName()); } - private void replace(IItemProvider item, ITag tag) + private void replace(ItemLike item, Tag tag) { replacements.put(item.asItem(), tag); } @Override - protected void buildShapelessRecipes(Consumer consumer) + protected void buildCraftingRecipes(Consumer consumer) { replace(Items.STICK, Tags.Items.RODS_WOODEN); replace(Items.GOLD_INGOT, Tags.Items.INGOTS_GOLD); @@ -94,19 +94,19 @@ public class ForgeRecipeProvider extends RecipeProvider exclude(Blocks.COBBLESTONE_SLAB); exclude(Blocks.COBBLESTONE_WALL); - super.buildShapelessRecipes(vanilla -> { - IFinishedRecipe modified = enhance(vanilla); + super.buildCraftingRecipes(vanilla -> { + FinishedRecipe modified = enhance(vanilla); if (modified != null) consumer.accept(modified); }); } @Override - protected void saveAdvancement(DirectoryCache cache, JsonObject advancementJson, Path pathIn) { + protected void saveAdvancement(HashCache cache, JsonObject advancementJson, Path pathIn) { //NOOP - We dont replace any of the advancement things yet... } - private IFinishedRecipe enhance(IFinishedRecipe vanilla) + private FinishedRecipe enhance(FinishedRecipe vanilla) { if (vanilla instanceof ShapelessRecipeBuilder.Result) return enhance((ShapelessRecipeBuilder.Result)vanilla); @@ -115,7 +115,7 @@ public class ForgeRecipeProvider extends RecipeProvider return null; } - private IFinishedRecipe enhance(ShapelessRecipeBuilder.Result vanilla) + private FinishedRecipe enhance(ShapelessRecipeBuilder.Result vanilla) { List ingredients = getField(ShapelessRecipeBuilder.Result.class, vanilla, 4); boolean modified = false; @@ -131,7 +131,7 @@ public class ForgeRecipeProvider extends RecipeProvider return modified ? vanilla : null; } - private IFinishedRecipe enhance(ShapedRecipeBuilder.Result vanilla) + private FinishedRecipe enhance(ShapedRecipeBuilder.Result vanilla) { Map ingredients = getField(ShapedRecipeBuilder.Result.class, vanilla, 5); boolean modified = false; @@ -153,17 +153,17 @@ public class ForgeRecipeProvider extends RecipeProvider return null; boolean modified = false; - List items = new ArrayList<>(); - IItemList[] vanillaItems = getField(Ingredient.class, vanilla, 2); //This will probably crash between versions, if null fix index - for (IItemList entry : vanillaItems) + List items = new ArrayList<>(); + Value[] vanillaItems = getField(Ingredient.class, vanilla, 2); //This will probably crash between versions, if null fix index + for (Value entry : vanillaItems) { - if (entry instanceof SingleItemList) + if (entry instanceof ItemValue) { ItemStack stack = entry.getItems().stream().findFirst().orElse(ItemStack.EMPTY); - ITag replacement = replacements.get(stack.getItem()); + Tag replacement = replacements.get(stack.getItem()); if (replacement != null) { - items.add(new TagList(replacement)); + items.add(new TagValue(replacement)); modified = true; } else diff --git a/src/main/java/net/minecraftforge/common/data/ForgeRegistryTagsProvider.java b/src/main/java/net/minecraftforge/common/data/ForgeRegistryTagsProvider.java index 6bd88d21c9..16e84bec1b 100644 --- a/src/main/java/net/minecraftforge/common/data/ForgeRegistryTagsProvider.java +++ b/src/main/java/net/minecraftforge/common/data/ForgeRegistryTagsProvider.java @@ -25,9 +25,9 @@ import java.nio.file.Path; import java.util.Map; import javax.annotation.Nullable; import net.minecraft.data.DataGenerator; -import net.minecraft.data.TagsProvider; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.registry.Registry; +import net.minecraft.data.tags.TagsProvider; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.Registry; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.ForgeRegistry; import net.minecraftforge.registries.GameData; diff --git a/src/main/java/net/minecraftforge/common/data/GlobalLootModifierProvider.java b/src/main/java/net/minecraftforge/common/data/GlobalLootModifierProvider.java index db28509bc3..254b8ceece 100644 --- a/src/main/java/net/minecraftforge/common/data/GlobalLootModifierProvider.java +++ b/src/main/java/net/minecraftforge/common/data/GlobalLootModifierProvider.java @@ -24,13 +24,12 @@ import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; import cpw.mods.modlauncher.api.LamdbaExceptionUtils; import net.minecraft.data.DataGenerator; -import net.minecraft.data.DirectoryCache; -import net.minecraft.data.IDataProvider; -import net.minecraft.util.ResourceLocation; +import net.minecraft.data.HashCache; +import net.minecraft.data.DataProvider; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Tuple; import net.minecraftforge.common.loot.GlobalLootModifierSerializer; import net.minecraftforge.common.loot.IGlobalLootModifier; -import net.minecraftforge.common.loot.LootModifier; import java.io.IOException; import java.nio.file.Path; @@ -41,11 +40,11 @@ import java.util.Map; import java.util.stream.Collectors; /** - * Provider for forge's GlobalLootModifier system. See {@link LootModifier} and {@link GlobalLootModifierSerializer}. + * Provider for forge's GlobalLootModifier system. See {@link net.minecraftforge.common.loot.LootModifier} and {@link GlobalLootModifierSerializer}. * * This provider only requires implementing {@link #start()} and calling {@link #add} from it. */ -public abstract class GlobalLootModifierProvider implements IDataProvider +public abstract class GlobalLootModifierProvider implements DataProvider { private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create(); private final DataGenerator gen; @@ -73,7 +72,7 @@ public abstract class GlobalLootModifierProvider implements IDataProvider protected abstract void start(); @Override - public void run(DirectoryCache cache) throws IOException + public void run(HashCache cache) throws IOException { start(); @@ -89,14 +88,14 @@ public abstract class GlobalLootModifierProvider implements IDataProvider JsonObject json = pair.getB(); json.addProperty("type", pair.getA().getRegistryName().toString()); - IDataProvider.save(GSON, cache, json, modifierPath); + DataProvider.save(GSON, cache, json, modifierPath); })); JsonObject forgeJson = new JsonObject(); forgeJson.addProperty("replace", this.replace); forgeJson.add("entries", GSON.toJsonTree(entries.stream().map(ResourceLocation::toString).collect(Collectors.toList()))); - IDataProvider.save(GSON, cache, forgeJson, forgePath); + DataProvider.save(GSON, cache, forgeJson, forgePath); } /** diff --git a/src/main/java/net/minecraftforge/common/data/LanguageProvider.java b/src/main/java/net/minecraftforge/common/data/LanguageProvider.java index 413248ce18..049fd06b1d 100644 --- a/src/main/java/net/minecraftforge/common/data/LanguageProvider.java +++ b/src/main/java/net/minecraftforge/common/data/LanguageProvider.java @@ -33,19 +33,18 @@ import org.apache.commons.lang3.text.translate.JavaUnicodeEscaper; import com.google.gson.Gson; import com.google.gson.GsonBuilder; -import net.minecraft.block.Block; +import net.minecraft.world.level.block.Block; import net.minecraft.data.DataGenerator; -import net.minecraft.data.DirectoryCache; -import net.minecraft.data.IDataProvider; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.entity.EntityType; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.potion.Effect; -import net.minecraft.world.biome.Biome; +import net.minecraft.data.HashCache; +import net.minecraft.data.DataProvider; +import net.minecraft.world.item.enchantment.Enchantment; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.effect.MobEffect; @SuppressWarnings("deprecation") -public abstract class LanguageProvider implements IDataProvider { +public abstract class LanguageProvider implements DataProvider { private static final Gson GSON = (new GsonBuilder()).setPrettyPrinting().disableHtmlEscaping().create(); private final Map data = new TreeMap<>(); private final DataGenerator gen; @@ -61,7 +60,7 @@ public abstract class LanguageProvider implements IDataProvider { protected abstract void addTranslations(); @Override - public void run(DirectoryCache cache) throws IOException { + public void run(HashCache cache) throws IOException { addTranslations(); if (!data.isEmpty()) save(cache, data, this.gen.getOutputFolder().resolve("assets/" + modid + "/lang/" + locale + ".json")); @@ -72,10 +71,10 @@ public abstract class LanguageProvider implements IDataProvider { return "Languages: " + locale; } - private void save(DirectoryCache cache, Object object, Path target) throws IOException { + private void save(HashCache cache, Object object, Path target) throws IOException { String data = GSON.toJson(object); data = JavaUnicodeEscaper.outsideOf(0, 0x7f).translate(data); // Escape unicode after the fact so that it's not double escaped by GSON - String hash = IDataProvider.SHA1.hashUnencodedChars(data).toString(); + String hash = DataProvider.SHA1.hashUnencodedChars(data).toString(); if (!Objects.equals(cache.getHash(target), hash) || !Files.exists(target)) { Files.createDirectories(target.getParent()); @@ -129,11 +128,11 @@ public abstract class LanguageProvider implements IDataProvider { } */ - public void addEffect(Supplier key, String name) { + public void addEffect(Supplier key, String name) { add(key.get(), name); } - public void add(Effect key, String name) { + public void add(MobEffect key, String name) { add(key.getDescriptionId(), name); } diff --git a/src/main/java/net/minecraftforge/common/data/SoundDefinition.java b/src/main/java/net/minecraftforge/common/data/SoundDefinition.java index 94c265482b..d2b0c186df 100644 --- a/src/main/java/net/minecraftforge/common/data/SoundDefinition.java +++ b/src/main/java/net/minecraftforge/common/data/SoundDefinition.java @@ -23,7 +23,7 @@ import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; import javax.annotation.Nullable; import java.util.ArrayList; diff --git a/src/main/java/net/minecraftforge/common/data/SoundDefinitionsProvider.java b/src/main/java/net/minecraftforge/common/data/SoundDefinitionsProvider.java index b21758e845..c8b42dca36 100644 --- a/src/main/java/net/minecraftforge/common/data/SoundDefinitionsProvider.java +++ b/src/main/java/net/minecraftforge/common/data/SoundDefinitionsProvider.java @@ -23,11 +23,11 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; import net.minecraft.data.DataGenerator; -import net.minecraft.data.DirectoryCache; -import net.minecraft.data.IDataProvider; -import net.minecraft.resources.ResourcePackType; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.SoundEvent; +import net.minecraft.data.HashCache; +import net.minecraft.data.DataProvider; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.packs.PackType; +import net.minecraft.sounds.SoundEvent; import net.minecraftforge.registries.ForgeRegistries; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -44,7 +44,7 @@ import java.util.stream.Collectors; * Data provider for the {@code sounds.json} file, which identifies sound definitions * for the various sound events in Minecraft. */ -public abstract class SoundDefinitionsProvider implements IDataProvider +public abstract class SoundDefinitionsProvider implements DataProvider { private static final Logger LOGGER = LogManager.getLogger(); private static final Gson GSON = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create(); @@ -74,7 +74,7 @@ public abstract class SoundDefinitionsProvider implements IDataProvider public abstract void registerSounds(); @Override - public void run(DirectoryCache cache) throws IOException + public void run(HashCache cache) throws IOException { this.sounds.clear(); this.registerSounds(); @@ -249,7 +249,7 @@ public abstract class SoundDefinitionsProvider implements IDataProvider private boolean validateSound(final String soundName, final ResourceLocation name) { - final boolean valid = this.helper.exists(name, ResourcePackType.CLIENT_RESOURCES, ".ogg", "sounds"); + final boolean valid = this.helper.exists(name, PackType.CLIENT_RESOURCES, ".ogg", "sounds"); if (!valid) { final String path = name.getNamespace() + ":sounds/" + name.getPath() + ".ogg"; @@ -268,9 +268,9 @@ public abstract class SoundDefinitionsProvider implements IDataProvider return valid; } - private void save(final DirectoryCache cache, final Path targetFile) throws IOException + private void save(final HashCache cache, final Path targetFile) throws IOException { - IDataProvider.save(GSON, cache, this.mapToJson(this.sounds), targetFile); + DataProvider.save(GSON, cache, this.mapToJson(this.sounds), targetFile); } private JsonObject mapToJson(final Map map) diff --git a/src/main/java/net/minecraftforge/common/data/package-info.java b/src/main/java/net/minecraftforge/common/data/package-info.java index de844c255f..f4ba9e900c 100644 --- a/src/main/java/net/minecraftforge/common/data/package-info.java +++ b/src/main/java/net/minecraftforge/common/data/package-info.java @@ -21,5 +21,5 @@ @MethodsReturnNonnullByDefault package net.minecraftforge.common.data; -import mcp.MethodsReturnNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeEntityMinecart.java b/src/main/java/net/minecraftforge/common/extensions/IForgeAbstractMinecart.java similarity index 70% rename from src/main/java/net/minecraftforge/common/extensions/IForgeEntityMinecart.java rename to src/main/java/net/minecraftforge/common/extensions/IForgeAbstractMinecart.java index da1fdd1681..6ce8e3f6d1 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeEntityMinecart.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeAbstractMinecart.java @@ -19,34 +19,21 @@ package net.minecraftforge.common.extensions; -import net.minecraft.entity.item.minecart.AbstractMinecartEntity; -import net.minecraft.item.Items; -import net.minecraft.item.ItemStack; +import net.minecraft.world.entity.vehicle.AbstractMinecart; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.ItemStack; import net.minecraft.tags.BlockTags; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraftforge.common.IMinecartCollisionHandler; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; -public interface IForgeEntityMinecart +public interface IForgeAbstractMinecart { public static float DEFAULT_MAX_SPEED_AIR_LATERAL = 0.4f; public static float DEFAULT_MAX_SPEED_AIR_VERTICAL = -1.0f; public static double DEFAULT_AIR_DRAG = 0.95f; - /** TODO: Remove 1.17 */ - public static IMinecartCollisionHandler COLLISIONS = null; - default AbstractMinecartEntity getMinecart() { - return (AbstractMinecartEntity)this; - } - - /** - * Gets the current global Minecart Collision handler if none - * is registered, returns null - * TODO: remove 1.17 - * @return The collision handler or null - */ - default IMinecartCollisionHandler getCollisionHandler() { - return COLLISIONS; + private AbstractMinecart self() { + return (AbstractMinecart)this; } /** @@ -54,11 +41,11 @@ public interface IForgeEntityMinecart */ default BlockPos getCurrentRailPosition() { - int x = MathHelper.floor(getMinecart().getX()); - int y = MathHelper.floor(getMinecart().getY()); - int z = MathHelper.floor(getMinecart().getZ()); + int x = Mth.floor(self().getX()); + int y = Mth.floor(self().getY()); + int z = Mth.floor(self().getZ()); BlockPos pos = new BlockPos(x, y, z); - if (getMinecart().level.getBlockState(pos.below()).is(BlockTags.RAILS)) pos = pos.below(); + if (self().level.getBlockState(pos.below()).is(BlockTags.RAILS)) pos = pos.below(); return pos; } @@ -78,15 +65,7 @@ public interface IForgeEntityMinecart */ default ItemStack getCartItem() { - switch (getMinecart().getMinecartType()) - { - case FURNACE: return new ItemStack(Items.FURNACE_MINECART); - case CHEST: return new ItemStack(Items.CHEST_MINECART); - case TNT: return new ItemStack(Items.TNT_MINECART); - case HOPPER: return new ItemStack(Items.HOPPER_MINECART); - case COMMAND_BLOCK: return new ItemStack(Items.COMMAND_BLOCK_MINECART); - default: return new ItemStack(Items.MINECART); - } + return new ItemStack(Items.MINECART); } /** @@ -116,7 +95,7 @@ public interface IForgeEntityMinecart * @return True if powered. */ default boolean isPoweredCart() { - return getMinecart().getMinecartType() == AbstractMinecartEntity.Type.FURNACE; + return self().getMinecartType() == AbstractMinecart.Type.FURNACE; } /** @@ -124,7 +103,7 @@ public interface IForgeEntityMinecart * @return True if this cart can be ridden. */ default boolean canBeRidden() { - return getMinecart().getMinecartType() == AbstractMinecartEntity.Type.RIDEABLE; + return self().getMinecartType() == AbstractMinecart.Type.RIDEABLE; } /** diff --git a/src/main/java/net/minecraftforge/common/extensions/IAbstractRailBlock.java b/src/main/java/net/minecraftforge/common/extensions/IForgeBaseRailBlock.java similarity index 70% rename from src/main/java/net/minecraftforge/common/extensions/IAbstractRailBlock.java rename to src/main/java/net/minecraftforge/common/extensions/IForgeBaseRailBlock.java index 42c9f33be1..59c81fe08f 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IAbstractRailBlock.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeBaseRailBlock.java @@ -19,24 +19,18 @@ package net.minecraftforge.common.extensions; -import net.minecraft.block.AbstractBlock; -import net.minecraft.block.BlockState; -import net.minecraft.entity.item.minecart.AbstractMinecartEntity; -import net.minecraft.state.properties.RailShape; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.vehicle.AbstractMinecart; +import net.minecraft.world.level.block.state.properties.RailShape; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; import javax.annotation.Nullable; -public interface IAbstractRailBlock +public interface IForgeBaseRailBlock { - default AbstractBlock getAbstractBlock() - { - return (AbstractBlock)this; - } - /** * Return true if the rail can make corners. * Used by placement logic. @@ -44,7 +38,7 @@ public interface IAbstractRailBlock * @param pos Block's position in world * @return True if the rail can make corners. */ - boolean isFlexibleRail(BlockState state, IBlockReader world, BlockPos pos); + boolean isFlexibleRail(BlockState state, BlockGetter world, BlockPos pos); /** * Returns true if the rail can make up and down slopes. @@ -53,7 +47,7 @@ public interface IAbstractRailBlock * @param pos Block's position in world * @return True if the rail can make slopes. */ - default boolean canMakeSlopes(BlockState state, IBlockReader world, BlockPos pos) + default boolean canMakeSlopes(BlockState state, BlockGetter world, BlockPos pos) { return true; } @@ -70,7 +64,7 @@ public interface IAbstractRailBlock * @param cart The cart asking for the metadata, null if it is not called by EntityMinecart. * @return The direction. */ - RailShape getRailDirection(BlockState state, IBlockReader world, BlockPos pos, @Nullable AbstractMinecartEntity cart); + RailShape getRailDirection(BlockState state, BlockGetter world, BlockPos pos, @Nullable AbstractMinecart cart); /** * Returns the max speed of the rail at the specified position. @@ -79,7 +73,7 @@ public interface IAbstractRailBlock * @param pos Block's position in world * @return The max speed of the current rail. */ - default float getRailMaxSpeed(BlockState state, World world, BlockPos pos, net.minecraft.entity.item.minecart.AbstractMinecartEntity cart) + default float getRailMaxSpeed(BlockState state, Level world, BlockPos pos, AbstractMinecart cart) { return 0.4f; } @@ -91,5 +85,5 @@ public interface IAbstractRailBlock * @param cart The cart on the rail. * @param pos Block's position in world */ - default void onMinecartPass(BlockState state, World world, BlockPos pos, net.minecraft.entity.item.minecart.AbstractMinecartEntity cart){} + default void onMinecartPass(BlockState state, Level world, BlockPos pos, AbstractMinecart cart){} } diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeBlock.java b/src/main/java/net/minecraftforge/common/extensions/IForgeBlock.java index 485c42e7f1..845c9c235e 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeBlock.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeBlock.java @@ -23,48 +23,58 @@ import java.util.Optional; import java.util.Set; import javax.annotation.Nullable; -import net.minecraft.block.*; -import net.minecraft.block.material.Material; -import net.minecraft.client.particle.ParticleManager; -import net.minecraft.client.renderer.ActiveRenderInfo; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.entity.Entity; -import net.minecraft.entity.MobEntity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.EntitySpawnPlacementRegistry; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.boss.dragon.EnderDragonEntity; -import net.minecraft.entity.boss.WitherEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.projectile.WitherSkullEntity; -import net.minecraft.fluid.FluidState; -import net.minecraft.potion.Effects; -import net.minecraft.item.AxeItem; -import net.minecraft.item.HoeItem; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ShovelItem; -import net.minecraft.pathfinding.PathNodeType; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.Mob; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.SpawnPlacements; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.boss.enderdragon.EnderDragon; +import net.minecraft.world.entity.boss.wither.WitherBoss; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.projectile.WitherSkull; +import net.minecraft.world.level.block.LadderBlock; +import net.minecraft.world.level.block.TrapDoorBlock; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.item.AxeItem; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.ShovelItem; +import net.minecraft.world.level.pathfinder.BlockPathTypes; import net.minecraft.tags.BlockTags; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.Rotation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.*; -import net.minecraft.world.server.ServerWorld; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.core.Direction; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.Vec3; +import net.minecraft.server.level.ServerLevel; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.IPlantable; import net.minecraftforge.common.Tags; import net.minecraftforge.common.ToolType; +import net.minecraft.world.level.BlockAndTintGetter; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Explosion; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.block.BeaconBeamBlock; +import net.minecraft.world.level.block.BedBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.FarmBlock; +import net.minecraft.world.level.block.FenceGateBlock; +import net.minecraft.world.level.block.FireBlock; +import net.minecraft.world.level.block.HalfTransparentBlock; +import net.minecraft.world.level.block.HorizontalDirectionalBlock; +import net.minecraft.world.level.block.LeavesBlock; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.state.BlockState; + @SuppressWarnings("deprecation") public interface IForgeBlock { - default Block getBlock() + private Block self() { return (Block) this; } @@ -74,9 +84,9 @@ public interface IForgeBlock * between 0 and 1. *

* Note that entities may reduce slipperiness by a certain factor of their own; - * for {@link net.minecraft.entity.LivingEntity}, this is {@code .91}. - * {@link net.minecraft.entity.item.ItemEntity} uses {@code .98}, and - * {@link net.minecraft.entity.projectile.FishingBobberEntity} uses {@code .92}. + * for {@link net.minecraft.world.entity.LivingEntity}, this is {@code .91}. + * {@link net.minecraft.world.entity.item.ItemEntity} uses {@code .98}, and + * {@link net.minecraft.world.entity.projectile.FishingHook} uses {@code .92}. * * @param state state of the block * @param world the world @@ -84,9 +94,9 @@ public interface IForgeBlock * @param entity the entity in question * @return the factor by which the entity's motion should be multiplied */ - default float getSlipperiness(BlockState state, IWorldReader world, BlockPos pos, @Nullable Entity entity) + default float getFriction(BlockState state, LevelReader world, BlockPos pos, @Nullable Entity entity) { - return getBlock().getFriction(); + return self().getFriction(); } /** @@ -97,7 +107,7 @@ public interface IForgeBlock * @param pos * @return The light value */ - default int getLightValue(BlockState state, IBlockReader world, BlockPos pos) + default int getLightEmission(BlockState state, BlockGetter world, BlockPos pos) { return state.getLightEmission(); } @@ -111,9 +121,9 @@ public interface IForgeBlock * @param entity The entity trying to use the ladder, CAN be null. * @return True if the block should act like a ladder */ - default boolean isLadder(BlockState state, IWorldReader world, BlockPos pos, LivingEntity entity) + default boolean isLadder(BlockState state, LevelReader world, BlockPos pos, LivingEntity entity) { - return state.getBlock().is(BlockTags.CLIMBABLE); + return state.is(BlockTags.CLIMBABLE); } /** @@ -125,7 +135,7 @@ public interface IForgeBlock * @param trapdoorState The current state of the open trapdoor above * @return True if the block should act like a ladder */ - default boolean makesOpenTrapdoorAboveClimbable(BlockState state, IWorldReader world, BlockPos pos, BlockState trapdoorState) + default boolean makesOpenTrapdoorAboveClimbable(BlockState state, LevelReader world, BlockPos pos, BlockState trapdoorState) { return state.getBlock() instanceof LadderBlock && state.getValue(LadderBlock.FACING) == trapdoorState.getValue(TrapDoorBlock.FACING); } @@ -138,43 +148,11 @@ public interface IForgeBlock * @param pos Block position in world * @return True if the block should deal damage */ - default boolean isBurning(BlockState state, IBlockReader world, BlockPos pos) + default boolean isBurning(BlockState state, BlockGetter world, BlockPos pos) { return this == Blocks.FIRE || this == Blocks.LAVA; } - /** - * Called throughout the code as a replacement for block instanceof BlockContainer - * Moving this to the Block base class allows for mods that wish to extend vanilla - * blocks, and also want to have a tile entity on that block, may. - * - * Return true from this function to specify this block has a tile entity. - * - * @param state State of the current block - * @return True if block has a tile entity, false otherwise - */ - default boolean hasTileEntity(BlockState state) - { - return this instanceof ITileEntityProvider; - } - - /** - * Called throughout the code as a replacement for ITileEntityProvider.createNewTileEntity - * Return the same thing you would from that function. - * This will fall back to ITileEntityProvider.createNewTileEntity(World) if this block is a ITileEntityProvider - * - * @param state The state of the current block - * @param world The world to create the TE in - * @return A instance of a class extending TileEntity - */ - @Nullable - default TileEntity createTileEntity(BlockState state, IBlockReader world) - { - if (getBlock() instanceof ITileEntityProvider) - return ((ITileEntityProvider)getBlock()).newBlockEntity(world); - return null; - } - /** * Determines if the player can harvest this block, obtaining it's drops when the block is destroyed. * @@ -183,7 +161,7 @@ public interface IForgeBlock * @param player The player damaging the block * @return True to spawn the drops */ - default public boolean canHarvestBlock(BlockState state, IBlockReader world, BlockPos pos, PlayerEntity player) + default public boolean canHarvestBlock(BlockState state, BlockGetter world, BlockPos pos, Player player) { return ForgeHooks.canHarvestBlock(state, player, world, pos); } @@ -208,9 +186,9 @@ public interface IForgeBlock * @param fluid The current fluid state at current position * @return True if the block is actually destroyed. */ - default boolean removedByPlayer(BlockState state, World world, BlockPos pos, PlayerEntity player, boolean willHarvest, FluidState fluid) + default boolean removedByPlayer(BlockState state, Level world, BlockPos pos, Player player, boolean willHarvest, FluidState fluid) { - getBlock().playerWillDestroy(world, pos, state, player); + self().playerWillDestroy(world, pos, state, player); return world.setBlock(pos, fluid.createLegacyBlock(), world.isClientSide ? 11 : 3); } @@ -225,9 +203,9 @@ public interface IForgeBlock * @param player The player or camera entity, null in some cases. * @return True to treat this as a bed */ - default boolean isBed(BlockState state, IBlockReader world, BlockPos pos, @Nullable Entity player) + default boolean isBed(BlockState state, BlockGetter world, BlockPos pos, @Nullable Entity player) { - return this.getBlock() instanceof BedBlock; //TODO: Forge: Keep isBed function? + return self() instanceof BedBlock; //TODO: Forge: Keep isBed function? } /** @@ -235,17 +213,18 @@ public interface IForgeBlock * respawning at this block. * * @param state The current state + * @param type The entity type used when checking if a dismount blockstate is dangerous. Currently always PLAYER. * @param world The current world * @param pos Block position in world * @param orientation The angle the entity had when setting the respawn point * @param entity The entity respawning, often null * @return The spawn position or the empty optional if respawning here is not possible */ - default Optional getRespawnPosition(BlockState state, EntityType type, IWorldReader world, BlockPos pos, float orientation, @Nullable LivingEntity entity) + default Optional getRespawnPosition(BlockState state, EntityType type, LevelReader world, BlockPos pos, float orientation, @Nullable LivingEntity entity) { - if (isBed(state, world, pos, entity) && world instanceof World && BedBlock.canSetSpawn((World) world)) + if (isBed(state, world, pos, entity) && world instanceof Level level && BedBlock.canSetSpawn(level)) { - return getBedSpawnPosition(type, state, world, pos, orientation, entity); + return BedBlock.findStandUpPosition(type, world, pos, orientation); } return Optional.empty(); } @@ -260,44 +239,21 @@ public interface IForgeBlock * @param type The Mob Category Type * @return True to allow a mob of the specified category to spawn, false to prevent it. */ - default boolean canCreatureSpawn(BlockState state, IBlockReader world, BlockPos pos, EntitySpawnPlacementRegistry.PlacementType type, EntityType entityType) + default boolean canCreatureSpawn(BlockState state, BlockGetter world, BlockPos pos, SpawnPlacements.Type type, EntityType entityType) { return state.isValidSpawn(world, pos, entityType); } - /** - * Returns the position that the sleeper is moved to upon - * waking up, or respawning at the bed. - * - * @param state The current state - * @param world The current world - * @param pos Block position in world - * @param orientation The direction the entity is facing while getting into bed. - * @param sleeper The sleeper or camera entity, null in some cases. - * @return The spawn position - * @deprecated use {@link #getRespawnPosition(BlockState, EntityType, IWorldReader, BlockPos, float, LivingEntity)} - */ - @Deprecated - default Optional getBedSpawnPosition(EntityType entityType, BlockState state, IWorldReader world, BlockPos pos, float orientation, @Nullable LivingEntity sleeper) - { - if (world instanceof World) - { - return BedBlock.findStandUpPosition(entityType, world, pos, orientation); - } - - return Optional.empty(); - } - /** * Called when a user either starts or stops sleeping in the bed. - * @param state * + * @param state * @param world The current world * @param pos Block position in world * @param sleeper The sleeper or camera entity, null in some cases. * @param occupied True if we are occupying the bed, or false if they are stopping use of the bed */ - default void setBedOccupied(BlockState state, World world, BlockPos pos, LivingEntity sleeper, boolean occupied) + default void setBedOccupied(BlockState state, Level world, BlockPos pos, LivingEntity sleeper, boolean occupied) { world.setBlock(pos, state.setValue(BedBlock.OCCUPIED, occupied), 3); } @@ -311,52 +267,9 @@ public interface IForgeBlock * @param pos Block position in world * @return Bed direction */ - default Direction getBedDirection(BlockState state, IWorldReader world, BlockPos pos) + default Direction getBedDirection(BlockState state, LevelReader world, BlockPos pos) { - return state.getValue(HorizontalBlock.FACING); - } - - /** - * Determines this block should be treated as an air block - * by the rest of the code. This method is primarily - * useful for creating pure logic-blocks that will be invisible - * to the player and otherwise interact as air would. - * - * @param state The current state - * @param world The current world - * @param pos Block position in world - * @return True if the block considered air - */ - default boolean isAir(BlockState state, IBlockReader world, BlockPos pos) - { - return state.getMaterial() == Material.AIR; - } - - /** - * Used during tree growth to determine if newly generated leaves can replace this block. - * - * @param state The current state - * @param world The current world - * @param pos Block position in world - * @return true if this block can be replaced by growing leaves. - */ - default boolean canBeReplacedByLeaves(BlockState state, IWorldReader world, BlockPos pos) - { - return isAir(state, world, pos) || state.is(BlockTags.LEAVES); - } - - /** - * Used during tree growth to determine if newly generated logs can replace this block. - * - * @param state The current state - * @param world The current world - * @param pos Block position in world - * @return true if this block can be replaced by growing leaves. - */ - default boolean canBeReplacedByLogs(BlockState state, IWorldReader world, BlockPos pos) - { - return (isAir(state, world, pos) || state.is(BlockTags.LEAVES)) || this == Blocks.GRASS_BLOCK || state.is(Tags.Blocks.DIRT) - || getBlock().is(BlockTags.LOGS) || getBlock().is(BlockTags.SAPLINGS) || this == Blocks.VINE; + return state.getValue(HorizontalDirectionalBlock.FACING); } /** @@ -367,24 +280,9 @@ public interface IForgeBlock * @param explosion The explosion * @return The amount of the explosion absorbed. */ - default float getExplosionResistance(BlockState state, IBlockReader world, BlockPos pos, Explosion explosion) + default float getExplosionResistance(BlockState state, BlockGetter world, BlockPos pos, Explosion explosion) { - return this.getBlock().getExplosionResistance(); - } - - /** - * Determine if this block can make a redstone connection on the side provided, - * Useful to control which sides are inputs and outputs for redstone wires. - * - * @param state The current state - * @param world The current world - * @param pos Block position in world - * @param side The side that is trying to make the connection, CAN BE NULL - * @return True to make the connection - */ - default boolean canConnectRedstone(BlockState state, IBlockReader world, BlockPos pos, @Nullable Direction side) - { - return state.isSignalSource() && side != null; + return self().getExplosionResistance(); } /** @@ -394,9 +292,9 @@ public interface IForgeBlock * @param target The full target the player is looking at * @return A ItemStack to add to the player's inventory, empty itemstack if nothing should be added. */ - default ItemStack getPickBlock(BlockState state, RayTraceResult target, IBlockReader world, BlockPos pos, PlayerEntity player) + default ItemStack getPickBlock(BlockState state, HitResult target, BlockGetter world, BlockPos pos, Player player) { - return this.getBlock().getCloneItemStack(world, pos, state); + return self().getCloneItemStack(world, pos, state); } /** @@ -411,14 +309,14 @@ public interface IForgeBlock * @param numberOfParticles That vanilla world have spawned * @return True to prevent vanilla landing particles from spawning */ - default boolean addLandingEffects(BlockState state1, ServerWorld worldserver, BlockPos pos, BlockState state2, LivingEntity entity, int numberOfParticles) + default boolean addLandingEffects(BlockState state1, ServerLevel worldserver, BlockPos pos, BlockState state2, LivingEntity entity, int numberOfParticles) { return false; } /** * Allows a block to override the standard vanilla running particles. - * This is called from {@link Entity#handleRunningEffect} and is called both, + * This is called from Entity.spawnSprintParticle and is called both, * Client and server side, it's up to the implementor to client check / server check. * By default vanilla spawns particles only on the client and the server methods no-op. * @@ -428,42 +326,7 @@ public interface IForgeBlock * @param entity The entity running on the block. * @return True to prevent vanilla running particles from spawning. */ - default boolean addRunningEffects(BlockState state, World world, BlockPos pos, Entity entity) - { - return false; - } - - /** - * Spawn a digging particle effect in the world, this is a wrapper - * around EffectRenderer.addBlockHitEffects to allow the block more - * control over the particles. Useful when you have entirely different - * texture sheets for different sides/locations in the world. - * - * @param state The current state - * @param world The current world - * @param target The target the player is looking at {x/y/z/side/sub} - * @param manager A reference to the current particle manager. - * @return True to prevent vanilla digging particles form spawning. - */ - @OnlyIn(Dist.CLIENT) - default boolean addHitEffects(BlockState state, World world, RayTraceResult target, ParticleManager manager) - { - return false; - } - - /** - * Spawn particles for when the block is destroyed. Due to the nature - * of how this is invoked, the x/y/z locations are not always guaranteed - * to host your block. So be sure to do proper sanity checks before assuming - * that the location is this block. - * - * @param world The current world - * @param pos Position to spawn the particle - * @param manager A reference to the current particle manager. - * @return True to prevent vanilla break particles from spawning. - */ - @OnlyIn(Dist.CLIENT) - default boolean addDestroyEffects(BlockState state, World world, BlockPos pos, ParticleManager manager) + default boolean addRunningEffects(BlockState state, Level world, BlockPos pos, Entity entity) { return false; } @@ -486,28 +349,7 @@ public interface IForgeBlock * @param plantable The plant that wants to check * @return True to allow the plant to be planted/stay. */ - boolean canSustainPlant(BlockState state, IBlockReader world, BlockPos pos, Direction facing, IPlantable plantable); - - /** - * Called when a plant grows on this block, only implemented for saplings using the WorldGen*Trees classes right now. - * Modder may implement this for custom plants. - * This does not use ForgeDirection, because large/huge trees can be located in non-representable direction, - * so the source location is specified. - * Currently this just changes the block to dirt if it was grass. - * - * Note: This happens DURING the generation, the generation may not be complete when this is called. - * - * @param state The current state - * @param world Current world - * @param pos Block position in world - * @param source Source plant's position in world - */ - @Deprecated//TODO - 1.17: Remove (unused) - default void onPlantGrow(BlockState state, IWorld world, BlockPos pos, BlockPos source) - { - if (state.is(Tags.Blocks.DIRT)) - world.setBlock(pos, Blocks.DIRT.defaultBlockState(), 2); - } + boolean canSustainPlant(BlockState state, BlockGetter world, BlockPos pos, Direction facing, IPlantable plantable); /** * Checks if this soil is fertile, typically this means that growth rates @@ -518,10 +360,10 @@ public interface IForgeBlock * @param pos Block position in world * @return True if the soil should be considered fertile. */ - default boolean isFertile(BlockState state, IBlockReader world, BlockPos pos) + default boolean isFertile(BlockState state, BlockGetter world, BlockPos pos) { if (state.is(Blocks.FARMLAND)) - return state.getValue(FarmlandBlock.MOISTURE) > 0; + return state.getValue(FarmBlock.MOISTURE) > 0; return false; } @@ -534,7 +376,7 @@ public interface IForgeBlock * @param conduit Conduit position in world * @return True, to support the conduit, and make it active with this block. */ - default boolean isConduitFrame(BlockState state, IWorldReader world, BlockPos pos, BlockPos conduit) + default boolean isConduitFrame(BlockState state, LevelReader world, BlockPos pos, BlockPos conduit) { return state.getBlock() == Blocks.PRISMARINE || state.getBlock() == Blocks.PRISMARINE_BRICKS || @@ -550,7 +392,7 @@ public interface IForgeBlock * @param pos Block position in world * @return True, to support being part of a nether portal frame, false otherwise. */ - default boolean isPortalFrame(BlockState state, IBlockReader world, BlockPos pos) + default boolean isPortalFrame(BlockState state, BlockGetter world, BlockPos pos) { return state.is(Blocks.OBSIDIAN); } @@ -564,12 +406,12 @@ public interface IForgeBlock * @param fortune * @return Amount of XP from breaking this block. */ - default int getExpDrop(BlockState state, IWorldReader world, BlockPos pos, int fortune, int silktouch) + default int getExpDrop(BlockState state, LevelReader world, BlockPos pos, int fortune, int silktouch) { return 0; } - default BlockState rotate(BlockState state, IWorld world, BlockPos pos, Rotation direction) + default BlockState rotate(BlockState state, LevelAccessor world, BlockPos pos, Rotation direction) { return state.rotate(direction); } @@ -580,7 +422,7 @@ public interface IForgeBlock * @param pos Block position in world * @return The amount of enchanting power this block produces. */ - default float getEnchantPowerBonus(BlockState state, IWorldReader world, BlockPos pos) + default float getEnchantPowerBonus(BlockState state, LevelReader world, BlockPos pos) { return state.is(Blocks.BOOKSHELF) ? 1: 0; } @@ -591,19 +433,7 @@ public interface IForgeBlock * @param pos Block position in world * @param neighbor Block position of neighbor */ - default void onNeighborChange(BlockState state, IWorldReader world, BlockPos pos, BlockPos neighbor){} - - /** - * Called on an Observer block whenever an update for an Observer is received. - * - * @param observerState The Observer block's state. - * @param world The current world. - * @param observerPos The Observer block's position. - * @param changedBlock The updated block. - * @param changedBlockPos The updated block's position. - */ - @Deprecated//TODO - 1.17: Remove (unused) - default void observedNeighborChange(BlockState observerState, World world, BlockPos observerPos, Block changedBlock, BlockPos changedBlockPos){} + default void onNeighborChange(BlockState state, LevelReader world, BlockPos pos, BlockPos neighbor){} /** * Called to determine whether to allow the a block to handle its own indirect power rather than using the default rules. @@ -612,7 +442,7 @@ public interface IForgeBlock * @param side The INPUT side of the block to be powered - ie the opposite of this block's output side * @return Whether Block#isProvidingWeakPower should be called when determining indirect power */ - default boolean shouldCheckWeakPower(BlockState state, IWorldReader world, BlockPos pos, Direction side) + default boolean shouldCheckWeakPower(BlockState state, LevelReader world, BlockPos pos, Direction side) { return state.isRedstoneConductor(world, pos); } @@ -626,7 +456,7 @@ public interface IForgeBlock * @param pos Block position in world * @return true To be notified of changes */ - default boolean getWeakChanges(BlockState state, IWorldReader world, BlockPos pos) + default boolean getWeakChanges(BlockState state, LevelReader world, BlockPos pos) { return false; } @@ -651,7 +481,7 @@ public interface IForgeBlock */ default boolean isToolEffective(BlockState state, ToolType tool) { - if (tool == ToolType.PICKAXE && (this.getBlock() == Blocks.REDSTONE_ORE || this.getBlock() == Blocks.REDSTONE_LAMP || this.getBlock() == Blocks.OBSIDIAN)) + if (tool == ToolType.PICKAXE && (self() == Blocks.REDSTONE_ORE || self() == Blocks.REDSTONE_LAMP || self() == Blocks.OBSIDIAN)) return false; return tool == getHarvestTool(state); } @@ -664,9 +494,9 @@ public interface IForgeBlock * @param entity The entity that is breaking/stepping on/placing/hitting/falling on this block, or null if no entity is in this context * @return A SoundType to use */ - default SoundType getSoundType(BlockState state, IWorldReader world, BlockPos pos, @Nullable Entity entity) + default SoundType getSoundType(BlockState state, LevelReader world, BlockPos pos, @Nullable Entity entity) { - return this.getBlock().getSoundType(state); + return self().getSoundType(state); } /** @@ -677,50 +507,13 @@ public interface IForgeBlock * @return A float RGB [0.0, 1.0] array to be averaged with a beacon's existing beam color, or null to do nothing to the beam */ @Nullable - default float[] getBeaconColorMultiplier(BlockState state, IWorldReader world, BlockPos pos, BlockPos beaconPos) + default float[] getBeaconColorMultiplier(BlockState state, LevelReader world, BlockPos pos, BlockPos beaconPos) { - if (getBlock() instanceof IBeaconBeamColorProvider) - return ((IBeaconBeamColorProvider)getBlock()).getColor().getTextureDiffuseColors(); + if (self() instanceof BeaconBeamBlock) + return ((BeaconBeamBlock) self()).getColor().getTextureDiffuseColors(); return null; } - /** - * Use this to change the fog color used when the entity is "inside" a material. - * Vec3d is used here as "r/g/b" 0 - 1 values. - * - * @param world The world. - * @param pos The position at the entity viewport. - * @param state The state at the entity viewport. - * @param entity the entity - * @param originalColor The current fog color, You are not expected to use this, Return as the default if applicable. - * @return The new fog color. - */ - @OnlyIn(Dist.CLIENT) - default Vector3d getFogColor(BlockState state, IWorldReader world, BlockPos pos, Entity entity, Vector3d originalColor, float partialTicks) - { - if (state.getMaterial() == Material.WATER) - { - float f12 = 0.0F; - - if (entity instanceof LivingEntity) - { - LivingEntity ent = (LivingEntity)entity; - f12 = (float) EnchantmentHelper.getRespiration(ent) * 0.2F; - - if (ent.hasEffect(Effects.WATER_BREATHING)) - { - f12 = f12 * 0.3F + 0.6F; - } - } - return new Vector3d(0.02F + f12, 0.02F + f12, 0.2F + f12); - } - else if (state.getMaterial() == Material.LAVA) - { - return new Vector3d(0.6F, 0.1F, 0.0F); - } - return originalColor; - } - /** * Used to determine the state 'viewed' by an entity (see * {@link ActiveRenderInfo#getBlockStateAtEntityViewpoint(World, Entity, float)}). @@ -732,7 +525,7 @@ public interface IForgeBlock * @param viewpoint the viewpoint * @return the block state that should be 'seen' */ - default BlockState getStateAtViewpoint(BlockState state, IBlockReader world, BlockPos pos, Vector3d viewpoint) + default BlockState getStateAtViewpoint(BlockState state, BlockGetter world, BlockPos pos, Vec3 viewpoint) { return state; } @@ -743,9 +536,9 @@ public interface IForgeBlock * @return the PathNodeType */ @Nullable - default PathNodeType getAiPathNodeType(BlockState state, IBlockReader world, BlockPos pos, @Nullable MobEntity entity) + default BlockPathTypes getAiPathNodeType(BlockState state, BlockGetter world, BlockPos pos, @Nullable Mob entity) { - return state.getBlock() == Blocks.LAVA ? PathNodeType.LAVA : state.isBurning(world, pos) ? PathNodeType.DAMAGE_FIRE : null; + return state.getBlock() == Blocks.LAVA ? BlockPathTypes.LAVA : state.isBurning(world, pos) ? BlockPathTypes.DAMAGE_FIRE : null; } /** @@ -789,7 +582,7 @@ public interface IForgeBlock * @param face The face that the fire is coming from * @return A number ranging from 0 to 300 relating used to determine if the block will be consumed by fire */ - default int getFlammability(BlockState state, IBlockReader world, BlockPos pos, Direction face) + default int getFlammability(BlockState state, BlockGetter world, BlockPos pos, Direction face) { return ((FireBlock)Blocks.FIRE).getBurnOdd(state); } @@ -804,7 +597,7 @@ public interface IForgeBlock * @param face The face that the fire is coming from * @return True if the face can be on fire, false otherwise. */ - default boolean isFlammable(BlockState state, IBlockReader world, BlockPos pos, Direction face) + default boolean isFlammable(BlockState state, BlockGetter world, BlockPos pos, Direction face) { return state.getFlammability(world, pos, face) > 0; } @@ -818,7 +611,7 @@ public interface IForgeBlock * @param face The face that the fire is coming from * @param igniter The entity that lit the fire */ - default void catchFire(BlockState state, World world, BlockPos pos, @Nullable Direction face, @Nullable LivingEntity igniter) {} + default void catchFire(BlockState state, Level world, BlockPos pos, @Nullable Direction face, @Nullable LivingEntity igniter) {} /** * Called when fire is updating on a neighbor block. @@ -830,7 +623,7 @@ public interface IForgeBlock * @param face The face that the fire is coming from * @return A number that is used to determine the speed of fire growth around the block */ - default int getFireSpreadSpeed(BlockState state, IBlockReader world, BlockPos pos, Direction face) + default int getFireSpreadSpeed(BlockState state, BlockGetter world, BlockPos pos, Direction face) { return ((FireBlock)Blocks.FIRE).getFlameOdds(state); } @@ -846,7 +639,7 @@ public interface IForgeBlock * @param side The face that the fire is coming from * @return True if this block sustains fire, meaning it will never go out. */ - default boolean isFireSource(BlockState state, IWorldReader world, BlockPos pos, Direction side) + default boolean isFireSource(BlockState state, LevelReader world, BlockPos pos, Direction side) { return state.is(world.dimensionType().infiniburn()); } @@ -859,16 +652,16 @@ public interface IForgeBlock * @param pos Block position in world * @return True to allow the ender dragon to destroy this block */ - default boolean canEntityDestroy(BlockState state, IBlockReader world, BlockPos pos, Entity entity) + default boolean canEntityDestroy(BlockState state, BlockGetter world, BlockPos pos, Entity entity) { - if (entity instanceof EnderDragonEntity) + if (entity instanceof EnderDragon) { - return !BlockTags.DRAGON_IMMUNE.contains(this.getBlock()); + return !BlockTags.DRAGON_IMMUNE.contains(this.self()); } - else if ((entity instanceof WitherEntity) || - (entity instanceof WitherSkullEntity)) + else if ((entity instanceof WitherBoss) || + (entity instanceof WitherSkull)) { - return state.isAir(world, pos) || WitherEntity.canDestroy(state); + return state.isAir() || WitherBoss.canDestroy(state); } return true; @@ -877,7 +670,7 @@ public interface IForgeBlock /** * Determines if this block should drop loot when exploded. */ - default boolean canDropFromExplosion(BlockState state, IBlockReader world, BlockPos pos, Explosion explosion) + default boolean canDropFromExplosion(BlockState state, BlockGetter world, BlockPos pos, Explosion explosion) { return state.getBlock().dropFromExplosion(explosion); } @@ -897,19 +690,19 @@ public interface IForgeBlock * @param pos Block position in world * @param explosion The explosion instance affecting the block */ - default void onBlockExploded(BlockState state, World world, BlockPos pos, Explosion explosion) + default void onBlockExploded(BlockState state, Level world, BlockPos pos, Explosion explosion) { world.setBlock(pos, Blocks.AIR.defaultBlockState(), 3); - getBlock().wasExploded(world, pos, explosion); + self().wasExploded(world, pos, explosion); } /** * Determines if this block's collision box should be treated as though it can extend above its block space. * Use this to replicate fence and wall behavior. */ - default boolean collisionExtendsVertically(BlockState state, IBlockReader world, BlockPos pos, Entity collidingEntity) + default boolean collisionExtendsVertically(BlockState state, BlockGetter world, BlockPos pos, Entity collidingEntity) { - return getBlock().is(BlockTags.FENCES) || getBlock().is(BlockTags.WALLS) || getBlock() instanceof FenceGateBlock; + return state.is(BlockTags.FENCES) || state.is(BlockTags.WALLS) || self() instanceof FenceGateBlock; } /** @@ -921,9 +714,9 @@ public interface IForgeBlock * @param fluidState The state of the fluid * @return Whether the fluid overlay texture should be used */ - default boolean shouldDisplayFluidOverlay(BlockState state, IBlockDisplayReader world, BlockPos pos, FluidState fluidState) + default boolean shouldDisplayFluidOverlay(BlockState state, BlockAndTintGetter world, BlockPos pos, FluidState fluidState) { - return state.getBlock() instanceof BreakableBlock || state.getBlock() instanceof LeavesBlock; + return state.getBlock() instanceof HalfTransparentBlock || state.getBlock() instanceof LeavesBlock; } /** @@ -939,10 +732,10 @@ public interface IForgeBlock * @return The resulting state after the action has been performed */ @Nullable - default BlockState getToolModifiedState(BlockState state, World world, BlockPos pos, PlayerEntity player, ItemStack stack, ToolType toolType) + default BlockState getToolModifiedState(BlockState state, Level world, BlockPos pos, Player player, ItemStack stack, ToolType toolType) { if (toolType == ToolType.AXE) return AxeItem.getAxeStrippingState(state); - else if(toolType == ToolType.HOE) return HoeItem.getHoeTillingState(state); +// else if(toolType == ToolType.HOE) return HoeItem.getHoeTillingState(state); //TODO HoeItem bork else return toolType == ToolType.SHOVEL ? ShovelItem.getShovelPathingState(state) : null; } @@ -955,7 +748,7 @@ public interface IForgeBlock * @param entity The entity on the scaffolding * @return True if the block should act like scaffolding */ - default boolean isScaffolding(BlockState state, IWorldReader world, BlockPos pos, LivingEntity entity) + default boolean isScaffolding(BlockState state, LevelReader world, BlockPos pos, LivingEntity entity) { return state.is(Blocks.SCAFFOLDING); } diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeTileEntity.java b/src/main/java/net/minecraftforge/common/extensions/IForgeBlockEntity.java similarity index 71% rename from src/main/java/net/minecraftforge/common/extensions/IForgeTileEntity.java rename to src/main/java/net/minecraftforge/common/extensions/IForgeBlockEntity.java index d6991a054f..9c1a9e38b4 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeTileEntity.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeBlockEntity.java @@ -21,44 +21,35 @@ package net.minecraftforge.common.extensions; import javax.annotation.Nonnull; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.World; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.Level; import net.minecraftforge.client.model.ModelDataManager; import net.minecraftforge.client.model.data.EmptyModelData; import net.minecraftforge.client.model.data.IModelData; import net.minecraftforge.common.capabilities.ICapabilitySerializable; -public interface IForgeTileEntity extends ICapabilitySerializable +public interface IForgeBlockEntity extends ICapabilitySerializable { - default TileEntity getTileEntity() { return (TileEntity) this; } + private BlockEntity self() { return (BlockEntity) this; } @Override - default void deserializeNBT(CompoundNBT nbt) + default void deserializeNBT(CompoundTag nbt) { - //TODO re-evaluate - deserializeNBT(null, nbt); - } - - // @Override TODO re-evaluate - default void deserializeNBT(BlockState state, CompoundNBT nbt) - { - getTileEntity().load(state, nbt); + self().load(nbt); } @Override - default CompoundNBT serializeNBT() + default CompoundTag serializeNBT() { - CompoundNBT ret = new CompoundNBT(); - getTileEntity().save(ret); + CompoundTag ret = new CompoundTag(); + self().save(ret); return ret; } @@ -71,7 +62,7 @@ public interface IForgeTileEntity extends ICapabilitySerializable * @param net The NetworkManager the packet originated from * @param pkt The data packet */ - default void onDataPacket(net.minecraft.network.NetworkManager net, net.minecraft.network.play.server.SUpdateTileEntityPacket pkt){ } + default void onDataPacket(net.minecraft.network.Connection net, net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket pkt){ } /** * Called when the chunk's TE update tag, gotten from {@link #getUpdateTag()}, is received on the client. @@ -80,9 +71,9 @@ public interface IForgeTileEntity extends ICapabilitySerializable * * @param tag The {@link NBTTagCompound} sent from {@link #getUpdateTag()} */ - default void handleUpdateTag(BlockState state, CompoundNBT tag) + default void handleUpdateTag(CompoundTag tag) { - getTileEntity().load(state, tag); + self().load(tag); } /** @@ -91,7 +82,7 @@ public interface IForgeTileEntity extends ICapabilitySerializable * * @return A compound tag for custom data */ - CompoundNBT getTileData(); + CompoundTag getTileData(); default void onChunkUnloaded(){} @@ -107,7 +98,7 @@ public interface IForgeTileEntity extends ICapabilitySerializable /** * Sometimes default render bounding box: infinite in scope. Used to control rendering on {@link TileEntitySpecialRenderer}. */ - public static final AxisAlignedBB INFINITE_EXTENT_AABB = new net.minecraft.util.math.AxisAlignedBB(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY); + public static final AABB INFINITE_EXTENT_AABB = new net.minecraft.world.phys.AABB(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY); /** * Return an {@link AxisAlignedBB} that controls the visible scope of a {@link TileEntitySpecialRenderer} associated with this {@link TileEntity} @@ -116,20 +107,19 @@ public interface IForgeTileEntity extends ICapabilitySerializable * * @return an appropriately size {@link AxisAlignedBB} for the {@link TileEntity} */ - @OnlyIn(Dist.CLIENT) - default AxisAlignedBB getRenderBoundingBox() + default AABB getRenderBoundingBox() { - AxisAlignedBB bb = INFINITE_EXTENT_AABB; - BlockState state = getTileEntity().getBlockState(); + AABB bb = INFINITE_EXTENT_AABB; + BlockState state = self().getBlockState(); Block block = state.getBlock(); - BlockPos pos = getTileEntity().getBlockPos(); + BlockPos pos = self().getBlockPos(); if (block == Blocks.ENCHANTING_TABLE) { - bb = new AxisAlignedBB(pos, pos.offset(1, 1, 1)); + bb = new AABB(pos, pos.offset(1, 1, 1)); } else if (block == Blocks.CHEST || block == Blocks.TRAPPED_CHEST) { - bb = new AxisAlignedBB(pos.offset(-1, 0, -1), pos.offset(2, 2, 2)); + bb = new AABB(pos.offset(-1, 0, -1), pos.offset(2, 2, 2)); } else if (block == Blocks.STRUCTURE_BLOCK) { @@ -137,10 +127,10 @@ public interface IForgeTileEntity extends ICapabilitySerializable } else if (block != null && block != Blocks.BEACON) { - AxisAlignedBB cbb = null; + AABB cbb = null; try { - VoxelShape collisionShape = state.getCollisionShape(getTileEntity().getLevel(), pos); + VoxelShape collisionShape = state.getCollisionShape(self().getLevel(), pos); if (!collisionShape.isEmpty()) { cbb = collisionShape.bounds().move(pos); @@ -154,7 +144,7 @@ public interface IForgeTileEntity extends ICapabilitySerializable // So, once again in the long line of US having to accommodate BUKKIT breaking things, // here it is, assume that the TE is only 1 cubic block. Problem with this is that it may // cause the TileEntity renderer to error further down the line! But alas, nothing we can do. - cbb = new net.minecraft.util.math.AxisAlignedBB(pos.offset(-1, 0, -1), pos.offset(1, 1, 1)); + cbb = new net.minecraft.world.phys.AABB(pos.offset(-1, 0, -1), pos.offset(1, 1, 1)); } if (cbb != null) bb = cbb; } @@ -167,8 +157,8 @@ public interface IForgeTileEntity extends ICapabilitySerializable */ default void requestModelDataUpdate() { - TileEntity te = getTileEntity(); - World world = te.getLevel(); + BlockEntity te = self(); + Level world = te.getLevel(); if (world != null && world.isClientSide) { ModelDataManager.requestModelDataRefresh(te); diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeBlockState.java b/src/main/java/net/minecraftforge/common/extensions/IForgeBlockState.java index 6698f362a7..cde9c82e39 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeBlockState.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeBlockState.java @@ -22,32 +22,36 @@ package net.minecraftforge.common.extensions; import java.util.Optional; import javax.annotation.Nullable; -import net.minecraft.block.*; -import net.minecraft.client.particle.ParticleManager; -import net.minecraft.entity.Entity; -import net.minecraft.entity.MobEntity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.EntitySpawnPlacementRegistry.PlacementType; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.fluid.FluidState; -import net.minecraft.item.ItemStack; -import net.minecraft.pathfinding.PathNodeType; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.*; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.*; -import net.minecraft.world.server.ServerWorld; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.Mob; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.SpawnPlacements.Type; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.pathfinder.BlockPathTypes; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.Vec3; +import net.minecraft.server.level.ServerLevel; import net.minecraftforge.common.IPlantable; import net.minecraftforge.common.ToolType; +import net.minecraft.core.Direction; +import net.minecraft.world.level.BlockAndTintGetter; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Explosion; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.state.BlockState; + public interface IForgeBlockState { - default BlockState getBlockState() + private BlockState self() { return (BlockState)this; } @@ -66,17 +70,17 @@ public interface IForgeBlockState * @param entity the entity in question * @return the factor by which the entity's motion should be multiplied */ - default float getSlipperiness(IWorldReader world, BlockPos pos, @Nullable Entity entity) + default float getFriction(LevelReader world, BlockPos pos, @Nullable Entity entity) { - return getBlockState().getBlock().getSlipperiness(getBlockState(), world, pos, entity); + return self().getBlock().getFriction(self(), world, pos, entity); } /** * Get a light value for this block, taking into account the given state and coordinates, normal ranges are between 0 and 15 */ - default int getLightValue(IBlockReader world, BlockPos pos) + default int getLightEmission(BlockGetter world, BlockPos pos) { - return getBlockState().getBlock().getLightValue(getBlockState(), world, pos); + return self().getBlock().getLightEmission(self(), world, pos); } /** @@ -87,37 +91,9 @@ public interface IForgeBlockState * @param entity The entity trying to use the ladder, CAN be null. * @return True if the block should act like a ladder */ - default boolean isLadder(IWorldReader world, BlockPos pos, LivingEntity entity) + default boolean isLadder(LevelReader world, BlockPos pos, LivingEntity entity) { - return getBlockState().getBlock().isLadder(getBlockState(), world, pos, entity); - } - - /** - * Called throughout the code as a replacement for block instanceof BlockContainer - * Moving this to the Block base class allows for mods that wish to extend vanilla - * blocks, and also want to have a tile entity on that block, may. - * - * Return true from this function to specify this block has a tile entity. - * - * @return True if block has a tile entity, false otherwise - */ - default boolean hasTileEntity() - { - return getBlockState().getBlock().hasTileEntity(getBlockState()); - } - - /** - * Called throughout the code as a replacement for ITileEntityProvider.createNewTileEntity - * Return the same thing you would from that function. - * This will fall back to ITileEntityProvider.createNewTileEntity(World) if this block is a ITileEntityProvider - * - * @param world The world to create the TE in - * @return A instance of a class extending TileEntity - */ - @Nullable - default TileEntity createTileEntity(IBlockReader world) - { - return getBlockState().getBlock().createTileEntity(getBlockState(), world); + return self().getBlock().isLadder(self(), world, pos, entity); } /** @@ -128,9 +104,9 @@ public interface IForgeBlockState * @param player The player damaging the block * @return True to spawn the drops */ - default boolean canHarvestBlock(IBlockReader world, BlockPos pos, PlayerEntity player) + default boolean canHarvestBlock(BlockGetter world, BlockPos pos, Player player) { - return getBlockState().getBlock().canHarvestBlock(getBlockState(), world, pos, player); + return self().getBlock().canHarvestBlock(self(), world, pos, player); } /** @@ -152,9 +128,9 @@ public interface IForgeBlockState * @param fluid The current fluid and block state for the position in the world. * @return True if the block is actually destroyed. */ - default boolean removedByPlayer(World world, BlockPos pos, PlayerEntity player, boolean willHarvest, FluidState fluid) + default boolean removedByPlayer(Level world, BlockPos pos, Player player, boolean willHarvest, FluidState fluid) { - return getBlockState().getBlock().removedByPlayer(getBlockState(), world, pos, player, willHarvest, fluid); + return self().getBlock().removedByPlayer(self(), world, pos, player, willHarvest, fluid); } /** @@ -167,9 +143,9 @@ public interface IForgeBlockState * @param sleeper The sleeper or camera entity, null in some cases. * @return True to treat this as a bed */ - default boolean isBed(IBlockReader world, BlockPos pos, @Nullable LivingEntity sleeper) + default boolean isBed(BlockGetter world, BlockPos pos, @Nullable LivingEntity sleeper) { - return getBlockState().getBlock().isBed(getBlockState(), world, pos, sleeper); + return self().getBlock().isBed(self(), world, pos, sleeper); } /** @@ -181,40 +157,25 @@ public interface IForgeBlockState * @param type The Mob Category Type * @return True to allow a mob of the specified category to spawn, false to prevent it. */ - default boolean canCreatureSpawn(IWorldReader world, BlockPos pos, PlacementType type, EntityType entityType) + default boolean canCreatureSpawn(LevelReader world, BlockPos pos, Type type, EntityType entityType) { - return getBlockState().getBlock().canCreatureSpawn(getBlockState(), world, pos, type, entityType); - } - /** - * Returns the position that the sleeper is moved to upon - * waking up, or respawning at the bed. - * - * @param world The current world - * @param pos Block position in world - * @param orientation The direction the entity is facing while getting into bed. - * @param sleeper The sleeper or camera entity, null in some cases. - * @return The spawn position - * @deprecated use {@link #getRespawnPosition(EntityType, IWorldReader, BlockPos, float, LivingEntity)} - */ - @Deprecated - default Optional getBedSpawnPosition(EntityType type, IWorldReader world, BlockPos pos, float orientation, @Nullable LivingEntity sleeper) - { - return getBlockState().getBlock().getBedSpawnPosition(type, getBlockState(), world, pos, orientation, sleeper); + return self().getBlock().canCreatureSpawn(self(), world, pos, type, entityType); } /** * Returns the position that the entity is moved to upon * respawning at this block. * + * @param type The entity type used when checking if a dismount blockstate is dangerous. Currently always PLAYER. * @param world The current world * @param pos Block position in world * @param orientation The angle the entity had when setting the respawn point * @param entity The entity respawning, often null * @return The spawn position or the empty optional if respawning here is not possible */ - default Optional getRespawnPosition(EntityType type, IWorldReader world, BlockPos pos, float orientation, @Nullable LivingEntity entity) + default Optional getRespawnPosition(EntityType type, LevelReader world, BlockPos pos, float orientation, @Nullable LivingEntity entity) { - return getBlockState().getBlock().getRespawnPosition(getBlockState(), type, world, pos, orientation, entity); + return self().getBlock().getRespawnPosition(self(), type, world, pos, orientation, entity); } /** @@ -225,9 +186,9 @@ public interface IForgeBlockState * @param sleeper The sleeper or camera entity, null in some cases. * @param occupied True if we are occupying the bed, or false if they are stopping use of the bed */ - default void setBedOccupied(World world, BlockPos pos, LivingEntity sleeper, boolean occupied) + default void setBedOccupied(Level world, BlockPos pos, LivingEntity sleeper, boolean occupied) { - getBlockState().getBlock().setBedOccupied(getBlockState(), world, pos, sleeper, occupied); + self().getBlock().setBedOccupied(self(), world, pos, sleeper, occupied); } /** @@ -238,53 +199,9 @@ public interface IForgeBlockState * @param pos Block position in world * @return Bed direction */ - default Direction getBedDirection(IWorldReader world, BlockPos pos) + default Direction getBedDirection(LevelReader world, BlockPos pos) { - return getBlockState().getBlock().getBedDirection(getBlockState(), world, pos); - } - - /** - * Determines this block should be treated as an air block - * by the rest of the code. This method is primarily - * useful for creating pure logic-blocks that will be invisible - * to the player and otherwise interact as air would. - * - * @param world The current world - * @param pos Block position in world - * @return True if the block considered air - * @deprecated TODO: Remove in 1.17, in favor of state only version. This is a old hook from before - * block states were unlimited and people used TileEntities. If you still use the location - * information in your TileEntity please explain why and how you can't use BlockState only version - * here: https://github.com/MinecraftForge/MinecraftForge/issues/7409 - */ - @Deprecated - default boolean isAir(IBlockReader world, BlockPos pos) - { - return getBlockState().getBlock().isAir(getBlockState(), world, pos); - } - - /** - * Used during tree growth to determine if newly generated leaves can replace this block. - * - * @param world The current world - * @param pos Block position in world - * @return true if this block can be replaced by growing leaves. - */ - default boolean canBeReplacedByLeaves(IWorldReader world, BlockPos pos) - { - return getBlockState().getBlock().canBeReplacedByLeaves(getBlockState(), world, pos); - } - - /** - * Used during tree growth to determine if newly generated logs can replace this block. - * - * @param world The current world - * @param pos Block position in world - * @return true if this block can be replaced by growing leaves. - */ - default boolean canBeReplacedByLogs(IWorldReader world, BlockPos pos) - { - return getBlockState().getBlock().canBeReplacedByLogs(getBlockState(), world, pos); + return self().getBlock().getBedDirection(self(), world, pos); } /** @@ -295,23 +212,9 @@ public interface IForgeBlockState * @param explosion The explosion * @return The amount of the explosion absorbed. */ - default float getExplosionResistance(IBlockReader world, BlockPos pos, Explosion explosion) + default float getExplosionResistance(BlockGetter world, BlockPos pos, Explosion explosion) { - return getBlockState().getBlock().getExplosionResistance(getBlockState(), world, pos, explosion); - } - - /** - * Determine if this block can make a redstone connection on the side provided, - * Useful to control which sides are inputs and outputs for redstone wires. - * - * @param world The current world - * @param pos Block position in world - * @param side The side that is trying to make the connection, CAN BE NULL - * @return True to make the connection - */ - default boolean canConnectRedstone(IBlockReader world, BlockPos pos, @Nullable Direction side) - { - return getBlockState().getBlock().canConnectRedstone(getBlockState(), world, pos, side); + return self().getBlock().getExplosionResistance(self(), world, pos, explosion); } /** @@ -321,9 +224,9 @@ public interface IForgeBlockState * @param target The full target the player is looking at * @return A ItemStack to add to the player's inventory, empty itemstack if nothing should be added. */ - default ItemStack getPickBlock(RayTraceResult target, IBlockReader world, BlockPos pos, PlayerEntity player) + default ItemStack getPickBlock(HitResult target, BlockGetter world, BlockPos pos, Player player) { - return getBlockState().getBlock().getPickBlock(getBlockState(), target, world, pos, player); + return self().getBlock().getPickBlock(self(), target, world, pos, player); } /** @@ -338,9 +241,9 @@ public interface IForgeBlockState * @param numberOfParticles That vanilla world have spawned * @return True to prevent vanilla landing particles from spawning */ - default boolean addLandingEffects(ServerWorld worldserver, BlockPos pos, BlockState state2, LivingEntity entity, int numberOfParticles) + default boolean addLandingEffects(ServerLevel worldserver, BlockPos pos, BlockState state2, LivingEntity entity, int numberOfParticles) { - return getBlockState().getBlock().addLandingEffects(getBlockState(), worldserver, pos, state2, entity, numberOfParticles); + return self().getBlock().addLandingEffects(self(), worldserver, pos, state2, entity, numberOfParticles); } /** * Allows a block to override the standard vanilla running particles. @@ -353,43 +256,9 @@ public interface IForgeBlockState * @param entity The entity running on the block. * @return True to prevent vanilla running particles from spawning. */ - default boolean addRunningEffects(World world, BlockPos pos, Entity entity) + default boolean addRunningEffects(Level world, BlockPos pos, Entity entity) { - return getBlockState().getBlock().addRunningEffects(getBlockState(), world, pos, entity); - } - - /** - * Spawn a digging particle effect in the world, this is a wrapper - * around EffectRenderer.addBlockHitEffects to allow the block more - * control over the particles. Useful when you have entirely different - * texture sheets for different sides/locations in the world. - * - * @param world The current world - * @param target The target the player is looking at {x/y/z/side/sub} - * @param manager A reference to the current particle manager. - * @return True to prevent vanilla digging particles form spawning. - */ - @OnlyIn(Dist.CLIENT) - default boolean addHitEffects(World world, RayTraceResult target, ParticleManager manager) - { - return getBlockState().getBlock().addHitEffects(getBlockState(), world, target, manager); - } - - /** - * Spawn particles for when the block is destroyed. Due to the nature - * of how this is invoked, the x/y/z locations are not always guaranteed - * to host your block. So be sure to do proper sanity checks before assuming - * that the location is this block. - * - * @param world The current world - * @param pos Position to spawn the particle - * @param manager A reference to the current particle manager. - * @return True to prevent vanilla break particles from spawning. - */ - @OnlyIn(Dist.CLIENT) - default boolean addDestroyEffects(World world, BlockPos pos, ParticleManager manager) - { - return getBlockState().getBlock().addDestroyEffects(getBlockState(), world, pos, manager); + return self().getBlock().addRunningEffects(self(), world, pos, entity); } /** @@ -408,9 +277,9 @@ public interface IForgeBlockState * @param plantable The plant that wants to check * @return True to allow the plant to be planted/stay. */ - default boolean canSustainPlant(IBlockReader world, BlockPos pos, Direction facing, IPlantable plantable) + default boolean canSustainPlant(BlockGetter world, BlockPos pos, Direction facing, IPlantable plantable) { - return getBlockState().getBlock().canSustainPlant(getBlockState(), world, pos, facing, plantable); + return self().getBlock().canSustainPlant(self(), world, pos, facing, plantable); } /** @@ -422,9 +291,9 @@ public interface IForgeBlockState * @param pos Block position in world * @return True if the soil should be considered fertile. */ - default boolean isFertile(IBlockReader world, BlockPos pos) + default boolean isFertile(BlockGetter world, BlockPos pos) { - return getBlockState().getBlock().isFertile(getBlockState(), world, pos); + return self().getBlock().isFertile(self(), world, pos); } /** @@ -435,9 +304,9 @@ public interface IForgeBlockState * @param conduit Conduit position in world * @return True, to support the conduit, and make it active with this block. */ - default boolean isConduitFrame(IWorldReader world, BlockPos pos, BlockPos conduit) + default boolean isConduitFrame(LevelReader world, BlockPos pos, BlockPos conduit) { - return getBlockState().getBlock().isConduitFrame(getBlockState(), world, pos, conduit); + return self().getBlock().isConduitFrame(self(), world, pos, conduit); } /** @@ -447,9 +316,9 @@ public interface IForgeBlockState * @param pos Block position in world * @return True, to support being part of a nether portal frame, false otherwise. */ - default boolean isPortalFrame(IBlockReader world, BlockPos pos) + default boolean isPortalFrame(BlockGetter world, BlockPos pos) { - return getBlockState().getBlock().isPortalFrame(getBlockState(), world, pos); + return self().getBlock().isPortalFrame(self(), world, pos); } /** @@ -460,14 +329,14 @@ public interface IForgeBlockState * @param fortune * @return Amount of XP from breaking this block. */ - default int getExpDrop(IWorldReader world, BlockPos pos, int fortune, int silktouch) + default int getExpDrop(LevelReader world, BlockPos pos, int fortune, int silktouch) { - return getBlockState().getBlock().getExpDrop(getBlockState(), world, pos, fortune, silktouch); + return self().getBlock().getExpDrop(self(), world, pos, fortune, silktouch); } - default BlockState rotate(IWorld world, BlockPos pos, Rotation direction) + default BlockState rotate(LevelAccessor world, BlockPos pos, Rotation direction) { - return getBlockState().getBlock().rotate(getBlockState(), world, pos, direction); + return self().getBlock().rotate(self(), world, pos, direction); } /** @@ -476,9 +345,9 @@ public interface IForgeBlockState * @param pos Block position in world * @return The amount of enchanting power this block produces. */ - default float getEnchantPowerBonus(IWorldReader world, BlockPos pos) + default float getEnchantPowerBonus(LevelReader world, BlockPos pos) { - return getBlockState().getBlock().getEnchantPowerBonus(getBlockState(), world, pos); + return self().getBlock().getEnchantPowerBonus(self(), world, pos); } /** @@ -487,23 +356,9 @@ public interface IForgeBlockState * @param pos Block position in world * @param neighbor Block position of neighbor */ - default void onNeighborChange(IWorldReader world, BlockPos pos, BlockPos neighbor) + default void onNeighborChange(LevelReader world, BlockPos pos, BlockPos neighbor) { - getBlockState().getBlock().onNeighborChange(getBlockState(), world, pos, neighbor); - } - - /** - * Called on an Observer block whenever an update for an Observer is received. - * - * @param world The current world. - * @param pos The Observer block's position. - * @param changed The updated block. - * @param changedPos The updated block's position. - */ - @Deprecated//TODO - 1.17: Remove (unused) - default void observedNeighborChange(World world, BlockPos pos, Block changed, BlockPos changedPos) - { - getBlockState().getBlock().observedNeighborChange(getBlockState(), world, pos, changed, changedPos); + self().getBlock().onNeighborChange(self(), world, pos, neighbor); } /** @@ -513,9 +368,9 @@ public interface IForgeBlockState * @param side The INPUT side of the block to be powered - ie the opposite of this block's output side * @return Whether Block#isProvidingWeakPower should be called when determining indirect power */ - default boolean shouldCheckWeakPower(IWorldReader world, BlockPos pos, Direction side) + default boolean shouldCheckWeakPower(LevelReader world, BlockPos pos, Direction side) { - return getBlockState().getBlock().shouldCheckWeakPower(getBlockState(), world, pos, side); + return self().getBlock().shouldCheckWeakPower(self(), world, pos, side); } /** @@ -527,9 +382,9 @@ public interface IForgeBlockState * @param pos Block position in world * @return true To be notified of changes */ - default boolean getWeakChanges(IWorldReader world, BlockPos pos) + default boolean getWeakChanges(LevelReader world, BlockPos pos) { - return getBlockState().getBlock().getWeakChanges(getBlockState(), world, pos); + return self().getBlock().getWeakChanges(self(), world, pos); } /** @@ -538,12 +393,12 @@ public interface IForgeBlockState */ default ToolType getHarvestTool() { - return getBlockState().getBlock().getHarvestTool(getBlockState()); + return self().getBlock().getHarvestTool(self()); } default int getHarvestLevel() { - return getBlockState().getBlock().getHarvestLevel(getBlockState()); + return self().getBlock().getHarvestLevel(self()); } /** @@ -552,7 +407,7 @@ public interface IForgeBlockState */ default boolean isToolEffective(ToolType tool) { - return getBlockState().getBlock().isToolEffective(getBlockState(), tool); + return self().getBlock().isToolEffective(self(), tool); } /** @@ -562,9 +417,9 @@ public interface IForgeBlockState * @param entity The entity that is breaking/stepping on/placing/hitting/falling on this block, or null if no entity is in this context * @return A SoundType to use */ - default SoundType getSoundType(IWorldReader world, BlockPos pos, @Nullable Entity entity) + default SoundType getSoundType(LevelReader world, BlockPos pos, @Nullable Entity entity) { - return getBlockState().getBlock().getSoundType(getBlockState(), world, pos, entity); + return self().getBlock().getSoundType(self(), world, pos, entity); } /** @@ -574,30 +429,14 @@ public interface IForgeBlockState * @return A float RGB [0.0, 1.0] array to be averaged with a beacon's existing beam color, or null to do nothing to the beam */ @Nullable - default float[] getBeaconColorMultiplier(IWorldReader world, BlockPos pos, BlockPos beacon) + default float[] getBeaconColorMultiplier(LevelReader world, BlockPos pos, BlockPos beacon) { - return getBlockState().getBlock().getBeaconColorMultiplier(getBlockState(), world, pos, beacon); - } - - /** - * Use this to change the fog color used when the entity is "inside" a material. - * Vec3d is used here as "r/g/b" 0 - 1 values. - * - * @param world The world. - * @param pos The position at the entity viewport. - * @param entity the entity - * @param originalColor The current fog color, You are not expected to use this, Return as the default if applicable. - * @return The new fog color. - */ - @OnlyIn(Dist.CLIENT) - default Vector3d getFogColor(IWorldReader world, BlockPos pos, Entity entity, Vector3d originalColor, float partialTicks) - { - return getBlockState().getBlock().getFogColor(getBlockState(), world, pos, entity, originalColor, partialTicks); + return self().getBlock().getBeaconColorMultiplier(self(), world, pos, beacon); } /** * Used to determine the state 'viewed' by an entity (see - * {@link ActiveRenderInfo#getBlockStateAtEntityViewpoint(World, Entity, float)}). + * {@link net.minecraft.client.Camera#getBlockAtCamera()}). * Can be used by fluid blocks to determine if the viewpoint is within the fluid or not. * * @param world the world @@ -605,9 +444,9 @@ public interface IForgeBlockState * @param viewpoint the viewpoint * @return the block state that should be 'seen' */ - default BlockState getStateAtViewpoint(IBlockReader world, BlockPos pos, Vector3d viewpoint) + default BlockState getStateAtViewpoint(BlockGetter world, BlockPos pos, Vec3 viewpoint) { - return getBlockState().getBlock().getStateAtViewpoint(getBlockState(), world, pos, viewpoint); + return self().getBlock().getStateAtViewpoint(self(), world, pos, viewpoint); } /** @@ -615,7 +454,7 @@ public interface IForgeBlockState */ default boolean isSlimeBlock() { - return getBlockState().getBlock().isSlimeBlock(getBlockState()); + return self().getBlock().isSlimeBlock(self()); } /** @@ -623,7 +462,7 @@ public interface IForgeBlockState */ default boolean isStickyBlock() { - return getBlockState().getBlock().isStickyBlock(getBlockState()); + return self().getBlock().isStickyBlock(self()); } /** @@ -633,7 +472,7 @@ public interface IForgeBlockState */ default boolean canStickTo(BlockState other) { - return getBlockState().getBlock().canStickTo(getBlockState(), other); + return self().getBlock().canStickTo(self(), other); } /** @@ -645,9 +484,9 @@ public interface IForgeBlockState * @param face The face that the fire is coming from * @return A number ranging from 0 to 300 relating used to determine if the block will be consumed by fire */ - default int getFlammability(IBlockReader world, BlockPos pos, Direction face) + default int getFlammability(BlockGetter world, BlockPos pos, Direction face) { - return getBlockState().getBlock().getFlammability(getBlockState(), world, pos, face); + return self().getBlock().getFlammability(self(), world, pos, face); } /** @@ -658,9 +497,9 @@ public interface IForgeBlockState * @param face The face that the fire is coming from * @return True if the face can be on fire, false otherwise. */ - default boolean isFlammable(IBlockReader world, BlockPos pos, Direction face) + default boolean isFlammable(BlockGetter world, BlockPos pos, Direction face) { - return getBlockState().getBlock().isFlammable(getBlockState(), world, pos, face); + return self().getBlock().isFlammable(self(), world, pos, face); } /** @@ -671,9 +510,9 @@ public interface IForgeBlockState * @param face The face that the fire is coming from * @param igniter The entity that lit the fire */ - default void catchFire(World world, BlockPos pos, @Nullable Direction face, @Nullable LivingEntity igniter) + default void catchFire(Level world, BlockPos pos, @Nullable Direction face, @Nullable LivingEntity igniter) { - getBlockState().getBlock().catchFire(getBlockState(), world, pos, face, igniter); + self().getBlock().catchFire(self(), world, pos, face, igniter); } /** @@ -685,9 +524,9 @@ public interface IForgeBlockState * @param face The face that the fire is coming from * @return A number that is used to determine the speed of fire growth around the block */ - default int getFireSpreadSpeed(IBlockReader world, BlockPos pos, Direction face) + default int getFireSpreadSpeed(BlockGetter world, BlockPos pos, Direction face) { - return getBlockState().getBlock().getFireSpreadSpeed(getBlockState(), world, pos, face); + return self().getBlock().getFireSpreadSpeed(self(), world, pos, face); } /** @@ -700,9 +539,9 @@ public interface IForgeBlockState * @param side The face that the fire is coming from * @return True if this block sustains fire, meaning it will never go out. */ - default boolean isFireSource(IWorldReader world, BlockPos pos, Direction side) + default boolean isFireSource(LevelReader world, BlockPos pos, Direction side) { - return getBlockState().getBlock().isFireSource(getBlockState(), world, pos, side); + return self().getBlock().isFireSource(self(), world, pos, side); } /** @@ -712,9 +551,9 @@ public interface IForgeBlockState * @param pos Block position in world * @return True to allow the ender dragon to destroy this block */ - default boolean canEntityDestroy(IBlockReader world, BlockPos pos, Entity entity) + default boolean canEntityDestroy(BlockGetter world, BlockPos pos, Entity entity) { - return getBlockState().getBlock().canEntityDestroy(getBlockState(), world, pos, entity); + return self().getBlock().canEntityDestroy(self(), world, pos, entity); } /** @@ -725,9 +564,9 @@ public interface IForgeBlockState * @param pos Block position in world * @return True if the block should deal damage */ - default boolean isBurning(IBlockReader world, BlockPos pos) + default boolean isBurning(BlockGetter world, BlockPos pos) { - return getBlockState().getBlock().isBurning(getBlockState(), world, pos); + return self().getBlock().isBurning(self(), world, pos); } /** @@ -736,7 +575,7 @@ public interface IForgeBlockState * @return the PathNodeType */ @Nullable - default PathNodeType getAiPathNodeType(IBlockReader world, BlockPos pos) + default BlockPathTypes getAiPathNodeType(BlockGetter world, BlockPos pos) { return getAiPathNodeType(world, pos, null); } @@ -747,17 +586,17 @@ public interface IForgeBlockState * @return the PathNodeType */ @Nullable - default PathNodeType getAiPathNodeType(IBlockReader world, BlockPos pos, @Nullable MobEntity entity) + default BlockPathTypes getAiPathNodeType(BlockGetter world, BlockPos pos, @Nullable Mob entity) { - return getBlockState().getBlock().getAiPathNodeType(getBlockState(), world, pos, entity); + return self().getBlock().getAiPathNodeType(self(), world, pos, entity); } /** * Determines if this block should drop loot when exploded. */ - default boolean canDropFromExplosion(IBlockReader world, BlockPos pos, Explosion explosion) + default boolean canDropFromExplosion(BlockGetter world, BlockPos pos, Explosion explosion) { - return getBlockState().getBlock().canDropFromExplosion(getBlockState(), world, pos, explosion); + return self().getBlock().canDropFromExplosion(self(), world, pos, explosion); } /** @@ -769,18 +608,18 @@ public interface IForgeBlockState * @param pos Block position in world * @param explosion The explosion instance affecting the block */ - default void onBlockExploded(World world, BlockPos pos, Explosion explosion) + default void onBlockExploded(Level world, BlockPos pos, Explosion explosion) { - getBlockState().getBlock().onBlockExploded(getBlockState(), world, pos, explosion); + self().getBlock().onBlockExploded(self(), world, pos, explosion); } /** * Determines if this block's collision box should be treated as though it can extend above its block space. * This can be used to replicate fence and wall behavior. */ - default boolean collisionExtendsVertically(IBlockReader world, BlockPos pos, Entity collidingEntity) + default boolean collisionExtendsVertically(BlockGetter world, BlockPos pos, Entity collidingEntity) { - return getBlockState().getBlock().collisionExtendsVertically(getBlockState(), world, pos, collidingEntity); + return self().getBlock().collisionExtendsVertically(self(), world, pos, collidingEntity); } /** @@ -791,9 +630,9 @@ public interface IForgeBlockState * @param fluidState The state of the fluid * @return Whether the fluid overlay texture should be used */ - default boolean shouldDisplayFluidOverlay(IBlockDisplayReader world, BlockPos pos, FluidState fluidState) + default boolean shouldDisplayFluidOverlay(BlockAndTintGetter world, BlockPos pos, FluidState fluidState) { - return getBlockState().getBlock().shouldDisplayFluidOverlay(getBlockState(), world, pos, fluidState); + return self().getBlock().shouldDisplayFluidOverlay(self(), world, pos, fluidState); } /** @@ -809,10 +648,10 @@ public interface IForgeBlockState * @return The resulting state after the action has been performed */ @Nullable - default BlockState getToolModifiedState(World world, BlockPos pos, PlayerEntity player, ItemStack stack, ToolType toolType) + default BlockState getToolModifiedState(Level world, BlockPos pos, Player player, ItemStack stack, ToolType toolType) { - BlockState eventState = net.minecraftforge.event.ForgeEventFactory.onToolUse(getBlockState(), world, pos, player, stack, toolType); - return eventState != getBlockState() ? eventState : getBlockState().getBlock().getToolModifiedState(getBlockState(), world, pos, player, stack, toolType); + BlockState eventState = net.minecraftforge.event.ForgeEventFactory.onToolUse(self(), world, pos, player, stack, toolType); + return eventState != self() ? eventState : self().getBlock().getToolModifiedState(self(), world, pos, player, stack, toolType); } /** @@ -823,6 +662,6 @@ public interface IForgeBlockState */ default boolean isScaffolding(LivingEntity entity) { - return getBlockState().getBlock().isScaffolding(getBlockState(), entity.level, entity.blockPosition(), entity); + return self().getBlock().isScaffolding(self(), entity.level, entity.blockPosition(), entity); } } diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeContainerType.java b/src/main/java/net/minecraftforge/common/extensions/IForgeContainerType.java index 64b66df21f..f8d41881a6 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeContainerType.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeContainerType.java @@ -19,17 +19,18 @@ package net.minecraftforge.common.extensions; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.inventory.container.Container; -import net.minecraft.inventory.container.ContainerType; -import net.minecraft.network.PacketBuffer; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraftforge.fmllegacy.network.IContainerFactory; public interface IForgeContainerType { - static ContainerType create(net.minecraftforge.fml.network.IContainerFactory factory) + static MenuType create(IContainerFactory factory) { - return new ContainerType<>(factory); + return new MenuType<>(factory); } - T create(int windowId, PlayerInventory playerInv, PacketBuffer extraData); + T create(int windowId, Inventory playerInv, FriendlyByteBuf extraData); } diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeEffect.java b/src/main/java/net/minecraftforge/common/extensions/IForgeEffect.java deleted file mode 100644 index 619c93ec84..0000000000 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeEffect.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.common.extensions; - -import java.util.ArrayList; -import java.util.List; - -import com.mojang.blaze3d.matrix.MatrixStack; -import net.minecraft.client.gui.AbstractGui; -import net.minecraft.client.gui.DisplayEffectsScreen; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.potion.Effect; -import net.minecraft.potion.EffectInstance; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; - -public interface IForgeEffect { - - default Effect getEffect() { - return (Effect)this; - } - - /** - * If the Potion effect should be displayed in the players inventory - * @param effect the active PotionEffect - * @return true to display it (default), false to hide it. - */ - default boolean shouldRender(EffectInstance effect) { return true; } - - /** - * If the standard PotionEffect text (name and duration) should be drawn when this potion is active. - * @param effect the active PotionEffect - * @return true to draw the standard text - */ - default boolean shouldRenderInvText(EffectInstance effect) { return true; } - - /** - * If the Potion effect should be displayed in the player's ingame HUD - * @param effect the active PotionEffect - * @return true to display it (default), false to hide it. - */ - default boolean shouldRenderHUD(EffectInstance effect) { return true; } - - /** - * Called to draw the this Potion onto the player's inventory when it's active. - * This can be used to e.g. render Potion icons from your own texture. - * - * @param effect the active PotionEffect - * @param gui the gui instance - * @param mStack The MatrixStack - * @param x the x coordinate - * @param y the y coordinate - * @param z the z level - */ - @OnlyIn(Dist.CLIENT) - default void renderInventoryEffect(EffectInstance effect, DisplayEffectsScreen gui, MatrixStack mStack, int x, int y, float z) { } - - /** - * Called to draw the this Potion onto the player's ingame HUD when it's active. - * This can be used to e.g. render Potion icons from your own texture. - * @param effect the active PotionEffect - * @param gui the gui instance - * @param mStack The MatrixStack - * @param x the x coordinate - * @param y the y coordinate - * @param z the z level - * @param alpha the alpha value, blinks when the potion is about to run out - */ - @OnlyIn(Dist.CLIENT) - default void renderHUDEffect(EffectInstance effect, AbstractGui gui, MatrixStack mStack, int x, int y, float z, float alpha) { } - - /** - * Get a fresh list of items that can cure this Potion. - * All new PotionEffects created from this Potion will call this to initialize the default curative items - * @see PotionEffect#getCurativeItems - * @return A list of items that can cure this Potion - */ - default List getCurativeItems() { - ArrayList ret = new ArrayList(); - ret.add(new ItemStack(Items.MILK_BUCKET)); - return ret; - } - - /** - * Used for determining {@code PotionEffect} sort order in GUIs. - * Defaults to the {@code PotionEffect}'s liquid color. - * @param potionEffect the {@code PotionEffect} instance containing the potion - * @return a value used to sort {@code PotionEffect}s in GUIs - */ - default int getGuiSortColor(EffectInstance potionEffect) { - return getEffect().getColor(); - } -} diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeEffectInstance.java b/src/main/java/net/minecraftforge/common/extensions/IForgeEffectInstance.java deleted file mode 100644 index c927589723..0000000000 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeEffectInstance.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.common.extensions; - -import java.util.List; - -import com.mojang.blaze3d.matrix.MatrixStack; -import net.minecraft.client.gui.AbstractGui; -import net.minecraft.client.gui.DisplayEffectsScreen; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.ListNBT; -import net.minecraft.potion.EffectInstance; -import net.minecraft.potion.Potion; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; - -public interface IForgeEffectInstance { - - default EffectInstance getEffectInstance() { - return (EffectInstance)this; - } - - /** - * If the Potion effect should be displayed in the players inventory - * @return true to display it (default), false to hide it. - */ - default boolean shouldRender() { - return getEffectInstance().getEffect().shouldRender(getEffectInstance()); - } - - /** - * If the standard PotionEffect text (name and duration) should be drawn when this potion is active. - * @return true to draw the standard text - */ - default boolean shouldRenderInvText() { - return getEffectInstance().getEffect().shouldRenderInvText(getEffectInstance()); - } - - /** - * If the Potion effect should be displayed in the player's ingame HUD - * @return true to display it (default), false to hide it. - */ - default boolean shouldRenderHUD() { - return getEffectInstance().getEffect().shouldRenderHUD(getEffectInstance()); - } - - /** - * Called to draw the this Potion onto the player's inventory when it's active. - * This can be used to e.g. render Potion icons from your own texture. - * - * @param gui the gui instance - * @param mStack The MatrixStack - * @param x the x coordinate - * @param y the y coordinate - * @param z the z level - */ - @OnlyIn(Dist.CLIENT) - default void renderInventoryEffect(DisplayEffectsScreen gui, MatrixStack mStack, int x, int y, float z) { - getEffectInstance().getEffect().renderInventoryEffect(getEffectInstance(), gui, mStack, x, y, z); - } - - /** - * Called to draw the this Potion onto the player's ingame HUD when it's active. - * This can be used to e.g. render Potion icons from your own texture. - * - * @param gui the gui instance - * @param mStack The MatrixStack - * @param x the x coordinate - * @param y the y coordinate - * @param z the z level - * @param alpha the alpha value, blinks when the potion is about to run out - */ - @OnlyIn(Dist.CLIENT) - default void renderHUDEffect(AbstractGui gui, MatrixStack mStack, int x, int y, float z, float alpha) { - getEffectInstance().getEffect().renderHUDEffect(getEffectInstance(), gui, mStack, x, y, z, alpha); - } - - /*** - * Returns a list of curative items for the potion effect - * By default, this list is initialized using {@link Potion#getCurativeItems} - * - * @return The list (ItemStack) of curative items for the potion effect - */ - List getCurativeItems(); - - /*** - * Checks the given ItemStack to see if it is in the list of curative items for the potion effect - * @param stack The ItemStack being checked against the list of curative items for this PotionEffect - * @return true if the given ItemStack is in the list of curative items for this PotionEffect, false otherwise - */ - default boolean isCurativeItem(ItemStack stack) { - return this.getCurativeItems().stream().anyMatch(e -> e.sameItem(stack)); - } - - /*** - * Sets the list of curative items for this potion effect, overwriting any already present - * @param curativeItems The list of ItemStacks being set to the potion effect - */ - void setCurativeItems(List curativeItems); - - /*** - * Adds the given stack to the list of curative items for this PotionEffect - * @param stack The ItemStack being added to the curative item list - */ - default void addCurativeItem(ItemStack stack) { - if (!this.isCurativeItem(stack)) - this.getCurativeItems().add(stack); - } - - default void writeCurativeItems(CompoundNBT nbt) { - ListNBT list = new ListNBT(); - getCurativeItems().forEach(s -> list.add(s.save(new CompoundNBT()))); - nbt.put("CurativeItems", list); - } -} diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeEntity.java b/src/main/java/net/minecraftforge/common/extensions/IForgeEntity.java index 828d12bff5..5f821af565 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeEntity.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeEntity.java @@ -20,47 +20,37 @@ package net.minecraftforge.common.extensions; import java.util.Collection; -import java.util.Collections; import javax.annotation.Nullable; -import net.minecraft.block.BlockState; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.LeashKnotEntity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.EntityClassification; -import net.minecraft.entity.item.ArmorStandEntity; -import net.minecraft.entity.item.BoatEntity; -import net.minecraft.entity.item.EnderCrystalEntity; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.item.ItemFrameEntity; -import net.minecraft.entity.item.minecart.AbstractMinecartEntity; -import net.minecraft.entity.item.PaintingEntity; -import net.minecraft.item.Items; -import net.minecraft.item.SpawnEggItem; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.RayTraceResult; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.MobCategory; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.item.SpawnEggItem; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.HitResult; import net.minecraftforge.common.capabilities.ICapabilitySerializable; import net.minecraftforge.entity.PartEntity; -public interface IForgeEntity extends ICapabilitySerializable +public interface IForgeEntity extends ICapabilitySerializable { - default Entity getEntity() { return (Entity) this; } + private Entity self() { return (Entity) this; } - default void deserializeNBT(CompoundNBT nbt) + default void deserializeNBT(CompoundTag nbt) { - getEntity().load(nbt); + self().load(nbt); } - default CompoundNBT serializeNBT() + default CompoundTag serializeNBT() { - CompoundNBT ret = new CompoundNBT(); - String id = getEntity().getEncodeId(); + CompoundTag ret = new CompoundTag(); + String id = self().getEncodeId(); if (id != null) { - ret.putString("id", getEntity().getEncodeId()); + ret.putString("id", self().getEncodeId()); } - return getEntity().saveWithoutId(ret); + return self().saveWithoutId(ret); } boolean canUpdate(); @@ -76,7 +66,7 @@ public interface IForgeEntity extends ICapabilitySerializable * It will be written, and read from disc, so it persists over world saves. * @return A NBTTagCompound */ - CompoundNBT getPersistentData(); + CompoundTag getPersistentData(); /** * Used in model rendering to determine if the entity riding this entity should be in the 'sitting' position. @@ -93,34 +83,17 @@ public interface IForgeEntity extends ICapabilitySerializable * @param target The full target the player is looking at * @return A ItemStack to add to the player's inventory, empty ItemStack if nothing should be added. */ - default ItemStack getPickedResult(RayTraceResult target) + default ItemStack getPickedResult(HitResult target) { - if (this instanceof PaintingEntity) - return new ItemStack(Items.PAINTING); - else if (this instanceof LeashKnotEntity) - return new ItemStack(Items.LEAD); - else if (this instanceof ItemFrameEntity) - { - ItemStack held = ((ItemFrameEntity)this).getItem(); - if (held.isEmpty()) - return new ItemStack(Items.ITEM_FRAME); + ItemStack result = self().getPickResult(); + if (result == null) { + SpawnEggItem egg = SpawnEggItem.byId(self().getType()); + if (egg != null) + result = new ItemStack(egg); else - return held.copy(); + result = ItemStack.EMPTY; } - else if (this instanceof AbstractMinecartEntity) - return ((AbstractMinecartEntity)this).getCartItem(); - else if (this instanceof BoatEntity) - return new ItemStack(((BoatEntity)this).getDropItem()); - else if (this instanceof ArmorStandEntity) - return new ItemStack(Items.ARMOR_STAND); - else if (this instanceof EnderCrystalEntity) - return new ItemStack(Items.END_CRYSTAL); - else - { - SpawnEggItem egg = SpawnEggItem.byId(getEntity().getType()); - if (egg != null) return new ItemStack(egg); - } - return ItemStack.EMPTY; + return result; } /** @@ -142,7 +115,7 @@ public interface IForgeEntity extends ICapabilitySerializable */ default boolean canBeRiddenInWater(Entity rider) { - return getEntity().rideableUnderWater(); + return self().rideableUnderWater(); } /** @@ -159,9 +132,9 @@ public interface IForgeEntity extends ICapabilitySerializable * @param forSpawnCount If this is being invoked to check spawn count caps. * @return If the creature is of the type provided */ - default EntityClassification getClassification(boolean forSpawnCount) + default MobCategory getClassification(boolean forSpawnCount) { - return getEntity().getType().getCategory(); + return self().getType().getCategory(); } /** diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeFluid.java b/src/main/java/net/minecraftforge/common/extensions/IForgeFluid.java index d0a936a63f..5071c9006f 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeFluid.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeFluid.java @@ -23,26 +23,21 @@ import java.util.Set; import javax.annotation.Nullable; -import net.minecraft.block.material.Material; -import net.minecraft.entity.Entity; -import net.minecraft.fluid.Fluid; -import net.minecraft.fluid.FluidState; -import net.minecraft.tags.Tag; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.Explosion; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorldReader; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.tags.SetTag; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Explosion; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelReader; import net.minecraftforge.fluids.FluidAttributes; public interface IForgeFluid { - default Fluid getFluid() - { - return (Fluid) this; - } - /** * Called when the entity is inside this block, may be used to determined if the entity can breathing, * display material overlays, or if the entity can swim inside a block. @@ -54,7 +49,7 @@ public interface IForgeFluid * @param tag Fluid category * @param testingHead when true, its testing the entities head for vision, breathing ect... otherwise its testing the body, for swimming and movement adjustment. */ - default boolean isEntityInside(FluidState state, IWorldReader world, BlockPos pos, Entity entity, double yToTest, Tag tag, boolean testingHead) + default boolean isEntityInside(FluidState state, LevelReader world, BlockPos pos, Entity entity, double yToTest, SetTag tag, boolean testingHead) { return state.is(tag) && yToTest < (double)(pos.getY() + state.getHeight(world, pos) + 0.11111111F); } @@ -70,7 +65,7 @@ public interface IForgeFluid * @return null for default behavior, true if the box is within the material, false if it was not. */ @Nullable - default Boolean isAABBInsideMaterial(FluidState state, IWorldReader world, BlockPos pos, AxisAlignedBB boundingBox, Material materialIn) + default Boolean isAABBInsideMaterial(FluidState state, LevelReader world, BlockPos pos, AABB boundingBox, Material materialIn) { return null; } @@ -84,7 +79,7 @@ public interface IForgeFluid * @return null for default behavior, true if the box is within the material, false if it was not. */ @Nullable - default Boolean isAABBInsideLiquid(FluidState state, IWorldReader world, BlockPos pos, AxisAlignedBB boundingBox) + default Boolean isAABBInsideLiquid(FluidState state, LevelReader world, BlockPos pos, AABB boundingBox) { return null; } @@ -98,7 +93,7 @@ public interface IForgeFluid * @return The amount of the explosion absorbed. */ @SuppressWarnings("deprecation") - default float getExplosionResistance(FluidState state, IBlockReader world, BlockPos pos, Explosion explosion) + default float getExplosionResistance(FluidState state, BlockGetter world, BlockPos pos, Explosion explosion) { return state.getExplosionResistance(); } diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeFluidState.java b/src/main/java/net/minecraftforge/common/extensions/IForgeFluidState.java index 40f5682518..ab14be80bd 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeFluidState.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeFluidState.java @@ -19,21 +19,18 @@ package net.minecraftforge.common.extensions; -import javax.annotation.Nullable; - -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.entity.Entity; -import net.minecraft.fluid.Fluid; -import net.minecraft.fluid.FluidState; -import net.minecraft.tags.Tag; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.Explosion; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorldReader; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.tags.SetTag; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Explosion; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelReader; public interface IForgeFluidState { - default FluidState getFluidState() + private FluidState self() { return (FluidState)this; } @@ -49,10 +46,10 @@ public interface IForgeFluidState * @param tag to test for. * @param testingHead when true, its testing the entities head for vision, breathing ect... otherwise its testing the body, for swimming and movement adjustment. */ - default boolean isEntityInside(IWorldReader world, BlockPos pos, Entity entity, double yToTest, Tag tag, boolean testingHead) + default boolean isEntityInside(LevelReader world, BlockPos pos, Entity entity, double yToTest, SetTag tag, boolean testingHead) { // return ifluidstate.isTagged(p_213290_1_) && d0 < (double)((float)blockpos.getY() + ifluidstate.getActualHeight(this.world, blockpos) + 0.11111111F); - return getFluidState().getType().isEntityInside(getFluidState(), world, pos, entity, yToTest, tag, testingHead); + return self().getType().isEntityInside(self(), world, pos, entity, yToTest, tag, testingHead); } @@ -65,9 +62,9 @@ public interface IForgeFluidState * @param explosion The explosion * @return The amount of the explosion absorbed. */ - default float getExplosionResistance(IBlockReader world, BlockPos pos, Explosion explosion) + default float getExplosionResistance(BlockGetter world, BlockPos pos, Explosion explosion) { - return getFluidState().getType().getExplosionResistance(getFluidState(), world, pos, explosion); + return self().getType().getExplosionResistance(self(), world, pos, explosion); } /** diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgePacketBuffer.java b/src/main/java/net/minecraftforge/common/extensions/IForgeFriendlyByteBuf.java similarity index 88% rename from src/main/java/net/minecraftforge/common/extensions/IForgePacketBuffer.java rename to src/main/java/net/minecraftforge/common/extensions/IForgeFriendlyByteBuf.java index 97017ab7ca..31a7040b2a 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgePacketBuffer.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeFriendlyByteBuf.java @@ -20,8 +20,8 @@ package net.minecraftforge.common.extensions; import com.google.common.base.Preconditions; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.ResourceLocation; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.registries.ForgeRegistry; import net.minecraftforge.registries.IForgeRegistry; @@ -34,12 +34,13 @@ import java.util.Objects; /** * Extension-Interface providing methods for writing registry-id's instead of their registry-names. */ -public interface IForgePacketBuffer +public interface IForgeFriendlyByteBuf { - default PacketBuffer getBuffer() + private FriendlyByteBuf self() { - return (PacketBuffer) this; + return (FriendlyByteBuf) this; } + /** * Writes the given entries integer id to the buffer. Notice however that this will only write the id of the given entry and will not check whether it actually exists * in the given registry. Therefore no safety checks can be performed whilst reading it and if the entry is not in the registry a default value will be written. @@ -51,7 +52,7 @@ public interface IForgePacketBuffer { ForgeRegistry forgeRegistry = (ForgeRegistry) registry; int id = forgeRegistry.getID(entry); - getBuffer().writeVarInt(id); + self().writeVarInt(id); } /** @@ -64,7 +65,7 @@ public interface IForgePacketBuffer { ForgeRegistry forgeRegistry = (ForgeRegistry) registry; int id = forgeRegistry.getID(entryKey); - getBuffer().writeVarInt(id); + self().writeVarInt(id); } /** @@ -75,7 +76,7 @@ public interface IForgePacketBuffer default > T readRegistryIdUnsafe(@Nonnull IForgeRegistry registry) { ForgeRegistry forgeRegistry = (ForgeRegistry) registry; - int id = getBuffer().readVarInt(); + int id = self().readVarInt(); return forgeRegistry.getValue(id); } @@ -97,8 +98,8 @@ public interface IForgePacketBuffer ResourceLocation name = retrievedRegistry.getRegistryName(); Preconditions.checkArgument(retrievedRegistry.containsValue(entry),"Cannot find %s in %s",entry.getRegistryName()!=null?entry.getRegistryName():entry,name); ForgeRegistry reg = (ForgeRegistry)retrievedRegistry; - getBuffer().writeResourceLocation(name); //TODO change to writing a varInt once registries use id's - getBuffer().writeVarInt(reg.getID(entry)); + self().writeResourceLocation(name); //TODO change to writing a varInt once registries use id's + self().writeVarInt(reg.getID(entry)); } /** @@ -109,9 +110,9 @@ public interface IForgePacketBuffer */ default > T readRegistryId() { - ResourceLocation location = getBuffer().readResourceLocation(); //TODO change to reading a varInt once registries use id's + ResourceLocation location = self().readResourceLocation(); //TODO change to reading a varInt once registries use id's ForgeRegistry registry = RegistryManager.ACTIVE.getRegistry(location); - return registry.getValue(getBuffer().readVarInt()); + return registry.getValue(self().readVarInt()); } /** @@ -137,10 +138,10 @@ public interface IForgePacketBuffer default void writeFluidStack(FluidStack stack) { if (stack.isEmpty()) { - getBuffer().writeBoolean(false); + self().writeBoolean(false); } else { - getBuffer().writeBoolean(true); - stack.writeToPacket(getBuffer()); + self().writeBoolean(true); + stack.writeToPacket(self()); } } @@ -149,6 +150,6 @@ public interface IForgePacketBuffer */ default FluidStack readFluidStack() { - return !getBuffer().readBoolean() ? FluidStack.EMPTY : FluidStack.readFromPacket(getBuffer()); + return !self().readBoolean() ? FluidStack.EMPTY : FluidStack.readFromPacket(self()); } } diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeItem.java b/src/main/java/net/minecraftforge/common/extensions/IForgeItem.java index 5847f4e80f..6ba717ed82 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeItem.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeItem.java @@ -26,45 +26,40 @@ import javax.annotation.Nullable; import com.google.common.collect.Multimap; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.client.renderer.entity.model.BipedModel; -import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer; -import net.minecraft.entity.Entity; -import net.minecraft.entity.MobEntity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.ai.attributes.Attribute; -import net.minecraft.entity.ai.attributes.AttributeModifier; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.monster.EndermanEntity; -import net.minecraft.entity.monster.piglin.PiglinTasks; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ArmorItem; -import net.minecraft.item.ArmorMaterial; -import net.minecraft.item.Items; -import net.minecraft.inventory.EquipmentSlotType; -import net.minecraft.item.Item; -import net.minecraft.item.AxeItem; -import net.minecraft.item.ItemGroup; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.item.crafting.IRecipeType; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.world.World; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.Mob; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.ai.attributes.Attribute; +import net.minecraft.world.entity.ai.attributes.AttributeModifier; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.monster.EnderMan; +import net.minecraft.world.entity.monster.piglin.PiglinAi; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ArmorItem; +import net.minecraft.world.item.ArmorMaterials; +import net.minecraft.world.item.Items; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.AxeItem; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.InteractionResult; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.network.chat.Component; +import net.minecraft.world.level.Level; import net.minecraftforge.common.ToolType; // TODO review most of the methods in this "patch" public interface IForgeItem { - // Helpers for accessing Item data - default Item getItem() + private Item self() { return (Item) this; } @@ -73,9 +68,9 @@ public interface IForgeItem * ItemStack sensitive version of getItemAttributeModifiers */ @SuppressWarnings("deprecation") - default Multimap getAttributeModifiers(EquipmentSlotType slot, ItemStack stack) + default Multimap getAttributeModifiers(EquipmentSlot slot, ItemStack stack) { - return getItem().getDefaultAttributeModifiers(slot); + return self().getDefaultAttributeModifiers(slot); } /** @@ -86,7 +81,7 @@ public interface IForgeItem * @param player The player that dropped the item * @param item The item stack, before the item is removed. */ - default boolean onDroppedByPlayer(ItemStack item, PlayerEntity player) + default boolean onDroppedByPlayer(ItemStack item, Player player) { return true; } @@ -100,7 +95,7 @@ public interface IForgeItem * @param displayName the name that will be displayed unless it is changed in * this method. */ - default ITextComponent getHighlightTip(ItemStack item, ITextComponent displayName) + default Component getHighlightTip(ItemStack item, Component displayName) { return displayName; } @@ -110,9 +105,9 @@ public interface IForgeItem * * @return Return PASS to allow vanilla handling, any other to skip normal code. */ - default ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context) + default InteractionResult onItemUseFirst(ItemStack stack, UseOnContext context) { - return ActionResultType.PASS; + return InteractionResult.PASS; } /** @@ -122,7 +117,7 @@ public interface IForgeItem */ default boolean isPiglinCurrency(ItemStack stack) { - return stack.getItem() == PiglinTasks.BARTERING_ITEM; + return stack.getItem() == PiglinAi.BARTERING_ITEM; } /** @@ -135,7 +130,7 @@ public interface IForgeItem */ default boolean makesPiglinsNeutral(ItemStack stack, LivingEntity wearer) { - return stack.getItem() instanceof ArmorItem && ((ArmorItem) stack.getItem()).getMaterial() == ArmorMaterial.GOLD; + return stack.getItem() instanceof ArmorItem && ((ArmorItem) stack.getItem()).getMaterial() == ArmorMaterials.GOLD; } /** @@ -171,7 +166,7 @@ public interface IForgeItem * @return The NBT tag */ @Nullable - default CompoundNBT getShareTag(ItemStack stack) + default CompoundTag getShareTag(ItemStack stack) { return stack.getTag(); } @@ -183,7 +178,7 @@ public interface IForgeItem * @param stack The stack that received NBT * @param nbt Received NBT, can be null */ - default void readShareTag(ItemStack stack, @Nullable CompoundNBT nbt) + default void readShareTag(ItemStack stack, @Nullable CompoundTag nbt) { stack.setTag(nbt); } @@ -199,7 +194,7 @@ public interface IForgeItem * @param player The Player that is wielding the item * @return True to prevent harvesting, false to continue as normal */ - default boolean onBlockStartBreak(ItemStack itemstack, BlockPos pos, PlayerEntity player) + default boolean onBlockStartBreak(ItemStack itemstack, BlockPos pos, Player player) { return false; } @@ -226,7 +221,7 @@ public interface IForgeItem * @param entity The entity being attacked * @return True to cancel the rest of the interaction. */ - default boolean onLeftClickEntity(ItemStack stack, PlayerEntity player, Entity entity) + default boolean onLeftClickEntity(ItemStack stack, Player player, Entity entity) { return false; } @@ -245,7 +240,7 @@ public interface IForgeItem { return ItemStack.EMPTY; } - return new ItemStack(getItem().getCraftingRemainingItem()); + return new ItemStack(self().getCraftingRemainingItem()); } /** @@ -257,7 +252,7 @@ public interface IForgeItem @SuppressWarnings("deprecation") default boolean hasContainerItem(ItemStack stack) { - return getItem().hasCraftingRemainingItem(); + return self().hasCraftingRemainingItem(); } /** @@ -268,7 +263,7 @@ public interface IForgeItem * @param world The world the entity is in * @return The normal lifespan in ticks. */ - default int getEntityLifespan(ItemStack itemStack, World world) + default int getEntityLifespan(ItemStack itemStack, Level world) { return 6000; } @@ -300,7 +295,7 @@ public interface IForgeItem * @return A new Entity object to spawn or null */ @Nullable - default Entity createEntity(World world, Entity location, ItemStack itemstack) + default Entity createEntity(Level world, Entity location, ItemStack itemstack) { return null; } @@ -325,9 +320,9 @@ public interface IForgeItem * * @return A list of all tabs that this item could possibly be one. */ - default java.util.Collection getCreativeTabs() + default java.util.Collection getCreativeTabs() { - return java.util.Collections.singletonList(getItem().getItemCategory()); + return java.util.Collections.singletonList(self().getItemCategory()); } /** @@ -353,7 +348,7 @@ public interface IForgeItem * @param player The Player that is wielding the item * @return */ - default boolean doesSneakBypassUse(ItemStack stack, net.minecraft.world.IWorldReader world, BlockPos pos, PlayerEntity player) + default boolean doesSneakBypassUse(ItemStack stack, net.minecraft.world.level.LevelReader world, BlockPos pos, Player player) { return false; } @@ -361,7 +356,7 @@ public interface IForgeItem /** * Called to tick armor in the armor slot. Override to do something */ - default void onArmorTick(ItemStack stack, World world, PlayerEntity player) + default void onArmorTick(ItemStack stack, Level world, Player player) { } @@ -374,9 +369,9 @@ public interface IForgeItem * @param entity The entity trying to equip the armor * @return True if the given ItemStack can be inserted in the slot */ - default boolean canEquip(ItemStack stack, EquipmentSlotType armorType, Entity entity) + default boolean canEquip(ItemStack stack, EquipmentSlot armorType, Entity entity) { - return MobEntity.getEquipmentSlotForItem(stack) == armorType; + return Mob.getEquipmentSlotForItem(stack) == armorType; } /** @@ -390,7 +385,7 @@ public interface IForgeItem * decide */ @Nullable - default EquipmentSlotType getEquipmentSlot(ItemStack stack) + default EquipmentSlot getEquipmentSlot(ItemStack stack) { return null; } @@ -421,37 +416,7 @@ public interface IForgeItem * @return Path of texture to bind, or null to use default */ @Nullable - default String getArmorTexture(ItemStack stack, Entity entity, EquipmentSlotType slot, String type) - { - return null; - } - - /** - * Returns the font renderer used to render tooltips and overlays for this item. - * Returning null will use the standard font renderer. - * - * @param stack The current item stack - * @return A instance of FontRenderer or null to use default - */ - @OnlyIn(Dist.CLIENT) - @Nullable - default net.minecraft.client.gui.FontRenderer getFontRenderer(ItemStack stack) - { - return null; - } - - /** - * Override this method to have an item handle its own armor rendering. - * - * @param entityLiving The entity wearing the armor - * @param itemStack The itemStack to render the model of - * @param armorSlot The slot the armor is in - * @param _default Original armor model. Will have attributes set. - * @return A ModelBiped to render instead of the default - */ - @OnlyIn(Dist.CLIENT) - @Nullable - default > A getArmorModel(LivingEntity entityLiving, ItemStack itemStack, EquipmentSlotType armorSlot, A _default) + default String getArmorTexture(ItemStack stack, Entity entity, EquipmentSlot slot, String type) { return null; } @@ -467,21 +432,6 @@ public interface IForgeItem return false; } - /** - * Called when the client starts rendering the HUD, for whatever item the player - * currently has as a helmet. This is where pumpkins would render there overlay. - * - * @param stack The ItemStack that is equipped - * @param player Reference to the current client entity - * @param resolution Resolution information about the current viewport and - * configured GUI Scale - * @param partialTicks Partial ticks for the renderer, useful for interpolation - */ - @OnlyIn(Dist.CLIENT) - default void renderHelmetOverlay(ItemStack stack, PlayerEntity player, int width, int height, float partialTicks) - { - } - /** * Return the itemDamage represented by this ItemStack. Defaults to the Damage * entry in the stack NBT, but can be overridden here for other sources. @@ -529,7 +479,7 @@ public interface IForgeItem */ default int getRGBDurabilityForDisplay(ItemStack stack) { - return MathHelper.hsvToRgb(Math.max(0.0F, (float) (1.0F - getDurabilityForDisplay(stack))) / 3.0F, 1.0F, 1.0F); + return Mth.hsvToRgb(Math.max(0.0F, (float) (1.0F - getDurabilityForDisplay(stack))) / 3.0F, 1.0F, 1.0F); } /** @@ -542,7 +492,7 @@ public interface IForgeItem @SuppressWarnings("deprecation") default int getMaxDamage(ItemStack stack) { - return getItem().getMaxDamage(); + return self().getMaxDamage(); } /** @@ -578,7 +528,7 @@ public interface IForgeItem */ default boolean canHarvestBlock(ItemStack stack, BlockState state) { - return getItem().isCorrectToolForDrops(state); + return self().isCorrectToolForDrops(state); } /** @@ -591,7 +541,7 @@ public interface IForgeItem @SuppressWarnings("deprecation") default int getItemStackLimit(ItemStack stack) { - return getItem().getMaxStackSize(); + return self().getMaxStackSize(); } Set getToolTypes(ItemStack stack); @@ -606,7 +556,7 @@ public interface IForgeItem * @param blockState The block to harvest * @return Harvest level, or -1 if not the specified tool type. */ - int getHarvestLevel(ItemStack stack, ToolType tool, @Nullable PlayerEntity player, @Nullable BlockState blockState); + int getHarvestLevel(ItemStack stack, ToolType tool, @Nullable Player player, @Nullable BlockState blockState); /** * ItemStack sensitive version of getItemEnchantability @@ -616,7 +566,7 @@ public interface IForgeItem */ default int getItemEnchantability(ItemStack stack) { - return getItem().getEnchantmentValue(); + return self().getEnchantmentValue(); } /** @@ -632,7 +582,7 @@ public interface IForgeItem * @param enchantment the enchantment to be applied * @return true if the enchantment can be applied to this item */ - default boolean canApplyAtEnchantingTable(ItemStack stack, net.minecraft.enchantment.Enchantment enchantment) + default boolean canApplyAtEnchantingTable(ItemStack stack, net.minecraft.world.item.enchantment.Enchantment enchantment) { return enchantment.category.canEnchant(stack.getItem()); } @@ -716,7 +666,7 @@ public interface IForgeItem * capabilities for the life of this item. */ @Nullable - default net.minecraftforge.common.capabilities.ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundNBT nbt) + default net.minecraftforge.common.capabilities.ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundTag nbt) { return null; } @@ -760,13 +710,7 @@ public interface IForgeItem * it not act as a fuel. Return -1 to let the default vanilla logic * decide. */ - default int getBurnTime(ItemStack itemStack, @Nullable IRecipeType recipeType) - { - return getBurnTime(itemStack); - } - - @Deprecated // use variant with IRecipeType - default int getBurnTime(ItemStack stack) + default int getBurnTime(ItemStack itemStack, @Nullable RecipeType recipeType) { return -1; } @@ -779,17 +723,10 @@ public interface IForgeItem * @param world the world the horse is in * @param horse the horse wearing this armor */ - default void onHorseArmorTick(ItemStack stack, World world, MobEntity horse) + default void onHorseArmorTick(ItemStack stack, Level world, Mob horse) { } - /** - * @return This Item's renderer, or the default instance if it does not have - * one. - */ - @OnlyIn(Dist.CLIENT) - ItemStackTileEntityRenderer getItemStackTileEntityRenderer(); - /** * Retrieves a list of tags names this is known to be associated with. * This should be used in favor of TagCollection.getOwningTags, as this caches the result and automatically updates when the TagCollection changes. @@ -818,7 +755,7 @@ public interface IForgeItem * @param endermanEntity The enderman that the player look * @return true if this Item can be used to hide player head for enderman */ - default boolean isEnderMask(ItemStack stack, PlayerEntity player, EndermanEntity endermanEntity) + default boolean isEnderMask(ItemStack stack, Player player, EnderMan endermanEntity) { return stack.getItem() == Blocks.CARVED_PUMPKIN.asItem(); } @@ -861,6 +798,6 @@ public interface IForgeItem */ default boolean isDamageable(ItemStack stack) { - return this.getItem().canBeDepleted(); + return self().canBeDepleted(); } } diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeItemStack.java b/src/main/java/net/minecraftforge/common/extensions/IForgeItemStack.java index 0f66ff3f72..ef11a48b41 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeItemStack.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeItemStack.java @@ -23,37 +23,36 @@ import java.util.Set; import javax.annotation.Nullable; -import net.minecraft.entity.monster.EndermanEntity; -import net.minecraft.item.crafting.IRecipeType; -import net.minecraft.util.CachedBlockInfo; -import net.minecraft.block.BlockState; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.entity.Entity; -import net.minecraft.entity.MobEntity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.inventory.EquipmentSlotType; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.world.entity.monster.EnderMan; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.level.block.state.pattern.BlockInWorld; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.enchantment.Enchantment; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.Mob; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.nbt.CompoundTag; import net.minecraft.stats.Stats; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.IFormattableTextComponent; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.world.World; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.Component; +import net.minecraft.world.level.Level; import net.minecraftforge.common.ToolType; import net.minecraftforge.common.capabilities.ICapabilitySerializable; /* * Extension added to ItemStack that bounces to ItemSack sensitive Item methods. Typically this is just for convince. */ -public interface IForgeItemStack extends ICapabilitySerializable +public interface IForgeItemStack extends ICapabilitySerializable { // Helpers for accessing Item data - default ItemStack getStack() + private ItemStack self() { return (ItemStack)this; } @@ -66,7 +65,7 @@ public interface IForgeItemStack extends ICapabilitySerializable */ default ItemStack getContainerItem() { - return getStack().getItem().getContainerItem(getStack()); + return self().getItem().getContainerItem(self()); } /** @@ -76,7 +75,7 @@ public interface IForgeItemStack extends ICapabilitySerializable */ default boolean hasContainerItem() { - return getStack().getItem().hasContainerItem(getStack()); + return self().getItem().hasContainerItem(self()); } /** @@ -84,15 +83,9 @@ public interface IForgeItemStack extends ICapabilitySerializable * it not act as a fuel. Return -1 to let the default vanilla logic * decide. */ - default int getBurnTime(@Nullable IRecipeType recipeType) + default int getBurnTime(@Nullable RecipeType recipeType) { - return getStack().getItem().getBurnTime(getStack(), recipeType); - } - - @Deprecated // use variant with IRecipeType - default int getBurnTime() - { - return getBurnTime(null); + return self().getItem().getBurnTime(self(), recipeType); } /** @@ -104,26 +97,26 @@ public interface IForgeItemStack extends ICapabilitySerializable * @param state The block to harvest * @return Harvest level, or -1 if not the specified tool type. */ - default int getHarvestLevel(ToolType tool, @Nullable PlayerEntity player, @Nullable BlockState state) + default int getHarvestLevel(ToolType tool, @Nullable Player player, @Nullable BlockState state) { - return getStack().getItem().getHarvestLevel(getStack(), tool, player, state); + return self().getItem().getHarvestLevel(self(), tool, player, state); } default Set getToolTypes() { - return getStack().getItem().getToolTypes(getStack()); + return self().getItem().getToolTypes(self()); } - default ActionResultType onItemUseFirst(ItemUseContext context) + default InteractionResult onItemUseFirst(UseOnContext context) { - PlayerEntity entityplayer = context.getPlayer(); + Player entityplayer = context.getPlayer(); BlockPos blockpos = context.getClickedPos(); - CachedBlockInfo blockworldstate = new CachedBlockInfo(context.getLevel(), blockpos, false); - if (entityplayer != null && !entityplayer.abilities.mayBuild && !getStack().hasAdventureModePlaceTagForBlock(context.getLevel().getTagManager(), blockworldstate)) { - return ActionResultType.PASS; + BlockInWorld blockworldstate = new BlockInWorld(context.getLevel(), blockpos, false); + if (entityplayer != null && !entityplayer.getAbilities().mayBuild && !self().hasAdventureModePlaceTagForBlock(context.getLevel().getTagManager(), blockworldstate)) { + return InteractionResult.PASS; } else { - Item item = getStack().getItem(); - ActionResultType enumactionresult = item.onItemUseFirst(getStack(), context); - if (entityplayer != null && enumactionresult == ActionResultType.SUCCESS) { + Item item = self().getItem(); + InteractionResult enumactionresult = item.onItemUseFirst(self(), context); + if (entityplayer != null && enumactionresult == InteractionResult.SUCCESS) { entityplayer.awardStat(Stats.ITEM_USED.get(item)); } @@ -131,10 +124,10 @@ public interface IForgeItemStack extends ICapabilitySerializable } } - default CompoundNBT serializeNBT() + default CompoundTag serializeNBT() { - CompoundNBT ret = new CompoundNBT(); - getStack().save(ret); + CompoundTag ret = new CompoundTag(); + self().save(ret); return ret; } /** @@ -147,9 +140,9 @@ public interface IForgeItemStack extends ICapabilitySerializable * @param player The Player that is wielding the item * @return True to prevent harvesting, false to continue as normal */ - default boolean onBlockStartBreak(BlockPos pos, PlayerEntity player) + default boolean onBlockStartBreak(BlockPos pos, Player player) { - return !getStack().isEmpty() && getStack().getItem().onBlockStartBreak(getStack(), pos, player); + return !self().isEmpty() && self().getItem().onBlockStartBreak(self(), pos, player); } /** @@ -161,7 +154,7 @@ public interface IForgeItemStack extends ICapabilitySerializable */ default boolean shouldCauseBlockBreakReset(ItemStack newStack) { - return getStack().getItem().shouldCauseBlockBreakReset(getStack(), newStack); + return self().getItem().shouldCauseBlockBreakReset(self(), newStack); } /** @@ -178,7 +171,7 @@ public interface IForgeItemStack extends ICapabilitySerializable */ default boolean canApplyAtEnchantingTable(Enchantment enchantment) { - return getStack().getItem().canApplyAtEnchantingTable(getStack(), enchantment); + return self().getItem().canApplyAtEnchantingTable(self(), enchantment); } /** @@ -188,7 +181,7 @@ public interface IForgeItemStack extends ICapabilitySerializable */ default int getItemEnchantability() { - return getStack().getItem().getItemEnchantability(getStack()); + return self().getItem().getItemEnchantability(self()); } /** @@ -201,9 +194,9 @@ public interface IForgeItemStack extends ICapabilitySerializable * decide */ @Nullable - default EquipmentSlotType getEquipmentSlot() + default EquipmentSlot getEquipmentSlot() { - return getStack().getItem().getEquipmentSlot(getStack()); + return self().getItem().getEquipmentSlot(self()); } /** @@ -216,7 +209,7 @@ public interface IForgeItemStack extends ICapabilitySerializable */ default boolean canDisableShield(ItemStack shield, LivingEntity entity, LivingEntity attacker) { - return getStack().getItem().canDisableShield(getStack(), shield, entity, attacker); + return self().getItem().canDisableShield(self(), shield, entity, attacker); } /** @@ -227,7 +220,7 @@ public interface IForgeItemStack extends ICapabilitySerializable */ default boolean isShield(@Nullable LivingEntity entity) { - return getStack().getItem().isShield(getStack(), entity); + return self().getItem().isShield(self(), entity); } /** @@ -238,7 +231,7 @@ public interface IForgeItemStack extends ICapabilitySerializable */ default boolean onEntitySwing(LivingEntity entity) { - return getStack().getItem().onEntitySwing(getStack(), entity); + return self().getItem().onEntitySwing(self(), entity); } /** @@ -250,7 +243,7 @@ public interface IForgeItemStack extends ICapabilitySerializable */ default void onUsingTick(LivingEntity player, int count) { - getStack().getItem().onUsingTick(getStack(), player, count); + self().getItem().onUsingTick(self(), player, count); } /** @@ -260,9 +253,9 @@ public interface IForgeItemStack extends ICapabilitySerializable * @param world The world the entity is in * @return The normal lifespan in ticks. */ - default int getEntityLifespan(World world) + default int getEntityLifespan(Level world) { - return getStack().getItem().getEntityLifespan(getStack(), world); + return self().getItem().getEntityLifespan(self(), world); } /** @@ -275,7 +268,7 @@ public interface IForgeItemStack extends ICapabilitySerializable */ default boolean onEntityItemUpdate(ItemEntity entity) { - return getStack().getItem().onEntityItemUpdate(getStack(), entity); + return self().getItem().onEntityItemUpdate(self(), entity); } /** @@ -284,15 +277,15 @@ public interface IForgeItemStack extends ICapabilitySerializable */ default float getXpRepairRatio() { - return getStack().getItem().getXpRepairRatio(getStack()); + return self().getItem().getXpRepairRatio(self()); } /** * Called to tick armor in the armor slot. Override to do something */ - default void onArmorTick(World world, PlayerEntity player) + default void onArmorTick(Level world, Player player) { - getStack().getItem().onArmorTick(getStack(), world, player); + self().getItem().onArmorTick(self(), world, player); } /** @@ -302,9 +295,9 @@ public interface IForgeItemStack extends ICapabilitySerializable * @param world the world the horse is in * @param horse the horse wearing this armor */ - default void onHorseArmorTick(World world, MobEntity horse) + default void onHorseArmorTick(Level world, Mob horse) { - getStack().getItem().onHorseArmorTick(getStack(), world, horse); + self().getItem().onHorseArmorTick(self(), world, horse); } /** @@ -315,9 +308,9 @@ public interface IForgeItemStack extends ICapabilitySerializable * @param entity The entity trying to equip the armor * @return True if the given ItemStack can be inserted in the slot */ - default boolean canEquip(EquipmentSlotType armorType, Entity entity) + default boolean canEquip(EquipmentSlot armorType, Entity entity) { - return getStack().getItem().canEquip(getStack(), armorType, entity); + return self().getItem().canEquip(self(), armorType, entity); } /** @@ -328,7 +321,7 @@ public interface IForgeItemStack extends ICapabilitySerializable */ default boolean isBookEnchantable(ItemStack book) { - return getStack().getItem().isBookEnchantable(getStack(), book); + return self().getItem().isBookEnchantable(self(), book); } @@ -339,9 +332,9 @@ public interface IForgeItemStack extends ICapabilitySerializable * * @param player The player that dropped the item */ - default boolean onDroppedByPlayer(PlayerEntity player) + default boolean onDroppedByPlayer(Player player) { - return getStack().getItem().onDroppedByPlayer(getStack(), player); + return self().getItem().onDroppedByPlayer(self(), player); } /** @@ -352,9 +345,9 @@ public interface IForgeItemStack extends ICapabilitySerializable * @param displayName the name that will be displayed unless it is changed in * this method. */ - default ITextComponent getHighlightTip(ITextComponent displayName) + default Component getHighlightTip(Component displayName) { - return getStack().getItem().getHighlightTip(getStack(), displayName); + return self().getItem().getHighlightTip(self(), displayName); } /** @@ -371,9 +364,9 @@ public interface IForgeItemStack extends ICapabilitySerializable * @return The NBT tag */ @Nullable - default CompoundNBT getShareTag() + default CompoundTag getShareTag() { - return getStack().getItem().getShareTag(getStack()); + return self().getItem().getShareTag(self()); } /** @@ -382,9 +375,9 @@ public interface IForgeItemStack extends ICapabilitySerializable * * @param nbt Received NBT, can be null */ - default void readShareTag(@Nullable CompoundNBT nbt) + default void readShareTag(@Nullable CompoundTag nbt) { - getStack().getItem().readShareTag(getStack(), nbt); + self().getItem().readShareTag(self(), nbt); } /** @@ -396,9 +389,9 @@ public interface IForgeItemStack extends ICapabilitySerializable * @param player The Player that is wielding the item * @return */ - default boolean doesSneakBypassUse(net.minecraft.world.IWorldReader world, BlockPos pos, PlayerEntity player) + default boolean doesSneakBypassUse(net.minecraft.world.level.LevelReader world, BlockPos pos, Player player) { - return getStack().isEmpty() || getStack().getItem().doesSneakBypassUse(getStack(), world, pos, player); + return self().isEmpty() || self().getItem().doesSneakBypassUse(self(), world, pos, player); } /** @@ -408,8 +401,8 @@ public interface IForgeItemStack extends ICapabilitySerializable */ default boolean areShareTagsEqual(ItemStack other) { - CompoundNBT shareTagA = getStack().getShareTag(); - CompoundNBT shareTagB = other.getShareTag(); + CompoundTag shareTagA = self().getShareTag(); + CompoundTag shareTagB = other.getShareTag(); if (shareTagA == null) return shareTagB == null; else @@ -425,11 +418,11 @@ public interface IForgeItemStack extends ICapabilitySerializable */ default boolean equals(ItemStack other, boolean limitTags) { - if (getStack().isEmpty()) + if (self().isEmpty()) return other.isEmpty(); else - return !other.isEmpty() && getStack().getCount() == other.getCount() && getStack().getItem() == other.getItem() && - (limitTags ? getStack().areShareTagsEqual(other) : ItemStack.tagMatches(getStack(), other)); + return !other.isEmpty() && self().getCount() == other.getCount() && self().getItem() == other.getItem() && + (limitTags ? self().areShareTagsEqual(other) : ItemStack.tagMatches(self(), other)); } /** @@ -439,7 +432,7 @@ public interface IForgeItemStack extends ICapabilitySerializable */ default boolean isRepairable() { - return getStack().getItem().isRepairable(getStack()); + return self().getItem().isRepairable(self()); } /** @@ -449,7 +442,7 @@ public interface IForgeItemStack extends ICapabilitySerializable */ default boolean isPiglinCurrency() { - return getStack().getItem().isPiglinCurrency(getStack()); + return self().getItem().isPiglinCurrency(self()); } /** @@ -462,7 +455,7 @@ public interface IForgeItemStack extends ICapabilitySerializable */ default boolean makesPiglinsNeutral(LivingEntity wearer) { - return getStack().getItem().makesPiglinsNeutral(getStack(), wearer); + return self().getItem().makesPiglinsNeutral(self(), wearer); } /** @@ -472,9 +465,9 @@ public interface IForgeItemStack extends ICapabilitySerializable * @param endermanEntity The enderman that the player look * @return true if this Item can be used. */ - default boolean isEnderMask(PlayerEntity player, EndermanEntity endermanEntity) + default boolean isEnderMask(Player player, EnderMan endermanEntity) { - return getStack().getItem().isEnderMask(getStack(), player, endermanEntity); + return self().getItem().isEnderMask(self(), player, endermanEntity); } /** @@ -486,7 +479,7 @@ public interface IForgeItemStack extends ICapabilitySerializable */ default boolean canElytraFly(LivingEntity entity) { - return getStack().getItem().canElytraFly(getStack(), entity); + return self().getItem().canElytraFly(self(), entity); } /** @@ -502,6 +495,6 @@ public interface IForgeItemStack extends ICapabilitySerializable */ default boolean elytraFlightTick(LivingEntity entity, int flightTicks) { - return getStack().getItem().elytraFlightTick(getStack(), entity, flightTicks); + return self().getItem().elytraFlightTick(self(), entity, flightTicks); } } diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeWorld.java b/src/main/java/net/minecraftforge/common/extensions/IForgeLevel.java similarity index 96% rename from src/main/java/net/minecraftforge/common/extensions/IForgeWorld.java rename to src/main/java/net/minecraftforge/common/extensions/IForgeLevel.java index 85644f3f4b..a628858c5f 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeWorld.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeLevel.java @@ -21,7 +21,7 @@ package net.minecraftforge.common.extensions; import net.minecraftforge.common.capabilities.ICapabilityProvider; -public interface IForgeWorld extends ICapabilityProvider +public interface IForgeLevel extends ICapabilityProvider { /** * The maximum radius to scan for entities when trying to check bounding boxes. Vanilla's default is diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeChunk.java b/src/main/java/net/minecraftforge/common/extensions/IForgeLevelChunk.java similarity index 93% rename from src/main/java/net/minecraftforge/common/extensions/IForgeChunk.java rename to src/main/java/net/minecraftforge/common/extensions/IForgeLevelChunk.java index 20c18fb53f..21d396103f 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeChunk.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeLevelChunk.java @@ -21,7 +21,7 @@ package net.minecraftforge.common.extensions; import net.minecraftforge.common.capabilities.ICapabilityProvider; -public interface IForgeChunk extends ICapabilityProvider +public interface IForgeLevelChunk extends ICapabilityProvider { } diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeMobEffect.java b/src/main/java/net/minecraftforge/common/extensions/IForgeMobEffect.java new file mode 100644 index 0000000000..fd0542ab8f --- /dev/null +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeMobEffect.java @@ -0,0 +1,57 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.common.extensions; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.effect.MobEffect; +import net.minecraft.world.effect.MobEffectInstance; + +public interface IForgeMobEffect +{ + private MobEffect self() { + return (MobEffect)this; + } + + /** + * Get a fresh list of items that can cure this Potion. + * All new PotionEffects created from this Potion will call this to initialize the default curative items + * @see PotionEffect#getCurativeItems + * @return A list of items that can cure this Potion + */ + default List getCurativeItems() { + ArrayList ret = new ArrayList(); + ret.add(new ItemStack(Items.MILK_BUCKET)); + return ret; + } + + /** + * Used for determining {@code PotionEffect} sort order in GUIs. + * Defaults to the {@code PotionEffect}'s liquid color. + * @param potionEffect the {@code PotionEffect} instance containing the potion + * @return a value used to sort {@code PotionEffect}s in GUIs + */ + default int getGuiSortColor(MobEffectInstance potionEffect) { + return self().getColor(); + } +} diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeMobEffectInstance.java b/src/main/java/net/minecraftforge/common/extensions/IForgeMobEffectInstance.java new file mode 100644 index 0000000000..def17f9ff3 --- /dev/null +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeMobEffectInstance.java @@ -0,0 +1,69 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.common.extensions; + +import java.util.List; + +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.world.effect.MobEffectInstance; + +public interface IForgeMobEffectInstance +{ + + /*** + * Returns a list of curative items for the potion effect + * By default, this list is initialized using {@link Potion#getCurativeItems} + * + * @return The list (ItemStack) of curative items for the potion effect + */ + List getCurativeItems(); + + /*** + * Checks the given ItemStack to see if it is in the list of curative items for the potion effect + * @param stack The ItemStack being checked against the list of curative items for this PotionEffect + * @return true if the given ItemStack is in the list of curative items for this PotionEffect, false otherwise + */ + default boolean isCurativeItem(ItemStack stack) { + return this.getCurativeItems().stream().anyMatch(e -> e.sameItem(stack)); + } + + /*** + * Sets the list of curative items for this potion effect, overwriting any already present + * @param curativeItems The list of ItemStacks being set to the potion effect + */ + void setCurativeItems(List curativeItems); + + /*** + * Adds the given stack to the list of curative items for this PotionEffect + * @param stack The ItemStack being added to the curative item list + */ + default void addCurativeItem(ItemStack stack) { + if (!this.isCurativeItem(stack)) + this.getCurativeItems().add(stack); + } + + default void writeCurativeItems(CompoundTag nbt) { + ListTag list = new ListTag(); + getCurativeItems().forEach(s -> list.add(s.save(new CompoundTag()))); + nbt.put("CurativeItems", list); + } +} diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeResourcePack.java b/src/main/java/net/minecraftforge/common/extensions/IForgePackResources.java similarity index 95% rename from src/main/java/net/minecraftforge/common/extensions/IForgeResourcePack.java rename to src/main/java/net/minecraftforge/common/extensions/IForgePackResources.java index 438c30af9e..6946e67818 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeResourcePack.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgePackResources.java @@ -19,7 +19,7 @@ package net.minecraftforge.common.extensions; -public interface IForgeResourcePack +public interface IForgePackResources { default boolean isHidden() { diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeStructure.java b/src/main/java/net/minecraftforge/common/extensions/IForgeStructureFeature.java similarity index 77% rename from src/main/java/net/minecraftforge/common/extensions/IForgeStructure.java rename to src/main/java/net/minecraftforge/common/extensions/IForgeStructureFeature.java index 70cc2417ae..c2839bcb62 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeStructure.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeStructureFeature.java @@ -21,15 +21,16 @@ package net.minecraftforge.common.extensions; import java.util.Collections; import java.util.List; -import net.minecraft.entity.EntityClassification; -import net.minecraft.world.biome.MobSpawnInfo; -import net.minecraft.world.gen.feature.structure.Structure; +import net.minecraft.util.random.WeightedRandomList; +import net.minecraft.world.entity.MobCategory; +import net.minecraft.world.level.biome.MobSpawnSettings; +import net.minecraft.world.level.levelgen.feature.StructureFeature; -public interface IForgeStructure +public interface IForgeStructureFeature { - default Structure getStructure() + private StructureFeature self() { - return (Structure) this; + return (StructureFeature) this; } /** @@ -37,7 +38,7 @@ public interface IForgeStructure * * @apiNote Implement this over {@link Structure#getSpawnList()} */ - default List getDefaultSpawnList() + default List getDefaultSpawnList() { return Collections.emptyList(); } @@ -47,7 +48,7 @@ public interface IForgeStructure * * @apiNote Implement this over {@link Structure#getCreatureSpawnList()} */ - default List getDefaultCreatureSpawnList() + default List getDefaultCreatureSpawnList() { return Collections.emptyList(); } @@ -60,7 +61,7 @@ public interface IForgeStructure default boolean getDefaultRestrictsSpawnsToInside() { //The Pillager Outpost and Ocean Monument check the full structure by default instead of limiting themselves to being within the structure's bounds - return getStructure() != Structure.PILLAGER_OUTPOST && getStructure() != Structure.OCEAN_MONUMENT; + return self() != StructureFeature.PILLAGER_OUTPOST && self() != StructureFeature.OCEAN_MONUMENT; } /** @@ -69,5 +70,5 @@ public interface IForgeStructure * @apiNote This method is marked as final in {@link Structure} so as to not be overridden by modders and breaking support for * {@link net.minecraftforge.event.world.StructureSpawnListGatherEvent}. */ - List getSpawnList(EntityClassification classification); + WeightedRandomList getSpawnList(MobCategory classification); } diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeTagAppender.java b/src/main/java/net/minecraftforge/common/extensions/IForgeTagAppender.java new file mode 100644 index 0000000000..ca7ddd74ff --- /dev/null +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeTagAppender.java @@ -0,0 +1,69 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.common.extensions; + +import net.minecraft.data.tags.TagsProvider; +import net.minecraft.tags.Tag; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; + +//TODO, Tag removal support. +public interface IForgeTagAppender +{ + private TagsProvider.TagAppender self() { + return (TagsProvider.TagAppender) this; + } + + @SuppressWarnings("unchecked") + default TagsProvider.TagAppender addTags(Tag.Named... values) { + TagsProvider.TagAppender builder = self(); + for (Tag.Named value : values) { + builder.addTag(value); + } + return builder; + } + + default TagsProvider.TagAppender add(ResourceKey... keys) { + TagsProvider.TagAppender builder = self(); + for (ResourceKey key : keys) { + builder.getInternalBuilder().addElement(key.location(), self().getModID()); + } + return builder; + } + + default TagsProvider.TagAppender replace() { + return replace(true); + } + + default TagsProvider.TagAppender replace(boolean value) { + self().getInternalBuilder().replace(value); + return self(); + } + + default TagsProvider.TagAppender addOptional(final ResourceLocation location) + { + return self().add(new Tag.OptionalElementEntry(location)); + } + + default TagsProvider.TagAppender addOptionalTag(final ResourceLocation location) + { + return self().add(new Tag.OptionalTagEntry(location)); + } +} diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeTagBuilder.java b/src/main/java/net/minecraftforge/common/extensions/IForgeTagBuilder.java deleted file mode 100644 index d6942aa65a..0000000000 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeTagBuilder.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.common.extensions; - -import net.minecraft.data.TagsProvider; -import net.minecraft.tags.ITag; -import net.minecraft.util.RegistryKey; -import net.minecraft.util.ResourceLocation; - -//TODO, Tag removal support. -public interface IForgeTagBuilder -{ - - default TagsProvider.Builder getBuilder() { - return (TagsProvider.Builder) this; - } - - @SuppressWarnings("unchecked") - default TagsProvider.Builder addTags(ITag.INamedTag... values) { - TagsProvider.Builder builder = getBuilder(); - for (ITag.INamedTag value : values) { - builder.addTag(value); - } - return builder; - } - - default TagsProvider.Builder add(RegistryKey... keys) { - TagsProvider.Builder builder = getBuilder(); - for (RegistryKey key : keys) { - builder.getInternalBuilder().addElement(key.location(), getBuilder().getModID()); - } - return builder; - } - - default TagsProvider.Builder replace() { - return replace(true); - } - - default TagsProvider.Builder replace(boolean value) { - getBuilder().getInternalBuilder().replace(value); - return getBuilder(); - } - - default TagsProvider.Builder addOptional(final ResourceLocation location) - { - return getBuilder().add(new ITag.OptionalItemEntry(location)); - } - - default TagsProvider.Builder addOptionalTag(final ResourceLocation location) - { - return getBuilder().add(new ITag.OptionalTagEntry(location)); - } -} diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeTagCollectionSupplier.java b/src/main/java/net/minecraftforge/common/extensions/IForgeTagContainer.java similarity index 68% rename from src/main/java/net/minecraftforge/common/extensions/IForgeTagCollectionSupplier.java rename to src/main/java/net/minecraftforge/common/extensions/IForgeTagContainer.java index 4865157287..de0d36e094 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeTagCollectionSupplier.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeTagContainer.java @@ -20,42 +20,42 @@ package net.minecraftforge.common.extensions; import java.util.Map; -import net.minecraft.tags.ITagCollection; -import net.minecraft.util.ResourceLocation; +import net.minecraft.tags.TagCollection; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.common.ForgeTagHandler; import net.minecraftforge.registries.IForgeRegistry; import net.minecraftforge.registries.IForgeRegistryEntry; -public interface IForgeTagCollectionSupplier +public interface IForgeTagContainer { /** * Gets the tag map of registry names to tag collections for the various custom tag types. * * @apiNote Prefer using one of the getCustomTypeCollection methods */ - default Map> getCustomTagTypes() + default Map> getCustomTagTypes() { return ForgeTagHandler.getCustomTagTypes(); } /** - * Gets the {@link ITagCollection} for a forge registry with the given name, or throws an exception if the registry doesn't support custom tag types. + * Gets the {@link TagCollection} for a forge registry with the given name, or throws an exception if the registry doesn't support custom tag types. * @param regName Name of the forge registry * @return The tag collection */ - default ITagCollection getCustomTypeCollection(ResourceLocation regName) + default TagCollection getCustomTypeCollection(ResourceLocation regName) { if (!ForgeTagHandler.getCustomTagTypeNames().contains(regName)) throw new IllegalArgumentException("Registry " + regName + ", does not support custom tag types"); return getCustomTagTypes().get(regName); } /** - * Gets the {@link ITagCollection} for a forge registry, or throws an exception if the registry doesn't support custom tag types. + * Gets the {@link TagCollection} for a forge registry, or throws an exception if the registry doesn't support custom tag types. * @param reg Forge registry * @return The tag collection */ - default > ITagCollection getCustomTypeCollection(IForgeRegistry reg) + default > TagCollection getCustomTypeCollection(IForgeRegistry reg) { - return (ITagCollection) getCustomTypeCollection(reg.getRegistryName()); + return (TagCollection) getCustomTypeCollection(reg.getRegistryName()); } } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeWorldServer.java b/src/main/java/net/minecraftforge/common/extensions/IForgeWorldServer.java deleted file mode 100644 index 14361fe2b1..0000000000 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeWorldServer.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.common.extensions; - -import net.minecraft.world.server.ServerWorld; - -public interface IForgeWorldServer extends IForgeWorld -{ - default ServerWorld getWorldServer() { return (ServerWorld) this; } -} diff --git a/src/main/java/net/minecraftforge/common/loot/GlobalLootModifierSerializer.java b/src/main/java/net/minecraftforge/common/loot/GlobalLootModifierSerializer.java index ac9250dbc7..9407c9235b 100644 --- a/src/main/java/net/minecraftforge/common/loot/GlobalLootModifierSerializer.java +++ b/src/main/java/net/minecraftforge/common/loot/GlobalLootModifierSerializer.java @@ -21,9 +21,9 @@ package net.minecraftforge.common.loot; import com.google.gson.JsonObject; -import net.minecraft.loot.ConditionArraySerializer; -import net.minecraft.loot.conditions.ILootCondition; -import net.minecraft.util.ResourceLocation; +import net.minecraft.advancements.critereon.SerializationContext; +import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.registries.GameData; import net.minecraftforge.registries.IForgeRegistryEntry; @@ -63,7 +63,7 @@ public abstract class GlobalLootModifierSerializer combinedConditions; /** * Constructs a LootModifier. * @param conditionsIn the ILootConditions that need to be matched before the loot is modified. */ - protected LootModifier(ILootCondition[] conditionsIn) { + protected LootModifier(LootItemCondition[] conditionsIn) { this.conditions = conditionsIn; - this.combinedConditions = LootConditionManager.andConditions(conditionsIn); + this.combinedConditions = LootItemConditions.andConditions(conditionsIn); } @Nonnull diff --git a/src/main/java/net/minecraftforge/common/loot/LootModifierManager.java b/src/main/java/net/minecraftforge/common/loot/LootModifierManager.java index 6b60bec721..7e4ff922d6 100644 --- a/src/main/java/net/minecraftforge/common/loot/LootModifierManager.java +++ b/src/main/java/net/minecraftforge/common/loot/LootModifierManager.java @@ -30,8 +30,8 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Map; -import net.minecraft.loot.LootSerializers; -import net.minecraft.loot.conditions.ILootCondition; +import net.minecraft.world.level.storage.loot.Deserializers; +import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; import org.apache.commons.io.IOUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -43,17 +43,17 @@ import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import net.minecraft.client.resources.JsonReloadListener; -import net.minecraft.profiler.IProfiler; -import net.minecraft.resources.IResource; -import net.minecraft.resources.IResourceManager; -import net.minecraft.util.JSONUtils; -import net.minecraft.util.ResourceLocation; +import net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener; +import net.minecraft.util.profiling.ProfilerFiller; +import net.minecraft.server.packs.resources.Resource; +import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.util.GsonHelper; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.registries.ForgeRegistries; -public class LootModifierManager extends JsonReloadListener { +public class LootModifierManager extends SimpleJsonResourceReloadListener { public static final Logger LOGGER = LogManager.getLogger(); - private static final Gson GSON_INSTANCE = LootSerializers.createFunctionSerializer().create(); + private static final Gson GSON_INSTANCE = Deserializers.createFunctionSerializer().create(); private Map registeredLootModifiers = ImmutableMap.of(); private static final String folder = "loot_modifiers"; @@ -63,7 +63,7 @@ public class LootModifierManager extends JsonReloadListener { } @Override - protected void apply(Map resourceList, IResourceManager resourceManagerIn, IProfiler profilerIn) { + protected void apply(Map resourceList, ResourceManager resourceManagerIn, ProfilerFiller profilerIn) { Builder builder = ImmutableMap.builder(); //old way (for reference) /*Map toLocation = new HashMap(); @@ -84,11 +84,11 @@ public class LootModifierManager extends JsonReloadListener { ResourceLocation resourcelocation = new ResourceLocation("forge","loot_modifiers/global_loot_modifiers.json"); try { //read in all data files from forge:loot_modifiers/global_loot_modifiers in order to do layering - for(IResource iresource : resourceManagerIn.getResources(resourcelocation)) { + for(Resource iresource : resourceManagerIn.getResources(resourcelocation)) { try ( InputStream inputstream = iresource.getInputStream(); Reader reader = new BufferedReader(new InputStreamReader(inputstream, StandardCharsets.UTF_8)); ) { - JsonObject jsonobject = JSONUtils.fromJson(GSON_INSTANCE, reader, JsonObject.class); + JsonObject jsonobject = GsonHelper.fromJson(GSON_INSTANCE, reader, JsonObject.class); boolean replace = jsonobject.get("replace").getAsBoolean(); if(replace) finalLocations.clear(); JsonArray entryList = jsonobject.get("entries").getAsJsonArray(); @@ -126,14 +126,14 @@ public class LootModifierManager extends JsonReloadListener { private IGlobalLootModifier deserializeModifier(ResourceLocation location, JsonElement element) { if (!element.isJsonObject()) return null; JsonObject object = element.getAsJsonObject(); - ILootCondition[] lootConditions = GSON_INSTANCE.fromJson(object.get("conditions"), ILootCondition[].class); + LootItemCondition[] lootConditions = GSON_INSTANCE.fromJson(object.get("conditions"), LootItemCondition[].class); // For backward compatibility with the initial implementation, fall back to using the location as the type. // TODO: Remove fallback in 1.16 ResourceLocation serializer = location; if (object.has("type")) { - serializer = new ResourceLocation(JSONUtils.getAsString(object, "type")); + serializer = new ResourceLocation(GsonHelper.getAsString(object, "type")); } return ForgeRegistries.LOOT_MODIFIER_SERIALIZERS.getValue(serializer).read(location, object, lootConditions); diff --git a/src/main/java/net/minecraftforge/common/loot/LootTableIdCondition.java b/src/main/java/net/minecraftforge/common/loot/LootTableIdCondition.java index 97ac2b1c72..0d7feedf47 100644 --- a/src/main/java/net/minecraftforge/common/loot/LootTableIdCondition.java +++ b/src/main/java/net/minecraftforge/common/loot/LootTableIdCondition.java @@ -22,17 +22,17 @@ package net.minecraftforge.common.loot; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonObject; import com.google.gson.JsonSerializationContext; -import net.minecraft.loot.ILootSerializer; -import net.minecraft.loot.LootConditionType; -import net.minecraft.loot.LootContext; -import net.minecraft.loot.conditions.ILootCondition; -import net.minecraft.util.JSONUtils; -import net.minecraft.util.ResourceLocation; +import net.minecraft.world.level.storage.loot.Serializer; +import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; +import net.minecraft.util.GsonHelper; +import net.minecraft.resources.ResourceLocation; -public class LootTableIdCondition implements ILootCondition +public class LootTableIdCondition implements LootItemCondition { // TODO Forge Registry at some point? - public static final LootConditionType LOOT_TABLE_ID = new LootConditionType(new LootTableIdCondition.Serializer()); + public static final LootItemConditionType LOOT_TABLE_ID = new LootItemConditionType(new LootTableIdCondition.Serializer()); public static final ResourceLocation UNKNOWN_LOOT_TABLE = new ResourceLocation("forge", "unknown_loot_table"); private final ResourceLocation targetLootTableId; @@ -43,7 +43,7 @@ public class LootTableIdCondition implements ILootCondition } @Override - public LootConditionType getType() + public LootItemConditionType getType() { return LOOT_TABLE_ID; } @@ -59,7 +59,7 @@ public class LootTableIdCondition implements ILootCondition return new Builder(targetLootTableId); } - public static class Builder implements ILootCondition.IBuilder + public static class Builder implements LootItemCondition.Builder { private final ResourceLocation targetLootTableId; @@ -70,13 +70,13 @@ public class LootTableIdCondition implements ILootCondition } @Override - public ILootCondition build() + public LootItemCondition build() { return new LootTableIdCondition(this.targetLootTableId); } } - public static class Serializer implements ILootSerializer + public static class Serializer implements net.minecraft.world.level.storage.loot.Serializer { @Override public void serialize(JsonObject object, LootTableIdCondition instance, JsonSerializationContext ctx) @@ -87,7 +87,7 @@ public class LootTableIdCondition implements ILootCondition @Override public LootTableIdCondition deserialize(JsonObject object, JsonDeserializationContext ctx) { - return new LootTableIdCondition(new ResourceLocation(JSONUtils.getAsString(object, "loot_table_id"))); + return new LootTableIdCondition(new ResourceLocation(GsonHelper.getAsString(object, "loot_table_id"))); } } } diff --git a/src/main/java/net/minecraftforge/common/model/TransformationHelper.java b/src/main/java/net/minecraftforge/common/model/TransformationHelper.java index 663ad6a09c..92635d6681 100644 --- a/src/main/java/net/minecraftforge/common/model/TransformationHelper.java +++ b/src/main/java/net/minecraftforge/common/model/TransformationHelper.java @@ -23,22 +23,27 @@ import java.lang.reflect.Type; import java.util.Map; import com.google.gson.*; -import net.minecraft.util.math.MathHelper; +import net.minecraft.util.Mth; -import net.minecraft.client.renderer.model.ItemTransformVec3f; -import net.minecraft.util.math.vector.*; +import net.minecraft.client.renderer.block.model.ItemTransform; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import com.mojang.math.Matrix4f; +import com.mojang.math.Quaternion; +import com.mojang.math.Transformation; +import com.mojang.math.Vector3f; +import com.mojang.math.Vector4f; + public final class TransformationHelper { @Deprecated @OnlyIn(Dist.CLIENT) - public static TransformationMatrix toTransformation(ItemTransformVec3f transform) + public static Transformation toTransformation(ItemTransform transform) { - if (transform.equals(ItemTransformVec3f.NO_TRANSFORM)) return TransformationMatrix.identity(); + if (transform.equals(ItemTransform.NO_TRANSFORM)) return Transformation.identity(); - return new TransformationMatrix(transform.translation, quatFromXYZ(transform.rotation, true), transform.scale, null); + return new Transformation(transform.translation, quatFromXYZ(transform.rotation, true), transform.scale, null); } public static Quaternion quatFromXYZ(Vector3f xyz, boolean degrees) @@ -83,19 +88,19 @@ public final class TransformationHelper // If the inputs are too close for comfort, linearly interpolate // and normalize the result. if (dot > THRESHOLD) { - float x = MathHelper.lerp(t, v0.i(), v1.i()); - float y = MathHelper.lerp(t, v0.j(), v1.j()); - float z = MathHelper.lerp(t, v0.k(), v1.k()); - float w = MathHelper.lerp(t, v0.r(), v1.r()); + float x = Mth.lerp(t, v0.i(), v1.i()); + float y = Mth.lerp(t, v0.j(), v1.j()); + float z = Mth.lerp(t, v0.k(), v1.k()); + float w = Mth.lerp(t, v0.r(), v1.r()); return new Quaternion(x,y,z,w); } // Since dot is in range [0, DOT_THRESHOLD], acos is safe float angle01 = (float)Math.acos(dot); float angle0t = angle01*t; - float sin0t = MathHelper.sin(angle0t); - float sin01 = MathHelper.sin(angle01); - float sin1t = MathHelper.sin(angle01 - angle0t); + float sin0t = Mth.sin(angle0t); + float sin01 = Mth.sin(angle01); + float sin1t = Mth.sin(angle01 - angle0t); float s1 = sin0t / sin01; float s0 = sin1t / sin01; @@ -108,39 +113,39 @@ public final class TransformationHelper ); } - public static TransformationMatrix slerp(TransformationMatrix one, TransformationMatrix that, float progress) + public static Transformation slerp(Transformation one, Transformation that, float progress) { - return new TransformationMatrix( + return new Transformation( lerp(one.getTranslation(), that.getTranslation(), progress), slerp(one.getLeftRotation(), that.getLeftRotation(), progress), lerp(one.getScale(), that.getScale(), progress), - slerp(one.getRightRot(), that.getRightRot(), progress) + slerp(one.getRightRotation(), that.getRightRotation(), progress) ); } public static boolean epsilonEquals(Vector4f v1, Vector4f v2, float epsilon) { - return MathHelper.abs(v1.x()-v2.x()) < epsilon && - MathHelper.abs(v1.y()-v2.y()) < epsilon && - MathHelper.abs(v1.z()-v2.z()) < epsilon && - MathHelper.abs(v1.w()-v2.w()) < epsilon; + return Mth.abs(v1.x()-v2.x()) < epsilon && + Mth.abs(v1.y()-v2.y()) < epsilon && + Mth.abs(v1.z()-v2.z()) < epsilon && + Mth.abs(v1.w()-v2.w()) < epsilon; } - public static class Deserializer implements JsonDeserializer + public static class Deserializer implements JsonDeserializer { private static final Vector3f ORIGIN_CORNER = new Vector3f(); private static final Vector3f ORIGIN_OPPOSING_CORNER = new Vector3f(1f, 1f, 1f); private static final Vector3f ORIGIN_CENTER = new Vector3f(.5f, .5f, .5f); @Override - public TransformationMatrix deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException + public Transformation deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { if (json.isJsonPrimitive() && json.getAsJsonPrimitive().isString()) { String transform = json.getAsString(); if(transform.equals("identity")) { - return TransformationMatrix.identity(); + return Transformation.identity(); } else { @@ -150,15 +155,15 @@ public final class TransformationHelper if (json.isJsonArray()) { // direct matrix array - return new TransformationMatrix(parseMatrix(json)); + return new Transformation(parseMatrix(json)); } if (!json.isJsonObject()) throw new JsonParseException("TRSR: expected array or object, got: " + json); JsonObject obj = json.getAsJsonObject(); - TransformationMatrix ret; + Transformation ret; if (obj.has("matrix")) { // matrix as a sole key - ret = new TransformationMatrix(parseMatrix(obj.get("matrix"))); + ret = new Transformation(parseMatrix(obj.get("matrix"))); obj.remove("matrix"); if (obj.entrySet().size() != 0) { @@ -214,7 +219,7 @@ public final class TransformationHelper obj.remove("origin"); } if (!obj.entrySet().isEmpty()) throw new JsonParseException("TRSR: can either have single 'matrix' key, or a combination of 'translation', 'rotation', 'scale', 'post-rotation', 'origin'"); - TransformationMatrix matrix = new TransformationMatrix(translation, leftRot, scale, rightRot); + Transformation matrix = new Transformation(translation, leftRot, scale, rightRot); // Use a different origin if needed. if (!ORIGIN_CENTER.equals(origin)) diff --git a/src/main/java/net/minecraftforge/common/model/animation/AnimationStateMachine.java b/src/main/java/net/minecraftforge/common/model/animation/AnimationStateMachine.java index 8c4d347076..e774b16051 100644 --- a/src/main/java/net/minecraftforge/common/model/animation/AnimationStateMachine.java +++ b/src/main/java/net/minecraftforge/common/model/animation/AnimationStateMachine.java @@ -36,10 +36,10 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import net.minecraft.client.renderer.model.IModelTransform; -import net.minecraft.resources.IResource; -import net.minecraft.resources.IResourceManager; -import net.minecraft.util.ResourceLocation; +import net.minecraft.client.resources.model.ModelState; +import net.minecraft.server.packs.resources.Resource; +import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.animation.Event; @@ -77,13 +77,13 @@ public final class AnimationStateMachine implements IAnimationStateMachine private transient IClip currentState; private transient float lastPollTime; - private static final LoadingCache, Pair>> clipCache = CacheBuilder.newBuilder() + private static final LoadingCache, Pair>> clipCache = CacheBuilder.newBuilder() .maximumSize(100) .expireAfterWrite(100, TimeUnit.MILLISECONDS) - .build(new CacheLoader, Pair>>() + .build(new CacheLoader, Pair>>() { @Override - public Pair> load(Triple key) throws Exception + public Pair> load(Triple key) throws Exception { return Clips.apply(key.getLeft(), key.getMiddle(), key.getRight()); } @@ -132,13 +132,13 @@ public final class AnimationStateMachine implements IAnimationStateMachine } @Override - public Pair> apply(float time) + public Pair> apply(float time) { if(lastPollTime == Float.NEGATIVE_INFINITY) { lastPollTime = time; } - Pair> pair = clipCache.getUnchecked(Triple.of(currentState, lastPollTime, time)); + Pair> pair = clipCache.getUnchecked(Triple.of(currentState, lastPollTime, time)); lastPollTime = time; boolean shouldFilter = false; if(shouldHandleSpecialEvents) @@ -206,9 +206,9 @@ public final class AnimationStateMachine implements IAnimationStateMachine * Load a new instance if AnimationStateMachine at specified location, with specified custom parameters. */ @OnlyIn(Dist.CLIENT) - public static IAnimationStateMachine load(IResourceManager manager, ResourceLocation location, ImmutableMap customParameters) + public static IAnimationStateMachine load(ResourceManager manager, ResourceLocation location, ImmutableMap customParameters) { - try (IResource resource = manager.getResource(location)) + try (Resource resource = manager.getResource(location)) { ClipResolver clipResolver = new ClipResolver(); ParameterResolver parameterResolver = new ParameterResolver(customParameters); diff --git a/src/main/java/net/minecraftforge/common/model/animation/CapabilityAnimation.java b/src/main/java/net/minecraftforge/common/model/animation/CapabilityAnimation.java index 31d2feb8b2..2b723cd4f7 100644 --- a/src/main/java/net/minecraftforge/common/model/animation/CapabilityAnimation.java +++ b/src/main/java/net/minecraftforge/common/model/animation/CapabilityAnimation.java @@ -19,8 +19,8 @@ package net.minecraftforge.common.model.animation; -import net.minecraft.nbt.INBT; -import net.minecraft.util.Direction; +import net.minecraft.nbt.Tag; +import net.minecraft.core.Direction; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.CapabilityInject; import net.minecraftforge.common.capabilities.CapabilityManager; @@ -37,17 +37,7 @@ public class CapabilityAnimation public static void register() { - CapabilityManager.INSTANCE.register(IAnimationStateMachine.class, new Capability.IStorage() - { - @Override - public INBT writeNBT(Capability capability, IAnimationStateMachine instance, Direction side) - { - return null; - } - - @Override - public void readNBT(Capability capability, IAnimationStateMachine instance, Direction side, INBT nbt) {} - }, AnimationStateMachine::getMissing); + CapabilityManager.INSTANCE.register(IAnimationStateMachine.class); } public static class DefaultItemAnimationCapabilityProvider implements ICapabilityProvider diff --git a/src/main/java/net/minecraftforge/common/model/animation/Clips.java b/src/main/java/net/minecraftforge/common/model/animation/Clips.java index 5f2787c388..94e496c709 100644 --- a/src/main/java/net/minecraftforge/common/model/animation/Clips.java +++ b/src/main/java/net/minecraftforge/common/model/animation/Clips.java @@ -21,13 +21,13 @@ package net.minecraftforge.common.model.animation; import java.io.IOException; -import net.minecraft.util.math.vector.TransformationMatrix; -import net.minecraft.client.renderer.model.IModelTransform; -import net.minecraft.client.renderer.model.IUnbakedModel; -import net.minecraft.client.renderer.model.ModelResourceLocation; -import net.minecraft.util.IStringSerializable; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.ResourceLocation; +import com.mojang.math.Transformation; +import net.minecraft.client.resources.model.ModelState; +import net.minecraft.client.resources.model.UnbakedModel; +import net.minecraft.client.resources.model.ModelResourceLocation; +import net.minecraft.util.StringRepresentable; +import net.minecraft.util.Mth; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.common.animation.Event; @@ -65,7 +65,7 @@ public final class Clips /** * Clip that does nothing. */ - public static enum IdentityClip implements IClip, IStringSerializable + public static enum IdentityClip implements IClip, StringRepresentable { INSTANCE; @@ -94,7 +94,7 @@ public final class Clips @OnlyIn(Dist.CLIENT) public static IClip getModelClipNode(ResourceLocation modelLocation, String clipName) { - IUnbakedModel model = ModelLoader.defaultModelGetter().apply(modelLocation); + UnbakedModel model = ModelLoader.defaultModelGetter().apply(modelLocation); Optional clip = model.getClip(clipName); if (clip.isPresent()) { @@ -174,7 +174,7 @@ public final class Clips { private final IJointClip parent = childClip.apply(joint); @Override - public TransformationMatrix apply(float time) + public Transformation apply(float time) { return parent.apply(TimeClip.this.time.apply(time)); } @@ -291,10 +291,10 @@ public final class Clips return new IJointClip() { @Override - public TransformationMatrix apply(float time) + public Transformation apply(float time) { float clipTime = input.apply(time); - return TransformationHelper.slerp(fromClip.apply(clipTime), toClip.apply(clipTime), MathHelper.clamp(progress.apply(time), 0, 1)); + return TransformationHelper.slerp(fromClip.apply(clipTime), toClip.apply(clipTime), Mth.clamp(progress.apply(time), 0, 1)); } }; } @@ -302,30 +302,30 @@ public final class Clips /** * IModelState wrapper for a Clip, sampled at specified time. */ - public static Pair> apply(final IClip clip, final float lastPollTime, final float time) + public static Pair> apply(final IClip clip, final float lastPollTime, final float time) { - return Pair.of(new IModelTransform() + return Pair.of(new ModelState() { @Override - public TransformationMatrix getRotation() + public Transformation getRotation() { - return TransformationMatrix.identity(); + return Transformation.identity(); } @Override - public TransformationMatrix getPartTransformation(Object part) + public Transformation getPartTransformation(Object part) { if(!(part instanceof IJoint)) { - return TransformationMatrix.identity(); + return Transformation.identity(); } IJoint joint = (IJoint)part; // TODO: Cache clip application? - TransformationMatrix jointTransform = clip.apply(joint).apply(time).compose(joint.getInvBindPose()); + Transformation jointTransform = clip.apply(joint).apply(time).compose(joint.getInvBindPose()); Optional parent = joint.getParent(); while(parent.isPresent()) { - TransformationMatrix parentTransform = clip.apply(parent.get()).apply(time); + Transformation parentTransform = clip.apply(parent.get()).apply(time); jointTransform = parentTransform.compose(jointTransform); parent = parent.get().getParent(); } @@ -374,7 +374,7 @@ public final class Clips * Reference to another clip. * Should only exist during debugging. */ - public static final class ClipReference implements IClip, IStringSerializable + public static final class ClipReference implements IClip, StringRepresentable { private final String clipName; private final Function clipResolver; @@ -473,9 +473,9 @@ public final class Clips public void write(JsonWriter out, IClip clip) throws IOException { // IdentityClip + ClipReference - if(clip instanceof IStringSerializable) + if(clip instanceof StringRepresentable) { - out.value("#" + ((IStringSerializable)clip).getSerializedName()); + out.value("#" + ((StringRepresentable)clip).getSerializedName()); return; } else if(clip instanceof TimeClip) diff --git a/src/main/java/net/minecraftforge/common/model/animation/IAnimationStateMachine.java b/src/main/java/net/minecraftforge/common/model/animation/IAnimationStateMachine.java index ba75ffd114..d8498e3eba 100644 --- a/src/main/java/net/minecraftforge/common/model/animation/IAnimationStateMachine.java +++ b/src/main/java/net/minecraftforge/common/model/animation/IAnimationStateMachine.java @@ -19,7 +19,7 @@ package net.minecraftforge.common.model.animation; -import net.minecraft.client.renderer.model.IModelTransform; +import net.minecraft.client.resources.model.ModelState; import net.minecraftforge.common.animation.Event; import org.apache.commons.lang3.tuple.Pair; @@ -34,7 +34,7 @@ public interface IAnimationStateMachine * Event iterable will contain all events that happened from the last invocation of this method, from most to least recent. * Event offset is relative to the previous event, and for the first event it's relative to the current time. */ - Pair> apply(float time); + Pair> apply(float time); /** * Transition to a new state. diff --git a/src/main/java/net/minecraftforge/common/model/animation/IJoint.java b/src/main/java/net/minecraftforge/common/model/animation/IJoint.java index 43507a29fa..51a263187f 100644 --- a/src/main/java/net/minecraftforge/common/model/animation/IJoint.java +++ b/src/main/java/net/minecraftforge/common/model/animation/IJoint.java @@ -19,7 +19,7 @@ package net.minecraftforge.common.model.animation; -import net.minecraft.util.math.vector.TransformationMatrix; +import com.mojang.math.Transformation; import java.util.Optional; @@ -28,7 +28,7 @@ import java.util.Optional; */ public interface IJoint { - TransformationMatrix getInvBindPose(); + Transformation getInvBindPose(); Optional getParent(); } diff --git a/src/main/java/net/minecraftforge/common/model/animation/IJointClip.java b/src/main/java/net/minecraftforge/common/model/animation/IJointClip.java index 6253c7a538..274b65b03d 100644 --- a/src/main/java/net/minecraftforge/common/model/animation/IJointClip.java +++ b/src/main/java/net/minecraftforge/common/model/animation/IJointClip.java @@ -19,12 +19,12 @@ package net.minecraftforge.common.model.animation; -import net.minecraft.util.math.vector.TransformationMatrix; +import com.mojang.math.Transformation; /** * Returns Local joint pose; animation clip for specific model part. */ public interface IJointClip { - TransformationMatrix apply(float time); + Transformation apply(float time); } diff --git a/src/main/java/net/minecraftforge/common/model/animation/JointClips.java b/src/main/java/net/minecraftforge/common/model/animation/JointClips.java index 8822d3b732..92e990ab05 100644 --- a/src/main/java/net/minecraftforge/common/model/animation/JointClips.java +++ b/src/main/java/net/minecraftforge/common/model/animation/JointClips.java @@ -19,7 +19,7 @@ package net.minecraftforge.common.model.animation; -import net.minecraft.util.math.vector.TransformationMatrix; +import com.mojang.math.Transformation; /** * Various implementations of IJointClip. @@ -31,9 +31,9 @@ public final class JointClips INSTANCE; @Override - public TransformationMatrix apply(float time) + public Transformation apply(float time) { - return TransformationMatrix.identity(); + return Transformation.identity(); } } @@ -49,7 +49,7 @@ public final class JointClips } @Override - public TransformationMatrix apply(float time) + public Transformation apply(float time) { return clip.apply(child).apply(time); } diff --git a/src/main/java/net/minecraftforge/common/modloading/ForgeModStateProvider.java b/src/main/java/net/minecraftforge/common/modloading/ForgeModStateProvider.java new file mode 100644 index 0000000000..6452d66c79 --- /dev/null +++ b/src/main/java/net/minecraftforge/common/modloading/ForgeModStateProvider.java @@ -0,0 +1,32 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.common.modloading; + +public class ForgeModStateProvider { +// +// statusConsumer.ifPresent(c->c.accept("Creating registries")); +// dispatchAndHandleError(ModLoadingStage.CREATE_REGISTRIES, syncExecutor, parallelExecutor, periodicTask); +// ObjectHolderRegistry.findObjectHolders(); +// CapabilityManager.INSTANCE.injectCapabilities(modList.getAllScanData()); +// statusConsumer.ifPresent(c->c.accept("Adding custom tag types")); +// GameData.setCustomTagTypesFromRegistries(); +// statusConsumer.ifPresent(c->c.accept("Populating registries")); +// dispatchAndHandleError(ModLoadingStage.LOAD_REGISTRIES, syncExecutor, parallelExecutor, periodicTask); +} diff --git a/src/main/java/net/minecraftforge/common/property/Properties.java b/src/main/java/net/minecraftforge/common/property/Properties.java index f7b1ddf810..ac4005c8c7 100644 --- a/src/main/java/net/minecraftforge/common/property/Properties.java +++ b/src/main/java/net/minecraftforge/common/property/Properties.java @@ -19,8 +19,8 @@ package net.minecraftforge.common.property; -import net.minecraft.client.renderer.model.IModelTransform; -import net.minecraft.state.BooleanProperty; +import net.minecraft.client.resources.model.ModelState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; import net.minecraftforge.client.model.data.ModelProperty; public class Properties @@ -33,5 +33,5 @@ public class Properties /** * Property holding the IModelState used for animating the model in the TESR. */ - public static final ModelProperty AnimationProperty = new ModelProperty(); + public static final ModelProperty AnimationProperty = new ModelProperty(); } diff --git a/src/main/java/net/minecraftforge/common/ticket/AABBTicket.java b/src/main/java/net/minecraftforge/common/ticket/AABBTicket.java index 91354d3147..da79e3f7af 100644 --- a/src/main/java/net/minecraftforge/common/ticket/AABBTicket.java +++ b/src/main/java/net/minecraftforge/common/ticket/AABBTicket.java @@ -19,23 +19,23 @@ package net.minecraftforge.common.ticket; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; import javax.annotation.Nonnull; -public class AABBTicket extends SimpleTicket +public class AABBTicket extends SimpleTicket { @Nonnull - public final AxisAlignedBB axisAlignedBB; + public final AABB axisAlignedBB; - public AABBTicket(@Nonnull AxisAlignedBB axisAlignedBB) + public AABBTicket(@Nonnull AABB axisAlignedBB) { this.axisAlignedBB = axisAlignedBB; } @Override - public boolean matches(Vector3d toMatch) + public boolean matches(Vec3 toMatch) { return this.axisAlignedBB.contains(toMatch); } diff --git a/src/main/java/net/minecraftforge/common/ticket/ChunkTicketManager.java b/src/main/java/net/minecraftforge/common/ticket/ChunkTicketManager.java index 35615e629f..8d22abe4a1 100644 --- a/src/main/java/net/minecraftforge/common/ticket/ChunkTicketManager.java +++ b/src/main/java/net/minecraftforge/common/ticket/ChunkTicketManager.java @@ -19,7 +19,7 @@ package net.minecraftforge.common.ticket; -import net.minecraft.util.math.ChunkPos; +import net.minecraft.world.level.ChunkPos; import java.util.Collection; import java.util.Collections; diff --git a/src/main/java/net/minecraftforge/common/util/BlockSnapshot.java b/src/main/java/net/minecraftforge/common/util/BlockSnapshot.java index 41fac5b250..608e9a8adb 100644 --- a/src/main/java/net/minecraftforge/common/util/BlockSnapshot.java +++ b/src/main/java/net/minecraftforge/common/util/BlockSnapshot.java @@ -22,15 +22,15 @@ package net.minecraftforge.common.util; import java.lang.ref.WeakReference; import java.util.Objects; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.RegistryKey; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IWorld; -import net.minecraft.world.World; -import net.minecraftforge.fml.server.ServerLifecycleHooks; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.resources.ResourceKey; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.Level; +import net.minecraftforge.fmllegacy.server.ServerLifecycleHooks; import javax.annotation.Nullable; @@ -45,18 +45,18 @@ public class BlockSnapshot { private static final boolean DEBUG = Boolean.parseBoolean(System.getProperty("forge.debugBlockSnapshot", "false")); - private final RegistryKey dim; + private final ResourceKey dim; private final BlockPos pos; private final int flags; private final BlockState block; @Nullable - private final CompoundNBT nbt; + private final CompoundTag nbt; @Nullable - private WeakReference world; + private WeakReference world; private String toString = null; - private BlockSnapshot(RegistryKey dim, IWorld world, BlockPos pos, BlockState state, @Nullable CompoundNBT nbt, int flags) + private BlockSnapshot(ResourceKey dim, LevelAccessor world, BlockPos pos, BlockState state, @Nullable CompoundTag nbt, int flags) { this.dim = dim; this.pos = pos.immutable(); @@ -70,36 +70,36 @@ public class BlockSnapshot System.out.println("Created " + this.toString()); } - public static BlockSnapshot create(RegistryKey dim, IWorld world, BlockPos pos) + public static BlockSnapshot create(ResourceKey dim, LevelAccessor world, BlockPos pos) { return create(dim, world, pos, 3); } - public static BlockSnapshot create(RegistryKey dim, IWorld world, BlockPos pos, int flag) + public static BlockSnapshot create(ResourceKey dim, LevelAccessor world, BlockPos pos, int flag) { return new BlockSnapshot(dim, world, pos, world.getBlockState(pos), getTileNBT(world.getBlockEntity(pos)), flag); } @Nullable - private static CompoundNBT getTileNBT(@Nullable TileEntity te) + private static CompoundTag getTileNBT(@Nullable BlockEntity te) { - return te == null ? null : te.save(new CompoundNBT()); + return te == null ? null : te.save(new CompoundTag()); } public BlockState getCurrentBlock() { - IWorld world = getWorld(); + LevelAccessor world = getWorld(); return world == null ? Blocks.AIR.defaultBlockState() : world.getBlockState(this.pos); } @Nullable - public IWorld getWorld() + public LevelAccessor getWorld() { - IWorld world = this.world != null ? this.world.get() : null; + LevelAccessor world = this.world != null ? this.world.get() : null; if (world == null) { world = ServerLifecycleHooks.getCurrentServer().getLevel(this.dim); - this.world = new WeakReference(world); + this.world = new WeakReference(world); } return world; } @@ -110,9 +110,9 @@ public class BlockSnapshot } @Nullable - public TileEntity getTileEntity() + public BlockEntity getBlockEntity() { - return getNbt() != null ? TileEntity.loadStatic(getReplacedBlock(), getNbt()) : null; + return getNbt() != null ? BlockEntity.loadStatic(getPos(), getReplacedBlock(), getNbt()) : null; } public boolean restore() @@ -130,7 +130,7 @@ public class BlockSnapshot return restoreToLocation(getWorld(), getPos(), force, notifyNeighbors); } - public boolean restoreToLocation(IWorld world, BlockPos pos, boolean force, boolean notifyNeighbors) + public boolean restoreToLocation(LevelAccessor world, BlockPos pos, boolean force, boolean notifyNeighbors) { BlockState current = getCurrentBlock(); BlockState replaced = getReplacedBlock(); @@ -146,16 +146,16 @@ public class BlockSnapshot } world.setBlock(pos, replaced, flags); - if (world instanceof World) - ((World)world).sendBlockUpdated(pos, current, replaced, flags); + if (world instanceof Level) + ((Level)world).sendBlockUpdated(pos, current, replaced, flags); - TileEntity te = null; + BlockEntity te = null; if (getNbt() != null) { te = world.getBlockEntity(pos); if (te != null) { - te.load(getReplacedBlock(), getNbt()); + te.load(getNbt()); te.setChanged(); } } @@ -216,6 +216,6 @@ public class BlockSnapshot public int getFlag() { return flags; } @Nullable - public CompoundNBT getNbt() { return nbt; } + public CompoundTag getNbt() { return nbt; } } diff --git a/src/main/java/net/minecraftforge/common/util/ChunkCoordComparator.java b/src/main/java/net/minecraftforge/common/util/ChunkCoordComparator.java index d7c012d194..62b706937c 100644 --- a/src/main/java/net/minecraftforge/common/util/ChunkCoordComparator.java +++ b/src/main/java/net/minecraftforge/common/util/ChunkCoordComparator.java @@ -19,8 +19,8 @@ package net.minecraftforge.common.util; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.util.math.ChunkPos; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.level.ChunkPos; // Sorter to load nearby chunks first public class ChunkCoordComparator implements java.util.Comparator @@ -28,7 +28,7 @@ public class ChunkCoordComparator implements java.util.Comparator private int x; private int z; - public ChunkCoordComparator(ServerPlayerEntity entityplayer) + public ChunkCoordComparator(ServerPlayer entityplayer) { x = (int) entityplayer.getX() >> 4; z = (int) entityplayer.getZ() >> 4; diff --git a/src/main/java/net/minecraftforge/common/util/Constants.java b/src/main/java/net/minecraftforge/common/util/Constants.java index c6cd957d41..d2973423a9 100644 --- a/src/main/java/net/minecraftforge/common/util/Constants.java +++ b/src/main/java/net/minecraftforge/common/util/Constants.java @@ -19,15 +19,6 @@ package net.minecraftforge.common.util; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.particles.ParticleTypes; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IWorld; -import net.minecraft.world.World; - /** * A class containing constants for magic numbers used in the minecraft codebase. * Everything here should be checked each update, and have a comment relating to where to check it. diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeSelectionContext.java b/src/main/java/net/minecraftforge/common/util/DummySavedData.java similarity index 66% rename from src/main/java/net/minecraftforge/common/extensions/IForgeSelectionContext.java rename to src/main/java/net/minecraftforge/common/util/DummySavedData.java index 5313ee44c9..d8bded5600 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeSelectionContext.java +++ b/src/main/java/net/minecraftforge/common/util/DummySavedData.java @@ -17,16 +17,20 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.common.extensions; +package net.minecraftforge.common.util; -import javax.annotation.Nullable; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.saveddata.SavedData; -import net.minecraft.entity.Entity; +public class DummySavedData extends SavedData { + public static final DummySavedData DUMMY = new DummySavedData(); + private DummySavedData() { + super(); + } -public interface IForgeSelectionContext -{ - default @Nullable Entity getEntity() - { + @Override + public CompoundTag save(final CompoundTag compound) { + // NOOP return null; } } diff --git a/src/main/java/net/minecraftforge/common/util/FakePlayer.java b/src/main/java/net/minecraftforge/common/util/FakePlayer.java index 21373757a2..30052dcc65 100644 --- a/src/main/java/net/minecraftforge/common/util/FakePlayer.java +++ b/src/main/java/net/minecraftforge/common/util/FakePlayer.java @@ -19,117 +19,155 @@ package net.minecraftforge.common.util; -import javax.annotation.Nullable; -import javax.annotation.ParametersAreNonnullByDefault; - import com.mojang.authlib.GameProfile; - import io.netty.util.concurrent.Future; import io.netty.util.concurrent.GenericFutureListener; - -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.network.IPacket; -import net.minecraft.network.NetworkManager; -import net.minecraft.network.PacketDirection; -import net.minecraft.network.play.ServerPlayNetHandler; -import net.minecraft.network.play.client.*; -import net.minecraft.network.play.server.SPlayerPositionLookPacket; +import net.minecraft.core.BlockPos; +import net.minecraft.network.Connection; +import net.minecraft.network.chat.Component; +import net.minecraft.network.protocol.Packet; +import net.minecraft.network.protocol.PacketFlow; +import net.minecraft.network.protocol.game.ClientboundPlayerPositionPacket; +import net.minecraft.network.protocol.game.ServerboundAcceptTeleportationPacket; +import net.minecraft.network.protocol.game.ServerboundBlockEntityTagQuery; +import net.minecraft.network.protocol.game.ServerboundChangeDifficultyPacket; +import net.minecraft.network.protocol.game.ServerboundChatPacket; +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; +import net.minecraft.network.protocol.game.ServerboundPaddleBoatPacket; +import net.minecraft.network.protocol.game.ServerboundPickItemPacket; +import net.minecraft.network.protocol.game.ServerboundPlaceRecipePacket; +import net.minecraft.network.protocol.game.ServerboundPlayerAbilitiesPacket; +import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket; +import net.minecraft.network.protocol.game.ServerboundPlayerCommandPacket; +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; +import net.minecraft.network.protocol.game.ServerboundSetCarriedItemPacket; +import net.minecraft.network.protocol.game.ServerboundSetCommandBlockPacket; +import net.minecraft.network.protocol.game.ServerboundSetCommandMinecartPacket; +import net.minecraft.network.protocol.game.ServerboundSetCreativeModeSlotPacket; +import net.minecraft.network.protocol.game.ServerboundSetJigsawBlockPacket; +import net.minecraft.network.protocol.game.ServerboundSetStructureBlockPacket; +import net.minecraft.network.protocol.game.ServerboundSignUpdatePacket; +import net.minecraft.network.protocol.game.ServerboundSwingPacket; +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.management.PlayerInteractionManager; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.network.ServerGamePacketListenerImpl; import net.minecraft.stats.Stat; -import net.minecraft.util.DamageSource; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.world.server.ServerWorld; -import net.minecraftforge.fml.server.ServerLifecycleHooks; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.phys.Vec3; +import net.minecraftforge.fmllegacy.server.ServerLifecycleHooks; +import javax.annotation.Nullable; +import javax.annotation.ParametersAreNonnullByDefault; import java.util.Set; import java.util.UUID; //Preliminary, simple Fake Player class -public class FakePlayer extends ServerPlayerEntity +public class FakePlayer extends ServerPlayer { - public FakePlayer(ServerWorld world, GameProfile name) + public FakePlayer(ServerLevel world, GameProfile name) { - super(world.getServer(), world, name, new PlayerInteractionManager(world)); + super(world.getServer(), world, name); this.connection = new FakePlayerNetHandler(world.getServer(), this); } - @Override public Vector3d position(){ return new Vector3d(0, 0, 0); } + @Override public Vec3 position(){ return new Vec3(0, 0, 0); } @Override public BlockPos blockPosition(){ return BlockPos.ZERO; } - @Override public void displayClientMessage(ITextComponent chatComponent, boolean actionBar){} - @Override public void sendMessage(ITextComponent component, UUID senderUUID) {} + @Override public void displayClientMessage(Component chatComponent, boolean actionBar){} + @Override public void sendMessage(Component component, UUID senderUUID) {} @Override public void awardStat(Stat par1StatBase, int par2){} //@Override public void openGui(Object mod, int modGuiId, World world, int x, int y, int z){} @Override public boolean isInvulnerableTo(DamageSource source){ return true; } - @Override public boolean canHarmPlayer(PlayerEntity player){ return false; } + @Override public boolean canHarmPlayer(Player player){ return false; } @Override public void die(DamageSource source){ return; } @Override public void tick(){ return; } - @Override public void updateOptions(CClientSettingsPacket pkt){ return; } + @Override public void updateOptions(ServerboundClientInformationPacket pkt){ return; } @Override @Nullable public MinecraftServer getServer() { return ServerLifecycleHooks.getCurrentServer(); } @ParametersAreNonnullByDefault - private static class FakePlayerNetHandler extends ServerPlayNetHandler { - private static final NetworkManager DUMMY_NETWORK_MANAGER = new NetworkManager(PacketDirection.CLIENTBOUND); + private static class FakePlayerNetHandler extends ServerGamePacketListenerImpl { + private static final Connection DUMMY_CONNECTION = new Connection(PacketFlow.CLIENTBOUND); - public FakePlayerNetHandler(MinecraftServer server, ServerPlayerEntity player) { - super(server, DUMMY_NETWORK_MANAGER, player); + public FakePlayerNetHandler(MinecraftServer server, ServerPlayer player) { + super(server, DUMMY_CONNECTION, player); } @Override public void tick() { } @Override public void resetPosition() { } - @Override public void disconnect(ITextComponent message) { } - @Override public void handlePlayerInput(CInputPacket packet) { } - @Override public void handleMoveVehicle(CMoveVehiclePacket packet) { } - @Override public void handleAcceptTeleportPacket(CConfirmTeleportPacket packet) { } - @Override public void handleRecipeBookSeenRecipePacket(CMarkRecipeSeenPacket packet) { } - @Override public void handleRecipeBookChangeSettingsPacket(CUpdateRecipeBookStatusPacket packet) { } - @Override public void handleSeenAdvancements(CSeenAdvancementsPacket packet) { } - @Override public void handleCustomCommandSuggestions(CTabCompletePacket packet) { } - @Override public void handleSetCommandBlock(CUpdateCommandBlockPacket packet) { } - @Override public void handleSetCommandMinecart(CUpdateMinecartCommandBlockPacket packet) { } - @Override public void handlePickItem(CPickItemPacket packet) { } - @Override public void handleRenameItem(CRenameItemPacket packet) { } - @Override public void handleSetBeaconPacket(CUpdateBeaconPacket packet) { } - @Override public void handleSetStructureBlock(CUpdateStructureBlockPacket packet) { } - @Override public void handleSetJigsawBlock(CUpdateJigsawBlockPacket packet) { } - @Override public void handleJigsawGenerate(CJigsawBlockGeneratePacket packet) { } - @Override public void handleSelectTrade(CSelectTradePacket packet) { } - @Override public void handleEditBook(CEditBookPacket packet) { } - @Override public void handleEntityTagQuery(CQueryEntityNBTPacket packet) { } - @Override public void handleBlockEntityTagQuery(CQueryTileEntityNBTPacket packet) { } - @Override public void handleMovePlayer(CPlayerPacket packet) { } + @Override public void disconnect(Component message) { } + @Override public void handlePlayerInput(ServerboundPlayerInputPacket packet) { } + @Override public void handleMoveVehicle(ServerboundMoveVehiclePacket packet) { } + @Override public void handleAcceptTeleportPacket(ServerboundAcceptTeleportationPacket packet) { } + @Override public void handleRecipeBookSeenRecipePacket(ServerboundRecipeBookSeenRecipePacket packet) { } + @Override public void handleRecipeBookChangeSettingsPacket(ServerboundRecipeBookChangeSettingsPacket packet) { } + @Override public void handleSeenAdvancements(ServerboundSeenAdvancementsPacket packet) { } + @Override public void handleCustomCommandSuggestions(ServerboundCommandSuggestionPacket packet) { } + @Override public void handleSetCommandBlock(ServerboundSetCommandBlockPacket packet) { } + @Override public void handleSetCommandMinecart(ServerboundSetCommandMinecartPacket packet) { } + @Override public void handlePickItem(ServerboundPickItemPacket packet) { } + @Override public void handleRenameItem(ServerboundRenameItemPacket packet) { } + @Override public void handleSetBeaconPacket(ServerboundSetBeaconPacket packet) { } + @Override public void handleSetStructureBlock(ServerboundSetStructureBlockPacket packet) { } + @Override public void handleSetJigsawBlock(ServerboundSetJigsawBlockPacket packet) { } + @Override public void handleJigsawGenerate(ServerboundJigsawGeneratePacket packet) { } + @Override public void handleSelectTrade(ServerboundSelectTradePacket packet) { } + @Override public void handleEditBook(ServerboundEditBookPacket packet) { } + @Override public void handleEntityTagQuery(ServerboundEntityTagQuery packet) { } + @Override public void handleBlockEntityTagQuery(ServerboundBlockEntityTagQuery packet) { } + @Override public void handleMovePlayer(ServerboundMovePlayerPacket packet) { } @Override public void teleport(double x, double y, double z, float yaw, float pitch) { } - @Override public void teleport(double x, double y, double z, float yaw, float pitch, Set flags) { } - @Override public void handlePlayerAction(CPlayerDiggingPacket packet) { } - @Override public void handleUseItemOn(CPlayerTryUseItemOnBlockPacket packet) { } - @Override public void handleUseItem(CPlayerTryUseItemPacket packet) { } - @Override public void handleTeleportToEntityPacket(CSpectatePacket packet) { } - @Override public void handleResourcePackResponse(CResourcePackStatusPacket packet) { } - @Override public void handlePaddleBoat(CSteerBoatPacket packet) { } - @Override public void onDisconnect(ITextComponent message) { } - @Override public void send(IPacket packet) { } - @Override public void send(IPacket packet, @Nullable GenericFutureListener> p_211148_2_) { } - @Override public void handleSetCarriedItem(CHeldItemChangePacket packet) { } - @Override public void handleChat(CChatMessagePacket packet) { } - @Override public void handleAnimate(CAnimateHandPacket packet) { } - @Override public void handlePlayerCommand(CEntityActionPacket packet) { } - @Override public void handleInteract(CUseEntityPacket packet) { } - @Override public void handleClientCommand(CClientStatusPacket packet) { } - @Override public void handleContainerClose(CCloseWindowPacket packet) { } - @Override public void handleContainerClick(CClickWindowPacket packet) { } - @Override public void handlePlaceRecipe(CPlaceRecipePacket packet) { } - @Override public void handleContainerButtonClick(CEnchantItemPacket packet) { } - @Override public void handleSetCreativeModeSlot(CCreativeInventoryActionPacket packet) { } - @Override public void handleContainerAck(CConfirmTransactionPacket packet) { } - @Override public void handleSignUpdate(CUpdateSignPacket packet) { } - @Override public void handleKeepAlive(CKeepAlivePacket packet) { } - @Override public void handlePlayerAbilities(CPlayerAbilitiesPacket packet) { } - @Override public void handleClientInformation(CClientSettingsPacket packet) { } - @Override public void handleCustomPayload(CCustomPayloadPacket packet) { } - @Override public void handleChangeDifficulty(CSetDifficultyPacket packet) { } - @Override public void handleLockDifficulty(CLockDifficultyPacket packet) { } + @Override public void teleport(double x, double y, double z, float yaw, float pitch, Set flags) { } + @Override public void handlePlayerAction(ServerboundPlayerActionPacket packet) { } + @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) { } + @Override public void send(Packet packet, @Nullable GenericFutureListener> listener) { } + @Override public void handleSetCarriedItem(ServerboundSetCarriedItemPacket packet) { } + @Override public void handleChat(ServerboundChatPacket packet) { } + @Override public void handleAnimate(ServerboundSwingPacket packet) { } + @Override public void handlePlayerCommand(ServerboundPlayerCommandPacket packet) { } + @Override public void handleInteract(ServerboundInteractPacket packet) { } + @Override public void handleClientCommand(ServerboundClientCommandPacket packet) { } + @Override public void handleContainerClose(ServerboundContainerClosePacket packet) { } + @Override public void handleContainerClick(ServerboundContainerClickPacket packet) { } + @Override public void handlePlaceRecipe(ServerboundPlaceRecipePacket packet) { } + @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) { } } } diff --git a/src/main/java/net/minecraftforge/common/util/FakePlayerFactory.java b/src/main/java/net/minecraftforge/common/util/FakePlayerFactory.java index f7fc3cbc44..3e40efb1f4 100644 --- a/src/main/java/net/minecraftforge/common/util/FakePlayerFactory.java +++ b/src/main/java/net/minecraftforge/common/util/FakePlayerFactory.java @@ -20,15 +20,13 @@ package net.minecraftforge.common.util; import java.lang.ref.WeakReference; -import java.util.Iterator; import java.util.Map; -import java.util.Map.Entry; import java.util.UUID; import com.google.common.collect.Maps; import com.mojang.authlib.GameProfile; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.server.level.ServerLevel; //To be expanded for generic Mod fake players? public class FakePlayerFactory @@ -38,7 +36,7 @@ public class FakePlayerFactory private static Map fakePlayers = Maps.newHashMap(); private static WeakReference MINECRAFT_PLAYER = null; - public static FakePlayer getMinecraft(ServerWorld world) + public static FakePlayer getMinecraft(ServerLevel world) { FakePlayer ret = MINECRAFT_PLAYER != null ? MINECRAFT_PLAYER.get() : null; if (ret == null) @@ -54,7 +52,7 @@ public class FakePlayerFactory * Mods should either hold weak references to the return value, or listen for a * WorldEvent.Unload and kill all references to prevent worlds staying in memory. */ - public static FakePlayer get(ServerWorld world, GameProfile username) + public static FakePlayer get(ServerLevel world, GameProfile username) { if (!fakePlayers.containsKey(username)) { @@ -65,7 +63,7 @@ public class FakePlayerFactory return fakePlayers.get(username); } - public static void unloadWorld(ServerWorld world) + public static void unloadWorld(ServerLevel world) { fakePlayers.entrySet().removeIf(entry -> entry.getValue().level == world); if (MINECRAFT_PLAYER != null && MINECRAFT_PLAYER.get() != null && MINECRAFT_PLAYER.get().level == world) // This shouldn't be strictly necessary, but lets be aggressive. diff --git a/src/main/java/net/minecraftforge/common/util/ForgeSoundType.java b/src/main/java/net/minecraftforge/common/util/ForgeSoundType.java index 71f25b4bc0..6e9c356db2 100644 --- a/src/main/java/net/minecraftforge/common/util/ForgeSoundType.java +++ b/src/main/java/net/minecraftforge/common/util/ForgeSoundType.java @@ -19,11 +19,8 @@ package net.minecraftforge.common.util; -import net.minecraft.block.Block; -import net.minecraft.block.SoundType; -import net.minecraft.util.SoundEvent; -import net.minecraftforge.fml.RegistryObject; -import net.minecraftforge.registries.DeferredRegister; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.sounds.SoundEvent; import javax.annotation.Nonnull; import java.util.function.Supplier; diff --git a/src/main/java/net/minecraftforge/common/util/INBTSerializable.java b/src/main/java/net/minecraftforge/common/util/INBTSerializable.java index eba05fc3a3..9fe7231620 100644 --- a/src/main/java/net/minecraftforge/common/util/INBTSerializable.java +++ b/src/main/java/net/minecraftforge/common/util/INBTSerializable.java @@ -19,13 +19,13 @@ package net.minecraftforge.common.util; -import net.minecraft.nbt.INBT; +import net.minecraft.nbt.Tag; /** * An interface designed to unify various things in the Minecraft * code base that can be serialized to and from a NBT tag. */ -public interface INBTSerializable +public interface INBTSerializable { T serializeNBT(); void deserializeNBT(T nbt); diff --git a/src/main/java/net/minecraftforge/common/util/ITeleporter.java b/src/main/java/net/minecraftforge/common/util/ITeleporter.java index 5905fcd908..c5a8f51746 100644 --- a/src/main/java/net/minecraftforge/common/util/ITeleporter.java +++ b/src/main/java/net/minecraftforge/common/util/ITeleporter.java @@ -23,13 +23,12 @@ import java.util.function.Function; import javax.annotation.Nullable; -import net.minecraft.block.PortalInfo; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.Teleporter; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.level.portal.PortalInfo; +import net.minecraft.world.entity.Entity; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.portal.PortalForcer; +import net.minecraft.server.level.ServerLevel; /** * Interface for handling the placement of entities during dimension change. @@ -60,7 +59,7 @@ public interface ITeleporter * * @return the entity in the new World. Vanilla creates for most {@link Entity}s a new instance and copy the data. But you are not allowed to create a new instance for {@link PlayerEntity}s! Move the player and update its state, see {@link ServerPlayerEntity#changeDimension(net.minecraft.world.server.ServerWorld, ITeleporter)} */ - default Entity placeEntity(Entity entity, ServerWorld currentWorld, ServerWorld destWorld, float yaw, Function repositionEntity) + default Entity placeEntity(Entity entity, ServerLevel currentWorld, ServerLevel destWorld, float yaw, Function repositionEntity) { return repositionEntity.apply(true); } @@ -79,9 +78,9 @@ public interface ITeleporter * @return The location, rotation, and motion of the entity in the destWorld after the teleport */ @Nullable - default PortalInfo getPortalInfo(Entity entity, ServerWorld destWorld, Function defaultPortalInfo) + default PortalInfo getPortalInfo(Entity entity, ServerLevel destWorld, Function defaultPortalInfo) { - return this.isVanilla() ? defaultPortalInfo.apply(destWorld) : new PortalInfo(entity.position(), Vector3d.ZERO, entity.yRot, entity.xRot); + return this.isVanilla() ? defaultPortalInfo.apply(destWorld) : new PortalInfo(entity.position(), Vec3.ZERO, entity.getYRot(), entity.getXRot()); } /** @@ -89,7 +88,7 @@ public interface ITeleporter */ default boolean isVanilla() { - return this.getClass() == Teleporter.class; + return this.getClass() == PortalForcer.class; } /** @@ -99,7 +98,7 @@ public interface ITeleporter * @param destWorld the target world * @return true to play the vanilla sound */ - default boolean playTeleportSound(ServerPlayerEntity player, ServerWorld sourceWorld, ServerWorld destWorld) + default boolean playTeleportSound(ServerPlayer player, ServerLevel sourceWorld, ServerLevel destWorld) { return true; } diff --git a/src/main/java/net/minecraftforge/common/util/JsonUtils.java b/src/main/java/net/minecraftforge/common/util/JsonUtils.java index 0488067646..e03a6c4492 100644 --- a/src/main/java/net/minecraftforge/common/util/JsonUtils.java +++ b/src/main/java/net/minecraftforge/common/util/JsonUtils.java @@ -38,8 +38,8 @@ import com.google.gson.JsonSerializer; import com.google.gson.JsonSyntaxException; import com.mojang.brigadier.exceptions.CommandSyntaxException; -import net.minecraft.nbt.JsonToNBT; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.TagParser; +import net.minecraft.nbt.CompoundTag; import javax.annotation.Nullable; @@ -97,13 +97,13 @@ public class JsonUtils } @Nullable - public static CompoundNBT readNBT(JsonObject json, String key) + public static CompoundTag readNBT(JsonObject json, String key) { - if (net.minecraft.util.JSONUtils.isValidNode(json, key)) + if (net.minecraft.util.GsonHelper.isValidNode(json, key)) { try { - return JsonToNBT.parseTag(net.minecraft.util.JSONUtils.getAsString(json, key)); + return TagParser.parseTag(net.minecraft.util.GsonHelper.getAsString(json, key)); } catch (CommandSyntaxException e) { throw new JsonSyntaxException("Malformed NBT tag", e); diff --git a/src/main/java/net/minecraftforge/common/util/LazyOptional.java b/src/main/java/net/minecraftforge/common/util/LazyOptional.java index 7d1022c156..2cf58d7705 100644 --- a/src/main/java/net/minecraftforge/common/util/LazyOptional.java +++ b/src/main/java/net/minecraftforge/common/util/LazyOptional.java @@ -28,15 +28,13 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; import org.apache.commons.lang3.mutable.Mutable; import org.apache.commons.lang3.mutable.MutableObject; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import mcp.MethodsReturnNonnullByDefault; -import net.minecraftforge.common.capabilities.Capability; - /** * This object encapsulates a lazy value, with typical transformation operations * (map/ifPresent) available, much like {@link Optional}. diff --git a/src/main/java/net/minecraftforge/common/util/LogMessageAdapter.java b/src/main/java/net/minecraftforge/common/util/LogMessageAdapter.java new file mode 100644 index 0000000000..0226ebcf82 --- /dev/null +++ b/src/main/java/net/minecraftforge/common/util/LogMessageAdapter.java @@ -0,0 +1,57 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.common.util; + +import org.apache.logging.log4j.message.Message; +import org.apache.logging.log4j.util.StringBuilderFormattable; + +import java.util.function.Consumer; + +public record LogMessageAdapter(Consumer builder) implements Message, StringBuilderFormattable { + private static final Object[] EMPTY = new Object[0]; + @Override + public String getFormattedMessage() { + return ""; + } + + @Override + public String getFormat() { + return ""; + } + + @Override + public Object[] getParameters() { + return EMPTY; + } + + @Override + public Throwable getThrowable() { + return null; + } + + @Override + public void formatTo(final StringBuilder buffer) { + builder.accept(buffer); + } + + public static Message adapt(final Consumer toConsume) { + return new LogMessageAdapter(toConsume); + } +} diff --git a/src/main/java/net/minecraftforge/common/util/NonNullConsumer.java b/src/main/java/net/minecraftforge/common/util/NonNullConsumer.java index 7bd5b7c131..83841d3a5b 100644 --- a/src/main/java/net/minecraftforge/common/util/NonNullConsumer.java +++ b/src/main/java/net/minecraftforge/common/util/NonNullConsumer.java @@ -19,8 +19,6 @@ package net.minecraftforge.common.util; -import java.util.function.Consumer; - import javax.annotation.Nonnull; /** diff --git a/src/main/java/net/minecraftforge/common/util/NonNullFunction.java b/src/main/java/net/minecraftforge/common/util/NonNullFunction.java index 83fbe3fee7..7829f10403 100644 --- a/src/main/java/net/minecraftforge/common/util/NonNullFunction.java +++ b/src/main/java/net/minecraftforge/common/util/NonNullFunction.java @@ -19,8 +19,6 @@ package net.minecraftforge.common.util; -import java.util.function.Function; - import javax.annotation.Nonnull; /** diff --git a/src/main/java/net/minecraftforge/common/util/NonNullPredicate.java b/src/main/java/net/minecraftforge/common/util/NonNullPredicate.java index 4bcf67d038..ee2307a5dc 100644 --- a/src/main/java/net/minecraftforge/common/util/NonNullPredicate.java +++ b/src/main/java/net/minecraftforge/common/util/NonNullPredicate.java @@ -19,8 +19,6 @@ package net.minecraftforge.common.util; -import java.util.function.Predicate; - import javax.annotation.Nonnull; /** diff --git a/src/main/java/net/minecraftforge/common/util/NonNullSupplier.java b/src/main/java/net/minecraftforge/common/util/NonNullSupplier.java index 889982d1dd..2a2612f285 100644 --- a/src/main/java/net/minecraftforge/common/util/NonNullSupplier.java +++ b/src/main/java/net/minecraftforge/common/util/NonNullSupplier.java @@ -19,8 +19,6 @@ package net.minecraftforge.common.util; -import java.util.function.Supplier; - import javax.annotation.Nonnull; /** diff --git a/src/main/java/net/minecraftforge/common/util/ReverseTagWrapper.java b/src/main/java/net/minecraftforge/common/util/ReverseTagWrapper.java index 3a09193e6c..f804353783 100644 --- a/src/main/java/net/minecraftforge/common/util/ReverseTagWrapper.java +++ b/src/main/java/net/minecraftforge/common/util/ReverseTagWrapper.java @@ -25,20 +25,20 @@ import java.util.Map; import java.util.Set; import java.util.function.Supplier; -import net.minecraft.tags.ITag; -import net.minecraft.tags.ITagCollection; -import net.minecraft.util.ResourceLocation; +import net.minecraft.tags.Tag; +import net.minecraft.tags.TagCollection; +import net.minecraft.resources.ResourceLocation; public class ReverseTagWrapper { private final T target; - private final Supplier> colSupplier; + private final Supplier> colSupplier; //This map is immutable we track its identity change. - private Map> colCache; + private Map> colCache; private Set cache = null; - public ReverseTagWrapper(T target, Supplier> colSupplier) + public ReverseTagWrapper(T target, Supplier> colSupplier) { this.target = target; this.colSupplier = colSupplier; @@ -46,7 +46,7 @@ public class ReverseTagWrapper public Set getTagNames() { - ITagCollection collection = colSupplier.get(); + TagCollection collection = colSupplier.get(); if (cache == null || colCache != collection.getAllTags()) // Identity equals. { this.cache = Collections.unmodifiableSet(new HashSet<>(collection.getMatchingTags(target))); diff --git a/src/main/java/net/minecraftforge/common/util/WorldCapabilityData.java b/src/main/java/net/minecraftforge/common/util/WorldCapabilityData.java index 35025d6f5c..7d4313ccb6 100644 --- a/src/main/java/net/minecraftforge/common/util/WorldCapabilityData.java +++ b/src/main/java/net/minecraftforge/common/util/WorldCapabilityData.java @@ -21,29 +21,29 @@ package net.minecraftforge.common.util; import javax.annotation.Nullable; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.world.storage.WorldSavedData; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.saveddata.SavedData; +import net.minecraftforge.common.capabilities.CapabilityProvider; -public class WorldCapabilityData extends WorldSavedData +public class WorldCapabilityData extends SavedData { public static final String ID = "capabilities"; - private INBTSerializable serializable; - private CompoundNBT capNBT = null; + private INBTSerializable serializable; + private CompoundTag capNBT = null; - public WorldCapabilityData(String name) + public WorldCapabilityData(@Nullable INBTSerializable serializable) { - super(name); - } - - public WorldCapabilityData(@Nullable INBTSerializable serializable) - { - super(ID); this.serializable = serializable; } - @Override - public void load(CompoundNBT nbt) + public static WorldCapabilityData load(CompoundTag tag, @Nullable INBTSerializable serializable) { + WorldCapabilityData data = new WorldCapabilityData(serializable); + data.read(tag); + return data; + } + + public void read(CompoundTag nbt) { this.capNBT = nbt; if (serializable != null) @@ -54,7 +54,7 @@ public class WorldCapabilityData extends WorldSavedData } @Override - public CompoundNBT save(CompoundNBT nbt) + public CompoundTag save(CompoundTag nbt) { if (serializable != null) nbt = serializable.serializeNBT(); @@ -67,7 +67,7 @@ public class WorldCapabilityData extends WorldSavedData return true; } - public void setCapabilities(INBTSerializable capabilities) + public void setCapabilities(INBTSerializable capabilities) { this.serializable = capabilities; if (this.capNBT != null && serializable != null) diff --git a/src/main/java/net/minecraftforge/common/world/BiomeGenerationSettingsBuilder.java b/src/main/java/net/minecraftforge/common/world/BiomeGenerationSettingsBuilder.java index cb57a4a74b..91231c00ed 100644 --- a/src/main/java/net/minecraftforge/common/world/BiomeGenerationSettingsBuilder.java +++ b/src/main/java/net/minecraftforge/common/world/BiomeGenerationSettingsBuilder.java @@ -19,18 +19,16 @@ package net.minecraftforge.common.world; -import net.minecraft.world.biome.BiomeGenerationSettings; -import net.minecraft.world.gen.GenerationStage; -import net.minecraft.world.gen.carver.ConfiguredCarver; -import net.minecraft.world.gen.feature.ConfiguredFeature; -import net.minecraft.world.gen.feature.StructureFeature; -import net.minecraft.world.gen.surfacebuilders.ConfiguredSurfaceBuilder; +import net.minecraft.world.level.biome.BiomeGenerationSettings; +import net.minecraft.world.level.levelgen.GenerationStep; +import net.minecraft.world.level.levelgen.carver.ConfiguredWorldCarver; +import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; +import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature; +import net.minecraft.world.level.levelgen.surfacebuilders.ConfiguredSurfaceBuilder; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.Optional; -import java.util.function.Predicate; import java.util.function.Supplier; public class BiomeGenerationSettingsBuilder extends BiomeGenerationSettings.Builder @@ -43,7 +41,7 @@ public class BiomeGenerationSettingsBuilder extends BiomeGenerationSettings.Buil structureStarts.addAll(orig.structures()); } - public List>> getFeatures(GenerationStage.Decoration stage) { + public List>> getFeatures(GenerationStep.Decoration stage) { addFeatureStepsUpTo(stage.ordinal()); return features.get(stage.ordinal()); } @@ -52,11 +50,11 @@ public class BiomeGenerationSettingsBuilder extends BiomeGenerationSettings.Buil return surfaceBuilder; } - public List>> getCarvers(GenerationStage.Carving stage) { + public List>> getCarvers(GenerationStep.Carving stage) { return carvers.computeIfAbsent(stage, key -> new ArrayList<>()); } - public List>> getStructures() { + public List>> getStructures() { return structureStarts; } } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/common/world/ForgeChunkManager.java b/src/main/java/net/minecraftforge/common/world/ForgeChunkManager.java index 15c58e3f45..4410189bf6 100644 --- a/src/main/java/net/minecraftforge/common/world/ForgeChunkManager.java +++ b/src/main/java/net/minecraftforge/common/world/ForgeChunkManager.java @@ -33,16 +33,16 @@ import java.util.UUID; import java.util.function.BiConsumer; import java.util.function.Function; import javax.annotation.ParametersAreNonnullByDefault; -import net.minecraft.entity.Entity; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.INBT; -import net.minecraft.nbt.ListNBT; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.ChunkPos; -import net.minecraft.world.ForcedChunksSaveData; -import net.minecraft.world.server.ServerWorld; -import net.minecraft.world.server.TicketType; +import net.minecraft.world.entity.Entity; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.Tag; +import net.minecraft.nbt.ListTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.ForcedChunksSavedData; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.TicketType; import net.minecraftforge.common.util.Constants; import net.minecraftforge.fml.ModList; import org.apache.logging.log4j.LogManager; @@ -75,9 +75,9 @@ public class ForgeChunkManager /** * Checks if a world has any forced chunks. Mainly used for seeing if a world should continue ticking with no players in it. */ - public static boolean hasForcedChunks(ServerWorld world) + public static boolean hasForcedChunks(ServerLevel world) { - ForcedChunksSaveData data = world.getDataStorage().get(ForcedChunksSaveData::new, "chunks"); + ForcedChunksSavedData data = world.getDataStorage().get(ForcedChunksSavedData::load, "chunks"); if (data == null) return false; return !data.getChunks().isEmpty() || !data.getBlockForcedChunks().isEmpty() || !data.getEntityForcedChunks().isEmpty(); } @@ -88,9 +88,9 @@ public class ForgeChunkManager * @param add {@code true} to force the chunk, {@code false} to unforce the chunk. * @param ticking {@code true} to make the chunk receive full chunk ticks even if there is no player nearby. */ - public static boolean forceChunk(ServerWorld world, String modId, BlockPos owner, int chunkX, int chunkZ, boolean add, boolean ticking) + public static boolean forceChunk(ServerLevel world, String modId, BlockPos owner, int chunkX, int chunkZ, boolean add, boolean ticking) { - return forceChunk(world, modId, owner, chunkX, chunkZ, add, ticking, ticking ? BLOCK_TICKING : BLOCK, ForcedChunksSaveData::getBlockForcedChunks); + return forceChunk(world, modId, owner, chunkX, chunkZ, add, ticking, ticking ? BLOCK_TICKING : BLOCK, ForcedChunksSavedData::getBlockForcedChunks); } /** @@ -99,7 +99,7 @@ public class ForgeChunkManager * @param add {@code true} to force the chunk, {@code false} to unforce the chunk. * @param ticking {@code true} to make the chunk receive full chunk ticks even if there is no player nearby. */ - public static boolean forceChunk(ServerWorld world, String modId, Entity owner, int chunkX, int chunkZ, boolean add, boolean ticking) + public static boolean forceChunk(ServerLevel world, String modId, Entity owner, int chunkX, int chunkZ, boolean add, boolean ticking) { return forceChunk(world, modId, owner.getUUID(), chunkX, chunkZ, add, ticking); } @@ -110,9 +110,9 @@ public class ForgeChunkManager * @param add {@code true} to force the chunk, {@code false} to unforce the chunk. * @param ticking {@code true} to make the chunk receive full chunk ticks even if there is no player nearby. */ - public static boolean forceChunk(ServerWorld world, String modId, UUID owner, int chunkX, int chunkZ, boolean add, boolean ticking) + public static boolean forceChunk(ServerLevel world, String modId, UUID owner, int chunkX, int chunkZ, boolean add, boolean ticking) { - return forceChunk(world, modId, owner, chunkX, chunkZ, add, ticking, ticking ? ENTITY_TICKING : ENTITY, ForcedChunksSaveData::getEntityForcedChunks); + return forceChunk(world, modId, owner, chunkX, chunkZ, add, ticking, ticking ? ENTITY_TICKING : ENTITY, ForcedChunksSavedData::getEntityForcedChunks); } /** @@ -120,17 +120,17 @@ public class ForgeChunkManager * * @param add {@code true} to force the chunk, {@code false} to unforce the chunk. * - * @implNote Based on {@link ServerWorld#forceChunk(int, int, boolean)} + * @implNote Based on {@link ServerLevel#setChunkForced(int, int, boolean)} */ - private static > boolean forceChunk(ServerWorld world, String modId, T owner, int chunkX, int chunkZ, boolean add, boolean ticking, - TicketType> type, Function> ticketGetter) + private static > boolean forceChunk(ServerLevel world, String modId, T owner, int chunkX, int chunkZ, boolean add, boolean ticking, + TicketType> type, Function> ticketGetter) { if (!ModList.get().isLoaded(modId)) { LOGGER.warn("A mod attempted to force a chunk for an unloaded mod of id: {}", modId); return false; } - ForcedChunksSaveData saveData = world.getDataStorage().computeIfAbsent(ForcedChunksSaveData::new, "chunks"); + ForcedChunksSavedData saveData = world.getDataStorage().computeIfAbsent(ForcedChunksSavedData::load, ForcedChunksSavedData::new, "chunks"); ChunkPos pos = new ChunkPos(chunkX, chunkZ); long chunk = pos.toLong(); TicketTracker tickets = ticketGetter.apply(saveData); @@ -163,7 +163,7 @@ public class ForgeChunkManager * @implNote We use distance 2 for what we pass, as when using register/releaseTicket the ticket's level is set to 33 - distance and the level that forced chunks use * is 31. */ - private static > void forceChunk(ServerWorld world, ChunkPos pos, TicketType> type, TicketOwner owner, boolean add, + private static > void forceChunk(ServerLevel world, ChunkPos pos, TicketType> type, TicketOwner owner, boolean add, boolean ticking) { if (add) @@ -185,7 +185,7 @@ public class ForgeChunkManager * * @apiNote Internal */ - public static void reinstatePersistentChunks(ServerWorld world, ForcedChunksSaveData saveData) + public static void reinstatePersistentChunks(ServerLevel world, ForcedChunksSavedData saveData) { if (!callbacks.isEmpty()) { @@ -241,7 +241,7 @@ public class ForgeChunkManager /** * Adds back any persistent forced chunks to the world's chunk provider. */ - private static > void reinstatePersistentChunks(ServerWorld world, TicketType> type, + private static > void reinstatePersistentChunks(ServerLevel world, TicketType> type, Map, LongSet> tickets, boolean ticking) { for (Map.Entry, LongSet> entry : tickets.entrySet()) @@ -258,19 +258,19 @@ public class ForgeChunkManager * * @apiNote Internal */ - public static void writeForgeForcedChunks(CompoundNBT nbt, TicketTracker blockForcedChunks, TicketTracker entityForcedChunks) + public static void writeForgeForcedChunks(CompoundTag nbt, TicketTracker blockForcedChunks, TicketTracker entityForcedChunks) { if (!blockForcedChunks.isEmpty() || !entityForcedChunks.isEmpty()) { - Map> forcedEntries = new HashMap<>(); - writeForcedChunkOwners(forcedEntries, blockForcedChunks, "Blocks", Constants.NBT.TAG_COMPOUND, (pos, forcedBlocks) -> forcedBlocks.add(NBTUtil.writeBlockPos(pos))); - writeForcedChunkOwners(forcedEntries, entityForcedChunks, "Entities", Constants.NBT.TAG_INT_ARRAY, (uuid, forcedEntities) -> forcedEntities.add(NBTUtil.createUUID(uuid))); - ListNBT forcedChunks = new ListNBT(); - for (Map.Entry> entry : forcedEntries.entrySet()) + Map> forcedEntries = new HashMap<>(); + writeForcedChunkOwners(forcedEntries, blockForcedChunks, "Blocks", Constants.NBT.TAG_COMPOUND, (pos, forcedBlocks) -> forcedBlocks.add(NbtUtils.writeBlockPos(pos))); + writeForcedChunkOwners(forcedEntries, entityForcedChunks, "Entities", Constants.NBT.TAG_INT_ARRAY, (uuid, forcedEntities) -> forcedEntities.add(NbtUtils.createUUID(uuid))); + ListTag forcedChunks = new ListTag(); + for (Map.Entry> entry : forcedEntries.entrySet()) { - CompoundNBT forcedEntry = new CompoundNBT(); + CompoundTag forcedEntry = new CompoundTag(); forcedEntry.putString("Mod", entry.getKey()); - ListNBT modForced = new ListNBT(); + ListTag modForced = new ListTag(); modForced.addAll(entry.getValue().values()); forcedEntry.put("ModForced", modForced); forcedChunks.add(forcedEntry); @@ -279,27 +279,27 @@ public class ForgeChunkManager } } - private static > void writeForcedChunkOwners(Map> forcedEntries, TicketTracker tracker, - String listKey, int listType, BiConsumer ownerWriter) + private static > void writeForcedChunkOwners(Map> forcedEntries, TicketTracker tracker, + String listKey, int listType, BiConsumer ownerWriter) { writeForcedChunkOwners(forcedEntries, tracker.chunks, listKey,listType, ownerWriter); writeForcedChunkOwners(forcedEntries, tracker.tickingChunks, "Ticking" + listKey, listType, ownerWriter); } - private static > void writeForcedChunkOwners(Map> forcedEntries, - Map, LongSet> forcedChunks, String listKey, int listType, BiConsumer ownerWriter) + private static > void writeForcedChunkOwners(Map> forcedEntries, + Map, LongSet> forcedChunks, String listKey, int listType, BiConsumer ownerWriter) { for (Map.Entry, LongSet> entry : forcedChunks.entrySet()) { - Long2ObjectMap modForced = forcedEntries.computeIfAbsent(entry.getKey().modId, modId -> new Long2ObjectOpenHashMap<>()); + Long2ObjectMap modForced = forcedEntries.computeIfAbsent(entry.getKey().modId, modId -> new Long2ObjectOpenHashMap<>()); for (long chunk : entry.getValue()) { - CompoundNBT modEntry = modForced.computeIfAbsent(chunk, chunkPos -> { - CompoundNBT baseEntry = new CompoundNBT(); + CompoundTag modEntry = modForced.computeIfAbsent(chunk, chunkPos -> { + CompoundTag baseEntry = new CompoundTag(); baseEntry.putLong("Chunk", chunkPos); return baseEntry; }); - ListNBT ownerList = modEntry.getList(listKey, listType); + ListTag ownerList = modEntry.getList(listKey, listType); ownerWriter.accept(entry.getKey().owner, ownerList); //Note: As getList returns a new list in the case the data is of the wrong type, // we need to mimic was vanilla does in various places and put our list back in @@ -314,19 +314,19 @@ public class ForgeChunkManager * * @apiNote Internal */ - public static void readForgeForcedChunks(CompoundNBT nbt, TicketTracker blockForcedChunks, TicketTracker entityForcedChunks) + public static void readForgeForcedChunks(CompoundTag nbt, TicketTracker blockForcedChunks, TicketTracker entityForcedChunks) { - ListNBT forcedChunks = nbt.getList("ForgeForced", Constants.NBT.TAG_COMPOUND); + ListTag forcedChunks = nbt.getList("ForgeForced", Constants.NBT.TAG_COMPOUND); for (int i = 0; i < forcedChunks.size(); i++) { - CompoundNBT forcedEntry = forcedChunks.getCompound(i); + CompoundTag forcedEntry = forcedChunks.getCompound(i); String modId = forcedEntry.getString("Mod"); if (ModList.get().isLoaded(modId)) { - ListNBT modForced = forcedEntry.getList("ModForced", Constants.NBT.TAG_COMPOUND); + ListTag modForced = forcedEntry.getList("ModForced", Constants.NBT.TAG_COMPOUND); for (int j = 0; j < modForced.size(); j++) { - CompoundNBT modEntry = modForced.getCompound(j); + CompoundTag modEntry = modForced.getCompound(j); long chunkPos = modEntry.getLong("Chunk"); readBlockForcedChunks(modId, chunkPos, modEntry, "Blocks", blockForcedChunks.chunks); readBlockForcedChunks(modId, chunkPos, modEntry, "TickingBlocks", blockForcedChunks.tickingChunks); @@ -344,24 +344,24 @@ public class ForgeChunkManager /** * Reads the forge block forced chunks. */ - private static void readBlockForcedChunks(String modId, long chunkPos, CompoundNBT modEntry, String key, Map, LongSet> blockForcedChunks) + private static void readBlockForcedChunks(String modId, long chunkPos, CompoundTag modEntry, String key, Map, LongSet> blockForcedChunks) { - ListNBT forcedBlocks = modEntry.getList(key, Constants.NBT.TAG_COMPOUND); + ListTag forcedBlocks = modEntry.getList(key, Constants.NBT.TAG_COMPOUND); for (int k = 0; k < forcedBlocks.size(); k++) { - blockForcedChunks.computeIfAbsent(new TicketOwner<>(modId, NBTUtil.readBlockPos(forcedBlocks.getCompound(k))), owner -> new LongOpenHashSet()).add(chunkPos); + blockForcedChunks.computeIfAbsent(new TicketOwner<>(modId, NbtUtils.readBlockPos(forcedBlocks.getCompound(k))), owner -> new LongOpenHashSet()).add(chunkPos); } } /** * Reads the forge entity forced chunks. */ - private static void readEntityForcedChunks(String modId, long chunkPos, CompoundNBT modEntry, String key, Map, LongSet> entityForcedChunks) + private static void readEntityForcedChunks(String modId, long chunkPos, CompoundTag modEntry, String key, Map, LongSet> entityForcedChunks) { - ListNBT forcedEntities = modEntry.getList(key, Constants.NBT.TAG_INT_ARRAY); - for (INBT uuid : forcedEntities) + ListTag forcedEntities = modEntry.getList(key, Constants.NBT.TAG_INT_ARRAY); + for (Tag uuid : forcedEntities) { - entityForcedChunks.computeIfAbsent(new TicketOwner<>(modId, NBTUtil.loadUUID(uuid)), owner -> new LongOpenHashSet()).add(chunkPos); + entityForcedChunks.computeIfAbsent(new TicketOwner<>(modId, NbtUtils.loadUUID(uuid)), owner -> new LongOpenHashSet()).add(chunkPos); } } @@ -373,7 +373,7 @@ public class ForgeChunkManager * @param world The world * @param ticketHelper Ticket helper to remove any invalid tickets. */ - void validateTickets(ServerWorld world, TicketHelper ticketHelper); + void validateTickets(ServerLevel world, TicketHelper ticketHelper); } /** @@ -383,10 +383,10 @@ public class ForgeChunkManager { private final Map> blockTickets; private final Map> entityTickets; - private final ForcedChunksSaveData saveData; + private final ForcedChunksSavedData saveData; private final String modId; - private TicketHelper(ForcedChunksSaveData saveData, String modId, Map> blockTickets, Map> entityTickets) + private TicketHelper(ForcedChunksSavedData saveData, String modId, Map> blockTickets, Map> entityTickets) { this.saveData = saveData; this.modId = modId; @@ -584,4 +584,4 @@ public class ForgeChunkManager return getTickets(ticking).computeIfAbsent(owner, o -> new LongOpenHashSet()).add(chunk); } } -} \ No newline at end of file +} diff --git a/src/main/java/net/minecraftforge/common/world/ForgeWorldType.java b/src/main/java/net/minecraftforge/common/world/ForgeWorldType.java index 1c566a9abf..a0fc274ec8 100644 --- a/src/main/java/net/minecraftforge/common/world/ForgeWorldType.java +++ b/src/main/java/net/minecraftforge/common/world/ForgeWorldType.java @@ -19,18 +19,18 @@ package net.minecraftforge.common.world; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.StringUtils; -import net.minecraft.util.Util; -import net.minecraft.util.registry.DynamicRegistries; -import net.minecraft.util.registry.Registry; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TranslationTextComponent; -import net.minecraft.world.DimensionType; -import net.minecraft.world.biome.Biome; -import net.minecraft.world.gen.ChunkGenerator; -import net.minecraft.world.gen.DimensionSettings; -import net.minecraft.world.gen.settings.DimensionGeneratorSettings; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.StringUtil; +import net.minecraft.Util; +import net.minecraft.core.RegistryAccess; +import net.minecraft.core.Registry; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.world.level.dimension.DimensionType; +import net.minecraft.world.level.biome.Biome; +import net.minecraft.world.level.chunk.ChunkGenerator; +import net.minecraft.world.level.levelgen.NoiseGeneratorSettings; +import net.minecraft.world.level.levelgen.WorldGenSettings; import net.minecraftforge.common.ForgeConfig; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.ForgeRegistryEntry; @@ -45,7 +45,7 @@ public class ForgeWorldType extends ForgeRegistryEntry { String defaultWorldType = ForgeConfig.COMMON.defaultWorldType.get(); - if (StringUtils.isNullOrEmpty(defaultWorldType) || "default".equals(defaultWorldType)) + if (StringUtil.isNullOrEmpty(defaultWorldType) || "default".equals(defaultWorldType)) return null; // use vanilla ForgeWorldType def = ForgeRegistries.WORLD_TYPES.getValue(new ResourceLocation(defaultWorldType)); @@ -74,9 +74,9 @@ public class ForgeWorldType extends ForgeRegistryEntry return Util.makeDescriptionId("generator", getRegistryName()); } - public ITextComponent getDisplayName() + public Component getDisplayName() { - return new TranslationTextComponent(getTranslationKey()); + return new TranslatableComponent(getTranslationKey()); } /** @@ -84,26 +84,26 @@ public class ForgeWorldType extends ForgeRegistryEntry * to construct the DimensionGEneratorSettings: * @return The constructed chunk generator. */ - public ChunkGenerator createChunkGenerator(Registry biomeRegistry, Registry dimensionSettingsRegistry, long seed, String generatorSettings) + public ChunkGenerator createChunkGenerator(Registry biomeRegistry, Registry dimensionSettingsRegistry, long seed, String generatorSettings) { return this.factory.createChunkGenerator(biomeRegistry, dimensionSettingsRegistry, seed, generatorSettings); } - public DimensionGeneratorSettings createSettings(DynamicRegistries dynamicRegistries, long seed, boolean generateStructures, boolean generateLoot, String generatorSettings) + public WorldGenSettings createSettings(RegistryAccess dynamicRegistries, long seed, boolean generateStructures, boolean generateLoot, String generatorSettings) { return this.factory.createSettings(dynamicRegistries, seed, generateStructures, generateLoot, generatorSettings); } public interface IChunkGeneratorFactory { - ChunkGenerator createChunkGenerator(Registry biomeRegistry, Registry dimensionSettingsRegistry, long seed, String generatorSettings); + ChunkGenerator createChunkGenerator(Registry biomeRegistry, Registry dimensionSettingsRegistry, long seed, String generatorSettings); - default DimensionGeneratorSettings createSettings(DynamicRegistries dynamicRegistries, long seed, boolean generateStructures, boolean bonusChest, String generatorSettings) { + default WorldGenSettings createSettings(RegistryAccess dynamicRegistries, long seed, boolean generateStructures, boolean bonusChest, String generatorSettings) { Registry biomeRegistry = dynamicRegistries.registryOrThrow(Registry.BIOME_REGISTRY); Registry dimensionTypeRegistry = dynamicRegistries.registryOrThrow(Registry.DIMENSION_TYPE_REGISTRY); - Registry dimensionSettingsRegistry = dynamicRegistries.registryOrThrow(Registry.NOISE_GENERATOR_SETTINGS_REGISTRY); - return new DimensionGeneratorSettings(seed, generateStructures, bonusChest, - DimensionGeneratorSettings.withOverworld(dimensionTypeRegistry, + Registry dimensionSettingsRegistry = dynamicRegistries.registryOrThrow(Registry.NOISE_GENERATOR_SETTINGS_REGISTRY); + return new WorldGenSettings(seed, generateStructures, bonusChest, + WorldGenSettings.withOverworld(dimensionTypeRegistry, DimensionType.defaultDimensions(dimensionTypeRegistry, biomeRegistry, dimensionSettingsRegistry, seed), createChunkGenerator(biomeRegistry, dimensionSettingsRegistry, seed, generatorSettings))); } @@ -111,9 +111,9 @@ public class ForgeWorldType extends ForgeRegistryEntry public interface IBasicChunkGeneratorFactory extends IChunkGeneratorFactory { - ChunkGenerator createChunkGenerator(Registry biomeRegistry, Registry dimensionSettingsRegistry, long seed); + ChunkGenerator createChunkGenerator(Registry biomeRegistry, Registry dimensionSettingsRegistry, long seed); - default ChunkGenerator createChunkGenerator(Registry biomeRegistry, Registry dimensionSettingsRegistry, long seed, String generatorSettings) + default ChunkGenerator createChunkGenerator(Registry biomeRegistry, Registry dimensionSettingsRegistry, long seed, String generatorSettings) { return createChunkGenerator(biomeRegistry, dimensionSettingsRegistry, seed); } diff --git a/src/main/java/net/minecraftforge/common/world/MobSpawnInfoBuilder.java b/src/main/java/net/minecraftforge/common/world/MobSpawnInfoBuilder.java index b21b645499..9d3cd7f665 100644 --- a/src/main/java/net/minecraftforge/common/world/MobSpawnInfoBuilder.java +++ b/src/main/java/net/minecraftforge/common/world/MobSpawnInfoBuilder.java @@ -25,32 +25,32 @@ import java.util.Set; import javax.annotation.Nullable; -import net.minecraft.entity.EntityClassification; -import net.minecraft.entity.EntityType; -import net.minecraft.world.biome.MobSpawnInfo; +import net.minecraft.world.entity.MobCategory; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.level.biome.MobSpawnSettings; -public class MobSpawnInfoBuilder extends MobSpawnInfo.Builder +public class MobSpawnInfoBuilder extends MobSpawnSettings.Builder { - private final Set typesView = Collections.unmodifiableSet(this.spawners.keySet()); + private final Set typesView = Collections.unmodifiableSet(this.spawners.keySet()); private final Set> costView = Collections.unmodifiableSet(this.mobSpawnCosts.keySet()); - public MobSpawnInfoBuilder(MobSpawnInfo orig) + public MobSpawnInfoBuilder(MobSpawnSettings orig) { orig.getSpawnerTypes().forEach(k -> { spawners.get(k).clear(); - spawners.get(k).addAll(new java.util.ArrayList<>(orig.getMobs(k))); + spawners.get(k).addAll(orig.getMobs(k).unwrap()); }); orig.getEntityTypes().forEach(k -> mobSpawnCosts.put(k, orig.getMobSpawnCost(k))); creatureGenerationProbability = orig.getCreatureProbability(); playerCanSpawn = orig.playerSpawnFriendly(); } - public Set getSpawnerTypes() + public Set getSpawnerTypes() { return this.typesView; } - public List getSpawner(EntityClassification type) + public List getSpawner(MobCategory type) { return this.spawners.get(type); } @@ -61,7 +61,7 @@ public class MobSpawnInfoBuilder extends MobSpawnInfo.Builder } @Nullable - public MobSpawnInfo.SpawnCosts getCost(EntityType type) + public MobSpawnSettings.MobSpawnCost getCost(EntityType type) { return this.mobSpawnCosts.get(type); } diff --git a/src/main/java/net/minecraftforge/common/world/StructureSpawnManager.java b/src/main/java/net/minecraftforge/common/world/StructureSpawnManager.java index c90c0b06a9..33618aa196 100644 --- a/src/main/java/net/minecraftforge/common/world/StructureSpawnManager.java +++ b/src/main/java/net/minecraftforge/common/world/StructureSpawnManager.java @@ -19,19 +19,18 @@ package net.minecraftforge.common.world; -import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import java.util.Collections; import java.util.LinkedHashMap; -import java.util.List; import java.util.Map; import java.util.Map.Entry; import javax.annotation.Nullable; -import net.minecraft.entity.EntityClassification; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.biome.MobSpawnInfo; -import net.minecraft.world.gen.feature.structure.Structure; -import net.minecraft.world.gen.feature.structure.StructureManager; +import net.minecraft.util.random.WeightedRandomList; +import net.minecraft.world.entity.MobCategory; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.biome.MobSpawnSettings; +import net.minecraft.world.level.levelgen.feature.StructureFeature; +import net.minecraft.world.level.StructureFeatureManager; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.world.StructureSpawnListGatherEvent; import net.minecraftforge.registries.ForgeRegistries; @@ -41,7 +40,7 @@ import net.minecraftforge.registries.ForgeRegistries; */ public class StructureSpawnManager { - private static Map, StructureSpawnInfo> structuresWithSpawns = Collections.emptyMap(); + private static Map, StructureSpawnInfo> structuresWithSpawns = Collections.emptyMap(); /** * Gathers potential entity spawns for all the different registered structures. @@ -52,15 +51,15 @@ public class StructureSpawnManager //We use a linked hash map to ensure that we check the structures in an order that if there are multiple structures a position satisfies // then we have the same behavior as vanilla as vanilla checks, swamp huts, pillager outposts, ocean monuments, and nether fortresses in // that order. - Map, StructureSpawnInfo> structuresWithSpawns = new LinkedHashMap<>(); - gatherEntitySpawns(structuresWithSpawns, Structure.SWAMP_HUT); - gatherEntitySpawns(structuresWithSpawns, Structure.PILLAGER_OUTPOST); - gatherEntitySpawns(structuresWithSpawns, Structure.OCEAN_MONUMENT); - gatherEntitySpawns(structuresWithSpawns, Structure.NETHER_BRIDGE); - for (Structure structure : ForgeRegistries.STRUCTURE_FEATURES.getValues()) + Map, StructureSpawnInfo> structuresWithSpawns = new LinkedHashMap<>(); + gatherEntitySpawns(structuresWithSpawns, StructureFeature.SWAMP_HUT); + gatherEntitySpawns(structuresWithSpawns, StructureFeature.PILLAGER_OUTPOST); + gatherEntitySpawns(structuresWithSpawns, StructureFeature.OCEAN_MONUMENT); + gatherEntitySpawns(structuresWithSpawns, StructureFeature.NETHER_BRIDGE); + for (StructureFeature structure : ForgeRegistries.STRUCTURE_FEATURES.getValues()) { - if (structure != Structure.SWAMP_HUT && structure != Structure.PILLAGER_OUTPOST && structure != Structure.OCEAN_MONUMENT && - structure != Structure.NETHER_BRIDGE) + if (structure != StructureFeature.SWAMP_HUT && structure != StructureFeature.PILLAGER_OUTPOST && structure != StructureFeature.OCEAN_MONUMENT && + structure != StructureFeature.NETHER_BRIDGE) { //If we didn't already gather the spawns already to ensure we do vanilla ones already // gather the spawns for this structure @@ -70,16 +69,16 @@ public class StructureSpawnManager StructureSpawnManager.structuresWithSpawns = structuresWithSpawns; } - private static void gatherEntitySpawns(Map, StructureSpawnInfo> structuresWithSpawns, Structure structure) + private static void gatherEntitySpawns(Map, StructureSpawnInfo> structuresWithSpawns, StructureFeature structure) { StructureSpawnListGatherEvent event = new StructureSpawnListGatherEvent(structure); MinecraftForge.EVENT_BUS.post(event); - ImmutableMap.Builder> builder = ImmutableMap.builder(); + ImmutableMap.Builder> builder = ImmutableMap.builder(); event.getEntitySpawns().forEach((classification, spawns) -> { if (!spawns.isEmpty()) - builder.put(classification, ImmutableList.copyOf(spawns)); + builder.put(classification, WeightedRandomList.create()); }); - Map> entitySpawns = builder.build(); + ImmutableMap> entitySpawns = builder.build(); if (!entitySpawns.isEmpty()) structuresWithSpawns.put(structure, new StructureSpawnInfo(entitySpawns, event.isInsideOnly())); } @@ -92,11 +91,11 @@ public class StructureSpawnManager * @param pos Position to get entity spawns of */ @Nullable - public static List getStructureSpawns(StructureManager structureManager, EntityClassification classification, BlockPos pos) + public static WeightedRandomList getStructureSpawns(StructureFeatureManager structureManager, MobCategory classification, BlockPos pos) { - for (Entry, StructureSpawnInfo> entry : structuresWithSpawns.entrySet()) + for (Entry, StructureSpawnInfo> entry : structuresWithSpawns.entrySet()) { - Structure structure = entry.getKey(); + StructureFeature structure = entry.getKey(); StructureSpawnInfo spawnInfo = entry.getValue(); //Note: We check if the structure has spawns for a type first before looking at the world as it should be a cheaper check if (spawnInfo.spawns.containsKey(classification) && structureManager.getStructureAt(pos, spawnInfo.insideOnly, structure).isValid()) @@ -110,11 +109,11 @@ public class StructureSpawnManager * @param structure The Structure * @param classification The classification to lookup */ - public static List getSpawnList(Structure structure, EntityClassification classification) + public static WeightedRandomList getSpawnList(StructureFeature structure, MobCategory classification) { if (structuresWithSpawns.containsKey(structure)) - return structuresWithSpawns.get(structure).spawns.getOrDefault(classification, Collections.emptyList()); - return Collections.emptyList(); + return structuresWithSpawns.get(structure).spawns.getOrDefault(classification, WeightedRandomList.create()); + return WeightedRandomList.create(); } /** @@ -122,10 +121,10 @@ public class StructureSpawnManager */ private static class StructureSpawnInfo { - private final Map> spawns; + private final Map> spawns; private final boolean insideOnly; - private StructureSpawnInfo(Map> spawns, boolean insideOnly) + private StructureSpawnInfo(ImmutableMap> spawns, boolean insideOnly) { this.spawns = spawns; this.insideOnly = insideOnly; diff --git a/src/main/java/net/minecraftforge/energy/CapabilityEnergy.java b/src/main/java/net/minecraftforge/energy/CapabilityEnergy.java index fe8a9196b4..e3408764e0 100644 --- a/src/main/java/net/minecraftforge/energy/CapabilityEnergy.java +++ b/src/main/java/net/minecraftforge/energy/CapabilityEnergy.java @@ -19,11 +19,7 @@ package net.minecraftforge.energy; -import net.minecraft.nbt.INBT; -import net.minecraft.nbt.IntNBT; -import net.minecraft.util.Direction; import net.minecraftforge.common.capabilities.*; -import net.minecraftforge.common.capabilities.Capability.IStorage; public class CapabilityEnergy { @@ -32,22 +28,6 @@ public class CapabilityEnergy public static void register() { - CapabilityManager.INSTANCE.register(IEnergyStorage.class, new IStorage() - { - @Override - public INBT writeNBT(Capability capability, IEnergyStorage instance, Direction side) - { - return IntNBT.valueOf(instance.getEnergyStored()); - } - - @Override - public void readNBT(Capability capability, IEnergyStorage instance, Direction side, INBT nbt) - { - if (!(instance instanceof EnergyStorage)) - throw new IllegalArgumentException("Can not deserialize to an instance that isn't the default implementation"); - ((EnergyStorage)instance).energy = ((IntNBT)nbt).getAsInt(); - } - }, - () -> new EnergyStorage(1000)); + CapabilityManager.INSTANCE.register(IEnergyStorage.class); } } diff --git a/src/main/java/net/minecraftforge/energy/EnergyStorage.java b/src/main/java/net/minecraftforge/energy/EnergyStorage.java index 9df95d3353..cb8901b958 100644 --- a/src/main/java/net/minecraftforge/energy/EnergyStorage.java +++ b/src/main/java/net/minecraftforge/energy/EnergyStorage.java @@ -19,13 +19,17 @@ package net.minecraftforge.energy; +import net.minecraft.nbt.IntTag; +import net.minecraft.nbt.Tag; +import net.minecraftforge.common.util.INBTSerializable; + /** * Reference implementation of {@link IEnergyStorage}. Use/extend this or implement your own. * * Derived from the Redstone Flux power system designed by King Lemming and originally utilized in Thermal Expansion and related mods. * Created with consent and permission of King Lemming and Team CoFH. Released with permission under LGPL 2.1 when bundled with Forge. */ -public class EnergyStorage implements IEnergyStorage +public class EnergyStorage implements IEnergyStorage, INBTSerializable { protected int energy; protected int capacity; @@ -102,4 +106,18 @@ public class EnergyStorage implements IEnergyStorage { return this.maxReceive > 0; } + + @Override + public Tag serializeNBT() + { + return IntTag.valueOf(this.getEnergyStored()); + } + + @Override + public void deserializeNBT(Tag nbt) + { + if (!(nbt instanceof IntTag intNbt)) + throw new IllegalArgumentException("Can not deserialize to an instance that isn't the default implementation"); + this.energy = intNbt.getAsInt(); + } } diff --git a/src/main/java/net/minecraftforge/entity/PartEntity.java b/src/main/java/net/minecraftforge/entity/PartEntity.java index 0490b1624b..863f4b0513 100644 --- a/src/main/java/net/minecraftforge/entity/PartEntity.java +++ b/src/main/java/net/minecraftforge/entity/PartEntity.java @@ -19,8 +19,8 @@ package net.minecraftforge.entity; -import net.minecraft.entity.Entity; -import net.minecraft.network.IPacket; +import net.minecraft.world.entity.Entity; +import net.minecraft.network.protocol.Packet; public abstract class PartEntity extends Entity { private final T parent; @@ -35,7 +35,7 @@ public abstract class PartEntity extends Entity { } @Override - public IPacket getAddEntityPacket() { + public Packet getAddEntityPacket() { throw new UnsupportedOperationException(); } } diff --git a/src/main/java/net/minecraftforge/event/AddReloadListenerEvent.java b/src/main/java/net/minecraftforge/event/AddReloadListenerEvent.java index 79436b0ef1..7825402ad3 100644 --- a/src/main/java/net/minecraftforge/event/AddReloadListenerEvent.java +++ b/src/main/java/net/minecraftforge/event/AddReloadListenerEvent.java @@ -20,11 +20,10 @@ package net.minecraftforge.event; import com.google.common.collect.ImmutableList; -import net.minecraft.profiler.IProfiler; -import net.minecraft.resources.DataPackRegistries; -import net.minecraft.resources.IFutureReloadListener; -import net.minecraft.resources.IResourceManager; -import net.minecraftforge.common.MinecraftForge; +import net.minecraft.util.profiling.ProfilerFiller; +import net.minecraft.server.ServerResources; +import net.minecraft.server.packs.resources.PreparableReloadListener; +import net.minecraft.server.packs.resources.ResourceManager; import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.fml.ModLoader; @@ -33,7 +32,7 @@ import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; -import net.minecraft.resources.IFutureReloadListener.IStage; +import net.minecraft.server.packs.resources.PreparableReloadListener.PreparationBarrier; /** * The main ResourceManager is recreated on each reload, through {@link DataPackRegistries}'s creation. @@ -43,10 +42,10 @@ import net.minecraft.resources.IFutureReloadListener.IStage; */ public class AddReloadListenerEvent extends Event { - private final List listeners = new ArrayList<>(); - private final DataPackRegistries dataPackRegistries; + private final List listeners = new ArrayList<>(); + private final ServerResources dataPackRegistries; - public AddReloadListenerEvent(DataPackRegistries dataPackRegistries) + public AddReloadListenerEvent(ServerResources dataPackRegistries) { this.dataPackRegistries = dataPackRegistries; } @@ -54,29 +53,29 @@ public class AddReloadListenerEvent extends Event /** * @param listener the listener to add to the ResourceManager on reload */ - public void addListener(IFutureReloadListener listener) + public void addListener(PreparableReloadListener listener) { listeners.add(new WrappedStateAwareListener(listener)); } - public List getListeners() + public List getListeners() { return ImmutableList.copyOf(listeners); } - public DataPackRegistries getDataPackRegistries() + public ServerResources getDataPackRegistries() { return dataPackRegistries; } - private static class WrappedStateAwareListener implements IFutureReloadListener { - private final IFutureReloadListener wrapped; + private static class WrappedStateAwareListener implements PreparableReloadListener { + private final PreparableReloadListener wrapped; - private WrappedStateAwareListener(final IFutureReloadListener wrapped) { + private WrappedStateAwareListener(final PreparableReloadListener wrapped) { this.wrapped = wrapped; } @Override - public CompletableFuture reload(final IStage stage, final IResourceManager resourceManager, final IProfiler preparationsProfiler, final IProfiler reloadProfiler, final Executor backgroundExecutor, final Executor gameExecutor) { + public CompletableFuture reload(final PreparationBarrier stage, final ResourceManager resourceManager, final ProfilerFiller preparationsProfiler, final ProfilerFiller reloadProfiler, final Executor backgroundExecutor, final Executor gameExecutor) { if (ModLoader.isLoadingStateValid()) return wrapped.reload(stage, resourceManager, preparationsProfiler, reloadProfiler, backgroundExecutor, gameExecutor); else diff --git a/src/main/java/net/minecraftforge/event/AnvilUpdateEvent.java b/src/main/java/net/minecraftforge/event/AnvilUpdateEvent.java index 25d26770a6..09a3129d27 100644 --- a/src/main/java/net/minecraftforge/event/AnvilUpdateEvent.java +++ b/src/main/java/net/minecraftforge/event/AnvilUpdateEvent.java @@ -19,9 +19,8 @@ package net.minecraftforge.event; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.inventory.container.RepairContainer; -import net.minecraft.item.ItemStack; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; import net.minecraftforge.eventbus.api.Cancelable; import net.minecraftforge.eventbus.api.Event; @@ -45,16 +44,9 @@ public class AnvilUpdateEvent extends Event private ItemStack output; private int cost; private int materialCost; - @Nullable // TODO: Remove 1.17 - Nullable only in the instance that a mod uses the deprecated ctor. - private final PlayerEntity player; + private final Player player; - @Deprecated //TODO: Remove 1.17 - Use Player-contextual constructor below. - public AnvilUpdateEvent(ItemStack left, ItemStack right, String name, int cost) - { - this(left, right, name, cost, null); - } - - public AnvilUpdateEvent(ItemStack left, ItemStack right, String name, int cost, PlayerEntity player) + public AnvilUpdateEvent(ItemStack left, ItemStack right, String name, int cost, Player player) { this.left = left; this.right = right; @@ -157,11 +149,9 @@ public class AnvilUpdateEvent extends Event } /** - * Nullable in the case someone is using the deprecated constructor. * @return The player using this anvil container. */ - @Nullable // TODO: Remove 1.17 - public PlayerEntity getPlayer() + public Player getPlayer() { return this.player; } diff --git a/src/main/java/net/minecraftforge/event/AttachCapabilitiesEvent.java b/src/main/java/net/minecraftforge/event/AttachCapabilitiesEvent.java index 76d35c378f..6b3d37b9c0 100644 --- a/src/main/java/net/minecraftforge/event/AttachCapabilitiesEvent.java +++ b/src/main/java/net/minecraftforge/event/AttachCapabilitiesEvent.java @@ -24,7 +24,7 @@ import java.util.List; import java.util.Map; import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.eventbus.api.GenericEvent; diff --git a/src/main/java/net/minecraftforge/event/CommandEvent.java b/src/main/java/net/minecraftforge/event/CommandEvent.java index 8f44ae0351..c117b972b3 100644 --- a/src/main/java/net/minecraftforge/event/CommandEvent.java +++ b/src/main/java/net/minecraftforge/event/CommandEvent.java @@ -20,9 +20,7 @@ package net.minecraftforge.event; import com.mojang.brigadier.ParseResults; -import net.minecraft.command.CommandSource; -import net.minecraft.command.Commands; -import net.minecraftforge.common.MinecraftForge; +import net.minecraft.commands.CommandSourceStack; import net.minecraftforge.eventbus.api.Cancelable; import net.minecraftforge.eventbus.api.Event; @@ -43,16 +41,16 @@ import net.minecraftforge.eventbus.api.Event; @Cancelable public class CommandEvent extends Event { - private ParseResults parse; + private ParseResults parse; private Throwable exception; - public CommandEvent(ParseResults parse) + public CommandEvent(ParseResults parse) { this.parse = parse; } - public ParseResults getParseResults() { return parse; } - public void setParseResults(ParseResults parse) { this.parse = parse; } + public ParseResults getParseResults() { return parse; } + public void setParseResults(ParseResults parse) { this.parse = parse; } public Throwable getException() { return exception; } public void setException(Throwable exception) { this.exception = exception; } } diff --git a/src/main/java/net/minecraftforge/event/DifficultyChangeEvent.java b/src/main/java/net/minecraftforge/event/DifficultyChangeEvent.java index 12c41e89c3..2eb084cb82 100644 --- a/src/main/java/net/minecraftforge/event/DifficultyChangeEvent.java +++ b/src/main/java/net/minecraftforge/event/DifficultyChangeEvent.java @@ -20,10 +20,7 @@ package net.minecraftforge.event; import net.minecraft.world.Difficulty; -import net.minecraftforge.common.ForgeHooks; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.Event; -import net.minecraftforge.eventbus.api.Event.HasResult; /** * DifficultyChangeEvent is fired when difficulty is changing.
diff --git a/src/main/java/net/minecraftforge/event/ForgeEventFactory.java b/src/main/java/net/minecraftforge/event/ForgeEventFactory.java index a06092d22d..cb4778fab7 100644 --- a/src/main/java/net/minecraftforge/event/ForgeEventFactory.java +++ b/src/main/java/net/minecraftforge/event/ForgeEventFactory.java @@ -26,67 +26,64 @@ import java.util.function.Consumer; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.brigadier.CommandDispatcher; -import net.minecraft.block.PortalSize; -import net.minecraft.block.BlockState; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.command.CommandSource; -import net.minecraft.command.Commands; -import net.minecraft.entity.Entity; -import net.minecraft.entity.Pose; -import net.minecraft.entity.EntitySize; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.MobEntity; -import net.minecraft.entity.SpawnReason; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.EntityClassification; -import net.minecraft.entity.effect.LightningBoltEntity; -import net.minecraft.entity.item.EnderPearlEntity; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.monster.ZombieEntity; -import net.minecraft.entity.passive.AnimalEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerEntity.SleepResult; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.entity.projectile.AbstractArrowEntity; -import net.minecraft.entity.projectile.DamagingProjectileEntity; -import net.minecraft.entity.projectile.FireworkRocketEntity; -import net.minecraft.entity.projectile.FishingBobberEntity; -import net.minecraft.entity.projectile.ThrowableEntity; -import net.minecraft.block.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.item.crafting.IRecipeType; -import net.minecraft.loot.LootTable; -import net.minecraft.loot.LootTableManager; -import net.minecraft.resources.IFutureReloadListener; -import net.minecraft.resources.DataPackRegistries; -import net.minecraft.world.spawner.AbstractSpawner; -import net.minecraft.util.ActionResult; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Hand; -import net.minecraft.util.NonNullList; -import net.minecraft.util.RegistryKey; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvent; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.ChunkPos; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.text.ChatType; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.world.Explosion; -import net.minecraft.world.GameRules; -import net.minecraft.world.IWorld; -import net.minecraft.world.IWorldReader; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; -import net.minecraft.world.biome.MobSpawnInfo; -import net.minecraft.world.storage.IServerWorldInfo; -import net.minecraft.world.storage.PlayerData; +import net.minecraft.world.entity.projectile.FireworkRocketEntity; +import net.minecraft.world.entity.projectile.Projectile; +import net.minecraft.world.entity.projectile.ThrownEnderpearl; +import net.minecraft.world.level.portal.PortalShape; +import net.minecraft.world.level.block.state.BlockState; +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.Pose; +import net.minecraft.world.entity.EntityDimensions; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.Mob; +import net.minecraft.world.entity.MobSpawnType; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.MobCategory; +import net.minecraft.world.entity.LightningBolt; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.monster.Zombie; +import net.minecraft.world.entity.animal.Animal; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.player.Player.BedSleepingProblem; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.level.storage.loot.LootTable; +import net.minecraft.world.level.storage.loot.LootTables; +import net.minecraft.server.packs.resources.PreparableReloadListener; +import net.minecraft.server.ServerResources; +import net.minecraft.world.level.BaseSpawner; +import net.minecraft.world.InteractionResultHolder; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.NonNullList; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.phys.HitResult; +import net.minecraft.network.chat.ChatType; +import net.minecraft.network.chat.Component; +import net.minecraft.world.level.Explosion; +import net.minecraft.world.level.GameRules; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.Level; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.biome.MobSpawnSettings; +import net.minecraft.world.level.storage.ServerLevelData; +import net.minecraft.world.level.storage.PlayerDataStorage; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.event.ClientChatEvent; @@ -104,11 +101,11 @@ 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.PlaySoundAtEntityEvent; import net.minecraftforge.event.entity.ProjectileImpactEvent; import net.minecraftforge.event.entity.item.ItemExpireEvent; import net.minecraftforge.event.entity.living.AnimalTameEvent; -import net.minecraftforge.event.entity.living.EnderTeleportEvent; import net.minecraftforge.event.entity.living.LivingConversionEvent; import net.minecraftforge.event.entity.living.LivingDestroyBlockEvent; import net.minecraftforge.event.entity.living.LivingEntityUseItemEvent; @@ -117,7 +114,6 @@ import net.minecraftforge.event.entity.living.LivingHealEvent; import net.minecraftforge.event.entity.living.LivingPackSizeEvent; import net.minecraftforge.event.entity.living.LivingSpawnEvent; import net.minecraftforge.event.entity.living.LivingSpawnEvent.AllowDespawn; -import net.minecraftforge.event.entity.living.EntityTeleportEvent; import net.minecraftforge.event.entity.living.ZombieEvent.SummonAidEvent; import net.minecraftforge.event.entity.player.ArrowLooseEvent; import net.minecraftforge.event.entity.player.ArrowNockEvent; @@ -168,32 +164,32 @@ public class ForgeEventFactory return MinecraftForge.EVENT_BUS.post(event); } - public static NeighborNotifyEvent onNeighborNotify(World world, BlockPos pos, BlockState state, EnumSet notifiedSides, boolean forceRedstoneUpdate) + public static NeighborNotifyEvent onNeighborNotify(Level world, BlockPos pos, BlockState state, EnumSet notifiedSides, boolean forceRedstoneUpdate) { NeighborNotifyEvent event = new NeighborNotifyEvent(world, pos, state, notifiedSides, forceRedstoneUpdate); MinecraftForge.EVENT_BUS.post(event); return event; } - public static boolean doPlayerHarvestCheck(PlayerEntity player, BlockState state, boolean success) + 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 float getBreakSpeed(PlayerEntity player, BlockState state, float original, BlockPos pos) + 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 void onPlayerDestroyItem(PlayerEntity player, @Nonnull ItemStack stack, @Nullable Hand hand) + public static void onPlayerDestroyItem(Player player, @Nonnull ItemStack stack, @Nullable InteractionHand hand) { MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(player, stack, hand)); } - public static Result canEntitySpawn(MobEntity entity, IWorld world, double x, double y, double z, AbstractSpawner spawner, SpawnReason spawnReason) + public static Result canEntitySpawn(Mob entity, LevelAccessor world, double x, double y, double z, BaseSpawner spawner, MobSpawnType spawnReason) { if (entity == null) return Result.DEFAULT; @@ -202,41 +198,35 @@ public class ForgeEventFactory return event.getResult(); } - public static boolean canEntitySpawnSpawner(MobEntity entity, World world, float x, float y, float z, AbstractSpawner spawner) + public static boolean canEntitySpawnSpawner(Mob entity, Level world, float x, float y, float z, BaseSpawner spawner) { - Result result = canEntitySpawn(entity, world, x, y, z, spawner, SpawnReason.SPAWNER); + Result result = canEntitySpawn(entity, world, x, y, z, spawner, MobSpawnType.SPAWNER); if (result == Result.DEFAULT) - return entity.checkSpawnRules(world, SpawnReason.SPAWNER) && entity.checkSpawnObstruction(world); // vanilla logic (inverted) + return entity.checkSpawnRules(world, MobSpawnType.SPAWNER) && entity.checkSpawnObstruction(world); // vanilla logic (inverted) else return result == Result.ALLOW; } - public static boolean doSpecialSpawn(MobEntity entity, World world, float x, float y, float z, AbstractSpawner spawner, SpawnReason spawnReason) + public static boolean doSpecialSpawn(Mob entity, Level world, float x, float y, float z, BaseSpawner spawner, MobSpawnType spawnReason) { return MinecraftForge.EVENT_BUS.post(new LivingSpawnEvent.SpecialSpawn(entity, world, x, y, z, spawner, spawnReason)); } - public static Result canEntityDespawn(MobEntity entity) + public static Result canEntityDespawn(Mob entity) { AllowDespawn event = new AllowDespawn(entity); MinecraftForge.EVENT_BUS.post(event); return event.getResult(); } - @Deprecated // use version with IRecipeType - public static int getItemBurnTime(@Nonnull ItemStack itemStack, int burnTime) - { - return getItemBurnTime(itemStack, burnTime, null); - } - - public static int getItemBurnTime(@Nonnull ItemStack itemStack, int burnTime, @Nullable IRecipeType recipeType) + public static int getItemBurnTime(@Nonnull 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 getExperienceDrop(LivingEntity entity, PlayerEntity attackingPlayer, int originalExperience) + public static int getExperienceDrop(LivingEntity entity, Player attackingPlayer, int originalExperience) { LivingExperienceDropEvent event = new LivingExperienceDropEvent(entity, attackingPlayer, originalExperience); if (MinecraftForge.EVENT_BUS.post(event)) @@ -246,58 +236,49 @@ public class ForgeEventFactory return event.getDroppedExperience(); } - @Nullable - public static List getPotentialSpawns(IWorld world, EntityClassification type, BlockPos pos, List oldList) - { - WorldEvent.PotentialSpawns event = new WorldEvent.PotentialSpawns(world, type, pos, oldList); - if (MinecraftForge.EVENT_BUS.post(event)) - return Collections.emptyList(); - return event.getList(); - } - - public static int getMaxSpawnPackSize(MobEntity entity) + public static int getMaxSpawnPackSize(Mob entity) { LivingPackSizeEvent maxCanSpawnEvent = new LivingPackSizeEvent(entity); MinecraftForge.EVENT_BUS.post(maxCanSpawnEvent); return maxCanSpawnEvent.getResult() == Result.ALLOW ? maxCanSpawnEvent.getMaxPackSize() : entity.getMaxSpawnClusterSize(); } - public static ITextComponent getPlayerDisplayName(PlayerEntity player, ITextComponent username) + 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 ITextComponent getPlayerTabListDisplayName(PlayerEntity player) + public static Component getPlayerTabListDisplayName(Player player) { PlayerEvent.TabListNameFormat event = new PlayerEvent.TabListNameFormat(player); MinecraftForge.EVENT_BUS.post(event); return event.getDisplayName(); } - public static BlockState fireFluidPlaceBlockEvent(IWorld world, BlockPos pos, BlockPos liquidPos, BlockState state) + public static BlockState fireFluidPlaceBlockEvent(LevelAccessor world, BlockPos pos, BlockPos liquidPos, BlockState state) { BlockEvent.FluidPlaceBlockEvent event = new BlockEvent.FluidPlaceBlockEvent(world, pos, liquidPos, state); MinecraftForge.EVENT_BUS.post(event); return event.getNewState(); } - public static ItemTooltipEvent onItemTooltip(ItemStack itemStack, @Nullable PlayerEntity entityPlayer, List list, ITooltipFlag flags) + 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 SummonAidEvent fireZombieSummonAid(ZombieEntity zombie, World world, int x, int y, int z, LivingEntity attacker, double summonChance) + public static SummonAidEvent fireZombieSummonAid(Zombie zombie, Level world, int x, int y, int z, LivingEntity attacker, double summonChance) { SummonAidEvent summonEvent = new SummonAidEvent(zombie, world, x, y, z, attacker, summonChance); MinecraftForge.EVENT_BUS.post(summonEvent); return summonEvent; } - public static boolean onEntityStruckByLightning(Entity entity, LightningBoltEntity bolt) + public static boolean onEntityStruckByLightning(Entity entity, LightningBolt bolt) { return MinecraftForge.EVENT_BUS.post(new EntityStruckByLightningEvent(entity, bolt)); } @@ -326,33 +307,33 @@ public class ForgeEventFactory return event.getResultStack(); } - public static void onStartEntityTracking(Entity entity, PlayerEntity player) + public static void onStartEntityTracking(Entity entity, Player player) { MinecraftForge.EVENT_BUS.post(new PlayerEvent.StartTracking(player, entity)); } - public static void onStopEntityTracking(Entity entity, PlayerEntity player) + public static void onStopEntityTracking(Entity entity, Player player) { MinecraftForge.EVENT_BUS.post(new PlayerEvent.StopTracking(player, entity)); } - public static void firePlayerLoadingEvent(PlayerEntity player, File playerDirectory, String uuidString) + public static void firePlayerLoadingEvent(Player player, File playerDirectory, String uuidString) { MinecraftForge.EVENT_BUS.post(new PlayerEvent.LoadFromFile(player, playerDirectory, uuidString)); } - public static void firePlayerSavingEvent(PlayerEntity player, File playerDirectory, String uuidString) + public static void firePlayerSavingEvent(Player player, File playerDirectory, String uuidString) { MinecraftForge.EVENT_BUS.post(new PlayerEvent.SaveToFile(player, playerDirectory, uuidString)); } - public static void firePlayerLoadingEvent(PlayerEntity player, PlayerData playerFileData, String uuidString) + public static void firePlayerLoadingEvent(Player player, PlayerDataStorage playerFileData, String uuidString) { MinecraftForge.EVENT_BUS.post(new PlayerEvent.LoadFromFile(player, playerFileData.getPlayerDataFolder(), uuidString)); } @Nullable - public static ITextComponent onClientChat(ChatType type, ITextComponent message, @Nullable UUID senderUUID) + public static Component onClientChat(ChatType type, Component message, @Nullable UUID senderUUID) { ClientChatReceivedEvent event = new ClientChatReceivedEvent(type, message, senderUUID); return MinecraftForge.EVENT_BUS.post(event) ? null : event.getMessage(); @@ -367,7 +348,7 @@ public class ForgeEventFactory //TODO: 1.17 Remove @Deprecated - public static int onHoeUse(ItemUseContext context) + public static int onHoeUse(UseOnContext context) { UseHoeEvent event = new UseHoeEvent(context); if (MinecraftForge.EVENT_BUS.post(event)) return -1; @@ -380,13 +361,13 @@ public class ForgeEventFactory } @Nullable - public static BlockState onToolUse(BlockState originalState, World world, BlockPos pos, PlayerEntity player, ItemStack stack, ToolType toolType) + public static BlockState onToolUse(BlockState originalState, Level world, BlockPos pos, Player player, ItemStack stack, ToolType toolType) { BlockToolInteractEvent event = new BlockToolInteractEvent(world, pos, originalState, player, stack, toolType); return MinecraftForge.EVENT_BUS.post(event) ? null : event.getFinalState(); } - public static int onApplyBonemeal(@Nonnull PlayerEntity player, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull ItemStack stack) + public static int onApplyBonemeal(@Nonnull Player player, @Nonnull Level world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull ItemStack stack) { BonemealEvent event = new BonemealEvent(player, world, pos, state, stack); if (MinecraftForge.EVENT_BUS.post(event)) return -1; @@ -400,24 +381,24 @@ public class ForgeEventFactory } @Nullable - public static ActionResult onBucketUse(@Nonnull PlayerEntity player, @Nonnull World world, @Nonnull ItemStack stack, @Nullable RayTraceResult target) + public static InteractionResultHolder onBucketUse(@Nonnull Player player, @Nonnull Level world, @Nonnull ItemStack stack, @Nullable HitResult target) { FillBucketEvent event = new FillBucketEvent(player, stack, world, target); - if (MinecraftForge.EVENT_BUS.post(event)) return new ActionResult(ActionResultType.FAIL, stack); + if (MinecraftForge.EVENT_BUS.post(event)) return new InteractionResultHolder(InteractionResult.FAIL, stack); if (event.getResult() == Result.ALLOW) { - if (player.abilities.instabuild) - return new ActionResult(ActionResultType.SUCCESS, stack); + if (player.getAbilities().instabuild) + return new InteractionResultHolder(InteractionResult.SUCCESS, stack); stack.shrink(1); if (stack.isEmpty()) - return new ActionResult(ActionResultType.SUCCESS, event.getFilledBucket()); + return new InteractionResultHolder(InteractionResult.SUCCESS, event.getFilledBucket()); - if (!player.inventory.add(event.getFilledBucket())) + if (!player.getInventory().add(event.getFilledBucket())) player.drop(event.getFilledBucket(), false); - return new ActionResult(ActionResultType.SUCCESS, stack); + return new InteractionResultHolder(InteractionResult.SUCCESS, stack); } return null; } @@ -429,7 +410,7 @@ public class ForgeEventFactory return event.getCanUpdate(); } - public static PlaySoundAtEntityEvent onPlaySoundAtEntity(Entity entity, SoundEvent name, SoundCategory category, float volume, float pitch) + public static PlaySoundAtEntityEvent onPlaySoundAtEntity(Entity entity, SoundEvent name, SoundSource category, float volume, float pitch) { PlaySoundAtEntityEvent event = new PlaySoundAtEntityEvent(entity, name, category, volume, pitch); MinecraftForge.EVENT_BUS.post(event); @@ -444,7 +425,7 @@ public class ForgeEventFactory return event.getExtraLife(); } - public static int onItemPickup(ItemEntity entityItem, PlayerEntity player) + public static int onItemPickup(ItemEntity entityItem, Player player) { Event event = new EntityItemPickupEvent(player, entityItem); if (MinecraftForge.EVENT_BUS.post(event)) return -1; @@ -464,44 +445,44 @@ public class ForgeEventFactory return true; } - public static boolean onAnimalTame(AnimalEntity animal, PlayerEntity tamer) + public static boolean onAnimalTame(Animal animal, Player tamer) { return MinecraftForge.EVENT_BUS.post(new AnimalTameEvent(animal, tamer)); } - public static SleepResult onPlayerSleepInBed(PlayerEntity player, Optional pos) + public static BedSleepingProblem onPlayerSleepInBed(Player player, Optional pos) { PlayerSleepInBedEvent event = new PlayerSleepInBedEvent(player, pos); MinecraftForge.EVENT_BUS.post(event); return event.getResultStatus(); } - public static void onPlayerWakeup(PlayerEntity player, boolean wakeImmediately, boolean updateWorldFlag) + public static void onPlayerWakeup(Player player, boolean wakeImmediately, boolean updateWorldFlag) { MinecraftForge.EVENT_BUS.post(new PlayerWakeUpEvent(player, wakeImmediately, updateWorldFlag)); } - public static void onPlayerFall(PlayerEntity player, float distance, float multiplier) + public static void onPlayerFall(Player player, float distance, float multiplier) { MinecraftForge.EVENT_BUS.post(new PlayerFlyableFallEvent(player, distance, multiplier)); } - public static boolean onPlayerSpawnSet(PlayerEntity player, RegistryKey world, BlockPos pos, boolean forced) + public static boolean onPlayerSpawnSet(Player player, ResourceKey world, BlockPos pos, boolean forced) { return MinecraftForge.EVENT_BUS.post(new PlayerSetSpawnEvent(player, world, pos, forced)); } - public static void onPlayerClone(PlayerEntity player, PlayerEntity oldPlayer, boolean wasDeath) + 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 boolean onExplosionStart(World world, Explosion explosion) + public static boolean onExplosionStart(Level world, Explosion explosion) { return MinecraftForge.EVENT_BUS.post(new ExplosionEvent.Start(world, explosion)); } - public static void onExplosionDetonate(World world, Explosion explosion, List list, double diameter) + public static void onExplosionDetonate(Level world, 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. @@ -517,7 +498,7 @@ public class ForgeEventFactory MinecraftForge.EVENT_BUS.post(new ExplosionEvent.Detonate(world, explosion, list)); } - public static boolean onCreateWorldSpawn(World world, IServerWorldInfo settings) + public static boolean onCreateWorldSpawn(Level world, ServerLevelData settings) { return MinecraftForge.EVENT_BUS.post(new WorldEvent.CreateSpawnPosition(world, settings)); } @@ -555,25 +536,25 @@ public class ForgeEventFactory MinecraftForge.EVENT_BUS.post(new PotionBrewEvent.Post(brewingItemStacks)); } - public static void onPlayerBrewedPotion(PlayerEntity player, ItemStack stack) + public static void onPlayerBrewedPotion(Player player, ItemStack stack) { MinecraftForge.EVENT_BUS.post(new PlayerBrewedPotionEvent(player, stack)); } @OnlyIn(Dist.CLIENT) - public static boolean renderFireOverlay(PlayerEntity player, MatrixStack mat) + public static boolean renderFireOverlay(Player player, PoseStack mat) { return renderBlockOverlay(player, mat, OverlayType.FIRE, Blocks.FIRE.defaultBlockState(), player.blockPosition()); } @OnlyIn(Dist.CLIENT) - public static boolean renderWaterOverlay(PlayerEntity player, MatrixStack mat) + public static boolean renderWaterOverlay(Player player, PoseStack mat) { return renderBlockOverlay(player, mat, OverlayType.WATER, Blocks.WATER.defaultBlockState(), player.blockPosition()); } @OnlyIn(Dist.CLIENT) - public static boolean renderBlockOverlay(PlayerEntity player, MatrixStack mat, OverlayType type, BlockState block, BlockPos pos) + public static boolean renderBlockOverlay(Player player, PoseStack mat, OverlayType type, BlockState block, BlockPos pos) { return MinecraftForge.EVENT_BUS.post(new RenderBlockOverlayEvent(player, mat, type, block, pos)); } @@ -615,7 +596,7 @@ public class ForgeEventFactory return canContinueSleep == Result.ALLOW; } - public static boolean fireSleepingTimeCheck(PlayerEntity player, Optional sleepingLocation) + public static boolean fireSleepingTimeCheck(Player player, Optional sleepingLocation) { SleepingTimeCheckEvent evt = new SleepingTimeCheckEvent(player, sleepingLocation); MinecraftForge.EVENT_BUS.post(evt); @@ -627,15 +608,15 @@ public class ForgeEventFactory return canContinueSleep == Result.ALLOW; } - public static ActionResult onArrowNock(ItemStack item, World world, PlayerEntity player, Hand hand, boolean hasAmmo) + public static InteractionResultHolder onArrowNock(ItemStack item, Level world, Player player, InteractionHand hand, boolean hasAmmo) { ArrowNockEvent event = new ArrowNockEvent(player, item, hand, world, hasAmmo); if (MinecraftForge.EVENT_BUS.post(event)) - return new ActionResult(ActionResultType.FAIL, item); + return new InteractionResultHolder(InteractionResult.FAIL, item); return event.getAction(); } - public static int onArrowLoose(ItemStack stack, World world, PlayerEntity player, int charge, boolean hasAmmo) + public static int onArrowLoose(ItemStack stack, Level world, Player player, int charge, boolean hasAmmo) { ArrowLooseEvent event = new ArrowLooseEvent(player, stack, world, charge, hasAmmo); if (MinecraftForge.EVENT_BUS.post(event)) @@ -643,37 +624,12 @@ public class ForgeEventFactory return event.getCharge(); } - public static boolean onProjectileImpact(Entity entity, RayTraceResult ray) + public static boolean onProjectileImpact(T projectile, HitResult ray) { - return MinecraftForge.EVENT_BUS.post(new ProjectileImpactEvent(entity, ray)); + return MinecraftForge.EVENT_BUS.post(new ProjectileImpactEvent<>(projectile, ray)); } - public static boolean onProjectileImpact(AbstractArrowEntity arrow, RayTraceResult ray) - { - return MinecraftForge.EVENT_BUS.post(new ProjectileImpactEvent.Arrow(arrow, ray)); - } - - public static boolean onProjectileImpact(DamagingProjectileEntity fireball, RayTraceResult ray) - { - return MinecraftForge.EVENT_BUS.post(new ProjectileImpactEvent.Fireball(fireball, ray)); - } - - public static boolean onProjectileImpact(ThrowableEntity throwable, RayTraceResult ray) - { - return MinecraftForge.EVENT_BUS.post(new ProjectileImpactEvent.Throwable(throwable, ray)); - } - - public static boolean onProjectileImpact(FireworkRocketEntity fireworkRocket, RayTraceResult ray) - { - return MinecraftForge.EVENT_BUS.post(new ProjectileImpactEvent.FireworkRocket(fireworkRocket, ray)); - } - - public static boolean onProjectileImpact(FishingBobberEntity fishingBobber, RayTraceResult ray) - { - return MinecraftForge.EVENT_BUS.post(new ProjectileImpactEvent.FishingBobber(fishingBobber, ray)); - } - - public static LootTable loadLootTable(ResourceLocation name, LootTable table, LootTableManager lootTableManager) + public static LootTable loadLootTable(ResourceLocation name, LootTable table, LootTables lootTableManager) { LootTableLoadEvent event = new LootTableLoadEvent(name, table, lootTableManager); if (MinecraftForge.EVENT_BUS.post(event)) @@ -681,7 +637,7 @@ public class ForgeEventFactory return event.getTable(); } - public static boolean canCreateFluidSource(IWorldReader world, BlockPos pos, BlockState state, boolean def) + public static boolean canCreateFluidSource(LevelReader world, BlockPos pos, BlockState state, boolean def) { CreateFluidSourceEvent evt = new CreateFluidSourceEvent(world, pos, state); MinecraftForge.EVENT_BUS.post(evt); @@ -690,13 +646,13 @@ public class ForgeEventFactory return result == Result.DEFAULT ? def : result == Result.ALLOW; } - public static Optional onTrySpawnPortal(IWorld world, BlockPos pos, Optional size) + public static Optional onTrySpawnPortal(LevelAccessor world, BlockPos pos, Optional size) { if (!size.isPresent()) return size; return !MinecraftForge.EVENT_BUS.post(new BlockEvent.PortalSpawnEvent(world, pos, world.getBlockState(pos), size.get())) ? size : Optional.empty(); } - public static int onEnchantmentLevelSet(World world, BlockPos pos, int enchantRow, int power, ItemStack itemStack, int level) + public static int onEnchantmentLevelSet(Level world, BlockPos pos, int enchantRow, int power, ItemStack itemStack, int level) { net.minecraftforge.event.enchanting.EnchantmentLevelSetEvent e = new net.minecraftforge.event.enchanting.EnchantmentLevelSetEvent(world, pos, enchantRow, power, itemStack, level); net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(e); @@ -708,7 +664,7 @@ public class ForgeEventFactory return !MinecraftForge.EVENT_BUS.post(new LivingDestroyBlockEvent(entity, pos, state)); } - public static boolean getMobGriefingEvent(World world, Entity entity) + public static boolean getMobGriefingEvent(Level world, Entity entity) { EntityMobGriefingEvent event = new EntityMobGriefingEvent(entity); MinecraftForge.EVENT_BUS.post(event); @@ -717,14 +673,14 @@ public class ForgeEventFactory return result == Result.DEFAULT ? world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) : result == Result.ALLOW; } - public static boolean saplingGrowTree(IWorld world, Random rand, BlockPos pos) + public static boolean saplingGrowTree(LevelAccessor world, Random rand, BlockPos pos) { SaplingGrowTreeEvent event = new SaplingGrowTreeEvent(world, rand, pos); MinecraftForge.EVENT_BUS.post(event); return event.getResult() != Result.DENY; } - public static void fireChunkWatch(boolean watch, ServerPlayerEntity entity, ChunkPos chunkpos, ServerWorld world) + public static void fireChunkWatch(boolean watch, ServerPlayer entity, ChunkPos chunkpos, ServerLevel world) { if (watch) MinecraftForge.EVENT_BUS.post(new ChunkWatchEvent.Watch(entity, chunkpos, world)); @@ -732,50 +688,50 @@ public class ForgeEventFactory MinecraftForge.EVENT_BUS.post(new ChunkWatchEvent.UnWatch(entity, chunkpos, world)); } - public static void fireChunkWatch(boolean wasLoaded, boolean load, ServerPlayerEntity entity, ChunkPos chunkpos, ServerWorld world) + public static void fireChunkWatch(boolean wasLoaded, boolean load, ServerPlayer entity, ChunkPos chunkpos, ServerLevel world) { if (wasLoaded != load) fireChunkWatch(load, entity, chunkpos, world); } - public static boolean onPistonMovePre(World world, BlockPos pos, Direction direction, boolean extending) + public static boolean onPistonMovePre(Level world, BlockPos pos, Direction direction, boolean extending) { return MinecraftForge.EVENT_BUS.post(new PistonEvent.Pre(world, pos, direction, extending ? PistonEvent.PistonMoveType.EXTEND : PistonEvent.PistonMoveType.RETRACT)); } - public static boolean onPistonMovePost(World world, BlockPos pos, Direction direction, boolean extending) + public static boolean onPistonMovePost(Level world, BlockPos pos, Direction direction, boolean extending) { return MinecraftForge.EVENT_BUS.post(new PistonEvent.Post(world, pos, direction, extending ? PistonEvent.PistonMoveType.EXTEND : PistonEvent.PistonMoveType.RETRACT)); } - public static long onSleepFinished(ServerWorld world, long newTime, long minTime) + public static long onSleepFinished(ServerLevel world, long newTime, long minTime) { SleepFinishedTimeEvent event = new SleepFinishedTimeEvent(world, newTime, minTime); MinecraftForge.EVENT_BUS.post(event); return event.getNewTime(); } - public static List onResourceReload(DataPackRegistries dataPackRegistries) + public static List onResourceReload(ServerResources dataPackRegistries) { AddReloadListenerEvent event = new AddReloadListenerEvent(dataPackRegistries); MinecraftForge.EVENT_BUS.post(event); return event.getListeners(); } - public static void onCommandRegister(CommandDispatcher dispatcher, Commands.EnvironmentType environment) + public static void onCommandRegister(CommandDispatcher dispatcher, Commands.CommandSelection environment) { RegisterCommandsEvent event = new RegisterCommandsEvent(dispatcher, environment); MinecraftForge.EVENT_BUS.post(event); } - public static net.minecraftforge.event.entity.EntityEvent.Size getEntitySizeForge(Entity entity, Pose pose, EntitySize size, float eyeHeight) + public static net.minecraftforge.event.entity.EntityEvent.Size getEntitySizeForge(Entity entity, Pose pose, EntityDimensions size, float eyeHeight) { EntityEvent.Size evt = new EntityEvent.Size(entity, pose, size, eyeHeight); MinecraftForge.EVENT_BUS.post(evt); return evt; } - public static net.minecraftforge.event.entity.EntityEvent.Size getEntitySizeForge(Entity entity, Pose pose, EntitySize oldSize, EntitySize newSize, float newEyeHeight) + public static net.minecraftforge.event.entity.EntityEvent.Size getEntitySizeForge(Entity entity, Pose pose, EntityDimensions oldSize, EntityDimensions newSize, float newEyeHeight) { EntityEvent.Size evt = new EntityEvent.Size(entity, pose, oldSize, newSize, entity.getEyeHeight(), newEyeHeight); MinecraftForge.EVENT_BUS.post(evt); @@ -809,31 +765,17 @@ public class ForgeEventFactory public static EntityTeleportEvent.EnderEntity onEnderTeleport(LivingEntity entity, double targetX, double targetY, double targetZ) { EntityTeleportEvent.EnderEntity event = new EntityTeleportEvent.EnderEntity(entity, targetX, targetY, targetZ); - onOldEnderTeleport(entity, 0, event); //TODO Forge: Remove this line in 1.17 MinecraftForge.EVENT_BUS.post(event); return event; } - public static EntityTeleportEvent.EnderPearl onEnderPearlLand(ServerPlayerEntity entity, double targetX, double targetY, double targetZ, EnderPearlEntity pearlEntity, float attackDamage) + public static EntityTeleportEvent.EnderPearl onEnderPearlLand(ServerPlayer entity, double targetX, double targetY, double targetZ, ThrownEnderpearl pearlEntity, float attackDamage) { EntityTeleportEvent.EnderPearl event = new EntityTeleportEvent.EnderPearl(entity, targetX, targetY, targetZ, pearlEntity, attackDamage); - event.setAttackDamage(onOldEnderTeleport(entity, attackDamage, event)); //TODO Forge: Remove this line in 1.17 MinecraftForge.EVENT_BUS.post(event); return event; } - @SuppressWarnings("deprecation") //TODO Forge: Scrap this method/event in 1.17 - it only exists for backwards-compatibility - private static float onOldEnderTeleport(LivingEntity entity, float attackDamage, EntityTeleportEvent event) - { - EnderTeleportEvent enderEvent = new EnderTeleportEvent(entity, event.getTargetX(), event.getTargetY(), event.getTargetZ(), attackDamage); - MinecraftForge.EVENT_BUS.post(enderEvent); - event.setCanceled(enderEvent.isCanceled()); - event.setTargetX(enderEvent.getTargetX()); - event.setTargetY(enderEvent.getTargetY()); - event.setTargetZ(enderEvent.getTargetZ()); - return enderEvent.getAttackDamage(); - } - public static EntityTeleportEvent.ChorusFruit onChorusFruitTeleport(LivingEntity entity, double targetX, double targetY, double targetZ) { EntityTeleportEvent.ChorusFruit event = new EntityTeleportEvent.ChorusFruit(entity, targetX, targetY, targetZ); diff --git a/src/main/java/net/minecraftforge/event/ItemAttributeModifierEvent.java b/src/main/java/net/minecraftforge/event/ItemAttributeModifierEvent.java index 417cae94c3..0ae27c4dd7 100644 --- a/src/main/java/net/minecraftforge/event/ItemAttributeModifierEvent.java +++ b/src/main/java/net/minecraftforge/event/ItemAttributeModifierEvent.java @@ -22,10 +22,10 @@ package net.minecraftforge.event; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimaps; import net.minecraftforge.eventbus.api.Event; -import net.minecraft.entity.ai.attributes.Attribute; -import net.minecraft.entity.ai.attributes.AttributeModifier; -import net.minecraft.inventory.EquipmentSlotType; -import net.minecraft.item.ItemStack; +import net.minecraft.world.entity.ai.attributes.Attribute; +import net.minecraft.world.entity.ai.attributes.AttributeModifier; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.ItemStack; import com.google.common.collect.Multimap; import javax.annotation.Nullable; @@ -44,13 +44,13 @@ import java.util.Collection; public class ItemAttributeModifierEvent extends Event { private final ItemStack stack; - private final EquipmentSlotType slotType; + private final EquipmentSlot slotType; private final Multimap originalModifiers; private Multimap unmodifiableModifiers; @Nullable private Multimap modifiableModifiers; - public ItemAttributeModifierEvent(ItemStack stack, EquipmentSlotType slotType, Multimap modifiers) + public ItemAttributeModifierEvent(ItemStack stack, EquipmentSlot slotType, Multimap modifiers) { this.stack = stack; this.slotType = slotType; @@ -131,7 +131,7 @@ public class ItemAttributeModifierEvent extends Event } /** Gets the slot containing this stack */ - public EquipmentSlotType getSlotType() + public EquipmentSlot getSlotType() { return this.slotType; } diff --git a/src/main/java/net/minecraftforge/event/LootTableLoadEvent.java b/src/main/java/net/minecraftforge/event/LootTableLoadEvent.java index b7cfabcce3..9733ddb465 100644 --- a/src/main/java/net/minecraftforge/event/LootTableLoadEvent.java +++ b/src/main/java/net/minecraftforge/event/LootTableLoadEvent.java @@ -19,9 +19,9 @@ package net.minecraftforge.event; -import net.minecraft.util.ResourceLocation; -import net.minecraft.loot.LootTable; -import net.minecraft.loot.LootTableManager; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.storage.loot.LootTable; +import net.minecraft.world.level.storage.loot.LootTables; import net.minecraftforge.eventbus.api.Cancelable; import net.minecraftforge.eventbus.api.Event; @@ -39,9 +39,9 @@ public class LootTableLoadEvent extends Event { private final ResourceLocation name; private LootTable table; - private LootTableManager lootTableManager; + private LootTables lootTableManager; - public LootTableLoadEvent(ResourceLocation name, LootTable table, LootTableManager lootTableManager) + public LootTableLoadEvent(ResourceLocation name, LootTable table, LootTables lootTableManager) { this.name = name; this.table = table; @@ -58,7 +58,7 @@ public class LootTableLoadEvent extends Event return this.table; } - public LootTableManager getLootTableManager() + public LootTables getLootTableManager() { return this.lootTableManager; } diff --git a/src/main/java/net/minecraftforge/event/RegisterCommandsEvent.java b/src/main/java/net/minecraftforge/event/RegisterCommandsEvent.java index 45aabc2d00..75ced83137 100644 --- a/src/main/java/net/minecraftforge/event/RegisterCommandsEvent.java +++ b/src/main/java/net/minecraftforge/event/RegisterCommandsEvent.java @@ -20,12 +20,12 @@ package net.minecraftforge.event; import com.mojang.brigadier.CommandDispatcher; -import net.minecraft.command.*; -import net.minecraft.resources.*; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.Event; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.commands.Commands; + /** * Commands are rebuilt whenever {@link DataPackRegistries} is recreated. * You can use this event to register your commands whenever the {@link net.minecraft.command.Commands} class in constructed. @@ -34,21 +34,21 @@ import net.minecraftforge.eventbus.api.Event; */ public class RegisterCommandsEvent extends Event { - private final CommandDispatcher dispatcher; - private final Commands.EnvironmentType environment; + private final CommandDispatcher dispatcher; + private final Commands.CommandSelection environment; - public RegisterCommandsEvent(CommandDispatcher dispatcher, Commands.EnvironmentType environment) + public RegisterCommandsEvent(CommandDispatcher dispatcher, Commands.CommandSelection environment) { this.dispatcher = dispatcher; this.environment = environment; } - public CommandDispatcher getDispatcher() + public CommandDispatcher getDispatcher() { return dispatcher; } - public Commands.EnvironmentType getEnvironment() + public Commands.CommandSelection getEnvironment() { return environment; } diff --git a/src/main/java/net/minecraftforge/event/RegistryEvent.java b/src/main/java/net/minecraftforge/event/RegistryEvent.java index bdbb3eb8df..b9774a0d82 100644 --- a/src/main/java/net/minecraftforge/event/RegistryEvent.java +++ b/src/main/java/net/minecraftforge/event/RegistryEvent.java @@ -22,11 +22,11 @@ package net.minecraftforge.event; import java.util.Collection; import java.util.stream.Collectors; -import net.minecraftforge.fml.event.lifecycle.IModBusEvent; +import net.minecraftforge.fml.event.IModBusEvent; import org.apache.commons.lang3.Validate; import com.google.common.collect.ImmutableList; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.fml.ModContainer; import net.minecraftforge.eventbus.api.GenericEvent; import net.minecraftforge.registries.IForgeRegistry; diff --git a/src/main/java/net/minecraftforge/event/ServerChatEvent.java b/src/main/java/net/minecraftforge/event/ServerChatEvent.java index 9342abf713..ac95707619 100644 --- a/src/main/java/net/minecraftforge/event/ServerChatEvent.java +++ b/src/main/java/net/minecraftforge/event/ServerChatEvent.java @@ -19,10 +19,8 @@ package net.minecraftforge.event; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.util.text.ITextComponent; -import net.minecraftforge.common.ForgeHooks; -import net.minecraftforge.common.MinecraftForge; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.network.chat.Component; import net.minecraftforge.eventbus.api.Cancelable; /** @@ -46,9 +44,9 @@ import net.minecraftforge.eventbus.api.Cancelable; public class ServerChatEvent extends net.minecraftforge.eventbus.api.Event { private final String message, username; - private final ServerPlayerEntity player; - private ITextComponent component; - public ServerChatEvent(ServerPlayerEntity player, String message, ITextComponent component) + private final ServerPlayer player; + private Component component; + public ServerChatEvent(ServerPlayer player, String message, Component component) { super(); this.message = message; @@ -57,17 +55,17 @@ public class ServerChatEvent extends net.minecraftforge.eventbus.api.Event this.component = component; } - public void setComponent(ITextComponent e) + public void setComponent(Component e) { this.component = e; } - public ITextComponent getComponent() + public Component getComponent() { return this.component; } public String getMessage() { return this.message; } public String getUsername() { return this.username; } - public ServerPlayerEntity getPlayer() { return this.player; } + public ServerPlayer getPlayer() { return this.player; } } diff --git a/src/main/java/net/minecraftforge/event/TagsUpdatedEvent.java b/src/main/java/net/minecraftforge/event/TagsUpdatedEvent.java index 352c3ade4c..05043d80c5 100644 --- a/src/main/java/net/minecraftforge/event/TagsUpdatedEvent.java +++ b/src/main/java/net/minecraftforge/event/TagsUpdatedEvent.java @@ -19,7 +19,7 @@ package net.minecraftforge.event; -import net.minecraft.tags.ITagCollectionSupplier; +import net.minecraft.tags.TagContainer; import net.minecraftforge.eventbus.api.Event; /** @@ -31,9 +31,9 @@ import net.minecraftforge.eventbus.api.Event; */ public class TagsUpdatedEvent extends Event { - private final ITagCollectionSupplier manager; + private final TagContainer manager; - public TagsUpdatedEvent(ITagCollectionSupplier manager) + public TagsUpdatedEvent(TagContainer manager) { this.manager = manager; } @@ -41,7 +41,7 @@ public class TagsUpdatedEvent extends Event /** * @return The network tag manager that has been updated with newly received tags. */ - public ITagCollectionSupplier getTagManager() + public TagContainer getTagManager() { return manager; } @@ -51,7 +51,7 @@ public class TagsUpdatedEvent extends Event */ public static class VanillaTagTypes extends TagsUpdatedEvent { - public VanillaTagTypes(ITagCollectionSupplier manager) + public VanillaTagTypes(TagContainer manager) { super(manager); } @@ -62,7 +62,7 @@ public class TagsUpdatedEvent extends Event */ public static class CustomTagTypes extends TagsUpdatedEvent { - public CustomTagTypes(ITagCollectionSupplier manager) + public CustomTagTypes(TagContainer manager) { super(manager); } diff --git a/src/main/java/net/minecraftforge/event/TickEvent.java b/src/main/java/net/minecraftforge/event/TickEvent.java index 6373c7e606..83d600fa05 100644 --- a/src/main/java/net/minecraftforge/event/TickEvent.java +++ b/src/main/java/net/minecraftforge/event/TickEvent.java @@ -19,9 +19,9 @@ package net.minecraftforge.event; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.world.World; +import net.minecraft.world.entity.player.Player; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.level.Level; import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.fml.LogicalSide; @@ -59,19 +59,19 @@ public class TickEvent extends Event } public static class WorldTickEvent extends TickEvent { - public final World world; - public WorldTickEvent(LogicalSide side, Phase phase, World world) + public final Level world; + public WorldTickEvent(LogicalSide side, Phase phase, Level world) { super(Type.WORLD, side, phase); this.world = world; } } public static class PlayerTickEvent extends TickEvent { - public final PlayerEntity player; + public final Player player; - public PlayerTickEvent(Phase phase, PlayerEntity player) + public PlayerTickEvent(Phase phase, Player player) { - super(Type.PLAYER, player instanceof ServerPlayerEntity ? LogicalSide.SERVER : LogicalSide.CLIENT, phase); + super(Type.PLAYER, player instanceof ServerPlayer ? LogicalSide.SERVER : LogicalSide.CLIENT, phase); this.player = player; } } diff --git a/src/main/java/net/minecraftforge/event/brewing/PlayerBrewedPotionEvent.java b/src/main/java/net/minecraftforge/event/brewing/PlayerBrewedPotionEvent.java index c9d4fdb523..f5297ec4d1 100644 --- a/src/main/java/net/minecraftforge/event/brewing/PlayerBrewedPotionEvent.java +++ b/src/main/java/net/minecraftforge/event/brewing/PlayerBrewedPotionEvent.java @@ -19,8 +19,8 @@ package net.minecraftforge.event.brewing; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; import net.minecraftforge.event.entity.player.PlayerEvent; import javax.annotation.Nonnull; @@ -32,7 +32,7 @@ public class PlayerBrewedPotionEvent extends PlayerEvent { private final ItemStack stack; - public PlayerBrewedPotionEvent(PlayerEntity player, @Nonnull ItemStack stack) + public PlayerBrewedPotionEvent(Player player, @Nonnull ItemStack stack) { super(player); this.stack = stack; diff --git a/src/main/java/net/minecraftforge/event/brewing/PotionBrewEvent.java b/src/main/java/net/minecraftforge/event/brewing/PotionBrewEvent.java index aae51e25ac..5dbc8f5109 100644 --- a/src/main/java/net/minecraftforge/event/brewing/PotionBrewEvent.java +++ b/src/main/java/net/minecraftforge/event/brewing/PotionBrewEvent.java @@ -19,13 +19,10 @@ package net.minecraftforge.event.brewing; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.BrewingStandTileEntity; -import net.minecraft.util.NonNullList; -import net.minecraftforge.common.MinecraftForge; +import net.minecraft.world.item.ItemStack; +import net.minecraft.core.NonNullList; import net.minecraftforge.eventbus.api.Cancelable; import net.minecraftforge.eventbus.api.Event; -import net.minecraftforge.eventbus.api.Event.HasResult; import javax.annotation.Nonnull; diff --git a/src/main/java/net/minecraftforge/event/enchanting/EnchantmentLevelSetEvent.java b/src/main/java/net/minecraftforge/event/enchanting/EnchantmentLevelSetEvent.java index c664d8112f..6b12c50381 100644 --- a/src/main/java/net/minecraftforge/event/enchanting/EnchantmentLevelSetEvent.java +++ b/src/main/java/net/minecraftforge/event/enchanting/EnchantmentLevelSetEvent.java @@ -19,10 +19,9 @@ package net.minecraftforge.event.enchanting; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraftforge.eventbus.api.Event; +import net.minecraft.world.item.ItemStack; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; import javax.annotation.Nonnull; @@ -36,7 +35,7 @@ import javax.annotation.Nonnull; */ public class EnchantmentLevelSetEvent extends net.minecraftforge.eventbus.api.Event { - private final World world; + private final Level world; private final BlockPos pos; private final int enchantRow; private final int power; @@ -45,7 +44,7 @@ public class EnchantmentLevelSetEvent extends net.minecraftforge.eventbus.api.Ev private final int originalLevel; private int level; - public EnchantmentLevelSetEvent(World world, BlockPos pos, int enchantRow, int power, @Nonnull ItemStack itemStack, int level) + public EnchantmentLevelSetEvent(Level world, BlockPos pos, int enchantRow, int power, @Nonnull ItemStack itemStack, int level) { this.world = world; this.pos = pos; @@ -61,7 +60,7 @@ public class EnchantmentLevelSetEvent extends net.minecraftforge.eventbus.api.Ev * * @return the world object */ - public World getWorld() + public Level getWorld() { return world; } diff --git a/src/main/java/net/minecraftforge/event/entity/EntityAttributeCreationEvent.java b/src/main/java/net/minecraftforge/event/entity/EntityAttributeCreationEvent.java index caeeab9a95..b211f23000 100644 --- a/src/main/java/net/minecraftforge/event/entity/EntityAttributeCreationEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/EntityAttributeCreationEvent.java @@ -21,12 +21,12 @@ package net.minecraftforge.event.entity; import java.util.Map; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.ai.attributes.AttributeModifierMap; -import net.minecraft.entity.ai.attributes.GlobalEntityTypeAttributes; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.ai.attributes.AttributeSupplier; +import net.minecraft.world.entity.ai.attributes.DefaultAttributes; import net.minecraftforge.eventbus.api.Event; -import net.minecraftforge.fml.event.lifecycle.IModBusEvent; +import net.minecraftforge.fml.event.IModBusEvent; /** * EntityAttributeCreationEvent.
@@ -37,16 +37,16 @@ import net.minecraftforge.fml.event.lifecycle.IModBusEvent; **/ public class EntityAttributeCreationEvent extends Event implements IModBusEvent { - private final Map, AttributeModifierMap> map; + private final Map, AttributeSupplier> map; - public EntityAttributeCreationEvent(Map, AttributeModifierMap> map) + public EntityAttributeCreationEvent(Map, AttributeSupplier> map) { this.map = map; } - public void put(EntityType entity, AttributeModifierMap map) + public void put(EntityType entity, AttributeSupplier map) { - if (GlobalEntityTypeAttributes.hasSupplier(entity)) + if (DefaultAttributes.hasSupplier(entity)) throw new IllegalStateException("Duplicate GlobalEntityTypeAttributes entry: " + entity); this.map.put(entity, map); } diff --git a/src/main/java/net/minecraftforge/event/entity/EntityAttributeModificationEvent.java b/src/main/java/net/minecraftforge/event/entity/EntityAttributeModificationEvent.java index dd97fbaec0..4000adc54d 100644 --- a/src/main/java/net/minecraftforge/event/entity/EntityAttributeModificationEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/EntityAttributeModificationEvent.java @@ -20,13 +20,13 @@ package net.minecraftforge.event.entity; import com.google.common.collect.ImmutableList; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.ai.attributes.Attribute; -import net.minecraft.entity.ai.attributes.AttributeModifierMap; -import net.minecraft.entity.ai.attributes.GlobalEntityTypeAttributes; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.ai.attributes.Attribute; +import net.minecraft.world.entity.ai.attributes.AttributeSupplier; +import net.minecraft.world.entity.ai.attributes.DefaultAttributes; import net.minecraftforge.eventbus.api.Event; -import net.minecraftforge.fml.event.lifecycle.IModBusEvent; +import net.minecraftforge.fml.event.IModBusEvent; import net.minecraftforge.registries.ForgeRegistries; import java.util.List; @@ -42,16 +42,16 @@ import java.util.stream.Collectors; **/ public class EntityAttributeModificationEvent extends Event implements IModBusEvent { - private final Map, AttributeModifierMap.MutableAttribute> entityAttributes; + private final Map, AttributeSupplier.Builder> entityAttributes; private final List> entityTypes; @SuppressWarnings("unchecked") - public EntityAttributeModificationEvent(Map, AttributeModifierMap.MutableAttribute> mapIn) + public EntityAttributeModificationEvent(Map, AttributeSupplier.Builder> mapIn) { this.entityAttributes = mapIn; this.entityTypes = ImmutableList.copyOf( ForgeRegistries.ENTITIES.getValues().stream() - .filter(GlobalEntityTypeAttributes::hasSupplier) + .filter(DefaultAttributes::hasSupplier) .map(entityType -> (EntityType) entityType) .collect(Collectors.toList()) ); @@ -59,8 +59,8 @@ public class EntityAttributeModificationEvent extends Event implements IModBusEv public void add(EntityType entityType, Attribute attribute, double value) { - AttributeModifierMap.MutableAttribute attributes = entityAttributes.computeIfAbsent(entityType, - (type) -> new AttributeModifierMap.MutableAttribute()); + AttributeSupplier.Builder attributes = entityAttributes.computeIfAbsent(entityType, + (type) -> new AttributeSupplier.Builder()); attributes.add(attribute, value); } @@ -71,7 +71,7 @@ public class EntityAttributeModificationEvent extends Event implements IModBusEv public boolean has(EntityType entityType, Attribute attribute) { - AttributeModifierMap globalMap = GlobalEntityTypeAttributes.getSupplier(entityType); + AttributeSupplier globalMap = DefaultAttributes.getSupplier(entityType); return globalMap.hasAttribute(attribute) || (entityAttributes.get(entityType) != null && entityAttributes.get(entityType).hasAttribute(attribute)); } diff --git a/src/main/java/net/minecraftforge/event/entity/EntityEvent.java b/src/main/java/net/minecraftforge/event/entity/EntityEvent.java index f78f3f05e8..78af12b872 100644 --- a/src/main/java/net/minecraftforge/event/entity/EntityEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/EntityEvent.java @@ -19,13 +19,9 @@ package net.minecraftforge.event.entity; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntitySize; -import net.minecraft.entity.Pose; -import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityDimensions; +import net.minecraft.world.entity.Pose; import net.minecraftforge.eventbus.api.Event; /** @@ -100,43 +96,6 @@ public class EntityEvent extends Event this.canUpdate = canUpdate; } } - - /** - * EnteringChunk is fired when an Entity enters a chunk.
- * This event is fired whenever vanilla Minecraft determines that an entity
- * is entering a chunk in {@link Chunk#addEntity(net.minecraft.entity.Entity)}
- *
- * 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}.
- **/ - public static class EnteringChunk extends EntityEvent - { - private int newChunkX; - private int newChunkZ; - private int oldChunkX; - private int oldChunkZ; - - public EnteringChunk(Entity entity, int newChunkX, int newChunkZ, int oldChunkX, int oldChunkZ) - { - super(entity); - this.setNewChunkX(newChunkX); - this.setNewChunkZ(newChunkZ); - this.setOldChunkX(oldChunkX); - this.setOldChunkZ(oldChunkZ); - } - - public int getNewChunkX() { return newChunkX; } - public void setNewChunkX(int newChunkX) { this.newChunkX = newChunkX; } - public int getNewChunkZ() { return newChunkZ; } - public void setNewChunkZ(int newChunkZ) { this.newChunkZ = newChunkZ; } - public int getOldChunkX() { return oldChunkX; } - public void setOldChunkX(int oldChunkX) { this.oldChunkX = oldChunkX; } - public int getOldChunkZ() { return oldChunkZ; } - public void setOldChunkZ(int oldChunkZ) { this.oldChunkZ = oldChunkZ; } - } /** * This event is fired whenever the {@link Pose} changes, and in a few other hardcoded scenarios.
@@ -152,17 +111,17 @@ public class EntityEvent extends Event public static class Size extends EntityEvent { private final Pose pose; - private final EntitySize oldSize; - private EntitySize newSize; + private final EntityDimensions oldSize; + private EntityDimensions newSize; private final float oldEyeHeight; private float newEyeHeight; - public Size(Entity entity, Pose pose, EntitySize size, float defaultEyeHeight) + public Size(Entity entity, Pose pose, EntityDimensions size, float defaultEyeHeight) { this(entity, pose, size, size, defaultEyeHeight, defaultEyeHeight); } - public Size(Entity entity, Pose pose, EntitySize oldSize, EntitySize newSize, float oldEyeHeight, float newEyeHeight) + public Size(Entity entity, Pose pose, EntityDimensions oldSize, EntityDimensions newSize, float oldEyeHeight, float newEyeHeight) { super(entity); this.pose = pose; @@ -174,9 +133,9 @@ public class EntityEvent extends Event public Pose getPose() { return pose; } - public EntitySize getOldSize() { return oldSize; } - public EntitySize getNewSize() { return newSize; } - public void setNewSize(EntitySize size) + public EntityDimensions getOldSize() { return oldSize; } + public EntityDimensions getNewSize() { return newSize; } + public void setNewSize(EntityDimensions size) { setNewSize(size, false); } @@ -184,7 +143,7 @@ public class EntityEvent extends Event /** * Set the new size of the entity. Set updateEyeHeight to true to also update the eye height according to the new size. */ - public void setNewSize(EntitySize size, boolean updateEyeHeight) + public void setNewSize(EntityDimensions size, boolean updateEyeHeight) { this.newSize = size; if (updateEyeHeight) diff --git a/src/main/java/net/minecraftforge/event/entity/EntityJoinWorldEvent.java b/src/main/java/net/minecraftforge/event/entity/EntityJoinWorldEvent.java index f46237072e..7f28b048e3 100644 --- a/src/main/java/net/minecraftforge/event/entity/EntityJoinWorldEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/EntityJoinWorldEvent.java @@ -19,12 +19,8 @@ package net.minecraftforge.event.entity; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.eventbus.api.Cancelable; -import net.minecraft.entity.Entity; -import net.minecraft.world.World; - -import java.util.Collection; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.Level; /** * EntityJoinWorldEvent is fired when an Entity joins the world.
@@ -45,15 +41,15 @@ import java.util.Collection; public class EntityJoinWorldEvent extends EntityEvent { - private final World world; + private final Level world; - public EntityJoinWorldEvent(Entity entity, World world) + public EntityJoinWorldEvent(Entity entity, Level world) { super(entity); this.world = world; } - public World getWorld() + public Level getWorld() { return world; } diff --git a/src/main/java/net/minecraftforge/event/entity/EntityLeaveWorldEvent.java b/src/main/java/net/minecraftforge/event/entity/EntityLeaveWorldEvent.java index 8a8d919543..8dded97c2c 100644 --- a/src/main/java/net/minecraftforge/event/entity/EntityLeaveWorldEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/EntityLeaveWorldEvent.java @@ -19,12 +19,8 @@ package net.minecraftforge.event.entity; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.eventbus.api.Cancelable; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.world.server.ServerWorld; -import net.minecraft.entity.Entity; -import net.minecraft.world.World; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.Level; /** * EntityLeaveWorldEvent is fired when an Entity leaves the world.
@@ -42,15 +38,15 @@ import net.minecraft.world.World; public class EntityLeaveWorldEvent extends EntityEvent { - private final World world; + private final Level world; - public EntityLeaveWorldEvent(Entity entity, World world) + public EntityLeaveWorldEvent(Entity entity, Level world) { super(entity); this.world = world; } - public World getWorld() + public Level getWorld() { return world; } diff --git a/src/main/java/net/minecraftforge/event/entity/EntityMobGriefingEvent.java b/src/main/java/net/minecraftforge/event/entity/EntityMobGriefingEvent.java index 9d5a63d0e5..7676c94173 100644 --- a/src/main/java/net/minecraftforge/event/entity/EntityMobGriefingEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/EntityMobGriefingEvent.java @@ -19,8 +19,7 @@ package net.minecraftforge.event.entity; -import net.minecraft.entity.Entity; -import net.minecraftforge.common.MinecraftForge; +import net.minecraft.world.entity.Entity; import net.minecraftforge.eventbus.api.Event.HasResult; /** diff --git a/src/main/java/net/minecraftforge/event/entity/EntityMountEvent.java b/src/main/java/net/minecraftforge/event/entity/EntityMountEvent.java index 0a4fa442ee..8354cb819b 100644 --- a/src/main/java/net/minecraftforge/event/entity/EntityMountEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/EntityMountEvent.java @@ -19,11 +19,9 @@ package net.minecraftforge.event.entity; -import net.minecraft.entity.Entity; -import net.minecraft.world.World; -import net.minecraftforge.common.MinecraftForge; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.Level; import net.minecraftforge.eventbus.api.Cancelable; -import net.minecraftforge.eventbus.api.Event.HasResult; /** * This event gets fired whenever a entity mounts/dismounts another entity.
@@ -45,11 +43,11 @@ public class EntityMountEvent extends EntityEvent private final Entity entityMounting; private final Entity entityBeingMounted; - private final World worldObj; + private final Level worldObj; private final boolean isMounting; - public EntityMountEvent(Entity entityMounting, Entity entityBeingMounted, World entityWorld, boolean isMounting) + public EntityMountEvent(Entity entityMounting, Entity entityBeingMounted, Level entityWorld, boolean isMounting) { super(entityMounting); this.entityMounting = entityMounting; @@ -78,7 +76,7 @@ public class EntityMountEvent extends EntityEvent return entityBeingMounted; } - public World getWorldObj() + public Level getWorldObj() { return worldObj; } diff --git a/src/main/java/net/minecraftforge/event/entity/EntityStruckByLightningEvent.java b/src/main/java/net/minecraftforge/event/entity/EntityStruckByLightningEvent.java index 1da71c20e2..311705345a 100644 --- a/src/main/java/net/minecraftforge/event/entity/EntityStruckByLightningEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/EntityStruckByLightningEvent.java @@ -19,11 +19,8 @@ package net.minecraftforge.event.entity; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.ForgeEventFactory; -import net.minecraftforge.eventbus.api.Cancelable; -import net.minecraft.entity.Entity; -import net.minecraft.entity.effect.LightningBoltEntity; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LightningBolt; /** * EntityStruckByLightningEvent is fired when an Entity is about to be struck by lightening.
@@ -42,15 +39,15 @@ import net.minecraft.entity.effect.LightningBoltEntity; @net.minecraftforge.eventbus.api.Cancelable public class EntityStruckByLightningEvent extends EntityEvent { - private final LightningBoltEntity lightning; + private final LightningBolt lightning; - public EntityStruckByLightningEvent(Entity entity, LightningBoltEntity lightning) + public EntityStruckByLightningEvent(Entity entity, LightningBolt lightning) { super(entity); this.lightning = lightning; } - public LightningBoltEntity getLightning() + public LightningBolt getLightning() { return lightning; } diff --git a/src/main/java/net/minecraftforge/event/entity/living/EntityTeleportEvent.java b/src/main/java/net/minecraftforge/event/entity/EntityTeleportEvent.java similarity index 89% rename from src/main/java/net/minecraftforge/event/entity/living/EntityTeleportEvent.java rename to src/main/java/net/minecraftforge/event/entity/EntityTeleportEvent.java index 25c9c999c1..a26ae4106a 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/EntityTeleportEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/EntityTeleportEvent.java @@ -17,15 +17,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.event.entity.living; +package net.minecraftforge.event.entity; -import net.minecraft.entity.Entity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.item.EnderPearlEntity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.entity.EntityEvent; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.projectile.ThrownEnderpearl; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.eventbus.api.Cancelable; /** @@ -38,6 +36,7 @@ import net.minecraftforge.eventbus.api.Cancelable; *
* All children of this event are fired on the {@link MinecraftForge#EVENT_BUS}.
**/ +@Cancelable public class EntityTeleportEvent extends EntityEvent { protected double targetX; @@ -57,11 +56,11 @@ public class EntityTeleportEvent extends EntityEvent public void setTargetY(double targetY) { this.targetY = targetY; } public double getTargetZ() { return targetZ; } public void setTargetZ(double targetZ) { this.targetZ = targetZ; } - public Vector3d getTarget() { return new Vector3d(this.targetX, this.targetY, this.targetZ); } + public Vec3 getTarget() { return new Vec3(this.targetX, this.targetY, this.targetZ); } public double getPrevX() { return getEntity().getX(); } public double getPrevY() { return getEntity().getY(); } public double getPrevZ() { return getEntity().getZ(); } - public Vector3d getPrev() { return getEntity().position(); } + public Vec3 getPrev() { return getEntity().position(); } /** * EntityTeleportEvent.TeleportCommand is fired before a living entity is teleported @@ -159,11 +158,11 @@ public class EntityTeleportEvent extends EntityEvent @Cancelable public static class EnderPearl extends EntityTeleportEvent { - private final ServerPlayerEntity player; - private final EnderPearlEntity pearlEntity; + private final ServerPlayer player; + private final ThrownEnderpearl pearlEntity; private float attackDamage; - public EnderPearl(ServerPlayerEntity entity, double targetX, double targetY, double targetZ, EnderPearlEntity pearlEntity, float attackDamage) + public EnderPearl(ServerPlayer entity, double targetX, double targetY, double targetZ, ThrownEnderpearl pearlEntity, float attackDamage) { super(entity, targetX, targetY, targetZ); this.pearlEntity = pearlEntity; @@ -171,12 +170,12 @@ public class EntityTeleportEvent extends EntityEvent this.attackDamage = attackDamage; } - public EnderPearlEntity getPearlEntity() + public ThrownEnderpearl getPearlEntity() { return pearlEntity; } - public ServerPlayerEntity getPlayer() + public ServerPlayer getPlayer() { return player; } diff --git a/src/main/java/net/minecraftforge/event/entity/EntityTravelToDimensionEvent.java b/src/main/java/net/minecraftforge/event/entity/EntityTravelToDimensionEvent.java index 17b469bb8f..07b610bb6b 100644 --- a/src/main/java/net/minecraftforge/event/entity/EntityTravelToDimensionEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/EntityTravelToDimensionEvent.java @@ -19,12 +19,10 @@ package net.minecraftforge.event.entity; -import net.minecraft.entity.Entity; -import net.minecraft.util.RegistryKey; -import net.minecraft.world.World; -import net.minecraftforge.common.MinecraftForge; +import net.minecraft.world.entity.Entity; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.level.Level; import net.minecraftforge.eventbus.api.Cancelable; -import net.minecraftforge.eventbus.api.Event.HasResult; /** * EntityTravelToDimensionEvent is fired before an Entity travels to a dimension.
@@ -41,15 +39,15 @@ import net.minecraftforge.eventbus.api.Event.HasResult; @Cancelable public class EntityTravelToDimensionEvent extends EntityEvent { - private final RegistryKey dimension; + private final ResourceKey dimension; - public EntityTravelToDimensionEvent(Entity entity, RegistryKey dimension) + public EntityTravelToDimensionEvent(Entity entity, ResourceKey dimension) { super(entity); this.dimension = dimension; } - public RegistryKey getDimension() + public ResourceKey getDimension() { return dimension; } diff --git a/src/main/java/net/minecraftforge/event/entity/PlaySoundAtEntityEvent.java b/src/main/java/net/minecraftforge/event/entity/PlaySoundAtEntityEvent.java index d088faa786..e89e79cb8b 100644 --- a/src/main/java/net/minecraftforge/event/entity/PlaySoundAtEntityEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/PlaySoundAtEntityEvent.java @@ -19,14 +19,9 @@ package net.minecraftforge.event.entity; -import net.minecraft.client.entity.player.ClientPlayerEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.world.World; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.eventbus.api.Cancelable; -import net.minecraft.entity.Entity; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvent; +import net.minecraft.world.entity.Entity; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvent; /** * PlaySoundAtEntityEvent is fired a sound is to be played at an Entity
@@ -51,13 +46,13 @@ import net.minecraft.util.SoundEvent; public class PlaySoundAtEntityEvent extends EntityEvent { private SoundEvent name; - private SoundCategory category; + private SoundSource category; private final float volume; private final float pitch; private float newVolume; private float newPitch; - public PlaySoundAtEntityEvent(Entity entity, SoundEvent name, SoundCategory category, float volume, float pitch) + public PlaySoundAtEntityEvent(Entity entity, SoundEvent name, SoundSource category, float volume, float pitch) { super(entity); this.name = name; @@ -69,13 +64,13 @@ public class PlaySoundAtEntityEvent extends EntityEvent } public SoundEvent getSound() { return this.name; } - public SoundCategory getCategory() { return this.category; } + public SoundSource getCategory() { return this.category; } public float getDefaultVolume() { return this.volume; } public float getDefaultPitch() { return this.pitch; } public float getVolume() { return this.newVolume; } public float getPitch() { return this.newPitch; } public void setSound(SoundEvent value) { this.name = value; } - public void setCategory(SoundCategory category) { this.category = category; } + public void setCategory(SoundSource category) { this.category = category; } public void setVolume(float value) { this.newVolume = value; } public void setPitch(float value) { this.newPitch = value; } } diff --git a/src/main/java/net/minecraftforge/event/entity/ProjectileImpactEvent.java b/src/main/java/net/minecraftforge/event/entity/ProjectileImpactEvent.java index d254a1a8f1..8da26bd1cf 100644 --- a/src/main/java/net/minecraftforge/event/entity/ProjectileImpactEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/ProjectileImpactEvent.java @@ -19,131 +19,41 @@ package net.minecraftforge.event.entity; -import net.minecraft.entity.Entity; -import net.minecraft.entity.projectile.AbstractArrowEntity; -import net.minecraft.entity.projectile.DamagingProjectileEntity; -import net.minecraft.entity.projectile.FireworkRocketEntity; -import net.minecraft.entity.projectile.FishingBobberEntity; -import net.minecraft.entity.projectile.ThrowableEntity; -import net.minecraft.util.math.RayTraceResult; +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; /** - * This event is fired when a projectile entity impacts something. - * This event is fired via {@link ForgeEventFactory#onProjectileImpact(Entity, RayTraceResult)} - * Subclasses of this event exist for more specific types of projectile. + * This event is fired on the {@link MinecraftForge#EVENT_BUS}.
+ * This event is fired when a projectile entity impacts something.
+ * 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. + * 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. - * This event is fired on the {@link MinecraftForge#EVENT_BUS}. */ @Cancelable -public class ProjectileImpactEvent extends EntityEvent +public class ProjectileImpactEvent extends EntityEvent { - private final RayTraceResult ray; + private final HitResult ray; + private final T projectile; - public ProjectileImpactEvent(Entity entity, RayTraceResult ray) + public ProjectileImpactEvent(T projectile, HitResult ray) { - super(entity); + super(projectile); this.ray = ray; + this.projectile = projectile; } - public RayTraceResult getRayTraceResult() + public HitResult getRayTraceResult() { return ray; } - @Cancelable - public static class Arrow extends ProjectileImpactEvent + public T getProjectile() { - private final AbstractArrowEntity arrow; - - public Arrow(AbstractArrowEntity arrow, RayTraceResult ray) - { - super(arrow, ray); - this.arrow = arrow; - } - - public AbstractArrowEntity getArrow() - { - return arrow; - } - } - - @Cancelable - public static class Fireball extends ProjectileImpactEvent - { - private final DamagingProjectileEntity fireball; - - public Fireball(DamagingProjectileEntity fireball, RayTraceResult ray) - { - super(fireball, ray); - this.fireball = fireball; - } - - public DamagingProjectileEntity getFireball() - { - return fireball; - } - } - - @Cancelable - public static class Throwable extends ProjectileImpactEvent - { - private final ThrowableEntity throwable; - - public Throwable(ThrowableEntity throwable, RayTraceResult ray) - { - super(throwable, ray); - this.throwable = throwable; - } - - public ThrowableEntity getThrowable() - { - return throwable; - } - } - - /** - * Event is cancellable, causes firework to ignore the current hit and continue on its journey. - */ - @Cancelable - public static class FireworkRocket extends ProjectileImpactEvent - { - private final FireworkRocketEntity fireworkRocket; - - public FireworkRocket(FireworkRocketEntity fireworkRocket, RayTraceResult ray) - { - super(fireworkRocket, ray); - this.fireworkRocket = fireworkRocket; - } - - public FireworkRocketEntity getFireworkRocket() - { - return fireworkRocket; - } - } - - /** - * Event is cancellable, causes bobber to ignore the current hit and continue on its journey. - */ - @Cancelable - public static class FishingBobber extends ProjectileImpactEvent - { - private final FishingBobberEntity fishingBobber; - - public FishingBobber(FishingBobberEntity fishingBobber, RayTraceResult ray) - { - super(fishingBobber, ray); - this.fishingBobber = fishingBobber; - } - - public FishingBobberEntity getFishingBobber() - { - return fishingBobber; - } + return projectile; } } diff --git a/src/main/java/net/minecraftforge/event/entity/item/ItemEvent.java b/src/main/java/net/minecraftforge/event/entity/item/ItemEvent.java index 6ae083027f..9cbd6b4ba7 100644 --- a/src/main/java/net/minecraftforge/event/entity/item/ItemEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/item/ItemEvent.java @@ -19,7 +19,7 @@ package net.minecraftforge.event.entity.item; -import net.minecraft.entity.item.ItemEntity; +import net.minecraft.world.entity.item.ItemEntity; import net.minecraftforge.event.entity.EntityEvent; /** diff --git a/src/main/java/net/minecraftforge/event/entity/item/ItemExpireEvent.java b/src/main/java/net/minecraftforge/event/entity/item/ItemExpireEvent.java index 30bd18d359..e51a2102d9 100644 --- a/src/main/java/net/minecraftforge/event/entity/item/ItemExpireEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/item/ItemExpireEvent.java @@ -20,7 +20,7 @@ package net.minecraftforge.event.entity.item; import net.minecraftforge.eventbus.api.Cancelable; -import net.minecraft.entity.item.ItemEntity; +import net.minecraft.world.entity.item.ItemEntity; /** * Event that is fired when an EntityItem's age has reached its maximum diff --git a/src/main/java/net/minecraftforge/event/entity/item/ItemTossEvent.java b/src/main/java/net/minecraftforge/event/entity/item/ItemTossEvent.java index 248e3d41a8..6989c2a67a 100644 --- a/src/main/java/net/minecraftforge/event/entity/item/ItemTossEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/item/ItemTossEvent.java @@ -20,8 +20,8 @@ package net.minecraftforge.event.entity.item; import net.minecraftforge.eventbus.api.Cancelable; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; /** * Event that is fired whenever a player tosses (Q) an item or drag-n-drops a @@ -33,7 +33,7 @@ import net.minecraft.entity.player.PlayerEntity; public class ItemTossEvent extends ItemEvent { - private final PlayerEntity player; + private final Player player; /** * Creates a new event for EntityItems tossed by a player. @@ -41,7 +41,7 @@ public class ItemTossEvent extends ItemEvent * @param entityItem The EntityItem being tossed. * @param player The player tossing the item. */ - public ItemTossEvent(ItemEntity entityItem, PlayerEntity player) + public ItemTossEvent(ItemEntity entityItem, Player player) { super(entityItem); this.player = player; @@ -50,7 +50,7 @@ public class ItemTossEvent extends ItemEvent /** * The player tossing the item. */ - public PlayerEntity getPlayer() + public Player getPlayer() { return player; } diff --git a/src/main/java/net/minecraftforge/event/entity/living/AnimalTameEvent.java b/src/main/java/net/minecraftforge/event/entity/living/AnimalTameEvent.java index 645f43127d..70109cb4b4 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/AnimalTameEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/AnimalTameEvent.java @@ -19,10 +19,8 @@ package net.minecraftforge.event.entity.living; -import net.minecraft.entity.passive.AnimalEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.ForgeEventFactory; +import net.minecraft.world.entity.animal.Animal; +import net.minecraft.world.entity.player.Player; import net.minecraftforge.eventbus.api.Cancelable; /** @@ -35,22 +33,22 @@ import net.minecraftforge.eventbus.api.Cancelable; @Cancelable public class AnimalTameEvent extends LivingEvent { - private final AnimalEntity animal; - private final PlayerEntity tamer; + private final Animal animal; + private final Player tamer; - public AnimalTameEvent(AnimalEntity animal, PlayerEntity tamer) + public AnimalTameEvent(Animal animal, Player tamer) { super(animal); this.animal = animal; this.tamer = tamer; } - public AnimalEntity getAnimal() + public Animal getAnimal() { return animal; } - public PlayerEntity getTamer() + public Player getTamer() { return tamer; } diff --git a/src/main/java/net/minecraftforge/event/entity/living/BabyEntitySpawnEvent.java b/src/main/java/net/minecraftforge/event/entity/living/BabyEntitySpawnEvent.java index 941993b051..4243e3a4cf 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/BabyEntitySpawnEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/BabyEntitySpawnEvent.java @@ -19,11 +19,10 @@ package net.minecraftforge.event.entity.living; -import net.minecraft.entity.AgeableEntity; -import net.minecraft.entity.MobEntity; -import net.minecraft.entity.passive.AnimalEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraftforge.common.MinecraftForge; +import net.minecraft.world.entity.AgeableMob; +import net.minecraft.world.entity.Mob; +import net.minecraft.world.entity.animal.Animal; +import net.minecraft.world.entity.player.Player; import net.minecraftforge.eventbus.api.Cancelable; import javax.annotation.Nullable; @@ -49,22 +48,22 @@ import javax.annotation.Nullable; @Cancelable public class BabyEntitySpawnEvent extends net.minecraftforge.eventbus.api.Event { - private final MobEntity parentA; - private final MobEntity parentB; - private final PlayerEntity causedByPlayer; - private AgeableEntity child; + private final Mob parentA; + private final Mob parentB; + private final Player causedByPlayer; + private AgeableMob child; - public BabyEntitySpawnEvent(MobEntity parentA, MobEntity parentB, @Nullable AgeableEntity proposedChild) + public BabyEntitySpawnEvent(Mob parentA, Mob parentB, @Nullable AgeableMob proposedChild) { //causedByPlayer calculated here to simplify the patch. - PlayerEntity causedByPlayer = null; - if (parentA instanceof AnimalEntity) { - causedByPlayer = ((AnimalEntity)parentA).getLoveCause(); + Player causedByPlayer = null; + if (parentA instanceof Animal) { + causedByPlayer = ((Animal)parentA).getLoveCause(); } - if (causedByPlayer == null && parentB instanceof AnimalEntity) + if (causedByPlayer == null && parentB instanceof Animal) { - causedByPlayer = ((AnimalEntity)parentB).getLoveCause(); + causedByPlayer = ((Animal)parentB).getLoveCause(); } this.parentA = parentA; @@ -73,29 +72,29 @@ public class BabyEntitySpawnEvent extends net.minecraftforge.eventbus.api.Event this.child = proposedChild; } - public MobEntity getParentA() + public Mob getParentA() { return parentA; } - public MobEntity getParentB() + public Mob getParentB() { return parentB; } @Nullable - public PlayerEntity getCausedByPlayer() + public Player getCausedByPlayer() { return causedByPlayer; } @Nullable - public AgeableEntity getChild() + public AgeableMob getChild() { return child; } - public void setChild(AgeableEntity proposedChild) + public void setChild(AgeableMob proposedChild) { child = proposedChild; } diff --git a/src/main/java/net/minecraftforge/event/entity/living/EnderTeleportEvent.java b/src/main/java/net/minecraftforge/event/entity/living/EnderTeleportEvent.java deleted file mode 100644 index 9f3046607a..0000000000 --- a/src/main/java/net/minecraftforge/event/entity/living/EnderTeleportEvent.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.event.entity.living; - -import net.minecraftforge.eventbus.api.Cancelable; -import net.minecraft.entity.LivingEntity; - -/** - * Event for when an Enderman/Shulker teleports or an ender pearl is used. Can be used to either modify the target position, or cancel the teleport outright. - * @author Mithion - * @deprecated Use {@link EntityTeleportEvent.EnderEntity} or {@link EntityTeleportEvent.EnderPearl}. - */ -@Deprecated //TODO Forge: Remove in 1.17 -@Cancelable -public class EnderTeleportEvent extends LivingEvent -{ - - private double targetX; - private double targetY; - private double targetZ; - private float attackDamage; - - public EnderTeleportEvent(LivingEntity entity, double targetX, double targetY, double targetZ, float attackDamage) - { - super(entity); - this.setTargetX(targetX); - this.setTargetY(targetY); - this.setTargetZ(targetZ); - this.setAttackDamage(attackDamage); - } - - public double getTargetX() { return targetX; } - public void setTargetX(double targetX) { this.targetX = targetX; } - public double getTargetY() { return targetY; } - public void setTargetY(double targetY) { this.targetY = targetY; } - public double getTargetZ() { return targetZ; } - public void setTargetZ(double targetZ) { this.targetZ = targetZ; } - public float getAttackDamage() { return attackDamage; } - public void setAttackDamage(float attackDamage) { this.attackDamage = attackDamage; } -} diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingAttackEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingAttackEvent.java index df0ccbf56f..704e726edf 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingAttackEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingAttackEvent.java @@ -19,11 +19,9 @@ package net.minecraftforge.event.entity.living; -import net.minecraftforge.common.ForgeHooks; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.Cancelable; -import net.minecraft.util.DamageSource; -import net.minecraft.entity.LivingEntity; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.LivingEntity; /** * LivingAttackEvent is fired when a living Entity is attacked.
diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingConversionEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingConversionEvent.java index 0f7a05066e..e670d842d5 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingConversionEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingConversionEvent.java @@ -19,8 +19,8 @@ package net.minecraftforge.event.entity.living; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.LivingEntity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.LivingEntity; import net.minecraftforge.eventbus.api.Cancelable; import java.util.function.Consumer; diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingDamageEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingDamageEvent.java index 509eaa37fc..efceb14d19 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingDamageEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingDamageEvent.java @@ -19,10 +19,9 @@ package net.minecraftforge.event.entity.living; -import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.eventbus.api.Cancelable; -import net.minecraft.util.DamageSource; -import net.minecraft.entity.LivingEntity; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.LivingEntity; /** * LivingDamageEvent is fired just before damage is applied to entity.
diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingDeathEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingDeathEvent.java index 587f9fa8c1..ca2f4cda75 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingDeathEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingDeathEvent.java @@ -19,11 +19,9 @@ package net.minecraftforge.event.entity.living; -import net.minecraftforge.common.ForgeHooks; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.Cancelable; -import net.minecraft.util.DamageSource; -import net.minecraft.entity.LivingEntity; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.LivingEntity; /** * LivingDeathEvent is fired when an Entity dies.
diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingDestroyBlockEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingDestroyBlockEvent.java index bb15b30db9..661e5d105d 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingDestroyBlockEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingDestroyBlockEvent.java @@ -19,12 +19,9 @@ package net.minecraftforge.event.entity.living; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.entity.Entity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraftforge.common.MinecraftForge; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.core.BlockPos; import net.minecraftforge.eventbus.api.Cancelable; /** diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingDropsEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingDropsEvent.java index 24f1813b21..cd68847ffc 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingDropsEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingDropsEvent.java @@ -19,15 +19,11 @@ package net.minecraftforge.event.entity.living; -import java.util.ArrayList; import java.util.Collection; -import net.minecraftforge.common.ForgeHooks; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.eventbus.api.Cancelable; -import net.minecraft.util.DamageSource; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.LivingEntity; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.LivingEntity; /** * LivingDropsEvent is fired when an Entity's death causes dropped items to appear.
diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingEntityUseItemEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingEntityUseItemEvent.java index d49b240260..4325dccfbf 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingEntityUseItemEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingEntityUseItemEvent.java @@ -19,8 +19,8 @@ package net.minecraftforge.event.entity.living; -import net.minecraft.entity.LivingEntity; -import net.minecraft.item.ItemStack; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.item.ItemStack; import net.minecraftforge.eventbus.api.Cancelable; import javax.annotation.Nonnull; diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingEquipmentChangeEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingEquipmentChangeEvent.java index abf517f218..1de6c50c79 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingEquipmentChangeEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingEquipmentChangeEvent.java @@ -19,11 +19,9 @@ package net.minecraftforge.event.entity.living; -import net.minecraft.entity.LivingEntity; -import net.minecraft.inventory.EquipmentSlotType; -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.ItemStack; import javax.annotation.Nonnull; @@ -45,11 +43,11 @@ import javax.annotation.Nonnull; **/ public class LivingEquipmentChangeEvent extends LivingEvent { - private final EquipmentSlotType slot; + private final EquipmentSlot slot; private final ItemStack from; private final ItemStack to; - public LivingEquipmentChangeEvent(LivingEntity entity, EquipmentSlotType slot, @Nonnull ItemStack from, @Nonnull ItemStack to) + public LivingEquipmentChangeEvent(LivingEntity entity, EquipmentSlot slot, @Nonnull ItemStack from, @Nonnull ItemStack to) { super(entity); this.slot = slot; @@ -57,7 +55,7 @@ public class LivingEquipmentChangeEvent extends LivingEvent this.to = to; } - public EquipmentSlotType getSlot() { return this.slot; } + public EquipmentSlot getSlot() { return this.slot; } @Nonnull public ItemStack getFrom() { return this.from; } @Nonnull diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingEvent.java index db4914d30d..092641b948 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingEvent.java @@ -19,11 +19,9 @@ package net.minecraftforge.event.entity.living; -import net.minecraft.entity.Entity; +import net.minecraft.world.entity.Entity; import net.minecraftforge.eventbus.api.Cancelable; -import net.minecraft.entity.LivingEntity; -import net.minecraftforge.common.ForgeHooks; -import net.minecraftforge.common.MinecraftForge; +import net.minecraft.world.entity.LivingEntity; import net.minecraftforge.event.entity.EntityEvent; import javax.annotation.Nullable; diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingExperienceDropEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingExperienceDropEvent.java index 9f125f6779..e549625758 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingExperienceDropEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingExperienceDropEvent.java @@ -19,8 +19,8 @@ package net.minecraftforge.event.entity.living; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; import net.minecraftforge.eventbus.api.Cancelable; /** @@ -31,12 +31,12 @@ import net.minecraftforge.eventbus.api.Cancelable; @Cancelable public class LivingExperienceDropEvent extends LivingEvent { - private final PlayerEntity attackingPlayer; + private final Player attackingPlayer; private final int originalExperiencePoints; private int droppedExperiencePoints; - public LivingExperienceDropEvent(LivingEntity entity, PlayerEntity attackingPlayer, int originalExperience) + public LivingExperienceDropEvent(LivingEntity entity, Player attackingPlayer, int originalExperience) { super(entity); @@ -54,7 +54,7 @@ public class LivingExperienceDropEvent extends LivingEvent this.droppedExperiencePoints = droppedExperience; } - public PlayerEntity getAttackingPlayer() + public Player getAttackingPlayer() { return attackingPlayer; } diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingFallEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingFallEvent.java index 753ffc337e..cc94d35cc1 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingFallEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingFallEvent.java @@ -19,10 +19,8 @@ package net.minecraftforge.event.entity.living; -import net.minecraftforge.common.ForgeHooks; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.Cancelable; -import net.minecraft.entity.LivingEntity; +import net.minecraft.world.entity.LivingEntity; /** * LivingFallEvent is fired when an Entity is set to be falling.
diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingHealEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingHealEvent.java index 2a0c29bde2..35d3a04c3c 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingHealEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingHealEvent.java @@ -19,10 +19,8 @@ package net.minecraftforge.event.entity.living; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.eventbus.api.Cancelable; -import net.minecraft.entity.LivingEntity; +import net.minecraft.world.entity.LivingEntity; /** * LivingHealEvent is fired when an Entity is set to be healed.
diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingHurtEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingHurtEvent.java index 23c0910745..2cfb4d0e52 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingHurtEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingHurtEvent.java @@ -19,11 +19,8 @@ package net.minecraftforge.event.entity.living; -import net.minecraftforge.common.ForgeHooks; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.eventbus.api.Cancelable; -import net.minecraft.util.DamageSource; -import net.minecraft.entity.LivingEntity; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.LivingEntity; /** * LivingHurtEvent is fired when an Entity is set to be hurt.
diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingKnockBackEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingKnockBackEvent.java index e1f20bb8ac..d0c449f062 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingKnockBackEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingKnockBackEvent.java @@ -19,11 +19,7 @@ package net.minecraftforge.event.entity.living; -import net.minecraft.entity.Entity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.util.DamageSource; -import net.minecraftforge.common.ForgeHooks; -import net.minecraftforge.common.MinecraftForge; +import net.minecraft.world.entity.LivingEntity; import net.minecraftforge.eventbus.api.Cancelable; /** diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingPackSizeEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingPackSizeEvent.java index 8e941a6c20..c4dd9e0964 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingPackSizeEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingPackSizeEvent.java @@ -20,14 +20,14 @@ package net.minecraftforge.event.entity.living; import net.minecraftforge.eventbus.api.Event.HasResult; -import net.minecraft.entity.MobEntity; +import net.minecraft.world.entity.Mob; @HasResult public class LivingPackSizeEvent extends LivingEvent { private int maxPackSize; - public LivingPackSizeEvent(MobEntity entity) + public LivingPackSizeEvent(Mob entity) { super(entity); } diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingSetAttackTargetEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingSetAttackTargetEvent.java index 6cd34a6aca..61a3010332 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingSetAttackTargetEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingSetAttackTargetEvent.java @@ -19,9 +19,7 @@ package net.minecraftforge.event.entity.living; -import net.minecraft.entity.LivingEntity; -import net.minecraftforge.common.ForgeHooks; -import net.minecraftforge.common.MinecraftForge; +import net.minecraft.world.entity.LivingEntity; /** * LivingSetAttackTargetEvent is fired when an Entity sets a target to attack.
diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingSpawnEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingSpawnEvent.java index d19b4d1c54..1781db4bb4 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingSpawnEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingSpawnEvent.java @@ -20,14 +20,11 @@ package net.minecraftforge.event.entity.living; import javax.annotation.Nullable; -import net.minecraft.world.spawner.AbstractSpawner; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.ForgeEventFactory; -import net.minecraftforge.eventbus.api.Event; -import net.minecraft.entity.MobEntity; -import net.minecraft.entity.SpawnReason; -import net.minecraft.world.IWorld; -import net.minecraft.world.World; +import net.minecraft.world.level.BaseSpawner; +import net.minecraft.world.entity.Mob; +import net.minecraft.world.entity.MobSpawnType; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.Level; import net.minecraftforge.eventbus.api.Event.HasResult; @@ -45,12 +42,12 @@ import net.minecraftforge.eventbus.api.Event.HasResult; **/ public class LivingSpawnEvent extends LivingEvent { - private final IWorld world; + private final LevelAccessor world; private final double x; private final double y; private final double z; - public LivingSpawnEvent(MobEntity entity, IWorld world, double x, double y, double z) + public LivingSpawnEvent(Mob entity, LevelAccessor world, double x, double y, double z) { super(entity); this.world = world; @@ -59,7 +56,7 @@ public class LivingSpawnEvent extends LivingEvent this.z = z; } - public IWorld getWorld() { return world; } + public LevelAccessor getWorld() { return world; } public double getX() { return x; } public double getY() { return y; } public double getZ() { return z; } @@ -76,8 +73,8 @@ public class LivingSpawnEvent extends LivingEvent public static class CheckSpawn extends LivingSpawnEvent { @Nullable - private final AbstractSpawner spawner; - private final SpawnReason spawnReason; + private final BaseSpawner spawner; + private final MobSpawnType spawnReason; /** * CheckSpawn is fired when an Entity is about to be spawned. @@ -89,7 +86,7 @@ public class LivingSpawnEvent extends LivingEvent * @param spawner position of the MobSpawner * null if it this spawn is coming from a WorldSpawner */ - public CheckSpawn(MobEntity entity, IWorld world, double x, double y, double z, @Nullable AbstractSpawner spawner, SpawnReason spawnReason) + public CheckSpawn(Mob entity, LevelAccessor world, double x, double y, double z, @Nullable BaseSpawner spawner, MobSpawnType spawnReason) { super(entity, world, x, y, z); this.spawner = spawner; @@ -102,12 +99,12 @@ public class LivingSpawnEvent extends LivingEvent } @Nullable - public AbstractSpawner getSpawner() + public BaseSpawner getSpawner() { return spawner; } - public SpawnReason getSpawnReason() + public MobSpawnType getSpawnReason() { return spawnReason; } @@ -130,13 +127,13 @@ public class LivingSpawnEvent extends LivingEvent public static class SpecialSpawn extends LivingSpawnEvent { @Nullable - private final AbstractSpawner spawner; - private final SpawnReason spawnReason; + private final BaseSpawner spawner; + private final MobSpawnType spawnReason; /** * @param spawner the position of a tileentity or approximate position of an entity that initiated the spawn if any */ - public SpecialSpawn(MobEntity entity, World world, double x, double y, double z, @Nullable AbstractSpawner spawner, SpawnReason spawnReason) + public SpecialSpawn(Mob entity, Level world, double x, double y, double z, @Nullable BaseSpawner spawner, MobSpawnType spawnReason) { super(entity, world, x, y, z); this.spawner = spawner; @@ -144,12 +141,12 @@ public class LivingSpawnEvent extends LivingEvent } @Nullable - public AbstractSpawner getSpawner() + public BaseSpawner getSpawner() { return spawner; } - public SpawnReason getSpawnReason() + public MobSpawnType getSpawnReason() { return spawnReason; } @@ -171,7 +168,7 @@ public class LivingSpawnEvent extends LivingEvent @HasResult public static class AllowDespawn extends LivingSpawnEvent { - public AllowDespawn(MobEntity entity) + public AllowDespawn(Mob entity) { super(entity, entity.level, entity.getX(), entity.getY(), entity.getZ()); } diff --git a/src/main/java/net/minecraftforge/event/entity/living/LootingLevelEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LootingLevelEvent.java index aba7597de9..69f1bb32da 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LootingLevelEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LootingLevelEvent.java @@ -19,8 +19,8 @@ package net.minecraftforge.event.entity.living; -import net.minecraft.entity.LivingEntity; -import net.minecraft.util.DamageSource; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.damagesource.DamageSource; public class LootingLevelEvent extends LivingEvent { diff --git a/src/main/java/net/minecraftforge/event/entity/living/PotionColorCalculationEvent.java b/src/main/java/net/minecraftforge/event/entity/living/PotionColorCalculationEvent.java index fcbc3ad21b..58f51452e4 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/PotionColorCalculationEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/PotionColorCalculationEvent.java @@ -21,8 +21,8 @@ package net.minecraftforge.event.entity.living; import java.util.Collection; import java.util.Collections; -import net.minecraft.entity.LivingEntity; -import net.minecraft.potion.EffectInstance; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.effect.MobEffectInstance; /** * Fires after Potion Color Calculation. @@ -35,10 +35,10 @@ public class PotionColorCalculationEvent extends LivingEvent { private int color; private boolean hideParticle; - private final Collection effectList; + private final Collection effectList; public PotionColorCalculationEvent(LivingEntity entity, int color, boolean hideParticle, - Collection effectList) + Collection effectList) { super(entity); this.color = color; @@ -71,7 +71,7 @@ public class PotionColorCalculationEvent extends LivingEvent * * @return effects */ - public Collection getEffects() + public Collection getEffects() { return Collections.unmodifiableCollection(effectList); } diff --git a/src/main/java/net/minecraftforge/event/entity/living/PotionEvent.java b/src/main/java/net/minecraftforge/event/entity/living/PotionEvent.java index 4b7da2e265..b94e432f91 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/PotionEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/PotionEvent.java @@ -22,10 +22,9 @@ package net.minecraftforge.event.entity.living; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import net.minecraft.entity.LivingEntity; -import net.minecraft.potion.Effect; -import net.minecraft.potion.EffectInstance; -import net.minecraftforge.common.MinecraftForge; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.effect.MobEffect; +import net.minecraft.world.effect.MobEffectInstance; import net.minecraftforge.eventbus.api.Cancelable; import net.minecraftforge.eventbus.api.Event.HasResult; @@ -36,9 +35,9 @@ import net.minecraftforge.eventbus.api.Event.HasResult; public class PotionEvent extends LivingEvent { @Nullable - protected final EffectInstance effect; + protected final MobEffectInstance effect; - public PotionEvent(LivingEntity living, EffectInstance effect) + public PotionEvent(LivingEntity living, MobEffectInstance effect) { super(living); this.effect = effect; @@ -47,7 +46,7 @@ public class PotionEvent extends LivingEvent * Retuns the PotionEffect. */ @Nullable - public EffectInstance getPotionEffect() + public MobEffectInstance getPotionEffect() { return effect; } @@ -60,15 +59,15 @@ public class PotionEvent extends LivingEvent @Cancelable public static class PotionRemoveEvent extends PotionEvent { - private final Effect potion; + private final MobEffect potion; - public PotionRemoveEvent(LivingEntity living, Effect potion) + public PotionRemoveEvent(LivingEntity living, MobEffect potion) { super(living, living.getEffect(potion)); this.potion = potion; } - public PotionRemoveEvent(LivingEntity living, EffectInstance effect) + public PotionRemoveEvent(LivingEntity living, MobEffectInstance effect) { super(living, effect); this.potion = effect.getEffect(); @@ -77,7 +76,7 @@ public class PotionEvent extends LivingEvent /** * @return the Potion which is tried to remove from the Entity. */ - public Effect getPotion() + public MobEffect getPotion() { return this.potion; } @@ -87,7 +86,7 @@ public class PotionEvent extends LivingEvent */ @Override @Nullable - public EffectInstance getPotionEffect() + public MobEffectInstance getPotionEffect() { return super.getPotionEffect(); } @@ -104,7 +103,7 @@ public class PotionEvent extends LivingEvent @HasResult public static class PotionApplicableEvent extends PotionEvent { - public PotionApplicableEvent(LivingEntity living, EffectInstance effect) + public PotionApplicableEvent(LivingEntity living, MobEffectInstance effect) { super(living, effect); } @@ -114,7 +113,7 @@ public class PotionEvent extends LivingEvent */ @Override @Nonnull - public EffectInstance getPotionEffect() + public MobEffectInstance getPotionEffect() { return super.getPotionEffect(); } @@ -127,9 +126,9 @@ public class PotionEvent extends LivingEvent */ public static class PotionAddedEvent extends PotionEvent { - private final EffectInstance oldEffect; + private final MobEffectInstance oldEffect; - public PotionAddedEvent(LivingEntity living, EffectInstance oldEffect, EffectInstance newEffect) + public PotionAddedEvent(LivingEntity living, MobEffectInstance oldEffect, MobEffectInstance newEffect) { super(living, newEffect); this.oldEffect = oldEffect; @@ -140,7 +139,7 @@ public class PotionEvent extends LivingEvent */ @Override @Nonnull - public EffectInstance getPotionEffect() + public MobEffectInstance getPotionEffect() { return super.getPotionEffect(); } @@ -149,7 +148,7 @@ public class PotionEvent extends LivingEvent * @return the old PotionEffect. THis can be null if the entity did not have an effect of this kind before. */ @Nullable - public EffectInstance getOldPotionEffect() + public MobEffectInstance getOldPotionEffect() { return oldEffect; } @@ -162,7 +161,7 @@ public class PotionEvent extends LivingEvent */ public static class PotionExpiryEvent extends PotionEvent { - public PotionExpiryEvent(LivingEntity living, EffectInstance effect) + public PotionExpiryEvent(LivingEntity living, MobEffectInstance effect) { super(living, effect); } diff --git a/src/main/java/net/minecraftforge/event/entity/living/ZombieEvent.java b/src/main/java/net/minecraftforge/event/entity/living/ZombieEvent.java index ae50cd399f..25e7b3bbc2 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/ZombieEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/ZombieEvent.java @@ -19,15 +19,10 @@ package net.minecraftforge.event.entity.living; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.monster.ZombieEntity; -import net.minecraft.util.DamageSource; -import net.minecraft.world.World; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.ForgeEventFactory; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.monster.Zombie; +import net.minecraft.world.level.Level; import net.minecraftforge.event.entity.EntityEvent; -import net.minecraftforge.eventbus.api.Cancelable; -import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.eventbus.api.Event.HasResult; @@ -40,14 +35,14 @@ import net.minecraftforge.eventbus.api.Event.HasResult; **/ public class ZombieEvent extends EntityEvent { - public ZombieEvent(ZombieEntity entity) + public ZombieEvent(Zombie entity) { super(entity); } - public ZombieEntity getSummoner() + public Zombie getSummoner() { - return (ZombieEntity) getEntity(); + return (Zombie) getEntity(); } /** @@ -75,16 +70,16 @@ public class ZombieEvent extends EntityEvent { **/ @HasResult public static class SummonAidEvent extends ZombieEvent { - private ZombieEntity customSummonedAid; + private Zombie customSummonedAid; - private final World world; + private final Level world; private final int x; private final int y; private final int z; private final LivingEntity attacker; private final double summonChance; - public SummonAidEvent(ZombieEntity entity, World world, int x, int y, int z, LivingEntity attacker, double summonChance) + public SummonAidEvent(Zombie entity, Level world, int x, int y, int z, LivingEntity attacker, double summonChance) { super(entity); this.world = world; @@ -98,9 +93,9 @@ public class ZombieEvent extends EntityEvent { /** * Populate this field to have a custom zombie instead of a normal zombie summoned */ - public ZombieEntity getCustomSummonedAid() { return customSummonedAid; } - public void setCustomSummonedAid(ZombieEntity customSummonedAid) { this.customSummonedAid = customSummonedAid; } - public World getWorld() { return world; } + public Zombie getCustomSummonedAid() { return customSummonedAid; } + public void setCustomSummonedAid(Zombie customSummonedAid) { this.customSummonedAid = customSummonedAid; } + public Level getWorld() { return world; } public int getX() { return x; } public int getY() { return y; } public int getZ() { return z; } 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 1bc3573e26..385af41e22 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/AdvancementEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/AdvancementEvent.java @@ -20,8 +20,7 @@ package net.minecraftforge.event.entity.player; import net.minecraft.advancements.Advancement; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraftforge.common.MinecraftForge; +import net.minecraft.world.entity.player.Player; /** * This event is fired when a player gets an advancement. @@ -36,7 +35,7 @@ public class AdvancementEvent extends PlayerEvent { private final Advancement advancement; - public AdvancementEvent(PlayerEntity player, Advancement advancement) + public AdvancementEvent(Player player, Advancement advancement) { super(player); this.advancement = advancement; diff --git a/src/main/java/net/minecraftforge/event/entity/player/AnvilRepairEvent.java b/src/main/java/net/minecraftforge/event/entity/player/AnvilRepairEvent.java index 0caacd2855..8c7c297b59 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/AnvilRepairEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/AnvilRepairEvent.java @@ -19,8 +19,8 @@ package net.minecraftforge.event.entity.player; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; import javax.annotation.Nonnull; @@ -41,7 +41,7 @@ public class AnvilRepairEvent extends PlayerEvent private final ItemStack output; // Set this to set the output stack private float breakChance; // Anvil's chance to break (reduced by 1 durability) when this is complete. Default is 12% (0.12f) - public AnvilRepairEvent(PlayerEntity player, @Nonnull ItemStack left, @Nonnull ItemStack right, @Nonnull ItemStack output) + public AnvilRepairEvent(Player player, @Nonnull ItemStack left, @Nonnull ItemStack right, @Nonnull ItemStack output) { super(player); this.output = output; diff --git a/src/main/java/net/minecraftforge/event/entity/player/ArrowLooseEvent.java b/src/main/java/net/minecraftforge/event/entity/player/ArrowLooseEvent.java index 095009b2c7..8c5435bd1d 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/ArrowLooseEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/ArrowLooseEvent.java @@ -19,11 +19,10 @@ package net.minecraftforge.event.entity.player; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.Cancelable; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; import javax.annotation.Nonnull; @@ -46,11 +45,11 @@ import javax.annotation.Nonnull; public class ArrowLooseEvent extends PlayerEvent { private final ItemStack bow; - private final World world; + private final Level world; private final boolean hasAmmo; private int charge; - public ArrowLooseEvent(PlayerEntity player, @Nonnull ItemStack bow, World world, int charge, boolean hasAmmo) + public ArrowLooseEvent(Player player, @Nonnull ItemStack bow, Level world, int charge, boolean hasAmmo) { super(player); this.bow = bow; @@ -61,7 +60,7 @@ public class ArrowLooseEvent extends PlayerEvent @Nonnull public ItemStack getBow() { return this.bow; } - public World getWorld() { return this.world; } + public Level getWorld() { return this.world; } public boolean hasAmmo() { return this.hasAmmo; } public int getCharge() { return this.charge; } public void setCharge(int charge) { this.charge = charge; } diff --git a/src/main/java/net/minecraftforge/event/entity/player/ArrowNockEvent.java b/src/main/java/net/minecraftforge/event/entity/player/ArrowNockEvent.java index 015ca10d4a..6ccebaec02 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/ArrowNockEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/ArrowNockEvent.java @@ -19,12 +19,11 @@ package net.minecraftforge.event.entity.player; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ActionResult; -import net.minecraft.util.Hand; -import net.minecraft.world.World; -import net.minecraftforge.common.MinecraftForge; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.InteractionResultHolder; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.level.Level; import javax.annotation.Nonnull; @@ -38,12 +37,12 @@ import javax.annotation.Nonnull; public class ArrowNockEvent extends PlayerEvent { private final ItemStack bow; - private final Hand hand; - private final World world; + private final InteractionHand hand; + private final Level world; private final boolean hasAmmo; - private ActionResult action; + private InteractionResultHolder action; - public ArrowNockEvent(PlayerEntity player, @Nonnull ItemStack item, Hand hand, World world, boolean hasAmmo) + public ArrowNockEvent(Player player, @Nonnull ItemStack item, InteractionHand hand, Level world, boolean hasAmmo) { super(player); this.bow = item; @@ -54,15 +53,15 @@ public class ArrowNockEvent extends PlayerEvent @Nonnull public ItemStack getBow() { return this.bow; } - public World getWorld() { return this.world; } - public Hand getHand() { return this.hand; } + public Level getWorld() { return this.world; } + public InteractionHand getHand() { return this.hand; } public boolean hasAmmo() { return this.hasAmmo; } - public ActionResult getAction() + public InteractionResultHolder getAction() { return this.action; } - public void setAction(ActionResult action) + public void setAction(InteractionResultHolder action) { this.action = action; } diff --git a/src/main/java/net/minecraftforge/event/entity/player/AttackEntityEvent.java b/src/main/java/net/minecraftforge/event/entity/player/AttackEntityEvent.java index 467974dcf4..8db9534488 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/AttackEntityEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/AttackEntityEvent.java @@ -19,10 +19,9 @@ package net.minecraftforge.event.entity.player; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.Cancelable; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; /** * AttackEntityEvent is fired when a player attacks an Entity.
@@ -42,7 +41,7 @@ import net.minecraft.entity.player.PlayerEntity; public class AttackEntityEvent extends PlayerEvent { private final Entity target; - public AttackEntityEvent(PlayerEntity player, Entity target) + public AttackEntityEvent(Player player, Entity target) { super(player); this.target = target; diff --git a/src/main/java/net/minecraftforge/event/entity/player/BonemealEvent.java b/src/main/java/net/minecraftforge/event/entity/player/BonemealEvent.java index 063ed31e12..15aea29f97 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/BonemealEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/BonemealEvent.java @@ -20,11 +20,11 @@ package net.minecraftforge.event.entity.player; import net.minecraftforge.eventbus.api.Cancelable; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; import javax.annotation.Nonnull; @@ -42,12 +42,12 @@ import javax.annotation.Nonnull; public class BonemealEvent extends PlayerEvent { - private final World world; + private final Level world; private final BlockPos pos; private final BlockState block; private final ItemStack stack; - public BonemealEvent(@Nonnull PlayerEntity player, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull BlockState block, @Nonnull ItemStack stack) + public BonemealEvent(@Nonnull Player player, @Nonnull Level world, @Nonnull BlockPos pos, @Nonnull BlockState block, @Nonnull ItemStack stack) { super(player); this.world = world; @@ -56,7 +56,7 @@ public class BonemealEvent extends PlayerEvent this.stack = stack; } - public World getWorld() + public Level getWorld() { return world; } diff --git a/src/main/java/net/minecraftforge/event/entity/player/CriticalHitEvent.java b/src/main/java/net/minecraftforge/event/entity/player/CriticalHitEvent.java index 70d0cd4086..58f3774054 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/CriticalHitEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/CriticalHitEvent.java @@ -20,10 +20,8 @@ package net.minecraftforge.event.entity.player; import net.minecraftforge.eventbus.api.Event.HasResult; -import net.minecraftforge.eventbus.api.Cancelable; -import net.minecraftforge.common.MinecraftForge; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; /** * This event is fired whenever a player attacks an Entity in @@ -46,7 +44,7 @@ public class CriticalHitEvent extends PlayerEvent private final Entity target; private final boolean vanillaCritical; - public CriticalHitEvent(PlayerEntity player, Entity target, float damageModifier, boolean vanillaCritical) + public CriticalHitEvent(Player player, Entity target, float damageModifier, boolean vanillaCritical) { super(player); this.target = target; diff --git a/src/main/java/net/minecraftforge/event/entity/player/EntityItemPickupEvent.java b/src/main/java/net/minecraftforge/event/entity/player/EntityItemPickupEvent.java index 60180850af..8bc58380a0 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/EntityItemPickupEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/EntityItemPickupEvent.java @@ -21,8 +21,8 @@ package net.minecraftforge.event.entity.player; import net.minecraftforge.eventbus.api.Cancelable; import net.minecraftforge.eventbus.api.Event; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; /** * This event is called when a player collides with a EntityItem on the ground. @@ -40,7 +40,7 @@ public class EntityItemPickupEvent extends PlayerEvent { private final ItemEntity item; - public EntityItemPickupEvent(PlayerEntity player, ItemEntity item) + public EntityItemPickupEvent(Player player, ItemEntity item) { super(player); this.item = item; diff --git a/src/main/java/net/minecraftforge/event/entity/player/FillBucketEvent.java b/src/main/java/net/minecraftforge/event/entity/player/FillBucketEvent.java index 64f300b589..699cb2e4d0 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/FillBucketEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/FillBucketEvent.java @@ -21,10 +21,10 @@ package net.minecraftforge.event.entity.player; import net.minecraftforge.eventbus.api.Cancelable; import net.minecraftforge.eventbus.api.Event; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.world.World; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.level.Level; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -44,13 +44,13 @@ public class FillBucketEvent extends PlayerEvent { private final ItemStack current; - private final World world; + private final Level world; @Nullable - private final RayTraceResult target; + private final HitResult target; private ItemStack result; - public FillBucketEvent(PlayerEntity player, @Nonnull ItemStack current, World world, @Nullable RayTraceResult target) + public FillBucketEvent(Player player, @Nonnull ItemStack current, Level world, @Nullable HitResult target) { super(player); this.current = current; @@ -60,9 +60,9 @@ public class FillBucketEvent extends PlayerEvent @Nonnull public ItemStack getEmptyBucket() { return this.current; } - public World getWorld(){ return this.world; } + public Level getWorld(){ return this.world; } @Nullable - public RayTraceResult getTarget() { return this.target; } + public HitResult getTarget() { return this.target; } @Nonnull public ItemStack getFilledBucket() { return this.result; } public void setFilledBucket(@Nonnull ItemStack bucket) { this.result = bucket; } diff --git a/src/main/java/net/minecraftforge/event/entity/player/ItemFishedEvent.java b/src/main/java/net/minecraftforge/event/entity/player/ItemFishedEvent.java index cec99a7ff3..117a99c31a 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/ItemFishedEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/ItemFishedEvent.java @@ -20,9 +20,9 @@ package net.minecraftforge.event.entity.player; import com.google.common.base.Preconditions; -import net.minecraft.entity.projectile.FishingBobberEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; +import net.minecraft.world.entity.projectile.FishingHook; +import net.minecraft.world.item.ItemStack; +import net.minecraft.core.NonNullList; import net.minecraftforge.eventbus.api.Cancelable; import javax.annotation.Nonnegative; @@ -39,10 +39,10 @@ import java.util.List; public class ItemFishedEvent extends PlayerEvent { private final NonNullList stacks = NonNullList.create(); - private final FishingBobberEntity hook; + private final FishingHook hook; private int rodDamage; - public ItemFishedEvent(List stacks, int rodDamage, FishingBobberEntity hook) + public ItemFishedEvent(List stacks, int rodDamage, FishingHook hook) { super(hook.getPlayerOwner()); this.stacks.addAll(stacks); @@ -83,7 +83,7 @@ public class ItemFishedEvent extends PlayerEvent /** * Use this to stuff related to the hook itself, like the position of the bobber. */ - public FishingBobberEntity getHookEntity() + public FishingHook getHookEntity() { return hook; } diff --git a/src/main/java/net/minecraftforge/event/entity/player/ItemTooltipEvent.java b/src/main/java/net/minecraftforge/event/entity/player/ItemTooltipEvent.java index 236408a216..d5e44e87cf 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/ItemTooltipEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/ItemTooltipEvent.java @@ -21,27 +21,26 @@ package net.minecraftforge.event.entity.player; import java.util.List; -import net.minecraft.client.Minecraft; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.text.ITextComponent; +import net.minecraft.world.item.TooltipFlag; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.network.chat.Component; import javax.annotation.Nonnull; import javax.annotation.Nullable; public class ItemTooltipEvent extends PlayerEvent { - private final ITooltipFlag flags; + private final TooltipFlag flags; @Nonnull private final ItemStack itemStack; - private final List toolTip; + private final List toolTip; /** * This event is fired in {@link ItemStack#getTooltip(EntityPlayer, ITooltipFlag)}, which in turn is called from it's respective GUIContainer. * Tooltips are also gathered with a null entityPlayer during startup by {@link Minecraft#populateSearchTreeManager()}. */ - public ItemTooltipEvent(@Nonnull ItemStack itemStack, @Nullable PlayerEntity entityPlayer, List list, ITooltipFlag flags) + public ItemTooltipEvent(@Nonnull ItemStack itemStack, @Nullable Player entityPlayer, List list, TooltipFlag flags) { super(entityPlayer); this.itemStack = itemStack; @@ -52,7 +51,7 @@ public class ItemTooltipEvent extends PlayerEvent /** * Use to determine if the advanced information on item tooltips is being shown, toggled by F3+H. */ - public ITooltipFlag getFlags() + public TooltipFlag getFlags() { return flags; } @@ -69,7 +68,7 @@ public class ItemTooltipEvent extends PlayerEvent /** * The {@link ItemStack} tooltip. */ - public List getToolTip() + public List getToolTip() { return toolTip; } @@ -79,7 +78,7 @@ public class ItemTooltipEvent extends PlayerEvent */ @Override @Nullable - public PlayerEntity getPlayer() + public Player getPlayer() { return super.getPlayer(); } diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerContainerEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerContainerEvent.java index 496163303d..d26d474a20 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerContainerEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerContainerEvent.java @@ -19,13 +19,13 @@ package net.minecraftforge.event.entity.player; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.inventory.container.Container; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; public class PlayerContainerEvent extends PlayerEvent { - private final Container container; - public PlayerContainerEvent(PlayerEntity player, Container container) + private final AbstractContainerMenu container; + public PlayerContainerEvent(Player player, AbstractContainerMenu container) { super(player); this.container = container; @@ -33,20 +33,20 @@ public class PlayerContainerEvent extends PlayerEvent public static class Open extends PlayerContainerEvent { - public Open(PlayerEntity player, Container container) + public Open(Player player, AbstractContainerMenu container) { super(player, container); } } public static class Close extends PlayerContainerEvent { - public Close(PlayerEntity player, Container container) + public Close(Player player, AbstractContainerMenu container) { super(player, container); } } - public Container getContainer() + public AbstractContainerMenu getContainer() { return container; } diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerDestroyItemEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerDestroyItemEvent.java index 41e0ca9f55..de2087046a 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerDestroyItemEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerDestroyItemEvent.java @@ -19,21 +19,9 @@ package net.minecraftforge.event.entity.player; -import net.minecraft.client.entity.player.ClientPlayerEntity; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.client.multiplayer.PlayerController; -import net.minecraft.entity.Entity; -import net.minecraft.server.management.PlayerInteractionManager; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraftforge.common.ForgeHooks; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.ForgeEventFactory; -import net.minecraftforge.eventbus.api.Cancelable; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Hand; -import net.minecraft.util.Direction; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.InteractionHand; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -67,8 +55,8 @@ public class PlayerDestroyItemEvent extends PlayerEvent @Nonnull private final ItemStack original; @Nullable - private final Hand hand; // May be null if this player destroys the item by any use besides holding it. - public PlayerDestroyItemEvent(PlayerEntity player, @Nonnull ItemStack original, @Nullable Hand hand) + private final InteractionHand hand; // May be null if this player destroys the item by any use besides holding it. + public PlayerDestroyItemEvent(Player player, @Nonnull ItemStack original, @Nullable InteractionHand hand) { super(player); this.original = original; @@ -78,6 +66,6 @@ public class PlayerDestroyItemEvent extends PlayerEvent @Nonnull public ItemStack getOriginal() { return this.original; } @Nullable - public Hand getHand() { return this.hand; } + public InteractionHand getHand() { return this.hand; } } diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerEvent.java index 805b4e4ce7..cd4e9e186c 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerEvent.java @@ -21,23 +21,19 @@ package net.minecraftforge.event.entity.player; import java.io.File; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.util.RegistryKey; -import net.minecraft.world.GameType; -import net.minecraft.world.World; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.ForgeEventFactory; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.Container; +import net.minecraft.world.item.ItemStack; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.level.GameType; +import net.minecraft.world.level.Level; import net.minecraftforge.eventbus.api.Cancelable; -import net.minecraft.block.BlockState; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.ITextComponent; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.Component; import net.minecraftforge.event.entity.living.LivingEvent; -import net.minecraftforge.eventbus.api.Event; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -51,8 +47,8 @@ import javax.annotation.Nullable; **/ public class PlayerEvent extends LivingEvent { - private final PlayerEntity entityPlayer; - public PlayerEvent(PlayerEntity player) + private final Player entityPlayer; + public PlayerEvent(Player player) { super(player); entityPlayer = player; @@ -61,7 +57,7 @@ public class PlayerEvent extends LivingEvent /** * @return Player */ - public PlayerEntity getPlayer() { return entityPlayer; } + public Player getPlayer() { return entityPlayer; } /** * HarvestCheck is fired when a player attempts to harvest a block.
* This event is fired whenever a player attempts to harvest a block in @@ -83,7 +79,7 @@ public class PlayerEvent extends LivingEvent private final BlockState state; private boolean success; - public HarvestCheck(PlayerEntity player, BlockState state, boolean success) + public HarvestCheck(Player player, BlockState state, boolean success) { super(player); this.state = state; @@ -122,7 +118,7 @@ public class PlayerEvent extends LivingEvent private float newSpeed = 0.0f; private final BlockPos pos; // Y position of -1 notes unknown location - public BreakSpeed(PlayerEntity player, BlockState state, float original, BlockPos pos) + public BreakSpeed(Player player, BlockState state, float original, BlockPos pos) { super(player); this.state = state; @@ -156,27 +152,27 @@ public class PlayerEvent extends LivingEvent **/ public static class NameFormat extends PlayerEvent { - private final ITextComponent username; - private ITextComponent displayname; + private final Component username; + private Component displayname; - public NameFormat(PlayerEntity player, ITextComponent username) + public NameFormat(Player player, Component username) { super(player); this.username = username; this.setDisplayname(username); } - public ITextComponent getUsername() + public Component getUsername() { return username; } - public ITextComponent getDisplayname() + public Component getDisplayname() { return displayname; } - public void setDisplayname(ITextComponent displayname) + public void setDisplayname(Component displayname) { this.displayname = displayname; } @@ -200,20 +196,20 @@ public class PlayerEvent extends LivingEvent public static class TabListNameFormat extends PlayerEvent { @Nullable - private ITextComponent displayName; + private Component displayName; - public TabListNameFormat(PlayerEntity player) + public TabListNameFormat(Player player) { super(player); } @Nullable - public ITextComponent getDisplayName() + public Component getDisplayName() { return displayName; } - public void setDisplayName(@Nullable ITextComponent displayName) + public void setDisplayName(@Nullable Component displayName) { this.displayName = displayName; } @@ -225,10 +221,10 @@ public class PlayerEvent extends LivingEvent */ public static class Clone extends PlayerEvent { - private final PlayerEntity original; + private final Player original; private final boolean wasDeath; - public Clone(PlayerEntity _new, PlayerEntity oldPlayer, boolean wasDeath) + public Clone(Player _new, Player oldPlayer, boolean wasDeath) { super(_new); this.original = oldPlayer; @@ -238,7 +234,7 @@ public class PlayerEvent extends LivingEvent /** * The old EntityPlayer that this new entity is a clone of. */ - public PlayerEntity getOriginal() + public Player getOriginal() { return original; } @@ -261,7 +257,7 @@ public class PlayerEvent extends LivingEvent private final Entity target; - public StartTracking(PlayerEntity player, Entity target) + public StartTracking(Player player, Entity target) { super(player); this.target = target; @@ -284,7 +280,7 @@ public class PlayerEvent extends LivingEvent private final Entity target; - public StopTracking(PlayerEntity player, Entity target) + public StopTracking(Player player, Entity target) { super(player); this.target = target; @@ -309,7 +305,7 @@ public class PlayerEvent extends LivingEvent private final File playerDirectory; private final String playerUUID; - public LoadFromFile(PlayerEntity player, File originDirectory, String playerUUID) + public LoadFromFile(Player player, File originDirectory, String playerUUID) { super(player); this.playerDirectory = originDirectory; @@ -362,7 +358,7 @@ public class PlayerEvent extends LivingEvent private final File playerDirectory; private final String playerUUID; - public SaveToFile(PlayerEntity player, File originDirectory, String playerUUID) + public SaveToFile(Player player, File originDirectory, String playerUUID) { super(player); this.playerDirectory = originDirectory; @@ -399,40 +395,6 @@ public class PlayerEvent extends LivingEvent } } - /** - * TODO 1.17 remove, unused - * Fired when the world checks if a player is near enough to be attacked by an entity. - * The resulting visibility modifier is multiplied by the one calculated by Minecraft (based on sneaking and more) and used to calculate the radius a player has to be in (targetDistance*modifier). - * This can also be used to increase the visibility of a player, if it was decreased by Minecraft or other mods. But the resulting value cannot be higher than the standard target distance. - */ - @Deprecated - public static class Visibility extends PlayerEvent - { - - private double visibilityModifier = 1D; - - public Visibility(PlayerEntity player) - { - super(player); - } - - /** - * @param mod Is multiplied with the current modifier - */ - public void modifyVisibility(double mod) - { - visibilityModifier *= mod; - } - - /** - * @return The current modifier - */ - public double getVisibilityModifier() - { - return visibilityModifier; - } - } - public static class ItemPickupEvent extends PlayerEvent { /** * Original EntityItem with current remaining stack size @@ -442,7 +404,7 @@ public class PlayerEvent extends LivingEvent * Clone item stack, containing the item and amount picked up */ private final ItemStack stack; - public ItemPickupEvent(PlayerEntity player, ItemEntity entPickedUp, ItemStack stack) + public ItemPickupEvent(Player player, ItemEntity entPickedUp, ItemStack stack) { super(player); this.originalEntity = entPickedUp; @@ -461,8 +423,8 @@ public class PlayerEvent extends LivingEvent public static class ItemCraftedEvent extends PlayerEvent { @Nonnull private final ItemStack crafting; - private final IInventory craftMatrix; - public ItemCraftedEvent(PlayerEntity player, @Nonnull ItemStack crafting, IInventory craftMatrix) + private final Container craftMatrix; + public ItemCraftedEvent(Player player, @Nonnull ItemStack crafting, Container craftMatrix) { super(player); this.crafting = crafting; @@ -475,7 +437,7 @@ public class PlayerEvent extends LivingEvent return this.crafting; } - public IInventory getInventory() + public Container getInventory() { return this.craftMatrix; } @@ -484,7 +446,7 @@ public class PlayerEvent extends LivingEvent public static class ItemSmeltedEvent extends PlayerEvent { @Nonnull private final ItemStack smelting; - public ItemSmeltedEvent(PlayerEntity player, @Nonnull ItemStack crafting) + public ItemSmeltedEvent(Player player, @Nonnull ItemStack crafting) { super(player); this.smelting = crafting; @@ -498,14 +460,14 @@ public class PlayerEvent extends LivingEvent } public static class PlayerLoggedInEvent extends PlayerEvent { - public PlayerLoggedInEvent(PlayerEntity player) + public PlayerLoggedInEvent(Player player) { super(player); } } public static class PlayerLoggedOutEvent extends PlayerEvent { - public PlayerLoggedOutEvent(PlayerEntity player) + public PlayerLoggedOutEvent(Player player) { super(player); } @@ -514,7 +476,7 @@ public class PlayerEvent extends LivingEvent public static class PlayerRespawnEvent extends PlayerEvent { private final boolean endConquered; - public PlayerRespawnEvent(PlayerEntity player, boolean endConquered) + public PlayerRespawnEvent(Player player, boolean endConquered) { super(player); this.endConquered = endConquered; @@ -533,21 +495,21 @@ public class PlayerEvent extends LivingEvent } public static class PlayerChangedDimensionEvent extends PlayerEvent { - private final RegistryKey fromDim; - private final RegistryKey toDim; - public PlayerChangedDimensionEvent(PlayerEntity player, RegistryKey fromDim, RegistryKey toDim) + private final ResourceKey fromDim; + private final ResourceKey toDim; + public PlayerChangedDimensionEvent(Player player, ResourceKey fromDim, ResourceKey toDim) { super(player); this.fromDim = fromDim; this.toDim = toDim; } - public RegistryKey getFrom() + public ResourceKey getFrom() { return this.fromDim; } - public RegistryKey getTo() + public ResourceKey getTo() { return this.toDim; } @@ -563,7 +525,7 @@ public class PlayerEvent extends LivingEvent private final GameType currentGameMode; private GameType newGameMode; - public PlayerChangeGameModeEvent(PlayerEntity player, GameType currentGameMode, GameType newGameMode) + public PlayerChangeGameModeEvent(Player player, GameType currentGameMode, GameType newGameMode) { super(player); this.currentGameMode = currentGameMode; diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerFlyableFallEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerFlyableFallEvent.java index bbabf02c18..a43988ca8d 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerFlyableFallEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerFlyableFallEvent.java @@ -19,7 +19,7 @@ package net.minecraftforge.event.entity.player; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.entity.player.Player; /** * Occurs when a player falls, but is able to fly. Doesn't need to be cancelable, this is mainly for notification purposes. @@ -31,7 +31,7 @@ public class PlayerFlyableFallEvent extends PlayerEvent private float distance; private float multiplier; - public PlayerFlyableFallEvent(PlayerEntity player, float distance, float multiplier) + public PlayerFlyableFallEvent(Player player, float distance, float multiplier) { super(player); this.distance = distance; diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerInteractEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerInteractEvent.java index 684dc4b851..cc330eaecb 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerInteractEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerInteractEvent.java @@ -20,19 +20,16 @@ package net.minecraftforge.event.entity.player; import com.google.common.base.Preconditions; -import net.minecraft.block.Block; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; -import net.minecraftforge.common.MinecraftForge; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.Level; import net.minecraftforge.eventbus.api.Cancelable; import javax.annotation.Nonnull; @@ -50,13 +47,13 @@ import net.minecraftforge.fml.LogicalSide; **/ public class PlayerInteractEvent extends PlayerEvent { - private final Hand hand; + private final InteractionHand hand; private final BlockPos pos; @Nullable private final Direction face; - private ActionResultType cancellationResult = ActionResultType.PASS; + private InteractionResult cancellationResult = InteractionResult.PASS; - private PlayerInteractEvent(PlayerEntity player, Hand hand, BlockPos pos, @Nullable Direction face) + private PlayerInteractEvent(Player player, InteractionHand hand, BlockPos pos, @Nullable Direction face) { super(Preconditions.checkNotNull(player, "Null player in PlayerInteractEvent!")); this.hand = Preconditions.checkNotNull(hand, "Null hand in PlayerInteractEvent!"); @@ -76,10 +73,10 @@ public class PlayerInteractEvent extends PlayerEvent @Cancelable public static class EntityInteractSpecific extends PlayerInteractEvent { - private final Vector3d localPos; + private final Vec3 localPos; private final Entity target; - public EntityInteractSpecific(PlayerEntity player, Hand hand, Entity target, Vector3d localPos) + public EntityInteractSpecific(Player player, InteractionHand hand, Entity target, Vec3 localPos) { super(player, hand, target.blockPosition(), null); this.localPos = localPos; @@ -92,7 +89,7 @@ public class PlayerInteractEvent extends PlayerEvent * [-width / 2, width / 2] while Y values will be in the range [0, height] * @return The local position */ - public Vector3d getLocalPos() + public Vec3 getLocalPos() { return localPos; } @@ -119,7 +116,7 @@ public class PlayerInteractEvent extends PlayerEvent { private final Entity target; - public EntityInteract(PlayerEntity player, Hand hand, Entity target) + public EntityInteract(Player player, InteractionHand hand, Entity target) { super(player, hand, target.blockPosition(), null); this.target = target; @@ -149,14 +146,9 @@ public class PlayerInteractEvent extends PlayerEvent { private Result useBlock = DEFAULT; private Result useItem = DEFAULT; - private BlockRayTraceResult hitVec; + private BlockHitResult hitVec; - @Deprecated //Use RayTraceResult version. TODO: Remove 1.17 - public RightClickBlock(PlayerEntity player, Hand hand, BlockPos pos, Direction face) { - super(player, hand, pos, face); - } - - public RightClickBlock(PlayerEntity player, Hand hand, BlockPos pos, BlockRayTraceResult hitVec) { + public RightClickBlock(Player player, InteractionHand hand, BlockPos pos, BlockHitResult hitVec) { super(player, hand, pos, hitVec.getDirection()); this.hitVec = hitVec; } @@ -180,7 +172,7 @@ public class PlayerInteractEvent extends PlayerEvent /** * @return The ray trace result targeting the block. */ - public BlockRayTraceResult getHitVec() + public BlockHitResult getHitVec() { return hitVec; } @@ -228,7 +220,7 @@ public class PlayerInteractEvent extends PlayerEvent @Cancelable public static class RightClickItem extends PlayerInteractEvent { - public RightClickItem(PlayerEntity player, Hand hand) + public RightClickItem(Player player, InteractionHand hand) { super(player, hand, player.blockPosition(), null); } @@ -241,7 +233,7 @@ public class PlayerInteractEvent extends PlayerEvent */ public static class RightClickEmpty extends PlayerInteractEvent { - public RightClickEmpty(PlayerEntity player, Hand hand) + public RightClickEmpty(Player player, InteractionHand hand) { super(player, hand, player.blockPosition(), null); } @@ -265,9 +257,9 @@ public class PlayerInteractEvent extends PlayerEvent private Result useBlock = DEFAULT; private Result useItem = DEFAULT; - public LeftClickBlock(PlayerEntity player, BlockPos pos, Direction face) + public LeftClickBlock(Player player, BlockPos pos, Direction face) { - super(player, Hand.MAIN_HAND, pos, face); + super(player, InteractionHand.MAIN_HAND, pos, face); } /** @@ -315,9 +307,9 @@ public class PlayerInteractEvent extends PlayerEvent */ public static class LeftClickEmpty extends PlayerInteractEvent { - public LeftClickEmpty(PlayerEntity player) + public LeftClickEmpty(Player player) { - super(player, Hand.MAIN_HAND, player.blockPosition(), null); + super(player, InteractionHand.MAIN_HAND, player.blockPosition(), null); } } @@ -325,7 +317,7 @@ public class PlayerInteractEvent extends PlayerEvent * @return The hand involved in this interaction. Will never be null. */ @Nonnull - public Hand getHand() + public InteractionHand getHand() { return hand; } @@ -364,7 +356,7 @@ public class PlayerInteractEvent extends PlayerEvent /** * @return Convenience method to get the world of this interaction. */ - public World getWorld() + public Level getWorld() { return getPlayer().getCommandSenderWorld(); } @@ -382,7 +374,7 @@ public class PlayerInteractEvent extends PlayerEvent * method of the event. By default, this is {@link EnumActionResult#PASS}, meaning cancelled events will cause * the client to keep trying more interactions until something works. */ - public ActionResultType getCancellationResult() + public InteractionResult getCancellationResult() { return cancellationResult; } @@ -392,7 +384,7 @@ public class PlayerInteractEvent extends PlayerEvent * method of the event. * Note that this only has an effect on {@link RightClickBlock}, {@link RightClickItem}, {@link EntityInteract}, and {@link EntityInteractSpecific}. */ - public void setCancellationResult(ActionResultType result) + public void setCancellationResult(InteractionResult result) { this.cancellationResult = result; } diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerSetSpawnEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerSetSpawnEvent.java index 55303180dd..30c5bb152e 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerSetSpawnEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerSetSpawnEvent.java @@ -19,10 +19,10 @@ package net.minecraftforge.event.entity.player; -import net.minecraft.util.RegistryKey; -import net.minecraft.world.World; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.util.math.BlockPos; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.level.Level; +import net.minecraft.world.entity.player.Player; +import net.minecraft.core.BlockPos; import net.minecraftforge.eventbus.api.Cancelable; import javax.annotation.Nullable; @@ -34,12 +34,12 @@ import javax.annotation.Nullable; @Cancelable public class PlayerSetSpawnEvent extends PlayerEvent { - private final RegistryKey spawnWorld; + private final ResourceKey spawnWorld; private final boolean forced; @Nullable private final BlockPos newSpawn; - public PlayerSetSpawnEvent(PlayerEntity player, RegistryKey spawnWorld, @Nullable BlockPos newSpawn, boolean forced) + public PlayerSetSpawnEvent(Player player, ResourceKey spawnWorld, @Nullable BlockPos newSpawn, boolean forced) { super(player); this.spawnWorld = spawnWorld; @@ -61,7 +61,7 @@ public class PlayerSetSpawnEvent extends PlayerEvent return newSpawn; } - public RegistryKey getSpawnWorld() + public ResourceKey getSpawnWorld() { return spawnWorld; } diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerSleepInBedEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerSleepInBedEvent.java index aee5aba9ee..8d267b8114 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerSleepInBedEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerSleepInBedEvent.java @@ -19,10 +19,9 @@ package net.minecraftforge.event.entity.player; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerEntity.SleepResult; -import net.minecraft.util.math.BlockPos; -import net.minecraftforge.common.MinecraftForge; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.player.Player.BedSleepingProblem; +import net.minecraft.core.BlockPos; import java.util.Optional; @@ -40,21 +39,21 @@ import java.util.Optional; **/ public class PlayerSleepInBedEvent extends PlayerEvent { - private SleepResult result = null; + private BedSleepingProblem result = null; private final Optional pos; - public PlayerSleepInBedEvent(PlayerEntity player, Optional pos) + public PlayerSleepInBedEvent(Player player, Optional pos) { super(player); this.pos = pos; } - public SleepResult getResultStatus() + public BedSleepingProblem getResultStatus() { return result; } - public void setResult(SleepResult result) + public void setResult(BedSleepingProblem result) { this.result = result; } diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerWakeUpEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerWakeUpEvent.java index b9afd8197c..90775ef3d1 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerWakeUpEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerWakeUpEvent.java @@ -19,7 +19,7 @@ package net.minecraftforge.event.entity.player; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.entity.player.Player; /** * This event is fired when the player is waking up.
@@ -32,7 +32,7 @@ public class PlayerWakeUpEvent extends PlayerEvent private final boolean updateWorld; - public PlayerWakeUpEvent(PlayerEntity player, boolean wakeImmediately, boolean updateWorld) + public PlayerWakeUpEvent(Player player, boolean wakeImmediately, boolean updateWorld) { super(player); this.wakeImmediately = wakeImmediately; diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerXpEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerXpEvent.java index f44774805f..7f97a3837a 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerXpEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerXpEvent.java @@ -19,9 +19,8 @@ package net.minecraftforge.event.entity.player; -import net.minecraft.entity.item.ExperienceOrbEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraftforge.common.MinecraftForge; +import net.minecraft.world.entity.ExperienceOrb; +import net.minecraft.world.entity.player.Player; import net.minecraftforge.eventbus.api.Cancelable; /** @@ -34,7 +33,7 @@ import net.minecraftforge.eventbus.api.Cancelable; public class PlayerXpEvent extends PlayerEvent { - public PlayerXpEvent(PlayerEntity player) + public PlayerXpEvent(Player player) { super(player); } @@ -47,15 +46,15 @@ public class PlayerXpEvent extends PlayerEvent public static class PickupXp extends PlayerXpEvent { - private final ExperienceOrbEntity orb; + private final ExperienceOrb orb; - public PickupXp(PlayerEntity player, ExperienceOrbEntity orb) + public PickupXp(Player player, ExperienceOrb orb) { super(player); this.orb = orb; } - public ExperienceOrbEntity getOrb() + public ExperienceOrb getOrb() { return orb; } @@ -72,7 +71,7 @@ public class PlayerXpEvent extends PlayerEvent private int amount; - public XpChange(PlayerEntity player, int amount) + public XpChange(Player player, int amount) { super(player); this.amount = amount; @@ -100,7 +99,7 @@ public class PlayerXpEvent extends PlayerEvent private int levels; - public LevelChange(PlayerEntity player, int levels) + public LevelChange(Player player, int levels) { super(player); this.levels = levels; diff --git a/src/main/java/net/minecraftforge/event/entity/player/SleepingLocationCheckEvent.java b/src/main/java/net/minecraftforge/event/entity/player/SleepingLocationCheckEvent.java index 01948191c1..248e313d2b 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/SleepingLocationCheckEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/SleepingLocationCheckEvent.java @@ -19,10 +19,8 @@ package net.minecraftforge.event.entity.player; -import net.minecraft.block.Block; -import net.minecraft.entity.Entity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.core.BlockPos; import net.minecraftforge.event.entity.living.LivingEvent; import net.minecraftforge.eventbus.api.Event.HasResult; diff --git a/src/main/java/net/minecraftforge/event/entity/player/SleepingTimeCheckEvent.java b/src/main/java/net/minecraftforge/event/entity/player/SleepingTimeCheckEvent.java index 24eb6415ac..3701960242 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/SleepingTimeCheckEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/SleepingTimeCheckEvent.java @@ -19,9 +19,8 @@ package net.minecraftforge.event.entity.player; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.world.entity.player.Player; +import net.minecraft.core.BlockPos; import net.minecraftforge.eventbus.api.Event.HasResult; import java.util.Optional; @@ -40,7 +39,7 @@ public class SleepingTimeCheckEvent extends PlayerEvent { private final Optional sleepingLocation; - public SleepingTimeCheckEvent(PlayerEntity player, Optional sleepingLocation) + public SleepingTimeCheckEvent(Player player, Optional sleepingLocation) { super(player); this.sleepingLocation = sleepingLocation; diff --git a/src/main/java/net/minecraftforge/event/entity/player/UseHoeEvent.java b/src/main/java/net/minecraftforge/event/entity/player/UseHoeEvent.java index e0dfccd485..f987e99348 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/UseHoeEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/UseHoeEvent.java @@ -19,7 +19,7 @@ package net.minecraftforge.event.entity.player; -import net.minecraft.item.ItemUseContext; +import net.minecraft.world.item.context.UseOnContext; import net.minecraftforge.eventbus.api.Cancelable; import net.minecraftforge.eventbus.api.Event.HasResult; @@ -41,16 +41,16 @@ import javax.annotation.Nonnull; @Deprecated public class UseHoeEvent extends PlayerEvent { - private final ItemUseContext context;; + private final UseOnContext context;; - public UseHoeEvent(ItemUseContext context) + public UseHoeEvent(UseOnContext context) { super(context.getPlayer()); this.context = context; } @Nonnull - public ItemUseContext getContext() + public UseOnContext getContext() { return context; } diff --git a/src/main/java/net/minecraftforge/event/furnace/FurnaceFuelBurnTimeEvent.java b/src/main/java/net/minecraftforge/event/furnace/FurnaceFuelBurnTimeEvent.java index 4605095d7e..3cd55aeb78 100644 --- a/src/main/java/net/minecraftforge/event/furnace/FurnaceFuelBurnTimeEvent.java +++ b/src/main/java/net/minecraftforge/event/furnace/FurnaceFuelBurnTimeEvent.java @@ -22,9 +22,9 @@ package net.minecraftforge.event.furnace; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipeType; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.RecipeType; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.eventbus.api.Cancelable; @@ -49,16 +49,10 @@ public class FurnaceFuelBurnTimeEvent extends Event @Nonnull private final ItemStack itemStack; @Nullable - private final IRecipeType recipeType; + private final RecipeType recipeType; private int burnTime; - @Deprecated // use version with IRecipeType - public FurnaceFuelBurnTimeEvent(@Nonnull ItemStack itemStack, int burnTime) - { - this(itemStack, burnTime, null); - } - - public FurnaceFuelBurnTimeEvent(@Nonnull ItemStack itemStack, int burnTime, @Nullable IRecipeType recipeType) + public FurnaceFuelBurnTimeEvent(@Nonnull ItemStack itemStack, int burnTime, @Nullable RecipeType recipeType) { this.itemStack = itemStack; this.burnTime = burnTime; @@ -79,7 +73,7 @@ public class FurnaceFuelBurnTimeEvent extends Event * Get the recipe type for which to obtain the burn time, if known. */ @Nullable - public IRecipeType getRecipeType() + public RecipeType getRecipeType() { return recipeType; } diff --git a/src/main/java/net/minecraftforge/event/village/VillageSiegeEvent.java b/src/main/java/net/minecraftforge/event/village/VillageSiegeEvent.java index 37ec4f1b5f..2477c4f934 100644 --- a/src/main/java/net/minecraftforge/event/village/VillageSiegeEvent.java +++ b/src/main/java/net/minecraftforge/event/village/VillageSiegeEvent.java @@ -19,11 +19,10 @@ package net.minecraftforge.event.village; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.village.VillageSiege; -import net.minecraft.world.World; -import net.minecraftforge.common.MinecraftForge; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.entity.ai.village.VillageSiege; +import net.minecraft.world.level.Level; import net.minecraftforge.eventbus.api.Cancelable; import net.minecraftforge.eventbus.api.Event; @@ -41,11 +40,11 @@ import net.minecraftforge.eventbus.api.Event; public class VillageSiegeEvent extends Event { private final VillageSiege siege; - private final World world; - private final PlayerEntity player; - private final Vector3d attemptedSpawnPos; + private final Level world; + private final Player player; + private final Vec3 attemptedSpawnPos; - public VillageSiegeEvent(VillageSiege siege, World world, PlayerEntity player, Vector3d attemptedSpawnPos) + public VillageSiegeEvent(VillageSiege siege, Level world, Player player, Vec3 attemptedSpawnPos) { this.siege = siege; this.world = world; @@ -58,17 +57,17 @@ public class VillageSiegeEvent extends Event return siege; } - public World getWorld() + public Level getWorld() { return world; } - public PlayerEntity getPlayer() + public Player getPlayer() { return player; } - public Vector3d getAttemptedSpawnPos() + public Vec3 getAttemptedSpawnPos() { return attemptedSpawnPos; } diff --git a/src/main/java/net/minecraftforge/event/village/VillagerTradesEvent.java b/src/main/java/net/minecraftforge/event/village/VillagerTradesEvent.java index 541e60bb76..75a52a8eb5 100644 --- a/src/main/java/net/minecraftforge/event/village/VillagerTradesEvent.java +++ b/src/main/java/net/minecraftforge/event/village/VillagerTradesEvent.java @@ -22,13 +22,10 @@ package net.minecraftforge.event.village; import java.util.List; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; -import net.minecraft.entity.merchant.villager.VillagerData; -import net.minecraft.entity.merchant.villager.VillagerProfession; -import net.minecraft.entity.merchant.villager.VillagerTrades.ITrade; -import net.minecraftforge.common.BasicTrade; -import net.minecraftforge.common.MinecraftForge; +import net.minecraft.world.entity.npc.VillagerProfession; +import net.minecraft.world.entity.npc.VillagerTrades.ItemListing; import net.minecraftforge.eventbus.api.Event; -import net.minecraftforge.fml.event.server.FMLServerAboutToStartEvent; +import net.minecraftforge.fmlserverevents.FMLServerAboutToStartEvent; /** * VillagerTradesEvent is fired during the {@link FMLServerAboutToStartEvent}. It is used to gather the trade lists for each profession. @@ -43,16 +40,16 @@ import net.minecraftforge.fml.event.server.FMLServerAboutToStartEvent; public class VillagerTradesEvent extends Event { - protected Int2ObjectMap> trades; + protected Int2ObjectMap> trades; protected VillagerProfession type; - public VillagerTradesEvent(Int2ObjectMap> trades, VillagerProfession type) + public VillagerTradesEvent(Int2ObjectMap> trades, VillagerProfession type) { this.trades = trades; this.type = type; } - public Int2ObjectMap> getTrades() + public Int2ObjectMap> getTrades() { return trades; } diff --git a/src/main/java/net/minecraftforge/event/village/WandererTradesEvent.java b/src/main/java/net/minecraftforge/event/village/WandererTradesEvent.java index 5f74918d48..eec915e176 100644 --- a/src/main/java/net/minecraftforge/event/village/WandererTradesEvent.java +++ b/src/main/java/net/minecraftforge/event/village/WandererTradesEvent.java @@ -21,11 +21,9 @@ package net.minecraftforge.event.village; import java.util.List; -import net.minecraft.entity.merchant.villager.VillagerTrades.ITrade; -import net.minecraftforge.common.BasicTrade; -import net.minecraftforge.common.MinecraftForge; +import net.minecraft.world.entity.npc.VillagerTrades.ItemListing; import net.minecraftforge.eventbus.api.Event; -import net.minecraftforge.fml.event.server.FMLServerAboutToStartEvent; +import net.minecraftforge.fmlserverevents.FMLServerAboutToStartEvent; /** * WandererTradesEvent is fired during the {@link FMLServerAboutToStartEvent}. It is used to gather the trade lists for the wandering merchant. @@ -36,21 +34,21 @@ import net.minecraftforge.fml.event.server.FMLServerAboutToStartEvent; public class WandererTradesEvent extends Event { - protected List generic; - protected List rare; + protected List generic; + protected List rare; - public WandererTradesEvent(List generic, List rare) + public WandererTradesEvent(List generic, List rare) { this.generic = generic; this.rare = rare; } - public List getGenericTrades() + public List getGenericTrades() { return generic; } - public List getRareTrades() + public List getRareTrades() { return rare; } diff --git a/src/main/java/net/minecraftforge/event/world/BiomeLoadingEvent.java b/src/main/java/net/minecraftforge/event/world/BiomeLoadingEvent.java index 961a6c4b2c..9f167065d1 100644 --- a/src/main/java/net/minecraftforge/event/world/BiomeLoadingEvent.java +++ b/src/main/java/net/minecraftforge/event/world/BiomeLoadingEvent.java @@ -19,13 +19,12 @@ package net.minecraftforge.event.world; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.biome.Biome; -import net.minecraft.world.biome.BiomeAmbience; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.biome.Biome; +import net.minecraft.world.level.biome.BiomeSpecialEffects; import net.minecraftforge.common.world.BiomeGenerationSettingsBuilder; import net.minecraftforge.common.world.MobSpawnInfoBuilder; import net.minecraftforge.eventbus.api.Event; -import net.minecraftforge.eventbus.api.EventPriority; import javax.annotation.Nullable; @@ -46,15 +45,15 @@ import javax.annotation.Nullable; public class BiomeLoadingEvent extends Event { private final ResourceLocation name; - private Biome.Climate climate; - private Biome.Category category; + private Biome.ClimateSettings climate; + private Biome.BiomeCategory category; private float depth; private float scale; - private BiomeAmbience effects; + private BiomeSpecialEffects effects; private final BiomeGenerationSettingsBuilder gen; private final MobSpawnInfoBuilder spawns; - public BiomeLoadingEvent(@Nullable final ResourceLocation name, final Biome.Climate climate, final Biome.Category category, final float depth, final float scale, final BiomeAmbience effects, final BiomeGenerationSettingsBuilder gen, final MobSpawnInfoBuilder spawns) + public BiomeLoadingEvent(@Nullable final ResourceLocation name, final Biome.ClimateSettings climate, final Biome.BiomeCategory category, final float depth, final float scale, final BiomeSpecialEffects effects, final BiomeGenerationSettingsBuilder gen, final MobSpawnInfoBuilder spawns) { this.name = name; this.climate = climate; @@ -77,22 +76,22 @@ public class BiomeLoadingEvent extends Event return name; } - public Biome.Climate getClimate() + public Biome.ClimateSettings getClimate() { return climate; } - public void setClimate(final Biome.Climate value) + public void setClimate(final Biome.ClimateSettings value) { this.climate = value; } - public Biome.Category getCategory() + public Biome.BiomeCategory getCategory() { return category; } - public void setCategory(final Biome.Category value) + public void setCategory(final Biome.BiomeCategory value) { this.category = value; } @@ -117,12 +116,12 @@ public class BiomeLoadingEvent extends Event this.scale = value; } - public BiomeAmbience getEffects() + public BiomeSpecialEffects getEffects() { return effects; } - public void setEffects(final BiomeAmbience value) + public void setEffects(final BiomeSpecialEffects value) { this.effects = value; } diff --git a/src/main/java/net/minecraftforge/event/world/BlockEvent.java b/src/main/java/net/minecraftforge/event/world/BlockEvent.java index d68ab0eb57..d1bd1cb5c5 100644 --- a/src/main/java/net/minecraftforge/event/world/BlockEvent.java +++ b/src/main/java/net/minecraftforge/event/world/BlockEvent.java @@ -22,20 +22,18 @@ package net.minecraftforge.event.world; import java.util.EnumSet; import java.util.List; -import net.minecraft.block.NetherPortalBlock; -import net.minecraft.block.PortalSize; -import net.minecraft.block.BlockState; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.enchantment.Enchantments; -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.Direction; -import net.minecraft.world.IWorld; -import net.minecraft.world.IWorldReader; -import net.minecraft.world.World; +import net.minecraft.world.level.portal.PortalShape; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.enchantment.Enchantments; +import net.minecraft.world.item.ItemStack; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.Level; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.ToolType; import net.minecraftforge.common.util.BlockSnapshot; @@ -53,17 +51,17 @@ public class BlockEvent extends Event { private static final boolean DEBUG = Boolean.parseBoolean(System.getProperty("forge.debugBlockEvent", "false")); - private final IWorld world; + private final LevelAccessor world; private final BlockPos pos; private final BlockState state; - public BlockEvent(IWorld world, BlockPos pos, BlockState state) + public BlockEvent(LevelAccessor world, BlockPos pos, BlockState state) { this.pos = pos; this.world = world; this.state = state; } - public IWorld getWorld() + public LevelAccessor getWorld() { return world; } @@ -86,10 +84,10 @@ public class BlockEvent extends Event public static class BreakEvent extends BlockEvent { /** Reference to the Player who broke the block. If no player is available, use a EntityFakePlayer */ - private final PlayerEntity player; + private final Player player; private int exp; - public BreakEvent(World world, BlockPos pos, BlockState state, PlayerEntity player) + public BreakEvent(Level world, BlockPos pos, BlockState state, Player player) { super(world, pos, state); this.player = player; @@ -106,7 +104,7 @@ public class BlockEvent extends Event } } - public PlayerEntity getPlayer() + public Player getPlayer() { return player; } @@ -147,10 +145,10 @@ public class BlockEvent extends Event public EntityPlaceEvent(@Nonnull BlockSnapshot blockSnapshot, @Nonnull BlockState placedAgainst, @Nullable Entity entity) { - super(blockSnapshot.getWorld(), blockSnapshot.getPos(), !(entity instanceof PlayerEntity) ? blockSnapshot.getReplacedBlock() : blockSnapshot.getCurrentBlock()); + super(blockSnapshot.getWorld(), blockSnapshot.getPos(), !(entity instanceof Player) ? blockSnapshot.getReplacedBlock() : blockSnapshot.getCurrentBlock()); this.entity = entity; this.blockSnapshot = blockSnapshot; - this.placedBlock = !(entity instanceof PlayerEntity) ? blockSnapshot.getReplacedBlock() : blockSnapshot.getCurrentBlock(); + this.placedBlock = !(entity instanceof Player) ? blockSnapshot.getReplacedBlock() : blockSnapshot.getCurrentBlock(); this.placedAgainst = placedAgainst; if (DEBUG) @@ -210,7 +208,7 @@ public class BlockEvent extends Event private final EnumSet notifiedSides; private final boolean forceRedstoneUpdate; - public NeighborNotifyEvent(World world, BlockPos pos, BlockState state, EnumSet notifiedSides, boolean forceRedstoneUpdate) + public NeighborNotifyEvent(Level world, BlockPos pos, BlockState state, EnumSet notifiedSides, boolean forceRedstoneUpdate) { super(world, pos, state); this.notifiedSides = notifiedSides; @@ -246,18 +244,18 @@ public class BlockEvent extends Event @HasResult public static class CreateFluidSourceEvent extends Event { - private final IWorldReader world; + private final LevelReader world; private final BlockPos pos; private final BlockState state; - public CreateFluidSourceEvent(IWorldReader world, BlockPos pos, BlockState state) + public CreateFluidSourceEvent(LevelReader world, BlockPos pos, BlockState state) { this.world = world; this.pos = pos; this.state = state; } - public IWorldReader getWorld() + public LevelReader getWorld() { return world; } @@ -288,7 +286,7 @@ public class BlockEvent extends Event private BlockState newState; private BlockState origState; - public FluidPlaceBlockEvent(IWorld world, BlockPos pos, BlockPos liquidPos, BlockState state) + public FluidPlaceBlockEvent(LevelAccessor world, BlockPos pos, BlockPos liquidPos, BlockState state) { super(world, pos, state); this.liquidPos = liquidPos; @@ -332,7 +330,7 @@ public class BlockEvent extends Event */ public static class CropGrowEvent extends BlockEvent { - public CropGrowEvent(World world, BlockPos pos, BlockState state) + public CropGrowEvent(Level world, BlockPos pos, BlockState state) { super(world, pos, state); } @@ -351,7 +349,7 @@ public class BlockEvent extends Event @HasResult public static class Pre extends CropGrowEvent { - public Pre(World world, BlockPos pos, BlockState state) + public Pre(Level world, BlockPos pos, BlockState state) { super(world, pos, state); } @@ -369,7 +367,7 @@ public class BlockEvent extends Event public static class Post extends CropGrowEvent { private final BlockState originalState; - public Post(World world, BlockPos pos, BlockState original, BlockState state) + public Post(Level world, BlockPos pos, BlockState original, BlockState state) { super(world, pos, state); originalState = original; @@ -393,7 +391,7 @@ public class BlockEvent extends Event private final Entity entity; private final float fallDistance; - public FarmlandTrampleEvent(World world, BlockPos pos, BlockState state, float fallDistance, Entity entity) + public FarmlandTrampleEvent(Level world, BlockPos pos, BlockState state, float fallDistance, Entity entity) { super(world, pos, state); this.entity = entity; @@ -418,15 +416,15 @@ public class BlockEvent extends Event @Cancelable public static class PortalSpawnEvent extends BlockEvent { - private final PortalSize size; + private final PortalShape size; - public PortalSpawnEvent(IWorld world, BlockPos pos, BlockState state, PortalSize size) + public PortalSpawnEvent(LevelAccessor world, BlockPos pos, BlockState state, PortalShape size) { super(world, pos, state); this.size = size; } - public PortalSize getPortalSize() + public PortalShape getPortalSize() { return size; } @@ -434,7 +432,9 @@ public class BlockEvent extends Event /** * Fired when when this block is right clicked by a tool to change its state. - * For example: Used to determine if an axe can strip, a shovel can path, or a hoe can till. + * For example: Used to determine if an axe can strip or a shovel can path. + * For hoes, see {@link net.minecraft.world.item.HoeItem#TILLABLES} and + * {@link net.minecraftforge.event.entity.player.UseHoeEvent}. * * This event is {@link Cancelable}. If canceled, this will prevent the tool * from changing the block's state. @@ -443,12 +443,12 @@ public class BlockEvent extends Event public static class BlockToolInteractEvent extends BlockEvent { - private final PlayerEntity player; + private final Player player; private final ItemStack stack; private final ToolType toolType; private BlockState state; - public BlockToolInteractEvent(IWorld world, BlockPos pos, BlockState originalState, PlayerEntity player, ItemStack stack, ToolType toolType) + public BlockToolInteractEvent(LevelAccessor world, BlockPos pos, BlockState originalState, Player player, ItemStack stack, ToolType toolType) { super(world, pos, originalState); this.player = player; @@ -458,7 +458,7 @@ public class BlockEvent extends Event } /**Gets the player using the tool.*/ - public PlayerEntity getPlayer() + public Player getPlayer() { return player; } diff --git a/src/main/java/net/minecraftforge/event/world/ChunkDataEvent.java b/src/main/java/net/minecraftforge/event/world/ChunkDataEvent.java index 4f396d425b..509b3df3a6 100644 --- a/src/main/java/net/minecraftforge/event/world/ChunkDataEvent.java +++ b/src/main/java/net/minecraftforge/event/world/ChunkDataEvent.java @@ -19,15 +19,10 @@ package net.minecraftforge.event.world; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.world.IWorld; -import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; -import net.minecraft.world.chunk.ChunkStatus; -import net.minecraft.world.chunk.IChunk; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.eventbus.api.Cancelable; -import net.minecraftforge.eventbus.api.Event; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.chunk.ChunkStatus; +import net.minecraft.world.level.chunk.ChunkAccess; /** * ChunkDataEvent is fired when an event involving chunk data occurs.
@@ -40,21 +35,21 @@ import net.minecraftforge.eventbus.api.Event; **/ public class ChunkDataEvent extends ChunkEvent { - private final CompoundNBT data; + private final CompoundTag data; - public ChunkDataEvent(IChunk chunk, CompoundNBT data) + public ChunkDataEvent(ChunkAccess chunk, CompoundTag data) { super(chunk); this.data = data; } - public ChunkDataEvent(IChunk chunk, IWorld world, CompoundNBT data) + public ChunkDataEvent(ChunkAccess chunk, LevelAccessor world, CompoundTag data) { super(chunk, world); this.data = data; } - public CompoundNBT getData() + public CompoundTag getData() { return data; } @@ -72,15 +67,15 @@ public class ChunkDataEvent extends ChunkEvent **/ public static class Load extends ChunkDataEvent { - private ChunkStatus.Type status; + private ChunkStatus.ChunkType status; - public Load(IChunk chunk, CompoundNBT data, ChunkStatus.Type status) + public Load(ChunkAccess chunk, CompoundTag data, ChunkStatus.ChunkType status) { super(chunk, data); this.status = status; } - public ChunkStatus.Type getStatus() + public ChunkStatus.ChunkType getStatus() { return this.status; } @@ -99,7 +94,7 @@ public class ChunkDataEvent extends ChunkEvent **/ public static class Save extends ChunkDataEvent { - public Save(IChunk chunk, IWorld world, CompoundNBT data) + public Save(ChunkAccess chunk, LevelAccessor world, CompoundTag data) { super(chunk, world, data); } diff --git a/src/main/java/net/minecraftforge/event/world/ChunkEvent.java b/src/main/java/net/minecraftforge/event/world/ChunkEvent.java index aa15d11e8d..492651ff1f 100644 --- a/src/main/java/net/minecraftforge/event/world/ChunkEvent.java +++ b/src/main/java/net/minecraftforge/event/world/ChunkEvent.java @@ -19,9 +19,8 @@ package net.minecraftforge.event.world; -import net.minecraft.world.IWorld; -import net.minecraft.world.chunk.IChunk; -import net.minecraftforge.common.MinecraftForge; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.chunk.ChunkAccess; /** * ChunkEvent is fired when an event involving a chunk occurs.
@@ -34,21 +33,21 @@ import net.minecraftforge.common.MinecraftForge; **/ public class ChunkEvent extends WorldEvent { - private final IChunk chunk; + private final ChunkAccess chunk; - public ChunkEvent(IChunk chunk) + public ChunkEvent(ChunkAccess chunk) { super(chunk.getWorldForge()); this.chunk = chunk; } - public ChunkEvent(IChunk chunk, IWorld world) + public ChunkEvent(ChunkAccess chunk, LevelAccessor world) { super(world); this.chunk = chunk; } - public IChunk getChunk() + public ChunkAccess getChunk() { return chunk; } @@ -68,7 +67,7 @@ public class ChunkEvent extends WorldEvent **/ public static class Load extends ChunkEvent { - public Load(IChunk chunk) + public Load(ChunkAccess chunk) { super(chunk); } @@ -87,7 +86,7 @@ public class ChunkEvent extends WorldEvent **/ public static class Unload extends ChunkEvent { - public Unload(IChunk chunk) + public Unload(ChunkAccess chunk) { super(chunk); } diff --git a/src/main/java/net/minecraftforge/event/world/ChunkWatchEvent.java b/src/main/java/net/minecraftforge/event/world/ChunkWatchEvent.java index 7801327856..8ee3659a8c 100644 --- a/src/main/java/net/minecraftforge/event/world/ChunkWatchEvent.java +++ b/src/main/java/net/minecraftforge/event/world/ChunkWatchEvent.java @@ -19,9 +19,9 @@ package net.minecraftforge.event.world; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.util.math.ChunkPos; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.server.level.ServerLevel; import net.minecraftforge.eventbus.api.Event; /** @@ -40,18 +40,18 @@ import net.minecraftforge.eventbus.api.Event; **/ public class ChunkWatchEvent extends Event { - private final ServerWorld world; - private final ServerPlayerEntity player; + private final ServerLevel world; + private final ServerPlayer player; private final ChunkPos pos; - public ChunkWatchEvent(ServerPlayerEntity player, ChunkPos pos, ServerWorld world) + public ChunkWatchEvent(ServerPlayer player, ChunkPos pos, ServerLevel world) { this.player = player; this.pos = pos; this.world = world; } - public ServerPlayerEntity getPlayer() + public ServerPlayer getPlayer() { return this.player; } @@ -61,7 +61,7 @@ public class ChunkWatchEvent extends Event return this.pos; } - public ServerWorld getWorld() + public ServerLevel getWorld() { return this.world; } @@ -79,7 +79,7 @@ public class ChunkWatchEvent extends Event **/ public static class Watch extends ChunkWatchEvent { - public Watch(ServerPlayerEntity player, ChunkPos pos, ServerWorld world) {super(player, pos, world);} + public Watch(ServerPlayer player, ChunkPos pos, ServerLevel world) {super(player, pos, world);} } /** @@ -95,6 +95,6 @@ public class ChunkWatchEvent extends Event **/ public static class UnWatch extends ChunkWatchEvent { - public UnWatch(ServerPlayerEntity player, ChunkPos pos, ServerWorld world) {super(player, pos, world);} + public UnWatch(ServerPlayer player, ChunkPos pos, ServerLevel world) {super(player, pos, world);} } } diff --git a/src/main/java/net/minecraftforge/event/world/ExplosionEvent.java b/src/main/java/net/minecraftforge/event/world/ExplosionEvent.java index d24dc53ab9..180713e7f5 100644 --- a/src/main/java/net/minecraftforge/event/world/ExplosionEvent.java +++ b/src/main/java/net/minecraftforge/event/world/ExplosionEvent.java @@ -21,13 +21,12 @@ package net.minecraftforge.event.world; import java.util.List; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.Cancelable; import net.minecraftforge.eventbus.api.Event; -import net.minecraft.entity.Entity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.Explosion; -import net.minecraft.world.World; +import net.minecraft.world.entity.Entity; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Explosion; +import net.minecraft.world.level.Level; /** ExplosionEvent triggers when an explosion happens in the world.
*
@@ -41,16 +40,16 @@ import net.minecraft.world.World; */ public class ExplosionEvent extends Event { - private final World world; + private final Level world; private final Explosion explosion; - public ExplosionEvent(World world, Explosion explosion) + public ExplosionEvent(Level world, Explosion explosion) { this.world = world; this.explosion = explosion; } - public World getWorld() + public Level getWorld() { return world; } @@ -69,7 +68,7 @@ public class ExplosionEvent extends Event @Cancelable public static class Start extends ExplosionEvent { - public Start(World world, Explosion explosion) + public Start(Level world, Explosion explosion) { super(world, explosion); } @@ -85,7 +84,7 @@ public class ExplosionEvent extends Event { private final List entityList; - public Detonate(World world, Explosion explosion, List entityList) + public Detonate(Level world, Explosion explosion, List entityList) { super(world, explosion); this.entityList = entityList; diff --git a/src/main/java/net/minecraftforge/event/world/NoteBlockEvent.java b/src/main/java/net/minecraftforge/event/world/NoteBlockEvent.java index 315dba743d..d445f2b223 100644 --- a/src/main/java/net/minecraftforge/event/world/NoteBlockEvent.java +++ b/src/main/java/net/minecraftforge/event/world/NoteBlockEvent.java @@ -19,10 +19,10 @@ package net.minecraftforge.event.world; -import net.minecraft.block.BlockState; -import net.minecraft.state.properties.NoteBlockInstrument; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.NoteBlockInstrument; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; import net.minecraftforge.eventbus.api.Cancelable; import com.google.common.base.Preconditions; @@ -35,7 +35,7 @@ public class NoteBlockEvent extends BlockEvent { private int noteId; - protected NoteBlockEvent(World world, BlockPos pos, BlockState state, int note) + protected NoteBlockEvent(Level world, BlockPos pos, BlockState state, int note) { super(world, pos, state); this.noteId = note; @@ -89,7 +89,7 @@ public class NoteBlockEvent extends BlockEvent { private NoteBlockInstrument instrument; - public Play(World world, BlockPos pos, BlockState state, int note, NoteBlockInstrument instrument) + public Play(Level world, BlockPos pos, BlockState state, int note, NoteBlockInstrument instrument) { super(world, pos, state, note); this.instrument = instrument; @@ -116,7 +116,7 @@ public class NoteBlockEvent extends BlockEvent private final Note oldNote; private final Octave oldOctave; - public Change(World world, BlockPos pos, BlockState state, int oldNote, int newNote) + public Change(Level world, BlockPos pos, BlockState state, int oldNote, int newNote) { super(world, pos, state, newNote); this.oldNote = Note.fromId(oldNote); diff --git a/src/main/java/net/minecraftforge/event/world/PistonEvent.java b/src/main/java/net/minecraftforge/event/world/PistonEvent.java index 35f351babd..35063ef912 100644 --- a/src/main/java/net/minecraftforge/event/world/PistonEvent.java +++ b/src/main/java/net/minecraftforge/event/world/PistonEvent.java @@ -21,10 +21,10 @@ package net.minecraftforge.event.world; import javax.annotation.Nullable; -import net.minecraft.block.PistonBlockStructureHelper; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.world.level.block.piston.PistonStructureResolver; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; import net.minecraftforge.eventbus.api.Cancelable; /** @@ -42,7 +42,7 @@ public abstract class PistonEvent extends BlockEvent * @param direction - The direction of the piston * @param direction - The move direction of the piston */ - public PistonEvent(World world, BlockPos pos, Direction direction, PistonMoveType moveType) + public PistonEvent(Level world, BlockPos pos, Direction direction, PistonMoveType moveType) { super(world, pos, world.getBlockState(pos)); this.direction = direction; @@ -77,10 +77,10 @@ public abstract class PistonEvent extends BlockEvent * @return A piston structure helper for this movement. Returns null if the world stored is not a {@link World} */ @Nullable - public PistonBlockStructureHelper getStructureHelper() + public PistonStructureResolver getStructureHelper() { - if(this.getWorld() instanceof World) { - return new PistonBlockStructureHelper((World) this.getWorld(), this.getPos(), this.getDirection(), this.getPistonMoveType().isExtend); + if(this.getWorld() instanceof Level) { + return new PistonStructureResolver((Level) this.getWorld(), this.getPos(), this.getDirection(), this.getPistonMoveType().isExtend); } else { return null; } @@ -92,7 +92,7 @@ public abstract class PistonEvent extends BlockEvent public static class Post extends PistonEvent { - public Post(World world, BlockPos pos, Direction direction, PistonMoveType moveType) + public Post(Level world, BlockPos pos, Direction direction, PistonMoveType moveType) { super(world, pos, direction, moveType); } @@ -106,7 +106,7 @@ public abstract class PistonEvent extends BlockEvent public static class Pre extends PistonEvent { - public Pre(World world, BlockPos pos, Direction direction, PistonMoveType moveType) + public Pre(Level world, BlockPos pos, Direction direction, PistonMoveType moveType) { super(world, pos, direction, moveType); } diff --git a/src/main/java/net/minecraftforge/event/world/RegisterDimensionsEvent.java b/src/main/java/net/minecraftforge/event/world/RegisterDimensionsEvent.java index ef2079ccbf..3e00b23aaf 100644 --- a/src/main/java/net/minecraftforge/event/world/RegisterDimensionsEvent.java +++ b/src/main/java/net/minecraftforge/event/world/RegisterDimensionsEvent.java @@ -19,16 +19,6 @@ /*package net.minecraftforge.event.world; -import java.util.Collections; -import java.util.Map; -import java.util.Set; - -import javax.annotation.Nullable; - -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.common.DimensionManager.SavedEntry; -import net.minecraftforge.eventbus.api.Event; - /** * Register all of your custom ModDimensons here, fired during server loading when * dimension data is read from the world file. diff --git a/src/main/java/net/minecraftforge/event/world/SaplingGrowTreeEvent.java b/src/main/java/net/minecraftforge/event/world/SaplingGrowTreeEvent.java index 87094ef5f1..4774a5fbf2 100644 --- a/src/main/java/net/minecraftforge/event/world/SaplingGrowTreeEvent.java +++ b/src/main/java/net/minecraftforge/event/world/SaplingGrowTreeEvent.java @@ -21,10 +21,8 @@ package net.minecraftforge.event.world; import java.util.Random; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IWorld; -import net.minecraft.world.World; -import net.minecraftforge.common.MinecraftForge; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.LevelAccessor; import net.minecraftforge.eventbus.api.Event.HasResult; /** @@ -48,7 +46,7 @@ public class SaplingGrowTreeEvent extends WorldEvent private final BlockPos pos; private final Random rand; - public SaplingGrowTreeEvent(IWorld world, Random rand, BlockPos pos) + public SaplingGrowTreeEvent(LevelAccessor world, Random rand, BlockPos pos) { super(world); this.rand = rand; diff --git a/src/main/java/net/minecraftforge/event/world/SleepFinishedTimeEvent.java b/src/main/java/net/minecraftforge/event/world/SleepFinishedTimeEvent.java index 2536b65b3c..3517109e00 100644 --- a/src/main/java/net/minecraftforge/event/world/SleepFinishedTimeEvent.java +++ b/src/main/java/net/minecraftforge/event/world/SleepFinishedTimeEvent.java @@ -19,7 +19,7 @@ package net.minecraftforge.event.world; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.server.level.ServerLevel; /** * This event is fired when all players are asleep and the time should be set to day.
@@ -31,7 +31,7 @@ public class SleepFinishedTimeEvent extends WorldEvent private long newTime; private final long minTime; - public SleepFinishedTimeEvent(ServerWorld worldIn, long newTimeIn, long minTimeIn) + public SleepFinishedTimeEvent(ServerLevel worldIn, long newTimeIn, long minTimeIn) { super(worldIn); this.newTime = newTimeIn; diff --git a/src/main/java/net/minecraftforge/event/world/StructureSpawnListGatherEvent.java b/src/main/java/net/minecraftforge/event/world/StructureSpawnListGatherEvent.java index 2f8c0c6998..28e9e3aaa3 100644 --- a/src/main/java/net/minecraftforge/event/world/StructureSpawnListGatherEvent.java +++ b/src/main/java/net/minecraftforge/event/world/StructureSpawnListGatherEvent.java @@ -24,11 +24,10 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; -import net.minecraft.entity.EntityClassification; -import net.minecraft.world.biome.MobSpawnInfo; -import net.minecraft.world.gen.feature.structure.Structure; +import net.minecraft.world.entity.MobCategory; +import net.minecraft.world.level.biome.MobSpawnSettings; +import net.minecraft.world.level.levelgen.feature.StructureFeature; import net.minecraftforge.eventbus.api.Event; -import net.minecraftforge.eventbus.api.EventPriority; /** * This event fires when a Structure is gathering what mobs/creatures can spawn in it. @@ -46,24 +45,24 @@ import net.minecraftforge.eventbus.api.EventPriority; public class StructureSpawnListGatherEvent extends Event { - private final Structure structure; - private final Map> entitySpawns = new HashMap<>(); - private final Map> entitySpawnsUnmodifiableLists = new HashMap<>(); - private final Map> entitySpawnsUnmodifiable = Collections.unmodifiableMap(entitySpawnsUnmodifiableLists); + private final StructureFeature structure; + private final Map> entitySpawns = new HashMap<>(); + private final Map> entitySpawnsUnmodifiableLists = new HashMap<>(); + private final Map> entitySpawnsUnmodifiable = Collections.unmodifiableMap(entitySpawnsUnmodifiableLists); private boolean insideOnly; - public StructureSpawnListGatherEvent(Structure structure) + public StructureSpawnListGatherEvent(StructureFeature structure) { this.structure = structure; this.insideOnly = this.structure.getDefaultRestrictsSpawnsToInside(); - addEntitySpawns(EntityClassification.MONSTER, this.structure.getDefaultSpawnList()); - addEntitySpawns(EntityClassification.CREATURE, this.structure.getDefaultCreatureSpawnList()); + addEntitySpawns(MobCategory.MONSTER, this.structure.getDefaultSpawnList()); + addEntitySpawns(MobCategory.CREATURE, this.structure.getDefaultCreatureSpawnList()); } /** * @return Structure to add or remove spawns to/from. */ - public Structure getStructure() + public StructureFeature getStructure() { return structure; } @@ -90,7 +89,7 @@ public class StructureSpawnListGatherEvent extends Event * @param classification Entity Classification * @return The list of spawns for the given classification. */ - public List getEntitySpawns(EntityClassification classification) + public List getEntitySpawns(MobCategory classification) { return this.entitySpawnsUnmodifiableLists.getOrDefault(classification, Collections.emptyList()); } @@ -98,10 +97,10 @@ public class StructureSpawnListGatherEvent extends Event /** * Gets the internal spawn list for a given entity classification, or adds one if needed. (This includes adding it to the unmodifiable view) */ - private List getOrCreateEntitySpawns(EntityClassification classification) + private List getOrCreateEntitySpawns(MobCategory classification) { return this.entitySpawns.computeIfAbsent(classification, c -> { - List spawners = new ArrayList<>(); + List spawners = new ArrayList<>(); //If the classification isn't in entitySpawns yet, also add an unmodifiable view of the list to // the unmodifiable list spawn map this.entitySpawnsUnmodifiableLists.put(c, Collections.unmodifiableList(spawners)); @@ -114,7 +113,7 @@ public class StructureSpawnListGatherEvent extends Event * @param classification Entity Classification * @param spawner Spawner */ - public void addEntitySpawn(EntityClassification classification, MobSpawnInfo.Spawners spawner) + public void addEntitySpawn(MobCategory classification, MobSpawnSettings.SpawnerData spawner) { getOrCreateEntitySpawns(classification).add(spawner); } @@ -124,7 +123,7 @@ public class StructureSpawnListGatherEvent extends Event * @param classification Entity Classification * @param spawners Spawners to add */ - public void addEntitySpawns(EntityClassification classification, List spawners) + public void addEntitySpawns(MobCategory classification, List spawners) { getOrCreateEntitySpawns(classification).addAll(spawners); } @@ -134,7 +133,7 @@ public class StructureSpawnListGatherEvent extends Event * @param classification Entity Classification * @param spawner Spawner */ - public void removeEntitySpawn(EntityClassification classification, MobSpawnInfo.Spawners spawner) + public void removeEntitySpawn(MobCategory classification, MobSpawnSettings.SpawnerData spawner) { if (this.entitySpawns.containsKey(classification)) this.entitySpawns.get(classification).remove(spawner); @@ -143,7 +142,7 @@ public class StructureSpawnListGatherEvent extends Event /** * Gets an unmodifiable view of the map of spawns based on entity classification that is used to fill in the various spawn lists for the structure. */ - public Map> getEntitySpawns() + public Map> getEntitySpawns() { return entitySpawnsUnmodifiable; } diff --git a/src/main/java/net/minecraftforge/event/world/WorldEvent.java b/src/main/java/net/minecraftforge/event/world/WorldEvent.java index 438cebcb48..7451c30201 100644 --- a/src/main/java/net/minecraftforge/event/world/WorldEvent.java +++ b/src/main/java/net/minecraftforge/event/world/WorldEvent.java @@ -22,18 +22,11 @@ package net.minecraftforge.event.world; import java.util.ArrayList; import java.util.List; -import net.minecraft.client.Minecraft; -import net.minecraft.entity.EntityClassification; -import net.minecraft.profiler.Profiler; -import net.minecraft.server.MinecraftServer; -import net.minecraft.server.integrated.IntegratedServer; -import net.minecraft.util.IProgressUpdate; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IWorld; -import net.minecraft.world.WorldSettings; -import net.minecraft.world.biome.MobSpawnInfo; -import net.minecraft.world.storage.IServerWorldInfo; -import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraft.world.entity.MobCategory; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.biome.MobSpawnSettings; +import net.minecraft.world.level.storage.ServerLevelData; import net.minecraftforge.eventbus.api.Event; /** @@ -47,14 +40,14 @@ import net.minecraftforge.eventbus.api.Event; **/ public class WorldEvent extends Event { - private final IWorld world; + private final LevelAccessor world; - public WorldEvent(IWorld world) + public WorldEvent(LevelAccessor world) { this.world = world; } - public IWorld getWorld() + public LevelAccessor getWorld() { return world; } @@ -76,7 +69,7 @@ public class WorldEvent extends Event **/ public static class Load extends WorldEvent { - public Load(IWorld world) { super(world); } + public Load(LevelAccessor world) { super(world); } } /** @@ -95,7 +88,7 @@ public class WorldEvent extends Event **/ public static class Unload extends WorldEvent { - public Unload(IWorld world) { super(world); } + public Unload(LevelAccessor world) { super(world); } } /** @@ -112,49 +105,7 @@ public class WorldEvent extends Event **/ public static class Save extends WorldEvent { - public Save(IWorld world) { super(world); } - } - - /** - * Called by WorldServer to gather a list of all possible entities that can spawn at the specified location. - * If an entry is added to the list, it needs to be a globally unique instance. - * The event is called in {@link WorldServer#getSpawnListEntryForTypeAt(EnumCreatureType, BlockPos)} as well as - * {@link WorldServer#canCreatureTypeSpawnHere(EnumCreatureType, SpawnListEntry, BlockPos)} - * where the latter checks for identity, meaning both events must add the same instance. - * Canceling the event will result in a empty list, meaning no entity will be spawned. - */ - @net.minecraftforge.eventbus.api.Cancelable - public static class PotentialSpawns extends WorldEvent - { - private final EntityClassification type; - private final BlockPos pos; - private final List list; - - public PotentialSpawns(IWorld world, EntityClassification type, BlockPos pos, List oldList) - { - super(world); - this.pos = pos; - this.type = type; - if (oldList != null) - this.list = new ArrayList<>(oldList); - else - this.list = new ArrayList<>(); - } - - public EntityClassification getType() - { - return type; - } - - public BlockPos getPos() - { - return pos; - } - - public List getList() - { - return list; - } + public Save(LevelAccessor world) { super(world); } } /** @@ -164,14 +115,14 @@ public class WorldEvent extends Event @net.minecraftforge.eventbus.api.Cancelable public static class CreateSpawnPosition extends WorldEvent { - private final IServerWorldInfo settings; - public CreateSpawnPosition(IWorld world, IServerWorldInfo settings) + private final ServerLevelData settings; + public CreateSpawnPosition(LevelAccessor world, ServerLevelData settings) { super(world); this.settings = settings; } - public IServerWorldInfo getSettings() + public ServerLevelData getSettings() { return settings; } diff --git a/src/main/java/net/minecraftforge/fluids/DispenseFluidContainer.java b/src/main/java/net/minecraftforge/fluids/DispenseFluidContainer.java index c074872133..e0f0fd1ab8 100644 --- a/src/main/java/net/minecraftforge/fluids/DispenseFluidContainer.java +++ b/src/main/java/net/minecraftforge/fluids/DispenseFluidContainer.java @@ -21,15 +21,15 @@ package net.minecraftforge.fluids; import javax.annotation.Nonnull; -import net.minecraft.block.DispenserBlock; -import net.minecraft.dispenser.DefaultDispenseItemBehavior; -import net.minecraft.dispenser.IBlockSource; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.DispenserTileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.world.level.block.DispenserBlock; +import net.minecraft.core.dispenser.DefaultDispenseItemBehavior; +import net.minecraft.core.BlockSource; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.entity.DispenserBlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandlerItem; @@ -51,7 +51,7 @@ public class DispenseFluidContainer extends DefaultDispenseItemBehavior @Override @Nonnull - public ItemStack execute(@Nonnull IBlockSource source, @Nonnull ItemStack stack) + public ItemStack execute(@Nonnull BlockSource source, @Nonnull ItemStack stack) { if (FluidUtil.getFluidContained(stack).isPresent()) { @@ -67,9 +67,9 @@ public class DispenseFluidContainer extends DefaultDispenseItemBehavior * Picks up fluid in front of a Dispenser and fills a container with it. */ @Nonnull - private ItemStack fillContainer(@Nonnull IBlockSource source, @Nonnull ItemStack stack) + private ItemStack fillContainer(@Nonnull BlockSource source, @Nonnull ItemStack stack) { - World world = source.getLevel(); + Level world = source.getLevel(); Direction dispenserFacing = source.getBlockState().getValue(DispenserBlock.FACING); BlockPos blockpos = source.getPos().relative(dispenserFacing); @@ -85,7 +85,7 @@ public class DispenseFluidContainer extends DefaultDispenseItemBehavior { return resultStack; } - else if (((DispenserTileEntity)source.getEntity()).addItem(resultStack) < 0) + else if (((DispenserBlockEntity)source.getEntity()).addItem(resultStack) < 0) { this.dispenseBehavior.dispense(source, resultStack); } @@ -99,7 +99,7 @@ public class DispenseFluidContainer extends DefaultDispenseItemBehavior * Drains a filled container and places the fluid in front of the Dispenser. */ @Nonnull - private ItemStack dumpContainer(IBlockSource source, @Nonnull ItemStack stack) + private ItemStack dumpContainer(BlockSource source, @Nonnull ItemStack stack) { ItemStack singleStack = stack.copy(); singleStack.setCount(1); @@ -112,7 +112,7 @@ public class DispenseFluidContainer extends DefaultDispenseItemBehavior FluidStack fluidStack = fluidHandler.drain(FluidAttributes.BUCKET_VOLUME, IFluidHandler.FluidAction.EXECUTE); Direction dispenserFacing = source.getBlockState().getValue(DispenserBlock.FACING); BlockPos blockpos = source.getPos().relative(dispenserFacing); - FluidActionResult result = FluidUtil.tryPlaceFluid(null, source.getLevel(), Hand.MAIN_HAND, blockpos, stack, fluidStack); + FluidActionResult result = FluidUtil.tryPlaceFluid(null, source.getLevel(), InteractionHand.MAIN_HAND, blockpos, stack, fluidStack); if (result.isSuccess()) { @@ -122,7 +122,7 @@ public class DispenseFluidContainer extends DefaultDispenseItemBehavior { return drainedStack; } - else if (!drainedStack.isEmpty() && ((DispenserTileEntity)source.getEntity()).addItem(drainedStack) < 0) + else if (!drainedStack.isEmpty() && ((DispenserBlockEntity)source.getEntity()).addItem(drainedStack) < 0) { this.dispenseBehavior.dispense(source, drainedStack); } diff --git a/src/main/java/net/minecraftforge/fluids/FluidActionResult.java b/src/main/java/net/minecraftforge/fluids/FluidActionResult.java index 3cd65d0854..248b5b310d 100644 --- a/src/main/java/net/minecraftforge/fluids/FluidActionResult.java +++ b/src/main/java/net/minecraftforge/fluids/FluidActionResult.java @@ -21,7 +21,7 @@ package net.minecraftforge.fluids; import javax.annotation.Nonnull; -import net.minecraft.item.ItemStack; +import net.minecraft.world.item.ItemStack; /** * Holds the result of a fluid action from {@link FluidUtil}. diff --git a/src/main/java/net/minecraftforge/fluids/FluidAttributes.java b/src/main/java/net/minecraftforge/fluids/FluidAttributes.java index 0d5de2274b..ecc8d87d87 100644 --- a/src/main/java/net/minecraftforge/fluids/FluidAttributes.java +++ b/src/main/java/net/minecraftforge/fluids/FluidAttributes.java @@ -21,24 +21,29 @@ package net.minecraftforge.fluids; import javax.annotation.Nullable; -import net.minecraft.block.BlockState; -import net.minecraft.fluid.Fluid; -import net.minecraft.fluid.FluidState; -import net.minecraft.item.ItemStack; -import net.minecraft.particles.ParticleTypes; -import net.minecraft.util.*; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TranslationTextComponent; -import net.minecraft.world.IBlockDisplayReader; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.item.ItemStack; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.world.level.BlockAndTintGetter; import java.util.function.BiFunction; import java.util.stream.Stream; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraft.item.Rarity; -import net.minecraft.world.biome.BiomeColors; +import net.minecraft.world.entity.player.Player; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; +import net.minecraft.world.item.Rarity; +import net.minecraft.client.renderer.BiomeColors; + +import net.minecraft.Util; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.sounds.SoundSource; /** * Minecraft Forge Fluid Implementation @@ -152,24 +157,24 @@ public class FluidAttributes return new ItemStack(stack.getFluid().getBucket()); } - public BlockState getBlock(IBlockDisplayReader reader, BlockPos pos, FluidState state) + public BlockState getBlock(BlockAndTintGetter reader, BlockPos pos, FluidState state) { return state.createLegacyBlock(); } - public FluidState getStateForPlacement(IBlockDisplayReader reader, BlockPos pos, FluidStack state) + public FluidState getStateForPlacement(BlockAndTintGetter reader, BlockPos pos, FluidStack state) { return state.getFluid().defaultFluidState(); } - public final boolean canBePlacedInWorld(IBlockDisplayReader reader, BlockPos pos, FluidState state) + public final boolean canBePlacedInWorld(BlockAndTintGetter reader, BlockPos pos, FluidState state) { - return !getBlock(reader, pos, state).isAir(reader, pos); + return !getBlock(reader, pos, state).isAir(); } - public final boolean canBePlacedInWorld(IBlockDisplayReader reader, BlockPos pos, FluidStack state) + public final boolean canBePlacedInWorld(BlockAndTintGetter reader, BlockPos pos, FluidStack state) { - return !getBlock(reader, pos, getStateForPlacement(reader, pos, state)).isAir(reader, pos); + return !getBlock(reader, pos, getStateForPlacement(reader, pos, state)).isAir(); } public final boolean isLighterThanAir() @@ -186,12 +191,12 @@ public class FluidAttributes * @param fluidStack The fluidStack is trying to be placed. * @return true if this fluid should vaporize in dimensions where water vaporizes when placed. */ - public boolean doesVaporize(IBlockDisplayReader reader, BlockPos pos, FluidStack fluidStack) + public boolean doesVaporize(BlockAndTintGetter reader, BlockPos pos, FluidStack fluidStack) { BlockState blockstate = getBlock(reader, pos, getStateForPlacement(reader, pos, fluidStack)); if (blockstate == null) return false; - return blockstate.getMaterial() == net.minecraft.block.material.Material.WATER; + return blockstate.getMaterial() == net.minecraft.world.level.material.Material.WATER; } /** @@ -204,9 +209,9 @@ public class FluidAttributes * @param pos The position in the world the fluid block was going to be placed. * @param fluidStack The fluidStack that was going to be placed. */ - public void vaporize(@Nullable PlayerEntity player, World worldIn, BlockPos pos, FluidStack fluidStack) + public void vaporize(@Nullable Player player, Level worldIn, BlockPos pos, FluidStack fluidStack) { - worldIn.playSound(player, pos, SoundEvents.FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (worldIn.random.nextFloat() - worldIn.random.nextFloat()) * 0.8F); + worldIn.playSound(player, pos, SoundEvents.FIRE_EXTINGUISH, SoundSource.BLOCKS, 0.5F, 2.6F + (worldIn.random.nextFloat() - worldIn.random.nextFloat()) * 0.8F); for (int l = 0; l < 8; ++l) { @@ -217,9 +222,9 @@ public class FluidAttributes /** * Returns the localized name of this fluid. */ - public ITextComponent getDisplayName(FluidStack stack) + public Component getDisplayName(FluidStack stack) { - return new TranslationTextComponent(getTranslationKey()); + return new TranslatableComponent(getTranslationKey()); } /** @@ -314,17 +319,17 @@ public class FluidAttributes public SoundEvent getEmptySound(FluidStack stack) { return getEmptySound(); } /* World-based Accessors */ - public int getLuminosity(IBlockDisplayReader world, BlockPos pos){ return getLuminosity(); } - public int getDensity(IBlockDisplayReader world, BlockPos pos){ return getDensity(); } - public int getTemperature(IBlockDisplayReader world, BlockPos pos){ return getTemperature(); } - public int getViscosity(IBlockDisplayReader world, BlockPos pos){ return getViscosity(); } - public boolean isGaseous(IBlockDisplayReader world, BlockPos pos){ return isGaseous(); } - public Rarity getRarity(IBlockDisplayReader world, BlockPos pos){ return getRarity(); } - public int getColor(IBlockDisplayReader world, BlockPos pos){ return getColor(); } - public ResourceLocation getStillTexture(IBlockDisplayReader world, BlockPos pos) { return getStillTexture(); } - public ResourceLocation getFlowingTexture(IBlockDisplayReader world, BlockPos pos) { return getFlowingTexture(); } - public SoundEvent getFillSound(IBlockDisplayReader world, BlockPos pos) { return getFillSound(); } - public SoundEvent getEmptySound(IBlockDisplayReader world, BlockPos pos) { return getEmptySound(); } + public int getLuminosity(BlockAndTintGetter world, BlockPos pos){ return getLuminosity(); } + public int getDensity(BlockAndTintGetter world, BlockPos pos){ return getDensity(); } + public int getTemperature(BlockAndTintGetter world, BlockPos pos){ return getTemperature(); } + public int getViscosity(BlockAndTintGetter world, BlockPos pos){ return getViscosity(); } + public boolean isGaseous(BlockAndTintGetter world, BlockPos pos){ return isGaseous(); } + public Rarity getRarity(BlockAndTintGetter world, BlockPos pos){ return getRarity(); } + public int getColor(BlockAndTintGetter world, BlockPos pos){ return getColor(); } + public ResourceLocation getStillTexture(BlockAndTintGetter world, BlockPos pos) { return getStillTexture(); } + public ResourceLocation getFlowingTexture(BlockAndTintGetter world, BlockPos pos) { return getFlowingTexture(); } + public SoundEvent getFillSound(BlockAndTintGetter world, BlockPos pos) { return getFillSound(); } + public SoundEvent getEmptySound(BlockAndTintGetter world, BlockPos pos) { return getEmptySound(); } public static Builder builder(ResourceLocation stillTexture, ResourceLocation flowingTexture) { return new Builder(stillTexture, flowingTexture, FluidAttributes::new); @@ -441,7 +446,7 @@ public class FluidAttributes } @Override - public int getColor(IBlockDisplayReader world, BlockPos pos) + public int getColor(BlockAndTintGetter world, BlockPos pos) { return BiomeColors.getAverageWaterColor(world, pos) | 0xFF000000; } diff --git a/src/main/java/net/minecraftforge/fluids/FluidStack.java b/src/main/java/net/minecraftforge/fluids/FluidStack.java index 1138e3d3a1..d1f5e683fe 100644 --- a/src/main/java/net/minecraftforge/fluids/FluidStack.java +++ b/src/main/java/net/minecraftforge/fluids/FluidStack.java @@ -21,20 +21,19 @@ package net.minecraftforge.fluids; import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import net.minecraft.fluid.Fluid; -import net.minecraft.fluid.Fluids; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.registry.Registry; -import net.minecraft.util.text.ITextComponent; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.Registry; +import net.minecraft.network.chat.Component; import net.minecraftforge.common.util.Constants; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.IRegistryDelegate; import javax.annotation.Nonnull; -import javax.annotation.Nullable; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -59,7 +58,7 @@ public class FluidStack instance -> instance.group( Registry.FLUID.fieldOf("FluidName").forGetter(FluidStack::getFluid), Codec.INT.fieldOf("Amount").forGetter(FluidStack::getAmount), - CompoundNBT.CODEC.optionalFieldOf("Tag").forGetter(stack -> Optional.ofNullable(stack.getTag())) + CompoundTag.CODEC.optionalFieldOf("Tag").forGetter(stack -> Optional.ofNullable(stack.getTag())) ).apply(instance, (fluid, amount, tag) -> { FluidStack stack = new FluidStack(fluid, amount); tag.ifPresent(stack::setTag); @@ -69,7 +68,7 @@ public class FluidStack private boolean isEmpty; private int amount; - private CompoundNBT tag; + private CompoundTag tag; private IRegistryDelegate fluidDelegate; public FluidStack(Fluid fluid, int amount) @@ -90,7 +89,7 @@ public class FluidStack updateEmpty(); } - public FluidStack(Fluid fluid, int amount, CompoundNBT nbt) + public FluidStack(Fluid fluid, int amount, CompoundTag nbt) { this(fluid, amount); @@ -109,7 +108,7 @@ public class FluidStack * This provides a safe method for retrieving a FluidStack - if the Fluid is invalid, the stack * will return as null. */ - public static FluidStack loadFluidStackFromNBT(CompoundNBT nbt) + public static FluidStack loadFluidStackFromNBT(CompoundTag nbt) { if (nbt == null) { @@ -135,7 +134,7 @@ public class FluidStack return stack; } - public CompoundNBT writeToNBT(CompoundNBT nbt) + public CompoundTag writeToNBT(CompoundTag nbt) { nbt.putString("FluidName", getFluid().getRegistryName().toString()); nbt.putInt("Amount", amount); @@ -147,18 +146,18 @@ public class FluidStack return nbt; } - public void writeToPacket(PacketBuffer buf) + public void writeToPacket(FriendlyByteBuf buf) { buf.writeRegistryId(getFluid()); buf.writeVarInt(getAmount()); buf.writeNbt(tag); } - public static FluidStack readFromPacket(PacketBuffer buf) + public static FluidStack readFromPacket(FriendlyByteBuf buf) { Fluid fluid = buf.readRegistryId(); int amount = buf.readVarInt(); - CompoundNBT tag = buf.readNbt(); + CompoundTag tag = buf.readNbt(); if (fluid == Fluids.EMPTY) return EMPTY; return new FluidStack(fluid, amount, tag); } @@ -206,35 +205,35 @@ public class FluidStack return tag != null; } - public CompoundNBT getTag() + public CompoundTag getTag() { return tag; } - public void setTag(CompoundNBT tag) + public void setTag(CompoundTag tag) { if (getRawFluid() == Fluids.EMPTY) throw new IllegalStateException("Can't modify the empty stack."); this.tag = tag; } - public CompoundNBT getOrCreateTag() + public CompoundTag getOrCreateTag() { if (tag == null) - setTag(new CompoundNBT()); + setTag(new CompoundTag()); return tag; } - public CompoundNBT getChildTag(String childName) + public CompoundTag getChildTag(String childName) { if (tag == null) return null; return tag.getCompound(childName); } - public CompoundNBT getOrCreateChildTag(String childName) + public CompoundTag getOrCreateChildTag(String childName) { getOrCreateTag(); - CompoundNBT child = tag.getCompound(childName); + CompoundTag child = tag.getCompound(childName); if (!tag.contains(childName, Constants.NBT.TAG_COMPOUND)) { tag.put(childName, child); @@ -248,7 +247,7 @@ public class FluidStack tag.remove(childName); } - public ITextComponent getDisplayName() + public Component getDisplayName() { return this.getFluid().getAttributes().getDisplayName(this); } diff --git a/src/main/java/net/minecraftforge/fluids/FluidUtil.java b/src/main/java/net/minecraftforge/fluids/FluidUtil.java index fa6da5f4d6..4e4e8b3a9e 100644 --- a/src/main/java/net/minecraftforge/fluids/FluidUtil.java +++ b/src/main/java/net/minecraftforge/fluids/FluidUtil.java @@ -23,23 +23,22 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import com.google.common.base.Preconditions; -import net.minecraft.block.Block; -import net.minecraft.block.IBucketPickupHandler; -import net.minecraft.block.ILiquidContainer; -import net.minecraft.block.material.Material; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.fluid.Fluid; -import net.minecraft.fluid.Fluids; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.*; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.BucketPickup; +import net.minecraft.world.level.block.LiquidBlockContainer; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.Level; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler; @@ -53,6 +52,11 @@ import net.minecraftforge.items.ItemHandlerHelper; import java.util.Optional; +import net.minecraft.core.Direction; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.sounds.SoundSource; +import net.minecraft.world.InteractionHand; + public class FluidUtil { private FluidUtil() @@ -72,7 +76,7 @@ public class FluidUtil * @param side The side of the block to interact with. May be null. * @return true if the interaction succeeded and updated the item held by the player, false otherwise. */ - public static boolean interactWithFluidHandler(@Nonnull PlayerEntity player, @Nonnull Hand hand, @Nonnull World world, @Nonnull BlockPos pos, @Nullable Direction side) + public static boolean interactWithFluidHandler(@Nonnull Player player, @Nonnull InteractionHand hand, @Nonnull Level world, @Nonnull BlockPos pos, @Nullable Direction side) { Preconditions.checkNotNull(world); Preconditions.checkNotNull(pos); @@ -91,7 +95,7 @@ public class FluidUtil * @param handler The fluid handler. * @return true if the interaction succeeded and updated the item held by the player, false otherwise. */ - public static boolean interactWithFluidHandler(@Nonnull PlayerEntity player, @Nonnull Hand hand, @Nonnull IFluidHandler handler) + public static boolean interactWithFluidHandler(@Nonnull Player player, @Nonnull InteractionHand hand, @Nonnull IFluidHandler handler) { Preconditions.checkNotNull(player); Preconditions.checkNotNull(hand); @@ -134,7 +138,7 @@ public class FluidUtil * @return a {@link FluidActionResult} holding the filled container if successful. */ @Nonnull - public static FluidActionResult tryFillContainer(@Nonnull ItemStack container, IFluidHandler fluidSource, int maxAmount, @Nullable PlayerEntity player, boolean doFill) + public static FluidActionResult tryFillContainer(@Nonnull ItemStack container, IFluidHandler fluidSource, int maxAmount, @Nullable Player player, boolean doFill) { ItemStack containerCopy = ItemHandlerHelper.copyStackWithSize(container, 1); // do not modify the input return getFluidHandler(containerCopy) @@ -148,7 +152,7 @@ public class FluidUtil if (player != null) { SoundEvent soundevent = simulatedTransfer.getFluid().getAttributes().getFillSound(simulatedTransfer); - player.level.playSound(null, player.getX(), player.getY() + 0.5, player.getZ(), soundevent, SoundCategory.BLOCKS, 1.0F, 1.0F); + player.level.playSound(null, player.getX(), player.getY() + 0.5, player.getZ(), soundevent, SoundSource.BLOCKS, 1.0F, 1.0F); } } else @@ -178,7 +182,7 @@ public class FluidUtil * NOTE If the container is consumable, the empty container will be null on success. */ @Nonnull - public static FluidActionResult tryEmptyContainer(@Nonnull ItemStack container, IFluidHandler fluidDestination, int maxAmount, @Nullable PlayerEntity player, boolean doDrain) + public static FluidActionResult tryEmptyContainer(@Nonnull ItemStack container, IFluidHandler fluidDestination, int maxAmount, @Nullable Player player, boolean doDrain) { ItemStack containerCopy = ItemHandlerHelper.copyStackWithSize(container, 1); // do not modify the input return getFluidHandler(containerCopy) @@ -192,7 +196,7 @@ public class FluidUtil if (doDrain && player != null) { SoundEvent soundevent = transfer.getFluid().getAttributes().getEmptySound(transfer); - player.level.playSound(null, player.getX(), player.getY() + 0.5, player.getZ(), soundevent, SoundCategory.BLOCKS, 1.0F, 1.0F); + player.level.playSound(null, player.getX(), player.getY() + 0.5, player.getZ(), soundevent, SoundSource.BLOCKS, 1.0F, 1.0F); } ItemStack resultContainer = containerFluidHandler.getContainer(); @@ -219,14 +223,14 @@ public class FluidUtil * @return a {@link FluidActionResult} holding the result and the resulting container. The resulting container is empty on failure. */ @Nonnull - public static FluidActionResult tryFillContainerAndStow(@Nonnull ItemStack container, IFluidHandler fluidSource, IItemHandler inventory, int maxAmount, @Nullable PlayerEntity player, boolean doFill) + public static FluidActionResult tryFillContainerAndStow(@Nonnull ItemStack container, IFluidHandler fluidSource, IItemHandler inventory, int maxAmount, @Nullable Player player, boolean doFill) { if (container.isEmpty()) { return FluidActionResult.FAILURE; } - if (player != null && player.abilities.instabuild) + if (player != null && player.getAbilities().instabuild) { FluidActionResult filledReal = tryFillContainer(container, fluidSource, maxAmount, player, doFill); if (filledReal.isSuccess()) @@ -287,14 +291,14 @@ public class FluidUtil * @return a {@link FluidActionResult} holding the result and the resulting container. The resulting container is empty on failure. */ @Nonnull - public static FluidActionResult tryEmptyContainerAndStow(@Nonnull ItemStack container, IFluidHandler fluidDestination, IItemHandler inventory, int maxAmount, @Nullable PlayerEntity player, boolean doDrain) + public static FluidActionResult tryEmptyContainerAndStow(@Nonnull ItemStack container, IFluidHandler fluidDestination, IItemHandler inventory, int maxAmount, @Nullable Player player, boolean doDrain) { if (container.isEmpty()) { return FluidActionResult.FAILURE; } - if (player != null && player.abilities.instabuild) + if (player != null && player.getAbilities().instabuild) { FluidActionResult emptiedReal = tryEmptyContainer(container, fluidDestination, maxAmount, player, doDrain); if (emptiedReal.isSuccess()) @@ -451,17 +455,17 @@ public class FluidUtil /** * Helper method to get an IFluidHandler for at a block position. */ - public static LazyOptional getFluidHandler(World world, BlockPos blockPos, @Nullable Direction side) + public static LazyOptional getFluidHandler(Level world, BlockPos blockPos, @Nullable Direction side) { BlockState state = world.getBlockState(blockPos); Block block = state.getBlock(); - if (block.hasTileEntity(state)) + if (state.hasBlockEntity()) { - TileEntity tileEntity = world.getBlockEntity(blockPos); - if (tileEntity != null) + BlockEntity blockEntity = world.getBlockEntity(blockPos); + if (blockEntity != null) { - return tileEntity.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side); + return blockEntity.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side); } } return LazyOptional.empty(); @@ -479,7 +483,7 @@ public class FluidUtil * @return a {@link FluidActionResult} holding the result and the resulting container. */ @Nonnull - public static FluidActionResult tryPickUpFluid(@Nonnull ItemStack emptyContainer, @Nullable PlayerEntity playerIn, World worldIn, BlockPos pos, Direction side) + public static FluidActionResult tryPickUpFluid(@Nonnull ItemStack emptyContainer, @Nullable Player playerIn, Level worldIn, BlockPos pos, Direction side) { if (emptyContainer.isEmpty() || worldIn == null || pos == null) { @@ -493,9 +497,9 @@ public class FluidUtil { targetFluidHandler = new FluidBlockWrapper((IFluidBlock) block, worldIn, pos); } - else if (block instanceof IBucketPickupHandler) + else if (block instanceof BucketPickup) { - targetFluidHandler = new BucketPickupHandlerWrapper((IBucketPickupHandler) block, worldIn, pos); + targetFluidHandler = new BucketPickupHandlerWrapper((BucketPickup) block, worldIn, pos); } else { @@ -522,7 +526,7 @@ public class FluidUtil * @return the container's ItemStack with the remaining amount of fluid if the placement was successful, null otherwise */ @Nonnull - public static FluidActionResult tryPlaceFluid(@Nullable PlayerEntity player, World world, Hand hand, BlockPos pos, @Nonnull ItemStack container, FluidStack resource) + public static FluidActionResult tryPlaceFluid(@Nullable Player player, Level world, InteractionHand hand, BlockPos pos, @Nonnull ItemStack container, FluidStack resource) { ItemStack containerCopy = ItemHandlerHelper.copyStackWithSize(container, 1); // do not modify the input return getFluidHandler(containerCopy) @@ -548,7 +552,7 @@ public class FluidUtil * @param resource The fluidStack to place. * @return true if the placement was successful, false otherwise */ - public static boolean tryPlaceFluid(@Nullable PlayerEntity player, World world, Hand hand, BlockPos pos, IFluidHandler fluidSource, FluidStack resource) + public static boolean tryPlaceFluid(@Nullable Player player, Level world, InteractionHand hand, BlockPos pos, IFluidHandler fluidSource, FluidStack resource) { if (world == null || pos == null) { @@ -566,14 +570,14 @@ public class FluidUtil return false; } - BlockItemUseContext context = new BlockItemUseContext(world, player, hand, player == null ? ItemStack.EMPTY : player.getItemInHand(hand), new BlockRayTraceResult(Vector3d.ZERO, Direction.UP, pos, false)); + BlockPlaceContext context = new BlockPlaceContext(world, player, hand, player == null ? ItemStack.EMPTY : player.getItemInHand(hand), new BlockHitResult(Vec3.ZERO, Direction.UP, pos, false)); // check that we can place the fluid at the destination BlockState destBlockState = world.getBlockState(pos); Material destMaterial = destBlockState.getMaterial(); boolean isDestNonSolid = !destMaterial.isSolid(); boolean isDestReplaceable = destBlockState.canBeReplaced(context); - boolean canDestContainFluid = destBlockState.getBlock() instanceof ILiquidContainer && ((ILiquidContainer) destBlockState.getBlock()).canPlaceLiquid(world, pos, destBlockState, fluid); + boolean canDestContainFluid = destBlockState.getBlock() instanceof LiquidBlockContainer && ((LiquidBlockContainer) destBlockState.getBlock()).canPlaceLiquid(world, pos, destBlockState, fluid); if (!world.isEmptyBlock(pos) && !isDestNonSolid && !isDestReplaceable && !canDestContainFluid) { return false; // Non-air, solid, unreplacable block. We can't put fluid here. @@ -594,7 +598,7 @@ public class FluidUtil IFluidHandler handler; if (canDestContainFluid) { - handler = new BlockWrapper.LiquidContainerBlockWrapper((ILiquidContainer) destBlockState.getBlock(), world, pos); + handler = new BlockWrapper.LiquidContainerBlockWrapper((LiquidBlockContainer) destBlockState.getBlock(), world, pos); } else { @@ -604,7 +608,7 @@ public class FluidUtil if (!result.isEmpty()) { SoundEvent soundevent = resource.getFluid().getAttributes().getEmptySound(resource); - world.playSound(player, pos, soundevent, SoundCategory.BLOCKS, 1.0F, 1.0F); + world.playSound(player, pos, soundevent, SoundSource.BLOCKS, 1.0F, 1.0F); return true; } } @@ -617,7 +621,7 @@ public class FluidUtil * Modders: Instead of this method, use {@link #tryPlaceFluid(PlayerEntity, World, Hand, BlockPos, ItemStack, FluidStack)} * or {@link #tryPlaceFluid(PlayerEntity, World, Hand, BlockPos, IFluidHandler, FluidStack)} */ - private static IFluidHandler getFluidBlockHandler(Fluid fluid, World world, BlockPos pos) + private static IFluidHandler getFluidBlockHandler(Fluid fluid, Level world, BlockPos pos) { BlockState state = fluid.getAttributes().getBlock(world, pos, fluid.defaultFluidState()); return new BlockWrapper(state, world, pos); @@ -632,7 +636,7 @@ public class FluidUtil * @param world the world that the fluid will be placed in * @param pos the location that the fluid will be placed */ - public static void destroyBlockOnFluidPlacement(World world, BlockPos pos) + public static void destroyBlockOnFluidPlacement(Level world, BlockPos pos) { if (!world.isClientSide) { diff --git a/src/main/java/net/minecraftforge/fluids/ForgeFlowingFluid.java b/src/main/java/net/minecraftforge/fluids/ForgeFlowingFluid.java index cf44597f2c..7e6893b222 100644 --- a/src/main/java/net/minecraftforge/fluids/ForgeFlowingFluid.java +++ b/src/main/java/net/minecraftforge/fluids/ForgeFlowingFluid.java @@ -19,23 +19,22 @@ package net.minecraftforge.fluids; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.FlowingFluidBlock; -import net.minecraft.fluid.FlowingFluid; -import net.minecraft.fluid.Fluid; -import net.minecraft.fluid.FluidState; -import net.minecraft.item.Item; -import net.minecraft.item.Items; -import net.minecraft.state.StateContainer; -import net.minecraft.tags.FluidTags; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorld; -import net.minecraft.world.IWorldReader; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.LiquidBlock; +import net.minecraft.world.level.material.FlowingFluid; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.LevelReader; import javax.annotation.Nullable; import java.util.function.Supplier; @@ -47,7 +46,7 @@ public abstract class ForgeFlowingFluid extends FlowingFluid @Nullable private final Supplier bucket; @Nullable - private final Supplier block; + private final Supplier block; private final FluidAttributes.Builder builder; private final boolean canMultiply; private final int slopeFindDistance; @@ -88,20 +87,20 @@ public abstract class ForgeFlowingFluid extends FlowingFluid } @Override - protected void beforeDestroyingBlock(IWorld worldIn, BlockPos pos, BlockState state) + protected void beforeDestroyingBlock(LevelAccessor worldIn, BlockPos pos, BlockState state) { - TileEntity tileentity = state.getBlock().hasTileEntity(state) ? worldIn.getBlockEntity(pos) : null; - Block.dropResources(state, worldIn, pos, tileentity); + BlockEntity blockEntity = state.hasBlockEntity() ? worldIn.getBlockEntity(pos) : null; + Block.dropResources(state, worldIn, pos, blockEntity); } @Override - protected int getSlopeFindDistance(IWorldReader worldIn) + protected int getSlopeFindDistance(LevelReader worldIn) { return slopeFindDistance; } @Override - protected int getDropOff(IWorldReader worldIn) + protected int getDropOff(LevelReader worldIn) { return levelDecreasePerBlock; } @@ -113,14 +112,14 @@ public abstract class ForgeFlowingFluid extends FlowingFluid } @Override - protected boolean canBeReplacedWith(FluidState state, IBlockReader world, BlockPos pos, Fluid fluidIn, Direction direction) + protected boolean canBeReplacedWith(FluidState state, BlockGetter world, BlockPos pos, Fluid fluidIn, Direction direction) { // Based on the water implementation, may need to be overriden for mod fluids that shouldn't behave like water. return direction == Direction.DOWN && !isSame(fluidIn); } @Override - public int getTickDelay(IWorldReader world) + public int getTickDelay(LevelReader world) { return tickRate; } @@ -135,7 +134,7 @@ public abstract class ForgeFlowingFluid extends FlowingFluid protected BlockState createLegacyBlock(FluidState state) { if (block != null) - return block.get().defaultBlockState().setValue(FlowingFluidBlock.LEVEL, getLegacyLevel(state)); + return block.get().defaultBlockState().setValue(LiquidBlock.LEVEL, getLegacyLevel(state)); return Blocks.AIR.defaultBlockState(); } @@ -158,7 +157,7 @@ public abstract class ForgeFlowingFluid extends FlowingFluid registerDefaultState(getStateDefinition().any().setValue(LEVEL, 7)); } - protected void createFluidStateDefinition(StateContainer.Builder builder) { + protected void createFluidStateDefinition(StateDefinition.Builder builder) { super.createFluidStateDefinition(builder); builder.add(LEVEL); } @@ -195,7 +194,7 @@ public abstract class ForgeFlowingFluid extends FlowingFluid private FluidAttributes.Builder attributes; private boolean canMultiply; private Supplier bucket; - private Supplier block; + private Supplier block; private int slopeFindDistance = 4; private int levelDecreasePerBlock = 1; private float explosionResistance = 1; @@ -220,7 +219,7 @@ public abstract class ForgeFlowingFluid extends FlowingFluid return this; } - public Properties block(Supplier block) + public Properties block(Supplier block) { this.block = block; return this; diff --git a/src/main/java/net/minecraftforge/fluids/IFluidBlock.java b/src/main/java/net/minecraftforge/fluids/IFluidBlock.java index 8946b57b65..8ab16dac0e 100644 --- a/src/main/java/net/minecraftforge/fluids/IFluidBlock.java +++ b/src/main/java/net/minecraftforge/fluids/IFluidBlock.java @@ -19,13 +19,12 @@ package net.minecraftforge.fluids; -import net.minecraft.fluid.Fluid; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; import net.minecraftforge.fluids.capability.IFluidHandler; import javax.annotation.Nonnull; -import javax.annotation.Nullable; /** * Implement this interface on Block classes which represent world-placeable Fluids. @@ -52,7 +51,7 @@ public interface IFluidBlock * @param action If SIMULATE, the placement will only be simulated * @return the amount of fluid extracted from the provided stack to achieve some fluid level */ - int place(World world, BlockPos pos, @Nonnull FluidStack fluidStack, IFluidHandler.FluidAction action); + int place(Level world, BlockPos pos, @Nonnull FluidStack fluidStack, IFluidHandler.FluidAction action); /** * Attempt to drain the block. This method should be called by devices such as pumps. @@ -64,7 +63,7 @@ public interface IFluidBlock * @return */ @Nonnull - FluidStack drain(World world, BlockPos pos, IFluidHandler.FluidAction action); + FluidStack drain(Level world, BlockPos pos, IFluidHandler.FluidAction action); /** * Check to see if a block can be drained. This method should be called by devices such as @@ -72,7 +71,7 @@ public interface IFluidBlock * * @return */ - boolean canDrain(World world, BlockPos pos); + boolean canDrain(Level world, BlockPos pos); /** * Returns the amount of a single block is filled. Value between 0 and 1. @@ -83,5 +82,5 @@ public interface IFluidBlock * * @return */ - float getFilledPercentage(World world, BlockPos pos); + float getFilledPercentage(Level world, BlockPos pos); } diff --git a/src/main/java/net/minecraftforge/fluids/IFluidTank.java b/src/main/java/net/minecraftforge/fluids/IFluidTank.java index def3c0c02b..c274a5578c 100644 --- a/src/main/java/net/minecraftforge/fluids/IFluidTank.java +++ b/src/main/java/net/minecraftforge/fluids/IFluidTank.java @@ -22,7 +22,6 @@ package net.minecraftforge.fluids; import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction; import javax.annotation.Nonnull; -import javax.annotation.Nullable; /** * This interface represents a Fluid Tank. IT IS NOT REQUIRED but is provided for convenience. diff --git a/src/main/java/net/minecraftforge/fluids/capability/CapabilityFluidHandler.java b/src/main/java/net/minecraftforge/fluids/capability/CapabilityFluidHandler.java index 6f8ee66a0b..4e926761a1 100644 --- a/src/main/java/net/minecraftforge/fluids/capability/CapabilityFluidHandler.java +++ b/src/main/java/net/minecraftforge/fluids/capability/CapabilityFluidHandler.java @@ -19,18 +19,9 @@ package net.minecraftforge.fluids.capability; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.INBT; -import net.minecraft.util.Direction; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.CapabilityInject; import net.minecraftforge.common.capabilities.CapabilityManager; -import net.minecraftforge.fluids.FluidAttributes; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.capability.templates.FluidHandlerItemStack; -import net.minecraftforge.fluids.capability.templates.FluidTank; public class CapabilityFluidHandler { @@ -41,34 +32,8 @@ public class CapabilityFluidHandler public static void register() { - CapabilityManager.INSTANCE.register(IFluidHandler.class, new DefaultFluidHandlerStorage<>(), () -> new FluidTank(FluidAttributes.BUCKET_VOLUME)); + CapabilityManager.INSTANCE.register(IFluidHandler.class); - CapabilityManager.INSTANCE.register(IFluidHandlerItem.class, new DefaultFluidHandlerStorage<>(), () -> new FluidHandlerItemStack(new ItemStack(Items.BUCKET), FluidAttributes.BUCKET_VOLUME)); - } - - private static class DefaultFluidHandlerStorage implements Capability.IStorage { - @Override - public INBT writeNBT(Capability capability, T instance, Direction side) - { - if (!(instance instanceof FluidTank)) - throw new RuntimeException("Cannot serialize to an instance that isn't the default implementation"); - CompoundNBT nbt = new CompoundNBT(); - FluidTank tank = (FluidTank) instance; - FluidStack fluid = tank.getFluid(); - fluid.writeToNBT(nbt); - nbt.putInt("Capacity", tank.getCapacity()); - return nbt; - } - - @Override - public void readNBT(Capability capability, T instance, Direction side, INBT nbt) - { - if (!(instance instanceof FluidTank)) - throw new RuntimeException("Cannot deserialize to an instance that isn't the default implementation"); - CompoundNBT tags = (CompoundNBT) nbt; - FluidTank tank = (FluidTank) instance; - tank.setCapacity(tags.getInt("Capacity")); - tank.readFromNBT(tags); - } + CapabilityManager.INSTANCE.register(IFluidHandlerItem.class); } } diff --git a/src/main/java/net/minecraftforge/fluids/capability/IFluidHandler.java b/src/main/java/net/minecraftforge/fluids/capability/IFluidHandler.java index 1e56311f81..d52fb0f840 100644 --- a/src/main/java/net/minecraftforge/fluids/capability/IFluidHandler.java +++ b/src/main/java/net/minecraftforge/fluids/capability/IFluidHandler.java @@ -20,7 +20,6 @@ package net.minecraftforge.fluids.capability; import javax.annotation.Nonnull; -import javax.annotation.Nullable; import net.minecraftforge.fluids.*; diff --git a/src/main/java/net/minecraftforge/fluids/capability/IFluidHandlerItem.java b/src/main/java/net/minecraftforge/fluids/capability/IFluidHandlerItem.java index b4d0587a51..781cd65636 100644 --- a/src/main/java/net/minecraftforge/fluids/capability/IFluidHandlerItem.java +++ b/src/main/java/net/minecraftforge/fluids/capability/IFluidHandlerItem.java @@ -20,9 +20,8 @@ package net.minecraftforge.fluids.capability; import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import net.minecraft.item.ItemStack; +import net.minecraft.world.item.ItemStack; /** * ItemStacks handled by an {@link IFluidHandler} may change, so this class allows diff --git a/src/main/java/net/minecraftforge/fluids/capability/ItemFluidContainer.java b/src/main/java/net/minecraftforge/fluids/capability/ItemFluidContainer.java index 3f13870ba8..0671c98326 100644 --- a/src/main/java/net/minecraftforge/fluids/capability/ItemFluidContainer.java +++ b/src/main/java/net/minecraftforge/fluids/capability/ItemFluidContainer.java @@ -19,9 +19,9 @@ package net.minecraftforge.fluids.capability; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.fluids.capability.templates.FluidHandlerItemStack; @@ -47,7 +47,7 @@ public class ItemFluidContainer extends Item } @Override - public ICapabilityProvider initCapabilities(@Nonnull ItemStack stack, @Nullable CompoundNBT nbt) + public ICapabilityProvider initCapabilities(@Nonnull ItemStack stack, @Nullable CompoundTag nbt) { return new FluidHandlerItemStack(stack, capacity); } diff --git a/src/main/java/net/minecraftforge/fluids/capability/TileFluidHandler.java b/src/main/java/net/minecraftforge/fluids/capability/TileFluidHandler.java index cdebb8c7c8..74845e2e12 100644 --- a/src/main/java/net/minecraftforge/fluids/capability/TileFluidHandler.java +++ b/src/main/java/net/minecraftforge/fluids/capability/TileFluidHandler.java @@ -19,11 +19,12 @@ package net.minecraftforge.fluids.capability; -import net.minecraft.block.BlockState; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.Direction; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.fluids.FluidAttributes; @@ -32,26 +33,26 @@ import net.minecraftforge.fluids.capability.templates.FluidTank; import javax.annotation.Nonnull; import javax.annotation.Nullable; -public class TileFluidHandler extends TileEntity +public class TileFluidHandler extends BlockEntity { protected FluidTank tank = new FluidTank(FluidAttributes.BUCKET_VOLUME); private final LazyOptional holder = LazyOptional.of(() -> tank); - public TileFluidHandler(@Nonnull TileEntityType tileEntityTypeIn) + public TileFluidHandler(@Nonnull BlockEntityType blockEntityType, BlockPos pos, BlockState state) { - super(tileEntityTypeIn); + super(blockEntityType, pos, state); } @Override - public void load(BlockState state, CompoundNBT tag) + public void load(CompoundTag tag) { - super.load(state, tag); + super.load(tag); tank.readFromNBT(tag); } @Override - public CompoundNBT save(CompoundNBT tag) + public CompoundTag save(CompoundTag tag) { tag = super.save(tag); tank.writeToNBT(tag); diff --git a/src/main/java/net/minecraftforge/fluids/capability/templates/EmptyFluidHandler.java b/src/main/java/net/minecraftforge/fluids/capability/templates/EmptyFluidHandler.java index 9a2fcf6c7c..d01fb4be15 100644 --- a/src/main/java/net/minecraftforge/fluids/capability/templates/EmptyFluidHandler.java +++ b/src/main/java/net/minecraftforge/fluids/capability/templates/EmptyFluidHandler.java @@ -20,7 +20,6 @@ package net.minecraftforge.fluids.capability.templates; import javax.annotation.Nonnull; -import javax.annotation.Nullable; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.IFluidHandler; diff --git a/src/main/java/net/minecraftforge/fluids/capability/templates/FluidHandlerItemStack.java b/src/main/java/net/minecraftforge/fluids/capability/templates/FluidHandlerItemStack.java index 9a3efdc2a8..2e8e2f8e52 100644 --- a/src/main/java/net/minecraftforge/fluids/capability/templates/FluidHandlerItemStack.java +++ b/src/main/java/net/minecraftforge/fluids/capability/templates/FluidHandlerItemStack.java @@ -22,9 +22,9 @@ package net.minecraftforge.fluids.capability.templates; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.Direction; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.core.Direction; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.common.util.LazyOptional; @@ -73,7 +73,7 @@ public class FluidHandlerItemStack implements IFluidHandlerItem, ICapabilityProv @Nonnull public FluidStack getFluid() { - CompoundNBT tagCompound = container.getTag(); + CompoundTag tagCompound = container.getTag(); if (tagCompound == null || !tagCompound.contains(FLUID_NBT_KEY)) { return FluidStack.EMPTY; @@ -85,10 +85,10 @@ public class FluidHandlerItemStack implements IFluidHandlerItem, ICapabilityProv { if (!container.hasTag()) { - container.setTag(new CompoundNBT()); + container.setTag(new CompoundTag()); } - CompoundNBT fluidTag = new CompoundNBT(); + CompoundTag fluidTag = new CompoundTag(); fluid.writeToNBT(fluidTag); container.getTag().put(FLUID_NBT_KEY, fluidTag); } diff --git a/src/main/java/net/minecraftforge/fluids/capability/templates/FluidHandlerItemStackSimple.java b/src/main/java/net/minecraftforge/fluids/capability/templates/FluidHandlerItemStackSimple.java index f8ccae7257..4ddb84ad0c 100644 --- a/src/main/java/net/minecraftforge/fluids/capability/templates/FluidHandlerItemStackSimple.java +++ b/src/main/java/net/minecraftforge/fluids/capability/templates/FluidHandlerItemStackSimple.java @@ -22,9 +22,9 @@ package net.minecraftforge.fluids.capability.templates; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.Direction; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.core.Direction; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.common.util.LazyOptional; @@ -70,7 +70,7 @@ public class FluidHandlerItemStackSimple implements IFluidHandlerItem, ICapabili @Nonnull public FluidStack getFluid() { - CompoundNBT tagCompound = container.getTag(); + CompoundTag tagCompound = container.getTag(); if (tagCompound == null || !tagCompound.contains(FLUID_NBT_KEY)) { return FluidStack.EMPTY; @@ -82,10 +82,10 @@ public class FluidHandlerItemStackSimple implements IFluidHandlerItem, ICapabili { if (!container.hasTag()) { - container.setTag(new CompoundNBT()); + container.setTag(new CompoundTag()); } - CompoundNBT fluidTag = new CompoundNBT(); + CompoundTag fluidTag = new CompoundTag(); fluid.writeToNBT(fluidTag); container.getTag().put(FLUID_NBT_KEY, fluidTag); } diff --git a/src/main/java/net/minecraftforge/fluids/capability/templates/FluidTank.java b/src/main/java/net/minecraftforge/fluids/capability/templates/FluidTank.java index cae1426b47..69c0ed297d 100644 --- a/src/main/java/net/minecraftforge/fluids/capability/templates/FluidTank.java +++ b/src/main/java/net/minecraftforge/fluids/capability/templates/FluidTank.java @@ -19,14 +19,13 @@ package net.minecraftforge.fluids.capability.templates; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.CompoundTag; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidTank; import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction; import javax.annotation.Nonnull; -import javax.annotation.Nullable; import java.util.function.Predicate; /** @@ -87,14 +86,14 @@ public class FluidTank implements IFluidHandler, IFluidTank { return fluid.getAmount(); } - public FluidTank readFromNBT(CompoundNBT nbt) { + public FluidTank readFromNBT(CompoundTag nbt) { FluidStack fluid = FluidStack.loadFluidStackFromNBT(nbt); setFluid(fluid); return this; } - public CompoundNBT writeToNBT(CompoundNBT nbt) { + public CompoundTag writeToNBT(CompoundTag nbt) { fluid.writeToNBT(nbt); diff --git a/src/main/java/net/minecraftforge/fluids/capability/templates/VoidFluidHandler.java b/src/main/java/net/minecraftforge/fluids/capability/templates/VoidFluidHandler.java index 9fc1507a52..1e8c677191 100644 --- a/src/main/java/net/minecraftforge/fluids/capability/templates/VoidFluidHandler.java +++ b/src/main/java/net/minecraftforge/fluids/capability/templates/VoidFluidHandler.java @@ -23,7 +23,6 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.IFluidHandler; import javax.annotation.Nonnull; -import javax.annotation.Nullable; import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction; 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 3bd137ed96..8059eab40f 100644 --- a/src/main/java/net/minecraftforge/fluids/capability/wrappers/BlockWrapper.java +++ b/src/main/java/net/minecraftforge/fluids/capability/wrappers/BlockWrapper.java @@ -19,10 +19,10 @@ package net.minecraftforge.fluids.capability.wrappers; -import net.minecraft.block.BlockState; -import net.minecraft.block.ILiquidContainer; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.LiquidBlockContainer; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; import net.minecraftforge.common.util.Constants; import net.minecraftforge.fluids.FluidAttributes; import net.minecraftforge.fluids.FluidStack; @@ -39,10 +39,10 @@ import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction; public class BlockWrapper extends VoidFluidHandler { protected final BlockState state; - protected final World world; + protected final Level world; protected final BlockPos blockPos; - public BlockWrapper(BlockState state, World world, BlockPos blockPos) + public BlockWrapper(BlockState state, Level world, BlockPos blockPos) { this.state = state; this.world = world; @@ -67,11 +67,11 @@ public class BlockWrapper extends VoidFluidHandler public static class LiquidContainerBlockWrapper extends VoidFluidHandler { - protected final ILiquidContainer liquidContainer; - protected final World world; + protected final LiquidBlockContainer liquidContainer; + protected final Level world; protected final BlockPos blockPos; - public LiquidContainerBlockWrapper(ILiquidContainer liquidContainer, World world, BlockPos blockPos) + public LiquidContainerBlockWrapper(LiquidBlockContainer liquidContainer, Level world, BlockPos blockPos) { this.liquidContainer = liquidContainer; this.world = world; 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 bbd076f7d0..4a2fba70a3 100644 --- a/src/main/java/net/minecraftforge/fluids/capability/wrappers/BucketPickupHandlerWrapper.java +++ b/src/main/java/net/minecraftforge/fluids/capability/wrappers/BucketPickupHandlerWrapper.java @@ -20,29 +20,28 @@ package net.minecraftforge.fluids.capability.wrappers; import javax.annotation.Nonnull; -import net.minecraft.block.IBucketPickupHandler; -import net.minecraft.fluid.Fluid; -import net.minecraft.fluid.FluidState; -import net.minecraft.fluid.Fluids; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; + +import net.minecraft.world.item.BucketItem; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.BucketPickup; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; import net.minecraftforge.fluids.FluidAttributes; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.IFluidHandler; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction; - public class BucketPickupHandlerWrapper implements IFluidHandler { private static final Logger LOGGER = LogManager.getLogger(); - protected final IBucketPickupHandler bucketPickupHandler; - protected final World world; + protected final BucketPickup bucketPickupHandler; + protected final Level world; protected final BlockPos blockPos; - public BucketPickupHandlerWrapper(IBucketPickupHandler bucketPickupHandler, World world, BlockPos blockPos) + public BucketPickupHandlerWrapper(BucketPickup bucketPickupHandler, Level world, BlockPos blockPos) { this.bucketPickupHandler = bucketPickupHandler; this.world = world; @@ -100,15 +99,15 @@ public class BucketPickupHandlerWrapper implements IFluidHandler { if (action.execute()) { - Fluid fluid = bucketPickupHandler.takeLiquid(world, blockPos, world.getBlockState(blockPos)); - if (fluid != Fluids.EMPTY) + ItemStack itemStack = bucketPickupHandler.pickupBlock(world, blockPos, world.getBlockState(blockPos)); + if (itemStack != ItemStack.EMPTY && itemStack.getItem() instanceof BucketItem bucket) { - FluidStack extracted = new FluidStack(fluid, FluidAttributes.BUCKET_VOLUME); + FluidStack extracted = new FluidStack(bucket.getFluid(), FluidAttributes.BUCKET_VOLUME); if (!resource.isFluidEqual(extracted)) { //Be loud if something went wrong LOGGER.error("Fluid removed without successfully being picked up. Fluid {} at {} in {} matched requested type, but after performing pickup was {}.", - fluidState.getType().getRegistryName(), blockPos, world.dimension().location(), fluid.getRegistryName()); + fluidState.getType().getRegistryName(), blockPos, world.dimension().location(), bucket.getFluid().getRegistryName()); return FluidStack.EMPTY; } return extracted; @@ -141,10 +140,10 @@ public class BucketPickupHandlerWrapper implements IFluidHandler { return new FluidStack(fluidState.getType(), FluidAttributes.BUCKET_VOLUME); } - Fluid fluid = bucketPickupHandler.takeLiquid(world, blockPos, world.getBlockState(blockPos)); - if (fluid != Fluids.EMPTY) + ItemStack itemStack = bucketPickupHandler.pickupBlock(world, blockPos, world.getBlockState(blockPos)); + if (itemStack != ItemStack.EMPTY && itemStack.getItem() instanceof BucketItem bucket) { - return new FluidStack(fluid, FluidAttributes.BUCKET_VOLUME); + return new FluidStack(bucket.getFluid(), FluidAttributes.BUCKET_VOLUME); } } } diff --git a/src/main/java/net/minecraftforge/fluids/capability/wrappers/FluidBlockWrapper.java b/src/main/java/net/minecraftforge/fluids/capability/wrappers/FluidBlockWrapper.java index 3da35991df..a06485da4b 100644 --- a/src/main/java/net/minecraftforge/fluids/capability/wrappers/FluidBlockWrapper.java +++ b/src/main/java/net/minecraftforge/fluids/capability/wrappers/FluidBlockWrapper.java @@ -20,8 +20,8 @@ package net.minecraftforge.fluids.capability.wrappers; import javax.annotation.Nonnull; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; import net.minecraftforge.fluids.FluidAttributes; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidBlock; @@ -32,10 +32,10 @@ import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction; public class FluidBlockWrapper implements IFluidHandler { protected final IFluidBlock fluidBlock; - protected final World world; + protected final Level world; protected final BlockPos blockPos; - public FluidBlockWrapper(IFluidBlock fluidBlock, World world, BlockPos blockPos) + public FluidBlockWrapper(IFluidBlock fluidBlock, Level world, BlockPos blockPos) { this.fluidBlock = fluidBlock; this.world = world; diff --git a/src/main/java/net/minecraftforge/fluids/capability/wrappers/FluidBucketWrapper.java b/src/main/java/net/minecraftforge/fluids/capability/wrappers/FluidBucketWrapper.java index 737bab288f..ba90cf5e37 100644 --- a/src/main/java/net/minecraftforge/fluids/capability/wrappers/FluidBucketWrapper.java +++ b/src/main/java/net/minecraftforge/fluids/capability/wrappers/FluidBucketWrapper.java @@ -22,10 +22,8 @@ package net.minecraftforge.fluids.capability.wrappers; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import net.minecraft.fluid.Fluids; -import net.minecraft.item.*; -import net.minecraft.util.Direction; -import net.minecraft.util.ResourceLocation; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.core.Direction; import net.minecraftforge.common.ForgeMod; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.ICapabilityProvider; @@ -38,6 +36,12 @@ import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction; +import net.minecraft.world.item.BucketItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.MilkBucketItem; + /** * Wrapper for vanilla and forge buckets. * Swaps between empty bucket and filled bucket of the correct type. diff --git a/src/main/java/net/minecraftforge/fml/ModLoadingStage.java b/src/main/java/net/minecraftforge/fml/ModLoadingStage.java deleted file mode 100644 index 7c79e15a3f..0000000000 --- a/src/main/java/net/minecraftforge/fml/ModLoadingStage.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fml; - -import cpw.mods.modlauncher.api.LamdbaExceptionUtils; -import net.minecraftforge.event.RegistryEvent; -import net.minecraftforge.eventbus.api.Event; -import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; -import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; -import net.minecraftforge.fml.event.lifecycle.FMLConstructModEvent; -import net.minecraftforge.fml.event.lifecycle.FMLDedicatedServerSetupEvent; -import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent; -import net.minecraftforge.fml.event.lifecycle.IModBusEvent; -import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent; -import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent; -import net.minecraftforge.fml.event.lifecycle.ParallelDispatchEvent; -import net.minecraftforge.registries.GameData; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.Executor; -import java.util.function.BiFunction; -import java.util.function.BinaryOperator; -import java.util.function.Consumer; -import java.util.function.Function; -import java.util.function.Supplier; -import java.util.stream.Stream; - -public enum ModLoadingStage -{ - ERROR(), - VALIDATE(), - CONSTRUCT(FMLConstructModEvent.class), - CREATE_REGISTRIES(()->Stream.of(EventGenerator.fromFunction(RegistryEvent.NewRegistry::new))), - LOAD_REGISTRIES(GameData::generateRegistryEvents, GameData::preRegistryEventDispatch, GameData::postRegistryEventDispatch, GameData::checkForRevertToVanilla), - COMMON_SETUP(FMLCommonSetupEvent.class), - SIDED_SETUP(DistExecutor.unsafeRunForDist(()->()->FMLClientSetupEvent.class, ()->()->FMLDedicatedServerSetupEvent.class)), - ENQUEUE_IMC(InterModEnqueueEvent.class), - PROCESS_IMC(InterModProcessEvent.class), - COMPLETE(FMLLoadCompleteEvent.class), - DONE(); - - private final Supplier>> eventFunctionStream; - private final Optional> parallelEventClass; - private final ThreadSelector threadSelector; - private final BiFunction>, CompletableFuture>> finalActivityGenerator; - private final BiFunction, CompletableFuture>> preDispatchHook; - private final BiFunction, CompletableFuture>> postDispatchHook; - private DeferredWorkQueue deferredWorkQueue; - - ModLoadingStage(Class parallelClass) { - final EventGenerator event = EventGenerator.fromFunction(LamdbaExceptionUtils.rethrowFunction((ModContainer mc) -> parallelClass.getConstructor(ModContainer.class).newInstance(mc))); - this.eventFunctionStream = ()->Stream.of(event); - this.threadSelector = ThreadSelector.PARALLEL; - this.parallelEventClass = Optional.of(parallelClass); - deferredWorkQueue = new DeferredWorkQueue(this, parallelClass); - this.finalActivityGenerator = (e, prev) -> prev.thenApplyAsync((List t) -> { - deferredWorkQueue.runTasks(); - return t; - }, e); - this.preDispatchHook = (t,f)->CompletableFuture.completedFuture(Collections.emptyList()); - this.postDispatchHook = (t,f)->CompletableFuture.completedFuture(Collections.emptyList()); - } - - ModLoadingStage(Supplier>> eventStream) { - this(eventStream, (t,f)->CompletableFuture.completedFuture(Collections.emptyList()), (t,f)->CompletableFuture.completedFuture(Collections.emptyList()), (e, prev) ->prev.thenApplyAsync(Function.identity(), e)); - } - - ModLoadingStage(Supplier>> eventStream, final BiFunction, CompletableFuture>> preDispatchHook, final BiFunction, CompletableFuture>> postDispatchHook, final BiFunction>, CompletableFuture>> finalActivityGenerator) { - this.eventFunctionStream = eventStream; - this.parallelEventClass = Optional.empty(); - this.threadSelector = ThreadSelector.SYNC; - this.preDispatchHook = preDispatchHook; - this.postDispatchHook = postDispatchHook; - this.finalActivityGenerator = finalActivityGenerator; - } - - ModLoadingStage() { - this(ParallelDispatchEvent.class); - } - - public CompletableFuture> buildTransition(final Executor syncExecutor, final Executor parallelExecutor) { - return buildTransition(syncExecutor, parallelExecutor, e->CompletableFuture.runAsync(()->{}, e), e->CompletableFuture.runAsync(()->{}, e)); - } - @SuppressWarnings("unchecked") - public CompletableFuture> buildTransition(final Executor syncExecutor, final Executor parallelExecutor, Function> preSyncTask, Function> postSyncTask) { - List>> cfs = new ArrayList<>(); - this.eventFunctionStream.get() - .map(f->(EventGenerator)f) - .reduce((head, tail)-> addCompletableFutureTaskForModDispatch(syncExecutor, parallelExecutor, cfs, head, ModLoadingStage::currentState, tail)) - .ifPresent(last-> addCompletableFutureTaskForModDispatch(syncExecutor, parallelExecutor, cfs, last, ModLoadingStage::nextState, null)); - final CompletableFuture preSyncTaskCF = preSyncTask.apply(syncExecutor); - final CompletableFuture> eventDispatchCF = ModList.gather(cfs).thenCompose(ModList::completableFutureFromExceptionList); - final CompletableFuture> postEventDispatchCF = preSyncTaskCF.thenComposeAsync(n -> eventDispatchCF, parallelExecutor).thenApply(r -> { - postSyncTask.apply(syncExecutor); - return r; - }); - return this.finalActivityGenerator.apply(syncExecutor, postEventDispatchCF); - } - - @SuppressWarnings("unchecked") - private EventGenerator addCompletableFutureTaskForModDispatch(final Executor syncExecutor, final Executor parallelExecutor, final List>> completeableFutures, final EventGenerator eventGenerator, BiFunction nextState, final EventGenerator nextGenerator) { - completeableFutures.add(((BiFunction, CompletableFuture>>)preDispatchHook).apply(threadSelector.apply(syncExecutor, parallelExecutor), eventGenerator)); - completeableFutures.add(ModList.get().futureVisitor(eventGenerator, nextState).apply(threadSelector.apply(syncExecutor, parallelExecutor))); - completeableFutures.add(((BiFunction, CompletableFuture>>)postDispatchHook).apply(threadSelector.apply(syncExecutor, parallelExecutor), eventGenerator)); - return nextGenerator; - } - - ModLoadingStage nextState(Throwable exception) { - return exception != null ? ERROR : values()[this.ordinal()+1]; - } - - ModLoadingStage currentState(Throwable exception) { - return exception != null ? ERROR : this; - } - - public Optional> getParallelEventClass() { - return parallelEventClass; - } - enum ThreadSelector implements BinaryOperator { - SYNC((sync, parallel)->sync), - PARALLEL((sync, parallel)->parallel); - - private final BinaryOperator selector; - - ThreadSelector(final BinaryOperator selector) { - this.selector = selector; - } - - @Override - public Executor apply(final Executor sync, final Executor parallel) { - return this.selector.apply(sync, parallel); - } - } - - public DeferredWorkQueue getDeferredWorkQueue() { - return deferredWorkQueue; - } - - public interface EventGenerator extends Function { - static EventGenerator fromFunction(Function fn) { - return fn::apply; - } - } -} diff --git a/src/main/java/net/minecraftforge/fml/client/EarlyLoaderGUI.java b/src/main/java/net/minecraftforge/fml/client/EarlyLoaderGUI.java deleted file mode 100644 index 213cead921..0000000000 --- a/src/main/java/net/minecraftforge/fml/client/EarlyLoaderGUI.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fml.client; - -import com.mojang.blaze3d.platform.GlStateManager; -import com.mojang.blaze3d.systems.RenderSystem; - -import net.minecraft.client.MainWindow; -import net.minecraft.client.Minecraft; -import net.minecraft.util.math.MathHelper; -import net.minecraftforge.fml.loading.progress.StartupMessageManager; -import org.apache.commons.lang3.tuple.Pair; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; -import org.lwjgl.stb.STBEasyFont; -import org.lwjgl.system.MemoryUtil; - -import java.lang.management.ManagementFactory; -import java.lang.management.MemoryUsage; -import java.nio.ByteBuffer; -import java.util.List; - -public class EarlyLoaderGUI { - private final MainWindow window; - private boolean handledElsewhere; - - public EarlyLoaderGUI(final MainWindow window) { - this.window = window; - } - - @SuppressWarnings("deprecation") - private void setupMatrix() { - RenderSystem.clear(256, Minecraft.ON_OSX); - RenderSystem.matrixMode(5889); - RenderSystem.loadIdentity(); - RenderSystem.ortho(0.0D, window.getWidth() / window.getGuiScale(), window.getHeight() / window.getGuiScale(), 0.0D, 1000.0D, 3000.0D); - RenderSystem.matrixMode(5888); - RenderSystem.loadIdentity(); - RenderSystem.translatef(0.0F, 0.0F, -2000.0F); - } - - public void handleElsewhere() { - this.handledElsewhere = true; - } - - void renderFromGUI() { - renderMessages(); - } - - @SuppressWarnings("deprecation") - void renderTick() { - if (handledElsewhere) return; - int guiScale = window.calculateScale(0, false); - window.setGuiScale(guiScale); - - RenderSystem.clearColor(1.0f, 1.0f, 1.0f, 1.0f); - RenderSystem.clear(GL11.GL_COLOR_BUFFER_BIT, Minecraft.ON_OSX); - RenderSystem.pushMatrix(); - setupMatrix(); - renderBackground(); - renderMessages(); - window.updateDisplay(); - RenderSystem.popMatrix(); - } - - private void renderBackground() { - GL11.glBegin(GL11.GL_QUADS); - GL11.glColor4f(239F / 255F, 50F / 255F, 61F / 255F, 255F / 255F); //Color from ResourceLoadProgressGui - GL11.glVertex3f(0, 0, -10); - GL11.glVertex3f(0, window.getGuiScaledHeight(), -10); - GL11.glVertex3f(window.getGuiScaledWidth(), window.getGuiScaledHeight(), -10); - GL11.glVertex3f(window.getGuiScaledWidth(), 0, -10); - GL11.glEnd(); - } - - private void renderMessages() { - List> messages = StartupMessageManager.getMessages(); - for (int i = 0; i < messages.size(); i++) { - boolean nofade = i == 0; - final Pair pair = messages.get(i); - final float fade = MathHelper.clamp((4000.0f - (float) pair.getLeft() - ( i - 4 ) * 1000.0f) / 5000.0f, 0.0f, 1.0f); - if (fade <0.01f && !nofade) continue; - StartupMessageManager.Message msg = pair.getRight(); - renderMessage(msg.getText(), msg.getTypeColour(), ((window.getGuiScaledHeight() - 15) / 10) - i + 1, nofade ? 1.0f : fade); - } - renderMemoryInfo(); - } - - private static final float[] memorycolour = new float[] { 0.0f, 0.0f, 0.0f}; - - private void renderMemoryInfo() { - final MemoryUsage heapusage = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage(); - final MemoryUsage offheapusage = ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage(); - final float pctmemory = (float) heapusage.getUsed() / heapusage.getMax(); - String memory = String.format("Memory Heap: %d / %d MB (%.1f%%) OffHeap: %d MB", heapusage.getUsed() >> 20, heapusage.getMax() >> 20, pctmemory * 100.0, offheapusage.getUsed() >> 20); - - final int i = MathHelper.hsvToRgb((1.0f - (float)Math.pow(pctmemory, 1.5f)) / 3f, 1.0f, 0.5f); - memorycolour[2] = ((i) & 0xFF) / 255.0f; - memorycolour[1] = ((i >> 8 ) & 0xFF) / 255.0f; - memorycolour[0] = ((i >> 16 ) & 0xFF) / 255.0f; - renderMessage(memory, memorycolour, 1, 1.0f); - } - - @SuppressWarnings("deprecation") - void renderMessage(final String message, final float[] colour, int line, float alpha) { - GlStateManager._enableClientState(GL11.GL_VERTEX_ARRAY); - ByteBuffer charBuffer = MemoryUtil.memAlloc(message.length() * 270); - int quads = STBEasyFont.stb_easy_font_print(0, 0, message, null, charBuffer); - GL14.glVertexPointer(2, GL11.GL_FLOAT, 16, charBuffer); - - RenderSystem.enableBlend(); - RenderSystem.disableTexture(); - // STBEasyFont's quads are in reverse order or what OGGL expects, so it gets culled for facing the wrong way. - // So Disable culling https://github.com/MinecraftForge/MinecraftForge/pull/6824 - RenderSystem.disableCull(); - GL14.glBlendColor(0,0,0, alpha); - RenderSystem.blendFunc(GlStateManager.SourceFactor.CONSTANT_ALPHA, GlStateManager.DestFactor.ONE_MINUS_CONSTANT_ALPHA); - RenderSystem.color3f(colour[0],colour[1],colour[2]); - RenderSystem.pushMatrix(); - RenderSystem.translatef(10, line * 10, 0); - RenderSystem.scalef(1, 1, 0); - RenderSystem.drawArrays(GL11.GL_QUADS, 0, quads * 4); - RenderSystem.popMatrix(); - - RenderSystem.enableCull(); - GlStateManager._disableClientState(GL11.GL_VERTEX_ARRAY); - MemoryUtil.memFree(charBuffer); - } -} diff --git a/src/main/java/net/minecraftforge/fml/client/registry/RenderingRegistry.java b/src/main/java/net/minecraftforge/fml/client/registry/RenderingRegistry.java deleted file mode 100644 index 1de50b8d4d..0000000000 --- a/src/main/java/net/minecraftforge/fml/client/registry/RenderingRegistry.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fml.client.registry; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import net.minecraft.client.renderer.entity.EntityRenderer; -import net.minecraft.client.renderer.entity.EntityRendererManager; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; - -public class RenderingRegistry -{ - private static final RenderingRegistry INSTANCE = new RenderingRegistry(); - - private final Map, IRenderFactory> entityRenderers = new ConcurrentHashMap<>(); - - /** - * Register an entity rendering handler. This will, after mod initialization, be inserted into the main - * render map for entities. - * Call this during {@link net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent}. - * This method is safe to call during parallel mod loading. - */ - public static void registerEntityRenderingHandler(EntityType entityClass, IRenderFactory renderFactory) - { - INSTANCE.entityRenderers.put(entityClass, renderFactory); - } - - public static void loadEntityRenderers(EntityRendererManager manager) - { - INSTANCE.entityRenderers.forEach((key, value) -> register(manager, key, value)); - manager.validateRendererExistence(); - } - - @SuppressWarnings("unchecked") - private static void register(EntityRendererManager manager, EntityType entityType, IRenderFactory renderFactory) - { - manager.register(entityType, ((IRenderFactory)renderFactory).createRenderFor(manager)); - } -} diff --git a/src/main/java/net/minecraftforge/fml/event/lifecycle/FMLFingerprintViolationEvent.java b/src/main/java/net/minecraftforge/fml/event/lifecycle/FMLFingerprintViolationEvent.java deleted file mode 100644 index ee6d465f8b..0000000000 --- a/src/main/java/net/minecraftforge/fml/event/lifecycle/FMLFingerprintViolationEvent.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fml.event.lifecycle; - -import java.io.File; -import java.util.Set; - -import com.google.common.collect.ImmutableSet; -import net.minecraftforge.fml.common.Mod; - - -/** - * DEPRECATED WITHOUT REPLACEMENT. REMOVE FROM YOUR CODE!!! - * IT HAS NEVER BEEN FIRED IN 1.13+ AND WILL NEVER FIRE AGAIN!!! - * FIRE.JPG FIRE.JPG FIRE.JPG - * DELET THIS - */ -@Deprecated -public class FMLFingerprintViolationEvent extends ModLifecycleEvent -{ - - private final boolean isDirectory; - private final Set fingerprints; - private final File source; - private final String expectedFingerprint; - - public FMLFingerprintViolationEvent(boolean isDirectory, File source, ImmutableSet fingerprints, String expectedFingerprint) - { - super(null); - this.isDirectory = isDirectory; - this.source = source; - this.fingerprints = fingerprints; - this.expectedFingerprint = expectedFingerprint; - } - - public boolean isDirectory() { return isDirectory; } - public Set getFingerprints() { return fingerprints; } - public File getSource() { return source; } - public String getExpectedFingerprint() { return expectedFingerprint; } -} diff --git a/src/main/java/net/minecraftforge/fml/relauncher/libraries/Artifact.java b/src/main/java/net/minecraftforge/fml/relauncher/libraries/Artifact.java deleted file mode 100644 index 63a41384d2..0000000000 --- a/src/main/java/net/minecraftforge/fml/relauncher/libraries/Artifact.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fml.relauncher.libraries; - -import java.io.File; -import java.text.ParseException; -import java.util.Date; -import java.util.Locale; - -import org.apache.maven.artifact.versioning.ComparableVersion; - -public class Artifact implements Comparable -{ - private final Repository repo; - private final String group; - private final String artifact; - private final String classifier; - private final String extension; - private final String value; - private final ComparableVersion version; - private final String timestamp; - private final Date date; - - private String filename; - private String folder; - - public Artifact(Repository repo, String value, String timestamp) - { - this.repo = repo; - this.value = value; - - int idx = value.indexOf('@'); - if (idx > 0) - { - this.extension = value.substring(idx + 1); - value = value.substring(0, idx); - } - else - this.extension = "jar"; - - String[] parts = value.split(":"); - this.group = parts[0]; - this.artifact = parts[1]; - this.version = new ComparableVersion(parts[2]); - this.classifier = parts.length > 3 ? parts[3] : null; - this.timestamp = isSnapshot() ? timestamp : null; - try - { - this.date = this.timestamp == null ? null : SnapshotJson.TIMESTAMP.parse(this.timestamp); - } - catch (ParseException e) - { - throw new RuntimeException(e); //TODO: Better logging? - } - } - - public Artifact(Artifact other, Repository repo, String timestamp) - { - this.repo = repo; - this.group = other.group; - this.artifact = other.artifact; - this.classifier = other.classifier; - this.extension = other.extension; - this.value = other.value; - this.version = other.version; - this.timestamp = timestamp; - try - { - this.date = this.timestamp == null ? null : SnapshotJson.TIMESTAMP.parse(this.timestamp); - } - catch (ParseException e) - { - throw new RuntimeException(e); //TODO: Better logging? - } - } - - @Override - public String toString() - { - return this.value; - } - - @Override - public int hashCode() - { - return this.value.hashCode(); - } - - public String getFilename() - { - if (this.filename == null) - { - StringBuilder sb = new StringBuilder(); - sb.append(artifact).append('-').append(version); - if (isSnapshot() && timestamp != null) - sb.append('-').append(getTimestamp()); - if (classifier != null) - sb.append('-').append(classifier); - sb.append('.').append(extension); - this.filename = sb.toString(); - } - return this.filename; - } - - public String getFolder() - { - if (folder == null) - { - StringBuilder sb = new StringBuilder(); - for (String part : group.split("\\.")) - sb.append(part).append(File.separatorChar); - sb.append(artifact).append(File.separatorChar); - sb.append(version); - folder = sb.toString(); - } - return folder; - } - - public String getPath() - { - return getFolder() + File.separatorChar + getFilename(); - } - - public File getFile() - { - return (repo != null ? repo : LibraryManager.getDefaultRepo()).getFile(getPath()); - } - - public File getSnapshotMeta() - { - if (!isSnapshot()) - throw new IllegalStateException("Attempted to call date suffix on non-snapshot"); - return (repo != null ? repo : LibraryManager.getDefaultRepo()).getFile(getFolder() + File.separatorChar + SnapshotJson.META_JSON_FILE); - } - - public boolean isSnapshot() - { - return version.toString().toLowerCase(Locale.ENGLISH).endsWith("-snapshot"); - } - - public String getTimestamp() - { - if (!isSnapshot()) - throw new IllegalStateException("Attempted to call date suffix on non-snapshot"); - - return timestamp; - } - - public ComparableVersion getVersion() - { - return this.version; - } - - public Repository getRepository() - { - return this.repo; - } - - public boolean matchesID(Artifact o) - { - if (o == null) - return false; - return group.equals(o.group) && artifact.equals(o.artifact) && (o.classifier == null ? classifier == null : o.classifier.equals(classifier)); //TODO: Case sensitive? - } - - public int compareVersion(Artifact o) - { - int ver = version.compareTo(o.version); - if (ver != 0 || !isSnapshot()) return ver; - return timestamp == null ? (o.timestamp == null ? 0 : -1) : o.timestamp == null ? 1 : date.compareTo(o.date); - } - - @Override - public int compareTo(Artifact o) - { - if (o == null) return 1; - if (!group.equals(o.group)) return group.compareTo(o.group); - if (!artifact.equals(o.artifact)) return artifact.compareTo(o.artifact); - if (classifier == null && o.classifier != null) return -1; - if (classifier != null && o.classifier == null) return 1; - if (classifier != null && !classifier.equals(o.classifier)) return classifier.compareTo(o.classifier); - return compareVersion(o); - } -} diff --git a/src/main/java/net/minecraftforge/fml/relauncher/libraries/LibraryManager.java b/src/main/java/net/minecraftforge/fml/relauncher/libraries/LibraryManager.java deleted file mode 100644 index 6f55e2eff8..0000000000 --- a/src/main/java/net/minecraftforge/fml/relauncher/libraries/LibraryManager.java +++ /dev/null @@ -1,502 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fml.relauncher.libraries; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.FilenameFilter; -import java.io.IOException; -import java.io.InputStream; -import java.net.URISyntaxException; -import java.security.CodeSource; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Comparator; -import java.util.Date; -import java.util.HashSet; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import java.util.jar.Attributes; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; -import java.util.jar.Manifest; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; - -import net.minecraftforge.versions.mcp.MCPVersion; -import org.apache.commons.lang3.tuple.Pair; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.apache.maven.artifact.versioning.ArtifactVersion; - -import com.google.common.io.ByteStreams; -import com.google.common.io.Files; - -import net.minecraftforge.fml.loading.FMLEnvironment; - -public class LibraryManager -{ - private static final Logger LOGGER = LogManager.getLogger(); - - public static final boolean DISABLE_EXTERNAL_MANIFEST = Boolean.parseBoolean(System.getProperty("forge.disable_external_manifest", "false")); - public static final boolean ENABLE_AUTO_MOD_MOVEMENT = Boolean.parseBoolean(System.getProperty("forge.enable_auto_mod_movement", "false")); - private static final String LIBRARY_DIRECTORY_OVERRIDE = System.getProperty("forge.lib_folder", null); - private static final List skipContainedDeps = Arrays.asList(System.getProperty("fml.skipContainedDeps","").split(",")); //TODO: Is this used by anyone in the real world? TODO: Remove in 1.13. - private static final FilenameFilter MOD_FILENAME_FILTER = (dir, name) -> name.endsWith(".jar") || name.endsWith(".zip"); //TODO: Disable support for zip in 1.13 - private static final Comparator FILE_NAME_SORTER_INSENSITVE = (o1, o2) -> o1.getName().toLowerCase(Locale.ENGLISH).compareTo(o2.getName().toLowerCase(Locale.ENGLISH)); - - public static final Attributes.Name MODSIDE = new Attributes.Name("ModSide"); - private static final Attributes.Name MODCONTAINSDEPS = new Attributes.Name("ContainedDeps"); - private static final Attributes.Name MAVEN_ARTIFACT = new Attributes.Name("Maven-Artifact"); - private static final Attributes.Name TIMESTAMP = new Attributes.Name("Timestamp"); - private static final Attributes.Name MD5 = new Attributes.Name("MD5"); - private static Repository libraries_dir = null; - private static Set processed = new HashSet(); - - public static void setup(File minecraftHome) - { - File libDir = findLibraryFolder(minecraftHome); - LOGGER.debug("Determined Minecraft Libraries Root: {}", libDir); - Repository old = Repository.replace(libDir, "libraries"); - if (old != null) - LOGGER.debug(" Overwriting Previous: {}", old); - libraries_dir = Repository.get("libraries"); - - File mods = new File(minecraftHome, "mods"); - File mods_ver = new File(mods, MCPVersion.getMCVersion()); - - ModList memory = null; - if (!ENABLE_AUTO_MOD_MOVEMENT) - { - Repository repo = new LinkRepository(new File(mods, "memory_repo")); - memory = new MemoryModList(repo); - ModList.cache.put("MEMORY", memory); - Repository.cache.put("MEMORY", repo); - } - - for (File dir : new File[]{mods, mods_ver}) - cleanDirectory(dir, ENABLE_AUTO_MOD_MOVEMENT ? ModList.create(new File(dir, "mod_list.json"), minecraftHome) : memory, mods_ver, mods); - - for (ModList list : ModList.getKnownLists(minecraftHome)) - { - Repository repo = list.getRepository() == null ? libraries_dir : list.getRepository(); - List artifacts = list.getArtifacts(); - // extractPacked adds artifacts to the list. As such, we can't use an Iterator to traverse it. - for (int i = 0; i < artifacts.size(); i++) - { - Artifact artifact = artifacts.get(i); - Artifact resolved = repo.resolve(artifact); - if (resolved != null) - { - File target = repo.getFile(resolved.getPath()); - if (target.exists()) - extractPacked(target, list, mods_ver, mods); - } - } - } - } - - private static File findLibraryFolder(File minecraftHome) - { - if (LIBRARY_DIRECTORY_OVERRIDE != null) - { - LOGGER.error("System variable set to override Library Directory: {}", LIBRARY_DIRECTORY_OVERRIDE); - return new File(LIBRARY_DIRECTORY_OVERRIDE); - } - - CodeSource source = ArtifactVersion.class.getProtectionDomain().getCodeSource(); - if (source == null) - { - LOGGER.error("Unable to determine codesource for {}. Using default libraries directory.", ArtifactVersion.class.getName()); - return new File(minecraftHome, "libraries"); - } - - try - { - File apache = new File(source.getLocation().toURI()); - if (apache.isFile()) - apache = apache.getParentFile(); //Get to a directory, this *should* always be the case... - apache = apache.getParentFile(); //Skip the version folder. In case we ever update the version, I don't want to edit this code again. - String comp = apache.getAbsolutePath().toLowerCase(Locale.ENGLISH).replace('\\', '/'); - if (!comp.endsWith("/")) - comp += '/'; - - if (!comp.endsWith("/org/apache/maven/maven-artifact/")) - { - LOGGER.error("Apache Maven library folder was not in the format expected. Using default libraries directory."); - LOGGER.error("Full: {}", new File(source.getLocation().toURI())); - LOGGER.error("Trimmed: {}", comp); - return new File(minecraftHome, "libraries"); - } - // maven-artifact /maven /apache /org /libraries - return apache .getParentFile().getParentFile().getParentFile().getParentFile(); - } - catch (URISyntaxException e) - { - LOGGER.error(LOGGER.getMessageFactory().newMessage("Unable to determine file for {}. Using default libraries directory.", ArtifactVersion.class.getName()), e); - } - - return new File(minecraftHome, "libraries"); //Everything else failed, return the default. - } - - private static void cleanDirectory(File dir, ModList modlist, File... modDirs) - { - if (!dir.exists()) - return; - - LOGGER.debug("Cleaning up mods folder: {}", dir); - for (File file : dir.listFiles(f -> f.isFile() && f.getName().endsWith(".jar"))) - { - Pair ret = extractPacked(file, modlist, modDirs); - if (ret != null) - { - Artifact artifact = ret.getLeft(); - Repository repo = modlist.getRepository() == null ? libraries_dir : modlist.getRepository(); - File moved = repo.archive(artifact, file, ret.getRight()); - processed.add(moved); - } - } - - try - { - if (modlist.changed()) - modlist.save(); - } - catch (IOException e) - { - LOGGER.error(LOGGER.getMessageFactory().newMessage("Error updating modlist file {}", modlist.getName()), e); - } - } - - private static Pair extractPacked(File file, ModList modlist, File... modDirs) - { - if (processed.contains(file)) - { - LOGGER.debug("File already proccessed {}, Skipping", file.getAbsolutePath()); - return null; - } - JarFile jar = null; - try - { - jar = new JarFile(file); - LOGGER.debug("Examining file: {}", file.getName()); - processed.add(file); - return extractPacked(jar, modlist, modDirs); - } - catch (IOException ioe) - { - LOGGER.error("Unable to read the jar file {} - ignoring", file.getName(), ioe); - } - finally - { - try { - if (jar != null) - jar.close(); - } catch (IOException e) {} - } - return null; - } - private static Pair extractPacked(JarFile jar, ModList modlist, File... modDirs) throws IOException - { - Attributes attrs; - if (jar.getManifest() == null) - return null; - - JarEntry manifest_entry = jar.getJarEntry(JarFile.MANIFEST_NAME); - if (manifest_entry == null) - manifest_entry = jar.stream().filter(e -> JarFile.MANIFEST_NAME.equals(e.getName().toUpperCase(Locale.ENGLISH))).findFirst().get(); //We know that getManifest returned non-null so we know there is *some* entry that matches the manifest file. So we dont need to empty check. - - attrs = jar.getManifest().getMainAttributes(); - - String modSide = attrs.getValue(LibraryManager.MODSIDE); - if (modSide != null && !"BOTH".equals(modSide) && !FMLEnvironment.dist.name().equals(modSide)) - return null; - - if (attrs.containsKey(MODCONTAINSDEPS)) - { - for (String dep : attrs.getValue(MODCONTAINSDEPS).split(" ")) - { - if (!dep.endsWith(".jar")) - { - LOGGER.error("Contained Dep is not a jar file: {}", dep); - throw new IllegalStateException("Invalid contained dep, Must be jar: " + dep); - } - - if (jar.getJarEntry(dep) == null && jar.getJarEntry("META-INF/libraries/" + dep) != null) - dep = "META-INF/libraries/" + dep; - - JarEntry depEntry = jar.getJarEntry(dep); - if (depEntry == null) - { - LOGGER.error("Contained Dep is not in the jar: {}", dep); - throw new IllegalStateException("Invalid contained dep, Missing from jar: " + dep); - } - - String depEndName = new File(dep).getName(); // extract last part of name - if (skipContainedDeps.contains(dep) || skipContainedDeps.contains(depEndName)) - { - LOGGER.error("Skipping dep at request: {}", dep); - continue; - } - - Attributes meta = null; - byte[] data = null; - byte[] manifest_data = null; - - JarEntry metaEntry = jar.getJarEntry(dep + ".meta"); - if (metaEntry != null) - { - manifest_data = readAll(jar.getInputStream(metaEntry)); - meta = new Manifest(new ByteArrayInputStream(manifest_data)).getMainAttributes(); - } - else - { - data = readAll(jar.getInputStream(depEntry)); - try (ZipInputStream zi = new ZipInputStream(new ByteArrayInputStream(data))) //We use zip input stream directly, as the current Oracle implementation of JarInputStream only works when the manifest is the First/Second entry in the jar... - { - ZipEntry ze = null; - while ((ze = zi.getNextEntry()) != null) - { - if (ze.getName().equalsIgnoreCase(JarFile.MANIFEST_NAME)) - { - manifest_data = readAll(zi); - meta = new Manifest(new ByteArrayInputStream(manifest_data)).getMainAttributes(); - break; - } - } - } - } - - if (meta == null || !meta.containsKey(MAVEN_ARTIFACT)) //Ugh I really don't want to do backwards compatibility here, I want to force modders to provide information... TODO: Remove in 1.13? - { - boolean found = false; - for (File dir : modDirs) - { - File target = new File(dir, depEndName); - if (target.exists()) - { - LOGGER.debug("Found existing ContainDep extracted to {}, skipping extraction", target.getCanonicalPath()); - found = true; - } - } - if (!found) - { - File target = new File(modDirs[0], depEndName); - LOGGER.debug("Extracting ContainedDep {} from {} to {}", dep, jar.getName(), target.getCanonicalPath()); - try - { - Files.createParentDirs(target); - try - ( - FileOutputStream out = new FileOutputStream(target); - InputStream in = data == null ? jar.getInputStream(depEntry) : new ByteArrayInputStream(data) - ) - { - ByteStreams.copy(in, out); - } - LOGGER.debug("Extracted ContainedDep {} from {} to {}", dep, jar.getName(), target.getCanonicalPath()); - extractPacked(target, modlist, modDirs); - } - catch (IOException e) - { - LOGGER.error("An error occurred extracting dependency", e); - } - } - } - else - { - try - { - Artifact artifact = readArtifact(modlist.getRepository(), meta); - File target = artifact.getFile(); - if (target.exists()) - { - LOGGER.debug("Found existing ContainedDep {}({}) from {} extracted to {}, skipping extraction", dep, artifact.toString(), target.getCanonicalPath(), jar.getName()); - if (!ENABLE_AUTO_MOD_MOVEMENT) - { - Pair child = extractPacked(target, modlist, modDirs); //If we're not building a real list we have to re-build the dep list every run. So search down. - if (child == null && metaEntry != null) //External meta with no internal name... If there is a internal name, we trust that that name is the correct one. - { - modlist.add(artifact); - } - } - } - else - { - LOGGER.debug("Extracting ContainedDep {}({}) from {} to {}", dep, artifact.toString(), jar.getName(), target.getCanonicalPath()); - Files.createParentDirs(target); - try - ( - FileOutputStream out = new FileOutputStream(target); - InputStream in = data == null ? jar.getInputStream(depEntry) : new ByteArrayInputStream(data) - ) - { - ByteStreams.copy(in, out); - } - LOGGER.debug("Extracted ContainedDep {}({}) from {} to {}", dep, artifact.toString(), jar.getName(), target.getCanonicalPath()); - - if (artifact.isSnapshot()) - { - SnapshotJson json = SnapshotJson.create(artifact.getSnapshotMeta()); - json.add(new SnapshotJson.Entry(artifact.getTimestamp(), meta.getValue(MD5))); - json.write(artifact.getSnapshotMeta()); - } - - if (!DISABLE_EXTERNAL_MANIFEST) - { - File meta_target = new File(target.getAbsolutePath() + ".meta"); - Files.write(manifest_data, meta_target); - } - Pair child = extractPacked(target, modlist, modDirs); - if (child == null && metaEntry != null) //External meta with no internal name... If there is a internal name, we trust that that name is the correct one. - { - modlist.add(artifact); - } - } - } - catch (NumberFormatException nfe) - { - LOGGER.error(LOGGER.getMessageFactory().newMessage("An error occurred extracting dependency. Invalid Timestamp: {}", meta.getValue(TIMESTAMP)), nfe); - } - catch (IOException e) - { - LOGGER.error("An error occurred extracting dependency", e); - } - } - } - } - - if (attrs.containsKey(MAVEN_ARTIFACT)) - { - Artifact artifact = readArtifact(modlist.getRepository(), attrs); - modlist.add(artifact); - return Pair.of(artifact, readAll(jar.getInputStream(manifest_entry))); - } - return null; - } - - private static Artifact readArtifact(Repository repo, Attributes meta) - { - String timestamp = meta.getValue(TIMESTAMP); - if (timestamp != null) - timestamp = SnapshotJson.TIMESTAMP.format(new Date(Long.parseLong(timestamp))); - - return new Artifact(repo, meta.getValue(MAVEN_ARTIFACT), timestamp); - } - - private static byte[] readAll(InputStream in) throws IOException - { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - int read = -1; - byte[] data = new byte[1024 * 16]; - - while ((read = in.read(data, 0, data.length)) != -1) - out.write(data, 0, read); - - out.flush(); - return out.toByteArray(); - } - - public static List flattenLists(File mcDir) - { - List merged = new ArrayList<>(); - for (ModList list : ModList.getBasicLists(mcDir)) - { - for (Artifact art : list.flatten()) - { - Optional old = merged.stream().filter(art::matchesID).findFirst(); - if (!old.isPresent()) - { - merged.add(art); - } - else if (old.get().getVersion().compareTo(art.getVersion()) < 0) - { - merged.add(merged.indexOf(old.get()), art); - merged.remove(old.get()); - } - } - } - return merged; - } - - public static List gatherLegacyCanidates(File mcDir) - { - List list = new ArrayList<>(); - - Map args = Collections.emptyMap(); // TODO Launch args - do we need this? (Map)Launcher.INSTANCE.blackboard().get("launchArgs"); - String extraMods = args.get("--mods"); - if (extraMods != null) - { - LOGGER.info("Found mods from the command line:"); - for (String mod : extraMods.split(",")) - { - File file = new File(mcDir, mod); - if (!file.exists()) - { - LOGGER.info(" Failed to find mod file {} ({})", mod, file.getAbsolutePath()); - } - else if (!list.contains(file)) - { - LOGGER.debug(" Adding {} ({}) to the mod list", mod, file.getAbsolutePath()); - list.add(file); - } - else if (!list.contains(file)) - { - LOGGER.debug(" Duplicte command line mod detected {} ({})", mod, file.getAbsolutePath()); - } - } - } - - for (String dir : new String[]{"mods", "mods" + File.separatorChar + MCPVersion.getMCVersion()}) - { - File base = new File(mcDir, dir); - if (!base.isDirectory() || !base.exists()) - continue; - - LOGGER.info("Searching {} for mods", base.getAbsolutePath()); - for (File f : base.listFiles(MOD_FILENAME_FILTER)) - { - if (!list.contains(f)) - { - LOGGER.debug(" Adding {} to the mod list", f.getName()); - list.add(f); - } - } - } - - ModList memory = ModList.cache.get("MEMORY"); - if (!ENABLE_AUTO_MOD_MOVEMENT && memory != null && memory.getRepository() != null) - memory.getRepository().filterLegacy(list); - - list.sort(FILE_NAME_SORTER_INSENSITVE); - return list; - } - - public static Repository getDefaultRepo() - { - return libraries_dir; - } -} diff --git a/src/main/java/net/minecraftforge/fml/relauncher/libraries/LinkRepository.java b/src/main/java/net/minecraftforge/fml/relauncher/libraries/LinkRepository.java deleted file mode 100644 index 8833fb9e41..0000000000 --- a/src/main/java/net/minecraftforge/fml/relauncher/libraries/LinkRepository.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fml.relauncher.libraries; - -import java.io.File; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -public class LinkRepository extends Repository -{ - private static final Logger LOGGER = LogManager.getLogger(); - - private Map artifact_to_file = new HashMap<>(); - private Map filesystem = new HashMap<>(); - private Map snapshots = new HashMap<>(); - private Set known = new HashSet<>(); - - LinkRepository(File root) - { - super(root, "MEMORY"); - } - - public File archive(Artifact artifact, File file, byte[] manifest) - { - String key = artifact.toString(); - known.add(file); - if (artifact_to_file.containsKey(key)) - { - LOGGER.debug("Maven file already exists for {}({}) at {}, ignoring duplicate.", file.getName(), artifact.toString(), artifact_to_file.get(key).getAbsolutePath()); - - if (artifact.isSnapshot()) - { - Artifact old = snapshots.get(key); - if (old == null || old.compareVersion(artifact) < 0) - { - LOGGER.debug("Overriding Snapshot {} -> {}", old == null ? "null" : old.getTimestamp(), artifact.getTimestamp()); - snapshots.put(key, artifact); - artifact_to_file.put(key, file); - filesystem.put(artifact.getPath(), file); - } - } - } - else - { - LOGGER.debug("Making maven link for {} in memory to {}.", key, file.getAbsolutePath()); - artifact_to_file.put(key, file); - filesystem.put(artifact.getPath(), file); - - if (artifact.isSnapshot()) - snapshots.put(key, artifact); - - /* Support external meta? screw it. - if (!LibraryManager.DISABLE_EXTERNAL_MANIFEST) - { - File meta_target = new File(target.getAbsolutePath() + ".meta"); - Files.write(manifest, meta_target); - } - */ - } - return file; - } - - @Override - public void filterLegacy(List list) - { - list.removeIf(e -> known.contains(e)); - } - - public Artifact resolve(Artifact artifact) - { - String key = artifact.toString(); - File file = artifact_to_file.get(key); - if (file == null || !file.exists()) - return super.resolve(artifact); - return new Artifact(artifact, this, artifact.isSnapshot() ? artifact.getTimestamp() : null); - } - - @Override - public File getFile(String path) - { - return filesystem.containsKey(path) ? filesystem.get(path) : super.getFile(path); - } -} diff --git a/src/main/java/net/minecraftforge/fml/relauncher/libraries/ModList.java b/src/main/java/net/minecraftforge/fml/relauncher/libraries/ModList.java deleted file mode 100644 index dcd5bdc009..0000000000 --- a/src/main/java/net/minecraftforge/fml/relauncher/libraries/ModList.java +++ /dev/null @@ -1,250 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fml.relauncher.libraries; - -import java.io.File; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.stream.Collectors; - -import net.minecraftforge.versions.mcp.MCPVersion; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import com.google.common.collect.ImmutableList; -import com.google.common.io.Files; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonSyntaxException; - -public class ModList -{ - private static final Logger LOGGER = LogManager.getLogger(); - - private static final Gson GSON = new GsonBuilder().setLenient().create(); - static final Map cache = new HashMap<>(); - - public static ModList create(File json, File mcdir) - { - try - { - String key = json.getCanonicalFile().getAbsolutePath(); - return cache.computeIfAbsent(key, k -> new ModList(json, mcdir)); - } - catch (IOException e) - { - LOGGER.error(LOGGER.getMessageFactory().newMessage("Unable to load ModList json at {}.", json.getAbsoluteFile()), e); - } - - return new ModList(json, mcdir); - } - - @SuppressWarnings("unchecked") - public static List getKnownLists(File mcdir) - { - for (String list : new String[] {"mods/mod_list.json", "mods/" + MCPVersion.getMCVersion() + "/mod_list.json"/* , TODO Launch args ((Map)Launch.blackboard.get("launchArgs")).get("--modListFile")*/}) - { - if (list != null) - { - File listFile = getFile(mcdir, list); - if (listFile != null && listFile.exists()) - create(listFile, mcdir); //Create will recursively create parent lists, so after this run everything should be populated. - } - } - return ImmutableList.copyOf(cache.values()); //TODO: Do we care about order? I dont think so as we resolve all libs in a flat map. - } - - @SuppressWarnings("unchecked") - public static List getBasicLists(File mcdir) - { - List lst = new ArrayList<>(); - - ModList memory = cache.get("MEMORY"); - if (memory != null) - lst.add(memory); - - for (String list : new String[] {"mods/mod_list.json", "mods/" + MCPVersion.getMCVersion() + "/mod_list.json"/* TODO Launch args, ((Map)Launch.blackboard.get("launchArgs")).get("--modListFile")*/}) - { - if (list != null) - { - File listFile = getFile(mcdir, list); - if (listFile != null && listFile.exists()) - lst.add(create(listFile, mcdir)); - } - } - return lst; - } - - private final File path; - private final JsonModList mod_list; - private final Repository repo; - private final ModList parent; - private final List artifacts = new ArrayList<>(); - private final List artifacts_imm = Collections.unmodifiableList(artifacts); - private final Map art_map = new HashMap<>(); - - private boolean changed = false; - - protected ModList(Repository repo) - { - this.path = null; - this.mod_list = new JsonModList(); - this.repo = repo; - this.parent = null; - } - - private ModList(File path, File mcdir) - { - this.path = path; - JsonModList temp_list = null; - if (this.path.exists()) - { - try - { - String json = Files.asCharSource(path, StandardCharsets.UTF_8).read(); - temp_list = GSON.fromJson(json, JsonModList.class); - } - catch (JsonSyntaxException jse) - { - LOGGER.info(LOGGER.getMessageFactory().newMessage("Failed to parse modList json file {}.", path), jse); - } - catch (IOException ioe) - { - LOGGER.info(LOGGER.getMessageFactory().newMessage("Failed to read modList json file {}.", path), ioe); - } - } - this.mod_list = temp_list == null ? new JsonModList() : temp_list; - Repository temp = null; - if (mod_list.repositoryRoot != null) - { - try - { - File repoFile = getFile(mcdir, this.mod_list.repositoryRoot); - if (repoFile != null) - { - temp = Repository.create(repoFile); - } - } - catch (IOException e) - { - LOGGER.info(LOGGER.getMessageFactory().newMessage("Failed to create repository for modlist at {}.", mod_list.repositoryRoot), e); - } - } - this.repo = temp; - File parent_path = this.mod_list.parentList == null ? null : getFile(mcdir, this.mod_list.parentList); - this.parent = parent_path == null || !parent_path.exists() ? null : ModList.create(parent_path, mcdir); - - if (mod_list.modRef != null) - { - for (String ref : mod_list.modRef) - add(new Artifact(this.getRepository(), ref, null)); - changed = false; - } - } - - public Repository getRepository() - { - return this.repo; - } - - public void add(Artifact artifact) - { - Artifact old = art_map.get(artifact.toString()); - if (old != null) - { - artifacts.add(artifacts.indexOf(old), artifact); - artifacts.remove(old); - } - else - artifacts.add(artifact); - art_map.put(artifact.toString(), artifact); - changed = true; - } - - public List getArtifacts() - { - return artifacts_imm; - } - - public boolean changed() - { - return changed; - } - - public void save() throws IOException - { - mod_list.modRef = artifacts.stream().map(a -> a.toString()).collect(Collectors.toList()); - Files.write(GSON.toJson(mod_list), path, StandardCharsets.UTF_8); - } - - private static File getFile(File root, String path) - { - try - { - if (path.startsWith("absolute:")) - return new File(path.substring(9)).getCanonicalFile(); - else - return new File(root, path).getCanonicalFile(); - } - catch (IOException ioe) - { - LOGGER.info(LOGGER.getMessageFactory().newMessage("Unable to canonicalize path {} relative to {}", path, root.getAbsolutePath())); - } - return null; - } - - private static class JsonModList - { - public String repositoryRoot; - public List modRef; - public String parentList; - } - - //TODO: Some form of caching? - public List flatten() - { - List lst = parent == null ? new ArrayList<>() : parent.flatten(); - for (Artifact art : artifacts) - { - Optional old = lst.stream().filter(art::matchesID).findFirst(); - if (!old.isPresent()) - { - lst.add(art); - } - else if (old.get().getVersion().compareTo(art.getVersion()) < 0) - { - lst.add(lst.indexOf(old.get()), art); - lst.remove(old.get()); - } - } - return lst; - } - - public Object getName() - { - return path.getAbsolutePath(); - } -} diff --git a/src/main/java/net/minecraftforge/fml/relauncher/libraries/Repository.java b/src/main/java/net/minecraftforge/fml/relauncher/libraries/Repository.java deleted file mode 100644 index 66b5e45e1c..0000000000 --- a/src/main/java/net/minecraftforge/fml/relauncher/libraries/Repository.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fml.relauncher.libraries; - -import java.io.File; -import java.io.IOException; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import com.google.common.hash.Hashing; -import com.google.common.io.Files; - -public class Repository -{ - private static final Logger LOGGER = LogManager.getLogger(); - - static final Map cache = new LinkedHashMap<>(); - - public static Repository create(File root) throws IOException - { - return create(root, root.getCanonicalPath()); - } - public static Repository create(File root, String name) - { - return cache.computeIfAbsent(name, f -> new Repository(root, name)); - } - public static Repository replace(File root, String name) - { - return cache.put(name, new Repository(root, name)); - } - public static Repository get(String name) - { - return cache.get(name); - } - public static Artifact resolveAll(Artifact artifact) - { - Artifact ret = null; - for (Repository repo : cache.values()) - { - Artifact tmp = repo.resolve(artifact); - if (tmp == null) - continue; - if (!artifact.isSnapshot()) - return tmp; //If its a concrete version *assume* any resolved one in any repo will work. As they shouldn't release overriding versions. - ret = ret == null || ret.compareTo(tmp) < 0 ? tmp : ret; - } - return ret; - } - - - private final String name; - private final File root; - - protected Repository(File root) throws IOException - { - this(root, root.getCanonicalPath()); - } - protected Repository(File root, String name) - { - this.root = root; - this.name = name; - if (name == null) - throw new IllegalArgumentException("Invalid Repository Name, for " + root); - } - - @Override - public int hashCode() - { - return this.name.hashCode(); - } - - @Override - public boolean equals(Object o) - { - return o instanceof Repository && ((Repository)o).name.equals(name); - } - - public Artifact resolve(Artifact artifact) - { - if (!artifact.isSnapshot()) - return getFile(artifact.getPath()).exists() ? artifact : null; - - File meta = getFile(artifact.getFolder() + File.separatorChar + SnapshotJson.META_JSON_FILE); - if (!meta.exists()) - return null; - - SnapshotJson json = SnapshotJson.create(getFile(artifact.getFolder() + File.separatorChar + SnapshotJson.META_JSON_FILE)); - if (json.getLatest() == null) - return null; - - Artifact ret = new Artifact(artifact, this, json.getLatest()); - while (json.getLatest() != null && !getFile(ret.getPath()).exists()) - { - if (!json.remove(json.getLatest())) - throw new IllegalStateException("Something went wrong, Latest (" + json.getLatest() + ") did not point to an entry in the json list: " + meta.getAbsolutePath()); - ret = new Artifact(artifact, this, json.getLatest()); - } - - return getFile(ret.getPath()).exists() ? ret : null; - } - - public File getFile(String path) - { - return new File(root, path); - } - - public File archive(Artifact artifact, File file, byte[] manifest) - { - File target = artifact.getFile(); - try - { - if (target.exists()) - { - LOGGER.debug("Maven file already exists for {}({}) at {}, deleting duplicate.", file.getName(), artifact.toString(), target.getAbsolutePath()); - file.delete(); - } - else - { - LOGGER.debug("Moving file {}({}) to maven repo at {}.", file.getName(), artifact.toString(), target.getAbsolutePath()); - Files.move(file, target); - - if (artifact.isSnapshot()) - { - SnapshotJson json = SnapshotJson.create(artifact.getSnapshotMeta()); - json.add(new SnapshotJson.Entry(artifact.getTimestamp(), Files.hash(target, Hashing.md5()).toString())); - json.write(artifact.getSnapshotMeta()); - } - - if (!LibraryManager.DISABLE_EXTERNAL_MANIFEST) - { - File meta_target = new File(target.getAbsolutePath() + ".meta"); - Files.write(manifest, meta_target); - } - } - return target; - } - catch (IOException e) - { - LOGGER.error(LOGGER.getMessageFactory().newMessage("Error moving file {} to {}", file, target.getAbsolutePath()), e); - } - return file; - } - - public void filterLegacy(List list){} -} diff --git a/src/main/java/net/minecraftforge/fml/relauncher/libraries/SnapshotJson.java b/src/main/java/net/minecraftforge/fml/relauncher/libraries/SnapshotJson.java deleted file mode 100644 index 63b3d5b623..0000000000 --- a/src/main/java/net/minecraftforge/fml/relauncher/libraries/SnapshotJson.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fml.relauncher.libraries; - -import java.io.File; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import com.google.common.io.Files; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonSyntaxException; - -/** - * This is different from the standard maven snapshot metadata. - * Because none of that data is exposed to us as a user of gradle/maven/whatever. - * So we JUST use the timestamp. - * - * { - * "latest": "yyyyMMdd.hhmmss", - * "versions": [ - * { - * "md5": "md5 in hex lowercase", - * "timestamp": "yyyyMMdd.hhmmss" - * ] - * } - * - */ -public class SnapshotJson implements Comparable -{ - private static final Logger LOGGER = LogManager.getLogger(); - public static final DateFormat TIMESTAMP = new SimpleDateFormat("yyyyMMdd.hhmmss"); - public static final String META_JSON_FILE = "maven-metadata.json"; - private static final Gson GSON = new GsonBuilder().create(); - private static final Comparator SORTER = (o1, o2) -> o2.timestamp.compareTo(o1.timestamp); - - public static SnapshotJson create(File target) - { - if (!target.exists()) - return new SnapshotJson(); - - try - { - String json = Files.asCharSource(target, StandardCharsets.UTF_8).read(); - SnapshotJson obj = GSON.fromJson(json, SnapshotJson.class); - obj.updateLatest(); - return obj; - } - catch (JsonSyntaxException jse) - { - LOGGER.info("Failed to parse snapshot json file " + target + ".", jse); - } - catch (IOException ioe) - { - LOGGER.info("Failed to read snapshot json file " + target + ".", ioe); - } - - return new SnapshotJson(); - } - - private String latest; - private List versions; - - public String getLatest() - { - return this.latest; - } - - public void add(Entry data) - { - if (versions == null) - versions = new ArrayList<>(); - versions.add(data); - updateLatest(); - } - - public void merge(SnapshotJson o) - { - if (o.versions != null) - { - if (versions == null) - versions = new ArrayList<>(o.versions); - else - o.versions.stream().filter(e -> versions.stream().anyMatch(e2 -> e.timestamp.equals(e2.timestamp))).forEach(e -> versions.add(e)); - updateLatest(); - } - } - - public boolean remove(String timestamp) - { - if (versions == null) - return false; - if (versions.removeIf(e -> e.timestamp.equals(timestamp))) - updateLatest(); - return false; - } - - public String updateLatest() - { - if (versions == null) - { - latest = null; - return null; - } - Collections.sort(versions, SORTER); - return latest = versions.isEmpty() ? null : versions.get(0).timestamp; - } - - public void write(File target) throws IOException - { - Files.write(GSON.toJson(this), target, StandardCharsets.UTF_8); - } - - @Override - public int compareTo(SnapshotJson o) - { - return o == null ? 1 : o.latest == null ? latest == null ? 0 : 1 : latest == null ? -1 : o.latest.compareTo(latest); - } - - public static class Entry - { - private String timestamp; - private String md5; - - public Entry(String timestamp, String md5) - { - this.timestamp = timestamp; - this.md5 = md5; - } - - public String getTimestamp() - { - return this.timestamp; - } - - public String getMd5() - { - return this.md5; - } - } -} diff --git a/src/main/java/net/minecraftforge/fml/client/ClientHooks.java b/src/main/java/net/minecraftforge/fmlclient/ClientHooks.java similarity index 82% rename from src/main/java/net/minecraftforge/fml/client/ClientHooks.java rename to src/main/java/net/minecraftforge/fmlclient/ClientHooks.java index 40bd53c742..4c72f5e7bf 100644 --- a/src/main/java/net/minecraftforge/fml/client/ClientHooks.java +++ b/src/main/java/net/minecraftforge/fmlclient/ClientHooks.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.client; +package net.minecraftforge.fmlclient; import java.io.File; import java.util.*; @@ -31,19 +31,20 @@ import com.google.common.collect.HashMultimap; import com.google.common.collect.SetMultimap; import com.google.common.collect.Sets; import com.google.common.collect.Table; -import com.mojang.blaze3d.matrix.MatrixStack; -import net.minecraft.client.entity.player.ClientPlayerEntity; -import net.minecraft.client.gui.AbstractGui; -import net.minecraft.client.gui.screen.MultiplayerScreen; -import net.minecraft.client.multiplayer.PlayerController; -import net.minecraft.util.text.StringTextComponent; +import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.client.gui.GuiComponent; +import net.minecraft.client.gui.screens.multiplayer.JoinMultiplayerScreen; +import net.minecraft.client.multiplayer.MultiPlayerGameMode; +import net.minecraft.network.chat.TextComponent; import net.minecraftforge.client.event.ClientPlayerNetworkEvent; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.ExtensionPoint; -import net.minecraftforge.fml.ForgeI18n; +import net.minecraftforge.fml.IExtensionPoint; +import net.minecraftforge.fmllegacy.ForgeI18n; import net.minecraftforge.fml.ModList; -import net.minecraftforge.fml.network.FMLNetworkConstants; -import net.minecraftforge.fml.network.NetworkRegistry; +import net.minecraftforge.fmllegacy.network.FMLNetworkConstants; +import net.minecraftforge.fmllegacy.network.NetworkRegistry; import net.minecraftforge.versions.forge.ForgeVersion; import org.apache.commons.lang3.tuple.Pair; import org.apache.logging.log4j.LogManager; @@ -56,17 +57,17 @@ import com.google.common.base.Strings; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ServerData; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.network.NetworkManager; -import net.minecraft.network.ServerStatusResponse; -import net.minecraft.resources.ResourcePack; -import net.minecraft.resources.FallbackResourceManager; -import net.minecraft.resources.IResourcePack; -import net.minecraft.resources.SimpleReloadableResourceManager; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.common.ObfuscationReflectionHelper; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.network.Connection; +import net.minecraft.network.protocol.status.ServerStatus; +import net.minecraft.server.packs.AbstractPackResources; +import net.minecraft.server.packs.resources.FallbackResourceManager; +import net.minecraft.server.packs.PackResources; +import net.minecraft.server.packs.resources.SimpleReloadableResourceManager; +import net.minecraft.resources.ResourceLocation; +import net.minecraftforge.fml.util.ObfuscationReflectionHelper; import net.minecraftforge.forgespi.language.IModInfo; -import net.minecraftforge.fml.packs.ModFileResourcePack; +import net.minecraftforge.fmllegacy.packs.ModFileResourcePack; import net.minecraftforge.registries.GameData; public class ClientHooks @@ -77,7 +78,7 @@ public class ClientHooks private static final ResourceLocation iconSheet = new ResourceLocation(ForgeVersion.MOD_ID, "textures/gui/icons.png"); @Nullable - public static void processForgeListPingData(ServerStatusResponse packet, ServerData target) + public static void processForgeListPingData(ServerStatus packet, ServerData target) { if (packet.getForgeData() != null) { final Map mods = packet.getForgeData().getRemoteModData(); @@ -89,8 +90,8 @@ public class ClientHooks AtomicBoolean result = new AtomicBoolean(true); final List extraClientMods = new ArrayList<>(); ModList.get().forEachModContainer((modid, mc) -> - mc.getCustomExtension(ExtensionPoint.DISPLAYTEST).ifPresent(ext-> { - boolean foundModOnServer = ext.getRight().test(mods.get(modid), true); + mc.getCustomExtension(IExtensionPoint.DisplayTest.class).ifPresent(ext-> { + boolean foundModOnServer = ext.remoteVersionTest().test(mods.get(modid), true); result.compareAndSet(true, foundModOnServer); if (!foundModOnServer) { extraClientMods.add(modid); @@ -135,7 +136,7 @@ public class ClientHooks } - public static void drawForgePingInfo(MultiplayerScreen gui, ServerData target, MatrixStack mStack, int x, int y, int width, int relativeMouseX, int relativeMouseY) { + public static void drawForgePingInfo(JoinMultiplayerScreen gui, ServerData target, PoseStack mStack, int x, int y, int width, int relativeMouseX, int relativeMouseY) { int idx; String tooltip; if (target.forgeData == null) @@ -173,13 +174,13 @@ public class ClientHooks tooltip = ForgeI18n.parseMessage("fml.menu.multiplayer.unknown", target.forgeData.type); } - Minecraft.getInstance().getTextureManager().bind(iconSheet); - AbstractGui.blit(mStack, x + width - 18, y + 10, 16, 16, 0, idx, 16, 16, 256, 256); + RenderSystem.setShaderTexture(0, iconSheet); + GuiComponent.blit(mStack, x + width - 18, y + 10, 16, 16, 0, idx, 16, 16, 256, 256); if(relativeMouseX > width - 15 && relativeMouseX < width && relativeMouseY > 10 && relativeMouseY < 26) { //this is not the most proper way to do it, //but works best here and has the least maintenance overhead - gui.setToolTip(Arrays.stream(tooltip.split("\n")).map(StringTextComponent::new).collect(Collectors.toList())); + gui.setToolTip(Arrays.stream(tooltip.split("\n")).map(TextComponent::new).collect(Collectors.toList())); } } @@ -194,14 +195,14 @@ public class ClientHooks return new File(Minecraft.getInstance().gameDirectory, "saves"); } - private static NetworkManager getClientToServerNetworkManager() + private static Connection getClientToServerNetworkManager() { return Minecraft.getInstance().getConnection()!=null ? Minecraft.getInstance().getConnection().getConnection() : null; } - public static void handleClientWorldClosing(ClientWorld world) + public static void handleClientWorldClosing(ClientLevel world) { - NetworkManager client = getClientToServerNetworkManager(); + Connection client = getClientToServerNetworkManager(); // ONLY revert a non-local connection if (client != null && !client.isMemoryConnection()) { @@ -241,7 +242,7 @@ public class ClientHooks Logger logger = LogManager.getLogger("FML.TEXTURE_ERRORS"); logger.error(Strings.repeat("+=", 25)); logger.error("The following texture errors were found."); - Map resManagers = ObfuscationReflectionHelper.getPrivateValue(SimpleReloadableResourceManager.class, (SimpleReloadableResourceManager)Minecraft.getInstance().getResourceManager(), "field_199014"+"_c"); + Map resManagers = ObfuscationReflectionHelper.getPrivateValue(SimpleReloadableResourceManager.class, (SimpleReloadableResourceManager)Minecraft.getInstance().getResourceManager(), "f_1087"+"0_"); for (String resourceDomain : badTextureDomains) { Set missing = missingTextures.get(resourceDomain); @@ -256,18 +257,18 @@ public class ClientHooks } else { - List resPacks = fallbackResourceManager.fallbacks; + List resPacks = fallbackResourceManager.fallbacks; logger.error(" domain {} has {} location{}:",resourceDomain, resPacks.size(), resPacks.size() != 1 ? "s" :""); - for (IResourcePack resPack : resPacks) + for (PackResources resPack : resPacks) { if (resPack instanceof ModFileResourcePack) { ModFileResourcePack modRP = (ModFileResourcePack) resPack; List mods = modRP.getModFile().getModInfos(); logger.error(" mod(s) {} resources at {}", mods.stream().map(IModInfo::getDisplayName).collect(Collectors.toList()), modRP.getModFile().getFilePath()); } - else if (resPack instanceof ResourcePack) + else if (resPack instanceof AbstractPackResources) { - logger.error(" resource pack at path {}", ((ResourcePack)resPack).file.getPath()); + logger.error(" resource pack at path {}", ((AbstractPackResources)resPack).file.getPath()); } else { @@ -306,15 +307,15 @@ public class ClientHooks logger.error(Strings.repeat("+=", 25)); } - public static void firePlayerLogin(PlayerController pc, ClientPlayerEntity player, NetworkManager networkManager) { + public static void firePlayerLogin(MultiPlayerGameMode pc, LocalPlayer player, Connection networkManager) { MinecraftForge.EVENT_BUS.post(new ClientPlayerNetworkEvent.LoggedInEvent(pc, player, networkManager)); } - public static void firePlayerLogout(PlayerController pc, ClientPlayerEntity player) { + public static void firePlayerLogout(MultiPlayerGameMode pc, LocalPlayer player) { MinecraftForge.EVENT_BUS.post(new ClientPlayerNetworkEvent.LoggedOutEvent(pc, player, player != null ? player.connection != null ? player.connection.getConnection() : null : null)); } - public static void firePlayerRespawn(PlayerController pc, ClientPlayerEntity oldPlayer, ClientPlayerEntity newPlayer, NetworkManager networkManager) { + public static void firePlayerRespawn(MultiPlayerGameMode pc, LocalPlayer oldPlayer, LocalPlayer newPlayer, Connection networkManager) { MinecraftForge.EVENT_BUS.post(new ClientPlayerNetworkEvent.RespawnEvent(pc, oldPlayer, newPlayer, networkManager)); } diff --git a/src/main/java/net/minecraftforge/fml/client/ClientModLoader.java b/src/main/java/net/minecraftforge/fmlclient/ClientModLoader.java similarity index 70% rename from src/main/java/net/minecraftforge/fml/client/ClientModLoader.java rename to src/main/java/net/minecraftforge/fmlclient/ClientModLoader.java index 78d55942c7..5872818db9 100644 --- a/src/main/java/net/minecraftforge/fml/client/ClientModLoader.java +++ b/src/main/java/net/minecraftforge/fmlclient/ClientModLoader.java @@ -17,10 +17,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.client; +package net.minecraftforge.fmlclient; import static net.minecraftforge.fml.Logging.CORE; -import static net.minecraftforge.fml.loading.LogMarkers.LOADING; +import static net.minecraftforge.fml.Logging.LOADING; import java.io.File; import java.util.*; @@ -31,36 +31,41 @@ import java.util.concurrent.TimeUnit; import java.util.function.BiConsumer; import java.util.function.Consumer; -import net.minecraft.resources.IFutureReloadListener; -import net.minecraft.resources.IPackNameDecorator; -import net.minecraft.resources.IReloadableResourceManager; -import net.minecraft.resources.IResourceManager; -import net.minecraft.resources.ResourcePackInfo; -import net.minecraft.resources.ResourcePackList; -import net.minecraft.util.datafix.codec.DatapackCodec; +import net.minecraft.server.packs.resources.PreparableReloadListener; +import net.minecraft.server.packs.repository.PackSource; +import net.minecraft.server.packs.resources.ReloadableResourceManager; +import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.server.packs.repository.Pack; +import net.minecraft.server.packs.repository.PackRepository; +import net.minecraft.world.level.DataPackConfig; import net.minecraftforge.fml.*; +import net.minecraftforge.fmlclient.registry.RenderingRegistry; +import net.minecraftforge.fmllegacy.BrandingControl; +import net.minecraftforge.fmllegacy.CrashReportExtender; +import net.minecraftforge.fmllegacy.LogicalSidedProvider; +import net.minecraftforge.forgespi.locating.IModFile; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import com.mojang.blaze3d.systems.RenderSystem; +import net.minecraft.SharedConstants; import net.minecraft.client.Minecraft; -import net.minecraft.client.resources.DownloadingPackFinder; -import net.minecraft.profiler.IProfiler; -import net.minecraft.resources.data.PackMetadataSection; -import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.client.resources.ClientPackSource; +import net.minecraft.util.profiling.ProfilerFiller; +import net.minecraft.server.packs.PackType; +import net.minecraft.server.packs.metadata.pack.PackMetadataSection; +import net.minecraft.network.chat.TranslatableComponent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.model.ModelLoaderRegistry; import net.minecraftforge.common.ForgeConfig; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.client.gui.screen.LoadingErrorScreen; -import net.minecraftforge.fml.client.registry.RenderingRegistry; -import net.minecraftforge.fml.loading.moddiscovery.ModFile; -import net.minecraftforge.fml.packs.DelegatingResourcePack; -import net.minecraftforge.fml.packs.ModFileResourcePack; -import net.minecraftforge.fml.packs.ResourcePackLoader; -import net.minecraftforge.fml.server.LanguageHook; +import net.minecraftforge.fmlclient.gui.screen.LoadingErrorScreen; +import net.minecraftforge.fmllegacy.packs.DelegatingResourcePack; +import net.minecraftforge.fmllegacy.packs.ModFileResourcePack; +import net.minecraftforge.fmllegacy.packs.ResourcePackLoader; +import net.minecraftforge.fmllegacy.server.LanguageHook; import net.minecraftforge.forgespi.language.IModInfo; @OnlyIn(Dist.CLIENT) @@ -91,26 +96,26 @@ public class ClientModLoader } } } - public static void begin(final Minecraft minecraft, final ResourcePackList defaultResourcePacks, final IReloadableResourceManager mcResourceManager, DownloadingPackFinder metadataSerializer) + public static void begin(final Minecraft minecraft, final PackRepository defaultResourcePacks, final ReloadableResourceManager mcResourceManager, ClientPackSource metadataSerializer) { // 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; + net.minecraftforge.fmlclient.ClientModLoader.mc = minecraft; LogicalSidedProvider.setClient(()->minecraft); LanguageHook.loadForgeAndMCLangs(); - earlyLoaderGUI = new EarlyLoaderGUI(minecraft.getWindow()); + earlyLoaderGUI = new EarlyLoaderGUI(minecraft); createRunnableWithCatch(()->ModLoader.get().gatherAndInitializeMods(ModWorkManager.syncExecutor(), ModWorkManager.parallelExecutor(), new SpacedRunnable(earlyLoaderGUI::renderTick))).run(); if (error == null) { - ResourcePackLoader.loadResourcePacks(defaultResourcePacks, ClientModLoader::buildPackFinder); - DatapackCodec.DEFAULT.addModPacks(ResourcePackLoader.getPackNames()); - mcResourceManager.registerReloadListener(ClientModLoader::onResourceReload); + ResourcePackLoader.loadResourcePacks(defaultResourcePacks, net.minecraftforge.fmlclient.ClientModLoader::buildPackFinder); + DataPackConfig.DEFAULT.addModPacks(ResourcePackLoader.getPackNames()); + mcResourceManager.registerReloadListener(net.minecraftforge.fmlclient.ClientModLoader::onResourceReload); mcResourceManager.registerReloadListener(BrandingControl.resourceManagerReloadListener()); ModelLoaderRegistry.init(); } } - private static CompletableFuture onResourceReload(final IFutureReloadListener.IStage stage, final IResourceManager resourceManager, final IProfiler prepareProfiler, final IProfiler executeProfiler, final Executor asyncExecutor, final Executor syncExecutor) { + 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()); @@ -129,12 +134,12 @@ public class ClientModLoader private static void startModLoading(ModWorkManager.DrivenExecutor syncExecutor, Executor parallelExecutor) { earlyLoaderGUI.handleElsewhere(); - createRunnableWithCatch(() -> ModLoader.get().loadMods(syncExecutor, parallelExecutor, executor -> CompletableFuture.runAsync(ClientModLoader::preSidedRunnable, executor), executor -> CompletableFuture.runAsync(ClientModLoader::postSidedRunnable, executor), new SpacedRunnable(earlyLoaderGUI::renderTick))).run(); + createRunnableWithCatch(() -> ModLoader.get().loadMods(syncExecutor, parallelExecutor, new SpacedRunnable(earlyLoaderGUI::renderTick))).run(); } private static void postSidedRunnable() { LOGGER.debug(LOADING, "Running post client event work"); - RenderingRegistry.loadEntityRenderers(mc.getEntityRenderDispatcher()); + RenderingRegistry.loadEntityRenderers(); } private static void preSidedRunnable() { @@ -154,7 +159,7 @@ public class ClientModLoader { boolean anyOutdated = ModList.get().getMods().stream() .map(VersionChecker::getResult) - .map(result -> result.status) + .map(result -> result.status()) .anyMatch(status -> status == VersionChecker.Status.OUTDATED || status == VersionChecker.Status.BETA_OUTDATED); return anyOutdated ? VersionChecker.Status.OUTDATED : null; } @@ -204,18 +209,17 @@ public class ClientModLoader return loading; } - private static ResourcePackLoader.IPackInfoFinder buildPackFinder(Map modResourcePacks, BiConsumer packSetter) { + private static ResourcePackLoader.IPackInfoFinder buildPackFinder(Map modResourcePacks, BiConsumer packSetter) { return (packList, factory) -> clientPackFinder(modResourcePacks, packSetter, packList, factory); } - private static void clientPackFinder(Map modResourcePacks, BiConsumer packSetter, Consumer consumer, ResourcePackInfo.IFactory factory) { + private static void clientPackFinder(Map modResourcePacks, BiConsumer packSetter, Consumer consumer, Pack.PackConstructor factory) { List hiddenPacks = new ArrayList<>(); - for (Entry e : modResourcePacks.entrySet()) + for (Entry e : modResourcePacks.entrySet()) { 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 ResourcePackInfo packInfo = ResourcePackInfo.create(name, false, e::getValue, factory, ResourcePackInfo.Priority.BOTTOM, IPackNameDecorator.DEFAULT); + final Pack packInfo = Pack.create(name, false, e::getValue, factory, Pack.Position.BOTTOM, PackSource.DEFAULT); if (packInfo == 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())); @@ -229,9 +233,9 @@ public class ClientModLoader hiddenPacks.add(e.getValue()); } } - final ResourcePackInfo packInfo = ResourcePackInfo.create("mod_resources", true, () -> new DelegatingResourcePack("mod_resources", "Mod Resources", - new PackMetadataSection(new TranslationTextComponent("fml.resources.modresources", hiddenPacks.size()), 6), - hiddenPacks), factory, ResourcePackInfo.Priority.BOTTOM, IPackNameDecorator.DEFAULT); + final Pack packInfo = Pack.create("mod_resources", true, () -> new DelegatingResourcePack("mod_resources", "Mod Resources", + new PackMetadataSection(new TranslatableComponent("fml.resources.modresources", hiddenPacks.size()), PackType.CLIENT_RESOURCES.getVersion(SharedConstants.getCurrentVersion())), + hiddenPacks), factory, Pack.Position.BOTTOM, PackSource.DEFAULT); consumer.accept(packInfo); } } diff --git a/src/main/java/net/minecraftforge/fml/client/ConfigGuiHandler.java b/src/main/java/net/minecraftforge/fmlclient/ConfigGuiHandler.java similarity index 69% rename from src/main/java/net/minecraftforge/fml/client/ConfigGuiHandler.java rename to src/main/java/net/minecraftforge/fmlclient/ConfigGuiHandler.java index 001f17834f..d6dc3c90c8 100644 --- a/src/main/java/net/minecraftforge/fml/client/ConfigGuiHandler.java +++ b/src/main/java/net/minecraftforge/fmlclient/ConfigGuiHandler.java @@ -17,22 +17,23 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.client; +package net.minecraftforge.fmlclient; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.gui.screens.Screen; import net.minecraftforge.fml.ModList; -import net.minecraftforge.fml.ExtensionPoint; -import net.minecraftforge.fml.loading.moddiscovery.ModInfo; +import net.minecraftforge.fml.IExtensionPoint; +import net.minecraftforge.forgespi.language.IModInfo; import java.util.Optional; import java.util.function.BiFunction; public class ConfigGuiHandler { - public static Optional> getGuiFactoryFor(ModInfo selectedMod) + public record ConfigGuiFactory(BiFunction screenFunction) implements IExtensionPoint {} + public static Optional> getGuiFactoryFor(IModInfo selectedMod) { return ModList.get().getModContainerById(selectedMod.getModId()). - flatMap(mc -> mc.getCustomExtension(ExtensionPoint.CONFIGGUIFACTORY)); + flatMap(mc -> mc.getCustomExtension(ConfigGuiFactory.class).map(ConfigGuiFactory::screenFunction)); } } diff --git a/src/main/java/net/minecraftforge/fmlclient/EarlyLoaderGUI.java b/src/main/java/net/minecraftforge/fmlclient/EarlyLoaderGUI.java new file mode 100644 index 0000000000..61664ef2ef --- /dev/null +++ b/src/main/java/net/minecraftforge/fmlclient/EarlyLoaderGUI.java @@ -0,0 +1,156 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.fmlclient; + +import com.mojang.blaze3d.platform.GlStateManager; +import com.mojang.blaze3d.systems.RenderSystem; + +import com.mojang.blaze3d.platform.Window; +import net.minecraft.client.Minecraft; +import net.minecraft.util.Mth; +import net.minecraftforge.fml.StartupMessageManager; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; +import org.lwjgl.stb.STBEasyFont; +import org.lwjgl.system.MemoryUtil; + +import java.lang.management.ManagementFactory; +import java.lang.management.MemoryUsage; +import java.nio.ByteBuffer; + +public class EarlyLoaderGUI { + private final Minecraft minecraft; + private final Window window; + private boolean handledElsewhere; + + public EarlyLoaderGUI(final Minecraft minecraft) { + this.minecraft = minecraft; + this.window = minecraft.getWindow(); + } + + @SuppressWarnings("deprecation") + private void setupMatrix() { + RenderSystem.clear(256, Minecraft.ON_OSX); + GL11.glMatrixMode(5889); + GL11.glLoadIdentity(); + GL11.glOrtho(0.0D, window.getWidth() / window.getGuiScale(), window.getHeight() / window.getGuiScale(), 0.0D, 1000.0D, 3000.0D); + GL11.glMatrixMode(5888); + GL11.glLoadIdentity(); + GL11.glTranslatef(0.0F, 0.0F, -2000.0F); + } + + public void handleElsewhere() { + this.handledElsewhere = true; + } + + void renderFromGUI() { + renderMessages(); + } + + @SuppressWarnings("deprecation") + void renderTick() { + if (handledElsewhere) return; + // int guiScale = window.calculateScale(0, false); + // window.setGuiScale(guiScale); + // + // RenderSystem.clearColor(1.0f, 1.0f, 1.0f, 1.0f); + // RenderSystem.clear(GL11.GL_COLOR_BUFFER_BIT, Minecraft.ON_OSX); + // GL11.glPushMatrix(); + // setupMatrix(); + // renderBackground(); + // renderMessages(); + // window.updateDisplay(); + // GL11.glPopMatrix(); + } + + private void renderBackground() { + GL11.glBegin(GL11.GL_QUADS); + boolean isDarkBackground = minecraft.options.darkMojangStudiosBackground; + GL11.glColor4f(isDarkBackground ? 0 : (239F / 255F), isDarkBackground ? 0 : (50F / 255F), isDarkBackground ? 0 : (61F / 255F), 1); //Color from LoadingOverlay + GL11.glVertex3f(0, 0, -10); + GL11.glVertex3f(0, window.getGuiScaledHeight(), -10); + GL11.glVertex3f(window.getGuiScaledWidth(), window.getGuiScaledHeight(), -10); + GL11.glVertex3f(window.getGuiScaledWidth(), 0, -10); + GL11.glEnd(); + } + + private void renderMessages() { +// List> messages = StartupMessageManager.getMessages(); +// for (int i = 0; i < messages.size(); i++) { +// boolean nofade = i == 0; +// final Pair pair = messages.get(i); +// final float fade = MathHelper.clamp((4000.0f - (float) pair.getLeft() - ( i - 4 ) * 1000.0f) / 5000.0f, 0.0f, 1.0f); +// if (fade <0.01f && !nofade) continue; +// StartupMessageManager.Message msg = pair.getRight(); +// renderMessage(msg.getText(), msg.getTypeColour(), ((window.getGuiScaledHeight() - 15) / 10) - i + 1, nofade ? 1.0f : fade); +// } +// List> messages = StartupMessageManager.getMessages(); +// for (int i = 0; i < messages.size(); i++) { +// boolean nofade = i == 0; +// final Pair pair = messages.get(i); +// final float fade = Mth.clamp((4000.0f - (float) pair.getLeft() - ( i - 4 ) * 1000.0f) / 5000.0f, 0.0f, 1.0f); +// if (fade <0.01f && !nofade) continue; +// StartupMessageManager.Message msg = pair.getRight(); +// renderMessage(msg.getText(), msg.getTypeColour(), ((window.getGuiScaledHeight() - 15) / 10) - i + 1, nofade ? 1.0f : fade); +// } +// renderMemoryInfo(); + } + + private static final float[] memorycolour = new float[] { 0.0f, 0.0f, 0.0f}; + + private void renderMemoryInfo() { + final MemoryUsage heapusage = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage(); + final MemoryUsage offheapusage = ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage(); + final float pctmemory = (float) heapusage.getUsed() / heapusage.getMax(); + String memory = String.format("Memory Heap: %d / %d MB (%.1f%%) OffHeap: %d MB", heapusage.getUsed() >> 20, heapusage.getMax() >> 20, pctmemory * 100.0, offheapusage.getUsed() >> 20); + + final int i = Mth.hsvToRgb((1.0f - (float)Math.pow(pctmemory, 1.5f)) / 3f, 1.0f, 0.5f); + memorycolour[2] = ((i) & 0xFF) / 255.0f; + memorycolour[1] = ((i >> 8 ) & 0xFF) / 255.0f; + memorycolour[0] = ((i >> 16 ) & 0xFF) / 255.0f; + renderMessage(memory, memorycolour, 1, 1.0f); + } + + @SuppressWarnings("deprecation") + void renderMessage(final String message, final float[] colour, int line, float alpha) { + // GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); + // ByteBuffer charBuffer = MemoryUtil.memAlloc(message.length() * 270); + // int quads = STBEasyFont.stb_easy_font_print(0, 0, message, null, charBuffer); + // GL14.glVertexPointer(2, GL11.GL_FLOAT, 16, charBuffer); + // + // RenderSystem.enableBlend(); + // RenderSystem.disableTexture(); + // // STBEasyFont's quads are in reverse order or what OGGL expects, so it gets culled for facing the wrong way. + // // So Disable culling https://github.com/MinecraftForge/MinecraftForge/pull/6824 + // RenderSystem.disableCull(); + // GL14.glBlendColor(0,0,0, alpha); + // RenderSystem.blendFunc(GlStateManager.SourceFactor.CONSTANT_ALPHA, GlStateManager.DestFactor.ONE_MINUS_CONSTANT_ALPHA); + // GL11.glColor3f(colour[0],colour[1],colour[2]); + // GL11.glPushMatrix(); + // GL11.glTranslatef(10, line * 10, 0); + // GL11.glScalef(1, 1, 0); + // GL11.glDrawArrays(GL11.GL_QUADS, 0, quads * 4); + // GL11.glPopMatrix(); + // + // RenderSystem.enableCull(); + // GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); + // MemoryUtil.memFree(charBuffer); + } +} diff --git a/src/main/java/net/minecraftforge/fml/client/ExtendedServerListData.java b/src/main/java/net/minecraftforge/fmlclient/ExtendedServerListData.java similarity index 97% rename from src/main/java/net/minecraftforge/fml/client/ExtendedServerListData.java rename to src/main/java/net/minecraftforge/fmlclient/ExtendedServerListData.java index 1a1f755600..ce6e8fd1fb 100644 --- a/src/main/java/net/minecraftforge/fml/client/ExtendedServerListData.java +++ b/src/main/java/net/minecraftforge/fmlclient/ExtendedServerListData.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.client; +package net.minecraftforge.fmlclient; public class ExtendedServerListData { public final String type; diff --git a/src/main/java/net/minecraftforge/fml/client/gui/GuiUtils.java b/src/main/java/net/minecraftforge/fmlclient/gui/GuiUtils.java similarity index 61% rename from src/main/java/net/minecraftforge/fml/client/gui/GuiUtils.java rename to src/main/java/net/minecraftforge/fmlclient/gui/GuiUtils.java index ebf7129d6f..19c7635b50 100644 --- a/src/main/java/net/minecraftforge/fml/client/gui/GuiUtils.java +++ b/src/main/java/net/minecraftforge/fmlclient/gui/GuiUtils.java @@ -17,27 +17,29 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.client.gui; +package net.minecraftforge.fmlclient.gui; +import com.mojang.blaze3d.vertex.VertexFormat; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.AbstractGui; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.BufferBuilder; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.vector.Matrix4f; -import net.minecraft.util.text.ITextProperties; -import net.minecraft.util.text.LanguageMap; -import net.minecraft.util.text.Style; +import net.minecraft.client.gui.GuiComponent; +import net.minecraft.client.gui.Font; +import net.minecraft.client.renderer.GameRenderer; +import net.minecraft.client.renderer.MultiBufferSource; +import com.mojang.blaze3d.vertex.Tesselator; +import com.mojang.blaze3d.vertex.BufferBuilder; +import com.mojang.blaze3d.vertex.DefaultVertexFormat; +import net.minecraft.world.item.ItemStack; +import net.minecraft.resources.ResourceLocation; +import com.mojang.math.Matrix4f; +import net.minecraft.network.chat.FormattedText; +import net.minecraft.locale.Language; +import net.minecraft.network.chat.Style; import net.minecraftforge.client.event.RenderTooltipEvent; import net.minecraftforge.common.MinecraftForge; import org.lwjgl.opengl.GL11; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.systems.RenderSystem; import javax.annotation.Nonnull; @@ -66,164 +68,6 @@ public class GuiUtils { return colorCodes[isLighter ? "0123456789abcdef".indexOf(c) : "0123456789abcdef".indexOf(c) + 16]; } - /** - * Draws a textured box of any size (smallest size is borderSize * 2 square) based on a fixed size textured box with continuous borders - * and filler. It is assumed that the desired texture ResourceLocation object has been bound using - * Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation). - * - * @param x x axis offset - * @param y y axis offset - * @param u bound resource location image x offset - * @param v bound resource location image y offset - * @param width the desired box width - * @param height the desired box height - * @param textureWidth the width of the box texture in the resource location image - * @param textureHeight the height of the box texture in the resource location image - * @param borderSize the size of the box's borders - * @param zLevel the zLevel to draw at - */ - @Deprecated //Use matrix stack version TODO remove 1.17 - public static void drawContinuousTexturedBox(int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, - int borderSize, float zLevel) - { - drawContinuousTexturedBox(x, y, u, v, width, height, textureWidth, textureHeight, borderSize, borderSize, borderSize, borderSize, zLevel); - } - - /** - * Draws a textured box of any size (smallest size is borderSize * 2 square) based on a fixed size textured box with continuous borders - * and filler. The provided ResourceLocation object will be bound using - * Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation). - * - * @param res the ResourceLocation object that contains the desired image - * @param x x axis offset - * @param y y axis offset - * @param u bound resource location image x offset - * @param v bound resource location image y offset - * @param width the desired box width - * @param height the desired box height - * @param textureWidth the width of the box texture in the resource location image - * @param textureHeight the height of the box texture in the resource location image - * @param borderSize the size of the box's borders - * @param zLevel the zLevel to draw at - */ - @Deprecated //Use matrix stack version TODO remove 1.17 - public static void drawContinuousTexturedBox(ResourceLocation res, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, - int borderSize, float zLevel) - { - drawContinuousTexturedBox(res, x, y, u, v, width, height, textureWidth, textureHeight, borderSize, borderSize, borderSize, borderSize, zLevel); - } - - /** - * Draws a textured box of any size (smallest size is borderSize * 2 square) based on a fixed size textured box with continuous borders - * and filler. The provided ResourceLocation object will be bound using - * Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation). - * - * @param res the ResourceLocation object that contains the desired image - * @param x x axis offset - * @param y y axis offset - * @param u bound resource location image x offset - * @param v bound resource location image y offset - * @param width the desired box width - * @param height the desired box height - * @param textureWidth the width of the box texture in the resource location image - * @param textureHeight the height of the box texture in the resource location image - * @param topBorder the size of the box's top border - * @param bottomBorder the size of the box's bottom border - * @param leftBorder the size of the box's left border - * @param rightBorder the size of the box's right border - * @param zLevel the zLevel to draw at - */ - @Deprecated //Use matrix stack version TODO remove 1.17 - public static void drawContinuousTexturedBox(ResourceLocation res, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, - int topBorder, int bottomBorder, int leftBorder, int rightBorder, float zLevel) - { - Minecraft.getInstance().getTextureManager().bind(res); - drawContinuousTexturedBox(x, y, u, v, width, height, textureWidth, textureHeight, topBorder, bottomBorder, leftBorder, rightBorder, zLevel); - } - - /** - * Draws a textured box of any size (smallest size is borderSize * 2 square) based on a fixed size textured box with continuous borders - * and filler. It is assumed that the desired texture ResourceLocation object has been bound using - * Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation). - * - * @param x x axis offset - * @param y y axis offset - * @param u bound resource location image x offset - * @param v bound resource location image y offset - * @param width the desired box width - * @param height the desired box height - * @param textureWidth the width of the box texture in the resource location image - * @param textureHeight the height of the box texture in the resource location image - * @param topBorder the size of the box's top border - * @param bottomBorder the size of the box's bottom border - * @param leftBorder the size of the box's left border - * @param rightBorder the size of the box's right border - * @param zLevel the zLevel to draw at - */ - @Deprecated //Use matrix stack version TODO remove 1.17 - public static void drawContinuousTexturedBox(int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, - int topBorder, int bottomBorder, int leftBorder, int rightBorder, float zLevel) - { - RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); - RenderSystem.enableBlend(); - RenderSystem.blendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); - - int fillerWidth = textureWidth - leftBorder - rightBorder; - int fillerHeight = textureHeight - topBorder - bottomBorder; - int canvasWidth = width - leftBorder - rightBorder; - int canvasHeight = height - topBorder - bottomBorder; - int xPasses = canvasWidth / fillerWidth; - int remainderWidth = canvasWidth % fillerWidth; - int yPasses = canvasHeight / fillerHeight; - int remainderHeight = canvasHeight % fillerHeight; - - // Draw Border - // Top Left - drawTexturedModalRect(x, y, u, v, leftBorder, topBorder, zLevel); - // Top Right - drawTexturedModalRect(x + leftBorder + canvasWidth, y, u + leftBorder + fillerWidth, v, rightBorder, topBorder, zLevel); - // Bottom Left - drawTexturedModalRect(x, y + topBorder + canvasHeight, u, v + topBorder + fillerHeight, leftBorder, bottomBorder, zLevel); - // Bottom Right - drawTexturedModalRect(x + leftBorder + canvasWidth, y + topBorder + canvasHeight, u + leftBorder + fillerWidth, v + topBorder + fillerHeight, rightBorder, bottomBorder, zLevel); - - for (int i = 0; i < xPasses + (remainderWidth > 0 ? 1 : 0); i++) - { - // Top Border - drawTexturedModalRect(x + leftBorder + (i * fillerWidth), y, u + leftBorder, v, (i == xPasses ? remainderWidth : fillerWidth), topBorder, zLevel); - // Bottom Border - drawTexturedModalRect(x + leftBorder + (i * fillerWidth), y + topBorder + canvasHeight, u + leftBorder, v + topBorder + fillerHeight, (i == xPasses ? remainderWidth : fillerWidth), bottomBorder, zLevel); - - // Throw in some filler for good measure - for (int j = 0; j < yPasses + (remainderHeight > 0 ? 1 : 0); j++) - drawTexturedModalRect(x + leftBorder + (i * fillerWidth), y + topBorder + (j * fillerHeight), u + leftBorder, v + topBorder, (i == xPasses ? remainderWidth : fillerWidth), (j == yPasses ? remainderHeight : fillerHeight), zLevel); - } - - // Side Borders - for (int j = 0; j < yPasses + (remainderHeight > 0 ? 1 : 0); j++) - { - // Left Border - drawTexturedModalRect(x, y + topBorder + (j * fillerHeight), u, v + topBorder, leftBorder, (j == yPasses ? remainderHeight : fillerHeight), zLevel); - // Right Border - drawTexturedModalRect(x + leftBorder + canvasWidth, y + topBorder + (j * fillerHeight), u + leftBorder + fillerWidth, v + topBorder, rightBorder, (j == yPasses ? remainderHeight : fillerHeight), zLevel); - } - } - - @Deprecated //Use matrix stack version TODO remove 1.17 - public static void drawTexturedModalRect(int x, int y, int u, int v, int width, int height, float zLevel) - { - final float uScale = 1f / 0x100; - final float vScale = 1f / 0x100; - - Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder wr = tessellator.getBuilder(); - wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); - wr.vertex(x , y + height, zLevel).uv( u * uScale, ((v + height) * vScale)).endVertex(); - wr.vertex(x + width, y + height, zLevel).uv((u + width) * uScale, ((v + height) * vScale)).endVertex(); - wr.vertex(x + width, y , zLevel).uv((u + width) * uScale, ( v * vScale)).endVertex(); - wr.vertex(x , y , zLevel).uv( u * uScale, ( v * vScale)).endVertex(); - tessellator.end(); - } /** * Draws a textured box of any size (smallest size is borderSize * 2 square) based on a fixed size textured box with continuous borders @@ -242,7 +86,7 @@ public class GuiUtils * @param borderSize the size of the box's borders * @param zLevel the zLevel to draw at */ - public static void drawContinuousTexturedBox(MatrixStack matrixStack, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, + public static void drawContinuousTexturedBox(PoseStack matrixStack, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, int borderSize, float zLevel) { drawContinuousTexturedBox(matrixStack, x, y, u, v, width, height, textureWidth, textureHeight, borderSize, borderSize, borderSize, borderSize, zLevel); @@ -266,7 +110,7 @@ public class GuiUtils * @param borderSize the size of the box's borders * @param zLevel the zLevel to draw at */ - public static void drawContinuousTexturedBox(MatrixStack matrixStack, ResourceLocation res, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, + public static void drawContinuousTexturedBox(PoseStack matrixStack, ResourceLocation res, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, int borderSize, float zLevel) { drawContinuousTexturedBox(matrixStack, res, x, y, u, v, width, height, textureWidth, textureHeight, borderSize, borderSize, borderSize, borderSize, zLevel); @@ -293,10 +137,10 @@ public class GuiUtils * @param rightBorder the size of the box's right border * @param zLevel the zLevel to draw at */ - public static void drawContinuousTexturedBox(MatrixStack matrixStack, ResourceLocation res, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, + public static void drawContinuousTexturedBox(PoseStack matrixStack, ResourceLocation res, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, int topBorder, int bottomBorder, int leftBorder, int rightBorder, float zLevel) { - Minecraft.getInstance().getTextureManager().bind(res); + RenderSystem.setShaderTexture(0, res); drawContinuousTexturedBox(matrixStack, x, y, u, v, width, height, textureWidth, textureHeight, topBorder, bottomBorder, leftBorder, rightBorder, zLevel); } @@ -321,10 +165,10 @@ public class GuiUtils * @param zLevel the zLevel to draw at */ @SuppressWarnings("deprecation") - public static void drawContinuousTexturedBox(MatrixStack matrixStack, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, + public static void drawContinuousTexturedBox(PoseStack matrixStack, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, int topBorder, int bottomBorder, int leftBorder, int rightBorder, float zLevel) { - RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.enableBlend(); RenderSystem.blendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); @@ -369,14 +213,14 @@ public class GuiUtils } } - public static void drawTexturedModalRect(MatrixStack matrixStack, int x, int y, int u, int v, int width, int height, float zLevel) + public static void drawTexturedModalRect(PoseStack matrixStack, int x, int y, int u, int v, int width, int height, float zLevel) { final float uScale = 1f / 0x100; final float vScale = 1f / 0x100; - Tessellator tessellator = Tessellator.getInstance(); + Tesselator tessellator = Tesselator.getInstance(); BufferBuilder wr = tessellator.getBuilder(); - wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); + wr.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX); Matrix4f matrix = matrixStack.last().pose(); wr.vertex(matrix, x , y + height, zLevel).uv( u * uScale, ((v + height) * vScale)).endVertex(); wr.vertex(matrix, x + width, y + height, zLevel).uv((u + width) * uScale, ((v + height) * vScale)).endVertex(); @@ -406,7 +250,7 @@ public class GuiUtils cachedTooltipStack = ItemStack.EMPTY; } - public static void drawHoveringText(MatrixStack mStack, List textLines, int mouseX, int mouseY, int screenWidth, int screenHeight, int maxTextWidth, FontRenderer font) + public static void drawHoveringText(PoseStack mStack, List textLines, int mouseX, int mouseY, int screenWidth, int screenHeight, int maxTextWidth, Font font) { drawHoveringText(mStack, textLines, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth, DEFAULT_BACKGROUND_COLOR, DEFAULT_BORDER_COLOR_START, DEFAULT_BORDER_COLOR_END, font); } @@ -430,13 +274,13 @@ public class GuiUtils * between the start and end values. * @param font the font for drawing the text in the tooltip box */ - public static void drawHoveringText(MatrixStack mStack, List textLines, int mouseX, int mouseY, int screenWidth, int screenHeight, - int maxTextWidth, int backgroundColor, int borderColorStart, int borderColorEnd, FontRenderer font) + public static void drawHoveringText(PoseStack mStack, List textLines, int mouseX, int mouseY, int screenWidth, int screenHeight, + int maxTextWidth, int backgroundColor, int borderColorStart, int borderColorEnd, Font font) { drawHoveringText(cachedTooltipStack, mStack, textLines, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth, backgroundColor, borderColorStart, borderColorEnd, font); } - public static void drawHoveringText(@Nonnull final ItemStack stack, MatrixStack mStack, List textLines, int mouseX, int mouseY, int screenWidth, int screenHeight, int maxTextWidth, FontRenderer font) + public static void drawHoveringText(@Nonnull final ItemStack stack, PoseStack mStack, List textLines, int mouseX, int mouseY, int screenWidth, int screenHeight, int maxTextWidth, Font font) { drawHoveringText(stack, mStack, textLines, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth, DEFAULT_BACKGROUND_COLOR, DEFAULT_BORDER_COLOR_START, DEFAULT_BORDER_COLOR_END, font); } @@ -447,13 +291,13 @@ public class GuiUtils * @see #drawHoveringText(MatrixStack, List, int, int, int, int, int, int, int, int, FontRenderer) */ //TODO, Validate rendering is the same as the original - public static void drawHoveringText(@Nonnull final ItemStack stack, MatrixStack mStack, List textLines, int mouseX, int mouseY, + public static void drawHoveringText(@Nonnull final ItemStack stack, PoseStack pStack, List textLines, int mouseX, int mouseY, int screenWidth, int screenHeight, int maxTextWidth, - int backgroundColor, int borderColorStart, int borderColorEnd, FontRenderer font) + int backgroundColor, int borderColorStart, int borderColorEnd, Font font) { if (!textLines.isEmpty()) { - RenderTooltipEvent.Pre event = new RenderTooltipEvent.Pre(stack, textLines, mStack, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth, font); + RenderTooltipEvent.Pre event = new RenderTooltipEvent.Pre(stack, textLines, pStack, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth, font); if (MinecraftForge.EVENT_BUS.post(event)) return; mouseX = event.getX(); @@ -463,11 +307,11 @@ public class GuiUtils maxTextWidth = event.getMaxWidth(); font = event.getFontRenderer(); - RenderSystem.disableRescaleNormal(); + // RenderSystem.disableRescaleNormal(); RenderSystem.disableDepthTest(); int tooltipTextWidth = 0; - for (ITextProperties textLine : textLines) + for (FormattedText textLine : textLines) { int textLineWidth = font.width(textLine); if (textLineWidth > tooltipTextWidth) @@ -500,15 +344,15 @@ public class GuiUtils if (needsWrap) { int wrappedTooltipWidth = 0; - List wrappedTextLines = new ArrayList<>(); + List wrappedTextLines = new ArrayList<>(); for (int i = 0; i < textLines.size(); i++) { - ITextProperties textLine = textLines.get(i); - List wrappedLine = font.getSplitter().splitLines(textLine, tooltipTextWidth, Style.EMPTY); + FormattedText textLine = textLines.get(i); + List wrappedLine = font.getSplitter().splitLines(textLine, tooltipTextWidth, Style.EMPTY); if (i == 0) titleLinesCount = wrappedLine.size(); - for (ITextProperties line : wrappedLine) + for (FormattedText line : wrappedLine) { int lineWidth = font.width(line); if (lineWidth > wrappedTooltipWidth) @@ -541,14 +385,14 @@ public class GuiUtils tooltipY = screenHeight - tooltipHeight - 4; final int zLevel = 400; - RenderTooltipEvent.Color colorEvent = new RenderTooltipEvent.Color(stack, textLines, mStack, tooltipX, tooltipY, font, backgroundColor, borderColorStart, borderColorEnd); + RenderTooltipEvent.Color colorEvent = new RenderTooltipEvent.Color(stack, textLines, pStack, tooltipX, tooltipY, font, backgroundColor, borderColorStart, borderColorEnd); MinecraftForge.EVENT_BUS.post(colorEvent); backgroundColor = colorEvent.getBackground(); borderColorStart = colorEvent.getBorderStart(); borderColorEnd = colorEvent.getBorderEnd(); - mStack.pushPose(); - Matrix4f mat = mStack.last().pose(); + pStack.pushPose(); + Matrix4f mat = pStack.last().pose(); //TODO, lots of unnessesary GL calls here, we can buffer all these together. drawGradientRect(mat, zLevel, tooltipX - 3, tooltipY - 4, tooltipX + tooltipTextWidth + 3, tooltipY - 3, backgroundColor, backgroundColor); drawGradientRect(mat, zLevel, tooltipX - 3, tooltipY + tooltipHeight + 3, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 4, backgroundColor, backgroundColor); @@ -560,18 +404,18 @@ public class GuiUtils drawGradientRect(mat, zLevel, tooltipX - 3, tooltipY - 3, tooltipX + tooltipTextWidth + 3, tooltipY - 3 + 1, borderColorStart, borderColorStart); drawGradientRect(mat, zLevel, tooltipX - 3, tooltipY + tooltipHeight + 2, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3, borderColorEnd, borderColorEnd); - MinecraftForge.EVENT_BUS.post(new RenderTooltipEvent.PostBackground(stack, textLines, mStack, tooltipX, tooltipY, font, tooltipTextWidth, tooltipHeight)); + MinecraftForge.EVENT_BUS.post(new RenderTooltipEvent.PostBackground(stack, textLines, pStack, tooltipX, tooltipY, font, tooltipTextWidth, tooltipHeight)); - IRenderTypeBuffer.Impl renderType = IRenderTypeBuffer.immediate(Tessellator.getInstance().getBuilder()); - mStack.translate(0.0D, 0.0D, zLevel); + MultiBufferSource.BufferSource renderType = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder()); + pStack.translate(0.0D, 0.0D, zLevel); int tooltipTop = tooltipY; for (int lineNumber = 0; lineNumber < textLines.size(); ++lineNumber) { - ITextProperties line = textLines.get(lineNumber); + FormattedText line = textLines.get(lineNumber); if (line != null) - font.drawInBatch(LanguageMap.getInstance().getVisualOrder(line), (float)tooltipX, (float)tooltipY, -1, true, mat, renderType, false, 0, 15728880); + font.drawInBatch(Language.getInstance().getVisualOrder(line), (float)tooltipX, (float)tooltipY, -1, true, mat, renderType, false, 0, 15728880); if (lineNumber + 1 == titleLinesCount) tooltipY += 2; @@ -580,12 +424,12 @@ public class GuiUtils } renderType.endBatch(); - mStack.popPose(); + pStack.popPose(); - MinecraftForge.EVENT_BUS.post(new RenderTooltipEvent.PostText(stack, textLines, mStack, tooltipX, tooltipTop, font, tooltipTextWidth, tooltipHeight)); + MinecraftForge.EVENT_BUS.post(new RenderTooltipEvent.PostText(stack, textLines, pStack, tooltipX, tooltipTop, font, tooltipTextWidth, tooltipHeight)); RenderSystem.enableDepthTest(); - RenderSystem.enableRescaleNormal(); + // RenderSystem.enableRescaleNormal(); } } @@ -605,28 +449,27 @@ public class GuiUtils RenderSystem.disableTexture(); RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); - RenderSystem.shadeModel(GL11.GL_SMOOTH); + RenderSystem.setShader(GameRenderer::getPositionColorShader); - Tessellator tessellator = Tessellator.getInstance(); + Tesselator tessellator = Tesselator.getInstance(); BufferBuilder buffer = tessellator.getBuilder(); - buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); + buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); buffer.vertex(mat, right, top, zLevel).color(startRed, startGreen, startBlue, startAlpha).endVertex(); buffer.vertex(mat, left, top, zLevel).color(startRed, startGreen, startBlue, startAlpha).endVertex(); buffer.vertex(mat, left, bottom, zLevel).color( endRed, endGreen, endBlue, endAlpha).endVertex(); buffer.vertex(mat, right, bottom, zLevel).color( endRed, endGreen, endBlue, endAlpha).endVertex(); tessellator.end(); - RenderSystem.shadeModel(GL11.GL_FLAT); RenderSystem.disableBlend(); RenderSystem.enableTexture(); } - public static void drawInscribedRect(MatrixStack mStack, int x, int y, int boundsWidth, int boundsHeight, int rectWidth, int rectHeight) + public static void drawInscribedRect(PoseStack mStack, int x, int y, int boundsWidth, int boundsHeight, int rectWidth, int rectHeight) { drawInscribedRect(mStack, x, y, boundsWidth, boundsHeight, rectWidth, rectHeight, true, true); } - public static void drawInscribedRect(MatrixStack mStack, int x, int y, int boundsWidth, int boundsHeight, int rectWidth, int rectHeight, boolean centerX, boolean centerY) + public static void drawInscribedRect(PoseStack mStack, int x, int y, int boundsWidth, int boundsHeight, int rectWidth, int rectHeight, boolean centerX, boolean centerY) { if (rectWidth * boundsHeight > rectHeight * boundsWidth) { int h = boundsHeight; @@ -638,6 +481,6 @@ public class GuiUtils if (centerX) x += (w - boundsWidth) / 2; } - AbstractGui.blit(mStack, x, y, boundsWidth, boundsHeight, 0.0f,0.0f, rectWidth, rectHeight, rectWidth, rectHeight); + GuiComponent.blit(mStack, x, y, boundsWidth, boundsHeight, 0.0f,0.0f, rectWidth, rectHeight, rectWidth, rectHeight); } } diff --git a/src/main/java/net/minecraftforge/fml/client/gui/screen/ConfirmationScreen.java b/src/main/java/net/minecraftforge/fmlclient/gui/screen/ConfirmationScreen.java similarity index 87% rename from src/main/java/net/minecraftforge/fml/client/gui/screen/ConfirmationScreen.java rename to src/main/java/net/minecraftforge/fmlclient/gui/screen/ConfirmationScreen.java index 588e7bf56e..ea1c5e990d 100644 --- a/src/main/java/net/minecraftforge/fml/client/gui/screen/ConfirmationScreen.java +++ b/src/main/java/net/minecraftforge/fmlclient/gui/screen/ConfirmationScreen.java @@ -19,11 +19,6 @@ /* package net.minecraftforge.fml.client.gui.screen; -import net.minecraft.client.gui.widget.button.Button; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TranslationTextComponent; -import net.minecraftforge.fml.ForgeI18n; -import net.minecraftforge.fml.StartupQuery; public class ConfirmationScreen extends NotificationScreen { diff --git a/src/main/java/net/minecraftforge/fml/client/gui/screen/LoadingErrorScreen.java b/src/main/java/net/minecraftforge/fmlclient/gui/screen/LoadingErrorScreen.java similarity index 54% rename from src/main/java/net/minecraftforge/fml/client/gui/screen/LoadingErrorScreen.java rename to src/main/java/net/minecraftforge/fmlclient/gui/screen/LoadingErrorScreen.java index 73c55f9b4a..e03f0491a2 100644 --- a/src/main/java/net/minecraftforge/fml/client/gui/screen/LoadingErrorScreen.java +++ b/src/main/java/net/minecraftforge/fmlclient/gui/screen/LoadingErrorScreen.java @@ -17,26 +17,26 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.client.gui.screen; +package net.minecraftforge.fmlclient.gui.screen; import com.google.common.base.Strings; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.screen.ErrorScreen; -import net.minecraft.client.gui.widget.list.ExtendedList; -import net.minecraft.util.IReorderingProcessor; -import net.minecraft.util.Util; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.ITextProperties; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TextFormatting; -import net.minecraftforge.fml.ForgeI18n; +import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.screens.ErrorScreen; +import net.minecraft.client.gui.components.ObjectSelectionList; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.util.FormattedCharSequence; +import net.minecraft.Util; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.ChatFormatting; +import net.minecraftforge.fmllegacy.ForgeI18n; import net.minecraftforge.fml.LoadingFailedException; import net.minecraftforge.fml.ModLoadingException; import net.minecraftforge.fml.ModLoadingWarning; -import net.minecraftforge.fml.client.ClientHooks; -import net.minecraftforge.fml.client.gui.widget.ExtendedButton; +import net.minecraftforge.fmlclient.ClientHooks; +import net.minecraftforge.fmlclient.gui.widget.ExtendedButton; import net.minecraftforge.fml.loading.FMLPaths; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -56,12 +56,12 @@ public class LoadingErrorScreen extends ErrorScreen { private final List modLoadWarnings; private final Path dumpedLocation; private LoadingEntryList entryList; - private ITextComponent errorHeader; - private ITextComponent warningHeader; + private Component errorHeader; + private Component warningHeader; public LoadingErrorScreen(LoadingFailedException loadingException, List warnings, final File dumpedLocation) { - super(new StringTextComponent("Loading Error"), null); + super(new TextComponent("Loading Error"), null); this.modLoadWarnings = warnings; this.modLoadErrors = loadingException == null ? Collections.emptyList() : loadingException.getErrors(); this.modsDir = FMLPaths.MODSDIR.get(); @@ -73,57 +73,56 @@ public class LoadingErrorScreen extends ErrorScreen { public void init() { super.init(); - this.buttons.clear(); - this.children.clear(); + this.clearWidgets(); - this.errorHeader = new StringTextComponent(TextFormatting.RED + ForgeI18n.parseMessage("fml.loadingerrorscreen.errorheader", this.modLoadErrors.size()) + TextFormatting.RESET); - this.warningHeader = new StringTextComponent(TextFormatting.YELLOW + ForgeI18n.parseMessage("fml.loadingerrorscreen.warningheader", this.modLoadErrors.size()) + TextFormatting.RESET); + this.errorHeader = new TextComponent(ChatFormatting.RED + ForgeI18n.parseMessage("fml.loadingerrorscreen.errorheader", this.modLoadErrors.size()) + ChatFormatting.RESET); + this.warningHeader = new TextComponent(ChatFormatting.YELLOW + ForgeI18n.parseMessage("fml.loadingerrorscreen.warningheader", this.modLoadErrors.size()) + ChatFormatting.RESET); int yOffset = 46; - this.addButton(new ExtendedButton(50, this.height - yOffset, this.width / 2 - 55, 20, new StringTextComponent(ForgeI18n.parseMessage("fml.button.open.mods.folder")), b -> Util.getPlatform().openFile(modsDir.toFile()))); - this.addButton(new ExtendedButton(this.width / 2 + 5, this.height - yOffset, this.width / 2 - 55, 20, new StringTextComponent(ForgeI18n.parseMessage("fml.button.open.file", logFile.getFileName())), b -> Util.getPlatform().openFile(logFile.toFile()))); + this.addRenderableWidget(new ExtendedButton(50, this.height - yOffset, this.width / 2 - 55, 20, new TextComponent(ForgeI18n.parseMessage("fml.button.open.mods.folder")), b -> Util.getPlatform().openFile(modsDir.toFile()))); + this.addRenderableWidget(new ExtendedButton(this.width / 2 + 5, this.height - yOffset, this.width / 2 - 55, 20, new TextComponent(ForgeI18n.parseMessage("fml.button.open.file", logFile.getFileName())), b -> Util.getPlatform().openFile(logFile.toFile()))); if (this.modLoadErrors.isEmpty()) { - this.addButton(new ExtendedButton(this.width / 4, this.height - 24, this.width / 2, 20, new StringTextComponent(ForgeI18n.parseMessage("fml.button.continue.launch")), b -> { + this.addRenderableWidget(new ExtendedButton(this.width / 4, this.height - 24, this.width / 2, 20, new TextComponent(ForgeI18n.parseMessage("fml.button.continue.launch")), b -> { ClientHooks.logMissingTextureErrors(); this.minecraft.setScreen(null); })); } else { - this.addButton(new ExtendedButton(this.width / 4, this.height - 24, this.width / 2, 20, new StringTextComponent(ForgeI18n.parseMessage("fml.button.open.file", dumpedLocation.getFileName())), b -> Util.getPlatform().openFile(dumpedLocation.toFile()))); + this.addRenderableWidget(new ExtendedButton(this.width / 4, this.height - 24, this.width / 2, 20, new TextComponent(ForgeI18n.parseMessage("fml.button.open.file", dumpedLocation.getFileName())), b -> Util.getPlatform().openFile(dumpedLocation.toFile()))); } this.entryList = new LoadingEntryList(this, this.modLoadErrors, this.modLoadWarnings); - this.children.add(this.entryList); + this.addRenderableWidget(this.entryList); this.setFocused(this.entryList); } @Override - public void render(MatrixStack mStack, int mouseX, int mouseY, float partialTicks) + public void render(PoseStack mStack, int mouseX, int mouseY, float partialTicks) { this.renderBackground(mStack); this.entryList.render(mStack, mouseX, mouseY, partialTicks); drawMultiLineCenteredString(mStack, font, this.modLoadErrors.isEmpty() ? warningHeader : errorHeader, this.width / 2, 10); - this.buttons.forEach(button -> button.render(mStack, mouseX, mouseY, partialTicks)); + this.renderables.forEach(button -> button.render(mStack, mouseX, mouseY, partialTicks)); } - private void drawMultiLineCenteredString(MatrixStack mStack, FontRenderer fr, ITextComponent str, int x, int y) { - for (IReorderingProcessor s : fr.split(str, this.width)) { + private void drawMultiLineCenteredString(PoseStack mStack, Font fr, Component str, int x, int y) { + for (FormattedCharSequence s : fr.split(str, this.width)) { fr.drawShadow(mStack, s, (float) (x - fr.width(s) / 2.0), y, 0xFFFFFF); y+=fr.lineHeight; } } - public static class LoadingEntryList extends ExtendedList { + public static class LoadingEntryList extends ObjectSelectionList { LoadingEntryList(final LoadingErrorScreen parent, final List errors, final List warnings) { super(parent.minecraft, parent.width, parent.height, 35, parent.height - 50, 2 * parent.minecraft.font.lineHeight + 8); boolean both = !errors.isEmpty() && !warnings.isEmpty(); if (both) addEntry(new LoadingMessageEntry(parent.errorHeader, true)); - errors.forEach(e->addEntry(new LoadingMessageEntry(new StringTextComponent(e.formatToString())))); + errors.forEach(e->addEntry(new LoadingMessageEntry(new TextComponent(e.formatToString())))); if (both) { int maxChars = (this.width - 10) / parent.minecraft.font.width("-"); - addEntry(new LoadingMessageEntry(new StringTextComponent("\n" + Strings.repeat("-", maxChars) + "\n"))); + addEntry(new LoadingMessageEntry(new TextComponent("\n" + Strings.repeat("-", maxChars) + "\n"))); addEntry(new LoadingMessageEntry(parent.warningHeader, true)); } - warnings.forEach(w->addEntry(new LoadingMessageEntry(new StringTextComponent(w.formatToString())))); + warnings.forEach(w->addEntry(new LoadingMessageEntry(new TextComponent(w.formatToString())))); } @Override @@ -138,29 +137,34 @@ public class LoadingErrorScreen extends ErrorScreen { return this.width; } - public class LoadingMessageEntry extends ExtendedList.AbstractListEntry { - private final ITextComponent message; + public class LoadingMessageEntry extends ObjectSelectionList.Entry { + private final Component message; private final boolean center; - LoadingMessageEntry(final ITextComponent message) { + LoadingMessageEntry(final Component message) { this(message, false); } - LoadingMessageEntry(final ITextComponent message, final boolean center) { + LoadingMessageEntry(final Component message, final boolean center) { this.message = Objects.requireNonNull(message); this.center = center; } @Override - public void render(MatrixStack mStack, int entryIdx, int top, int left, final int entryWidth, final int entryHeight, final int mouseX, final int mouseY, final boolean p_194999_5_, final float partialTicks) { - FontRenderer font = Minecraft.getInstance().font; - final List strings = font.split(message, LoadingEntryList.this.width); + public Component getNarration() { + return new TranslatableComponent("narrator.select", message); + } + + @Override + public void render(PoseStack pStack, int entryIdx, int top, int left, final int entryWidth, final int entryHeight, final int mouseX, final int mouseY, final boolean p_194999_5_, final float partialTicks) { + Font font = Minecraft.getInstance().font; + final List strings = font.split(message, LoadingEntryList.this.width); int y = top + 2; for (int i = 0; i < Math.min(strings.size(), 2); i++) { if (center) - font.draw(mStack, strings.get(i), left + (width) - font.width(strings.get(i)) / 2F, y, 0xFFFFFF); + font.draw(pStack, strings.get(i), left + (width) - font.width(strings.get(i)) / 2F, y, 0xFFFFFF); else - font.draw(mStack, strings.get(i), left + 5, y, 0xFFFFFF); + font.draw(pStack, strings.get(i), left + 5, y, 0xFFFFFF); y += font.lineHeight; } } diff --git a/src/main/java/net/minecraftforge/fml/client/gui/screen/ModListScreen.java b/src/main/java/net/minecraftforge/fmlclient/gui/screen/ModListScreen.java similarity index 74% rename from src/main/java/net/minecraftforge/fml/client/gui/screen/ModListScreen.java rename to src/main/java/net/minecraftforge/fmlclient/gui/screen/ModListScreen.java index 044dcc52b6..c9c63d5a0b 100644 --- a/src/main/java/net/minecraftforge/fml/client/gui/screen/ModListScreen.java +++ b/src/main/java/net/minecraftforge/fmlclient/gui/screen/ModListScreen.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.client.gui.screen; +package net.minecraftforge.fmlclient.gui.screen; import java.io.IOException; import java.io.InputStream; @@ -30,10 +30,10 @@ import java.util.function.Consumer; import java.util.function.Function; import java.util.stream.Collectors; -import com.mojang.blaze3d.matrix.MatrixStack; -import cpw.mods.modlauncher.Environment; -import net.minecraft.util.text.*; -import net.minecraftforge.fml.loading.FMLEnvironment; +import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.client.renderer.GameRenderer; +import net.minecraftforge.fmlclient.gui.GuiUtils; +import net.minecraftforge.fmlclient.gui.widget.ModListWidget; import org.apache.commons.lang3.tuple.Pair; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -42,41 +42,43 @@ import org.apache.maven.artifact.versioning.ComparableVersion; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.gui.widget.TextFieldWidget; -import net.minecraft.client.gui.widget.button.Button; -import net.minecraft.client.gui.widget.list.ExtendedList; -import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.gui.components.EditBox; +import net.minecraft.client.gui.components.Button; +import net.minecraft.client.gui.components.ObjectSelectionList; +import com.mojang.blaze3d.vertex.Tesselator; import net.minecraft.client.renderer.texture.DynamicTexture; -import net.minecraft.client.renderer.texture.NativeImage; +import com.mojang.blaze3d.platform.NativeImage; import net.minecraft.client.renderer.texture.TextureManager; -import net.minecraft.util.IReorderingProcessor; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.Util; +import net.minecraft.util.FormattedCharSequence; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.Util; import net.minecraftforge.client.gui.ScrollPanel; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.util.Size2i; -import net.minecraftforge.fml.ForgeI18n; -import net.minecraftforge.fml.MavenVersionStringHelper; +import net.minecraftforge.fmllegacy.ForgeI18n; +import net.minecraftforge.fmllegacy.MavenVersionStringHelper; import net.minecraftforge.fml.ModContainer; import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.VersionChecker; -import net.minecraftforge.fml.client.ConfigGuiHandler; -import net.minecraftforge.fml.client.gui.GuiUtils; -import net.minecraftforge.fml.client.gui.widget.ModListWidget; +import net.minecraftforge.fmlclient.ConfigGuiHandler; import net.minecraftforge.fml.loading.FMLPaths; import net.minecraftforge.fml.loading.StringUtils; -import net.minecraftforge.fml.loading.moddiscovery.ModInfo; -import net.minecraftforge.fml.packs.ModFileResourcePack; -import net.minecraftforge.fml.packs.ResourcePackLoader; +import net.minecraftforge.fmllegacy.packs.ModFileResourcePack; +import net.minecraftforge.fmllegacy.packs.ResourcePackLoader; import net.minecraftforge.forgespi.language.IModInfo; +import net.minecraft.locale.Language; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.Style; +import net.minecraft.network.chat.TranslatableComponent; + public class ModListScreen extends Screen { - private static String stripControlCodes(String value) { return net.minecraft.util.StringUtils.stripColor(value); } + private static String stripControlCodes(String value) { return net.minecraft.util.StringUtil.stripColor(value); } private static final Logger LOGGER = LogManager.getLogger(); - private enum SortType implements Comparator + private enum SortType implements Comparator { NORMAL, A_TO_Z{ @Override protected int compare(String name1, String name2){ return name1.compareTo(name2); }}, @@ -85,14 +87,14 @@ public class ModListScreen extends Screen Button button; protected int compare(String name1, String name2){ return 0; } @Override - public int compare(ModInfo o1, ModInfo o2) { + public int compare(IModInfo o1, IModInfo o2) { String name1 = StringUtils.toLowerCase(stripControlCodes(o1.getDisplayName())); String name2 = StringUtils.toLowerCase(stripControlCodes(o2.getDisplayName())); return compare(name1, name2); } - ITextComponent getButtonText() { - return new TranslationTextComponent("fml.menu.mods." + StringUtils.toLowerCase(name())); + Component getButtonText() { + return new TranslatableComponent("fml.menu.mods." + StringUtils.toLowerCase(name())); } } @@ -104,15 +106,15 @@ public class ModListScreen extends Screen private InfoPanel modInfo; private ModListWidget.ModEntry selected = null; private int listWidth; - private List mods; - private final List unsortedMods; - private Button configButton, openModsFolderButton; + private List mods; + private final List unsortedMods; + private Button configButton, openModsFolderButton, doneButton; private int buttonMargin = 1; private int numButtons = SortType.values().length; private String lastFilterText = ""; - private TextFieldWidget search; + private EditBox search; private boolean sorted = false; private SortType sortType = SortType.NORMAL; @@ -122,7 +124,7 @@ public class ModListScreen extends Screen */ public ModListScreen(Screen parentScreen) { - super(new TranslationTextComponent("fml.menu.mods.title")); + super(new TranslatableComponent("fml.menu.mods.title")); this.parentScreen = parentScreen; this.mods = Collections.unmodifiableList(ModList.get().getMods()); this.unsortedMods = Collections.unmodifiableList(this.mods); @@ -131,7 +133,7 @@ public class ModListScreen extends Screen class InfoPanel extends ScrollPanel { private ResourceLocation logoPath; private Size2i logoDims = new Size2i(0, 0); - private List lines = Collections.emptyList(); + private List lines = Collections.emptyList(); InfoPanel(Minecraft mcIn, int widthIn, int heightIn, int topIn) { @@ -152,9 +154,9 @@ public class ModListScreen extends Screen this.lines = Collections.emptyList(); } - private List resizeContent(List lines) + private List resizeContent(List lines) { - List ret = new ArrayList<>(); + List ret = new ArrayList<>(); for (String line : lines) { if (line == null) @@ -163,11 +165,11 @@ public class ModListScreen extends Screen continue; } - ITextComponent chat = ForgeHooks.newChatWithLinks(line, false); + Component chat = ForgeHooks.newChatWithLinks(line, false); int maxTextLength = this.width - 12; if (maxTextLength >= 0) { - ret.addAll(LanguageMap.getInstance().getVisualOrder(font.getSplitter().splitLines(chat, maxTextLength, Style.EMPTY))); + ret.addAll(Language.getInstance().getVisualOrder(font.getSplitter().splitLines(chat, maxTextLength, Style.EMPTY))); } } return ret; @@ -190,25 +192,25 @@ public class ModListScreen extends Screen } @Override - protected void drawPanel(MatrixStack mStack, int entryRight, int relativeY, Tessellator tess, int mouseX, int mouseY) + protected void drawPanel(PoseStack mStack, int entryRight, int relativeY, Tesselator tess, int mouseX, int mouseY) { if (logoPath != null) { - Minecraft.getInstance().getTextureManager().bind(logoPath); + RenderSystem.setShader(GameRenderer::getPositionTexShader); RenderSystem.enableBlend(); - RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); + RenderSystem.setShaderTexture(0, logoPath); // Draw the logo image inscribed in a rectangle with width entryWidth (minus some padding) and height 50 int headerHeight = 50; GuiUtils.drawInscribedRect(mStack, left + PADDING, relativeY, width - (PADDING * 2), headerHeight, logoDims.width, logoDims.height, false, true); relativeY += headerHeight + PADDING; } - for (IReorderingProcessor line : lines) + for (FormattedCharSequence line : lines) { if (line != null) { RenderSystem.enableBlend(); ModListScreen.this.font.drawShadow(mStack, line, left + PADDING, relativeY, 0xFFFFFF); - RenderSystem.disableAlphaTest(); RenderSystem.disableBlend(); } relativeY += font.lineHeight; @@ -232,7 +234,7 @@ public class ModListScreen extends Screen if (lineIdx >= lines.size() || lineIdx < 1) return null; - IReorderingProcessor line = lines.get(lineIdx-1); + FormattedCharSequence line = lines.get(lineIdx-1); if (line != null) { return font.getSplitter().componentStyleAtWidth(line, mouseX - left - border); @@ -258,7 +260,7 @@ public class ModListScreen extends Screen @Override public void init() { - for (ModInfo mod : mods) + for (IModInfo mod : mods) { listWidth = Math.max(listWidth,getFontRenderer().width(mod.getDisplayName()) + 10); listWidth = Math.max(listWidth,getFontRenderer().width(MavenVersionStringHelper.artifactVersionToString(mod.getVersion())) + 5); @@ -269,37 +271,37 @@ public class ModListScreen extends Screen int modInfoWidth = this.width - this.listWidth - (PADDING * 3); int doneButtonWidth = Math.min(modInfoWidth, 200); int y = this.height - 20 - PADDING; - this.addButton(new Button(((listWidth + PADDING + this.width - doneButtonWidth) / 2), y, doneButtonWidth, 20, - new TranslationTextComponent("gui.done"), b -> ModListScreen.this.onClose())); - this.addButton(this.openModsFolderButton = new Button(6, y, this.listWidth, 20, - new TranslationTextComponent("fml.menu.mods.openmodsfolder"), b -> Util.getPlatform().openFile(FMLPaths.MODSDIR.get().toFile()))); - y -= 20 + PADDING; - this.addButton(this.configButton = new Button(6, y, this.listWidth, 20, - new TranslationTextComponent("fml.menu.mods.config"), b -> ModListScreen.this.displayModConfig())); - this.configButton.active = false; - - y -= 14 + PADDING + 1; - search = new TextFieldWidget(getFontRenderer(), PADDING + 1, y, listWidth - 2, 14, new TranslationTextComponent("fml.menu.mods.search")); - int fullButtonHeight = PADDING + 20 + PADDING; + + doneButton = new Button(((listWidth + PADDING + this.width - doneButtonWidth) / 2), y, doneButtonWidth, 20, new TranslatableComponent("gui.done"), b -> ModListScreen.this.onClose()); + openModsFolderButton = new Button(6, y, this.listWidth, 20, new TranslatableComponent("fml.menu.mods.openmodsfolder"), b -> Util.getPlatform().openFile(FMLPaths.MODSDIR.get().toFile())); + y -= 20 + PADDING; + configButton = new Button(6, y, this.listWidth, 20, new TranslatableComponent("fml.menu.mods.config"), b -> ModListScreen.this.displayModConfig()); + y -= 14 + PADDING; + search = new EditBox(getFontRenderer(), PADDING + 1, y, listWidth - 2, 14, new TranslatableComponent("fml.menu.mods.search")); + this.modList = new ModListWidget(this, listWidth, fullButtonHeight, search.y - getFontRenderer().lineHeight - PADDING); this.modList.setLeftPos(6); - this.modInfo = new InfoPanel(this.minecraft, modInfoWidth, this.height - PADDING - fullButtonHeight, PADDING); - children.add(search); - children.add(modList); - children.add(modInfo); + this.addRenderableWidget(modList); + this.addRenderableOnly(modInfo); + this.addRenderableWidget(search); + this.addRenderableWidget(doneButton); + this.addRenderableWidget(configButton); + this.addRenderableWidget(openModsFolderButton); + search.setFocus(false); search.setCanLoseFocus(true); + configButton.active = false; final int width = listWidth / numButtons; int x = PADDING; - addButton(SortType.NORMAL.button = new Button(x, PADDING, width - buttonMargin, 20, SortType.NORMAL.getButtonText(), b -> resortMods(SortType.NORMAL))); + addRenderableWidget(SortType.NORMAL.button = new Button(x, PADDING, width - buttonMargin, 20, SortType.NORMAL.getButtonText(), b -> resortMods(SortType.NORMAL))); x += width + buttonMargin; - addButton(SortType.A_TO_Z.button = new Button(x, PADDING, width - buttonMargin, 20, SortType.A_TO_Z.getButtonText(), b -> resortMods(SortType.A_TO_Z))); + addRenderableWidget(SortType.A_TO_Z.button = new Button(x, PADDING, width - buttonMargin, 20, SortType.A_TO_Z.getButtonText(), b -> resortMods(SortType.A_TO_Z))); x += width + buttonMargin; - addButton(SortType.Z_TO_A.button = new Button(x, PADDING, width - buttonMargin, 20, SortType.Z_TO_A.getButtonText(), b -> resortMods(SortType.Z_TO_A))); + addRenderableWidget(SortType.Z_TO_A.button = new Button(x, PADDING, width - buttonMargin, 20, SortType.Z_TO_A.getButtonText(), b -> resortMods(SortType.Z_TO_A))); resortMods(SortType.NORMAL); updateCache(); } @@ -343,7 +345,7 @@ public class ModListScreen extends Screen } } - public > void buildModList(Consumer modListViewConsumer, Function newEntry) + public > void buildModList(Consumer modListViewConsumer, Function newEntry) { mods.forEach(mod->modListViewConsumer.accept(newEntry.apply(mod))); } @@ -368,17 +370,17 @@ public class ModListScreen extends Screen } @Override - public void render(MatrixStack mStack, int mouseX, int mouseY, float partialTicks) + public void render(PoseStack mStack, int mouseX, int mouseY, float partialTicks) { this.modList.render(mStack, mouseX, mouseY, partialTicks); if (this.modInfo != null) this.modInfo.render(mStack, mouseX, mouseY, partialTicks); - ITextComponent text = new TranslationTextComponent("fml.menu.mods.search"); + Component text = new TranslatableComponent("fml.menu.mods.search"); int x = modList.getLeft() + ((modList.getRight() - modList.getLeft()) / 2) - (getFontRenderer().width(text) / 2); - getFontRenderer().draw(mStack, text.getVisualOrderText(), x, search.y - getFontRenderer().lineHeight, 0xFFFFFF); this.search.render(mStack, mouseX , mouseY, partialTicks); super.render(mStack, mouseX, mouseY, partialTicks); + getFontRenderer().draw(mStack, text.getVisualOrderText(), x, search.y - getFontRenderer().lineHeight, 0xFFFFFF); } public Minecraft getMinecraftInstance() @@ -386,7 +388,7 @@ public class ModListScreen extends Screen return minecraft; } - public FontRenderer getFontRenderer() + public Font getFontRenderer() { return font; } @@ -404,7 +406,7 @@ public class ModListScreen extends Screen this.modInfo.clearInfo(); return; } - ModInfo selectedMod = selected.getInfo(); + IModInfo selectedMod = selected.getInfo(); this.configButton.active = ConfigGuiHandler.getGuiFactoryFor(selectedMod).isPresent(); List lines = new ArrayList<>(); VersionChecker.CheckResult vercheck = VersionChecker.getResult(selectedMod); @@ -446,19 +448,19 @@ public class ModListScreen extends Screen lines.add(ForgeI18n.parseMessage("fml.menu.mods.info.idstate", selectedMod.getModId(), ModList.get().getModContainerById(selectedMod.getModId()). map(ModContainer::getCurrentState).map(Object::toString).orElse("NONE"))); - selectedMod.getConfigElement("credits").ifPresent(credits-> + selectedMod.getConfig().getConfigElement("credits").ifPresent(credits-> lines.add(ForgeI18n.parseMessage("fml.menu.mods.info.credits", credits))); - selectedMod.getConfigElement("authors").ifPresent(authors -> + selectedMod.getConfig().getConfigElement("authors").ifPresent(authors -> lines.add(ForgeI18n.parseMessage("fml.menu.mods.info.authors", authors))); - selectedMod.getConfigElement("displayURL").ifPresent(displayURL -> + selectedMod.getConfig().getConfigElement("displayURL").ifPresent(displayURL -> lines.add(ForgeI18n.parseMessage("fml.menu.mods.info.displayurl", displayURL))); if (selectedMod.getOwningFile() == null || selectedMod.getOwningFile().getMods().size()==1) lines.add(ForgeI18n.parseMessage("fml.menu.mods.info.nochildmods")); else lines.add(ForgeI18n.parseMessage("fml.menu.mods.info.childmods", selectedMod.getOwningFile().getMods().stream().map(IModInfo::getDisplayName).collect(Collectors.joining(",")))); - if (vercheck.status == VersionChecker.Status.OUTDATED || vercheck.status == VersionChecker.Status.BETA_OUTDATED) - lines.add(ForgeI18n.parseMessage("fml.menu.mods.info.updateavailable", vercheck.url == null ? "" : vercheck.url)); + if (vercheck.status() == VersionChecker.Status.OUTDATED || vercheck.status() == VersionChecker.Status.BETA_OUTDATED) + lines.add(ForgeI18n.parseMessage("fml.menu.mods.info.updateavailable", vercheck.url() == null ? "" : vercheck.url())); lines.add(ForgeI18n.parseMessage("fml.menu.mods.info.license", selectedMod.getOwningFile().getLicense())); lines.add(null); lines.add(selectedMod.getDescription()); @@ -466,18 +468,18 @@ public class ModListScreen extends Screen /* Removed because people bitched that this information was misleading. lines.add(null); if (FMLEnvironment.secureJarsEnabled) { - lines.add(ForgeI18n.parseMessage("fml.menu.mods.info.signature", selectedMod.getOwningFile().getCodeSigningFingerprint().orElse(ForgeI18n.parseMessage("fml.menu.mods.info.signature.unsigned")))); + lines.add(ForgeI18getOwningFile().getFile().n.parseMessage("fml.menu.mods.info.signature", selectedMod.getOwningFile().getCodeSigningFingerprint().orElse(ForgeI18n.parseMessage("fml.menu.mods.info.signature.unsigned")))); lines.add(ForgeI18n.parseMessage("fml.menu.mods.info.trust", selectedMod.getOwningFile().getTrustData().orElse(ForgeI18n.parseMessage("fml.menu.mods.info.trust.noauthority")))); } else { lines.add(ForgeI18n.parseMessage("fml.menu.mods.info.securejardisabled")); } */ - if ((vercheck.status == VersionChecker.Status.OUTDATED || vercheck.status == VersionChecker.Status.BETA_OUTDATED) && vercheck.changes.size() > 0) + if ((vercheck.status() == VersionChecker.Status.OUTDATED || vercheck.status() == VersionChecker.Status.BETA_OUTDATED) && vercheck.changes().size() > 0) { lines.add(null); lines.add(ForgeI18n.parseMessage("fml.menu.mods.info.changelogheader")); - for (Entry entry : vercheck.changes.entrySet()) + for (Entry entry : vercheck.changes().entrySet()) { lines.add(" " + entry.getKey() + ":"); lines.add(entry.getValue()); diff --git a/src/main/java/net/minecraftforge/fml/client/gui/screen/NotificationScreen.java b/src/main/java/net/minecraftforge/fmlclient/gui/screen/NotificationScreen.java similarity index 92% rename from src/main/java/net/minecraftforge/fml/client/gui/screen/NotificationScreen.java rename to src/main/java/net/minecraftforge/fmlclient/gui/screen/NotificationScreen.java index 5def5109ff..6df13826aa 100644 --- a/src/main/java/net/minecraftforge/fml/client/gui/screen/NotificationScreen.java +++ b/src/main/java/net/minecraftforge/fmlclient/gui/screen/NotificationScreen.java @@ -20,14 +20,6 @@ /* package net.minecraftforge.fml.client.gui.screen; -import com.mojang.blaze3d.matrix.MatrixStack; -import net.minecraft.client.gui.widget.button.Button; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.util.text.TranslationTextComponent; -import net.minecraftforge.client.gui.ScrollPanel; - public class NotificationScreen extends Screen { private class TextPanel extends ScrollPanel diff --git a/src/main/java/net/minecraftforge/fml/client/gui/widget/ExtendedButton.java b/src/main/java/net/minecraftforge/fmlclient/gui/widget/ExtendedButton.java similarity index 78% rename from src/main/java/net/minecraftforge/fml/client/gui/widget/ExtendedButton.java rename to src/main/java/net/minecraftforge/fmlclient/gui/widget/ExtendedButton.java index cf2941d7ef..021157c432 100644 --- a/src/main/java/net/minecraftforge/fml/client/gui/widget/ExtendedButton.java +++ b/src/main/java/net/minecraftforge/fmlclient/gui/widget/ExtendedButton.java @@ -17,16 +17,16 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.client.gui.widget; +package net.minecraftforge.fmlclient.gui.widget; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.widget.button.Button; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; -import net.minecraftforge.fml.client.gui.GuiUtils; +import net.minecraft.client.gui.components.Button; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraftforge.fmlclient.gui.GuiUtils; -import net.minecraft.client.gui.widget.button.Button.IPressable; +import net.minecraft.client.gui.components.Button.OnPress; /** * This class provides a button that fixes several bugs present in the vanilla GuiButton drawing code. @@ -40,7 +40,7 @@ import net.minecraft.client.gui.widget.button.Button.IPressable; */ public class ExtendedButton extends Button { - public ExtendedButton(int xPos, int yPos, int width, int height, ITextComponent displayString, IPressable handler) + public ExtendedButton(int xPos, int yPos, int width, int height, Component displayString, OnPress handler) { super(xPos, yPos, width, height, displayString, handler); } @@ -49,7 +49,7 @@ public class ExtendedButton extends Button * Draws this button to the screen. */ @Override - public void renderButton(MatrixStack mStack, int mouseX, int mouseY, float partial) + public void renderButton(PoseStack mStack, int mouseX, int mouseY, float partial) { if (this.visible) { @@ -59,13 +59,13 @@ public class ExtendedButton extends Button GuiUtils.drawContinuousTexturedBox(mStack, WIDGETS_LOCATION, this.x, this.y, 0, 46 + k * 20, this.width, this.height, 200, 20, 2, 3, 2, 2, this.getBlitOffset()); this.renderBg(mStack, mc, mouseX, mouseY); - ITextComponent buttonText = this.getMessage(); + Component buttonText = this.getMessage(); int strWidth = mc.font.width(buttonText); int ellipsisWidth = mc.font.width("..."); if (strWidth > width - 6 && strWidth > ellipsisWidth) //TODO, srg names make it hard to figure out how to append to an ITextProperties from this trim operation, wraping this in StringTextComponent is kinda dirty. - buttonText = new StringTextComponent(mc.font.substrByWidth(buttonText, width - 6 - ellipsisWidth).getString() + "..."); + buttonText = new TextComponent(mc.font.substrByWidth(buttonText, width - 6 - ellipsisWidth).getString() + "..."); drawCenteredString(mStack, mc.font, buttonText, this.x + this.width / 2, this.y + (this.height - 8) / 2, getFGColor()); } diff --git a/src/main/java/net/minecraftforge/fml/client/gui/widget/ModListWidget.java b/src/main/java/net/minecraftforge/fmlclient/gui/widget/ModListWidget.java similarity index 50% rename from src/main/java/net/minecraftforge/fml/client/gui/widget/ModListWidget.java rename to src/main/java/net/minecraftforge/fmlclient/gui/widget/ModListWidget.java index 9ae705b7ce..744e56999b 100644 --- a/src/main/java/net/minecraftforge/fml/client/gui/widget/ModListWidget.java +++ b/src/main/java/net/minecraftforge/fmlclient/gui/widget/ModListWidget.java @@ -17,29 +17,29 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.client.gui.widget; +package net.minecraftforge.fmlclient.gui.widget; -import com.mojang.blaze3d.matrix.MatrixStack; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.AbstractGui; -import net.minecraft.client.gui.widget.list.ExtendedList; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.ITextProperties; -import net.minecraft.util.text.LanguageMap; -import net.minecraft.util.text.StringTextComponent; -import net.minecraftforge.fml.client.gui.screen.ModListScreen; +import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.GuiComponent; +import net.minecraft.client.gui.components.ObjectSelectionList; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.FormattedText; +import net.minecraft.locale.Language; +import net.minecraft.network.chat.TextComponent; +import net.minecraftforge.fmlclient.gui.screen.ModListScreen; import net.minecraftforge.versions.forge.ForgeVersion; -import net.minecraftforge.fml.MavenVersionStringHelper; +import net.minecraftforge.fmllegacy.MavenVersionStringHelper; import net.minecraftforge.fml.VersionChecker; -import net.minecraftforge.fml.loading.moddiscovery.ModInfo; +import net.minecraftforge.forgespi.language.IModInfo; import com.mojang.blaze3d.systems.RenderSystem; -public class ModListWidget extends ExtendedList +public class ModListWidget extends ObjectSelectionList { - private static String stripControlCodes(String value) { return net.minecraft.util.StringUtils.stripColor(value); } + private static String stripControlCodes(String value) { return net.minecraft.util.StringUtil.stripColor(value); } private static final ResourceLocation VERSION_CHECK_ICONS = new ResourceLocation(ForgeVersion.MOD_ID, "textures/gui/version_check_icons.png"); private final int listWidth; @@ -71,37 +71,42 @@ public class ModListWidget extends ExtendedList } @Override - protected void renderBackground(MatrixStack mStack) + protected void renderBackground(PoseStack mStack) { this.parent.renderBackground(mStack); } - public class ModEntry extends ExtendedList.AbstractListEntry { - private final ModInfo modInfo; + public class ModEntry extends ObjectSelectionList.Entry { + private final IModInfo modInfo; private final ModListScreen parent; - ModEntry(ModInfo info, ModListScreen parent) { + ModEntry(IModInfo info, ModListScreen parent) { this.modInfo = info; this.parent = parent; } @Override - public void render(MatrixStack mStack, int entryIdx, int top, int left, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean p_194999_5_, float partialTicks) + public Component getNarration() { + return new TranslatableComponent("narrator.select", modInfo.getDisplayName()); + } + + @Override + public void render(PoseStack pStack, int entryIdx, int top, int left, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean p_194999_5_, float partialTicks) { - ITextComponent name = new StringTextComponent(stripControlCodes(modInfo.getDisplayName())); - ITextComponent version = new StringTextComponent(stripControlCodes(MavenVersionStringHelper.artifactVersionToString(modInfo.getVersion()))); + Component name = new TextComponent(stripControlCodes(modInfo.getDisplayName())); + Component version = new TextComponent(stripControlCodes(MavenVersionStringHelper.artifactVersionToString(modInfo.getVersion()))); VersionChecker.CheckResult vercheck = VersionChecker.getResult(modInfo); - FontRenderer font = this.parent.getFontRenderer(); - font.draw(mStack, LanguageMap.getInstance().getVisualOrder(ITextProperties.composite(font.substrByWidth(name, listWidth))), left + 3, top + 2, 0xFFFFFF); - font.draw(mStack, LanguageMap.getInstance().getVisualOrder(ITextProperties.composite(font.substrByWidth(version, listWidth))), left + 3, top + 2 + font.lineHeight, 0xCCCCCC); - if (vercheck.status.shouldDraw()) + Font font = this.parent.getFontRenderer(); + font.draw(pStack, Language.getInstance().getVisualOrder(FormattedText.composite(font.substrByWidth(name, listWidth))), left + 3, top + 2, 0xFFFFFF); + font.draw(pStack, Language.getInstance().getVisualOrder(FormattedText.composite(font.substrByWidth(version, listWidth))), left + 3, top + 2 + font.lineHeight, 0xCCCCCC); + if (vercheck.status().shouldDraw()) { //TODO: Consider adding more icons for visualization - Minecraft.getInstance().getTextureManager().bind(VERSION_CHECK_ICONS); - RenderSystem.color4f(1, 1, 1, 1); - RenderSystem.pushMatrix(); - AbstractGui.blit(mStack, getLeft() + width - 12, top + entryHeight / 4, vercheck.status.getSheetOffset() * 8, (vercheck.status.isAnimated() && ((System.currentTimeMillis() / 800 & 1)) == 1) ? 8 : 0, 8, 8, 64, 16); - RenderSystem.popMatrix(); + RenderSystem.setShaderColor(1, 1, 1, 1); + RenderSystem.setShaderTexture(0, VERSION_CHECK_ICONS); + pStack.pushPose(); + GuiComponent.blit(pStack, getLeft() + width - 12, top + entryHeight / 4, vercheck.status().getSheetOffset() * 8, (vercheck.status().isAnimated() && ((System.currentTimeMillis() / 800 & 1)) == 1) ? 8 : 0, 8, 8, 64, 16); + pStack.popPose(); } } @@ -113,7 +118,7 @@ public class ModListWidget extends ExtendedList return false; } - public ModInfo getInfo() + public IModInfo getInfo() { return modInfo; } diff --git a/src/main/java/net/minecraftforge/fml/client/gui/widget/Slider.java b/src/main/java/net/minecraftforge/fmlclient/gui/widget/Slider.java similarity index 78% rename from src/main/java/net/minecraftforge/fml/client/gui/widget/Slider.java rename to src/main/java/net/minecraftforge/fmlclient/gui/widget/Slider.java index 22981f1dbd..e644242a5a 100644 --- a/src/main/java/net/minecraftforge/fml/client/gui/widget/Slider.java +++ b/src/main/java/net/minecraftforge/fmlclient/gui/widget/Slider.java @@ -17,17 +17,17 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.client.gui.widget; +package net.minecraftforge.fmlclient.gui.widget; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; -import net.minecraftforge.fml.client.gui.GuiUtils; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraftforge.fmlclient.gui.GuiUtils; import javax.annotation.Nullable; -import net.minecraft.client.gui.widget.button.Button.IPressable; +import net.minecraft.client.gui.components.Button.OnPress; /** * This class is blatantly stolen from iChunUtils with permission. @@ -39,7 +39,7 @@ public class Slider extends ExtendedButton /** The value of this slider control. */ public double sliderValue = 1.0F; - public ITextComponent dispString; + public Component dispString; /** Is this slider control being dragged. */ public boolean dragging = false; @@ -52,16 +52,16 @@ public class Slider extends ExtendedButton @Nullable public ISlider parent = null; - public ITextComponent suffix; + public Component suffix; public boolean drawString = true; - public Slider(int xPos, int yPos, int width, int height, ITextComponent prefix, ITextComponent suf, double minVal, double maxVal, double currentVal, boolean showDec, boolean drawStr, IPressable handler) + public Slider(int xPos, int yPos, int width, int height, Component prefix, Component suf, double minVal, double maxVal, double currentVal, boolean showDec, boolean drawStr, OnPress handler) { this(xPos, yPos, width, height, prefix, suf, minVal, maxVal, currentVal, showDec, drawStr, handler, null); } - public Slider(int xPos, int yPos, int width, int height, ITextComponent prefix, ITextComponent suf, double minVal, double maxVal, double currentVal, boolean showDec, boolean drawStr, IPressable handler, @Nullable ISlider par) + public Slider(int xPos, int yPos, int width, int height, Component prefix, Component suf, double minVal, double maxVal, double currentVal, boolean showDec, boolean drawStr, OnPress handler, @Nullable ISlider par) { super(xPos, yPos, width, height, prefix, handler); minValue = minVal; @@ -84,16 +84,16 @@ public class Slider extends ExtendedButton precision = 0; } - setMessage(new StringTextComponent("").append(dispString).append(val).append(suffix)); + setMessage(new TextComponent("").append(dispString).append(val).append(suffix)); drawString = drawStr; if(!drawString) - setMessage(new StringTextComponent("")); + setMessage(new TextComponent("")); } - public Slider(int xPos, int yPos, ITextComponent displayStr, double minVal, double maxVal, double currentVal, IPressable handler, ISlider par) + public Slider(int xPos, int yPos, Component displayStr, double minVal, double maxVal, double currentVal, OnPress handler, ISlider par) { - this(xPos, yPos, 150, 20, displayStr, new StringTextComponent(""), minVal, maxVal, currentVal, true, true, handler, par); + this(xPos, yPos, 150, 20, displayStr, new TextComponent(""), minVal, maxVal, currentVal, true, true, handler, par); } /** @@ -110,7 +110,7 @@ public class Slider extends ExtendedButton * Fired when the mouse button is dragged. Equivalent of MouseListener.mouseDragged(MouseEvent e). */ @Override - protected void renderBg(MatrixStack mStack, Minecraft par1Minecraft, int par2, int par3) + protected void renderBg(PoseStack mStack, Minecraft par1Minecraft, int par2, int par3) { if (this.visible) { @@ -178,7 +178,7 @@ public class Slider extends ExtendedButton if(drawString) { - setMessage(new StringTextComponent("").append(dispString).append(val).append(suffix)); + setMessage(new TextComponent("").append(dispString).append(val).append(suffix)); } if (parent != null) diff --git a/src/main/java/net/minecraftforge/fml/client/gui/widget/UnicodeGlyphButton.java b/src/main/java/net/minecraftforge/fmlclient/gui/widget/UnicodeGlyphButton.java similarity index 71% rename from src/main/java/net/minecraftforge/fml/client/gui/widget/UnicodeGlyphButton.java rename to src/main/java/net/minecraftforge/fmlclient/gui/widget/UnicodeGlyphButton.java index d784a05784..f748837914 100644 --- a/src/main/java/net/minecraftforge/fml/client/gui/widget/UnicodeGlyphButton.java +++ b/src/main/java/net/minecraftforge/fmlclient/gui/widget/UnicodeGlyphButton.java @@ -17,17 +17,17 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.client.gui.widget; +package net.minecraftforge.fmlclient.gui.widget; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.widget.button.Button; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; -import net.minecraftforge.fml.client.gui.GuiUtils; +import net.minecraft.client.gui.components.Button; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraftforge.fmlclient.gui.GuiUtils; -import net.minecraft.client.gui.widget.button.Button.IPressable; +import net.minecraft.client.gui.components.Button.OnPress; /** * This class provides a button that shows a string glyph at the beginning. The glyph can be scaled using the glyphScale parameter. @@ -39,7 +39,7 @@ public class UnicodeGlyphButton extends ExtendedButton public String glyph; public float glyphScale; - public UnicodeGlyphButton(int xPos, int yPos, int width, int height, ITextComponent displayString, String glyph, float glyphScale, IPressable handler) + public UnicodeGlyphButton(int xPos, int yPos, int width, int height, Component displayString, String glyph, float glyphScale, OnPress handler) { super(xPos, yPos, width, height, displayString, handler); this.glyph = glyph; @@ -47,31 +47,31 @@ public class UnicodeGlyphButton extends ExtendedButton } @Override - public void render(MatrixStack mStack, int mouseX, int mouseY, float partial) + public void render(PoseStack mStack, int mouseX, int mouseY, float partial) { if (this.visible) { Minecraft mc = Minecraft.getInstance(); this.isHovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height; int k = this.getYImage(this.isHovered); - GuiUtils.drawContinuousTexturedBox(mStack, Button.WIDGETS_LOCATION, this.x, this.y, 0, 46 + k * 20, this.width, this.height, 200, 20, 2, 3, 2, 2, this.getBlitOffset()); + GuiUtils.drawContinuousTexturedBox(mStack, WIDGETS_LOCATION, this.x, this.y, 0, 46 + k * 20, this.width, this.height, 200, 20, 2, 3, 2, 2, this.getBlitOffset()); this.renderBg(mStack, mc, mouseX, mouseY); - ITextComponent buttonText = this.createNarrationMessage(); + Component buttonText = this.createNarrationMessage(); int glyphWidth = (int) (mc.font.width(glyph) * glyphScale); int strWidth = mc.font.width(buttonText); int ellipsisWidth = mc.font.width("..."); int totalWidth = strWidth + glyphWidth; if (totalWidth > width - 6 && totalWidth > ellipsisWidth) - buttonText = new StringTextComponent(mc.font.substrByWidth(buttonText, width - 6 - ellipsisWidth).getString().trim() + "...") ; + buttonText = new TextComponent(mc.font.substrByWidth(buttonText, width - 6 - ellipsisWidth).getString().trim() + "...") ; strWidth = mc.font.width(buttonText); totalWidth = glyphWidth + strWidth; mStack.pushPose(); mStack.scale(glyphScale, glyphScale, 1.0F); - this.drawCenteredString(mStack, mc.font, new StringTextComponent(glyph), + this.drawCenteredString(mStack, mc.font, new TextComponent(glyph), (int) (((this.x + (this.width / 2) - (strWidth / 2)) / glyphScale) - (glyphWidth / (2 * glyphScale)) + 2), (int) (((this.y + ((this.height - 8) / glyphScale) / 2) - 1) / glyphScale), getFGColor()); mStack.popPose(); diff --git a/src/main/java/net/minecraftforge/fml/client/registry/ClientRegistry.java b/src/main/java/net/minecraftforge/fmlclient/registry/ClientRegistry.java similarity index 65% rename from src/main/java/net/minecraftforge/fml/client/registry/ClientRegistry.java rename to src/main/java/net/minecraftforge/fmlclient/registry/ClientRegistry.java index e1e8e7fcb2..e4bd2457f5 100644 --- a/src/main/java/net/minecraftforge/fml/client/registry/ClientRegistry.java +++ b/src/main/java/net/minecraftforge/fmlclient/registry/ClientRegistry.java @@ -17,44 +17,28 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.client.registry; +package net.minecraftforge.fmlclient.registry; -import net.minecraft.client.renderer.tileentity.TileEntityRenderer; -import net.minecraft.entity.Entity; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.ResourceLocation; +import net.minecraft.world.entity.Entity; +import net.minecraft.resources.ResourceLocation; import org.apache.commons.lang3.ArrayUtils; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.client.settings.KeyBinding; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.client.KeyMapping; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import java.util.function.Function; public class ClientRegistry { private static Map, ResourceLocation> entityShaderMap = new ConcurrentHashMap<>(); - /** - * Registers a Tile Entity renderer. - * Call this during {@link net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent}. - * This method is safe to call during parallel mod loading. - */ - public static synchronized void bindTileEntityRenderer(TileEntityType tileEntityType, - Function> rendererFactory) - { - TileEntityRendererDispatcher.instance.setSpecialRendererInternal(tileEntityType, rendererFactory.apply(TileEntityRendererDispatcher.instance)); - } - /** * Registers a KeyBinding. * Call this during {@link net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent}. * This method is safe to call during parallel mod loading. */ - public static synchronized void registerKeyBinding(KeyBinding key) + public static synchronized void registerKeyBinding(KeyMapping key) { Minecraft.getInstance().options.keyMappings = ArrayUtils.add(Minecraft.getInstance().options.keyMappings, key); } diff --git a/src/main/java/net/minecraftforge/fml/client/registry/IRenderFactory.java b/src/main/java/net/minecraftforge/fmlclient/registry/IRenderFactory.java similarity index 78% rename from src/main/java/net/minecraftforge/fml/client/registry/IRenderFactory.java rename to src/main/java/net/minecraftforge/fmlclient/registry/IRenderFactory.java index 1dabba0f8e..3704e986ea 100644 --- a/src/main/java/net/minecraftforge/fml/client/registry/IRenderFactory.java +++ b/src/main/java/net/minecraftforge/fmlclient/registry/IRenderFactory.java @@ -17,13 +17,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.client.registry; +package net.minecraftforge.fmlclient.registry; import net.minecraft.client.renderer.entity.EntityRenderer; -import net.minecraft.client.renderer.entity.EntityRendererManager; -import net.minecraft.entity.Entity; +import net.minecraft.client.renderer.entity.EntityRenderDispatcher; +import net.minecraft.world.entity.Entity; public interface IRenderFactory { - EntityRenderer createRenderFor(EntityRendererManager manager); + EntityRenderer createRenderFor(EntityRenderDispatcher manager); } diff --git a/src/main/java/net/minecraftforge/fmlclient/registry/RenderingRegistry.java b/src/main/java/net/minecraftforge/fmlclient/registry/RenderingRegistry.java new file mode 100644 index 0000000000..7eefaf8d1a --- /dev/null +++ b/src/main/java/net/minecraftforge/fmlclient/registry/RenderingRegistry.java @@ -0,0 +1,120 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.fmlclient.registry; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.function.Supplier; + +import com.google.common.collect.ImmutableMap; +import net.minecraft.client.model.geom.ModelLayerLocation; +import net.minecraft.client.model.geom.builders.LayerDefinition; +import net.minecraft.client.renderer.entity.EntityRendererProvider; +import net.minecraft.client.renderer.entity.EntityRenderers; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; + +public class RenderingRegistry +{ + private static final RenderingRegistry INSTANCE = new RenderingRegistry(); + + private final Map, EntityRendererProvider> entityRenderers = new ConcurrentHashMap<>(); + private final Map> layerDefinitions = new ConcurrentHashMap<>(); + + /** + * Register an entity rendering handler. This will, after mod initialization, be inserted into the main + * render map for entities. + * Call this during {@link net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent}. + * This method is safe to call during parallel mod loading. + */ + public static void registerEntityRenderingHandler(EntityType entityClass, EntityRendererProvider renderProvider) + { + INSTANCE.entityRenderers.put(entityClass, renderProvider); + } + + /** + * Registers a layer definition supplier with the given {@link ModelLayerLocation}. This will, after mod + * initialization, be inserted into the main layer definition map for entity model layers. + *

+ * Call this during {@link net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent}. + * This method is safe to call during parallel mod loading. + * @param layerLocation The model layer location, which should be used in conjunction with {@link EntityRendererProvider.Context#bakeLayer(ModelLayerLocation)} + * @param supplier A supplier to create a {@link LayerDefinition}, generally a static method reference in the entity model class + */ + public static void registerLayerDefinition(ModelLayerLocation layerLocation, Supplier supplier) + { + INSTANCE.layerDefinitions.put(layerLocation, supplier); + } + + public static void loadEntityRenderers() + { + INSTANCE.entityRenderers.forEach(RenderingRegistry::register); + EntityRenderers.validateRegistrations(); + } + + public static void loadLayerDefinitions(ImmutableMap.Builder builder) { + INSTANCE.layerDefinitions.forEach((k, v) -> builder.put(k, v.get())); + } + + @SuppressWarnings("unchecked") + private static void register(EntityType entityType, EntityRendererProvider renderProvider) + { + EntityRenderers.register(entityType, ((EntityRendererProvider)renderProvider)); + } + + private static ModelLayerLocation registerModelLayer(ResourceLocation model, String layer) + { + return new ModelLayerLocation(model, layer); + } + + /** + * Registers a model layer location for the main layer definition of an entity. + * + * @param model The model {@link ResourceLocation} + * @return A main model layer location + */ + public static ModelLayerLocation registerMainModelLayer(ResourceLocation model) + { + return registerModelLayer(model, "main"); + } + + /** + * Registers a model layer location for the inner armor layer definition of an entity. + * + * @param model The model {@link ResourceLocation} + * @return An inner armor model layer location + */ + public static ModelLayerLocation registerInnerArmorModelLayer(ResourceLocation model) + { + return registerModelLayer(model, "inner_armor"); + } + + /** + * Registers a model layer location for the outer armor layer definition of an entity. + * + * @param model The model {@link ResourceLocation} + * @return An outer armor model layer location + */ + public static ModelLayerLocation registerOuterArmorModelLayer(ResourceLocation model) + { + return registerModelLayer(model, "outer_armor"); + } +} diff --git a/src/main/java/net/minecraftforge/fml/BrandingControl.java b/src/main/java/net/minecraftforge/fmllegacy/BrandingControl.java similarity index 90% rename from src/main/java/net/minecraftforge/fml/BrandingControl.java rename to src/main/java/net/minecraftforge/fmllegacy/BrandingControl.java index ccddba6681..5bb457a4fc 100644 --- a/src/main/java/net/minecraftforge/fml/BrandingControl.java +++ b/src/main/java/net/minecraftforge/fmllegacy/BrandingControl.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml; +package net.minecraftforge.fmllegacy; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; @@ -25,9 +25,10 @@ import java.util.List; import java.util.function.BiConsumer; import java.util.stream.IntStream; -import net.minecraft.resources.IResourceManager; -import net.minecraft.resources.IResourceManagerReloadListener; +import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.server.packs.resources.ResourceManagerReloadListener; import net.minecraftforge.client.ForgeHooksClient; +import net.minecraftforge.fml.ModList; import net.minecraftforge.versions.forge.ForgeVersion; import net.minecraftforge.versions.mcp.MCPVersion; @@ -89,11 +90,11 @@ public class BrandingControl return "forge"; } - public static IResourceManagerReloadListener resourceManagerReloadListener() { + public static ResourceManagerReloadListener resourceManagerReloadListener() { return BrandingControl::onResourceManagerReload; } - private static void onResourceManagerReload(IResourceManager resourceManager) { + private static void onResourceManagerReload(ResourceManager resourceManager) { brandings = null; brandingsNoMC = null; } diff --git a/src/main/java/net/minecraftforge/fml/CrashReportExtender.java b/src/main/java/net/minecraftforge/fmllegacy/CrashReportExtender.java similarity index 73% rename from src/main/java/net/minecraftforge/fml/CrashReportExtender.java rename to src/main/java/net/minecraftforge/fmllegacy/CrashReportExtender.java index 490df7adff..ad1dba2ee2 100644 --- a/src/main/java/net/minecraftforge/fml/CrashReportExtender.java +++ b/src/main/java/net/minecraftforge/fmllegacy/CrashReportExtender.java @@ -17,51 +17,35 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml; +package net.minecraftforge.fmllegacy; import cpw.mods.modlauncher.log.TransformingThrowablePatternConverter; import joptsimple.internal.Strings; -import net.minecraft.crash.CrashReport; -import net.minecraft.crash.CrashReportCategory; -import net.minecraftforge.fml.common.ICrashCallable; -import net.minecraftforge.fml.loading.moddiscovery.ModFileInfo; +import net.minecraft.CrashReport; +import net.minecraft.CrashReportCategory; +import net.minecraft.SystemReport; +import net.minecraftforge.fml.CrashReportCallables; +import net.minecraftforge.fml.ISystemReportExtender; +import net.minecraftforge.fml.LoadingFailedException; +import net.minecraftforge.forgespi.language.IModFileInfo; import net.minecraftforge.forgespi.language.IModInfo; import org.apache.logging.log4j.Logger; import java.io.File; import java.text.SimpleDateFormat; import java.util.*; -import java.util.concurrent.Callable; public class CrashReportExtender { - private static List crashCallables = Collections.synchronizedList(new ArrayList<>()); - public static void enhanceCrashReport(final CrashReport crashReport, final CrashReportCategory category) + public static void extendSystemReport(final SystemReport systemReport) { - for (final ICrashCallable call: crashCallables) + for (final ISystemReportExtender call: CrashReportCallables.allCrashCallables()) { - category.setDetail(call.getLabel(), call); + systemReport.setDetail(call.getLabel(), call); } } - public static void registerCrashCallable(ICrashCallable callable) - { - crashCallables.add(callable); - } - - public static void registerCrashCallable(String headerName, Callable reportGenerator) { - registerCrashCallable(new ICrashCallable() { - @Override - public String getLabel() { - return headerName; - } - @Override - public String call() throws Exception { - return reportGenerator.call(); - } - }); - } public static void addCrashReportHeader(StringBuilder stringbuilder, CrashReport crashReport) { } @@ -94,10 +78,10 @@ public class CrashReportExtender } if (cause != null) category.applyStackTrace(cause); - category.setDetail("Mod File", () -> modInfo.map(IModInfo::getOwningFile).map(t->((ModFileInfo)t).getFile().getFileName()).orElse("NO FILE INFO")); + category.setDetail("Mod File", () -> modInfo.map(IModInfo::getOwningFile).map(t-> t.getFile().getFileName()).orElse("NO FILE INFO")); category.setDetail("Failure message", () -> mle.getCleanMessage().replace("\n", "\n\t\t")); category.setDetail("Mod Version", () -> modInfo.map(IModInfo::getVersion).map(Object::toString).orElse("NO MOD INFO AVAILABLE")); - category.setDetail("Mod Issue URL", () -> modInfo.map(IModInfo::getOwningFile).map(ModFileInfo.class::cast).flatMap(mfi->mfi.getConfigElement("issueTrackerURL")).orElse("NOT PROVIDED")); + category.setDetail("Mod Issue URL", () -> modInfo.map(IModInfo::getOwningFile).map(IModFileInfo.class::cast).flatMap(mfi->mfi.getConfig().getConfigElement("issueTrackerURL")).orElse("NOT PROVIDED")); category.setDetail("Exception message", Objects.toString(cause, "MISSING EXCEPTION MESSAGE")); }); final File file1 = new File(topLevelDir, "crash-reports"); diff --git a/src/main/java/net/minecraftforge/fml/DatagenModLoader.java b/src/main/java/net/minecraftforge/fmllegacy/DatagenModLoader.java similarity index 70% rename from src/main/java/net/minecraftforge/fml/DatagenModLoader.java rename to src/main/java/net/minecraftforge/fmllegacy/DatagenModLoader.java index 3d4ec7e94a..9554d22330 100644 --- a/src/main/java/net/minecraftforge/fml/DatagenModLoader.java +++ b/src/main/java/net/minecraftforge/fmllegacy/DatagenModLoader.java @@ -17,12 +17,14 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml; +package net.minecraftforge.fmllegacy; import java.util.Collections; -import net.minecraft.util.registry.Bootstrap; +import net.minecraft.server.Bootstrap; import net.minecraftforge.common.data.ExistingFileHelper; -import net.minecraftforge.fml.event.lifecycle.GatherDataEvent; +import net.minecraftforge.fml.ModLoader; +import net.minecraftforge.fml.ModWorkManager; +import net.minecraftforge.forge.event.lifecycle.GatherDataEvent; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -41,16 +43,6 @@ public class DatagenModLoader { return runningDataGen; } - @Deprecated //TODO: Remove in 1.17 - public static void begin(final Set mods, final Path path, final Collection inputs, Collection existingPacks, final boolean serverGenerators, final boolean clientGenerators, final boolean devToolGenerators, final boolean reportsGenerator, final boolean structureValidator, final boolean flat) { - begin(mods, path, inputs, existingPacks, Collections.emptySet(), serverGenerators, clientGenerators, devToolGenerators, reportsGenerator, structureValidator, flat); - } - - @Deprecated //TODO: Remove in 1.17 - public static void begin(final Set mods, final Path path, final Collection inputs, Collection existingPacks, Set existingMods, final boolean serverGenerators, final boolean clientGenerators, final boolean devToolGenerators, final boolean reportsGenerator, final boolean structureValidator, final boolean flat) { - begin(mods, path, inputs, existingPacks, existingMods, serverGenerators, clientGenerators, devToolGenerators, reportsGenerator, structureValidator, flat, null, null); - } - public static void begin(final Set mods, final Path path, final Collection inputs, Collection existingPacks, Set existingMods, final boolean serverGenerators, final boolean clientGenerators, final boolean devToolGenerators, final boolean reportsGenerator, final boolean structureValidator, final boolean flat, final String assetIndex, final File assetsDir) { if (mods.contains("minecraft") && mods.size() == 1) return; LOGGER.info("Initializing Data Gatherer for mods {}", mods); diff --git a/src/main/java/net/minecraftforge/fml/FMLWorldPersistenceHook.java b/src/main/java/net/minecraftforge/fmllegacy/FMLWorldPersistenceHook.java similarity index 83% rename from src/main/java/net/minecraftforge/fml/FMLWorldPersistenceHook.java rename to src/main/java/net/minecraftforge/fmllegacy/FMLWorldPersistenceHook.java index cbfa2fa5c9..bd32265bd4 100644 --- a/src/main/java/net/minecraftforge/fml/FMLWorldPersistenceHook.java +++ b/src/main/java/net/minecraftforge/fmllegacy/FMLWorldPersistenceHook.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml; +package net.minecraftforge.fmllegacy; import java.util.HashMap; import java.util.Map; @@ -25,11 +25,13 @@ import java.util.Objects; import java.util.Optional; import com.google.common.collect.Multimap; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.ListNBT; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.storage.IServerConfiguration; -import net.minecraft.world.storage.SaveFormat; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.storage.WorldData; +import net.minecraft.world.level.storage.LevelStorageSource; +import net.minecraftforge.fml.ModContainer; +import net.minecraftforge.fml.ModList; import net.minecraftforge.registries.ForgeRegistry; import net.minecraftforge.registries.GameData; import net.minecraftforge.registries.RegistryManager; @@ -56,20 +58,20 @@ public final class FMLWorldPersistenceHook implements WorldPersistenceHooks.Worl } @Override - public CompoundNBT getDataForWriting(SaveFormat.LevelSave levelSave, IServerConfiguration serverInfo) + public CompoundTag getDataForWriting(LevelStorageSource.LevelStorageAccess levelSave, WorldData serverInfo) { - CompoundNBT fmlData = new CompoundNBT(); - ListNBT modList = new ListNBT(); + CompoundTag fmlData = new CompoundTag(); + ListTag modList = new ListTag(); ModList.get().getMods().forEach(mi-> { - final CompoundNBT mod = new CompoundNBT(); + final CompoundTag mod = new CompoundTag(); mod.putString("ModId", mi.getModId()); mod.putString("ModVersion", MavenVersionStringHelper.artifactVersionToString(mi.getVersion())); modList.add(mod); }); fmlData.put("LoadingModList", modList); - CompoundNBT registries = new CompoundNBT(); + CompoundTag registries = new CompoundTag(); fmlData.put("Registries", registries); LOGGER.debug(WORLDPERSISTENCE,"Gathering id map for writing to world save {}", serverInfo.getLevelName()); @@ -82,14 +84,14 @@ public final class FMLWorldPersistenceHook implements WorldPersistenceHooks.Worl } @Override - public void readData(SaveFormat.LevelSave levelSave, IServerConfiguration serverInfo, CompoundNBT tag) + public void readData(LevelStorageSource.LevelStorageAccess levelSave, WorldData serverInfo, CompoundTag tag) { if (tag.contains("LoadingModList")) { - ListNBT modList = tag.getList("LoadingModList", (byte)10); + ListTag modList = tag.getList("LoadingModList", (byte)10); for (int i = 0; i < modList.size(); i++) { - CompoundNBT mod = modList.getCompound(i); + CompoundTag mod = modList.getCompound(i); String modId = mod.getString("ModId"); if (Objects.equals("minecraft", modId)) { continue; @@ -113,7 +115,7 @@ public final class FMLWorldPersistenceHook implements WorldPersistenceHooks.Worl if (tag.contains("Registries")) // 1.8, genericed out the 'registries' list { Map snapshot = new HashMap<>(); - CompoundNBT regs = tag.getCompound("Registries"); + CompoundTag regs = tag.getCompound("Registries"); for (String key : regs.getAllKeys()) { snapshot.put(new ResourceLocation(key), ForgeRegistry.Snapshot.read(regs.getCompound(key))); diff --git a/src/main/java/net/minecraftforge/fmllegacy/ForgeBindings.java b/src/main/java/net/minecraftforge/fmllegacy/ForgeBindings.java new file mode 100644 index 0000000000..f21c4a3b9f --- /dev/null +++ b/src/main/java/net/minecraftforge/fmllegacy/ForgeBindings.java @@ -0,0 +1,59 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.fmllegacy; + +import net.minecraftforge.common.MinecraftForge; +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 ForgeBindings implements IBindingsProvider { + @Override + public Supplier getForgeBusSupplier() { + return ()-> MinecraftForge.EVENT_BUS; + } + + @Override + public Supplier getMessageParser() { + return ()->new I18NParser() { + @Override + public String parseMessage(final String i18nMessage, final Object... args) { + return ForgeI18n.parseMessage(i18nMessage, args); + } + + @Override + public String stripControlCodes(final String toStrip) { + return ForgeI18n.stripControlCodes(toStrip); + } + }; + } + + @Override + public Supplier getConfigConfiguration() { + return ()->new IConfigEvent.ConfigConfig(ModConfigEvent.Loading::new, ModConfigEvent.Reloading::new); + } +} diff --git a/src/main/java/net/minecraftforge/fml/ForgeI18n.java b/src/main/java/net/minecraftforge/fmllegacy/ForgeI18n.java similarity index 98% rename from src/main/java/net/minecraftforge/fml/ForgeI18n.java rename to src/main/java/net/minecraftforge/fmllegacy/ForgeI18n.java index 60f4756437..97a33f9469 100644 --- a/src/main/java/net/minecraftforge/fml/ForgeI18n.java +++ b/src/main/java/net/minecraftforge/fmllegacy/ForgeI18n.java @@ -17,11 +17,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml; +package net.minecraftforge.fmllegacy; import com.google.common.base.CharMatcher; import net.minecraftforge.fml.loading.StringUtils; -import net.minecraftforge.fml.loading.moddiscovery.ModInfo; +import net.minecraftforge.forgespi.language.IModInfo; import org.apache.commons.lang3.text.ExtendedMessageFormat; import org.apache.commons.lang3.text.FormatFactory; import org.apache.logging.log4j.LogManager; @@ -79,7 +79,7 @@ public class ForgeI18n { } private static void parseModInfo(final String formatString, final StringBuffer stringBuffer, final Object modInfo) { - final ModInfo info = (ModInfo) modInfo; + final IModInfo info = (IModInfo) modInfo; if (Objects.equals(formatString, "id")) { stringBuffer.append(info.getModId()); } else if (Objects.equals(formatString, "name")) { diff --git a/src/main/java/net/minecraftforge/fmllegacy/ForgeStatesProvider.java b/src/main/java/net/minecraftforge/fmllegacy/ForgeStatesProvider.java new file mode 100644 index 0000000000..2b1e9686d8 --- /dev/null +++ b/src/main/java/net/minecraftforge/fmllegacy/ForgeStatesProvider.java @@ -0,0 +1,60 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.fmllegacy; + +import net.minecraftforge.common.capabilities.CapabilityManager; +import net.minecraftforge.event.RegistryEvent; +import net.minecraftforge.fml.*; +import net.minecraftforge.fmllegacy.network.NetworkRegistry; +import net.minecraftforge.registries.GameData; +import net.minecraftforge.registries.ObjectHolderRegistry; + +import java.util.List; +import java.util.stream.Stream; + +/* + dispatchAndHandleError(ModLoadingStage.CONSTRUCT, syncExecutor, parallelExecutor, periodicTask); + statusConsumer.ifPresent(c->c.accept("Creating registries")); + dispatchAndHandleError(ModLoadingStage.CREATE_REGISTRIES, syncExecutor, parallelExecutor, periodicTask); + ObjectHolderRegistry.findObjectHolders(); + CapabilityManager.INSTANCE.injectCapabilities(modList.getAllScanData()); + statusConsumer.ifPresent(c->c.accept("Adding custom tag types")); + GameData.setCustomTagTypesFromRegistries(); + statusConsumer.ifPresent(c->c.accept("Populating registries")); + dispatchAndHandleError(ModLoadingStage.LOAD_REGISTRIES, syncExecutor, parallelExecutor, periodicTask); + statusConsumer.ifPresent(c->c.accept("Early mod loading complete")); + + statusConsumer.ifPresent(c->c.accept("Freezing data")); + GameData.freezeData(); + NetworkRegistry.lock(); +*/ +public class ForgeStatesProvider implements IModStateProvider { + final ModLoadingState CREATE_REGISTRIES = ModLoadingState.withTransition("CREATE_REGISTRIES", "CONSTRUCT", ModLoadingPhase.GATHER, SerialTransition.of(()-> Stream.of(IModStateTransition.EventGenerator.fromFunction(RegistryEvent.NewRegistry::new)))); + final ModLoadingState OBJECT_HOLDERS = ModLoadingState.withInline("OBJECT_HOLDERS", "CREATE_REGISTRIES", ModLoadingPhase.GATHER, ml-> ObjectHolderRegistry.findObjectHolders()); + final ModLoadingState INJECT_CAPABILITIES = ModLoadingState.withInline("INJECT_CAPABILITIES", "OBJECT_HOLDERS", ModLoadingPhase.GATHER, ml-> CapabilityManager.INSTANCE.injectCapabilities(ml.getAllScanData())); + final ModLoadingState CUSTOM_TAGS = ModLoadingState.withInline("CUSTOM_TAGS", "INJECT_CAPABILITIES", ModLoadingPhase.GATHER, ml-> GameData.setCustomTagTypesFromRegistries()); + final ModLoadingState LOAD_REGISTRIES = ModLoadingState.withTransition("LOAD_REGISTRIES", "CUSTOM_TAGS", ModLoadingPhase.GATHER, new SerialTransition>(GameData::generateRegistryEvents, GameData::preRegistryEventDispatch, GameData::postRegistryEventDispatch, GameData::checkForRevertToVanilla)); + final ModLoadingState FREEZE = ModLoadingState.withInline("FREEZE_DATA", "COMPLETE", ModLoadingPhase.COMPLETE, ml->GameData.freezeData()); + final ModLoadingState NETLOCK = ModLoadingState.withInline("NETWORK_LOCK", "FREEZE_DATA", ModLoadingPhase.COMPLETE, ml-> NetworkRegistry.lock()); + @Override + public List getAllStates() { + return List.of(CREATE_REGISTRIES, OBJECT_HOLDERS, INJECT_CAPABILITIES, CUSTOM_TAGS, LOAD_REGISTRIES, FREEZE, NETLOCK); + } +} diff --git a/src/main/java/net/minecraftforge/fml/LogicalSidedProvider.java b/src/main/java/net/minecraftforge/fmllegacy/LogicalSidedProvider.java similarity index 90% rename from src/main/java/net/minecraftforge/fml/LogicalSidedProvider.java rename to src/main/java/net/minecraftforge/fmllegacy/LogicalSidedProvider.java index d3f84c1724..fb85eaea1a 100644 --- a/src/main/java/net/minecraftforge/fml/LogicalSidedProvider.java +++ b/src/main/java/net/minecraftforge/fmllegacy/LogicalSidedProvider.java @@ -17,11 +17,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml; +package net.minecraftforge.fmllegacy; import net.minecraft.client.Minecraft; import net.minecraft.server.MinecraftServer; -import net.minecraft.world.World; +import net.minecraft.world.level.Level; +import net.minecraftforge.fml.LogicalSide; import java.util.Optional; import java.util.function.Function; @@ -31,7 +32,7 @@ public enum LogicalSidedProvider { WORKQUEUE((c)->c.get(), (s)->s.get()), INSTANCE((c)->c.get(), (s)->s.get()), - CLIENTWORLD((c)-> Optional.of(c.get().level), (s)->Optional.empty()) + CLIENTWORLD((c)-> Optional.of(c.get().level), (s)->Optional.empty()) ; private static Supplier client; private static Supplier server; diff --git a/src/main/java/net/minecraftforge/fml/MavenVersionStringHelper.java b/src/main/java/net/minecraftforge/fmllegacy/MavenVersionStringHelper.java similarity index 99% rename from src/main/java/net/minecraftforge/fml/MavenVersionStringHelper.java rename to src/main/java/net/minecraftforge/fmllegacy/MavenVersionStringHelper.java index 783febd4a1..d44271a9f9 100644 --- a/src/main/java/net/minecraftforge/fml/MavenVersionStringHelper.java +++ b/src/main/java/net/minecraftforge/fmllegacy/MavenVersionStringHelper.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml; +package net.minecraftforge.fmllegacy; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.Restriction; diff --git a/src/main/java/net/minecraftforge/fml/relauncher/libraries/MemoryModList.java b/src/main/java/net/minecraftforge/fmllegacy/NoVizFallback.java similarity index 63% rename from src/main/java/net/minecraftforge/fml/relauncher/libraries/MemoryModList.java rename to src/main/java/net/minecraftforge/fmllegacy/NoVizFallback.java index 7701be3878..cb27cd715e 100644 --- a/src/main/java/net/minecraftforge/fml/relauncher/libraries/MemoryModList.java +++ b/src/main/java/net/minecraftforge/fmllegacy/NoVizFallback.java @@ -17,23 +17,14 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.relauncher.libraries; +package net.minecraftforge.fmllegacy; -import java.io.IOException; +import java.util.function.IntSupplier; +import java.util.function.LongSupplier; +import java.util.function.Supplier; -public class MemoryModList extends ModList -{ - MemoryModList(Repository repo) - { - super(repo); - } - - @Override - public void save() throws IOException {} - - @Override - public String getName() - { - return "MEMORY"; +public final class NoVizFallback { + public static LongSupplier fallback(IntSupplier width, IntSupplier height, Supplier title, LongSupplier monitor) { + return ()->org.lwjgl.glfw.GLFW.glfwCreateWindow(width.getAsInt(), height.getAsInt(), title.get(), monitor.getAsLong(), 0L); } } diff --git a/src/main/java/net/minecraftforge/fml/RegistryObject.java b/src/main/java/net/minecraftforge/fmllegacy/RegistryObject.java similarity index 99% rename from src/main/java/net/minecraftforge/fml/RegistryObject.java rename to src/main/java/net/minecraftforge/fmllegacy/RegistryObject.java index 67eff542e9..5e05e66363 100644 --- a/src/main/java/net/minecraftforge/fml/RegistryObject.java +++ b/src/main/java/net/minecraftforge/fmllegacy/RegistryObject.java @@ -17,9 +17,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml; +package net.minecraftforge.fmllegacy; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.registries.IForgeRegistry; import net.minecraftforge.registries.IForgeRegistryEntry; import net.minecraftforge.registries.ObjectHolderRegistry; diff --git a/src/main/java/net/minecraftforge/fmllegacy/SerialTransition.java b/src/main/java/net/minecraftforge/fmllegacy/SerialTransition.java new file mode 100644 index 0000000000..4496a3d6bb --- /dev/null +++ b/src/main/java/net/minecraftforge/fmllegacy/SerialTransition.java @@ -0,0 +1,56 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.fmllegacy; + +import net.minecraftforge.eventbus.api.Event; +import net.minecraftforge.fml.IModStateTransition; +import net.minecraftforge.fml.ModLoadingStage; +import net.minecraftforge.fml.ThreadSelector; +import net.minecraftforge.fml.event.IModBusEvent; + +import java.util.Collections; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Executor; +import java.util.function.BiFunction; +import java.util.function.Function; +import java.util.function.Supplier; +import java.util.stream.Stream; + +record SerialTransition(Supplier>> eventStream, BiFunction, CompletableFuture>> preDispatchHook, BiFunction, CompletableFuture>> postDispatchHook, BiFunction>, CompletableFuture>> finalActivityGenerator) implements IModStateTransition { + public static SerialTransition of(Supplier>> eventStream) { + return new SerialTransition(eventStream, (t,f)->CompletableFuture.completedFuture(Collections.emptyList()), (t, f)->CompletableFuture.completedFuture(Collections.emptyList()), (e, prev) ->prev.thenApplyAsync(Function.identity(), e)); + } + @Override + public Supplier>> eventFunctionStream() { + return eventStream; + } + + @Override + public ThreadSelector threadSelector() { + return ThreadSelector.SYNC; + } + + // These never progress the ModLoadingStage.. + @Override + public BiFunction nextModLoadingStage() { + return ModLoadingStage::currentState; + } +} diff --git a/src/main/java/net/minecraftforge/fml/TextComponentMessageFormatHandler.java b/src/main/java/net/minecraftforge/fmllegacy/TextComponentMessageFormatHandler.java similarity index 69% rename from src/main/java/net/minecraftforge/fml/TextComponentMessageFormatHandler.java rename to src/main/java/net/minecraftforge/fmllegacy/TextComponentMessageFormatHandler.java index a0baeb7f33..2bf2c35b65 100644 --- a/src/main/java/net/minecraftforge/fml/TextComponentMessageFormatHandler.java +++ b/src/main/java/net/minecraftforge/fmllegacy/TextComponentMessageFormatHandler.java @@ -17,18 +17,18 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml; +package net.minecraftforge.fmllegacy; -import net.minecraft.util.text.ITextProperties; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.network.chat.FormattedText; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.network.chat.TranslatableComponent; import java.util.List; public class TextComponentMessageFormatHandler { - public static int handle(final TranslationTextComponent parent, final List children, final Object[] formatArgs, final String format) { + public static int handle(final TranslatableComponent parent, final List children, final Object[] formatArgs, final String format) { try { - StringTextComponent component = new StringTextComponent(ForgeI18n.parseFormat(format, formatArgs)); + TextComponent component = new TextComponent(ForgeI18n.parseFormat(format, formatArgs)); component.getStyle().applyTo(parent.getStyle()); children.add(component); return format.length(); diff --git a/src/main/java/net/minecraftforge/fml/WorldPersistenceHooks.java b/src/main/java/net/minecraftforge/fmllegacy/WorldPersistenceHooks.java similarity index 65% rename from src/main/java/net/minecraftforge/fml/WorldPersistenceHooks.java rename to src/main/java/net/minecraftforge/fmllegacy/WorldPersistenceHooks.java index 4e5054d0a4..371fa7b636 100644 --- a/src/main/java/net/minecraftforge/fml/WorldPersistenceHooks.java +++ b/src/main/java/net/minecraftforge/fmllegacy/WorldPersistenceHooks.java @@ -17,12 +17,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml; +package net.minecraftforge.fmllegacy; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.world.storage.IServerConfiguration; -import net.minecraft.world.storage.SaveFormat; -import net.minecraftforge.fml.common.thread.EffectiveSide; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.storage.WorldData; +import net.minecraft.world.level.storage.LevelStorageSource; import java.util.ArrayList; import java.util.List; @@ -35,12 +34,12 @@ public class WorldPersistenceHooks worldPersistenceHooks.add(hook); } - public static void handleWorldDataSave(final SaveFormat.LevelSave levelSave, final IServerConfiguration serverInfo, final CompoundNBT tagCompound) + public static void handleWorldDataSave(final LevelStorageSource.LevelStorageAccess levelSave, final WorldData serverInfo, final CompoundTag tagCompound) { worldPersistenceHooks.forEach(wac->tagCompound.put(wac.getModId(), wac.getDataForWriting(levelSave, serverInfo))); } - public static void handleWorldDataLoad(SaveFormat.LevelSave levelSave, IServerConfiguration serverInfo, CompoundNBT tagCompound) + public static void handleWorldDataLoad(LevelStorageSource.LevelStorageAccess levelSave, WorldData serverInfo, CompoundTag tagCompound) { worldPersistenceHooks.forEach(wac->wac.readData(levelSave, serverInfo, tagCompound.getCompound(wac.getModId()))); } @@ -48,7 +47,7 @@ public class WorldPersistenceHooks public interface WorldPersistenceHook { String getModId(); - CompoundNBT getDataForWriting(SaveFormat.LevelSave levelSave, IServerConfiguration serverInfo); - void readData(SaveFormat.LevelSave levelSave, IServerConfiguration serverInfo, CompoundNBT tag); + CompoundTag getDataForWriting(LevelStorageSource.LevelStorageAccess levelSave, WorldData serverInfo); + void readData(LevelStorageSource.LevelStorageAccess levelSave, WorldData serverInfo, CompoundTag tag); } } diff --git a/src/main/java/net/minecraftforge/fml/common/network/ByteBufUtils.java b/src/main/java/net/minecraftforge/fmllegacy/common/network/ByteBufUtils.java similarity index 98% rename from src/main/java/net/minecraftforge/fml/common/network/ByteBufUtils.java rename to src/main/java/net/minecraftforge/fmllegacy/common/network/ByteBufUtils.java index 950815bc21..903516a5a6 100644 --- a/src/main/java/net/minecraftforge/fml/common/network/ByteBufUtils.java +++ b/src/main/java/net/minecraftforge/fmllegacy/common/network/ByteBufUtils.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.common.network; +package net.minecraftforge.fmllegacy.common.network; import io.netty.buffer.ByteBuf; diff --git a/src/main/java/net/minecraftforge/fml/common/network/PacketLoggingHandler.java b/src/main/java/net/minecraftforge/fmllegacy/common/network/PacketLoggingHandler.java similarity index 69% rename from src/main/java/net/minecraftforge/fml/common/network/PacketLoggingHandler.java rename to src/main/java/net/minecraftforge/fmllegacy/common/network/PacketLoggingHandler.java index b3dfd95023..f080df015f 100644 --- a/src/main/java/net/minecraftforge/fml/common/network/PacketLoggingHandler.java +++ b/src/main/java/net/minecraftforge/fmllegacy/common/network/PacketLoggingHandler.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.common.network; +package net.minecraftforge.fmllegacy.common.network; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; @@ -31,31 +31,31 @@ import java.util.Iterator; import java.util.List; -import net.minecraft.network.PacketDirection; -import net.minecraft.network.NettyVarint21FrameDecoder; -import net.minecraft.network.NettyVarint21FrameEncoder; -import net.minecraft.network.NetworkManager; -import net.minecraft.network.IPacket; -import net.minecraft.network.PacketBuffer; +import net.minecraft.network.protocol.PacketFlow; +import net.minecraft.network.Varint21FrameDecoder; +import net.minecraft.network.Varint21LengthFieldPrepender; +import net.minecraft.network.Connection; +import net.minecraft.network.protocol.Packet; +import net.minecraft.network.FriendlyByteBuf; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; public class PacketLoggingHandler { private static final Logger LOGGER = LogManager.getLogger(); - public static void register(NetworkManager manager) + public static void register(Connection manager) { ChannelPipeline pipeline = manager.channel().pipeline(); - final PacketDirection direction = manager.getDirection(); + final PacketFlow direction = manager.getDirection(); if (manager.isMemoryConnection()) { - pipeline.addBefore("packet_handler", "splitter", new SimpleChannelInboundHandler>() + pipeline.addBefore("packet_handler", "splitter", new SimpleChannelInboundHandler>() { - String prefix = (direction == PacketDirection.SERVERBOUND ? "SERVER: C->S" : "CLIENT: S->C"); + String prefix = (direction == PacketFlow.SERVERBOUND ? "SERVER: C->S" : "CLIENT: S->C"); @Override - protected void channelRead0(ChannelHandlerContext ctx, IPacket msg) throws Exception + protected void channelRead0(ChannelHandlerContext ctx, Packet msg) throws Exception { - PacketBuffer buf = new PacketBuffer(Unpooled.buffer()); + FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.buffer()); msg.write(buf); LOGGER.debug("{} {}:\n{}", prefix, msg.getClass().getSimpleName(), ByteBufUtils.getContentDump(buf)); ctx.fireChannelRead(msg); @@ -63,14 +63,14 @@ public class PacketLoggingHandler }); pipeline.addBefore("splitter", "prepender", new ChannelOutboundHandlerAdapter() { - String prefix = (direction == PacketDirection.SERVERBOUND ? "SERVER: S->C" : "CLIENT: C->S"); + String prefix = (direction == PacketFlow.SERVERBOUND ? "SERVER: S->C" : "CLIENT: C->S"); @Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { - if (msg instanceof IPacket) + if (msg instanceof Packet) { - PacketBuffer buf = new PacketBuffer(Unpooled.buffer()); - ((IPacket)msg).write(buf); + FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.buffer()); + ((Packet)msg).write(buf); LOGGER.debug("{} {}:\n{}", prefix, msg.getClass().getSimpleName(), ByteBufUtils.getContentDump(buf)); } ctx.write(msg, promise); @@ -79,11 +79,11 @@ public class PacketLoggingHandler } else { - pipeline.replace("splitter", "splitter", new NettyVarint21FrameDecoder() + pipeline.replace("splitter", "splitter", new Varint21FrameDecoder() { - String prefix = (direction == PacketDirection.SERVERBOUND ? "SERVER: C->S" : "CLIENT: S->C"); + String prefix = (direction == PacketFlow.SERVERBOUND ? "SERVER: C->S" : "CLIENT: S->C"); @Override - protected void decode(ChannelHandlerContext context, ByteBuf input, List output) throws Exception + protected void decode(ChannelHandlerContext context, ByteBuf input, List output) { super.decode(context, input, output); Iterator itr = output.iterator(); @@ -96,11 +96,11 @@ public class PacketLoggingHandler } } }); - pipeline.replace("prepender", "prepender", new NettyVarint21FrameEncoder() + pipeline.replace("prepender", "prepender", new Varint21LengthFieldPrepender() { - String prefix = (direction == PacketDirection.SERVERBOUND ? "SERVER: S->C" : "CLIENT: C->S"); + String prefix = (direction == PacketFlow.SERVERBOUND ? "SERVER: S->C" : "CLIENT: C->S"); @Override - protected void encode(ChannelHandlerContext context, ByteBuf input, ByteBuf output) throws Exception + protected void encode(ChannelHandlerContext context, ByteBuf input, ByteBuf output) { input.markReaderIndex(); LOGGER.debug("{}:\n{}", prefix, ByteBufUtils.getContentDump(input)); diff --git a/src/main/java/net/minecraftforge/fml/common/registry/GameRegistry.java b/src/main/java/net/minecraftforge/fmllegacy/common/registry/GameRegistry.java similarity index 96% rename from src/main/java/net/minecraftforge/fml/common/registry/GameRegistry.java rename to src/main/java/net/minecraftforge/fmllegacy/common/registry/GameRegistry.java index e6c802bb84..2f8f24330e 100644 --- a/src/main/java/net/minecraftforge/fml/common/registry/GameRegistry.java +++ b/src/main/java/net/minecraftforge/fmllegacy/common/registry/GameRegistry.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.common.registry; +package net.minecraftforge.fmllegacy.common.registry; import net.minecraftforge.registries.IForgeRegistry; import net.minecraftforge.registries.IForgeRegistryEntry; diff --git a/src/main/java/net/minecraftforge/fml/common/registry/IEntityAdditionalSpawnData.java b/src/main/java/net/minecraftforge/fmllegacy/common/registry/IEntityAdditionalSpawnData.java similarity index 86% rename from src/main/java/net/minecraftforge/fml/common/registry/IEntityAdditionalSpawnData.java rename to src/main/java/net/minecraftforge/fmllegacy/common/registry/IEntityAdditionalSpawnData.java index 91f1b141b2..9baa02aea5 100644 --- a/src/main/java/net/minecraftforge/fml/common/registry/IEntityAdditionalSpawnData.java +++ b/src/main/java/net/minecraftforge/fmllegacy/common/registry/IEntityAdditionalSpawnData.java @@ -17,9 +17,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.common.registry; +package net.minecraftforge.fmllegacy.common.registry; -import net.minecraft.network.PacketBuffer; +import net.minecraft.network.FriendlyByteBuf; /** * A interface for Entities that need extra information to be communicated @@ -33,7 +33,7 @@ public interface IEntityAdditionalSpawnData * * @param buffer The packet data stream */ - void writeSpawnData(PacketBuffer buffer); + void writeSpawnData(FriendlyByteBuf buffer); /** * Called by the client when it receives a Entity spawn packet. @@ -41,5 +41,5 @@ public interface IEntityAdditionalSpawnData * * @param additionalData The packet data stream */ - void readSpawnData(PacketBuffer additionalData); + void readSpawnData(FriendlyByteBuf additionalData); } diff --git a/src/main/java/net/minecraftforge/fml/event/lifecycle/FMLModIdMappingEvent.java b/src/main/java/net/minecraftforge/fmllegacy/event/lifecycle/FMLModIdMappingEvent.java similarity index 94% rename from src/main/java/net/minecraftforge/fml/event/lifecycle/FMLModIdMappingEvent.java rename to src/main/java/net/minecraftforge/fmllegacy/event/lifecycle/FMLModIdMappingEvent.java index e277fca926..37b8408688 100644 --- a/src/main/java/net/minecraftforge/fml/event/lifecycle/FMLModIdMappingEvent.java +++ b/src/main/java/net/minecraftforge/fmllegacy/event/lifecycle/FMLModIdMappingEvent.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.event.lifecycle; +package net.minecraftforge.fmllegacy.event.lifecycle; import java.util.Comparator; import java.util.List; @@ -27,7 +27,8 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; +import net.minecraftforge.fml.event.lifecycle.ModLifecycleEvent; /** * Called whenever the ID mapping might have changed. If you register for this event, you diff --git a/src/main/java/net/minecraftforge/fml/hooks/BasicEventHooks.java b/src/main/java/net/minecraftforge/fmllegacy/hooks/BasicEventHooks.java similarity index 73% rename from src/main/java/net/minecraftforge/fml/hooks/BasicEventHooks.java rename to src/main/java/net/minecraftforge/fmllegacy/hooks/BasicEventHooks.java index fb95cbd58e..5411dc6cca 100644 --- a/src/main/java/net/minecraftforge/fml/hooks/BasicEventHooks.java +++ b/src/main/java/net/minecraftforge/fmllegacy/hooks/BasicEventHooks.java @@ -17,14 +17,14 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.hooks; +package net.minecraftforge.fmllegacy.hooks; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.util.RegistryKey; -import net.minecraft.world.World; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.Container; +import net.minecraft.world.item.ItemStack; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.level.Level; import net.minecraftforge.client.model.animation.Animation; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.PlayerEvent; @@ -34,37 +34,37 @@ import net.minecraftforge.event.TickEvent; public class BasicEventHooks { - public static void firePlayerChangedDimensionEvent(PlayerEntity player, RegistryKey fromDim, RegistryKey toDim) + public static void firePlayerChangedDimensionEvent(Player player, ResourceKey fromDim, ResourceKey toDim) { MinecraftForge.EVENT_BUS.post(new PlayerEvent.PlayerChangedDimensionEvent(player, fromDim, toDim)); } - public static void firePlayerLoggedIn(PlayerEntity player) + public static void firePlayerLoggedIn(Player player) { MinecraftForge.EVENT_BUS.post(new PlayerEvent.PlayerLoggedInEvent(player)); } - public static void firePlayerLoggedOut(PlayerEntity player) + public static void firePlayerLoggedOut(Player player) { MinecraftForge.EVENT_BUS.post(new PlayerEvent.PlayerLoggedOutEvent(player)); } - public static void firePlayerRespawnEvent(PlayerEntity player, boolean endConquered) + public static void firePlayerRespawnEvent(Player player, boolean endConquered) { MinecraftForge.EVENT_BUS.post(new PlayerEvent.PlayerRespawnEvent(player, endConquered)); } - public static void firePlayerItemPickupEvent(PlayerEntity player, ItemEntity item, ItemStack clone) + public static void firePlayerItemPickupEvent(Player player, ItemEntity item, ItemStack clone) { MinecraftForge.EVENT_BUS.post(new PlayerEvent.ItemPickupEvent(player, item, clone)); } - public static void firePlayerCraftingEvent(PlayerEntity player, ItemStack crafted, IInventory craftMatrix) + public static void firePlayerCraftingEvent(Player player, ItemStack crafted, Container craftMatrix) { MinecraftForge.EVENT_BUS.post(new PlayerEvent.ItemCraftedEvent(player, crafted, craftMatrix)); } - public static void firePlayerSmeltedEvent(PlayerEntity player, ItemStack smelted) + public static void firePlayerSmeltedEvent(Player player, ItemStack smelted) { MinecraftForge.EVENT_BUS.post(new PlayerEvent.ItemSmeltedEvent(player, smelted)); } @@ -80,22 +80,22 @@ public class BasicEventHooks MinecraftForge.EVENT_BUS.post(new TickEvent.RenderTickEvent(TickEvent.Phase.END, timer)); } - public static void onPlayerPreTick(PlayerEntity player) + public static void onPlayerPreTick(Player player) { MinecraftForge.EVENT_BUS.post(new TickEvent.PlayerTickEvent(TickEvent.Phase.START, player)); } - public static void onPlayerPostTick(PlayerEntity player) + public static void onPlayerPostTick(Player player) { MinecraftForge.EVENT_BUS.post(new TickEvent.PlayerTickEvent(TickEvent.Phase.END, player)); } - public static void onPreWorldTick(World world) + public static void onPreWorldTick(Level world) { MinecraftForge.EVENT_BUS.post(new TickEvent.WorldTickEvent(LogicalSide.SERVER, TickEvent.Phase.START, world)); } - public static void onPostWorldTick(World world) + public static void onPostWorldTick(Level world) { MinecraftForge.EVENT_BUS.post(new TickEvent.WorldTickEvent(LogicalSide.SERVER, TickEvent.Phase.END, world)); } diff --git a/src/main/java/net/minecraftforge/fmllegacy/network/ConfigSync.java b/src/main/java/net/minecraftforge/fmllegacy/network/ConfigSync.java new file mode 100644 index 0000000000..6099046297 --- /dev/null +++ b/src/main/java/net/minecraftforge/fmllegacy/network/ConfigSync.java @@ -0,0 +1,59 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.fmllegacy.network; + +import net.minecraft.client.Minecraft; +import net.minecraftforge.fml.config.ConfigTracker; +import net.minecraftforge.fml.config.ModConfig; +import org.apache.commons.lang3.tuple.Pair; + +import java.io.IOException; +import java.nio.file.Files; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.function.Supplier; +import java.util.stream.Collectors; + +public class ConfigSync { + public static final ConfigSync INSTANCE = new ConfigSync(ConfigTracker.INSTANCE); + private final ConfigTracker tracker; + + private ConfigSync(final ConfigTracker tracker) { + this.tracker = tracker; + } + + public List> syncConfigs(boolean isLocal) { + final Map configData = tracker.configSets().get(ModConfig.Type.SERVER).stream().collect(Collectors.toMap(ModConfig::getFileName, mc -> { + try { + return Files.readAllBytes(mc.getFullPath()); + } catch (IOException e) { + throw new RuntimeException(e); + } + })); + return configData.entrySet().stream().map(e->Pair.of("Config "+e.getKey(), new FMLHandshakeMessages.S2CConfigData(e.getKey(), e.getValue()))).collect(Collectors.toList()); + } + + public void receiveSyncedConfig(final FMLHandshakeMessages.S2CConfigData s2CConfigData, final Supplier contextSupplier) { + if (!Minecraft.getInstance().isLocalServer()) { + Optional.ofNullable(tracker.fileMap().get(s2CConfigData.getFileName())).ifPresent(mc-> mc.acceptSyncedConfig(s2CConfigData.getBytes())); + } + } +} diff --git a/src/main/java/net/minecraftforge/fml/network/ConnectionType.java b/src/main/java/net/minecraftforge/fmllegacy/network/ConnectionType.java similarity index 96% rename from src/main/java/net/minecraftforge/fml/network/ConnectionType.java rename to src/main/java/net/minecraftforge/fmllegacy/network/ConnectionType.java index cc9b99d516..0d051ad2d3 100644 --- a/src/main/java/net/minecraftforge/fml/network/ConnectionType.java +++ b/src/main/java/net/minecraftforge/fmllegacy/network/ConnectionType.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.network; +package net.minecraftforge.fmllegacy.network; import java.util.function.Function; diff --git a/src/main/java/net/minecraftforge/fml/network/FMLConnectionData.java b/src/main/java/net/minecraftforge/fmllegacy/network/FMLConnectionData.java similarity index 96% rename from src/main/java/net/minecraftforge/fml/network/FMLConnectionData.java rename to src/main/java/net/minecraftforge/fmllegacy/network/FMLConnectionData.java index ac81e79468..955e5a3a3c 100644 --- a/src/main/java/net/minecraftforge/fml/network/FMLConnectionData.java +++ b/src/main/java/net/minecraftforge/fmllegacy/network/FMLConnectionData.java @@ -17,11 +17,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.network; +package net.minecraftforge.fmllegacy.network; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; import java.util.List; import java.util.Map; diff --git a/src/main/java/net/minecraftforge/fml/network/FMLHandshakeHandler.java b/src/main/java/net/minecraftforge/fmllegacy/network/FMLHandshakeHandler.java similarity index 90% rename from src/main/java/net/minecraftforge/fml/network/FMLHandshakeHandler.java rename to src/main/java/net/minecraftforge/fmllegacy/network/FMLHandshakeHandler.java index 65496a72b1..4662e37b40 100644 --- a/src/main/java/net/minecraftforge/fml/network/FMLHandshakeHandler.java +++ b/src/main/java/net/minecraftforge/fmllegacy/network/FMLHandshakeHandler.java @@ -17,18 +17,15 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.network; +package net.minecraftforge.fmllegacy.network; -import net.minecraft.network.login.ServerLoginNetHandler; import com.google.common.collect.Multimap; -import net.minecraft.network.NetworkManager; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.StringTextComponent; -import net.minecraftforge.fml.config.ConfigTracker; -import net.minecraftforge.fml.loading.AdvancedLogMessageAdapter; -import net.minecraftforge.fml.network.simple.SimpleChannel; -import net.minecraftforge.fml.util.ThreeConsumer; +import net.minecraft.network.Connection; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.network.chat.TextComponent; +import net.minecraftforge.common.util.LogMessageAdapter; +import net.minecraftforge.fmllegacy.network.simple.SimpleChannel; +import net.minecraftforge.fmllegacy.util.ThreeConsumer; import net.minecraftforge.registries.ForgeRegistry; import net.minecraftforge.registries.GameData; import org.apache.logging.log4j.LogManager; @@ -63,9 +60,9 @@ import static net.minecraftforge.registries.ForgeRegistry.REGISTRIES; * *

During client to server initiation, on the server, the {@link NetworkEvent.GatherLoginPayloadsEvent} is fired, * which solicits all registered channels at the {@link NetworkRegistry} for any - * {@link net.minecraftforge.fml.network.NetworkRegistry.LoginPayload} they wish to supply. + * {@link NetworkRegistry.LoginPayload} they wish to supply. * - *

The collected {@link net.minecraftforge.fml.network.NetworkRegistry.LoginPayload} are sent, one per tick, via + *

The collected {@link NetworkRegistry.LoginPayload} are sent, one per tick, via * the {@link FMLLoginWrapper#wrapPacket(ResourceLocation, PacketBuffer)} mechanism to the incoming client connection. Each * packet is indexed via {@link net.minecraft.network.login.client.CCustomPayloadLoginPacket#transaction}, which is * the only mechanism available for tracking request/response pairs. @@ -93,11 +90,11 @@ public class FMLHandshakeHandler { * @param manager The network manager for this connection * @param direction The {@link NetworkDirection} for this connection: {@link NetworkDirection#LOGIN_TO_SERVER} or {@link NetworkDirection#LOGIN_TO_CLIENT} */ - static void registerHandshake(NetworkManager manager, NetworkDirection direction) { + static void registerHandshake(Connection manager, NetworkDirection direction) { manager.channel().attr(FMLNetworkConstants.FML_HANDSHAKE_HANDLER).compareAndSet(null, new FMLHandshakeHandler(manager, direction)); } - static boolean tickLogin(NetworkManager networkManager) + static boolean tickLogin(Connection networkManager) { return networkManager.channel().attr(FMLNetworkConstants.FML_HANDSHAKE_HANDLER).get().tickServer(); } @@ -107,13 +104,13 @@ public class FMLHandshakeHandler { private List sentMessages = new ArrayList<>(); private final NetworkDirection direction; - private final NetworkManager manager; + private final Connection manager; private int packetPosition; private Map registrySnapshots; private Set registriesToReceive; private Map registryHashes; - private FMLHandshakeHandler(NetworkManager networkManager, NetworkDirection side) + private FMLHandshakeHandler(Connection networkManager, NetworkDirection side) { this.direction = side; this.manager = networkManager; @@ -176,7 +173,7 @@ public class FMLHandshakeHandler { c.get().setPacketHandled(true); if (!accepted) { LOGGER.error(FMLHSMARKER, "Terminating connection with server, mismatched mod list"); - c.get().getNetworkManager().disconnect(new StringTextComponent("Connection closed - mismatched mod channel list")); + c.get().getNetworkManager().disconnect(new TextComponent("Connection closed - mismatched mod channel list")); return; } FMLNetworkConstants.handshakeChannel.reply(new FMLHandshakeMessages.C2SModListReply(), c.get()); @@ -210,7 +207,7 @@ public class FMLHandshakeHandler { c.get().setPacketHandled(true); if (!accepted) { LOGGER.error(FMLHSMARKER, "Terminating connection with client, mismatched mod list"); - c.get().getNetworkManager().disconnect(new StringTextComponent("Connection closed - mismatched mod channel list")); + c.get().getNetworkManager().disconnect(new TextComponent("Connection closed - mismatched mod channel list")); return; } LOGGER.debug(FMLHSMARKER, "Accepted client connection mod list"); @@ -243,7 +240,7 @@ public class FMLHandshakeHandler { final Multimap missingData = GameData.injectSnapshot(registrySnapshots, false, false); LOGGER.debug(FMLHSMARKER, "Snapshot injected."); if (!missingData.isEmpty()) { - LOGGER.error(FMLHSMARKER, "Missing registry data for network connection:\n{}", new AdvancedLogMessageAdapter(sb-> + LOGGER.error(FMLHSMARKER, "Missing registry data for network connection:\n{}", LogMessageAdapter.adapt(sb-> missingData.forEach((reg, entry)-> sb.append("\t").append(reg).append(": ").append(entry).append('\n')))); } successfulConnection.set(missingData.isEmpty()); @@ -259,7 +256,7 @@ public class FMLHandshakeHandler { LOGGER.debug(FMLHSMARKER, "Registry load complete, continuing handshake."); } else { LOGGER.error(FMLHSMARKER, "Failed to load registry, closing connection."); - this.manager.disconnect(new StringTextComponent("Failed to synchronize registry data from server, closing connection")); + this.manager.disconnect(new TextComponent("Failed to synchronize registry data from server, closing connection")); } return successfulConnection.get(); } @@ -271,7 +268,7 @@ public class FMLHandshakeHandler { void handleConfigSync(final FMLHandshakeMessages.S2CConfigData msg, final Supplier contextSupplier) { LOGGER.debug(FMLHSMARKER, "Received config sync from server"); - ConfigTracker.INSTANCE.receiveSyncedConfig(msg, contextSupplier); + ConfigSync.INSTANCE.receiveSyncedConfig(msg, contextSupplier); contextSupplier.get().setPacketHandled(true); FMLNetworkConstants.handshakeChannel.reply(new FMLHandshakeMessages.C2SAcknowledge(), contextSupplier.get()); } diff --git a/src/main/java/net/minecraftforge/fml/network/FMLHandshakeMessages.java b/src/main/java/net/minecraftforge/fmllegacy/network/FMLHandshakeMessages.java similarity index 88% rename from src/main/java/net/minecraftforge/fml/network/FMLHandshakeMessages.java rename to src/main/java/net/minecraftforge/fmllegacy/network/FMLHandshakeMessages.java index ee238e5d2e..71446cbb7d 100644 --- a/src/main/java/net/minecraftforge/fml/network/FMLHandshakeMessages.java +++ b/src/main/java/net/minecraftforge/fmllegacy/network/FMLHandshakeMessages.java @@ -17,12 +17,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.network; +package net.minecraftforge.fmllegacy.network; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.ResourceLocation; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.fml.ModList; -import net.minecraftforge.fml.loading.moddiscovery.ModInfo; +import net.minecraftforge.forgespi.language.IModInfo; import net.minecraftforge.registries.ForgeRegistry; import net.minecraftforge.registries.RegistryManager; @@ -31,7 +31,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.function.IntSupplier; -import java.util.function.Supplier; import java.util.stream.Collectors; import javax.annotation.Nullable; @@ -68,7 +67,7 @@ public class FMLHandshakeMessages public S2CModList() { - this.mods = ModList.get().getMods().stream().map(ModInfo::getModId).collect(Collectors.toList()); + this.mods = ModList.get().getMods().stream().map(IModInfo::getModId).collect(Collectors.toList()); this.channels = NetworkRegistry.buildChannelVersions(); this.registries = RegistryManager.getRegistryNamesForSyncToClient(); } @@ -80,7 +79,7 @@ public class FMLHandshakeMessages this.registries = registries; } - public static S2CModList decode(PacketBuffer input) + public static S2CModList decode(FriendlyByteBuf input) { List mods = new ArrayList<>(); int len = input.readVarInt(); @@ -100,7 +99,7 @@ public class FMLHandshakeMessages return new S2CModList(mods, channels, registries); } - public void encode(PacketBuffer output) + public void encode(FriendlyByteBuf output) { output.writeVarInt(mods.size()); mods.forEach(m -> output.writeUtf(m, 0x100)); @@ -136,7 +135,7 @@ public class FMLHandshakeMessages public C2SModListReply() { - this.mods = ModList.get().getMods().stream().map(ModInfo::getModId).collect(Collectors.toList()); + this.mods = ModList.get().getMods().stream().map(IModInfo::getModId).collect(Collectors.toList()); this.channels = NetworkRegistry.buildChannelVersions(); this.registries = Maps.newHashMap(); //TODO: Fill with known hashes, which requires keeping a file cache } @@ -148,7 +147,7 @@ public class FMLHandshakeMessages this.registries = registries; } - public static C2SModListReply decode(PacketBuffer input) + public static C2SModListReply decode(FriendlyByteBuf input) { List mods = new ArrayList<>(); int len = input.readVarInt(); @@ -168,7 +167,7 @@ public class FMLHandshakeMessages return new C2SModListReply(mods, channels, registries); } - public void encode(PacketBuffer output) + public void encode(FriendlyByteBuf output) { output.writeVarInt(mods.size()); mods.forEach(m -> output.writeUtf(m, 0x100)); @@ -200,11 +199,11 @@ public class FMLHandshakeMessages } public static class C2SAcknowledge extends LoginIndexedMessage { - public void encode(PacketBuffer buf) { + public void encode(FriendlyByteBuf buf) { } - public static C2SAcknowledge decode(PacketBuffer buf) { + public static C2SAcknowledge decode(FriendlyByteBuf buf) { return new C2SAcknowledge(); } } @@ -219,14 +218,14 @@ public class FMLHandshakeMessages this.snapshot = snapshot; } - void encode(final PacketBuffer buffer) { + void encode(final FriendlyByteBuf buffer) { buffer.writeResourceLocation(registryName); buffer.writeBoolean(hasSnapshot()); if (hasSnapshot()) buffer.writeBytes(snapshot.getPacketData()); } - public static S2CRegistry decode(final PacketBuffer buffer) { + public static S2CRegistry decode(final FriendlyByteBuf buffer) { ResourceLocation name = buffer.readResourceLocation(); ForgeRegistry.Snapshot snapshot = null; if (buffer.readBoolean()) @@ -258,12 +257,12 @@ public class FMLHandshakeMessages this.fileData = configFileData; } - void encode(final PacketBuffer buffer) { + void encode(final FriendlyByteBuf buffer) { buffer.writeUtf(this.fileName); buffer.writeByteArray(this.fileData); } - public static S2CConfigData decode(final PacketBuffer buffer) { + public static S2CConfigData decode(final FriendlyByteBuf buffer) { return new S2CConfigData(buffer.readUtf(32767), buffer.readByteArray()); } diff --git a/src/main/java/net/minecraftforge/fml/network/FMLLoginWrapper.java b/src/main/java/net/minecraftforge/fmllegacy/network/FMLLoginWrapper.java similarity index 82% rename from src/main/java/net/minecraftforge/fml/network/FMLLoginWrapper.java rename to src/main/java/net/minecraftforge/fmllegacy/network/FMLLoginWrapper.java index 1bfb74c1d9..fc022896b9 100644 --- a/src/main/java/net/minecraftforge/fml/network/FMLLoginWrapper.java +++ b/src/main/java/net/minecraftforge/fmllegacy/network/FMLLoginWrapper.java @@ -17,13 +17,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.network; +package net.minecraftforge.fmllegacy.network; import io.netty.buffer.Unpooled; -import net.minecraft.network.NetworkManager; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.network.event.EventNetworkChannel; +import net.minecraft.network.Connection; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.resources.ResourceLocation; +import net.minecraftforge.fmllegacy.network.event.EventNetworkChannel; import org.apache.commons.lang3.tuple.Pair; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -50,13 +50,13 @@ public class FMLLoginWrapper { // we don't care about channel registration change events on this channel if (packet instanceof NetworkEvent.ChannelRegistrationChangeEvent) return; final NetworkEvent.Context wrappedContext = packet.getSource().get(); - final PacketBuffer payload = packet.getPayload(); + final FriendlyByteBuf payload = packet.getPayload(); ResourceLocation targetNetworkReceiver = FMLNetworkConstants.FML_HANDSHAKE_RESOURCE; - PacketBuffer data = null; + FriendlyByteBuf data = null; if (payload != null) { targetNetworkReceiver = payload.readResourceLocation(); final int payloadLength = payload.readVarInt(); - data = new PacketBuffer(payload.readBytes(payloadLength)); + data = new FriendlyByteBuf(payload.readBytes(payloadLength)); } final int loginSequence = packet.getLoginIndex(); LOGGER.debug(FMLHandshakeHandler.FMLHSMARKER, "Recieved login wrapper packet event for channel {} with index {}", targetNetworkReceiver, loginSequence); @@ -71,16 +71,16 @@ public class FMLLoginWrapper { }); } - private PacketBuffer wrapPacket(final ResourceLocation rl, final PacketBuffer buf) { - PacketBuffer pb = new PacketBuffer(Unpooled.buffer(buf.capacity())); + private FriendlyByteBuf wrapPacket(final ResourceLocation rl, final FriendlyByteBuf buf) { + FriendlyByteBuf pb = new FriendlyByteBuf(Unpooled.buffer(buf.capacity())); pb.writeResourceLocation(rl); pb.writeVarInt(buf.readableBytes()); pb.writeBytes(buf); return pb; } - void sendServerToClientLoginPacket(final ResourceLocation resourceLocation, final PacketBuffer buffer, final int index, final NetworkManager manager) { - PacketBuffer pb = wrapPacket(resourceLocation, buffer); + void sendServerToClientLoginPacket(final ResourceLocation resourceLocation, final FriendlyByteBuf buffer, final int index, final Connection manager) { + FriendlyByteBuf pb = wrapPacket(resourceLocation, buffer); manager.send(NetworkDirection.LOGIN_TO_CLIENT.buildPacket(Pair.of(pb, index), WRAPPER).getThis()); } } diff --git a/src/main/java/net/minecraftforge/fml/network/FMLMCRegisterPacketHandler.java b/src/main/java/net/minecraftforge/fmllegacy/network/FMLMCRegisterPacketHandler.java similarity index 84% rename from src/main/java/net/minecraftforge/fml/network/FMLMCRegisterPacketHandler.java rename to src/main/java/net/minecraftforge/fmllegacy/network/FMLMCRegisterPacketHandler.java index d6de6f3455..7ff8f8e75f 100644 --- a/src/main/java/net/minecraftforge/fml/network/FMLMCRegisterPacketHandler.java +++ b/src/main/java/net/minecraftforge/fmllegacy/network/FMLMCRegisterPacketHandler.java @@ -17,14 +17,14 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.network; +package net.minecraftforge.fmllegacy.network; import io.netty.buffer.Unpooled; import io.netty.util.Attribute; -import net.minecraft.network.IPacket; -import net.minecraft.network.NetworkManager; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.ResourceLocation; +import net.minecraft.network.protocol.Packet; +import net.minecraft.network.Connection; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.resources.ResourceLocation; import org.apache.commons.lang3.tuple.Pair; @@ -42,7 +42,7 @@ public class FMLMCRegisterPacketHandler { public static class ChannelList { private Set locations = new HashSet<>(); - public void updateFrom(final Supplier source, PacketBuffer buffer, final NetworkEvent.RegistrationChangeType changeType) { + public void updateFrom(final Supplier source, FriendlyByteBuf buffer, final NetworkEvent.RegistrationChangeType changeType) { byte[] data = new byte[Math.max(buffer.readableBytes(), 0)]; buffer.readBytes(data); Set oldLocations = this.locations; @@ -83,7 +83,7 @@ public class FMLMCRegisterPacketHandler { } } - public void addChannels(Set locations, NetworkManager manager) { + public void addChannels(Set locations, Connection manager) { getFrom(manager).locations.addAll(locations); } @@ -99,7 +99,7 @@ public class FMLMCRegisterPacketHandler { evt.getSource().get().setPacketHandled(true); } - private static ChannelList getFrom(NetworkManager manager) { + private static ChannelList getFrom(Connection manager) { return fromAttr(manager.channel().attr(FMLNetworkConstants.FML_MC_REGISTRY)); } @@ -112,10 +112,10 @@ public class FMLMCRegisterPacketHandler { return attr.get(); } - public void sendRegistry(NetworkManager manager, final NetworkDirection dir) { - PacketBuffer pb = new PacketBuffer(Unpooled.buffer()); + public void sendRegistry(Connection manager, final NetworkDirection dir) { + FriendlyByteBuf pb = new FriendlyByteBuf(Unpooled.buffer()); pb.writeBytes(getFrom(manager).toByteArray()); - final ICustomPacket> iPacketICustomPacket = dir.buildPacket(Pair.of(pb, 0), FMLNetworkConstants.MC_REGISTER_RESOURCE); + final ICustomPacket> iPacketICustomPacket = dir.buildPacket(Pair.of(pb, 0), FMLNetworkConstants.MC_REGISTER_RESOURCE); manager.send(iPacketICustomPacket.getThis()); } } diff --git a/src/main/java/net/minecraftforge/fml/network/FMLNetworkConstants.java b/src/main/java/net/minecraftforge/fmllegacy/network/FMLNetworkConstants.java similarity index 92% rename from src/main/java/net/minecraftforge/fml/network/FMLNetworkConstants.java rename to src/main/java/net/minecraftforge/fmllegacy/network/FMLNetworkConstants.java index bb5c0daaf0..a5f6fe5697 100644 --- a/src/main/java/net/minecraftforge/fml/network/FMLNetworkConstants.java +++ b/src/main/java/net/minecraftforge/fmllegacy/network/FMLNetworkConstants.java @@ -17,12 +17,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.network; +package net.minecraftforge.fmllegacy.network; import io.netty.util.AttributeKey; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.network.event.EventNetworkChannel; -import net.minecraftforge.fml.network.simple.SimpleChannel; +import net.minecraft.resources.ResourceLocation; +import net.minecraftforge.fmllegacy.network.event.EventNetworkChannel; +import net.minecraftforge.fmllegacy.network.simple.SimpleChannel; import org.apache.logging.log4j.Marker; import org.apache.logging.log4j.MarkerManager; diff --git a/src/main/java/net/minecraftforge/fml/network/FMLPlayMessages.java b/src/main/java/net/minecraftforge/fmllegacy/network/FMLPlayMessages.java similarity index 73% rename from src/main/java/net/minecraftforge/fml/network/FMLPlayMessages.java rename to src/main/java/net/minecraftforge/fmllegacy/network/FMLPlayMessages.java index 518d574f3b..2f3000e389 100644 --- a/src/main/java/net/minecraftforge/fml/network/FMLPlayMessages.java +++ b/src/main/java/net/minecraftforge/fmllegacy/network/FMLPlayMessages.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.network; +package net.minecraftforge.fmllegacy.network; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; @@ -27,31 +27,32 @@ import io.netty.buffer.Unpooled; import java.util.List; import java.util.Map; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.IHasContainer; -import net.minecraft.client.gui.ScreenManager; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; -import net.minecraft.inventory.container.Container; -import net.minecraft.inventory.container.ContainerType; -import net.minecraft.network.PacketBuffer; -import net.minecraft.tags.ITag; -import net.minecraft.tags.ITagCollection; -import net.minecraft.tags.ITagCollectionSupplier; -import net.minecraft.tags.TagRegistryManager; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.text.TranslationTextComponent; -import net.minecraft.world.World; +import net.minecraft.client.gui.screens.inventory.MenuAccess; +import net.minecraft.client.gui.screens.MenuScreens; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.tags.Tag; +import net.minecraft.tags.TagCollection; +import net.minecraft.tags.TagContainer; +import net.minecraft.tags.StaticTags; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.world.level.Level; import net.minecraftforge.common.ForgeTagHandler; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.TagsUpdatedEvent; -import net.minecraftforge.fml.LogicalSidedProvider; -import net.minecraft.util.registry.Registry; -import net.minecraft.util.text.ITextComponent; -import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData; +import net.minecraftforge.fmllegacy.LogicalSidedProvider; +import net.minecraft.core.Registry; +import net.minecraft.network.chat.Component; +import net.minecraftforge.fmllegacy.common.registry.IEntityAdditionalSpawnData; import java.util.Optional; import java.util.UUID; @@ -80,7 +81,7 @@ public class FMLPlayMessages private final double posX, posY, posZ; private final byte pitch, yaw, headYaw; private final int velX, velY, velZ; - private final PacketBuffer buf; + private final FriendlyByteBuf buf; SpawnEntity(Entity e) { @@ -91,13 +92,13 @@ public class FMLPlayMessages this.posX = e.getX(); this.posY = e.getY(); this.posZ = e.getZ(); - this.pitch = (byte) MathHelper.floor(e.xRot * 256.0F / 360.0F); - this.yaw = (byte) MathHelper.floor(e.yRot * 256.0F / 360.0F); + this.pitch = (byte) Mth.floor(e.getXRot() * 256.0F / 360.0F); + this.yaw = (byte) Mth.floor(e.getYRot() * 256.0F / 360.0F); this.headYaw = (byte) (e.getYHeadRot() * 256.0F / 360.0F); - Vector3d vec3d = e.getDeltaMovement(); - double d1 = MathHelper.clamp(vec3d.x, -3.9D, 3.9D); - double d2 = MathHelper.clamp(vec3d.y, -3.9D, 3.9D); - double d3 = MathHelper.clamp(vec3d.z, -3.9D, 3.9D); + Vec3 vec3d = e.getDeltaMovement(); + double d1 = Mth.clamp(vec3d.x, -3.9D, 3.9D); + double d2 = Mth.clamp(vec3d.y, -3.9D, 3.9D); + double d3 = Mth.clamp(vec3d.z, -3.9D, 3.9D); this.velX = (int)(d1 * 8000.0D); this.velY = (int)(d2 * 8000.0D); this.velZ = (int)(d3 * 8000.0D); @@ -105,7 +106,7 @@ public class FMLPlayMessages } private SpawnEntity(int typeId, int entityId, UUID uuid, double posX, double posY, double posZ, - byte pitch, byte yaw, byte headYaw, int velX, int velY, int velZ, PacketBuffer buf) + byte pitch, byte yaw, byte headYaw, int velX, int velY, int velZ, FriendlyByteBuf buf) { this.entity = null; this.typeId = typeId; @@ -123,7 +124,7 @@ public class FMLPlayMessages this.buf = buf; } - public static void encode(SpawnEntity msg, PacketBuffer buf) + public static void encode(SpawnEntity msg, FriendlyByteBuf buf) { buf.writeVarInt(msg.typeId); buf.writeInt(msg.entityId); @@ -144,7 +145,7 @@ public class FMLPlayMessages } } - public static SpawnEntity decode(PacketBuffer buf) + public static SpawnEntity decode(FriendlyByteBuf buf) { return new SpawnEntity( buf.readVarInt(), @@ -166,7 +167,7 @@ public class FMLPlayMessages throw new RuntimeException(String.format("Could not spawn entity (id %d) with unknown type at (%f, %f, %f)", msg.entityId, msg.posX, msg.posY, msg.posZ)); } - Optional world = LogicalSidedProvider.CLIENTWORLD.get(ctx.get().getDirection().getReceptionSide()); + Optional world = LogicalSidedProvider.CLIENTWORLD.get(ctx.get().getDirection().getReceptionSide()); Entity e = world.map(w->type.customClientSpawn(msg, w)).orElse(null); if (e == null) { @@ -180,7 +181,7 @@ public class FMLPlayMessages e.setId(msg.entityId); e.setUUID(msg.uuid); - world.filter(ClientWorld.class::isInstance).ifPresent(w->((ClientWorld)w).putNonPlayerEntity(msg.entityId, e)); + world.filter(ClientLevel.class::isInstance).ifPresent(w->((ClientLevel)w).putNonPlayerEntity(msg.entityId, e)); e.lerpMotion(msg.velX / 8000.0, msg.velY / 8000.0, msg.velZ / 8000.0); if (e instanceof IEntityAdditionalSpawnData) { @@ -255,7 +256,7 @@ public class FMLPlayMessages return velZ; } - public PacketBuffer getAdditionalData() + public FriendlyByteBuf getAdditionalData() { return buf; } @@ -265,15 +266,15 @@ public class FMLPlayMessages { private final int id; private final int windowId; - private final ITextComponent name; - private final PacketBuffer additionalData; + private final Component name; + private final FriendlyByteBuf additionalData; - OpenContainer(ContainerType id, int windowId, ITextComponent name, PacketBuffer additionalData) + OpenContainer(MenuType id, int windowId, Component name, FriendlyByteBuf additionalData) { this(Registry.MENU.getId(id), windowId, name, additionalData); } - private OpenContainer(int id, int windowId, ITextComponent name, PacketBuffer additionalData) + private OpenContainer(int id, int windowId, Component name, FriendlyByteBuf additionalData) { this.id = id; this.windowId = windowId; @@ -281,7 +282,7 @@ public class FMLPlayMessages this.additionalData = additionalData; } - public static void encode(OpenContainer msg, PacketBuffer buf) + public static void encode(OpenContainer msg, FriendlyByteBuf buf) { buf.writeVarInt(msg.id); buf.writeVarInt(msg.windowId); @@ -289,27 +290,27 @@ public class FMLPlayMessages buf.writeByteArray(msg.additionalData.readByteArray()); } - public static OpenContainer decode(PacketBuffer buf) + public static OpenContainer decode(FriendlyByteBuf buf) { - return new OpenContainer(buf.readVarInt(), buf.readVarInt(), buf.readComponent(), new PacketBuffer(Unpooled.wrappedBuffer(buf.readByteArray(32600)))); + return new OpenContainer(buf.readVarInt(), buf.readVarInt(), buf.readComponent(), new FriendlyByteBuf(Unpooled.wrappedBuffer(buf.readByteArray(32600)))); } public static void handle(OpenContainer msg, Supplier ctx) { ctx.get().enqueueWork(() -> { - ScreenManager.getScreenFactory(msg.getType(), Minecraft.getInstance(), msg.getWindowId(), msg.getName()) + MenuScreens.getScreenFactory(msg.getType(), Minecraft.getInstance(), msg.getWindowId(), msg.getName()) .ifPresent(f -> { - Container c = msg.getType().create(msg.getWindowId(), Minecraft.getInstance().player.inventory, msg.getAdditionalData()); + AbstractContainerMenu c = msg.getType().create(msg.getWindowId(), Minecraft.getInstance().player.getInventory(), msg.getAdditionalData()); @SuppressWarnings("unchecked") - Screen s = ((ScreenManager.IScreenFactory)f).create(c, Minecraft.getInstance().player.inventory, msg.getName()); - Minecraft.getInstance().player.containerMenu = ((IHasContainer)s).getMenu(); + Screen s = ((MenuScreens.ScreenConstructor)f).create(c, Minecraft.getInstance().player.getInventory(), msg.getName()); + Minecraft.getInstance().player.containerMenu = ((MenuAccess)s).getMenu(); Minecraft.getInstance().setScreen(s); }); }); ctx.get().setPacketHandled(true); } - public final ContainerType getType() { + public final MenuType getType() { return Registry.MENU.byId(this.id); } @@ -317,11 +318,11 @@ public class FMLPlayMessages return windowId; } - public ITextComponent getName() { + public Component getName() { return name; } - public PacketBuffer getAdditionalData() { + public FriendlyByteBuf getAdditionalData() { return additionalData; } } @@ -329,25 +330,25 @@ public class FMLPlayMessages public static class SyncCustomTagTypes { private static final Logger LOGGER = LogManager.getLogger(); - private final Map> customTagTypeCollections; + private final Map> customTagTypeCollections; - SyncCustomTagTypes(Map> customTagTypeCollections) + SyncCustomTagTypes(Map> customTagTypeCollections) { this.customTagTypeCollections = customTagTypeCollections; } - public Map> getCustomTagTypes() + public Map> getCustomTagTypes() { return customTagTypeCollections; } - public static void encode(SyncCustomTagTypes msg, PacketBuffer buf) + public static void encode(SyncCustomTagTypes msg, FriendlyByteBuf buf) { buf.writeVarInt(msg.customTagTypeCollections.size()); msg.customTagTypeCollections.forEach((registryName, modded) -> forgeTagCollectionWrite(buf, registryName, modded.getAllTags())); } - private static void forgeTagCollectionWrite(PacketBuffer buf, ResourceLocation registryName, Map> tags) + private static void forgeTagCollectionWrite(FriendlyByteBuf buf, ResourceLocation registryName, Map> tags) { buf.writeResourceLocation(registryName); buf.writeVarInt(tags.size()); @@ -362,9 +363,9 @@ public class FMLPlayMessages }); } - public static SyncCustomTagTypes decode(PacketBuffer buf) + public static SyncCustomTagTypes decode(FriendlyByteBuf buf) { - ImmutableMap.Builder> builder = ImmutableMap.builder(); + ImmutableMap.Builder> builder = ImmutableMap.builder(); int size = buf.readVarInt(); for (int i = 0; i < size; i++) { @@ -378,9 +379,9 @@ public class FMLPlayMessages return new SyncCustomTagTypes(builder.build()); } - private static > ITagCollection readTagCollection(PacketBuffer buf, IForgeRegistry registry) + private static > TagCollection readTagCollection(FriendlyByteBuf buf, IForgeRegistry registry) { - Map> tags = Maps.newHashMap(); + Map> tags = Maps.newHashMap(); int totalTags = buf.readVarInt(); for (int i = 0; i < totalTags; i++) { @@ -395,9 +396,9 @@ public class FMLPlayMessages elementBuilder.add(element); } } - tags.put(name, ITag.fromSet(elementBuilder.build())); + tags.put(name, Tag.fromSet(elementBuilder.build())); } - return ITagCollection.of(tags); + return TagCollection.of(tags); } public static void handle(SyncCustomTagTypes msg, Supplier ctx) @@ -405,14 +406,14 @@ public class FMLPlayMessages ctx.get().enqueueWork(() -> { if (Minecraft.getInstance().level != null) { - ITagCollectionSupplier tagCollectionSupplier = Minecraft.getInstance().level.getTagManager(); + TagContainer tagCollectionSupplier = Minecraft.getInstance().level.getTagManager(); //Validate that all the tags exist using the tag type collections from the packet // We mimic vanilla in that we validate before updating the actual stored tags so that it can gracefully fallback // to the last working set of tags //Note: We gracefully ignore any tag types the server may have that we don't as they won't be in our tag registry // so they won't be validated //Override and use the tags from the packet to test for validation before we actually set them - Multimap missingTags = TagRegistryManager.getAllMissingTags(ForgeTagHandler.withSpecificCustom(tagCollectionSupplier, msg.customTagTypeCollections)); + Multimap>, ResourceLocation> missingTags = StaticTags.getAllMissingTags(ForgeTagHandler.withSpecificCustom(tagCollectionSupplier, msg.customTagTypeCollections)); if (missingTags.isEmpty()) { //If we have no missing tags, update the custom tag types @@ -422,12 +423,12 @@ public class FMLPlayMessages //And if everything hasn't already been set due to being in single player // Fetch and update the custom tag types. We skip vanilla tag types as they have already been fetched // And fire an event that the custom tag types have been updated - TagRegistryManager.fetchCustomTagTypes(tagCollectionSupplier); + StaticTags.fetchCustomTagTypes(tagCollectionSupplier); MinecraftForge.EVENT_BUS.post(new TagsUpdatedEvent.CustomTagTypes(tagCollectionSupplier)); } } else { LOGGER.warn("Incomplete server tags, disconnecting. Missing: {}", missingTags); - ctx.get().getNetworkManager().disconnect(new TranslationTextComponent("multiplayer.disconnect.missing_tags")); + ctx.get().getNetworkManager().disconnect(new TranslatableComponent("multiplayer.disconnect.missing_tags")); } } }); diff --git a/src/main/java/net/minecraftforge/fml/network/FMLStatusPing.java b/src/main/java/net/minecraftforge/fmllegacy/network/FMLStatusPing.java similarity index 81% rename from src/main/java/net/minecraftforge/fml/network/FMLStatusPing.java rename to src/main/java/net/minecraftforge/fmllegacy/network/FMLStatusPing.java index 870f938f97..a644b658dc 100644 --- a/src/main/java/net/minecraftforge/fml/network/FMLStatusPing.java +++ b/src/main/java/net/minecraftforge/fmllegacy/network/FMLStatusPing.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.network; +package net.minecraftforge.fmllegacy.network; import com.google.common.collect.ImmutableMap; import com.google.gson.JsonArray; @@ -26,9 +26,9 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSyntaxException; -import net.minecraft.util.JSONUtils; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.ExtensionPoint; +import net.minecraft.util.GsonHelper; +import net.minecraft.resources.ResourceLocation; +import net.minecraftforge.fml.IExtensionPoint; import net.minecraftforge.fml.ModList; import org.apache.commons.lang3.tuple.Pair; import org.apache.logging.log4j.LogManager; @@ -37,11 +37,10 @@ import org.apache.logging.log4j.Logger; import java.util.HashMap; import java.util.Map; import java.util.function.Supplier; + import java.util.stream.Collectors; import java.util.stream.StreamSupport; -import static net.minecraftforge.fml.network.FMLNetworkConstants.NETWORK; - /** * { * "fmlNetworkVersion" : FMLNETVERSION, @@ -76,8 +75,10 @@ public class FMLStatusPing { this.channels = NetworkRegistry.buildChannelVersionsForListPing(); this.mods = new HashMap<>(); ModList.get().forEachModContainer((modid, mc) -> - mods.put(modid, mc.getCustomExtension(ExtensionPoint.DISPLAYTEST). - map(Pair::getLeft).map(Supplier::get).orElse(FMLNetworkConstants.IGNORESERVERONLY))); + mods.put(modid, mc.getCustomExtension(IExtensionPoint.DisplayTest.class) + .map(IExtensionPoint.DisplayTest::suppliedVersion) + .map(Supplier::get) + .orElse(FMLNetworkConstants.IGNORESERVERONLY))); this.fmlNetworkVer = FMLNetworkConstants.FMLNETVERSION; this.truncated = false; } @@ -92,21 +93,21 @@ public class FMLStatusPing { public static class Serializer { public static FMLStatusPing deserialize(JsonObject forgeData, JsonDeserializationContext ctx) { try { - final Map> channels = StreamSupport.stream(JSONUtils.getAsJsonArray(forgeData, "channels").spliterator(), false). + final Map> channels = StreamSupport.stream(GsonHelper.getAsJsonArray(forgeData, "channels").spliterator(), false). map(JsonElement::getAsJsonObject). - collect(Collectors.toMap(jo -> new ResourceLocation(JSONUtils.getAsString(jo, "res")), - jo -> Pair.of(JSONUtils.getAsString(jo, "version"), JSONUtils.getAsBoolean(jo, "required"))) + collect(Collectors.toMap(jo -> new ResourceLocation(GsonHelper.getAsString(jo, "res")), + jo -> Pair.of(GsonHelper.getAsString(jo, "version"), GsonHelper.getAsBoolean(jo, "required"))) ); - final Map mods = StreamSupport.stream(JSONUtils.getAsJsonArray(forgeData, "mods").spliterator(), false). + final Map mods = StreamSupport.stream(GsonHelper.getAsJsonArray(forgeData, "mods").spliterator(), false). map(JsonElement::getAsJsonObject). - collect(Collectors.toMap(jo -> JSONUtils.getAsString(jo, "modId"), jo->JSONUtils.getAsString(jo, "modmarker"))); + collect(Collectors.toMap(jo -> GsonHelper.getAsString(jo, "modId"), jo->GsonHelper.getAsString(jo, "modmarker"))); - final int remoteFMLVersion = JSONUtils.getAsInt(forgeData, "fmlNetworkVersion"); - final boolean truncated = JSONUtils.getAsBoolean(forgeData, "truncated", false); + final int remoteFMLVersion = GsonHelper.getAsInt(forgeData, "fmlNetworkVersion"); + final boolean truncated = GsonHelper.getAsBoolean(forgeData, "truncated", false); return new FMLStatusPing(channels, mods, remoteFMLVersion, truncated); } catch (JsonSyntaxException e) { - LOGGER.debug(NETWORK, "Encountered an error parsing status ping data", e); + LOGGER.debug(FMLNetworkConstants.NETWORK, "Encountered an error parsing status ping data", e); return null; } } diff --git a/src/main/java/net/minecraftforge/fml/network/IContainerFactory.java b/src/main/java/net/minecraftforge/fmllegacy/network/IContainerFactory.java similarity index 63% rename from src/main/java/net/minecraftforge/fml/network/IContainerFactory.java rename to src/main/java/net/minecraftforge/fmllegacy/network/IContainerFactory.java index 9fe7d56f86..1a777dd552 100644 --- a/src/main/java/net/minecraftforge/fml/network/IContainerFactory.java +++ b/src/main/java/net/minecraftforge/fmllegacy/network/IContainerFactory.java @@ -17,19 +17,19 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.network; +package net.minecraftforge.fmllegacy.network; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.inventory.container.Container; -import net.minecraft.inventory.container.ContainerType; -import net.minecraft.network.PacketBuffer; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.network.FriendlyByteBuf; -public interface IContainerFactory extends ContainerType.IFactory +public interface IContainerFactory extends MenuType.MenuSupplier { - T create(int windowId, PlayerInventory inv, PacketBuffer data); + T create(int windowId, Inventory inv, FriendlyByteBuf data); @Override - default T create(int p_create_1_, PlayerInventory p_create_2_) + default T create(int p_create_1_, Inventory p_create_2_) { return create(p_create_1_, p_create_2_, null); } diff --git a/src/main/java/net/minecraftforge/fml/network/ICustomPacket.java b/src/main/java/net/minecraftforge/fmllegacy/network/ICustomPacket.java similarity index 75% rename from src/main/java/net/minecraftforge/fml/network/ICustomPacket.java rename to src/main/java/net/minecraftforge/fmllegacy/network/ICustomPacket.java index d4aad1de82..4513e05ee3 100644 --- a/src/main/java/net/minecraftforge/fml/network/ICustomPacket.java +++ b/src/main/java/net/minecraftforge/fmllegacy/network/ICustomPacket.java @@ -17,16 +17,16 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.network; +package net.minecraftforge.fmllegacy.network; import it.unimi.dsi.fastutil.objects.Reference2ReferenceArrayMap; -import net.minecraft.network.IPacket; -import net.minecraft.network.PacketBuffer; -import net.minecraft.network.login.client.CCustomPayloadLoginPacket; -import net.minecraft.network.login.server.SCustomPayloadLoginPacket; -import net.minecraft.network.play.client.CCustomPayloadPacket; -import net.minecraft.network.play.server.SCustomPayloadPlayPacket; -import net.minecraft.util.ResourceLocation; +import net.minecraft.network.protocol.Packet; +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.resources.ResourceLocation; import net.minecraftforge.fml.unsafe.UnsafeHacks; import java.lang.reflect.Field; @@ -37,13 +37,13 @@ import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; -public interface ICustomPacket> { +public interface ICustomPacket> { @SuppressWarnings("OptionalUsedAsFieldOrParameterType") enum Fields { - CPACKETCUSTOMPAYLOAD(CCustomPayloadPacket.class), - SPACKETCUSTOMPAYLOAD(SCustomPayloadPlayPacket.class), - CPACKETCUSTOMLOGIN(CCustomPayloadLoginPacket.class), - SPACKETCUSTOMLOGIN(SCustomPayloadLoginPacket.class), + CPACKETCUSTOMPAYLOAD(ServerboundCustomPayloadPacket.class), + SPACKETCUSTOMPAYLOAD(ClientboundCustomPayloadPacket.class), + CPACKETCUSTOMLOGIN(ServerboundCustomQueryPacket.class), + SPACKETCUSTOMLOGIN(ClientboundCustomQueryPacket.class), ; static final Reference2ReferenceArrayMap, Fields> lookup; @@ -62,7 +62,7 @@ public interface ICustomPacket> { { this.clazz = customPacketClass; Field[] fields = customPacketClass.getDeclaredFields(); - data = Arrays.stream(fields).filter(f-> !Modifier.isStatic(f.getModifiers()) && f.getType() == PacketBuffer.class).findFirst(); + data = Arrays.stream(fields).filter(f-> !Modifier.isStatic(f.getModifiers()) && f.getType() == FriendlyByteBuf.class).findFirst(); channel = Arrays.stream(fields).filter(f->!Modifier.isStatic(f.getModifiers()) && f.getType() == ResourceLocation.class).findFirst(); index = Arrays.stream(fields).filter(f->!Modifier.isStatic(f.getModifiers()) && f.getType() == int.class).findFirst(); } @@ -73,8 +73,8 @@ public interface ICustomPacket> { } } - default PacketBuffer getInternalData() { - return Fields.lookup.get(this.getClass()).data.map(f->UnsafeHacks.getField(f, this)).orElse(null); + default FriendlyByteBuf getInternalData() { + return Fields.lookup.get(this.getClass()).data.map(f->UnsafeHacks.getField(f, this)).orElse(null); } default ResourceLocation getName() { @@ -85,7 +85,7 @@ public interface ICustomPacket> { return Fields.lookup.get(this.getClass()).index.map(f->UnsafeHacks.getIntField(f, this)).orElse(Integer.MIN_VALUE); } - default void setData(PacketBuffer buffer) { + default void setData(FriendlyByteBuf buffer) { Fields.lookup.get(this.getClass()).data.ifPresent(f->UnsafeHacks.setField(f, this, buffer)); } diff --git a/src/main/java/net/minecraftforge/fml/network/NetworkDirection.java b/src/main/java/net/minecraftforge/fmllegacy/network/NetworkDirection.java similarity index 74% rename from src/main/java/net/minecraftforge/fml/network/NetworkDirection.java rename to src/main/java/net/minecraftforge/fmllegacy/network/NetworkDirection.java index 6497916692..5dcddae09f 100644 --- a/src/main/java/net/minecraftforge/fml/network/NetworkDirection.java +++ b/src/main/java/net/minecraftforge/fmllegacy/network/NetworkDirection.java @@ -17,16 +17,16 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.network; +package net.minecraftforge.fmllegacy.network; import it.unimi.dsi.fastutil.objects.Reference2ReferenceArrayMap; -import net.minecraft.network.IPacket; -import net.minecraft.network.PacketBuffer; -import net.minecraft.network.login.client.CCustomPayloadLoginPacket; -import net.minecraft.network.login.server.SCustomPayloadLoginPacket; -import net.minecraft.network.play.client.CCustomPayloadPacket; -import net.minecraft.network.play.server.SCustomPayloadPlayPacket; -import net.minecraft.util.ResourceLocation; +import net.minecraft.network.protocol.Packet; +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.resources.ResourceLocation; import net.minecraftforge.fml.LogicalSide; import net.minecraftforge.fml.unsafe.UnsafeHacks; import org.apache.commons.lang3.tuple.Pair; @@ -39,24 +39,24 @@ import java.util.stream.Stream; public enum NetworkDirection { - PLAY_TO_SERVER(NetworkEvent.ClientCustomPayloadEvent::new, LogicalSide.CLIENT, CCustomPayloadPacket.class, 1), - PLAY_TO_CLIENT(NetworkEvent.ServerCustomPayloadEvent::new, LogicalSide.SERVER, SCustomPayloadPlayPacket.class, 0), - LOGIN_TO_SERVER(NetworkEvent.ClientCustomPayloadLoginEvent::new, LogicalSide.CLIENT, CCustomPayloadLoginPacket.class, 3), - LOGIN_TO_CLIENT(NetworkEvent.ServerCustomPayloadLoginEvent::new, LogicalSide.SERVER, SCustomPayloadLoginPacket.class, 2); + PLAY_TO_SERVER(NetworkEvent.ClientCustomPayloadEvent::new, LogicalSide.CLIENT, ServerboundCustomPayloadPacket.class, 1), + PLAY_TO_CLIENT(NetworkEvent.ServerCustomPayloadEvent::new, LogicalSide.SERVER, ClientboundCustomPayloadPacket.class, 0), + LOGIN_TO_SERVER(NetworkEvent.ClientCustomPayloadLoginEvent::new, LogicalSide.CLIENT, ServerboundCustomQueryPacket.class, 3), + LOGIN_TO_CLIENT(NetworkEvent.ServerCustomPayloadLoginEvent::new, LogicalSide.SERVER, ClientboundCustomQueryPacket.class, 2); private final BiFunction, Supplier, NetworkEvent> eventSupplier; private final LogicalSide logicalSide; - private final Class packetClass; + private final Class packetClass; private final int otherWay; - private static final Reference2ReferenceArrayMap, NetworkDirection> packetLookup; + private static final Reference2ReferenceArrayMap, NetworkDirection> packetLookup; static { packetLookup = Stream.of(values()). collect(Collectors.toMap(NetworkDirection::getPacketClass, Function.identity(), (m1,m2)->m1, Reference2ReferenceArrayMap::new)); } - NetworkDirection(BiFunction, Supplier, NetworkEvent> eventSupplier, LogicalSide logicalSide, Class clazz, int i) + NetworkDirection(BiFunction, Supplier, NetworkEvent> eventSupplier, LogicalSide logicalSide, Class clazz, int i) { this.eventSupplier = eventSupplier; this.logicalSide = logicalSide; @@ -64,7 +64,7 @@ public enum NetworkDirection this.otherWay = i; } - private Class getPacketClass() { + private Class getPacketClass() { return packetClass; } public static > NetworkDirection directionFor(Class customPacket) @@ -87,7 +87,7 @@ public enum NetworkDirection public LogicalSide getReceptionSide() { return reply().logicalSide; }; @SuppressWarnings("unchecked") - public > ICustomPacket buildPacket(Pair packetData, ResourceLocation channelName) + public > ICustomPacket buildPacket(Pair packetData, ResourceLocation channelName) { ICustomPacket packet = (ICustomPacket)UnsafeHacks.newInstance(getPacketClass()); packet.setName(channelName); diff --git a/src/main/java/net/minecraftforge/fml/network/NetworkEvent.java b/src/main/java/net/minecraftforge/fmllegacy/network/NetworkEvent.java similarity index 81% rename from src/main/java/net/minecraftforge/fml/network/NetworkEvent.java rename to src/main/java/net/minecraftforge/fmllegacy/network/NetworkEvent.java index 84be07d22e..d47c400df9 100644 --- a/src/main/java/net/minecraftforge/fml/network/NetworkEvent.java +++ b/src/main/java/net/minecraftforge/fmllegacy/network/NetworkEvent.java @@ -17,22 +17,22 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.network; +package net.minecraftforge.fmllegacy.network; import javax.annotation.Nullable; import io.netty.util.Attribute; import io.netty.util.AttributeKey; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.network.INetHandler; -import net.minecraft.network.play.ServerPlayNetHandler; -import net.minecraft.network.NetworkManager; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.concurrent.ThreadTaskExecutor; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.network.PacketListener; +import net.minecraft.server.network.ServerGamePacketListenerImpl; +import net.minecraft.network.Connection; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.thread.BlockableEventLoop; import net.minecraftforge.eventbus.api.Event; -import net.minecraftforge.fml.LogicalSidedProvider; +import net.minecraftforge.fmllegacy.LogicalSidedProvider; import java.util.List; import java.util.concurrent.CompletableFuture; @@ -40,7 +40,7 @@ import java.util.function.Supplier; public class NetworkEvent extends Event { - private final PacketBuffer payload; + private final FriendlyByteBuf payload; private final Supplier source; private final int loginIndex; @@ -51,7 +51,7 @@ public class NetworkEvent extends Event this.loginIndex = payload.getIndex(); } - private NetworkEvent(final PacketBuffer payload, final Supplier source, final int loginIndex) + private NetworkEvent(final FriendlyByteBuf payload, final Supplier source, final int loginIndex) { this.payload = payload; this.source = source; @@ -64,7 +64,7 @@ public class NetworkEvent extends Event this.loginIndex = -1; } - public PacketBuffer getPayload() + public FriendlyByteBuf getPayload() { return payload; } @@ -114,7 +114,7 @@ public class NetworkEvent extends Event this.isLocal = isLocal; } - public void add(PacketBuffer buffer, ResourceLocation channelName, String context) { + public void add(FriendlyByteBuf buffer, ResourceLocation channelName, String context) { collected.add(new NetworkRegistry.LoginPayload(buffer, channelName, context)); } @@ -124,7 +124,7 @@ public class NetworkEvent extends Event } public static class LoginPayloadEvent extends NetworkEvent { - LoginPayloadEvent(final PacketBuffer payload, final Supplier source, final int loginIndex) { + LoginPayloadEvent(final FriendlyByteBuf payload, final Supplier source, final int loginIndex) { super(payload, source, loginIndex); } } @@ -160,7 +160,7 @@ public class NetworkEvent extends Event /** * The {@link NetworkManager} for this message. */ - private final NetworkManager networkManager; + private final Connection networkManager; /** * The {@link NetworkDirection} this message has been received on. @@ -173,12 +173,12 @@ public class NetworkEvent extends Event private final PacketDispatcher packetDispatcher; private boolean packetHandled; - Context(NetworkManager netHandler, NetworkDirection networkDirection, int index) + Context(Connection netHandler, NetworkDirection networkDirection, int index) { this(netHandler, networkDirection, new PacketDispatcher.NetworkManagerDispatcher(netHandler, index, networkDirection.reply()::buildPacket)); } - Context(NetworkManager networkManager, NetworkDirection networkDirection, PacketDispatcher dispatcher) { + Context(Connection networkManager, NetworkDirection networkDirection, PacketDispatcher dispatcher) { this.networkManager = networkManager; this.networkDirection = networkDirection; this.packetDispatcher = dispatcher; @@ -206,7 +206,7 @@ public class NetworkEvent extends Event } public CompletableFuture enqueueWork(Runnable runnable) { - ThreadTaskExecutor executor = LogicalSidedProvider.WORKQUEUE.get(getDirection().getReceptionSide()); + BlockableEventLoop executor = LogicalSidedProvider.WORKQUEUE.get(getDirection().getReceptionSide()); // Must check ourselves as Minecraft will sometimes delay tasks even when they are received on the client thread // Same logic as ThreadTaskExecutor#runImmediately without the join if (!executor.isSameThread()) { @@ -221,18 +221,18 @@ public class NetworkEvent extends Event * When available, gets the sender for packets that are sent from a client to the server. */ @Nullable - public ServerPlayerEntity getSender() + public ServerPlayer getSender() { - INetHandler netHandler = networkManager.getPacketListener(); - if (netHandler instanceof ServerPlayNetHandler) + PacketListener netHandler = networkManager.getPacketListener(); + if (netHandler instanceof ServerGamePacketListenerImpl) { - ServerPlayNetHandler netHandlerPlayServer = (ServerPlayNetHandler) netHandler; + ServerGamePacketListenerImpl netHandlerPlayServer = (ServerGamePacketListenerImpl) netHandler; return netHandlerPlayServer.player; } return null; } - public NetworkManager getNetworkManager() { + public Connection getNetworkManager() { return networkManager; } } diff --git a/src/main/java/net/minecraftforge/fml/network/NetworkHooks.java b/src/main/java/net/minecraftforge/fmllegacy/network/NetworkHooks.java similarity index 71% rename from src/main/java/net/minecraftforge/fml/network/NetworkHooks.java rename to src/main/java/net/minecraftforge/fmllegacy/network/NetworkHooks.java index a493d4331e..35eea6b19e 100644 --- a/src/main/java/net/minecraftforge/fml/network/NetworkHooks.java +++ b/src/main/java/net/minecraftforge/fmllegacy/network/NetworkHooks.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.network; +package net.minecraftforge.fmllegacy.network; import java.util.Map; import java.util.Objects; @@ -29,26 +29,27 @@ import java.util.stream.Collectors; import io.netty.channel.Channel; import io.netty.channel.ChannelHandlerContext; -import net.minecraft.tags.ITagCollection; -import net.minecraft.tags.ITagCollectionSupplier; -import net.minecraft.util.text.StringTextComponent; -import net.minecraftforge.fml.common.thread.EffectiveSide; +import net.minecraft.tags.TagCollection; +import net.minecraft.tags.TagContainer; +import net.minecraft.network.chat.TextComponent; +import net.minecraftforge.common.extensions.IForgeTagContainer; +import net.minecraftforge.fml.util.thread.EffectiveSide; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import io.netty.buffer.Unpooled; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.inventory.container.Container; -import net.minecraft.inventory.container.ContainerType; -import net.minecraft.inventory.container.INamedContainerProvider; -import net.minecraft.network.IPacket; -import net.minecraft.network.NetworkManager; -import net.minecraft.network.PacketBuffer; -import net.minecraft.network.handshake.client.CHandshakePacket; -import net.minecraft.network.login.ServerLoginNetHandler; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.entity.Entity; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.MenuProvider; +import net.minecraft.network.protocol.Packet; +import net.minecraft.network.Connection; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.protocol.handshake.ClientIntentionPacket; +import net.minecraft.server.network.ServerLoginPacketListenerImpl; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.BlockPos; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.PlayerContainerEvent; import net.minecraftforge.fml.config.ConfigTracker; @@ -65,7 +66,7 @@ public class NetworkHooks return ip.contains("\0") ? Objects.equals(ip.split("\0")[1], FMLNetworkConstants.NETVERSION) ? FMLNetworkConstants.NETVERSION : ip.split("\0")[1] : FMLNetworkConstants.NOVERSION; } - public static ConnectionType getConnectionType(final Supplier connection) + public static ConnectionType getConnectionType(final Supplier connection) { return getConnectionType(connection.get().channel()); } @@ -80,44 +81,44 @@ public class NetworkHooks return ConnectionType.forVersionFlag(channel.attr(FMLNetworkConstants.FML_NETVERSION).get()); } - public static IPacket getEntitySpawningPacket(Entity entity) + public static Packet getEntitySpawningPacket(Entity entity) { return FMLNetworkConstants.playChannel.toVanillaPacket(new FMLPlayMessages.SpawnEntity(entity), NetworkDirection.PLAY_TO_CLIENT); } - public static boolean onCustomPayload(final ICustomPacket packet, final NetworkManager manager) { + public static boolean onCustomPayload(final ICustomPacket packet, final Connection manager) { return NetworkRegistry.findTarget(packet.getName()). filter(ni->validateSideForProcessing(packet, ni, manager)). map(ni->ni.dispatch(packet.getDirection(), packet, manager)).orElse(Boolean.FALSE); } - private static boolean validateSideForProcessing(final ICustomPacket packet, final NetworkInstance ni, final NetworkManager manager) { + private static boolean validateSideForProcessing(final ICustomPacket packet, final NetworkInstance ni, final Connection manager) { if (packet.getDirection().getReceptionSide() != EffectiveSide.get()) { - manager.disconnect(new StringTextComponent("Illegal packet received, terminating connection")); + manager.disconnect(new TextComponent("Illegal packet received, terminating connection")); return false; } return true; } - public static void validatePacketDirection(final NetworkDirection packetDirection, final Optional expectedDirection, final NetworkManager connection) { + public static void validatePacketDirection(final NetworkDirection packetDirection, final Optional expectedDirection, final Connection connection) { if (packetDirection != expectedDirection.orElse(packetDirection)) { - connection.disconnect(new StringTextComponent("Illegal packet received, terminating connection")); + connection.disconnect(new TextComponent("Illegal packet received, terminating connection")); throw new IllegalStateException("Invalid packet received, aborting connection"); } } - public static void registerServerLoginChannel(NetworkManager manager, CHandshakePacket packet) + public static void registerServerLoginChannel(Connection manager, ClientIntentionPacket packet) { manager.channel().attr(FMLNetworkConstants.FML_NETVERSION).set(packet.getFMLVersion()); FMLHandshakeHandler.registerHandshake(manager, NetworkDirection.LOGIN_TO_CLIENT); } - public synchronized static void registerClientLoginChannel(NetworkManager manager) + public synchronized static void registerClientLoginChannel(Connection manager) { manager.channel().attr(FMLNetworkConstants.FML_NETVERSION).set(FMLNetworkConstants.NOVERSION); FMLHandshakeHandler.registerHandshake(manager, NetworkDirection.LOGIN_TO_SERVER); } - public synchronized static void sendMCRegistryPackets(NetworkManager manager, String direction) { + public synchronized static void sendMCRegistryPackets(Connection manager, String direction) { NetworkFilters.injectIfNecessary(manager); final Set resourceLocations = NetworkRegistry.buildChannelVersions().keySet().stream(). filter(rl -> !Objects.equals(rl.getNamespace(), "minecraft")). @@ -135,13 +136,13 @@ public class NetworkHooks FMLNetworkConstants.playChannel.sendTo(new FMLPlayMessages.DimensionInfoMessage(player.dimension), manager, NetworkDirection.PLAY_TO_CLIENT); }*/ - public static boolean isVanillaConnection(NetworkManager 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; } - public static void handleClientLoginSuccess(NetworkManager manager) { + public static void handleClientLoginSuccess(Connection manager) { if (isVanillaConnection(manager)) { LOGGER.info("Connected to a vanilla server. Catching up missing behaviour."); ConfigTracker.INSTANCE.loadDefaultServerConfigs(); @@ -150,7 +151,7 @@ public class NetworkHooks } } - public static boolean tickNegotiation(ServerLoginNetHandler netHandlerLoginServer, NetworkManager networkManager, ServerPlayerEntity player) + public static boolean tickNegotiation(ServerLoginPacketListenerImpl netHandlerLoginServer, Connection networkManager, ServerPlayer player) { return FMLHandshakeHandler.tickLogin(networkManager); } @@ -158,7 +159,7 @@ public class NetworkHooks /** * Request to open a GUI on the client, from the server * - * Refer to {@link net.minecraftforge.fml.ExtensionPoint#GUIFACTORY} for how to provide a function to consume + * Refer to {@link net.minecraftforge.fml.ExtensionPoint#CONFIGGUIFACTORY} for how to provide a function to consume * these GUI requests on the client. * * The {@link IInteractionObject#getGuiID()} is treated as a {@link ResourceLocation}. @@ -168,7 +169,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 openGui(ServerPlayerEntity player, INamedContainerProvider containerSupplier) + public static void openGui(ServerPlayer player, MenuProvider containerSupplier) { openGui(player, containerSupplier, buf -> {}); } @@ -176,7 +177,7 @@ public class NetworkHooks /** * Request to open a GUI on the client, from the server * - * Refer to {@link net.minecraftforge.fml.ExtensionPoint#GUIFACTORY} for how to provide a function to consume + * Refer to {@link net.minecraftforge.fml.ExtensionPoint#CONFIGGUIFACTORY} for how to provide a function to consume * these GUI requests on the client. * * The {@link IInteractionObject#getGuiID()} is treated as a {@link ResourceLocation}. @@ -187,14 +188,14 @@ 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 openGui(ServerPlayerEntity player, INamedContainerProvider containerSupplier, BlockPos pos) + public static void openGui(ServerPlayer player, MenuProvider containerSupplier, BlockPos pos) { openGui(player, containerSupplier, buf -> buf.writeBlockPos(pos)); } /** * Request to open a GUI on the client, from the server * - * Refer to {@link net.minecraftforge.fml.ExtensionPoint#GUIFACTORY} for how to provide a function to consume + * Refer to {@link net.minecraftforge.fml.ExtensionPoint#CONFIGGUIFACTORY} for how to provide a function to consume * these GUI requests on the client. * * The {@link IInteractionObject#getGuiID()} is treated as a {@link ResourceLocation}. @@ -206,40 +207,40 @@ 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 openGui(ServerPlayerEntity player, INamedContainerProvider containerSupplier, Consumer extraDataWriter) + public static void openGui(ServerPlayer player, MenuProvider containerSupplier, Consumer extraDataWriter) { if (player.level.isClientSide) return; player.doCloseContainer(); player.nextContainerCounter(); int openContainerId = player.containerCounter; - PacketBuffer extraData = new PacketBuffer(Unpooled.buffer()); + FriendlyByteBuf extraData = new FriendlyByteBuf(Unpooled.buffer()); extraDataWriter.accept(extraData); extraData.readerIndex(0); // reset to beginning in case modders read for whatever reason - PacketBuffer output = new PacketBuffer(Unpooled.buffer()); + FriendlyByteBuf output = new FriendlyByteBuf(Unpooled.buffer()); output.writeVarInt(extraData.readableBytes()); output.writeBytes(extraData); if (output.readableBytes() > 32600 || output.readableBytes() < 1) { throw new IllegalArgumentException("Invalid PacketBuffer for openGui, found "+ output.readableBytes()+ " bytes"); } - Container c = containerSupplier.createMenu(openContainerId, player.inventory, player); - ContainerType type = c.getType(); + AbstractContainerMenu c = containerSupplier.createMenu(openContainerId, player.getInventory(), player); + MenuType type = c.getType(); FMLPlayMessages.OpenContainer msg = new FMLPlayMessages.OpenContainer(type, openContainerId, containerSupplier.getDisplayName(), output); FMLNetworkConstants.playChannel.sendTo(msg, player.connection.getConnection(), NetworkDirection.PLAY_TO_CLIENT); player.containerMenu = c; - player.containerMenu.addSlotListener(player); + player.initMenu(player.containerMenu); MinecraftForge.EVENT_BUS.post(new PlayerContainerEvent.Open(player, c)); } /** - * Syncs the custom tag types attached to a {@link ITagCollectionSupplier} to all connected players. + * Syncs the custom tag types attached to a {@link IForgeTagContainer} to all connected players. * @param tagCollectionSupplier The tag collection supplier containing the custom tags */ - public static void syncCustomTagTypes(ITagCollectionSupplier tagCollectionSupplier) + public static void syncCustomTagTypes(TagContainer tagCollectionSupplier) { - Map> customTagTypes = tagCollectionSupplier.getCustomTagTypes(); + Map> customTagTypes = tagCollectionSupplier.getCustomTagTypes(); if (!customTagTypes.isEmpty()) { FMLNetworkConstants.playChannel.send(PacketDistributor.ALL.noArg(), new FMLPlayMessages.SyncCustomTagTypes(customTagTypes)); @@ -247,13 +248,13 @@ public class NetworkHooks } /** - * Syncs the custom tag types attached to a {@link ITagCollectionSupplier} to the given player. + * Syncs the custom tag types attached to a {@link IForgeTagContainer} to the given player. * @param player The player to sync the custom tags to. * @param tagCollectionSupplier The tag collection supplier containing the custom tags */ - public static void syncCustomTagTypes(ServerPlayerEntity player, ITagCollectionSupplier tagCollectionSupplier) + public static void syncCustomTagTypes(ServerPlayer player, TagContainer tagCollectionSupplier) { - Map> customTagTypes = tagCollectionSupplier.getCustomTagTypes(); + Map> customTagTypes = tagCollectionSupplier.getCustomTagTypes(); if (!customTagTypes.isEmpty()) { FMLNetworkConstants.playChannel.sendTo(new FMLPlayMessages.SyncCustomTagTypes(customTagTypes), player.connection.getConnection(), NetworkDirection.PLAY_TO_CLIENT); @@ -261,7 +262,7 @@ public class NetworkHooks } @Nullable - public static FMLConnectionData getConnectionData(NetworkManager mgr) + public static FMLConnectionData getConnectionData(Connection mgr) { return mgr.channel().attr(FMLNetworkConstants.FML_CONNECTION_DATA).get(); } diff --git a/src/main/java/net/minecraftforge/fml/network/NetworkInitialization.java b/src/main/java/net/minecraftforge/fmllegacy/network/NetworkInitialization.java similarity index 95% rename from src/main/java/net/minecraftforge/fml/network/NetworkInitialization.java rename to src/main/java/net/minecraftforge/fmllegacy/network/NetworkInitialization.java index 239949f375..80f51475b6 100644 --- a/src/main/java/net/minecraftforge/fml/network/NetworkInitialization.java +++ b/src/main/java/net/minecraftforge/fmllegacy/network/NetworkInitialization.java @@ -17,11 +17,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.network; +package net.minecraftforge.fmllegacy.network; -import net.minecraftforge.fml.config.ConfigTracker; -import net.minecraftforge.fml.network.event.EventNetworkChannel; -import net.minecraftforge.fml.network.simple.SimpleChannel; +import net.minecraftforge.fmllegacy.network.event.EventNetworkChannel; +import net.minecraftforge.fmllegacy.network.simple.SimpleChannel; import net.minecraftforge.registries.RegistryManager; import java.util.Arrays; @@ -71,7 +70,7 @@ class NetworkInitialization { loginIndex(FMLHandshakeMessages.LoginIndexedMessage::getLoginIndex, FMLHandshakeMessages.LoginIndexedMessage::setLoginIndex). decoder(FMLHandshakeMessages.S2CConfigData::decode). encoder(FMLHandshakeMessages.S2CConfigData::encode). - buildLoginPacketList(ConfigTracker.INSTANCE::syncConfigs). + buildLoginPacketList(ConfigSync.INSTANCE::syncConfigs). consumer(FMLHandshakeHandler.biConsumerFor(FMLHandshakeHandler::handleConfigSync)). add(); diff --git a/src/main/java/net/minecraftforge/fml/network/NetworkInstance.java b/src/main/java/net/minecraftforge/fmllegacy/network/NetworkInstance.java similarity index 90% rename from src/main/java/net/minecraftforge/fml/network/NetworkInstance.java rename to src/main/java/net/minecraftforge/fmllegacy/network/NetworkInstance.java index e508325153..4c4722828a 100644 --- a/src/main/java/net/minecraftforge/fml/network/NetworkInstance.java +++ b/src/main/java/net/minecraftforge/fmllegacy/network/NetworkInstance.java @@ -17,21 +17,17 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.network; +package net.minecraftforge.fmllegacy.network; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.network.NetworkManager; -import net.minecraft.util.ResourceLocation; +import net.minecraft.network.Connection; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.eventbus.api.BusBuilder; import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.IEventListener; -import net.minecraftforge.fml.network.simple.SimpleChannel; import java.util.List; import java.util.function.Consumer; -import java.util.function.Function; import java.util.function.Predicate; import java.util.function.Supplier; @@ -80,7 +76,7 @@ public class NetworkInstance this.networkEventBus.unregister(object); } - boolean dispatch(final NetworkDirection side, final ICustomPacket packet, final NetworkManager manager) + boolean dispatch(final NetworkDirection side, final ICustomPacket packet, final Connection manager) { final NetworkEvent.Context context = new NetworkEvent.Context(manager, side, packet.getIndex()); this.networkEventBus.post(side.getEvent(packet, () -> context)); @@ -111,7 +107,7 @@ public class NetworkInstance this.networkEventBus.post(networkEvent); } - public boolean isRemotePresent(NetworkManager manager) { + public boolean isRemotePresent(Connection manager) { FMLConnectionData connectionData = NetworkHooks.getConnectionData(manager); return connectionData != null && connectionData.getChannels().containsKey(channelName); } diff --git a/src/main/java/net/minecraftforge/fml/network/NetworkRegistry.java b/src/main/java/net/minecraftforge/fmllegacy/network/NetworkRegistry.java similarity index 96% rename from src/main/java/net/minecraftforge/fml/network/NetworkRegistry.java rename to src/main/java/net/minecraftforge/fmllegacy/network/NetworkRegistry.java index b365457842..a589d8bf27 100644 --- a/src/main/java/net/minecraftforge/fml/network/NetworkRegistry.java +++ b/src/main/java/net/minecraftforge/fmllegacy/network/NetworkRegistry.java @@ -17,13 +17,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.network; +package net.minecraftforge.fmllegacy.network; -import net.minecraft.network.NetworkManager; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.network.event.EventNetworkChannel; -import net.minecraftforge.fml.network.simple.SimpleChannel; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.resources.ResourceLocation; +import net.minecraftforge.fmllegacy.network.event.EventNetworkChannel; +import net.minecraftforge.fmllegacy.network.simple.SimpleChannel; import org.apache.commons.lang3.tuple.Pair; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -133,7 +132,6 @@ public class NetworkRegistry return new EventNetworkChannel(createInstance(name, networkProtocolVersion, clientAcceptedVersions, serverAcceptedVersions)); } - /** * Creates the internal {@link NetworkInstance} that tracks the channel data. * @param name registry name @@ -259,7 +257,7 @@ public class NetworkRegistry /** * Retrieve the {@link LoginPayload} list for dispatch during {@link FMLHandshakeHandler#tickLogin(NetworkManager)} handling. - * Dispatches {@link net.minecraftforge.fml.network.NetworkEvent.GatherLoginPayloadsEvent} to each {@link NetworkInstance}. + * Dispatches {@link NetworkEvent.GatherLoginPayloadsEvent} to each {@link NetworkInstance}. * * @return The {@link LoginPayload} list * @param direction the network direction for the request - only gathers for LOGIN_TO_CLIENT @@ -314,13 +312,13 @@ public class NetworkRegistry /** * Tracks individual outbound messages for dispatch to clients during login handling. Gathered by dispatching - * {@link net.minecraftforge.fml.network.NetworkEvent.GatherLoginPayloadsEvent} during early connection handling. + * {@link NetworkEvent.GatherLoginPayloadsEvent} during early connection handling. */ public static class LoginPayload { /** * The data for sending */ - private final PacketBuffer data; + private final FriendlyByteBuf data; /** * A channel which will receive a {@link NetworkEvent.LoginPayloadEvent} from the {@link FMLLoginWrapper} */ @@ -331,13 +329,13 @@ public class NetworkRegistry */ private final String messageContext; - public LoginPayload(final PacketBuffer buffer, final ResourceLocation channelName, final String messageContext) { + public LoginPayload(final FriendlyByteBuf buffer, final ResourceLocation channelName, final String messageContext) { this.data = buffer; this.channelName = channelName; this.messageContext = messageContext; } - public PacketBuffer getData() { + public FriendlyByteBuf getData() { return data; } diff --git a/src/main/java/net/minecraftforge/fml/network/PacketDispatcher.java b/src/main/java/net/minecraftforge/fmllegacy/network/PacketDispatcher.java similarity index 69% rename from src/main/java/net/minecraftforge/fml/network/PacketDispatcher.java rename to src/main/java/net/minecraftforge/fmllegacy/network/PacketDispatcher.java index 0bbb0d02a6..87cf3554c3 100644 --- a/src/main/java/net/minecraftforge/fml/network/PacketDispatcher.java +++ b/src/main/java/net/minecraftforge/fmllegacy/network/PacketDispatcher.java @@ -17,11 +17,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.network; +package net.minecraftforge.fmllegacy.network; -import net.minecraft.network.NetworkManager; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.ResourceLocation; +import net.minecraft.network.Connection; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.resources.ResourceLocation; import org.apache.commons.lang3.tuple.Pair; import java.util.function.BiConsumer; @@ -32,9 +32,9 @@ import java.util.function.BiFunction; * and unwrapped packets. */ public class PacketDispatcher { - BiConsumer packetSink; + BiConsumer packetSink; - PacketDispatcher(final BiConsumer packetSink) { + PacketDispatcher(final BiConsumer packetSink) { this.packetSink = packetSink; } @@ -42,16 +42,16 @@ public class PacketDispatcher { } - public void sendPacket(ResourceLocation resourceLocation, PacketBuffer buffer) { + public void sendPacket(ResourceLocation resourceLocation, FriendlyByteBuf buffer) { packetSink.accept(resourceLocation, buffer); } static class NetworkManagerDispatcher extends PacketDispatcher { - private final NetworkManager manager; + private final Connection manager; private final int packetIndex; - private final BiFunction, ResourceLocation, ICustomPacket> customPacketSupplier; + private final BiFunction, ResourceLocation, ICustomPacket> customPacketSupplier; - NetworkManagerDispatcher(NetworkManager manager, int packetIndex, BiFunction, ResourceLocation, ICustomPacket> customPacketSupplier) { + NetworkManagerDispatcher(Connection manager, int packetIndex, BiFunction, ResourceLocation, ICustomPacket> customPacketSupplier) { super(); this.packetSink = this::dispatchPacket; this.manager = manager; @@ -59,7 +59,7 @@ public class PacketDispatcher { this.customPacketSupplier = customPacketSupplier; } - private void dispatchPacket(final ResourceLocation resourceLocation, final PacketBuffer buffer) { + private void dispatchPacket(final ResourceLocation resourceLocation, final FriendlyByteBuf buffer) { final ICustomPacket packet = this.customPacketSupplier.apply(Pair.of(buffer, packetIndex), resourceLocation); this.manager.send(packet.getThis()); } diff --git a/src/main/java/net/minecraftforge/fml/network/PacketDistributor.java b/src/main/java/net/minecraftforge/fmllegacy/network/PacketDistributor.java similarity index 69% rename from src/main/java/net/minecraftforge/fml/network/PacketDistributor.java rename to src/main/java/net/minecraftforge/fmllegacy/network/PacketDistributor.java index 8c12707ea2..7e161b3884 100644 --- a/src/main/java/net/minecraftforge/fml/network/PacketDistributor.java +++ b/src/main/java/net/minecraftforge/fmllegacy/network/PacketDistributor.java @@ -17,20 +17,21 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.network; +package net.minecraftforge.fmllegacy.network; import net.minecraft.client.Minecraft; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.network.NetworkManager; -import net.minecraft.network.IPacket; +import net.minecraft.world.entity.Entity; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.network.Connection; +import net.minecraft.network.protocol.Packet; import net.minecraft.server.MinecraftServer; -import net.minecraft.util.RegistryKey; -import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; -import net.minecraft.world.server.ServerChunkProvider; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraft.server.level.ServerChunkCache; import net.minecraftforge.fml.LogicalSide; -import net.minecraftforge.fml.LogicalSidedProvider; +import net.minecraftforge.fmllegacy.LogicalSidedProvider; +import net.minecraftforge.fmllegacy.network.simple.SimpleChannel; import java.util.List; import java.util.function.BiFunction; @@ -40,7 +41,7 @@ import java.util.function.Supplier; /** * Means to distribute packets in various ways * - * @see net.minecraftforge.fml.network.simple.SimpleChannel#send(PacketTarget, Object) + * @see SimpleChannel#send(PacketTarget, Object) * * @param */ @@ -50,13 +51,13 @@ public class PacketDistributor { *
* {@link #with(Supplier)} Player */ - public static final PacketDistributor PLAYER = new PacketDistributor<>(PacketDistributor::playerConsumer, NetworkDirection.PLAY_TO_CLIENT); + public static final PacketDistributor PLAYER = new PacketDistributor<>(PacketDistributor::playerConsumer, NetworkDirection.PLAY_TO_CLIENT); /** * Send to everyone in the dimension specified in the Supplier *
* {@link #with(Supplier)} DimensionType */ - public static final PacketDistributor> DIMENSION = new PacketDistributor<>(PacketDistributor::playerListDimConsumer, NetworkDirection.PLAY_TO_CLIENT); + public static final PacketDistributor> DIMENSION = new PacketDistributor<>(PacketDistributor::playerListDimConsumer, NetworkDirection.PLAY_TO_CLIENT); /** * Send to everyone near the {@link TargetPoint} specified in the Supplier *
@@ -92,22 +93,22 @@ public class PacketDistributor { *
* {@link #with(Supplier)} Chunk */ - public static final PacketDistributor TRACKING_CHUNK = new PacketDistributor<>(PacketDistributor::trackingChunk, NetworkDirection.PLAY_TO_CLIENT); + public static final PacketDistributor TRACKING_CHUNK = new PacketDistributor<>(PacketDistributor::trackingChunk, NetworkDirection.PLAY_TO_CLIENT); /** * Send to the supplied list of NetworkManager instances in the Supplier *
* {@link #with(Supplier)} List of NetworkManager */ - public static final PacketDistributor> NMLIST = new PacketDistributor<>(PacketDistributor::networkManagerList, NetworkDirection.PLAY_TO_CLIENT); + public static final PacketDistributor> NMLIST = new PacketDistributor<>(PacketDistributor::networkManagerList, NetworkDirection.PLAY_TO_CLIENT); public static final class TargetPoint { - private final ServerPlayerEntity excluded; + private final ServerPlayer excluded; private final double x; private final double y; private final double z; private final double r2; - private final RegistryKey dim; + private final ResourceKey dim; /** * A target point with excluded entity @@ -119,7 +120,7 @@ public class PacketDistributor { * @param r2 Radius * @param dim DimensionType */ - public TargetPoint(final ServerPlayerEntity excluded, final double x, final double y, final double z, final double r2, final RegistryKey dim) { + public TargetPoint(final ServerPlayer excluded, final double x, final double y, final double z, final double r2, final ResourceKey dim) { this.excluded = excluded; this.x = x; this.y = y; @@ -136,7 +137,7 @@ public class PacketDistributor { * @param r2 Radius * @param dim DimensionType */ - public TargetPoint(final double x, final double y, final double z, final double r2, final RegistryKey dim) { + public TargetPoint(final double x, final double y, final double z, final double r2, final ResourceKey dim) { this.excluded = null; this.x = x; this.y = y; @@ -154,7 +155,7 @@ public class PacketDistributor { * @param dim DimensionType * @return A TargetPoint supplier */ - public static Supplier p(double x, double y, double z, double r2, RegistryKey dim) { + public static Supplier p(double x, double y, double z, double r2, ResourceKey dim) { TargetPoint tp = new TargetPoint(x, y, z, r2, dim); return ()->tp; } @@ -164,18 +165,18 @@ public class PacketDistributor { /** * A Distributor curried with a specific value instance, for actual dispatch * - * @see net.minecraftforge.fml.network.simple.SimpleChannel#send(PacketTarget, Object) + * @see SimpleChannel#send(PacketTarget, Object) * */ public static class PacketTarget { - private final Consumer> packetConsumer; + private final Consumer> packetConsumer; private final PacketDistributor distributor; - PacketTarget(final Consumer> packetConsumer, final PacketDistributor distributor) { + PacketTarget(final Consumer> packetConsumer, final PacketDistributor distributor) { this.packetConsumer = packetConsumer; this.distributor = distributor; } - public void send(IPacket packet) { + public void send(Packet packet) { packetConsumer.accept(packet); } @@ -185,10 +186,10 @@ public class PacketDistributor { } - private final BiFunction, Supplier, Consumer>> functor; + private final BiFunction, Supplier, Consumer>> functor; private final NetworkDirection direction; - public PacketDistributor(BiFunction, Supplier, Consumer>> functor, NetworkDirection direction) { + public PacketDistributor(BiFunction, Supplier, Consumer>> functor, NetworkDirection direction) { this.functor = functor; this.direction = direction; } @@ -213,50 +214,50 @@ public class PacketDistributor { return new PacketTarget(functor.apply(this, ()->null), this); } - private Consumer> playerConsumer(final Supplier entityPlayerMPSupplier) { + private Consumer> playerConsumer(final Supplier entityPlayerMPSupplier) { return p -> entityPlayerMPSupplier.get().connection.connection.send(p); } - private Consumer> playerListDimConsumer(final Supplier> dimensionTypeSupplier) { + private Consumer> playerListDimConsumer(final Supplier> dimensionTypeSupplier) { return p->getServer().getPlayerList().broadcastAll(p, dimensionTypeSupplier.get()); } - private Consumer> playerListAll(final Supplier voidSupplier) { + private Consumer> playerListAll(final Supplier voidSupplier) { return p -> getServer().getPlayerList().broadcastAll(p); } - private Consumer> clientToServer(final Supplier voidSupplier) { + private Consumer> clientToServer(final Supplier voidSupplier) { return p -> Minecraft.getInstance().getConnection().send(p); } - private Consumer> playerListPointConsumer(final Supplier targetPointSupplier) { + private Consumer> playerListPointConsumer(final Supplier targetPointSupplier) { return p -> { final TargetPoint tp = targetPointSupplier.get(); getServer().getPlayerList().broadcast(tp.excluded, tp.x, tp.y, tp.z, tp.r2, tp.dim, p); }; } - private Consumer> trackingEntity(final Supplier entitySupplier) { + private Consumer> trackingEntity(final Supplier entitySupplier) { return p-> { final Entity entity = entitySupplier.get(); - ((ServerChunkProvider)entity.getCommandSenderWorld().getChunkSource()).broadcast(entity, p); + ((ServerChunkCache)entity.getCommandSenderWorld().getChunkSource()).broadcast(entity, p); }; } - private Consumer> trackingEntityAndSelf(final Supplier entitySupplier) { + private Consumer> trackingEntityAndSelf(final Supplier entitySupplier) { return p-> { final Entity entity = entitySupplier.get(); - ((ServerChunkProvider)entity.getCommandSenderWorld().getChunkSource()).broadcastAndSend(entity, p); + ((ServerChunkCache)entity.getCommandSenderWorld().getChunkSource()).broadcastAndSend(entity, p); }; } - private Consumer> trackingChunk(final Supplier chunkPosSupplier) { + private Consumer> trackingChunk(final Supplier chunkPosSupplier) { return p -> { - final Chunk chunk = chunkPosSupplier.get(); - ((ServerChunkProvider)chunk.getLevel().getChunkSource()).chunkMap.getPlayers(chunk.getPos(), false).forEach(e -> e.connection.send(p)); + final LevelChunk chunk = chunkPosSupplier.get(); + ((ServerChunkCache)chunk.getLevel().getChunkSource()).chunkMap.getPlayers(chunk.getPos(), false).forEach(e -> e.connection.send(p)); }; } - private Consumer> networkManagerList(final Supplier> nmListSupplier) { + private Consumer> networkManagerList(final Supplier> nmListSupplier) { return p -> nmListSupplier.get().forEach(nm->nm.send(p)); } diff --git a/src/main/java/net/minecraftforge/fml/network/event/EventNetworkChannel.java b/src/main/java/net/minecraftforge/fmllegacy/network/event/EventNetworkChannel.java similarity index 81% rename from src/main/java/net/minecraftforge/fml/network/event/EventNetworkChannel.java rename to src/main/java/net/minecraftforge/fmllegacy/network/event/EventNetworkChannel.java index 47d6c6218a..a177e287e2 100644 --- a/src/main/java/net/minecraftforge/fml/network/event/EventNetworkChannel.java +++ b/src/main/java/net/minecraftforge/fmllegacy/network/event/EventNetworkChannel.java @@ -17,12 +17,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.network.event; +package net.minecraftforge.fmllegacy.network.event; -import net.minecraft.network.NetworkManager; -import net.minecraftforge.fml.network.NetworkEvent; -import net.minecraftforge.fml.network.NetworkHooks; -import net.minecraftforge.fml.network.NetworkInstance; +import net.minecraft.network.Connection; +import net.minecraftforge.fmllegacy.network.NetworkEvent; +import net.minecraftforge.fmllegacy.network.NetworkInstance; import java.util.function.Consumer; @@ -50,7 +49,7 @@ public class EventNetworkChannel instance.unregisterObject(object); } - public boolean isRemotePresent(NetworkManager manager) { + public boolean isRemotePresent(Connection manager) { return instance.isRemotePresent(manager); } } diff --git a/src/main/java/net/minecraftforge/fml/network/simple/IndexedMessageCodec.java b/src/main/java/net/minecraftforge/fmllegacy/network/simple/IndexedMessageCodec.java similarity index 83% rename from src/main/java/net/minecraftforge/fml/network/simple/IndexedMessageCodec.java rename to src/main/java/net/minecraftforge/fmllegacy/network/simple/IndexedMessageCodec.java index a94ac3088a..f460a7f29a 100644 --- a/src/main/java/net/minecraftforge/fml/network/simple/IndexedMessageCodec.java +++ b/src/main/java/net/minecraftforge/fmllegacy/network/simple/IndexedMessageCodec.java @@ -17,15 +17,15 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.network.simple; +package net.minecraftforge.fmllegacy.network.simple; import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap; import it.unimi.dsi.fastutil.shorts.Short2ObjectArrayMap; -import net.minecraft.network.PacketBuffer; -import net.minecraftforge.fml.network.NetworkDirection; -import net.minecraftforge.fml.network.NetworkEvent; -import net.minecraftforge.fml.network.NetworkHooks; -import net.minecraftforge.fml.network.NetworkInstance; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraftforge.fmllegacy.network.NetworkDirection; +import net.minecraftforge.fmllegacy.network.NetworkEvent; +import net.minecraftforge.fmllegacy.network.NetworkHooks; +import net.minecraftforge.fmllegacy.network.NetworkInstance; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Marker; @@ -65,8 +65,8 @@ public class IndexedMessageCodec @SuppressWarnings("OptionalUsedAsFieldOrParameterType") class MessageHandler { - private final Optional> encoder; - private final Optional> decoder; + private final Optional> encoder; + private final Optional> decoder; private final int index; private final BiConsumer> messageConsumer; private final Class messageType; @@ -74,7 +74,7 @@ public class IndexedMessageCodec private Optional> loginIndexSetter; private Optional> loginIndexGetter; - public MessageHandler(int index, Class messageType, BiConsumer encoder, Function decoder, BiConsumer> messageConsumer, final Optional networkDirection) + public MessageHandler(int index, Class messageType, BiConsumer encoder, Function decoder, BiConsumer> messageConsumer, final Optional networkDirection) { this.index = index; this.messageType = messageType; @@ -115,7 +115,7 @@ public class IndexedMessageCodec } } - private static void tryDecode(PacketBuffer payload, Supplier context, int payloadIndex, MessageHandler codec) + private static void tryDecode(FriendlyByteBuf payload, Supplier context, int payloadIndex, MessageHandler codec) { codec.decoder.map(d->d.apply(payload)). map(p->{ @@ -128,7 +128,7 @@ public class IndexedMessageCodec }).ifPresent(m->codec.messageConsumer.accept(m, context)); } - private static int tryEncode(PacketBuffer target, M message, MessageHandler codec) { + private static int tryEncode(FriendlyByteBuf target, M message, MessageHandler codec) { codec.encoder.ifPresent(encoder->{ target.writeByte(codec.index & 0xff); encoder.accept(message, target); @@ -136,7 +136,7 @@ public class IndexedMessageCodec return codec.loginIndexGetter.orElse(m -> Integer.MIN_VALUE).apply(message); } - public int build(MSG message, PacketBuffer target) + public int build(MSG message, FriendlyByteBuf target) { @SuppressWarnings("unchecked") MessageHandler messageHandler = (MessageHandler)types.get(message.getClass()); @@ -147,7 +147,7 @@ public class IndexedMessageCodec return tryEncode(target, message, messageHandler); } - void consume(PacketBuffer payload, int payloadIndex, Supplier context) { + void consume(FriendlyByteBuf payload, int payloadIndex, Supplier context) { if (payload == null) { LOGGER.error(SIMPLENET, "Received empty payload on channel {}", Optional.ofNullable(networkInstance).map(NetworkInstance::getChannelName).map(Objects::toString).orElse("MISSING CHANNEL")); return; @@ -162,7 +162,7 @@ public class IndexedMessageCodec tryDecode(payload, context, payloadIndex, messageHandler); } - MessageHandler addCodecIndex(int index, Class messageType, BiConsumer encoder, Function decoder, BiConsumer> messageConsumer, final Optional networkDirection) { + MessageHandler addCodecIndex(int index, Class messageType, BiConsumer encoder, Function decoder, BiConsumer> messageConsumer, final Optional networkDirection) { return new MessageHandler<>(index, messageType, encoder, decoder, messageConsumer, networkDirection); } } diff --git a/src/main/java/net/minecraftforge/fml/network/simple/SimpleChannel.java b/src/main/java/net/minecraftforge/fmllegacy/network/simple/SimpleChannel.java similarity index 85% rename from src/main/java/net/minecraftforge/fml/network/simple/SimpleChannel.java rename to src/main/java/net/minecraftforge/fmllegacy/network/simple/SimpleChannel.java index 5bb447fd18..2754e0c42d 100644 --- a/src/main/java/net/minecraftforge/fml/network/simple/SimpleChannel.java +++ b/src/main/java/net/minecraftforge/fmllegacy/network/simple/SimpleChannel.java @@ -17,15 +17,17 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.network.simple; +package net.minecraftforge.fmllegacy.network.simple; import io.netty.buffer.Unpooled; import net.minecraft.client.Minecraft; -import net.minecraft.network.NetworkManager; -import net.minecraft.network.IPacket; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.text.StringTextComponent; -import net.minecraftforge.fml.network.*; +import net.minecraft.network.Connection; +import net.minecraft.network.protocol.Packet; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraftforge.fmllegacy.network.NetworkDirection; +import net.minecraftforge.fmllegacy.network.NetworkEvent; +import net.minecraftforge.fmllegacy.network.NetworkInstance; +import net.minecraftforge.fmllegacy.network.PacketDistributor; import org.apache.commons.lang3.tuple.Pair; import java.util.ArrayList; @@ -66,7 +68,7 @@ public class SimpleChannel private void networkLoginGather(final NetworkEvent.GatherLoginPayloadsEvent gatherEvent) { loginPackets.forEach(packetGenerator->{ packetGenerator.apply(gatherEvent.isLocal()).forEach(p->{ - PacketBuffer pb = new PacketBuffer(Unpooled.buffer()); + FriendlyByteBuf pb = new FriendlyByteBuf(Unpooled.buffer()); this.indexedCodec.build(p.getRight(), pb); gatherEvent.add(pb, this.instance.getChannelName(), p.getLeft()); }); @@ -81,20 +83,20 @@ public class SimpleChannel } } - public int encodeMessage(MSG message, final PacketBuffer target) { + public int encodeMessage(MSG message, final FriendlyByteBuf target) { return this.indexedCodec.build(message, target); } - public IndexedMessageCodec.MessageHandler registerMessage(int index, Class messageType, BiConsumer encoder, Function decoder, BiConsumer> messageConsumer) { + public IndexedMessageCodec.MessageHandler registerMessage(int index, Class messageType, BiConsumer encoder, Function decoder, BiConsumer> messageConsumer) { return registerMessage(index, messageType, encoder, decoder, messageConsumer, Optional.empty()); } - public IndexedMessageCodec.MessageHandler registerMessage(int index, Class messageType, BiConsumer encoder, Function decoder, BiConsumer> messageConsumer, final Optional networkDirection) { + public IndexedMessageCodec.MessageHandler registerMessage(int index, Class messageType, BiConsumer encoder, Function decoder, BiConsumer> messageConsumer, final Optional networkDirection) { return this.indexedCodec.addCodecIndex(index, messageType, encoder, decoder, messageConsumer, networkDirection); } - private Pair toBuffer(MSG msg) { - final PacketBuffer bufIn = new PacketBuffer(Unpooled.buffer()); + private Pair toBuffer(MSG msg) { + final FriendlyByteBuf bufIn = new FriendlyByteBuf(Unpooled.buffer()); int index = encodeMessage(msg, bufIn); return Pair.of(bufIn, index); } @@ -104,7 +106,7 @@ public class SimpleChannel sendTo(message, Minecraft.getInstance().getConnection().getConnection(), NetworkDirection.PLAY_TO_SERVER); } - public void sendTo(MSG message, NetworkManager manager, NetworkDirection direction) + public void sendTo(MSG message, Connection manager, NetworkDirection direction) { manager.send(toVanillaPacket(message, direction)); } @@ -124,7 +126,7 @@ public class SimpleChannel target.send(toVanillaPacket(message, target.getDirection())); } - public IPacket toVanillaPacket(MSG message, NetworkDirection direction) + public Packet toVanillaPacket(MSG message, NetworkDirection direction) { return direction.buildPacket(toBuffer(message), instance.getChannelName()).getThis(); } @@ -137,7 +139,7 @@ public class SimpleChannel /** * Returns true if the channel is present in the given connection. */ - public boolean isRemotePresent(NetworkManager manager) { + public boolean isRemotePresent(Connection manager) { return instance.isRemotePresent(manager); } @@ -171,8 +173,8 @@ public class SimpleChannel private SimpleChannel channel; private Class type; private int id; - private BiConsumer encoder; - private Function decoder; + private BiConsumer encoder; + private Function decoder; private BiConsumer> consumer; private Function loginIndexGetter; private BiConsumer loginIndexSetter; @@ -188,12 +190,12 @@ public class SimpleChannel return builder; } - public MessageBuilder encoder(BiConsumer encoder) { + public MessageBuilder encoder(BiConsumer encoder) { this.encoder = encoder; return this; } - public MessageBuilder decoder(Function decoder) { + public MessageBuilder decoder(Function decoder) { this.decoder = decoder; return this; } diff --git a/src/main/java/net/minecraftforge/fml/packs/DelegatingResourcePack.java b/src/main/java/net/minecraftforge/fmllegacy/packs/DelegatingResourcePack.java similarity index 61% rename from src/main/java/net/minecraftforge/fml/packs/DelegatingResourcePack.java rename to src/main/java/net/minecraftforge/fmllegacy/packs/DelegatingResourcePack.java index 3674255652..2b87cc9a22 100644 --- a/src/main/java/net/minecraftforge/fml/packs/DelegatingResourcePack.java +++ b/src/main/java/net/minecraftforge/fmllegacy/packs/DelegatingResourcePack.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.packs; +package net.minecraftforge.fmllegacy.packs; import java.io.File; import java.io.IOException; @@ -28,38 +28,38 @@ import java.util.stream.Collectors; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import net.minecraft.resources.IResourcePack; -import net.minecraft.resources.ResourcePack; -import net.minecraft.resources.ResourcePackFileNotFoundException; -import net.minecraft.resources.ResourcePackType; -import net.minecraft.resources.data.IMetadataSectionSerializer; -import net.minecraft.resources.data.PackMetadataSection; -import net.minecraft.util.ResourceLocation; +import net.minecraft.server.packs.PackResources; +import net.minecraft.server.packs.AbstractPackResources; +import net.minecraft.server.packs.ResourcePackFileNotFoundException; +import net.minecraft.server.packs.PackType; +import net.minecraft.server.packs.metadata.MetadataSectionSerializer; +import net.minecraft.server.packs.metadata.pack.PackMetadataSection; +import net.minecraft.resources.ResourceLocation; -public class DelegatingResourcePack extends ResourcePack +public class DelegatingResourcePack extends AbstractPackResources { - private final List delegates; - private final Map> namespacesAssets; - private final Map> namespacesData; + private final List delegates; + private final Map> namespacesAssets; + private final Map> namespacesData; private final String name; private final PackMetadataSection packInfo; - public DelegatingResourcePack(String id, String name, PackMetadataSection packInfo, List packs) + public DelegatingResourcePack(String id, String name, PackMetadataSection packInfo, List packs) { super(new File(id)); this.name = name; this.packInfo = packInfo; this.delegates = ImmutableList.copyOf(packs); - this.namespacesAssets = this.buildNamespaceMap(ResourcePackType.CLIENT_RESOURCES, delegates); - this.namespacesData = this.buildNamespaceMap(ResourcePackType.SERVER_DATA, delegates); + this.namespacesAssets = this.buildNamespaceMap(PackType.CLIENT_RESOURCES, delegates); + this.namespacesData = this.buildNamespaceMap(PackType.SERVER_DATA, delegates); } - private Map> buildNamespaceMap(ResourcePackType type, List packList) + private Map> buildNamespaceMap(PackType type, List packList) { - Map> map = new HashMap<>(); - for (IResourcePack pack : packList) + Map> map = new HashMap<>(); + for (PackResources pack : packList) { for (String namespace : pack.getNamespaces(type)) { @@ -78,7 +78,7 @@ public class DelegatingResourcePack extends ResourcePack @SuppressWarnings("unchecked") @Override - public T getMetadataSection(IMetadataSectionSerializer deserializer) throws IOException + public T getMetadataSection(MetadataSectionSerializer deserializer) throws IOException { if (deserializer.getMetadataSectionName().equals("pack")) { @@ -88,7 +88,7 @@ public class DelegatingResourcePack extends ResourcePack } @Override - public Collection getResources(ResourcePackType type, String pathIn, String pathIn2, int maxDepth, Predicate filter) + public Collection getResources(PackType type, String pathIn, String pathIn2, int maxDepth, Predicate filter) { return delegates.stream() .flatMap(r -> r.getResources(type, pathIn, pathIn2, maxDepth, filter).stream()) @@ -96,15 +96,15 @@ public class DelegatingResourcePack extends ResourcePack } @Override - public Set getNamespaces(ResourcePackType type) + public Set getNamespaces(PackType type) { - return type == ResourcePackType.CLIENT_RESOURCES ? namespacesAssets.keySet() : namespacesData.keySet(); + return type == PackType.CLIENT_RESOURCES ? namespacesAssets.keySet() : namespacesData.keySet(); } @Override public void close() { - for (IResourcePack pack : delegates) + for (PackResources pack : delegates) { pack.close(); } @@ -132,9 +132,9 @@ public class DelegatingResourcePack extends ResourcePack } @Override - public InputStream getResource(ResourcePackType type, ResourceLocation location) throws IOException + public InputStream getResource(PackType type, ResourceLocation location) throws IOException { - for (IResourcePack pack : getCandidatePacks(type, location)) + for (PackResources pack : getCandidatePacks(type, location)) { if (pack.hasResource(type, location)) { @@ -145,9 +145,9 @@ public class DelegatingResourcePack extends ResourcePack } @Override - public boolean hasResource(ResourcePackType type, ResourceLocation location) + public boolean hasResource(PackType type, ResourceLocation location) { - for (IResourcePack pack : getCandidatePacks(type, location)) + for (PackResources pack : getCandidatePacks(type, location)) { if (pack.hasResource(type, location)) { @@ -157,14 +157,14 @@ public class DelegatingResourcePack extends ResourcePack return false; } - private List getCandidatePacks(ResourcePackType type, ResourceLocation location) + private List getCandidatePacks(PackType type, ResourceLocation location) { - Map> map = type == ResourcePackType.CLIENT_RESOURCES ? namespacesAssets : namespacesData; - List packsWithNamespace = map.get(location.getNamespace()); + Map> map = type == PackType.CLIENT_RESOURCES ? namespacesAssets : namespacesData; + List packsWithNamespace = map.get(location.getNamespace()); return packsWithNamespace == null ? Collections.emptyList() : packsWithNamespace; } - private static String getFullPath(ResourcePackType type, ResourceLocation location) + private static String getFullPath(PackType type, ResourceLocation location) { // stolen from ResourcePack return String.format("%s/%s/%s", type.getDirectory(), location.getNamespace(), location.getPath()); diff --git a/src/main/java/net/minecraftforge/fml/packs/ModFileResourcePack.java b/src/main/java/net/minecraftforge/fmllegacy/packs/ModFileResourcePack.java similarity index 53% rename from src/main/java/net/minecraftforge/fml/packs/ModFileResourcePack.java rename to src/main/java/net/minecraftforge/fmllegacy/packs/ModFileResourcePack.java index 088bf7e68c..23482ce84a 100644 --- a/src/main/java/net/minecraftforge/fml/packs/ModFileResourcePack.java +++ b/src/main/java/net/minecraftforge/fmllegacy/packs/ModFileResourcePack.java @@ -17,14 +17,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.packs; +package net.minecraftforge.fmllegacy.packs; -import net.minecraft.resources.ResourcePack; -import net.minecraft.resources.ResourcePackFileNotFoundException; -import net.minecraft.resources.ResourcePackInfo; -import net.minecraft.resources.ResourcePackType; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.loading.moddiscovery.ModFile; +import net.minecraft.server.packs.AbstractPackResources; +import net.minecraft.server.packs.ResourcePackFileNotFoundException; +import net.minecraft.server.packs.repository.Pack; +import net.minecraft.server.packs.PackType; +import net.minecraft.resources.ResourceLocation; import java.io.File; import java.io.IOException; @@ -39,19 +38,20 @@ import java.util.function.Predicate; import java.util.stream.Collectors; import com.google.common.base.Joiner; +import net.minecraftforge.forgespi.locating.IModFile; -public class ModFileResourcePack extends ResourcePack +public class ModFileResourcePack extends AbstractPackResources { - private final ModFile modFile; - private ResourcePackInfo packInfo; + private final IModFile modFile; + private Pack packInfo; - public ModFileResourcePack(final ModFile modFile) + public ModFileResourcePack(final IModFile modFile) { super(new File("dummy")); this.modFile = modFile; } - public ModFile getModFile() { + public IModFile getModFile() { return this.modFile; } @@ -64,7 +64,7 @@ public class ModFileResourcePack extends ResourcePack @Override protected InputStream getResource(String name) throws IOException { - final Path path = modFile.getLocator().findPath(modFile, name); + final Path path = modFile.findResource(name); if(!Files.exists(path)) throw new ResourcePackFileNotFoundException(modFile.getFilePath().toFile(), name); return Files.newInputStream(path, StandardOpenOption.READ); @@ -73,29 +73,26 @@ public class ModFileResourcePack extends ResourcePack @Override protected boolean hasResource(String name) { - return Files.exists(modFile.getLocator().findPath(modFile, name)); + return Files.exists(modFile.findResource(name)); } @Override - public Collection getResources(ResourcePackType type, String resourceNamespace, String pathIn, int maxDepth, Predicate filter) + public Collection getResources(PackType type, String resourceNamespace, String pathIn, int maxDepth, Predicate filter) { try { - Path root = modFile.getLocator().findPath(modFile, type.getDirectory(), resourceNamespace).toAbsolutePath(); + Path root = modFile.findResource(type.getDirectory(), resourceNamespace).toAbsolutePath(); Path inputPath = root.getFileSystem().getPath(pathIn); - return Files.walk(root). - map(path -> root.relativize(path.toAbsolutePath())). - filter(path -> path.getNameCount() <= maxDepth). // Make sure the depth is within bounds - filter(path -> !path.toString().endsWith(".mcmeta")). // Ignore .mcmeta files - filter(path -> path.startsWith(inputPath)). // Make sure the target path is inside this one - filter(path -> filter.test(path.getFileName().toString())). // Test the file name against the predicate - // Finally we need to form the RL, so use the first name as the domain, and the rest as the path + return Files.walk(root) + .map(root::relativize) + .filter(path -> path.getNameCount() <= maxDepth && !path.toString().endsWith(".mcmeta") && path.startsWith(inputPath)) + .filter(path -> filter.test(path.getFileName().toString())) // It is VERY IMPORTANT that we do not rely on Path.toString as this is inconsistent between operating systems // Join the path names ourselves to force forward slashes - map(path -> new ResourceLocation(resourceNamespace, Joiner.on('/').join(path))). - collect(Collectors.toList()); + .map(path -> new ResourceLocation(resourceNamespace, Joiner.on('/').join(path))) + .collect(Collectors.toList()); } catch (IOException e) { @@ -104,12 +101,12 @@ public class ModFileResourcePack extends ResourcePack } @Override - public Set getNamespaces(ResourcePackType type) + public Set getNamespaces(PackType type) { try { - Path root = modFile.getLocator().findPath(modFile, type.getDirectory()).toAbsolutePath(); + Path root = modFile.findResource(type.getDirectory()); return Files.walk(root,1) - .map(path -> root.relativize(path.toAbsolutePath())) + .map(path -> root.relativize(path)) .filter(path -> path.getNameCount() > 0) // skip the root entry .map(p->p.toString().replaceAll("/$","")) // remove the trailing slash, if present .filter(s -> !s.isEmpty()) //filter empty strings, otherwise empty strings default to minecraft in ResourceLocations @@ -117,9 +114,9 @@ public class ModFileResourcePack extends ResourcePack } catch (IOException e) { - if (type == ResourcePackType.SERVER_DATA) //We still have to add the resource namespace if client resources exist, as we load langs (which are in assets) on server + if (type == PackType.SERVER_DATA) //We still have to add the resource namespace if client resources exist, as we load langs (which are in assets) on server { - return this.getNamespaces(ResourcePackType.CLIENT_RESOURCES); + return this.getNamespaces(PackType.CLIENT_RESOURCES); } else { @@ -128,17 +125,17 @@ public class ModFileResourcePack extends ResourcePack } } - public InputStream getResource(ResourcePackType type, ResourceLocation location) throws IOException { + public InputStream getResource(PackType type, ResourceLocation location) throws IOException { if (location.getPath().startsWith("lang/")) { - return super.getResource(ResourcePackType.CLIENT_RESOURCES, location); + return super.getResource(PackType.CLIENT_RESOURCES, location); } else { return super.getResource(type, location); } } - public boolean hasResource(ResourcePackType type, ResourceLocation location) { + public boolean hasResource(PackType type, ResourceLocation location) { if (location.getPath().startsWith("lang/")) { - return super.hasResource(ResourcePackType.CLIENT_RESOURCES, location); + return super.hasResource(PackType.CLIENT_RESOURCES, location); } else { return super.hasResource(type, location); } @@ -150,11 +147,11 @@ public class ModFileResourcePack extends ResourcePack } - void setPackInfo(final T packInfo) { + void setPackInfo(final T packInfo) { this.packInfo = packInfo; } - T getPackInfo() { + T getPackInfo() { return (T)this.packInfo; } } diff --git a/src/main/java/net/minecraftforge/fml/packs/ResourcePackLoader.java b/src/main/java/net/minecraftforge/fmllegacy/packs/ResourcePackLoader.java similarity index 66% rename from src/main/java/net/minecraftforge/fml/packs/ResourcePackLoader.java rename to src/main/java/net/minecraftforge/fmllegacy/packs/ResourcePackLoader.java index fbbc19f144..25684ad1c8 100644 --- a/src/main/java/net/minecraftforge/fml/packs/ResourcePackLoader.java +++ b/src/main/java/net/minecraftforge/fmllegacy/packs/ResourcePackLoader.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.packs; +package net.minecraftforge.fmllegacy.packs; import java.util.ArrayList; import java.util.Comparator; @@ -34,37 +34,34 @@ import java.util.stream.Collectors; import it.unimi.dsi.fastutil.objects.Object2IntMap; import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; -import net.minecraft.resources.IPackFinder; -import net.minecraft.resources.ResourcePackInfo; -import net.minecraft.resources.ResourcePackInfo.IFactory; -import net.minecraft.resources.ResourcePackList; +import net.minecraft.server.packs.repository.RepositorySource; +import net.minecraft.server.packs.repository.Pack; +import net.minecraft.server.packs.repository.Pack.PackConstructor; +import net.minecraft.server.packs.repository.PackRepository; import net.minecraftforge.fml.ModList; -import net.minecraftforge.fml.loading.moddiscovery.ModFile; -import net.minecraftforge.fml.loading.moddiscovery.ModFileInfo; +import net.minecraftforge.forgespi.language.IModFileInfo; +import net.minecraftforge.forgespi.locating.IModFile; -public class ResourcePackLoader -{ - private static Map modResourcePacks; - private static ResourcePackList resourcePackList; +public class ResourcePackLoader { + private static Map modResourcePacks; + private static PackRepository resourcePackList; - public static Optional getResourcePackFor(String modId) - { + public static Optional getResourcePackFor(String modId) { return Optional.ofNullable(ModList.get().getModFileById(modId)). - map(ModFileInfo::getFile).map(mf->modResourcePacks.get(mf)); + map(IModFileInfo::getFile).map(mf->modResourcePacks.get(mf)); } - public static void loadResourcePacks(ResourcePackList resourcePacks, BiFunction, BiConsumer, IPackInfoFinder> packFinder) { + public static void loadResourcePacks(PackRepository resourcePacks, BiFunction, BiConsumer, IPackInfoFinder> packFinder) { resourcePackList = resourcePacks; modResourcePacks = ModList.get().getModFiles().stream() - .filter(mf->!Objects.equals(mf.getModLoader(),"minecraft")) + .filter(mf->mf.requiredLanguageLoaders().stream().noneMatch(ls->ls.languageName().equals("minecraft"))) .map(mf -> new ModFileResourcePack(mf.getFile())) .collect(Collectors.toMap(ModFileResourcePack::getModFile, Function.identity(), (u,v) -> { throw new IllegalStateException(String.format("Duplicate key %s", u)); }, LinkedHashMap::new)); resourcePacks.addPackFinder(new LambdaFriendlyPackFinder(packFinder.apply(modResourcePacks, ModFileResourcePack::setPackInfo))); } - public static List getPackNames() - { - return ModList.get().applyForEachModFile(mf->"mod:"+mf.getModInfos().get(0).getModId()).filter(n->!n.equals("mod:minecraft")).collect(Collectors.toList()); + public static List getPackNames() { + return ModList.get().applyForEachModFile(mf->"mod:"+mf.getModInfos().get(0).getModId()).collect(Collectors.toList()); } public static Comparator> getSorter() { @@ -72,12 +69,11 @@ public class ResourcePackLoader order.add("vanilla"); order.add("mod_resources"); - ModList.get().getModFiles().stream(). - filter(mf -> !Objects.equals(mf.getModLoader(), "minecraft")). - map(e -> e.getMods().get(0).getModId()). - filter(e -> !"minecraft".equals(e)). - map(e -> "mod:" + e). - forEach(order::add); + ModList.get().getModFiles().stream() + .filter(mf -> mf.requiredLanguageLoaders().stream().noneMatch(ls->ls.languageName().equals("minecraft"))) + .map(e -> e.getMods().get(0).getModId()) + .map(e -> "mod:" + e) + .forEach(order::add); final Object2IntMap order_f = new Object2IntOpenHashMap<>(order.size()); for (int x = 0; x < order.size(); x++) @@ -98,12 +94,12 @@ public class ResourcePackLoader } public interface IPackInfoFinder { - void addPackInfos(Consumer consumer, IFactory factory); + void addPackInfos(Consumer consumer, PackConstructor factory); } // SO GROSS - DON'T @ me bro @SuppressWarnings("unchecked") - private static class LambdaFriendlyPackFinder implements IPackFinder { + private static class LambdaFriendlyPackFinder implements RepositorySource { private IPackInfoFinder wrapped; private LambdaFriendlyPackFinder(final IPackInfoFinder wrapped) { @@ -111,8 +107,7 @@ public class ResourcePackLoader } @Override - public void loadPacks(Consumer consumer, IFactory factory) - { + public void loadPacks(Consumer consumer, PackConstructor factory) { wrapped.addPackInfos(consumer, factory); } } diff --git a/src/main/java/net/minecraftforge/fml/server/LanguageHook.java b/src/main/java/net/minecraftforge/fmllegacy/server/LanguageHook.java similarity index 83% rename from src/main/java/net/minecraftforge/fml/server/LanguageHook.java rename to src/main/java/net/minecraftforge/fmllegacy/server/LanguageHook.java index 9f1a113689..7af0709a0c 100644 --- a/src/main/java/net/minecraftforge/fml/server/LanguageHook.java +++ b/src/main/java/net/minecraftforge/fmllegacy/server/LanguageHook.java @@ -17,17 +17,17 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.server; +package net.minecraftforge.fmllegacy.server; import com.google.gson.Gson; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import net.minecraft.resources.IResource; -import net.minecraft.resources.IResourceManager; +import net.minecraft.server.packs.resources.Resource; +import net.minecraft.server.packs.resources.ResourceManager; import net.minecraft.server.MinecraftServer; -import net.minecraft.util.JSONUtils; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.ForgeI18n; +import net.minecraft.util.GsonHelper; +import net.minecraft.resources.ResourceLocation; +import net.minecraftforge.fmllegacy.ForgeI18n; import org.apache.commons.io.IOUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -58,18 +58,18 @@ public class LanguageHook } // The below is based on client side net.minecraft.client.resources.Locale code - private static void loadLocaleData(final List allResources) { - allResources.stream().map(IResource::getInputStream).forEach(LanguageHook::loadLocaleData); + private static void loadLocaleData(final List allResources) { + allResources.stream().map(Resource::getInputStream).forEach(LanguageHook::loadLocaleData); } private static void loadLocaleData(final InputStream inputstream) { try { JsonElement jsonelement = GSON.fromJson(new InputStreamReader(inputstream, StandardCharsets.UTF_8), JsonElement.class); - JsonObject jsonobject = JSONUtils.convertToJsonObject(jsonelement, "strings"); + JsonObject jsonobject = GsonHelper.convertToJsonObject(jsonelement, "strings"); jsonobject.entrySet().forEach(entry -> { - String s = PATTERN.matcher(JSONUtils.convertToString(entry.getValue(), entry.getKey())).replaceAll("%$1s"); + String s = PATTERN.matcher(GsonHelper.convertToString(entry.getValue(), entry.getKey())).replaceAll("%$1s"); modTable.put(entry.getKey(), s); }); } @@ -81,7 +81,7 @@ public class LanguageHook private static void loadLanguage(String langName, MinecraftServer server) { String langFile = String.format("lang/%s.json", langName); - IResourceManager resourceManager = server.getDataPackRegistries().getResourceManager(); + ResourceManager resourceManager = server.getServerResources().getResourceManager(); resourceManager.getNamespaces().forEach(namespace -> { try { ResourceLocation langResource = new ResourceLocation(namespace, langFile); diff --git a/src/main/java/net/minecraftforge/fml/server/ServerLifecycleHooks.java b/src/main/java/net/minecraftforge/fmllegacy/server/ServerLifecycleHooks.java similarity index 71% rename from src/main/java/net/minecraftforge/fml/server/ServerLifecycleHooks.java rename to src/main/java/net/minecraftforge/fmllegacy/server/ServerLifecycleHooks.java index edd51f1ba7..aea2108c7e 100644 --- a/src/main/java/net/minecraftforge/fml/server/ServerLifecycleHooks.java +++ b/src/main/java/net/minecraftforge/fmllegacy/server/ServerLifecycleHooks.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.server; +package net.minecraftforge.fmllegacy.server; import static net.minecraftforge.fml.Logging.CORE; @@ -30,43 +30,43 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.BiConsumer; import java.util.function.Consumer; -import net.minecraft.resources.IPackNameDecorator; -import net.minecraft.world.storage.FolderName; +import net.minecraft.server.packs.repository.PackSource; +import net.minecraft.world.level.storage.LevelResource; import net.minecraftforge.fml.DistExecutor; -import net.minecraftforge.fml.LogicalSidedProvider; +import net.minecraftforge.fmllegacy.LogicalSidedProvider; import net.minecraftforge.fml.ModLoader; import net.minecraftforge.fml.ModLoadingStage; import net.minecraftforge.fml.ModLoadingWarning; -import net.minecraftforge.fml.network.ConnectionType; -import net.minecraftforge.fml.network.FMLNetworkConstants; -import net.minecraftforge.fml.network.FMLStatusPing; -import net.minecraftforge.fml.network.NetworkHooks; -import net.minecraftforge.fml.network.NetworkRegistry; +import net.minecraftforge.fmllegacy.network.ConnectionType; +import net.minecraftforge.fmllegacy.network.FMLNetworkConstants; +import net.minecraftforge.fmllegacy.network.FMLStatusPing; +import net.minecraftforge.fmllegacy.network.NetworkHooks; +import net.minecraftforge.fmllegacy.network.NetworkRegistry; +import net.minecraftforge.fmllegacy.packs.ModFileResourcePack; +import net.minecraftforge.fmllegacy.packs.ResourcePackLoader; +import net.minecraftforge.forgespi.locating.IModFile; 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 net.minecraft.network.NetworkManager; -import net.minecraft.network.ProtocolType; -import net.minecraft.network.handshake.client.CHandshakePacket; -import net.minecraft.network.login.server.SDisconnectLoginPacket; -import net.minecraft.resources.ResourcePackInfo; +import net.minecraft.network.Connection; +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.MinecraftServer; -import net.minecraft.util.text.StringTextComponent; +import net.minecraft.network.chat.TextComponent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.config.ConfigTracker; import net.minecraftforge.fml.config.ModConfig; -import net.minecraftforge.fml.event.server.FMLServerAboutToStartEvent; -import net.minecraftforge.fml.event.server.FMLServerStartedEvent; -import net.minecraftforge.fml.event.server.FMLServerStartingEvent; -import net.minecraftforge.fml.event.server.FMLServerStoppedEvent; -import net.minecraftforge.fml.event.server.FMLServerStoppingEvent; +import net.minecraftforge.fmlserverevents.FMLServerAboutToStartEvent; +import net.minecraftforge.fmlserverevents.FMLServerStartedEvent; +import net.minecraftforge.fmlserverevents.FMLServerStartingEvent; +import net.minecraftforge.fmlserverevents.FMLServerStoppedEvent; +import net.minecraftforge.fmlserverevents.FMLServerStoppingEvent; import net.minecraftforge.fml.loading.FileUtils; -import net.minecraftforge.fml.loading.moddiscovery.ModFile; -import net.minecraftforge.fml.packs.ModFileResourcePack; -import net.minecraftforge.fml.packs.ResourcePackLoader; import net.minecraftforge.forgespi.language.IModInfo; import net.minecraftforge.registries.GameData; @@ -74,7 +74,7 @@ public class ServerLifecycleHooks { private static final Logger LOGGER = LogManager.getLogger(); private static final Marker SERVERHOOKS = MarkerManager.getMarker("SERVERHOOKS"); - private static final FolderName SERVERCONFIG = new FolderName("serverconfig"); + private static final LevelResource SERVERCONFIG = new LevelResource("serverconfig"); private static volatile CountDownLatch exitLatch = null; private static MinecraftServer currentServer; @@ -140,17 +140,17 @@ public class ServerLifecycleHooks } private static AtomicBoolean allowLogins = new AtomicBoolean(false); - public static boolean handleServerLogin(final CHandshakePacket packet, final NetworkManager manager) { + public static boolean handleServerLogin(final ClientIntentionPacket packet, final Connection manager) { if (!allowLogins.get()) { - StringTextComponent text = new StringTextComponent("Server is still starting! Please wait before reconnecting."); + TextComponent text = new TextComponent("Server is still starting! Please wait before reconnecting."); LOGGER.info(SERVERHOOKS,"Disconnecting Player (server is still starting): {}", text.getContents()); - manager.send(new SDisconnectLoginPacket(text)); + manager.send(new ClientboundLoginDisconnectPacket(text)); manager.disconnect(text); return false; } - if (packet.getIntention() == ProtocolType.LOGIN) { + if (packet.getIntention() == ConnectionProtocol.LOGIN) { final ConnectionType connectionType = ConnectionType.forVersionFlag(packet.getFMLVersion()); final int versionNumber = connectionType.getFMLVersionNumber(packet.getFMLVersion()); @@ -165,18 +165,18 @@ public class ServerLifecycleHooks } } - if (packet.getIntention() == ProtocolType.STATUS) return true; + if (packet.getIntention() == ConnectionProtocol.STATUS) return true; NetworkHooks.registerServerLoginChannel(manager, packet); return true; } - private static void rejectConnection(final NetworkManager manager, ConnectionType type, String message) { - manager.setProtocol(ProtocolType.LOGIN); + private static void rejectConnection(final Connection manager, ConnectionType type, String message) { + manager.setProtocol(ConnectionProtocol.LOGIN); LOGGER.info(SERVERHOOKS, "Disconnecting {} connection attempt: {}", type, message); - StringTextComponent text = new StringTextComponent(message); - manager.send(new SDisconnectLoginPacket(text)); + TextComponent text = new TextComponent(message); + manager.send(new ClientboundLoginDisconnectPacket(text)); manager.disconnect(text); } @@ -187,17 +187,17 @@ public class ServerLifecycleHooks //INTERNAL MODDERS DO NOT USE @Deprecated - public static ResourcePackLoader.IPackInfoFinder buildPackFinder(Map modResourcePacks, BiConsumer packSetter) { + public static ResourcePackLoader.IPackInfoFinder buildPackFinder(Map modResourcePacks, BiConsumer packSetter) { return (packList, factory) -> serverPackFinder(modResourcePacks, packSetter, packList, factory); } - private static void serverPackFinder(Map modResourcePacks, BiConsumer packSetter, Consumer consumer, ResourcePackInfo.IFactory factory) { - for (Entry e : modResourcePacks.entrySet()) + private static void serverPackFinder(Map modResourcePacks, BiConsumer packSetter, Consumer consumer, Pack.PackConstructor factory) { + for (Entry e : modResourcePacks.entrySet()) { 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 ResourcePackInfo packInfo = ResourcePackInfo.create(name, false, e::getValue, factory, ResourcePackInfo.Priority.BOTTOM, IPackNameDecorator.DEFAULT); + final Pack packInfo = Pack.create(name, false, e::getValue, factory, Pack.Position.BOTTOM, PackSource.DEFAULT); if (packInfo == 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/fml/server/ServerModLoader.java b/src/main/java/net/minecraftforge/fmllegacy/server/ServerModLoader.java similarity index 89% rename from src/main/java/net/minecraftforge/fml/server/ServerModLoader.java rename to src/main/java/net/minecraftforge/fmllegacy/server/ServerModLoader.java index 3d16347664..0f2c7d0e68 100644 --- a/src/main/java/net/minecraftforge/fml/server/ServerModLoader.java +++ b/src/main/java/net/minecraftforge/fmllegacy/server/ServerModLoader.java @@ -17,18 +17,19 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.server; +package net.minecraftforge.fmllegacy.server; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.*; +import net.minecraftforge.fmllegacy.CrashReportExtender; +import net.minecraftforge.fmllegacy.LogicalSidedProvider; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.io.File; import java.util.List; -import java.util.concurrent.CompletableFuture; -import static net.minecraftforge.fml.loading.LogMarkers.LOADING; +import static net.minecraftforge.fml.Logging.LOADING; public class ServerModLoader { @@ -42,7 +43,7 @@ public class ServerModLoader LanguageHook.loadForgeAndMCLangs(); try { ModLoader.get().gatherAndInitializeMods(ModWorkManager.syncExecutor(), ModWorkManager.parallelExecutor(), ()->{}); - ModLoader.get().loadMods(ModWorkManager.syncExecutor(), ModWorkManager.parallelExecutor(), e-> CompletableFuture.runAsync(()->{}, e), e->CompletableFuture.runAsync(()->{}, e), ()->{}); + ModLoader.get().loadMods(ModWorkManager.syncExecutor(), ModWorkManager.parallelExecutor(), ()->{}); ModLoader.get().finishMods(ModWorkManager.syncExecutor(), ModWorkManager.parallelExecutor(), ()->{}); } catch (LoadingFailedException error) { ServerModLoader.hasErrors = true; diff --git a/src/main/java/net/minecraftforge/fml/util/ThreeConsumer.java b/src/main/java/net/minecraftforge/fmllegacy/util/ThreeConsumer.java similarity index 97% rename from src/main/java/net/minecraftforge/fml/util/ThreeConsumer.java rename to src/main/java/net/minecraftforge/fmllegacy/util/ThreeConsumer.java index 1dc0b6be64..3c973c0223 100644 --- a/src/main/java/net/minecraftforge/fml/util/ThreeConsumer.java +++ b/src/main/java/net/minecraftforge/fmllegacy/util/ThreeConsumer.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.util; +package net.minecraftforge.fmllegacy.util; import java.util.function.Consumer; diff --git a/src/main/java/net/minecraftforge/fml/event/server/FMLServerAboutToStartEvent.java b/src/main/java/net/minecraftforge/fmlserverevents/FMLServerAboutToStartEvent.java similarity index 91% rename from src/main/java/net/minecraftforge/fml/event/server/FMLServerAboutToStartEvent.java rename to src/main/java/net/minecraftforge/fmlserverevents/FMLServerAboutToStartEvent.java index 16b857b4c6..e254210736 100644 --- a/src/main/java/net/minecraftforge/fml/event/server/FMLServerAboutToStartEvent.java +++ b/src/main/java/net/minecraftforge/fmlserverevents/FMLServerAboutToStartEvent.java @@ -17,10 +17,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.event.server; +package net.minecraftforge.fmlserverevents; import net.minecraft.server.MinecraftServer; -import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent; /** * Called before the server begins loading anything. Called after {@link InterModProcessEvent} on the dedicated diff --git a/src/main/java/net/minecraftforge/fml/event/server/FMLServerStartedEvent.java b/src/main/java/net/minecraftforge/fmlserverevents/FMLServerStartedEvent.java similarity index 96% rename from src/main/java/net/minecraftforge/fml/event/server/FMLServerStartedEvent.java rename to src/main/java/net/minecraftforge/fmlserverevents/FMLServerStartedEvent.java index f4313a3dd8..39283fb957 100644 --- a/src/main/java/net/minecraftforge/fml/event/server/FMLServerStartedEvent.java +++ b/src/main/java/net/minecraftforge/fmlserverevents/FMLServerStartedEvent.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.event.server; +package net.minecraftforge.fmlserverevents; import net.minecraft.server.MinecraftServer; diff --git a/src/main/java/net/minecraftforge/fml/event/server/FMLServerStartingEvent.java b/src/main/java/net/minecraftforge/fmlserverevents/FMLServerStartingEvent.java similarity index 96% rename from src/main/java/net/minecraftforge/fml/event/server/FMLServerStartingEvent.java rename to src/main/java/net/minecraftforge/fmlserverevents/FMLServerStartingEvent.java index 6397795478..ab2b99a32f 100644 --- a/src/main/java/net/minecraftforge/fml/event/server/FMLServerStartingEvent.java +++ b/src/main/java/net/minecraftforge/fmlserverevents/FMLServerStartingEvent.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.event.server; +package net.minecraftforge.fmlserverevents; import net.minecraft.server.MinecraftServer; diff --git a/src/main/java/net/minecraftforge/fml/event/server/FMLServerStoppedEvent.java b/src/main/java/net/minecraftforge/fmlserverevents/FMLServerStoppedEvent.java similarity index 96% rename from src/main/java/net/minecraftforge/fml/event/server/FMLServerStoppedEvent.java rename to src/main/java/net/minecraftforge/fmlserverevents/FMLServerStoppedEvent.java index 3639a7f512..760d5bfbc1 100644 --- a/src/main/java/net/minecraftforge/fml/event/server/FMLServerStoppedEvent.java +++ b/src/main/java/net/minecraftforge/fmlserverevents/FMLServerStoppedEvent.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.event.server; +package net.minecraftforge.fmlserverevents; import net.minecraft.server.MinecraftServer; diff --git a/src/main/java/net/minecraftforge/fml/event/server/FMLServerStoppingEvent.java b/src/main/java/net/minecraftforge/fmlserverevents/FMLServerStoppingEvent.java similarity index 95% rename from src/main/java/net/minecraftforge/fml/event/server/FMLServerStoppingEvent.java rename to src/main/java/net/minecraftforge/fmlserverevents/FMLServerStoppingEvent.java index aaf787f86f..f6d60c2649 100644 --- a/src/main/java/net/minecraftforge/fml/event/server/FMLServerStoppingEvent.java +++ b/src/main/java/net/minecraftforge/fmlserverevents/FMLServerStoppingEvent.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.event.server; +package net.minecraftforge.fmlserverevents; import net.minecraft.server.MinecraftServer; diff --git a/src/main/java/net/minecraftforge/fml/event/server/ServerLifecycleEvent.java b/src/main/java/net/minecraftforge/fmlserverevents/ServerLifecycleEvent.java similarity index 96% rename from src/main/java/net/minecraftforge/fml/event/server/ServerLifecycleEvent.java rename to src/main/java/net/minecraftforge/fmlserverevents/ServerLifecycleEvent.java index 264ecd4239..47fe9a03a7 100644 --- a/src/main/java/net/minecraftforge/fml/event/server/ServerLifecycleEvent.java +++ b/src/main/java/net/minecraftforge/fmlserverevents/ServerLifecycleEvent.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.event.server; +package net.minecraftforge.fmlserverevents; import net.minecraft.server.MinecraftServer; import net.minecraftforge.eventbus.api.Event; diff --git a/src/main/java/net/minecraftforge/fml/event/lifecycle/GatherDataEvent.java b/src/main/java/net/minecraftforge/forge/event/lifecycle/GatherDataEvent.java similarity index 97% rename from src/main/java/net/minecraftforge/fml/event/lifecycle/GatherDataEvent.java rename to src/main/java/net/minecraftforge/forge/event/lifecycle/GatherDataEvent.java index f84848060f..6cc33198c1 100644 --- a/src/main/java/net/minecraftforge/fml/event/lifecycle/GatherDataEvent.java +++ b/src/main/java/net/minecraftforge/forge/event/lifecycle/GatherDataEvent.java @@ -17,13 +17,14 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.event.lifecycle; +package net.minecraftforge.forge.event.lifecycle; import cpw.mods.modlauncher.api.LamdbaExceptionUtils; import net.minecraft.data.DataGenerator; import net.minecraftforge.common.data.ExistingFileHelper; import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.fml.ModContainer; +import net.minecraftforge.fml.event.IModBusEvent; import java.nio.file.Path; import java.util.ArrayList; diff --git a/src/main/java/net/minecraftforge/items/CapabilityItemHandler.java b/src/main/java/net/minecraftforge/items/CapabilityItemHandler.java index 8b61539d44..df27b70959 100644 --- a/src/main/java/net/minecraftforge/items/CapabilityItemHandler.java +++ b/src/main/java/net/minecraftforge/items/CapabilityItemHandler.java @@ -19,17 +19,10 @@ package net.minecraftforge.items; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.INBT; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.ListNBT; -import net.minecraft.util.Direction; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.CapabilityInject; import net.minecraftforge.common.capabilities.CapabilityManager; -import java.util.concurrent.Callable; - public class CapabilityItemHandler { @CapabilityInject(IItemHandler.class) @@ -37,46 +30,7 @@ public class CapabilityItemHandler public static void register() { - CapabilityManager.INSTANCE.register(IItemHandler.class, new Capability.IStorage() - { - @Override - public INBT writeNBT(Capability capability, IItemHandler instance, Direction side) - { - ListNBT nbtTagList = new ListNBT(); - int size = instance.getSlots(); - for (int i = 0; i < size; i++) - { - ItemStack stack = instance.getStackInSlot(i); - if (!stack.isEmpty()) - { - CompoundNBT itemTag = new CompoundNBT(); - itemTag.putInt("Slot", i); - stack.save(itemTag); - nbtTagList.add(itemTag); - } - } - return nbtTagList; - } - - @Override - public void readNBT(Capability capability, IItemHandler instance, Direction side, INBT base) - { - if (!(instance instanceof IItemHandlerModifiable)) - throw new RuntimeException("IItemHandler instance does not implement IItemHandlerModifiable"); - IItemHandlerModifiable itemHandlerModifiable = (IItemHandlerModifiable) instance; - ListNBT tagList = (ListNBT) base; - for (int i = 0; i < tagList.size(); i++) - { - CompoundNBT itemTags = tagList.getCompound(i); - int j = itemTags.getInt("Slot"); - - if (j >= 0 && j < instance.getSlots()) - { - itemHandlerModifiable.setStackInSlot(j, ItemStack.of(itemTags)); - } - } - } - }, ItemStackHandler::new); + CapabilityManager.INSTANCE.register(IItemHandler.class); } } diff --git a/src/main/java/net/minecraftforge/items/IItemHandler.java b/src/main/java/net/minecraftforge/items/IItemHandler.java index c52c181e71..4a64a93d19 100644 --- a/src/main/java/net/minecraftforge/items/IItemHandler.java +++ b/src/main/java/net/minecraftforge/items/IItemHandler.java @@ -19,15 +19,10 @@ package net.minecraftforge.items; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.capability.IFluidHandler; +import net.minecraft.world.item.ItemStack; import javax.annotation.Nonnull; -import javax.annotation.Nonnull; - public interface IItemHandler { /** diff --git a/src/main/java/net/minecraftforge/items/IItemHandlerModifiable.java b/src/main/java/net/minecraftforge/items/IItemHandlerModifiable.java index 8434cc49cf..de3607202f 100644 --- a/src/main/java/net/minecraftforge/items/IItemHandlerModifiable.java +++ b/src/main/java/net/minecraftforge/items/IItemHandlerModifiable.java @@ -19,7 +19,7 @@ package net.minecraftforge.items; -import net.minecraft.item.ItemStack; +import net.minecraft.world.item.ItemStack; import javax.annotation.Nonnull; diff --git a/src/main/java/net/minecraftforge/items/ItemHandlerHelper.java b/src/main/java/net/minecraftforge/items/ItemHandlerHelper.java index 73ccca853c..c89333e9c3 100644 --- a/src/main/java/net/minecraftforge/items/ItemHandlerHelper.java +++ b/src/main/java/net/minecraftforge/items/ItemHandlerHelper.java @@ -19,13 +19,13 @@ package net.minecraftforge.items; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.util.SoundEvents; -import net.minecraft.item.ItemStack; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.math.MathHelper; -import net.minecraft.world.World; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.world.item.ItemStack; +import net.minecraft.sounds.SoundSource; +import net.minecraft.util.Mth; +import net.minecraft.world.level.Level; import net.minecraftforge.items.wrapper.PlayerMainInvWrapper; import javax.annotation.Nonnull; @@ -149,7 +149,7 @@ public class ItemHandlerHelper } /** giveItemToPlayer without preferred slot */ - public static void giveItemToPlayer(PlayerEntity player, @Nonnull ItemStack stack) { + public static void giveItemToPlayer(Player player, @Nonnull ItemStack stack) { giveItemToPlayer(player, stack, -1); } @@ -160,12 +160,12 @@ public class ItemHandlerHelper * @param player The player to give the item to * @param stack The itemstack to insert */ - public static void giveItemToPlayer(PlayerEntity player, @Nonnull ItemStack stack, int preferredSlot) + public static void giveItemToPlayer(Player player, @Nonnull ItemStack stack, int preferredSlot) { if (stack.isEmpty()) return; - IItemHandler inventory = new PlayerMainInvWrapper(player.inventory); - World world = player.level; + IItemHandler inventory = new PlayerMainInvWrapper(player.getInventory()); + Level world = player.level; // try adding it into the inventory ItemStack remainder = stack; @@ -184,7 +184,7 @@ public class ItemHandlerHelper if (remainder.isEmpty() || remainder.getCount() != stack.getCount()) { world.playSound(null, player.getX(), player.getY() + 0.5, player.getZ(), - SoundEvents.ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, ((world.random.nextFloat() - world.random.nextFloat()) * 0.7F + 1.0F) * 2.0F); + SoundEvents.ITEM_PICKUP, SoundSource.PLAYERS, 0.2F, ((world.random.nextFloat() - world.random.nextFloat()) * 0.7F + 1.0F) * 2.0F); } // drop remaining itemstack into the world @@ -227,7 +227,7 @@ public class ItemHandlerHelper } proportion = proportion / (float)inv.getSlots(); - return MathHelper.floor(proportion * 14.0F) + (itemsFound > 0 ? 1 : 0); + return Mth.floor(proportion * 14.0F) + (itemsFound > 0 ? 1 : 0); } } } diff --git a/src/main/java/net/minecraftforge/items/ItemStackHandler.java b/src/main/java/net/minecraftforge/items/ItemStackHandler.java index eae7c1565d..538dc9fed6 100644 --- a/src/main/java/net/minecraftforge/items/ItemStackHandler.java +++ b/src/main/java/net/minecraftforge/items/ItemStackHandler.java @@ -19,16 +19,16 @@ package net.minecraftforge.items; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.ListNBT; -import net.minecraft.util.NonNullList; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.core.NonNullList; import net.minecraftforge.common.util.Constants; import net.minecraftforge.common.util.INBTSerializable; import javax.annotation.Nonnull; -public class ItemStackHandler implements IItemHandler, IItemHandlerModifiable, INBTSerializable +public class ItemStackHandler implements IItemHandler, IItemHandlerModifiable, INBTSerializable { protected NonNullList stacks; @@ -178,33 +178,33 @@ public class ItemStackHandler implements IItemHandler, IItemHandlerModifiable, I } @Override - public CompoundNBT serializeNBT() + public CompoundTag serializeNBT() { - ListNBT nbtTagList = new ListNBT(); + ListTag nbtTagList = new ListTag(); for (int i = 0; i < stacks.size(); i++) { if (!stacks.get(i).isEmpty()) { - CompoundNBT itemTag = new CompoundNBT(); + CompoundTag itemTag = new CompoundTag(); itemTag.putInt("Slot", i); stacks.get(i).save(itemTag); nbtTagList.add(itemTag); } } - CompoundNBT nbt = new CompoundNBT(); + CompoundTag nbt = new CompoundTag(); nbt.put("Items", nbtTagList); nbt.putInt("Size", stacks.size()); return nbt; } @Override - public void deserializeNBT(CompoundNBT nbt) + public void deserializeNBT(CompoundTag nbt) { setSize(nbt.contains("Size", Constants.NBT.TAG_INT) ? nbt.getInt("Size") : stacks.size()); - ListNBT tagList = nbt.getList("Items", Constants.NBT.TAG_COMPOUND); + ListTag tagList = nbt.getList("Items", Constants.NBT.TAG_COMPOUND); for (int i = 0; i < tagList.size(); i++) { - CompoundNBT itemTags = tagList.getCompound(i); + CompoundTag itemTags = tagList.getCompound(i); int slot = itemTags.getInt("Slot"); if (slot >= 0 && slot < stacks.size()) diff --git a/src/main/java/net/minecraftforge/items/SlotItemHandler.java b/src/main/java/net/minecraftforge/items/SlotItemHandler.java index dacfcf3d76..827325fb35 100644 --- a/src/main/java/net/minecraftforge/items/SlotItemHandler.java +++ b/src/main/java/net/minecraftforge/items/SlotItemHandler.java @@ -19,16 +19,16 @@ package net.minecraftforge.items; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.Inventory; -import net.minecraft.inventory.container.Slot; -import net.minecraft.item.ItemStack; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.Container; +import net.minecraft.world.SimpleContainer; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.ItemStack; import javax.annotation.Nonnull; public class SlotItemHandler extends Slot { - private static IInventory emptyInventory = new Inventory(0); + private static Container emptyInventory = new SimpleContainer(0); private final IItemHandler itemHandler; private final int index; @@ -105,7 +105,7 @@ public class SlotItemHandler extends Slot } @Override - public boolean mayPickup(PlayerEntity playerIn) + public boolean mayPickup(Player playerIn) { return !this.getItemHandler().extractItem(index, 1, true).isEmpty(); } diff --git a/src/main/java/net/minecraftforge/items/VanillaHopperItemHandler.java b/src/main/java/net/minecraftforge/items/VanillaHopperItemHandler.java index 429af7a93d..a8a22e718b 100644 --- a/src/main/java/net/minecraftforge/items/VanillaHopperItemHandler.java +++ b/src/main/java/net/minecraftforge/items/VanillaHopperItemHandler.java @@ -19,17 +19,17 @@ package net.minecraftforge.items; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.HopperTileEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.entity.HopperBlockEntity; import net.minecraftforge.items.wrapper.InvWrapper; import javax.annotation.Nonnull; public class VanillaHopperItemHandler extends InvWrapper { - private final HopperTileEntity hopper; + private final HopperBlockEntity hopper; - public VanillaHopperItemHandler(HopperTileEntity hopper) + public VanillaHopperItemHandler(HopperBlockEntity hopper) { super(hopper); this.hopper = hopper; diff --git a/src/main/java/net/minecraftforge/items/VanillaInventoryCodeHooks.java b/src/main/java/net/minecraftforge/items/VanillaInventoryCodeHooks.java index 2e790fd2fc..6840b91ffb 100644 --- a/src/main/java/net/minecraftforge/items/VanillaInventoryCodeHooks.java +++ b/src/main/java/net/minecraftforge/items/VanillaInventoryCodeHooks.java @@ -19,19 +19,17 @@ package net.minecraftforge.items; -import net.minecraft.block.Block; -import net.minecraft.block.DropperBlock; -import net.minecraft.block.HopperBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.IHopper; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.DispenserTileEntity; -import net.minecraft.tileentity.HopperTileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.world.World; -import net.minecraftforge.common.util.LazyOptional; +import net.minecraft.world.level.block.DropperBlock; +import net.minecraft.world.level.block.HopperBlock; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.entity.Hopper; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.DispenserBlockEntity; +import net.minecraft.world.level.block.entity.HopperBlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.level.Level; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; @@ -47,9 +45,9 @@ public class VanillaInventoryCodeHooks * @return Null if we did nothing {no IItemHandler}, True if we moved an item, False if we moved no items */ @Nullable - public static Boolean extractHook(IHopper dest) + public static Boolean extractHook(Level level, Hopper dest) { - return getItemHandler(dest, Direction.UP) + return getItemHandler(level, dest, Direction.UP) .map(itemHandlerResult -> { IItemHandler handler = itemHandlerResult.getKey(); @@ -86,7 +84,7 @@ public class VanillaInventoryCodeHooks /** * Copied from BlockDropper#dispense and added capability support */ - public static boolean dropperInsertHook(World world, BlockPos pos, DispenserTileEntity dropper, int slot, @Nonnull ItemStack stack) + public static boolean dropperInsertHook(Level world, BlockPos pos, DispenserBlockEntity dropper, int slot, @Nonnull ItemStack stack) { Direction enumfacing = world.getBlockState(pos).getValue(DropperBlock.FACING); BlockPos blockpos = pos.relative(enumfacing); @@ -116,10 +114,10 @@ public class VanillaInventoryCodeHooks /** * Copied from TileEntityHopper#transferItemsOut and added capability support */ - public static boolean insertHook(HopperTileEntity hopper) + public static boolean insertHook(HopperBlockEntity hopper) { Direction hopperFacing = hopper.getBlockState().getValue(HopperBlock.FACING); - return getItemHandler(hopper, hopperFacing) + return getItemHandler(hopper.getLevel(), hopper, hopperFacing) .map(destinationResult -> { IItemHandler itemHandler = destinationResult.getKey(); Object destination = destinationResult.getValue(); @@ -152,7 +150,7 @@ public class VanillaInventoryCodeHooks .orElse(false); } - private static ItemStack putStackInInventoryAllSlots(TileEntity source, Object destination, IItemHandler destInventory, ItemStack stack) + private static ItemStack putStackInInventoryAllSlots(BlockEntity source, Object destination, IItemHandler destInventory, ItemStack stack) { for (int slot = 0; slot < destInventory.getSlots() && !stack.isEmpty(); slot++) { @@ -164,7 +162,7 @@ public class VanillaInventoryCodeHooks /** * Copied from TileEntityHopper#insertStack and added capability support */ - private static ItemStack insertStack(TileEntity source, Object destination, IItemHandler destInventory, ItemStack stack, int slot) + private static ItemStack insertStack(BlockEntity source, Object destination, IItemHandler destInventory, ItemStack stack, int slot) { ItemStack itemstack = destInventory.getStackInSlot(slot); @@ -188,16 +186,16 @@ public class VanillaInventoryCodeHooks if (insertedItem) { - if (inventoryWasEmpty && destination instanceof HopperTileEntity) + if (inventoryWasEmpty && destination instanceof HopperBlockEntity) { - HopperTileEntity destinationHopper = (HopperTileEntity)destination; + HopperBlockEntity destinationHopper = (HopperBlockEntity)destination; if (!destinationHopper.isOnCustomCooldown()) { int k = 0; - if (source instanceof HopperTileEntity) + if (source instanceof HopperBlockEntity) { - if (destinationHopper.getLastUpdateTime() >= ((HopperTileEntity) source).getLastUpdateTime()) + if (destinationHopper.getLastUpdateTime() >= ((HopperBlockEntity) source).getLastUpdateTime()) { k = 1; } @@ -211,12 +209,12 @@ public class VanillaInventoryCodeHooks return stack; } - private static Optional> getItemHandler(IHopper hopper, Direction hopperFacing) + private static Optional> getItemHandler(Level level, Hopper hopper, Direction hopperFacing) { double x = hopper.getLevelX() + (double) hopperFacing.getStepX(); double y = hopper.getLevelY() + (double) hopperFacing.getStepY(); double z = hopper.getLevelZ() + (double) hopperFacing.getStepZ(); - return getItemHandler(hopper.getLevel(), x, y, z, hopperFacing.getOpposite()); + return getItemHandler(level, x, y, z, hopperFacing.getOpposite()); } private static boolean isFull(IItemHandler itemHandler) @@ -245,21 +243,21 @@ public class VanillaInventoryCodeHooks return true; } - public static Optional> getItemHandler(World worldIn, double x, double y, double z, final Direction side) + public static Optional> getItemHandler(Level worldIn, double x, double y, double z, final Direction side) { - int i = MathHelper.floor(x); - int j = MathHelper.floor(y); - int k = MathHelper.floor(z); + int i = Mth.floor(x); + int j = Mth.floor(y); + int k = Mth.floor(z); BlockPos blockpos = new BlockPos(i, j, k); - net.minecraft.block.BlockState state = worldIn.getBlockState(blockpos); + net.minecraft.world.level.block.state.BlockState state = worldIn.getBlockState(blockpos); - if (state.hasTileEntity()) + if (state.hasBlockEntity()) { - TileEntity tileentity = worldIn.getBlockEntity(blockpos); - if (tileentity != null) + BlockEntity blockEntity = worldIn.getBlockEntity(blockpos); + if (blockEntity != null) { - return tileentity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side) - .map(capability -> ImmutablePair.of(capability, tileentity)); + return blockEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side) + .map(capability -> ImmutablePair.of(capability, blockEntity)); } } diff --git a/src/main/java/net/minecraftforge/items/wrapper/CombinedInvWrapper.java b/src/main/java/net/minecraftforge/items/wrapper/CombinedInvWrapper.java index c81506ff17..3988ab9460 100644 --- a/src/main/java/net/minecraftforge/items/wrapper/CombinedInvWrapper.java +++ b/src/main/java/net/minecraftforge/items/wrapper/CombinedInvWrapper.java @@ -19,7 +19,7 @@ package net.minecraftforge.items.wrapper; -import net.minecraft.item.ItemStack; +import net.minecraft.world.item.ItemStack; import net.minecraftforge.items.IItemHandlerModifiable; import javax.annotation.Nonnull; diff --git a/src/main/java/net/minecraftforge/items/wrapper/EmptyHandler.java b/src/main/java/net/minecraftforge/items/wrapper/EmptyHandler.java index 4d91eb9ae0..2bb70de690 100644 --- a/src/main/java/net/minecraftforge/items/wrapper/EmptyHandler.java +++ b/src/main/java/net/minecraftforge/items/wrapper/EmptyHandler.java @@ -19,7 +19,7 @@ package net.minecraftforge.items.wrapper; -import net.minecraft.item.ItemStack; +import net.minecraft.world.item.ItemStack; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandlerModifiable; diff --git a/src/main/java/net/minecraftforge/items/wrapper/EntityArmorInvWrapper.java b/src/main/java/net/minecraftforge/items/wrapper/EntityArmorInvWrapper.java index 46e1cb7c22..308001f3a2 100644 --- a/src/main/java/net/minecraftforge/items/wrapper/EntityArmorInvWrapper.java +++ b/src/main/java/net/minecraftforge/items/wrapper/EntityArmorInvWrapper.java @@ -19,9 +19,8 @@ package net.minecraftforge.items.wrapper; -import net.minecraft.entity.LivingEntity; -import net.minecraft.inventory.EquipmentSlotType; -import net.minecraftforge.items.IItemHandler; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.EquipmentSlot; /** * Exposes the armor inventory of an {@link EntityLivingBase} as an {@link IItemHandler} using {@link EntityLivingBase#getItemStackFromSlot} and @@ -31,6 +30,6 @@ public class EntityArmorInvWrapper extends EntityEquipmentInvWrapper { public EntityArmorInvWrapper(final LivingEntity entity) { - super(entity, EquipmentSlotType.Group.ARMOR); + super(entity, EquipmentSlot.Type.ARMOR); } } diff --git a/src/main/java/net/minecraftforge/items/wrapper/EntityEquipmentInvWrapper.java b/src/main/java/net/minecraftforge/items/wrapper/EntityEquipmentInvWrapper.java index e2c7df6e99..1403a937f2 100644 --- a/src/main/java/net/minecraftforge/items/wrapper/EntityEquipmentInvWrapper.java +++ b/src/main/java/net/minecraftforge/items/wrapper/EntityEquipmentInvWrapper.java @@ -20,11 +20,10 @@ package net.minecraftforge.items.wrapper; import com.google.common.collect.ImmutableList; -import net.minecraft.entity.LivingEntity; -import net.minecraft.inventory.EquipmentSlotType; -import net.minecraft.item.ItemStack; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.ItemStack; import net.minecraftforge.common.util.LazyOptional; -import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.ItemHandlerHelper; import java.util.ArrayList; @@ -32,10 +31,6 @@ import java.util.List; import javax.annotation.Nonnull; -import javax.annotation.Nonnull; -import java.util.ArrayList; -import java.util.List; - /** * Exposes the armor or hands inventory of an {@link EntityLivingBase} as an {@link IItemHandler} using {@link EntityLivingBase#getItemStackFromSlot} and * {@link EntityLivingBase#setItemStackToSlot}. @@ -50,19 +45,19 @@ public abstract class EntityEquipmentInvWrapper implements IItemHandlerModifiabl /** * The slots exposed by this wrapper, with {@link EntityEquipmentSlot#index} as the index. */ - protected final List slots; + protected final List slots; /** * @param entity The entity. * @param slotType The slot type to expose. */ - public EntityEquipmentInvWrapper(final LivingEntity entity, final EquipmentSlotType.Group slotType) + public EntityEquipmentInvWrapper(final LivingEntity entity, final EquipmentSlot.Type slotType) { this.entity = entity; - final List slots = new ArrayList(); + final List slots = new ArrayList(); - for (final EquipmentSlotType slot : EquipmentSlotType.values()) + for (final EquipmentSlot slot : EquipmentSlot.values()) { if (slot.getType() == slotType) { @@ -93,7 +88,7 @@ public abstract class EntityEquipmentInvWrapper implements IItemHandlerModifiabl if (stack.isEmpty()) return ItemStack.EMPTY; - final EquipmentSlotType equipmentSlot = validateSlotIndex(slot); + final EquipmentSlot equipmentSlot = validateSlotIndex(slot); final ItemStack existing = entity.getItemBySlot(equipmentSlot); @@ -134,7 +129,7 @@ public abstract class EntityEquipmentInvWrapper implements IItemHandlerModifiabl if (amount == 0) return ItemStack.EMPTY; - final EquipmentSlotType equipmentSlot = validateSlotIndex(slot); + final EquipmentSlot equipmentSlot = validateSlotIndex(slot); final ItemStack existing = entity.getItemBySlot(equipmentSlot); @@ -166,8 +161,8 @@ public abstract class EntityEquipmentInvWrapper implements IItemHandlerModifiabl @Override public int getSlotLimit(final int slot) { - final EquipmentSlotType equipmentSlot = validateSlotIndex(slot); - return equipmentSlot.getType() == EquipmentSlotType.Group.ARMOR ? 1 : 64; + final EquipmentSlot equipmentSlot = validateSlotIndex(slot); + return equipmentSlot.getType() == EquipmentSlot.Type.ARMOR ? 1 : 64; } protected int getStackLimit(final int slot, @Nonnull final ItemStack stack) @@ -178,7 +173,7 @@ public abstract class EntityEquipmentInvWrapper implements IItemHandlerModifiabl @Override public void setStackInSlot(final int slot, @Nonnull final ItemStack stack) { - final EquipmentSlotType equipmentSlot = validateSlotIndex(slot); + final EquipmentSlot equipmentSlot = validateSlotIndex(slot); if (ItemStack.matches(entity.getItemBySlot(equipmentSlot), stack)) return; entity.setItemSlot(equipmentSlot, stack); @@ -190,7 +185,7 @@ public abstract class EntityEquipmentInvWrapper implements IItemHandlerModifiabl return true; } - protected EquipmentSlotType validateSlotIndex(final int slot) + protected EquipmentSlot validateSlotIndex(final int slot) { if (slot < 0 || slot >= slots.size()) throw new IllegalArgumentException("Slot " + slot + " not in valid range - [0," + slots.size() + ")"); diff --git a/src/main/java/net/minecraftforge/items/wrapper/EntityHandsInvWrapper.java b/src/main/java/net/minecraftforge/items/wrapper/EntityHandsInvWrapper.java index 219c2e6e1c..c7ec482e29 100644 --- a/src/main/java/net/minecraftforge/items/wrapper/EntityHandsInvWrapper.java +++ b/src/main/java/net/minecraftforge/items/wrapper/EntityHandsInvWrapper.java @@ -19,9 +19,8 @@ package net.minecraftforge.items.wrapper; -import net.minecraft.entity.LivingEntity; -import net.minecraft.inventory.EquipmentSlotType; -import net.minecraftforge.items.IItemHandler; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.EquipmentSlot; /** * Exposes the hands inventory of an {@link EntityLivingBase} as an {@link IItemHandler} using {@link EntityLivingBase#getItemStackFromSlot} and @@ -31,6 +30,6 @@ public class EntityHandsInvWrapper extends EntityEquipmentInvWrapper { public EntityHandsInvWrapper(LivingEntity entity) { - super(entity, EquipmentSlotType.Group.HAND); + super(entity, EquipmentSlot.Type.HAND); } } diff --git a/src/main/java/net/minecraftforge/items/wrapper/InvWrapper.java b/src/main/java/net/minecraftforge/items/wrapper/InvWrapper.java index 04dfc3f05c..18fbe8411d 100644 --- a/src/main/java/net/minecraftforge/items/wrapper/InvWrapper.java +++ b/src/main/java/net/minecraftforge/items/wrapper/InvWrapper.java @@ -19,8 +19,8 @@ package net.minecraftforge.items.wrapper; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; +import net.minecraft.world.Container; +import net.minecraft.world.item.ItemStack; import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.ItemHandlerHelper; @@ -28,9 +28,9 @@ import javax.annotation.Nonnull; public class InvWrapper implements IItemHandlerModifiable { - private final IInventory inv; + private final Container inv; - public InvWrapper(IInventory inv) + public InvWrapper(Container inv) { this.inv = inv; } @@ -210,7 +210,7 @@ public class InvWrapper implements IItemHandlerModifiable return getInv().canPlaceItem(slot, stack); } - public IInventory getInv() + public Container getInv() { return inv; } diff --git a/src/main/java/net/minecraftforge/items/wrapper/PlayerArmorInvWrapper.java b/src/main/java/net/minecraftforge/items/wrapper/PlayerArmorInvWrapper.java index 3e011bbdd8..662ebd4eea 100644 --- a/src/main/java/net/minecraftforge/items/wrapper/PlayerArmorInvWrapper.java +++ b/src/main/java/net/minecraftforge/items/wrapper/PlayerArmorInvWrapper.java @@ -19,17 +19,17 @@ package net.minecraftforge.items.wrapper; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.inventory.EquipmentSlotType; -import net.minecraft.item.ItemStack; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.ItemStack; import javax.annotation.Nonnull; public class PlayerArmorInvWrapper extends RangedWrapper { - private final PlayerInventory inventoryPlayer; + private final Inventory inventoryPlayer; - public PlayerArmorInvWrapper(PlayerInventory inv) + public PlayerArmorInvWrapper(Inventory inv) { super(new InvWrapper(inv), inv.items.size(), inv.items.size() + inv.armor.size()); inventoryPlayer = inv; @@ -39,10 +39,10 @@ public class PlayerArmorInvWrapper extends RangedWrapper @Nonnull public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) { - EquipmentSlotType equ = null; - for (EquipmentSlotType s : EquipmentSlotType.values()) + EquipmentSlot equ = null; + for (EquipmentSlot s : EquipmentSlot.values()) { - if (s.getType() == EquipmentSlotType.Group.ARMOR && s.getIndex() == slot) + if (s.getType() == EquipmentSlot.Type.ARMOR && s.getIndex() == slot) { equ = s; break; @@ -56,7 +56,7 @@ public class PlayerArmorInvWrapper extends RangedWrapper return stack; } - public PlayerInventory getInventoryPlayer() + public Inventory getInventoryPlayer() { return inventoryPlayer; } diff --git a/src/main/java/net/minecraftforge/items/wrapper/PlayerInvWrapper.java b/src/main/java/net/minecraftforge/items/wrapper/PlayerInvWrapper.java index 81c6a2cac0..365df2464d 100644 --- a/src/main/java/net/minecraftforge/items/wrapper/PlayerInvWrapper.java +++ b/src/main/java/net/minecraftforge/items/wrapper/PlayerInvWrapper.java @@ -19,11 +19,11 @@ package net.minecraftforge.items.wrapper; -import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.world.entity.player.Inventory; public class PlayerInvWrapper extends CombinedInvWrapper { - public PlayerInvWrapper(PlayerInventory inv) + public PlayerInvWrapper(Inventory inv) { super(new PlayerMainInvWrapper(inv), new PlayerArmorInvWrapper(inv), new PlayerOffhandInvWrapper(inv)); } diff --git a/src/main/java/net/minecraftforge/items/wrapper/PlayerMainInvWrapper.java b/src/main/java/net/minecraftforge/items/wrapper/PlayerMainInvWrapper.java index 37a5b04614..64e4f81392 100644 --- a/src/main/java/net/minecraftforge/items/wrapper/PlayerMainInvWrapper.java +++ b/src/main/java/net/minecraftforge/items/wrapper/PlayerMainInvWrapper.java @@ -19,9 +19,9 @@ package net.minecraftforge.items.wrapper; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.item.ItemStack; import javax.annotation.Nonnull; @@ -31,9 +31,9 @@ import javax.annotation.Nonnull; */ public class PlayerMainInvWrapper extends RangedWrapper { - private final PlayerInventory inventoryPlayer; + private final Inventory inventoryPlayer; - public PlayerMainInvWrapper(PlayerInventory inv) + public PlayerMainInvWrapper(Inventory inv) { super(new InvWrapper(inv), 0, inv.items.size()); inventoryPlayer = inv; @@ -54,7 +54,7 @@ public class PlayerMainInvWrapper extends RangedWrapper { inSlot.setPopTime(5); } - else if(getInventoryPlayer().player instanceof ServerPlayerEntity) { + else if(getInventoryPlayer().player instanceof ServerPlayer) { getInventoryPlayer().player.containerMenu.broadcastChanges(); } } @@ -62,7 +62,7 @@ public class PlayerMainInvWrapper extends RangedWrapper return rest; } - public PlayerInventory getInventoryPlayer() + public Inventory getInventoryPlayer() { return inventoryPlayer; } diff --git a/src/main/java/net/minecraftforge/items/wrapper/PlayerOffhandInvWrapper.java b/src/main/java/net/minecraftforge/items/wrapper/PlayerOffhandInvWrapper.java index 9b650d8097..699c45d9a6 100644 --- a/src/main/java/net/minecraftforge/items/wrapper/PlayerOffhandInvWrapper.java +++ b/src/main/java/net/minecraftforge/items/wrapper/PlayerOffhandInvWrapper.java @@ -19,11 +19,11 @@ package net.minecraftforge.items.wrapper; -import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.world.entity.player.Inventory; public class PlayerOffhandInvWrapper extends RangedWrapper { - public PlayerOffhandInvWrapper(PlayerInventory inv) + public PlayerOffhandInvWrapper(Inventory inv) { super(new InvWrapper(inv), inv.items.size() + inv.armor.size(), inv.items.size() + inv.armor.size() + inv.offhand.size()); diff --git a/src/main/java/net/minecraftforge/items/wrapper/RangedWrapper.java b/src/main/java/net/minecraftforge/items/wrapper/RangedWrapper.java index 5923d8bc30..39c628be27 100644 --- a/src/main/java/net/minecraftforge/items/wrapper/RangedWrapper.java +++ b/src/main/java/net/minecraftforge/items/wrapper/RangedWrapper.java @@ -20,7 +20,7 @@ package net.minecraftforge.items.wrapper; import com.google.common.base.Preconditions; -import net.minecraft.item.ItemStack; +import net.minecraft.world.item.ItemStack; import net.minecraftforge.items.IItemHandlerModifiable; import javax.annotation.Nonnull; diff --git a/src/main/java/net/minecraftforge/items/wrapper/RecipeWrapper.java b/src/main/java/net/minecraftforge/items/wrapper/RecipeWrapper.java index dc23a57e3c..f7271b6f4b 100644 --- a/src/main/java/net/minecraftforge/items/wrapper/RecipeWrapper.java +++ b/src/main/java/net/minecraftforge/items/wrapper/RecipeWrapper.java @@ -19,12 +19,12 @@ package net.minecraftforge.items.wrapper; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.Container; +import net.minecraft.world.item.ItemStack; import net.minecraftforge.items.IItemHandlerModifiable; -public class RecipeWrapper implements IInventory { +public class RecipeWrapper implements Container { protected final IItemHandlerModifiable inv; @@ -113,10 +113,10 @@ public class RecipeWrapper implements IInventory { @Override public void setChanged() {} @Override - public boolean stillValid(PlayerEntity player) { return false; } + public boolean stillValid(Player player) { return false; } @Override - public void startOpen(PlayerEntity player) {} + public void startOpen(Player player) {} @Override - public void stopOpen(PlayerEntity player) {} + public void stopOpen(Player player) {} } diff --git a/src/main/java/net/minecraftforge/items/wrapper/SidedInvWrapper.java b/src/main/java/net/minecraftforge/items/wrapper/SidedInvWrapper.java index 8fb5254b1a..c8021bd424 100644 --- a/src/main/java/net/minecraftforge/items/wrapper/SidedInvWrapper.java +++ b/src/main/java/net/minecraftforge/items/wrapper/SidedInvWrapper.java @@ -19,9 +19,9 @@ package net.minecraftforge.items.wrapper; -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Direction; +import net.minecraft.world.WorldlyContainer; +import net.minecraft.world.item.ItemStack; +import net.minecraft.core.Direction; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.ItemHandlerHelper; @@ -31,12 +31,12 @@ import javax.annotation.Nullable; public class SidedInvWrapper implements IItemHandlerModifiable { - protected final ISidedInventory inv; + protected final WorldlyContainer inv; @Nullable protected final Direction side; @SuppressWarnings("unchecked") - public static LazyOptional[] create(ISidedInventory inv, Direction... sides) { + public static LazyOptional[] create(WorldlyContainer inv, Direction... sides) { LazyOptional[] ret = new LazyOptional[sides.length]; for (int x = 0; x < sides.length; x++) { final Direction side = sides[x]; @@ -45,13 +45,13 @@ public class SidedInvWrapper implements IItemHandlerModifiable return ret; } - public SidedInvWrapper(ISidedInventory inv, @Nullable Direction side) + public SidedInvWrapper(WorldlyContainer inv, @Nullable Direction side) { this.inv = inv; this.side = side; } - public static int getSlot(ISidedInventory inv, int slot, @Nullable Direction side) + public static int getSlot(WorldlyContainer inv, int slot, @Nullable Direction side) { int[] slots = inv.getSlotsForFace(side); if (slot < slots.length) diff --git a/src/main/java/net/minecraftforge/logging/ModelLoaderErrorMessage.java b/src/main/java/net/minecraftforge/logging/ModelLoaderErrorMessage.java index 0b8d8e4a85..6a38d0dcc8 100644 --- a/src/main/java/net/minecraftforge/logging/ModelLoaderErrorMessage.java +++ b/src/main/java/net/minecraftforge/logging/ModelLoaderErrorMessage.java @@ -22,17 +22,15 @@ package net.minecraftforge.logging; import com.google.common.base.Joiner; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; -import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.BlockModelShapes; -import net.minecraft.client.renderer.model.ModelResourceLocation; -import net.minecraft.item.Item; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.client.renderer.block.BlockModelShaper; +import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.registries.ForgeRegistries; import org.apache.logging.log4j.message.SimpleMessage; import java.util.Collection; -import java.util.function.Function; import static net.minecraftforge.client.model.ModelLoader.getInventoryVariant; @@ -49,7 +47,7 @@ public class ModelLoaderErrorMessage extends SimpleMessage ForgeRegistries.BLOCKS.getValues().stream() .flatMap(block -> block.getStateDefinition().getPossibleStates().stream()) - .forEach(state -> reverseBlockMap.put(BlockModelShapes.stateToModelLocation(state), state)); + .forEach(state -> reverseBlockMap.put(BlockModelShaper.stateToModelLocation(state), state)); ForgeRegistries.ITEMS.forEach(item -> { diff --git a/src/main/java/net/minecraftforge/network/ForgeConnectionNetworkFilter.java b/src/main/java/net/minecraftforge/network/ForgeConnectionNetworkFilter.java index efa50d08ee..f30eeadee6 100644 --- a/src/main/java/net/minecraftforge/network/ForgeConnectionNetworkFilter.java +++ b/src/main/java/net/minecraftforge/network/ForgeConnectionNetworkFilter.java @@ -26,13 +26,13 @@ import java.util.function.BiConsumer; import javax.annotation.Nullable; import io.netty.channel.ChannelHandler; -import net.minecraft.network.IPacket; -import net.minecraft.network.NetworkManager; -import net.minecraft.network.PacketDirection; -import net.minecraft.network.ProtocolType; -import net.minecraft.network.play.server.SAdvancementInfoPacket; -import net.minecraft.network.play.server.STagsListPacket; -import net.minecraft.network.play.server.SUpdateRecipesPacket; +import net.minecraft.network.protocol.Packet; +import net.minecraft.network.Connection; +import net.minecraft.network.protocol.PacketFlow; +import net.minecraft.network.ConnectionProtocol; +import net.minecraft.network.protocol.game.ClientboundUpdateAdvancementsPacket; +import net.minecraft.network.protocol.game.ClientboundUpdateTagsPacket; +import net.minecraft.network.protocol.game.ClientboundUpdateRecipesPacket; import com.google.common.collect.ImmutableMap; @@ -49,12 +49,12 @@ public class ForgeConnectionNetworkFilter extends VanillaPacketFilter this(null); } - public ForgeConnectionNetworkFilter(@Nullable NetworkManager manager) + public ForgeConnectionNetworkFilter(@Nullable Connection manager) { super(buildHandlers(manager)); } - private static Map>, BiConsumer, List>>> buildHandlers(@Nullable NetworkManager manager) + private static Map>, BiConsumer, List>>> buildHandlers(@Nullable Connection manager) { VanillaPacketSplitter.RemoteCompatibility compatibility = manager == null ? VanillaPacketSplitter.RemoteCompatibility.ABSENT : VanillaPacketSplitter.getRemoteCompatibility(manager); @@ -62,28 +62,25 @@ public class ForgeConnectionNetworkFilter extends VanillaPacketFilter { return ImmutableMap.of(); } - ImmutableMap.Builder>, BiConsumer, List>>> builder = ImmutableMap.>, BiConsumer, List>>>builder() - .put(SUpdateRecipesPacket.class, ForgeConnectionNetworkFilter::splitPacket) - .put(STagsListPacket.class, ForgeConnectionNetworkFilter::splitPacket); + ImmutableMap.Builder>, BiConsumer, List>>> builder = ImmutableMap.>, BiConsumer, List>>>builder() + .put(ClientboundUpdateRecipesPacket.class, ForgeConnectionNetworkFilter::splitPacket) + .put(ClientboundUpdateTagsPacket.class, ForgeConnectionNetworkFilter::splitPacket) + .put(ClientboundUpdateAdvancementsPacket.class, ForgeConnectionNetworkFilter::splitPacket); - if (compatibility == VanillaPacketSplitter.RemoteCompatibility.V11) - { - builder.put(SAdvancementInfoPacket.class, ForgeConnectionNetworkFilter::splitPacket); - } return builder.build(); } @Override - protected boolean isNecessary(NetworkManager manager) + protected boolean isNecessary(Connection manager) { // not needed on local connections, because packets are not encoded to bytes there return !manager.isMemoryConnection() && VanillaPacketSplitter.isRemoteCompatible(manager); } - private static void splitPacket(IPacket packet, List> out) + private static void splitPacket(Packet packet, List> out) { VanillaPacketSplitter.appendPackets( - ProtocolType.PLAY, PacketDirection.CLIENTBOUND, packet, out + ConnectionProtocol.PLAY, PacketFlow.CLIENTBOUND, packet, out ); } diff --git a/src/main/java/net/minecraftforge/network/NetworkFilters.java b/src/main/java/net/minecraftforge/network/NetworkFilters.java index 199135f734..fb9b9b4a29 100644 --- a/src/main/java/net/minecraftforge/network/NetworkFilters.java +++ b/src/main/java/net/minecraftforge/network/NetworkFilters.java @@ -22,7 +22,7 @@ package net.minecraftforge.network; import java.util.Map; import java.util.function.Function; -import net.minecraft.network.NetworkManager; +import net.minecraft.network.Connection; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -34,12 +34,12 @@ public class NetworkFilters private static final Logger LOGGER = LogManager.getLogger(); - private static final Map> instances = ImmutableMap.of( + private static final Map> instances = ImmutableMap.of( "forge:vanilla_filter", manager -> new VanillaConnectionNetworkFilter(), "forge:forge_fixes", ForgeConnectionNetworkFilter::new ); - public static void injectIfNecessary(NetworkManager manager) + public static void injectIfNecessary(Connection manager) { instances.forEach((key, filterFactory) -> { VanillaPacketFilter filter = filterFactory.apply(manager); diff --git a/src/main/java/net/minecraftforge/network/VanillaConnectionNetworkFilter.java b/src/main/java/net/minecraftforge/network/VanillaConnectionNetworkFilter.java index 0d4debe678..efea67c32c 100644 --- a/src/main/java/net/minecraftforge/network/VanillaConnectionNetworkFilter.java +++ b/src/main/java/net/minecraftforge/network/VanillaConnectionNetworkFilter.java @@ -19,7 +19,6 @@ package net.minecraftforge.network; -import java.util.AbstractMap; import java.util.Collections; import java.util.List; import java.util.function.BiConsumer; @@ -27,14 +26,14 @@ import java.util.function.BiConsumer; import javax.annotation.Nonnull; import io.netty.channel.ChannelHandler; -import net.minecraft.command.ISuggestionProvider; -import net.minecraft.command.arguments.ArgumentTypes; -import net.minecraft.network.IPacket; -import net.minecraft.network.NetworkManager; -import net.minecraft.network.play.server.SCommandListPacket; -import net.minecraft.network.play.server.SEntityPropertiesPacket; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.network.NetworkHooks; +import net.minecraft.commands.SharedSuggestionProvider; +import net.minecraft.commands.synchronization.ArgumentTypes; +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.resources.ResourceLocation; +import net.minecraftforge.fmllegacy.network.NetworkHooks; import net.minecraftforge.registries.ForgeRegistries; import org.apache.logging.log4j.LogManager; @@ -56,15 +55,15 @@ public class VanillaConnectionNetworkFilter extends VanillaPacketFilter public VanillaConnectionNetworkFilter() { super( - ImmutableMap.>, BiConsumer, List>>>builder() - .put(handler(SEntityPropertiesPacket.class, VanillaConnectionNetworkFilter::filterEntityProperties)) - .put(handler(SCommandListPacket.class, VanillaConnectionNetworkFilter::filterCommandList)) + ImmutableMap.>, BiConsumer, List>>>builder() + .put(handler(ClientboundUpdateAttributesPacket.class, VanillaConnectionNetworkFilter::filterEntityProperties)) + .put(handler(ClientboundCommandsPacket.class, VanillaConnectionNetworkFilter::filterCommandList)) .build() ); } @Override - protected boolean isNecessary(NetworkManager manager) + protected boolean isNecessary(Connection manager) { return NetworkHooks.isVanillaConnection(manager); } @@ -74,9 +73,9 @@ public class VanillaConnectionNetworkFilter extends VanillaPacketFilter * A vanilla client would ignore these with an error log. */ @Nonnull - private static SEntityPropertiesPacket filterEntityProperties(SEntityPropertiesPacket msg) + private static ClientboundUpdateAttributesPacket filterEntityProperties(ClientboundUpdateAttributesPacket msg) { - SEntityPropertiesPacket newPacket = new SEntityPropertiesPacket(msg.getEntityId(), Collections.emptyList()); + ClientboundUpdateAttributesPacket newPacket = new ClientboundUpdateAttributesPacket(msg.getEntityId(), Collections.emptyList()); msg.getValues().stream() .filter(snapshot -> { ResourceLocation key = ForgeRegistries.ATTRIBUTES.getKey(snapshot.getAttribute()); @@ -91,13 +90,13 @@ public class VanillaConnectionNetworkFilter extends VanillaPacketFilter * A vanilla client would fail to deserialize the packet and disconnect with an error message if these were sent. */ @Nonnull - private static SCommandListPacket filterCommandList(SCommandListPacket packet) + private static ClientboundCommandsPacket filterCommandList(ClientboundCommandsPacket packet) { - RootCommandNode root = packet.getRoot(); - RootCommandNode newRoot = CommandTreeCleaner.cleanArgumentTypes(root, argType -> { + RootCommandNode root = packet.getRoot(); + RootCommandNode newRoot = CommandTreeCleaner.cleanArgumentTypes(root, argType -> { ResourceLocation id = ArgumentTypes.getId(argType); return id != null && (id.getNamespace().equals("minecraft") || id.getNamespace().equals("brigadier")); }); - return new SCommandListPacket(newRoot); + return new ClientboundCommandsPacket(newRoot); } } diff --git a/src/main/java/net/minecraftforge/network/VanillaPacketFilter.java b/src/main/java/net/minecraftforge/network/VanillaPacketFilter.java index acc02034c1..e5526c150d 100644 --- a/src/main/java/net/minecraftforge/network/VanillaPacketFilter.java +++ b/src/main/java/net/minecraftforge/network/VanillaPacketFilter.java @@ -29,18 +29,18 @@ import javax.annotation.Nonnull; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.MessageToMessageEncoder; -import net.minecraft.network.IPacket; -import net.minecraft.network.NetworkManager; +import net.minecraft.network.protocol.Packet; +import net.minecraft.network.Connection; /** * A filter for vanilla network packets. */ -public abstract class VanillaPacketFilter extends MessageToMessageEncoder> +public abstract class VanillaPacketFilter extends MessageToMessageEncoder> { - protected final Map>, BiConsumer, List>>> handlers; + protected final Map>, BiConsumer, List>>> handlers; - protected VanillaPacketFilter(Map>, BiConsumer, List>>> handlers) + protected VanillaPacketFilter(Map>, BiConsumer, List>>> handlers) { this.handlers = handlers; } @@ -49,7 +49,7 @@ public abstract class VanillaPacketFilter extends MessageToMessageEncoder> Map.Entry>, BiConsumer, List>>> handler(Class cls, Function> function) + protected static > Map.Entry>, BiConsumer, List>>> handler(Class cls, Function> function) { return handler(cls, (pkt, list) -> list.add(function.apply(cls.cast(pkt)))); } @@ -58,7 +58,7 @@ public abstract class VanillaPacketFilter extends MessageToMessageEncoder> Map.Entry>, BiConsumer, List>>> handler(Class cls, BiConsumer, List>> consumer) + protected static > Map.Entry>, BiConsumer, List>>> handler(Class cls, BiConsumer, List>> consumer) { return new AbstractMap.SimpleEntry<>(cls, consumer); } @@ -66,12 +66,12 @@ public abstract class VanillaPacketFilter extends MessageToMessageEncoder msg, List out) + protected void encode(ChannelHandlerContext ctx, Packet msg, List out) { - BiConsumer, List>> consumer = handlers.getOrDefault(msg.getClass(), (pkt, list) -> list.add(pkt)); + BiConsumer, List>> consumer = handlers.getOrDefault(msg.getClass(), (pkt, list) -> list.add(pkt)); consumer.accept(msg, out); } diff --git a/src/main/java/net/minecraftforge/network/VanillaPacketSplitter.java b/src/main/java/net/minecraftforge/network/VanillaPacketSplitter.java index 1dfe195cc9..5b623163de 100644 --- a/src/main/java/net/minecraftforge/network/VanillaPacketSplitter.java +++ b/src/main/java/net/minecraftforge/network/VanillaPacketSplitter.java @@ -19,32 +19,29 @@ package net.minecraftforge.network; -import java.io.IOException; -import java.io.UncheckedIOException; import java.util.ArrayList; import java.util.List; -import java.util.Set; import java.util.function.Predicate; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import net.minecraft.client.Minecraft; -import net.minecraft.client.network.play.ClientPlayNetHandler; +import net.minecraft.client.multiplayer.ClientPacketListener; import net.minecraft.network.*; -import net.minecraft.network.play.server.SCustomPayloadPlayPacket; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.network.FMLConnectionData; -import net.minecraftforge.fml.network.NetworkDirection; -import net.minecraftforge.fml.network.NetworkEvent; -import net.minecraftforge.fml.network.NetworkHooks; -import net.minecraftforge.fml.network.NetworkRegistry; -import net.minecraftforge.fml.network.event.EventNetworkChannel; +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.fmllegacy.network.FMLConnectionData; +import net.minecraftforge.fmllegacy.network.NetworkDirection; +import net.minecraftforge.fmllegacy.network.NetworkEvent; +import net.minecraftforge.fmllegacy.network.NetworkHooks; +import net.minecraftforge.fmllegacy.network.NetworkRegistry; +import net.minecraftforge.fmllegacy.network.event.EventNetworkChannel; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import com.google.common.collect.ImmutableSet; - /** * 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. @@ -55,13 +52,7 @@ public class VanillaPacketSplitter private static final Logger LOGGER = LogManager.getLogger(); private static final ResourceLocation CHANNEL = new ResourceLocation("forge", "split"); - // TODO 1.17: bump this to version 1.1 and remove dummy channel - // Version 1.1 removed client-side whitelist - // we don't bump actual channel version because that would prevent old clients from connecting - // but we still need to detect new clients, so we add a dummy channel just for that. - private static final ResourceLocation V11_DUMMY_CHANNEL = new ResourceLocation("forge", "split_11"); - private static final String VERSION = "1.0"; - private static final String VERSION_11 = "1.1"; + private static final String VERSION = "1.1"; private static final int PROTOCOL_MAX = 2097152; @@ -77,16 +68,13 @@ public class VanillaPacketSplitter Predicate versionCheck = NetworkRegistry.acceptMissingOr(VERSION); EventNetworkChannel channel = NetworkRegistry.newEventChannel(CHANNEL, () -> VERSION, versionCheck, versionCheck); channel.addListener(VanillaPacketSplitter::onClientPacket); - - Predicate version11Check = NetworkRegistry.acceptMissingOr(VERSION_11); - NetworkRegistry.newEventChannel(V11_DUMMY_CHANNEL, () -> VERSION_11, version11Check, version11Check); } /** * 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(ProtocolType protocol, PacketDirection direction, IPacket packet, List> out) + public static void appendPackets(ConnectionProtocol protocol, PacketFlow direction, Packet packet, List> out) { if (heuristicIsDefinitelySmallEnough(packet)) { @@ -94,15 +82,8 @@ public class VanillaPacketSplitter } else { - PacketBuffer buf = new PacketBuffer(Unpooled.buffer()); - try - { - packet.write(buf); - } - catch (IOException e) - { - throw new UncheckedIOException(e); - } + FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.buffer()); + packet.write(buf); if (buf.readableBytes() <= PROTOCOL_MAX) { buf.release(); @@ -125,7 +106,7 @@ public class VanillaPacketSplitter { partPrefix = Unpooled.buffer(5); partPrefix.writeByte(STATE_FIRST); - new PacketBuffer(partPrefix).writeVarInt(protocol.getPacketId(direction, packet)); + new FriendlyByteBuf(partPrefix).writeVarInt(protocol.getPacketId(direction, packet)); } else { @@ -138,7 +119,7 @@ public class VanillaPacketSplitter buf.retainedSlice(buf.readerIndex(), partSize) ); buf.skipBytes(partSize); - out.add(new SCustomPayloadPlayPacket(CHANNEL, new PacketBuffer(partBuf))); + out.add(new ClientboundCustomPayloadPacket(CHANNEL, new FriendlyByteBuf(partBuf))); } // we retained all the slices, so we do not need this one anymore buf.release(); @@ -147,23 +128,23 @@ public class VanillaPacketSplitter } } - private static boolean heuristicIsDefinitelySmallEnough(IPacket packet) + private static boolean heuristicIsDefinitelySmallEnough(Packet packet) { return false; } - private static final List receivedBuffers = new ArrayList<>(); + private static final List receivedBuffers = new ArrayList<>(); @SuppressWarnings("unchecked") private static void onClientPacket(NetworkEvent.ServerCustomPayloadEvent event) { NetworkEvent.Context ctx = event.getSource().get(); - PacketDirection direction = ctx.getDirection() == NetworkDirection.PLAY_TO_CLIENT ? PacketDirection.CLIENTBOUND : PacketDirection.SERVERBOUND; - ProtocolType protocol = ProtocolType.PLAY; + PacketFlow direction = ctx.getDirection() == NetworkDirection.PLAY_TO_CLIENT ? PacketFlow.CLIENTBOUND : PacketFlow.SERVERBOUND; + ConnectionProtocol protocol = ConnectionProtocol.PLAY; ctx.setPacketHandled(true); - PacketBuffer buf = event.getPayload(); + FriendlyByteBuf buf = event.getPayload(); byte state = buf.readByte(); if (state == STATE_FIRST) @@ -178,27 +159,18 @@ public class VanillaPacketSplitter receivedBuffers.add(buf); if (state == STATE_LAST) { - PacketBuffer full = new PacketBuffer(Unpooled.wrappedBuffer(receivedBuffers.toArray(new PacketBuffer[0]))); + FriendlyByteBuf full = new FriendlyByteBuf(Unpooled.wrappedBuffer(receivedBuffers.toArray(new FriendlyByteBuf[0]))); int packetId = full.readVarInt(); - IPacket packet = protocol.createPacket(direction, packetId); + Packet packet = protocol.createPacket(direction, packetId, full); if (packet == null) { LOGGER.error("Received invalid packet ID {} in forge:split", packetId); } else { - try - { - packet.read(full); - } - catch (IOException e) - { - throw new UncheckedIOException(e); - } finally { - receivedBuffers.clear(); - full.release(); - } - ctx.enqueueWork(() -> ((IPacket)packet).handle(Minecraft.getInstance().getConnection())); + receivedBuffers.clear(); + full.release(); + ctx.enqueueWork(() -> ((Packet)packet).handle(Minecraft.getInstance().getConnection())); } } } @@ -206,24 +178,15 @@ public class VanillaPacketSplitter public enum RemoteCompatibility { ABSENT, - V10_LEGACY, - V11 + PRESENT } - public static RemoteCompatibility getRemoteCompatibility(NetworkManager manager) + public static RemoteCompatibility getRemoteCompatibility(Connection manager) { FMLConnectionData connectionData = NetworkHooks.getConnectionData(manager); - if (connectionData == null) + if (connectionData != null && connectionData.getChannels().containsKey(CHANNEL)) { - return RemoteCompatibility.ABSENT; - } - else if (connectionData.getChannels().containsKey(V11_DUMMY_CHANNEL)) - { - return RemoteCompatibility.V11; - } - else if (connectionData.getChannels().containsKey(CHANNEL)) - { - return RemoteCompatibility.V10_LEGACY; + return RemoteCompatibility.PRESENT; } else { @@ -231,7 +194,7 @@ public class VanillaPacketSplitter } } - public static boolean isRemoteCompatible(NetworkManager manager) + public static boolean isRemoteCompatible(Connection manager) { return getRemoteCompatibility(manager) != RemoteCompatibility.ABSENT; } diff --git a/src/main/java/net/minecraftforge/registries/DataSerializerEntry.java b/src/main/java/net/minecraftforge/registries/DataSerializerEntry.java index 07d42b2c85..1a18dd3c5c 100644 --- a/src/main/java/net/minecraftforge/registries/DataSerializerEntry.java +++ b/src/main/java/net/minecraftforge/registries/DataSerializerEntry.java @@ -19,18 +19,18 @@ package net.minecraftforge.registries; -import net.minecraft.network.datasync.IDataSerializer; +import net.minecraft.network.syncher.EntityDataSerializer; public final class DataSerializerEntry extends ForgeRegistryEntry { - private final IDataSerializer serializer; + private final EntityDataSerializer serializer; - public DataSerializerEntry(IDataSerializer serializer) + public DataSerializerEntry(EntityDataSerializer serializer) { this.serializer = serializer; } - public IDataSerializer getSerializer() + public EntityDataSerializer getSerializer() { return serializer; } diff --git a/src/main/java/net/minecraftforge/registries/DeferredRegister.java b/src/main/java/net/minecraftforge/registries/DeferredRegister.java index ec74ffe766..03c798b388 100644 --- a/src/main/java/net/minecraftforge/registries/DeferredRegister.java +++ b/src/main/java/net/minecraftforge/registries/DeferredRegister.java @@ -19,12 +19,11 @@ package net.minecraftforge.registries; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.event.RegistryEvent; -import net.minecraftforge.eventbus.api.EventPriority; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.RegistryObject; +import net.minecraftforge.fmllegacy.RegistryObject; import java.util.Collection; import java.util.Collections; @@ -35,8 +34,6 @@ import java.util.Objects; import java.util.Set; import java.util.function.Supplier; -import com.google.common.reflect.TypeToken; - /** * Utility class to help with managing registry entries. * Maintains a list of all suppliers for entries and registers them during the proper Register event. diff --git a/src/main/java/net/minecraftforge/registries/ForgeRegistries.java b/src/main/java/net/minecraftforge/registries/ForgeRegistries.java index a762bf22aa..ea36771f02 100644 --- a/src/main/java/net/minecraftforge/registries/ForgeRegistries.java +++ b/src/main/java/net/minecraftforge/registries/ForgeRegistries.java @@ -19,46 +19,45 @@ package net.minecraftforge.registries; -import net.minecraft.block.Block; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.ai.attributes.Attribute; -import net.minecraft.entity.ai.brain.memory.MemoryModuleType; -import net.minecraft.entity.ai.brain.schedule.Activity; -import net.minecraft.entity.ai.brain.schedule.Schedule; -import net.minecraft.entity.ai.brain.sensor.SensorType; -import net.minecraft.entity.item.PaintingType; -import net.minecraft.entity.merchant.villager.VillagerProfession; -import net.minecraft.fluid.Fluid; -import net.minecraft.inventory.container.ContainerType; -import net.minecraft.util.registry.Bootstrap; -import net.minecraft.util.registry.Registry; -import net.minecraft.village.PointOfInterestType; -import net.minecraft.item.Item; -import net.minecraft.item.crafting.IRecipeSerializer; -import net.minecraft.particles.ParticleType; -import net.minecraft.potion.Effect; -import net.minecraft.potion.Potion; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.item.enchantment.Enchantment; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.ai.attributes.Attribute; +import net.minecraft.world.entity.ai.memory.MemoryModuleType; +import net.minecraft.world.entity.schedule.Activity; +import net.minecraft.world.entity.schedule.Schedule; +import net.minecraft.world.entity.ai.sensing.SensorType; +import net.minecraft.world.entity.decoration.Motive; +import net.minecraft.world.entity.npc.VillagerProfession; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.server.Bootstrap; +import net.minecraft.core.Registry; +import net.minecraft.world.entity.ai.village.poi.PoiType; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.crafting.RecipeSerializer; +import net.minecraft.core.particles.ParticleType; +import net.minecraft.world.effect.MobEffect; +import net.minecraft.world.item.alchemy.Potion; import net.minecraft.stats.StatType; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.RegistryKey; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.SoundEvent; -import net.minecraft.world.biome.Biome; -import net.minecraft.world.chunk.ChunkStatus; -import net.minecraft.world.gen.blockplacer.BlockPlacerType; -import net.minecraft.world.gen.blockstateprovider.BlockStateProviderType; -import net.minecraft.world.gen.carver.WorldCarver; -import net.minecraft.world.gen.feature.Feature; -import net.minecraft.world.gen.feature.structure.Structure; -import net.minecraft.world.gen.foliageplacer.FoliagePlacerType; -import net.minecraft.world.gen.placement.Placement; -import net.minecraft.world.gen.surfacebuilders.SurfaceBuilder; -import net.minecraft.world.gen.treedecorator.TreeDecoratorType; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.world.level.biome.Biome; +import net.minecraft.world.level.chunk.ChunkStatus; +import net.minecraft.world.level.levelgen.feature.blockplacers.BlockPlacerType; +import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProviderType; +import net.minecraft.world.level.levelgen.carver.WorldCarver; +import net.minecraft.world.level.levelgen.feature.Feature; +import net.minecraft.world.level.levelgen.feature.StructureFeature; +import net.minecraft.world.level.levelgen.feature.foliageplacers.FoliagePlacerType; +import net.minecraft.world.level.levelgen.placement.FeatureDecorator; +import net.minecraft.world.level.levelgen.surfacebuilders.SurfaceBuilder; +import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecoratorType; import net.minecraftforge.common.Tags; import net.minecraftforge.common.loot.GlobalLootModifierSerializer; import net.minecraftforge.common.world.ForgeWorldType; -import net.minecraftforge.fml.common.registry.GameRegistry; /** * A class that exposes static references to all vanilla and Forge registries. @@ -73,22 +72,22 @@ public class ForgeRegistries public static final IForgeRegistry BLOCKS = RegistryManager.ACTIVE.getRegistry(Block.class); public static final IForgeRegistry FLUIDS = RegistryManager.ACTIVE.getRegistry(Fluid.class); public static final IForgeRegistry ITEMS = RegistryManager.ACTIVE.getRegistry(Item.class); - public static final IForgeRegistry POTIONS = RegistryManager.ACTIVE.getRegistry(Effect.class); + public static final IForgeRegistry POTIONS = RegistryManager.ACTIVE.getRegistry(MobEffect.class); public static final IForgeRegistry SOUND_EVENTS = RegistryManager.ACTIVE.getRegistry(SoundEvent.class); public static final IForgeRegistry POTION_TYPES = RegistryManager.ACTIVE.getRegistry(Potion.class); public static final IForgeRegistry ENCHANTMENTS = RegistryManager.ACTIVE.getRegistry(Enchantment.class); public static final IForgeRegistry> ENTITIES = RegistryManager.ACTIVE.getRegistry(EntityType.class); - public static final IForgeRegistry> TILE_ENTITIES = RegistryManager.ACTIVE.getRegistry(TileEntityType.class); + public static final IForgeRegistry> BLOCK_ENTITIES = RegistryManager.ACTIVE.getRegistry(BlockEntityType.class); public static final IForgeRegistry> PARTICLE_TYPES = RegistryManager.ACTIVE.getRegistry(ParticleType.class); - public static final IForgeRegistry> CONTAINERS = RegistryManager.ACTIVE.getRegistry(ContainerType.class); - public static final IForgeRegistry PAINTING_TYPES = RegistryManager.ACTIVE.getRegistry(PaintingType.class); - public static final IForgeRegistry> RECIPE_SERIALIZERS = RegistryManager.ACTIVE.getRegistry(IRecipeSerializer.class); + public static final IForgeRegistry> CONTAINERS = RegistryManager.ACTIVE.getRegistry(MenuType.class); + public static final IForgeRegistry PAINTING_TYPES = RegistryManager.ACTIVE.getRegistry(Motive.class); + public static final IForgeRegistry> RECIPE_SERIALIZERS = RegistryManager.ACTIVE.getRegistry(RecipeSerializer.class); public static final IForgeRegistry ATTRIBUTES = RegistryManager.ACTIVE.getRegistry(Attribute.class); public static final IForgeRegistry> STAT_TYPES = RegistryManager.ACTIVE.getRegistry(StatType.class); // Villages public static final IForgeRegistry PROFESSIONS = RegistryManager.ACTIVE.getRegistry(VillagerProfession.class); - public static final IForgeRegistry POI_TYPES = RegistryManager.ACTIVE.getRegistry(PointOfInterestType.class); + public static final IForgeRegistry POI_TYPES = RegistryManager.ACTIVE.getRegistry(PoiType.class); public static final IForgeRegistry> MEMORY_MODULE_TYPES = RegistryManager.ACTIVE.getRegistry(MemoryModuleType.class); public static final IForgeRegistry> SENSOR_TYPES = RegistryManager.ACTIVE.getRegistry(SensorType.class); public static final IForgeRegistry SCHEDULES = RegistryManager.ACTIVE.getRegistry(Schedule.class); @@ -98,9 +97,9 @@ public class ForgeRegistries public static final IForgeRegistry> WORLD_CARVERS = RegistryManager.ACTIVE.getRegistry(WorldCarver.class); public static final IForgeRegistry> SURFACE_BUILDERS = RegistryManager.ACTIVE.getRegistry(SurfaceBuilder.class); public static final IForgeRegistry> FEATURES = RegistryManager.ACTIVE.getRegistry(Feature.class); - public static final IForgeRegistry> DECORATORS = RegistryManager.ACTIVE.getRegistry(Placement.class); + public static final IForgeRegistry> DECORATORS = RegistryManager.ACTIVE.getRegistry(FeatureDecorator.class); public static final IForgeRegistry CHUNK_STATUS = RegistryManager.ACTIVE.getRegistry(ChunkStatus.class); - public static final IForgeRegistry> STRUCTURE_FEATURES = RegistryManager.ACTIVE.getRegistry(Structure.class); + public static final IForgeRegistry> STRUCTURE_FEATURES = RegistryManager.ACTIVE.getRegistry(StructureFeature.class); public static final IForgeRegistry> BLOCK_STATE_PROVIDER_TYPES = RegistryManager.ACTIVE.getRegistry(BlockStateProviderType.class); public static final IForgeRegistry> BLOCK_PLACER_TYPES = RegistryManager.ACTIVE.getRegistry(BlockPlacerType.class); public static final IForgeRegistry> FOLIAGE_PLACER_TYPES = RegistryManager.ACTIVE.getRegistry(FoliagePlacerType.class); @@ -116,49 +115,49 @@ public class ForgeRegistries public static final class Keys { //Vanilla - public static final RegistryKey> BLOCKS = key("block"); - public static final RegistryKey> FLUIDS = key("fluid"); - public static final RegistryKey> ITEMS = key("item"); - public static final RegistryKey> EFFECTS = key("mob_effect"); - public static final RegistryKey> POTIONS = key("potion"); - public static final RegistryKey> ATTRIBUTES = key("attribute"); - public static final RegistryKey>> STAT_TYPES = key("stat_type"); - public static final RegistryKey> SOUND_EVENTS = key("sound_event"); - public static final RegistryKey> ENCHANTMENTS = key("enchantment"); - public static final RegistryKey>> ENTITY_TYPES = key("entity_type"); - public static final RegistryKey> PAINTING_TYPES = key("motive"); - public static final RegistryKey>> PARTICLE_TYPES = key("particle_type"); - public static final RegistryKey>> CONTAINER_TYPES = key("menu"); - public static final RegistryKey>> TILE_ENTITY_TYPES = key("block_entity_type"); - public static final RegistryKey>> RECIPE_SERIALIZERS = key("recipe_serializer"); - public static final RegistryKey> VILLAGER_PROFESSIONS = key("villager_profession"); - public static final RegistryKey> POI_TYPES = key("point_of_interest_type"); - public static final RegistryKey>> MEMORY_MODULE_TYPES = key("memory_module_type"); - public static final RegistryKey>> SENSOR_TYPES = key("sensor_type"); - public static final RegistryKey> SCHEDULES = key("schedule"); - public static final RegistryKey> ACTIVITIES = key("activity"); - public static final RegistryKey>> WORLD_CARVERS = key("worldgen/carver"); - public static final RegistryKey>> SURFACE_BUILDERS = key("worldgen/surface_builder"); - public static final RegistryKey>> FEATURES = key("worldgen/feature"); - public static final RegistryKey>> DECORATORS = key("worldgen/decorator"); - public static final RegistryKey> CHUNK_STATUS = key("chunk_status"); - public static final RegistryKey>> STRUCTURE_FEATURES = key("worldgen/structure_feature"); - public static final RegistryKey>> BLOCK_STATE_PROVIDER_TYPES = key("worldgen/block_state_provider_type"); - public static final RegistryKey>> BLOCK_PLACER_TYPES = key("worldgen/block_placer_type"); - public static final RegistryKey>> FOLIAGE_PLACER_TYPES = key("worldgen/foliage_placer_type"); - public static final RegistryKey>> TREE_DECORATOR_TYPES = key("worldgen/tree_decorator_type"); + public static final ResourceKey> BLOCKS = key("block"); + public static final ResourceKey> FLUIDS = key("fluid"); + public static final ResourceKey> ITEMS = key("item"); + public static final ResourceKey> EFFECTS = key("mob_effect"); + public static final ResourceKey> POTIONS = key("potion"); + public static final ResourceKey> ATTRIBUTES = key("attribute"); + public static final ResourceKey>> STAT_TYPES = key("stat_type"); + public static final ResourceKey> SOUND_EVENTS = key("sound_event"); + public static final ResourceKey> ENCHANTMENTS = key("enchantment"); + public static final ResourceKey>> ENTITY_TYPES = key("entity_type"); + public static final ResourceKey> PAINTING_TYPES = key("motive"); + public static final ResourceKey>> PARTICLE_TYPES = key("particle_type"); + public static final ResourceKey>> CONTAINER_TYPES = key("menu"); + public static final ResourceKey>> BLOCK_ENTITY_TYPES = key("block_entity_type"); + public static final ResourceKey>> RECIPE_SERIALIZERS = key("recipe_serializer"); + public static final ResourceKey> VILLAGER_PROFESSIONS = key("villager_profession"); + public static final ResourceKey> POI_TYPES = key("point_of_interest_type"); + public static final ResourceKey>> MEMORY_MODULE_TYPES = key("memory_module_type"); + public static final ResourceKey>> SENSOR_TYPES = key("sensor_type"); + public static final ResourceKey> SCHEDULES = key("schedule"); + public static final ResourceKey> ACTIVITIES = key("activity"); + public static final ResourceKey>> WORLD_CARVERS = key("worldgen/carver"); + public static final ResourceKey>> SURFACE_BUILDERS = key("worldgen/surface_builder"); + public static final ResourceKey>> FEATURES = key("worldgen/feature"); + public static final ResourceKey>> DECORATORS = key("worldgen/decorator"); + public static final ResourceKey> CHUNK_STATUS = key("chunk_status"); + public static final ResourceKey>> STRUCTURE_FEATURES = key("worldgen/structure_feature"); + public static final ResourceKey>> BLOCK_STATE_PROVIDER_TYPES = key("worldgen/block_state_provider_type"); + public static final ResourceKey>> BLOCK_PLACER_TYPES = key("worldgen/block_placer_type"); + public static final ResourceKey>> FOLIAGE_PLACER_TYPES = key("worldgen/foliage_placer_type"); + public static final ResourceKey>> TREE_DECORATOR_TYPES = key("worldgen/tree_decorator_type"); // Vanilla Dynamic - public static final RegistryKey> BIOMES = key("worldgen/biome"); + public static final ResourceKey> BIOMES = key("worldgen/biome"); //Forge - public static final RegistryKey> DATA_SERIALIZERS = key("data_serializers"); - public static final RegistryKey>> LOOT_MODIFIER_SERIALIZERS = key("forge:loot_modifier_serializers"); - public static final RegistryKey> WORLD_TYPES = key("forge:world_types"); + public static final ResourceKey> DATA_SERIALIZERS = key("data_serializers"); + public static final ResourceKey>> LOOT_MODIFIER_SERIALIZERS = key("forge:loot_modifier_serializers"); + public static final ResourceKey> WORLD_TYPES = key("forge:world_types"); - private static RegistryKey> key(String name) + private static ResourceKey> key(String name) { - return RegistryKey.createRegistryKey(new ResourceLocation(name)); + return ResourceKey.createRegistryKey(new ResourceLocation(name)); } private static void init() {} } diff --git a/src/main/java/net/minecraftforge/registries/ForgeRegistry.java b/src/main/java/net/minecraftforge/registries/ForgeRegistry.java index fce2690412..37394d5aa7 100644 --- a/src/main/java/net/minecraftforge/registries/ForgeRegistry.java +++ b/src/main/java/net/minecraftforge/registries/ForgeRegistry.java @@ -31,9 +31,9 @@ import java.util.Map.Entry; import javax.annotation.Nonnull; import javax.annotation.Nullable; +import net.minecraftforge.common.util.LogMessageAdapter; import net.minecraftforge.fml.ModLoadingContext; -import net.minecraftforge.fml.common.ObfuscationReflectionHelper; -import net.minecraftforge.fml.loading.AdvancedLogMessageAdapter; +import net.minecraftforge.fml.util.ObfuscationReflectionHelper; import org.apache.commons.lang3.Validate; import java.util.Set; @@ -48,13 +48,13 @@ import com.google.common.collect.Multimap; import com.google.common.collect.Sets; import io.netty.buffer.Unpooled; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.ListNBT; -import net.minecraft.nbt.StringNBT; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.RegistryKey; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.registry.Registry; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.nbt.StringTag; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.Registry; import net.minecraftforge.common.util.TablePrinter; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.event.RegistryEvent.MissingMappings; @@ -71,7 +71,7 @@ public class ForgeRegistry> implements IForgeRe private final RegistryManager stage; private final BiMap ids = HashBiMap.create(); private final BiMap names = HashBiMap.create(); - private final BiMap, V> keys = HashBiMap.create(); + private final BiMap, V> keys = HashBiMap.create(); private final Class superType; private final Map aliases = Maps.newHashMap(); final Map slaves = Maps.newHashMap(); @@ -100,13 +100,13 @@ public class ForgeRegistry> implements IForgeRe boolean isFrozen = false; private final ResourceLocation name; - private final RegistryKey> key; + private final ResourceKey> key; private final RegistryBuilder builder; ForgeRegistry(RegistryManager stage, ResourceLocation name, RegistryBuilder builder) { this.name = name; - this.key = RegistryKey.createRegistryKey(name); + this.key = ResourceKey.createRegistryKey(name); this.builder = builder; this.stage = stage; this.superType = builder.getType(); @@ -169,7 +169,7 @@ public class ForgeRegistry> implements IForgeRe return this.name; } - public RegistryKey> getRegistryKey() + public ResourceKey> getRegistryKey() { return this.key; } @@ -251,7 +251,7 @@ public class ForgeRegistry> implements IForgeRe } @Override - public Set, V>> getEntries() + public Set, V>> getEntries() { return Collections.unmodifiableSet(this.keys.entrySet()); } @@ -299,7 +299,7 @@ public class ForgeRegistry> implements IForgeRe } @Nullable - public RegistryKey getKey(int id) + public ResourceKey getKey(int id) { V value = getValue(id); return this.keys.inverse().get(value); @@ -375,7 +375,7 @@ public class ForgeRegistry> implements IForgeRe } this.names.put(key, value); - this.keys.put(RegistryKey.create(this.key, key), value); + this.keys.put(ResourceKey.create(this.key, key), value); this.ids.put(idToUse, value); this.availabilityMap.set(idToUse); this.owners.put(new OverrideOwner(owner == null ? key.getPath() : owner, key), value); @@ -635,7 +635,7 @@ public class ForgeRegistry> implements IForgeRe V value = this.names.remove(key); if (value != null) { - RegistryKey rkey = this.keys.inverse().remove(value); + ResourceKey rkey = this.keys.inverse().remove(value); if (rkey == null) throw new IllegalStateException("Removed a entry that did not have an associated RegistryKey: " + key + " " + value.toString() + " This should never happen unless hackery!"); @@ -691,7 +691,7 @@ public class ForgeRegistry> implements IForgeRe .header("Key", r -> r.key) .header("Value", r -> r.value); - LOGGER.debug(REGISTRYDUMP, ()-> new AdvancedLogMessageAdapter(sb -> + LOGGER.debug(REGISTRYDUMP, ()-> LogMessageAdapter.adapt(sb -> { sb.append("Registry Name: ").append(name).append('\n'); tab.clearRows(); @@ -705,22 +705,7 @@ public class ForgeRegistry> implements IForgeRe } } - //TODO: Convert to record in 1.17+ - private static class DumpRow - { - final String id; - final String key; - final String value; - final String dummied; - - private DumpRow(String id, String key, String value, String dummied) - { - this.id = id; - this.key = key; - this.value = value; - this.dummied = dummied; - } - } + private record DumpRow(String id, String key, String value, String dummied) {} public void loadIds(Map ids, Map overrides, Map missing, Map remapped, ForgeRegistry old, ResourceLocation name) { @@ -839,7 +824,7 @@ public class ForgeRegistry> implements IForgeRe if (value == null) throw new IllegalStateException("ContainsKey for " + key + " was true, but removing by name returned no value.. This should never happen unless hackery!"); - RegistryKey rkey = this.keys.inverse().remove(value); // Remove from the RegistryKey -> Value map + ResourceKey rkey = this.keys.inverse().remove(value); // Remove from the RegistryKey -> Value map if (rkey == null) throw new IllegalStateException("Removed a entry that did not have an associated RegistryKey: " + key + " " + value.toString() + " This should never happen unless hackery!"); @@ -895,36 +880,36 @@ public class ForgeRegistry> implements IForgeRe public final Set blocked = Sets.newTreeSet(); public final Set dummied = Sets.newTreeSet(sorter); public final Map overrides = Maps.newTreeMap(sorter); - private PacketBuffer binary = null; + private FriendlyByteBuf binary = null; - public CompoundNBT write() + public CompoundTag write() { - CompoundNBT data = new CompoundNBT(); + CompoundTag data = new CompoundTag(); - ListNBT ids = new ListNBT(); + ListTag ids = new ListTag(); this.ids.entrySet().stream().forEach(e -> { - CompoundNBT tag = new CompoundNBT(); + CompoundTag tag = new CompoundTag(); tag.putString("K", e.getKey().toString()); tag.putInt("V", e.getValue()); ids.add(tag); }); data.put("ids", ids); - ListNBT aliases = new ListNBT(); + ListTag aliases = new ListTag(); this.aliases.entrySet().stream().forEach(e -> { - CompoundNBT tag = new CompoundNBT(); + CompoundTag tag = new CompoundTag(); tag.putString("K", e.getKey().toString()); tag.putString("V", e.getValue().toString()); aliases.add(tag); }); data.put("aliases", aliases); - ListNBT overrides = new ListNBT(); + ListTag overrides = new ListTag(); this.overrides.entrySet().stream().forEach(e -> { - CompoundNBT tag = new CompoundNBT(); + CompoundTag tag = new CompoundTag(); tag.putString("K", e.getKey().toString()); tag.putString("V", e.getValue()); overrides.add(tag); @@ -934,14 +919,14 @@ public class ForgeRegistry> implements IForgeRe int[] blocked = this.blocked.stream().mapToInt(x->x).sorted().toArray(); data.putIntArray("blocked", blocked); - ListNBT dummied = new ListNBT(); - this.dummied.stream().sorted().forEach(e -> dummied.add(StringNBT.valueOf(e.toString()))); + ListTag dummied = new ListTag(); + this.dummied.stream().sorted().forEach(e -> dummied.add(StringTag.valueOf(e.toString()))); data.put("dummied", dummied); return data; } - public static Snapshot read(CompoundNBT nbt) + public static Snapshot read(CompoundTag nbt) { Snapshot ret = new Snapshot(); if (nbt == null) @@ -949,24 +934,24 @@ public class ForgeRegistry> implements IForgeRe return ret; } - ListNBT list = nbt.getList("ids", 10); + ListTag list = nbt.getList("ids", 10); list.forEach(e -> { - CompoundNBT comp = (CompoundNBT)e; + CompoundTag comp = (CompoundTag)e; ret.ids.put(new ResourceLocation(comp.getString("K")), comp.getInt("V")); }); list = nbt.getList("aliases", 10); list.forEach(e -> { - CompoundNBT comp = (CompoundNBT)e; + CompoundTag comp = (CompoundTag)e; ret.aliases.put(new ResourceLocation(comp.getString("K")), new ResourceLocation(comp.getString("V"))); }); list = nbt.getList("overrides", 10); list.forEach(e -> { - CompoundNBT comp = (CompoundNBT)e; + CompoundTag comp = (CompoundTag)e; ret.overrides.put(new ResourceLocation(comp.getString("K")), comp.getString("V")); }); @@ -977,15 +962,15 @@ public class ForgeRegistry> implements IForgeRe } list = nbt.getList("dummied", 8); - list.forEach(e -> ret.dummied.add(new ResourceLocation(((StringNBT)e).getAsString()))); + list.forEach(e -> ret.dummied.add(new ResourceLocation(((StringTag)e).getAsString()))); return ret; } - public synchronized PacketBuffer getPacketData() + public synchronized FriendlyByteBuf getPacketData() { if (binary == null) { - PacketBuffer pkt = new PacketBuffer(Unpooled.buffer()); + FriendlyByteBuf pkt = new FriendlyByteBuf(Unpooled.buffer()); pkt.writeVarInt(this.ids.size()); this.ids.forEach((k,v) -> { @@ -1014,10 +999,10 @@ public class ForgeRegistry> implements IForgeRe this.binary = pkt; } - return new PacketBuffer(binary.slice()); + return new FriendlyByteBuf(binary.slice()); } - public static Snapshot read(PacketBuffer buff) + public static Snapshot read(FriendlyByteBuf buff) { if (buff == null) return new Snapshot(); diff --git a/src/main/java/net/minecraftforge/registries/ForgeRegistryEntry.java b/src/main/java/net/minecraftforge/registries/ForgeRegistryEntry.java index d95868e36c..69720f1cab 100644 --- a/src/main/java/net/minecraftforge/registries/ForgeRegistryEntry.java +++ b/src/main/java/net/minecraftforge/registries/ForgeRegistryEntry.java @@ -21,7 +21,7 @@ package net.minecraftforge.registries; import com.google.common.reflect.TypeToken; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; import javax.annotation.Nullable; /** diff --git a/src/main/java/net/minecraftforge/registries/GameData.java b/src/main/java/net/minecraftforge/registries/GameData.java index c634c89a93..395baa12eb 100644 --- a/src/main/java/net/minecraftforge/registries/GameData.java +++ b/src/main/java/net/minecraftforge/registries/GameData.java @@ -24,71 +24,63 @@ import com.mojang.serialization.Lifecycle; import java.util.*; -import net.minecraft.block.AirBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.material.Material; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.ai.attributes.Attribute; -import net.minecraft.entity.ai.attributes.AttributeModifierMap; -import net.minecraft.entity.ai.attributes.GlobalEntityTypeAttributes; -import net.minecraft.entity.ai.brain.memory.MemoryModuleType; -import net.minecraft.entity.ai.brain.schedule.Activity; -import net.minecraft.entity.ai.brain.schedule.Schedule; -import net.minecraft.entity.ai.brain.sensor.SensorType; -import net.minecraft.entity.item.PaintingType; -import net.minecraft.entity.merchant.villager.VillagerProfession; -import net.minecraft.fluid.Fluid; -import net.minecraft.inventory.container.ContainerType; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; -import net.minecraft.item.crafting.IRecipeSerializer; -import net.minecraft.network.datasync.IDataSerializer; -import net.minecraft.particles.ParticleType; -import net.minecraft.potion.Effect; -import net.minecraft.potion.Potion; -import net.minecraft.state.StateContainer; +import net.minecraft.world.level.block.AirBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.item.enchantment.Enchantment; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.ai.attributes.Attribute; +import net.minecraft.world.entity.ai.attributes.DefaultAttributes; +import net.minecraft.world.entity.ai.memory.MemoryModuleType; +import net.minecraft.world.entity.schedule.Activity; +import net.minecraft.world.entity.schedule.Schedule; +import net.minecraft.world.entity.ai.sensing.SensorType; +import net.minecraft.world.entity.decoration.Motive; +import net.minecraft.world.entity.npc.VillagerProfession; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.crafting.RecipeSerializer; +import net.minecraft.network.syncher.EntityDataSerializer; +import net.minecraft.core.particles.ParticleType; +import net.minecraft.world.effect.MobEffect; +import net.minecraft.world.item.alchemy.Potion; +import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.stats.StatType; -import net.minecraft.tags.TagRegistryManager; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.*; -import net.minecraft.util.registry.DefaultedRegistry; -import net.minecraft.util.registry.Registry; -import net.minecraft.util.registry.SimpleRegistry; -import net.minecraft.village.PointOfInterestType; -import net.minecraft.world.biome.Biome; -import net.minecraft.world.chunk.ChunkStatus; -import net.minecraft.world.gen.DebugChunkGenerator; -import net.minecraft.world.gen.blockplacer.BlockPlacerType; -import net.minecraft.world.gen.blockstateprovider.BlockStateProviderType; -import net.minecraft.world.gen.carver.WorldCarver; -import net.minecraft.world.gen.feature.Feature; -import net.minecraft.world.gen.feature.structure.Structure; -import net.minecraft.world.gen.foliageplacer.FoliagePlacerType; -import net.minecraft.world.gen.placement.Placement; -import net.minecraft.world.gen.surfacebuilders.SurfaceBuilder; -import net.minecraft.world.gen.treedecorator.TreeDecoratorType; -import net.minecraftforge.common.ForgeHooks; +import net.minecraft.tags.StaticTags; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.DefaultedRegistry; +import net.minecraft.core.Registry; +import net.minecraft.core.MappedRegistry; +import net.minecraft.world.entity.ai.village.poi.PoiType; +import net.minecraft.world.level.biome.Biome; +import net.minecraft.world.level.chunk.ChunkStatus; +import net.minecraft.world.level.levelgen.DebugLevelSource; +import net.minecraft.world.level.levelgen.feature.blockplacers.BlockPlacerType; +import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProviderType; +import net.minecraft.world.level.levelgen.carver.WorldCarver; +import net.minecraft.world.level.levelgen.feature.Feature; +import net.minecraft.world.level.levelgen.feature.StructureFeature; +import net.minecraft.world.level.levelgen.feature.foliageplacers.FoliagePlacerType; +import net.minecraft.world.level.levelgen.placement.FeatureDecorator; +import net.minecraft.world.level.levelgen.surfacebuilders.SurfaceBuilder; +import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecoratorType; import net.minecraftforge.common.ForgeTagHandler; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.loot.GlobalLootModifierSerializer; +import net.minecraftforge.common.util.LogMessageAdapter; import net.minecraftforge.common.world.ForgeWorldType; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.event.RegistryEvent.MissingMappings; -import net.minecraftforge.event.entity.EntityAttributeCreationEvent; -import net.minecraftforge.event.entity.EntityAttributeModificationEvent; -import net.minecraftforge.fml.ModContainer; -import net.minecraftforge.fml.ModLoader; import net.minecraftforge.fml.ModLoadingContext; -import net.minecraftforge.fml.ModLoadingStage; -import net.minecraftforge.fml.common.EnhancedRuntimeException; -import net.minecraftforge.fml.common.thread.EffectiveSide; -import net.minecraftforge.fml.event.lifecycle.FMLModIdMappingEvent; -import net.minecraftforge.fml.loading.AdvancedLogMessageAdapter; +import net.minecraftforge.fml.IModStateTransition; +import net.minecraftforge.fml.StartupMessageManager; +import net.minecraftforge.fml.util.EnhancedRuntimeException; +import net.minecraftforge.fml.util.thread.EffectiveSide; +import net.minecraftforge.fmllegacy.event.lifecycle.FMLModIdMappingEvent; -import net.minecraftforge.fml.loading.progress.StartupMessageManager; import org.apache.commons.lang3.Validate; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -99,7 +91,6 @@ import java.lang.reflect.Field; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; import java.util.function.BiConsumer; -import java.util.function.BiFunction; import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -107,7 +98,10 @@ import java.util.stream.Stream; import static net.minecraftforge.registries.ForgeRegistry.REGISTRIES; import static net.minecraftforge.registries.ForgeRegistries.Keys.*; -import net.minecraftforge.fml.common.EnhancedRuntimeException.WrappedPrintStream; +import net.minecraft.core.IdMapper; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.sounds.SoundEvent; /** * INTERNAL ONLY @@ -147,23 +141,23 @@ public class GameData makeRegistry(BLOCKS, Block.class, "air").addCallback(BlockCallbacks.INSTANCE).legacyName("blocks").create(); makeRegistry(FLUIDS, Fluid.class, "empty").create(); makeRegistry(ITEMS, Item.class, "air").addCallback(ItemCallbacks.INSTANCE).legacyName("items").create(); - makeRegistry(EFFECTS, Effect.class ).legacyName("potions").create(); + makeRegistry(EFFECTS, MobEffect.class ).legacyName("potions").create(); //makeRegistry(BIOMES, Biome.class).legacyName("biomes").create(); makeRegistry(SOUND_EVENTS, SoundEvent.class).legacyName("soundevents").create(); makeRegistry(POTIONS, Potion.class, "empty").legacyName("potiontypes").tagFolder("potions").create(); makeRegistry(ENCHANTMENTS, Enchantment.class).legacyName("enchantments").tagFolder("enchantments").create(); makeRegistry(ENTITY_TYPES, c(EntityType.class), "pig").legacyName("entities").create(); - makeRegistry(TILE_ENTITY_TYPES, c(TileEntityType.class)).disableSaving().legacyName("tileentities").tagFolder("tile_entity_types").create(); + makeRegistry(BLOCK_ENTITY_TYPES, c(BlockEntityType.class)).disableSaving().legacyName("blockentities").tagFolder("block_entity_types").create(); makeRegistry(PARTICLE_TYPES, c(ParticleType.class)).disableSaving().create(); - makeRegistry(CONTAINER_TYPES, c(ContainerType.class)).disableSaving().create(); - makeRegistry(PAINTING_TYPES, PaintingType.class, "kebab").create(); - makeRegistry(RECIPE_SERIALIZERS, c(IRecipeSerializer.class)).disableSaving().create(); + makeRegistry(CONTAINER_TYPES, c(MenuType.class)).disableSaving().create(); + makeRegistry(PAINTING_TYPES, Motive.class, "kebab").create(); + makeRegistry(RECIPE_SERIALIZERS, c(RecipeSerializer.class)).disableSaving().create(); makeRegistry(ATTRIBUTES, Attribute.class).onValidate(AttributeCallbacks.INSTANCE).disableSaving().disableSync().create(); makeRegistry(STAT_TYPES, c(StatType.class)).create(); // Villagers makeRegistry(VILLAGER_PROFESSIONS, VillagerProfession.class, "none").create(); - makeRegistry(POI_TYPES, PointOfInterestType.class, "unemployed").addCallback(PointOfInterestTypeCallbacks.INSTANCE).disableSync().create(); + makeRegistry(POI_TYPES, PoiType.class, "unemployed").addCallback(PointOfInterestTypeCallbacks.INSTANCE).disableSync().create(); makeRegistry(MEMORY_MODULE_TYPES, c(MemoryModuleType.class), "dummy").disableSync().create(); makeRegistry(SENSOR_TYPES, c(SensorType.class), "dummy").disableSaving().disableSync().create(); makeRegistry(SCHEDULES, Schedule.class).disableSaving().disableSync().create(); @@ -173,9 +167,9 @@ public class GameData makeRegistry(WORLD_CARVERS, c(WorldCarver.class)).disableSaving().disableSync().create(); makeRegistry(SURFACE_BUILDERS, c(SurfaceBuilder.class)).disableSaving().disableSync().create(); makeRegistry(FEATURES, c(Feature.class)).addCallback(FeatureCallbacks.INSTANCE).disableSaving().disableSync().create(); - makeRegistry(DECORATORS, c(Placement.class)).disableSaving().disableSync().create(); + makeRegistry(DECORATORS, c(FeatureDecorator.class)).disableSaving().disableSync().create(); makeRegistry(CHUNK_STATUS, ChunkStatus.class, "empty").disableSaving().disableSync().create(); - makeRegistry(STRUCTURE_FEATURES, c(Structure.class)).disableSaving().disableSync().create(); + makeRegistry(STRUCTURE_FEATURES, c(StructureFeature.class)).disableSaving().disableSync().create(); makeRegistry(BLOCK_STATE_PROVIDER_TYPES, c(BlockStateProviderType.class)).disableSaving().disableSync().create(); makeRegistry(BLOCK_PLACER_TYPES, c(BlockPlacerType.class)).disableSaving().disableSync().create(); makeRegistry(FOLIAGE_PLACER_TYPES, c(FoliagePlacerType.class)).disableSaving().disableSync().create(); @@ -192,30 +186,30 @@ public class GameData @SuppressWarnings("unchecked") //Ugly hack to let us pass in a typed Class object. Remove when we remove type specific references. private static Class c(Class cls) { return (Class)cls; } - private static > RegistryBuilder makeRegistry(RegistryKey> key, Class type) + private static > RegistryBuilder makeRegistry(ResourceKey> key, Class type) { return new RegistryBuilder().setName(key.location()).setType(type).setMaxID(MAX_VARINT).addCallback(new NamespacedWrapper.Factory()); } - private static > RegistryBuilder makeRegistry(RegistryKey> key, Class type, int min, int max) + private static > RegistryBuilder makeRegistry(ResourceKey> key, Class type, int min, int max) { return new RegistryBuilder().setName(key.location()).setType(type).setIDRange(min, max).hasWrapper(); } - private static > RegistryBuilder makeRegistry(RegistryKey> key, Class type, String _default) + private static > RegistryBuilder makeRegistry(ResourceKey> key, Class type, String _default) { return new RegistryBuilder().setName(key.location()).setType(type).setMaxID(MAX_VARINT).hasWrapper().setDefaultKey(new ResourceLocation(_default)); } - public static > SimpleRegistry getWrapper(RegistryKey> key, Lifecycle lifecycle) + public static > MappedRegistry getWrapper(ResourceKey> key, Lifecycle lifecycle) { IForgeRegistry reg = RegistryManager.ACTIVE.getRegistry(key); Validate.notNull(reg, "Attempted to get vanilla wrapper for unknown registry: " + key.toString()); @SuppressWarnings("unchecked") - SimpleRegistry ret = reg.getSlaveMap(NamespacedWrapper.Factory.ID, NamespacedWrapper.class); + MappedRegistry ret = reg.getSlaveMap(NamespacedWrapper.Factory.ID, NamespacedWrapper.class); Validate.notNull(ret, "Attempted to get vanilla wrapper for registry created incorrectly: " + key.toString()); return ret; } - public static > DefaultedRegistry getWrapper(RegistryKey> key, Lifecycle lifecycle, String defKey) + public static > DefaultedRegistry getWrapper(ResourceKey> key, Lifecycle lifecycle, String defKey) { IForgeRegistry reg = RegistryManager.ACTIVE.getRegistry(key); Validate.notNull(reg, "Attempted to get vanilla wrapper for unknown registry: " + key.toString()); @@ -232,27 +226,27 @@ public class GameData } @SuppressWarnings("unchecked") - public static ObjectIntIdentityMap getBlockStateIDMap() + public static IdMapper getBlockStateIDMap() { - return RegistryManager.ACTIVE.getRegistry(Block.class).getSlaveMap(BLOCKSTATE_TO_ID, ObjectIntIdentityMap.class); + return RegistryManager.ACTIVE.getRegistry(Block.class).getSlaveMap(BLOCKSTATE_TO_ID, IdMapper.class); } @SuppressWarnings("unchecked") - public static Map getBlockStatePointOfInterestTypeMap() + public static Map getBlockStatePointOfInterestTypeMap() { - return RegistryManager.ACTIVE.getRegistry(PointOfInterestType.class).getSlaveMap(BLOCKSTATE_TO_POINT_OF_INTEREST_TYPE, Map.class); + return RegistryManager.ACTIVE.getRegistry(PoiType.class).getSlaveMap(BLOCKSTATE_TO_POINT_OF_INTEREST_TYPE, Map.class); } @SuppressWarnings("unchecked") - public static Map, DataSerializerEntry> getSerializerMap() + public static Map, DataSerializerEntry> getSerializerMap() { return RegistryManager.ACTIVE.getRegistry(DataSerializerEntry.class).getSlaveMap(SERIALIZER_TO_ENTRY, Map.class); } @SuppressWarnings("unchecked") - public static BiMap> getStructureMap() + public static BiMap> getStructureMap() { - return (BiMap>) RegistryManager.ACTIVE.getRegistry(Feature.class).getSlaveMap(STRUCTURES, BiMap.class); + return (BiMap>) RegistryManager.ACTIVE.getRegistry(Feature.class).getSlaveMap(STRUCTURES, BiMap.class); } public static > K register_impl(K value) @@ -350,7 +344,7 @@ public class GameData } @SuppressWarnings("rawtypes") //Eclipse compiler generics issue. - public static Stream> generateRegistryEvents() { + public static Stream> generateRegistryEvents() { List keys = Lists.newArrayList(RegistryManager.ACTIVE.registries.keySet()); keys.sort((o1, o2) -> String.valueOf(o1).compareToIgnoreCase(String.valueOf(o2))); @@ -362,10 +356,10 @@ public class GameData keys.add(1, ITEMS.location()); final Function> registerEventGenerator = rl -> RegistryManager.ACTIVE.getRegistry(rl).getRegisterEvent(rl); - return keys.stream().map(rl -> ModLoadingStage.EventGenerator.fromFunction(mc -> registerEventGenerator.apply(rl))); + return keys.stream().map(rl -> IModStateTransition.EventGenerator.fromFunction(mc -> registerEventGenerator.apply(rl))); } - public static CompletableFuture> preRegistryEventDispatch(final Executor executor, final ModLoadingStage.EventGenerator> eventGenerator) { + public static CompletableFuture> preRegistryEventDispatch(final Executor executor, final IModStateTransition.EventGenerator> eventGenerator) { return CompletableFuture.runAsync(()-> { final RegistryEvent.Register event = eventGenerator.apply(null); final ResourceLocation rl = event.getName(); @@ -375,7 +369,7 @@ public class GameData }, executor).thenApply(v->Collections.emptyList()); } - public static CompletableFuture> postRegistryEventDispatch(final Executor executor, final ModLoadingStage.EventGenerator> eventGenerator) { + public static CompletableFuture> postRegistryEventDispatch(final Executor executor, final IModStateTransition.EventGenerator> eventGenerator) { return CompletableFuture.runAsync(()-> { final RegistryEvent.Register event = eventGenerator.apply(null); final ResourceLocation rl = event.getName(); @@ -406,18 +400,18 @@ public class GameData for (Map.Entry>> entry : RegistryManager.ACTIVE.registries.entrySet()) { ResourceLocation registryName = entry.getKey(); - if (entry.getValue().getTagFolder() != null && TagRegistryManager.get(registryName) == null) + if (entry.getValue().getTagFolder() != null && StaticTags.get(registryName) == null) { LOGGER.debug(REGISTRIES, "Registering custom tag type for: {}", registryName); customTagTypes.add(registryName); - TagRegistryManager.create(registryName, tagCollectionSupplier -> tagCollectionSupplier.getCustomTypeCollection(registryName)); + StaticTags.create(ResourceKey.createRegistryKey(registryName), entry.getValue().getTagFolder()); } } ForgeTagHandler.setCustomTagTypes(customTagTypes); } //Lets us clear the map so we can rebuild it. - private static class ClearableObjectIntIdentityMap extends ObjectIntIdentityMap + private static class ClearableObjectIntIdentityMap extends IdMapper { void clear() { @@ -445,8 +439,8 @@ public class GameData { if (oldBlock != null) { - StateContainer oldContainer = oldBlock.getStateDefinition(); - StateContainer newContainer = block.getStateDefinition(); + StateDefinition oldContainer = oldBlock.getStateDefinition(); + StateDefinition newContainer = block.getStateDefinition(); // Test vanilla blockstates, if the number matches, make sure they also match in their string representations if (block.getRegistryName().getNamespace().equals("minecraft") && !oldContainer.getProperties().equals(newContainer.getProperties())) @@ -460,7 +454,7 @@ public class GameData s.getPossibleValues().stream().map(Object::toString).collect(Collectors.joining( "," )))) .collect(Collectors.joining(";")); - LOGGER.error(REGISTRIES,()-> new AdvancedLogMessageAdapter(sb-> { + LOGGER.error(REGISTRIES,()-> LogMessageAdapter.adapt(sb-> { sb.append("Registry replacements for vanilla block '").append(block.getRegistryName()). append("' must not change the number or order of blockstates.\n"); sb.append("\tOld: ").append(oldSequence).append('\n'); @@ -521,7 +515,7 @@ public class GameData block.getLootTable(); } - DebugChunkGenerator.initValidStates(); + DebugLevelSource.initValidStates(); } private static class BlockDummyAir extends AirBlock //A named class so DummyBlockReplacementTest can detect if its a dummy @@ -583,7 +577,7 @@ public class GameData public void onValidate(IForgeRegistryInternal owner, RegistryManager stage, int id, ResourceLocation key, Attribute obj) { // some stuff hard patched in can cause this to derp if it's JUST vanilla, so skip - if (stage!=RegistryManager.VANILLA) GlobalEntityTypeAttributes.validate(); + if (stage!=RegistryManager.VANILLA) DefaultAttributes.validate(); } } @@ -595,7 +589,7 @@ public class GameData public void onAdd(IForgeRegistryInternal owner, RegistryManager stage, int id, DataSerializerEntry entry, @Nullable DataSerializerEntry oldEntry) { @SuppressWarnings("unchecked") - Map, DataSerializerEntry> map = owner.getSlaveMap(SERIALIZER_TO_ENTRY, Map.class); + Map, DataSerializerEntry> map = owner.getSlaveMap(SERIALIZER_TO_ENTRY, Map.class); if (oldEntry != null) map.remove(oldEntry.getSerializer()); map.put(entry.getSerializer(), entry); } @@ -630,21 +624,21 @@ public class GameData } } - private static class PointOfInterestTypeCallbacks implements IForgeRegistry.AddCallback , IForgeRegistry.ClearCallback, IForgeRegistry.CreateCallback + private static class PointOfInterestTypeCallbacks implements IForgeRegistry.AddCallback , IForgeRegistry.ClearCallback, IForgeRegistry.CreateCallback { static final PointOfInterestTypeCallbacks INSTANCE = new PointOfInterestTypeCallbacks(); @Override - public void onAdd(IForgeRegistryInternal owner, RegistryManager stage, int id, PointOfInterestType obj, @Nullable PointOfInterestType oldObj) + public void onAdd(IForgeRegistryInternal owner, RegistryManager stage, int id, PoiType obj, @Nullable PoiType oldObj) { - Map map = owner.getSlaveMap(BLOCKSTATE_TO_POINT_OF_INTEREST_TYPE, Map.class); + Map map = owner.getSlaveMap(BLOCKSTATE_TO_POINT_OF_INTEREST_TYPE, Map.class); if (oldObj != null) { oldObj.getBlockStates().forEach(map::remove); } obj.getBlockStates().forEach((state) -> { - PointOfInterestType oldType = map.put(state, obj); + PoiType oldType = map.put(state, obj); if (oldType != null) { throw new IllegalStateException(String.format("Point of interest types %s and %s both list %s in their blockstates, this is not allowed. Blockstates can only have one point of interest type each.", oldType, obj, state)); @@ -653,13 +647,13 @@ public class GameData } @Override - public void onClear(IForgeRegistryInternal owner, RegistryManager stage) + public void onClear(IForgeRegistryInternal owner, RegistryManager stage) { owner.getSlaveMap(BLOCKSTATE_TO_POINT_OF_INTEREST_TYPE, Map.class).clear(); } @Override - public void onCreate(IForgeRegistryInternal owner, RegistryManager stage) + public void onCreate(IForgeRegistryInternal owner, RegistryManager stage) { owner.setSlaveMap(BLOCKSTATE_TO_POINT_OF_INTEREST_TYPE, new HashMap<>()); } @@ -796,7 +790,7 @@ public class GameData List> lst = event.getAllMappings().stream().filter(e -> e.getAction() == MissingMappings.Action.DEFAULT).sorted((a, b) -> a.toString().compareTo(b.toString())).collect(Collectors.toList()); if (!lst.isEmpty()) { - LOGGER.error(REGISTRIES,()->new AdvancedLogMessageAdapter(sb->{ + LOGGER.error(REGISTRIES,()->LogMessageAdapter.adapt(sb->{ sb.append("Unidentified mapping from registry ").append(name).append('\n'); lst.stream().sorted().forEach(map->sb.append('\t').append(map.key).append(": ").append(map.id).append('\n')); })); diff --git a/src/main/java/net/minecraftforge/registries/IForgeRegistry.java b/src/main/java/net/minecraftforge/registries/IForgeRegistry.java index 4878e9786a..f2a896c539 100644 --- a/src/main/java/net/minecraftforge/registries/IForgeRegistry.java +++ b/src/main/java/net/minecraftforge/registries/IForgeRegistry.java @@ -25,8 +25,8 @@ import java.util.Set; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import net.minecraft.util.RegistryKey; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; /** * Main interface for the registry system. Use this to query the registry system. @@ -52,7 +52,7 @@ public interface IForgeRegistry> extends Iterab @Nonnull Set getKeys(); @Nonnull Collection getValues(); - @Nonnull Set, V>> getEntries(); + @Nonnull Set, V>> getEntries(); /** * Retrieve the slave map of type T from the registry. diff --git a/src/main/java/net/minecraftforge/registries/IForgeRegistryEntry.java b/src/main/java/net/minecraftforge/registries/IForgeRegistryEntry.java index 29b6e4b2aa..8a817465b8 100644 --- a/src/main/java/net/minecraftforge/registries/IForgeRegistryEntry.java +++ b/src/main/java/net/minecraftforge/registries/IForgeRegistryEntry.java @@ -18,7 +18,7 @@ */ package net.minecraftforge.registries; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; import javax.annotation.Nullable; diff --git a/src/main/java/net/minecraftforge/registries/IForgeRegistryInternal.java b/src/main/java/net/minecraftforge/registries/IForgeRegistryInternal.java index 03b9fe1bec..d64e88c1af 100644 --- a/src/main/java/net/minecraftforge/registries/IForgeRegistryInternal.java +++ b/src/main/java/net/minecraftforge/registries/IForgeRegistryInternal.java @@ -19,7 +19,7 @@ package net.minecraftforge.registries; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; public interface IForgeRegistryInternal> extends IForgeRegistry { diff --git a/src/main/java/net/minecraftforge/registries/IForgeRegistryModifiable.java b/src/main/java/net/minecraftforge/registries/IForgeRegistryModifiable.java index 267f40763e..be83d63fc0 100644 --- a/src/main/java/net/minecraftforge/registries/IForgeRegistryModifiable.java +++ b/src/main/java/net/minecraftforge/registries/IForgeRegistryModifiable.java @@ -19,7 +19,7 @@ package net.minecraftforge.registries; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; public interface IForgeRegistryModifiable> extends IForgeRegistry { diff --git a/src/main/java/net/minecraftforge/registries/IRegistryDelegate.java b/src/main/java/net/minecraftforge/registries/IRegistryDelegate.java index 2e80710c92..a136e6bcd6 100644 --- a/src/main/java/net/minecraftforge/registries/IRegistryDelegate.java +++ b/src/main/java/net/minecraftforge/registries/IRegistryDelegate.java @@ -19,7 +19,7 @@ package net.minecraftforge.registries; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; import java.util.function.Supplier; diff --git a/src/main/java/net/minecraftforge/registries/NamespacedDefaultedWrapper.java b/src/main/java/net/minecraftforge/registries/NamespacedDefaultedWrapper.java index 5a4f42ee73..17d61cb8e1 100644 --- a/src/main/java/net/minecraftforge/registries/NamespacedDefaultedWrapper.java +++ b/src/main/java/net/minecraftforge/registries/NamespacedDefaultedWrapper.java @@ -31,9 +31,9 @@ import javax.annotation.Nullable; import org.apache.commons.lang3.Validate; -import net.minecraft.util.RegistryKey; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.registry.DefaultedRegistry; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.DefaultedRegistry; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -52,7 +52,7 @@ class NamespacedDefaultedWrapper> extends Defau } @Override - public V registerMapping(int id, RegistryKey key, V value, Lifecycle lifecycle) + public V registerMapping(int id, ResourceKey key, V value, Lifecycle lifecycle) { if (locked) throw new IllegalStateException("Can not register to a locked registry. Modder should use Forge Register methods."); @@ -69,13 +69,13 @@ class NamespacedDefaultedWrapper> extends Defau } @Override - public V register(RegistryKey key, V value, Lifecycle lifecycle) + public V register(ResourceKey key, V value, Lifecycle lifecycle) { return registerMapping(-1, key, value, lifecycle); } @Override - public V registerOrOverride(OptionalInt id, RegistryKey key, V value, Lifecycle lifecycle) { + public V registerOrOverride(OptionalInt id, ResourceKey key, V value, Lifecycle lifecycle) { int wanted = -1; if (id.isPresent() && byId(id.getAsInt()) != null) wanted = id.getAsInt(); @@ -98,7 +98,7 @@ class NamespacedDefaultedWrapper> extends Defau @Override @Nullable - public T get(@Nullable RegistryKey name) + public T get(@Nullable ResourceKey name) { return name == null ? null : this.delegate.getRaw(name.location()); //get without default } @@ -142,7 +142,7 @@ class NamespacedDefaultedWrapper> extends Defau } @Override - public Set, T>> entrySet() + public Set, T>> entrySet() { return this.delegate.getEntries(); } diff --git a/src/main/java/net/minecraftforge/registries/NamespacedWrapper.java b/src/main/java/net/minecraftforge/registries/NamespacedWrapper.java index 27e0127e0f..74ddc1eee8 100644 --- a/src/main/java/net/minecraftforge/registries/NamespacedWrapper.java +++ b/src/main/java/net/minecraftforge/registries/NamespacedWrapper.java @@ -28,16 +28,16 @@ import java.util.Random; import java.util.Set; import javax.annotation.Nullable; -import net.minecraft.util.RegistryKey; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.registry.SimpleRegistry; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.MappedRegistry; import org.apache.commons.lang3.Validate; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import com.mojang.serialization.Lifecycle; -class NamespacedWrapper> extends SimpleRegistry implements ILockableRegistry +class NamespacedWrapper> extends MappedRegistry implements ILockableRegistry { private static final Logger LOGGER = LogManager.getLogger(); private boolean locked = false; @@ -50,7 +50,7 @@ class NamespacedWrapper> extends SimpleRegistry } @Override - public V registerMapping(int id, RegistryKey key, V value, Lifecycle lifecycle) + public V registerMapping(int id, ResourceKey key, V value, Lifecycle lifecycle) { if (locked) throw new IllegalStateException("Can not register to a locked registry. Modder should use Forge Register methods."); @@ -67,13 +67,13 @@ class NamespacedWrapper> extends SimpleRegistry } @Override - public R register(RegistryKey key, R value, Lifecycle lifecycle) + public R register(ResourceKey key, R value, Lifecycle lifecycle) { return registerMapping(-1, key, value, lifecycle); } @Override - public V registerOrOverride(OptionalInt id, RegistryKey key, V value, Lifecycle lifecycle) { + public V registerOrOverride(OptionalInt id, ResourceKey key, V value, Lifecycle lifecycle) { int wanted = -1; if (id.isPresent() && byId(id.getAsInt()) != null) wanted = id.getAsInt(); @@ -96,7 +96,7 @@ class NamespacedWrapper> extends SimpleRegistry @Override @Nullable - public T get(@Nullable RegistryKey name) + public T get(@Nullable ResourceKey name) { return name == null ? null : this.delegate.getRaw(name.location()); //get without default } @@ -140,7 +140,7 @@ class NamespacedWrapper> extends SimpleRegistry } @Override - public Set, T>> entrySet() + public Set, T>> entrySet() { return this.delegate.getEntries(); } diff --git a/src/main/java/net/minecraftforge/registries/ObjectHolderRef.java b/src/main/java/net/minecraftforge/registries/ObjectHolderRef.java index 2e02f0452e..1d9bfe0a6c 100644 --- a/src/main/java/net/minecraftforge/registries/ObjectHolderRef.java +++ b/src/main/java/net/minecraftforge/registries/ObjectHolderRef.java @@ -27,8 +27,8 @@ import java.util.Queue; import java.util.function.Consumer; import java.util.function.Predicate; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.ResourceLocationException; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.ResourceLocationException; import javax.annotation.Nullable; diff --git a/src/main/java/net/minecraftforge/registries/ObjectHolderRegistry.java b/src/main/java/net/minecraftforge/registries/ObjectHolderRegistry.java index 822efb8593..4a940116a3 100644 --- a/src/main/java/net/minecraftforge/registries/ObjectHolderRegistry.java +++ b/src/main/java/net/minecraftforge/registries/ObjectHolderRegistry.java @@ -31,7 +31,7 @@ import java.util.function.Consumer; import java.util.function.Predicate; import java.util.stream.Collectors; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.forgespi.language.ModFileScanData; @@ -93,21 +93,21 @@ public class ObjectHolderRegistry final List annotations = ModList.get().getAllScanData().stream() .map(ModFileScanData::getAnnotations) .flatMap(Collection::stream) - .filter(a -> OBJECT_HOLDER.equals(a.getAnnotationType()) || MOD.equals(a.getAnnotationType())) + .filter(a -> OBJECT_HOLDER.equals(a.annotationType()) || MOD.equals(a.annotationType())) .collect(Collectors.toList()); Map classModIds = Maps.newHashMap(); Map> classCache = Maps.newHashMap(); // Gather all @Mod classes, so that @ObjectHolder's in those classes don't need to specify the mod id, Modder convince - annotations.stream().filter(a -> MOD.equals(a.getAnnotationType())).forEach(data -> classModIds.put(data.getClassType(), (String)data.getAnnotationData().get("value"))); + annotations.stream().filter(a -> MOD.equals(a.annotationType())).forEach(data -> classModIds.put(data.clazz(), (String)data.annotationData().get("value"))); // double pass - get all the class level annotations first, then the field level annotations - annotations.stream().filter(a -> OBJECT_HOLDER.equals(a.getAnnotationType())).filter(a -> a.getTargetType() == ElementType.TYPE) - .forEach(data -> scanTarget(classModIds, classCache, data.getClassType(), null, (String)data.getAnnotationData().get("value"), true, data.getClassType().getClassName().startsWith("net.minecraft."))); + annotations.stream().filter(a -> OBJECT_HOLDER.equals(a.annotationType())).filter(a -> a.targetType() == ElementType.TYPE) + .forEach(data -> scanTarget(classModIds, classCache, data.clazz(), null, (String)data.annotationData().get("value"), true, data.clazz().getClassName().startsWith("net.minecraft."))); - annotations.stream().filter(a -> OBJECT_HOLDER.equals(a.getAnnotationType())).filter(a -> a.getTargetType() == ElementType.FIELD) - .forEach(data -> scanTarget(classModIds, classCache, data.getClassType(), data.getMemberName(), (String)data.getAnnotationData().get("value"), false, false)); + annotations.stream().filter(a -> OBJECT_HOLDER.equals(a.annotationType())).filter(a -> a.targetType() == ElementType.FIELD) + .forEach(data -> scanTarget(classModIds, classCache, data.clazz(), data.memberName(), (String)data.annotationData().get("value"), false, false)); LOGGER.debug(REGISTRIES,"Found {} ObjectHolder annotations", objectHolders.size()); } diff --git a/src/main/java/net/minecraftforge/registries/RegistryBuilder.java b/src/main/java/net/minecraftforge/registries/RegistryBuilder.java index 7b010d993d..6c04f57a22 100644 --- a/src/main/java/net/minecraftforge/registries/RegistryBuilder.java +++ b/src/main/java/net/minecraftforge/registries/RegistryBuilder.java @@ -25,7 +25,7 @@ import java.util.Set; import com.google.common.collect.Lists; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.registries.IForgeRegistry.*; import javax.annotation.Nullable; diff --git a/src/main/java/net/minecraftforge/registries/RegistryDelegate.java b/src/main/java/net/minecraftforge/registries/RegistryDelegate.java index baf2f2043d..0ce37e1f2f 100644 --- a/src/main/java/net/minecraftforge/registries/RegistryDelegate.java +++ b/src/main/java/net/minecraftforge/registries/RegistryDelegate.java @@ -21,7 +21,7 @@ package net.minecraftforge.registries; import com.google.common.base.Objects; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; /* * This is the internal implementation class of the delegate. diff --git a/src/main/java/net/minecraftforge/registries/RegistryManager.java b/src/main/java/net/minecraftforge/registries/RegistryManager.java index 4b63f2bbb2..27e3a13869 100644 --- a/src/main/java/net/minecraftforge/registries/RegistryManager.java +++ b/src/main/java/net/minecraftforge/registries/RegistryManager.java @@ -32,10 +32,10 @@ import com.google.common.collect.Maps; import com.google.common.collect.Sets; import com.google.common.collect.Sets.SetView; -import net.minecraft.util.RegistryKey; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.registry.Registry; -import net.minecraftforge.fml.network.FMLHandshakeMessages; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.Registry; +import net.minecraftforge.fmllegacy.network.FMLHandshakeMessages; import net.minecraftforge.registries.ForgeRegistry.Snapshot; import org.apache.commons.lang3.tuple.Pair; import org.apache.logging.log4j.LogManager; @@ -77,7 +77,7 @@ public class RegistryManager return (ForgeRegistry)this.registries.get(key); } - public > ForgeRegistry getRegistry(RegistryKey> key) + public > ForgeRegistry getRegistry(ResourceKey> key) { return getRegistry(key.location()); } diff --git a/src/main/java/net/minecraftforge/resource/ISelectiveResourceReloadListener.java b/src/main/java/net/minecraftforge/resource/ISelectiveResourceReloadListener.java deleted file mode 100644 index 317e3e1768..0000000000 --- a/src/main/java/net/minecraftforge/resource/ISelectiveResourceReloadListener.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.resource; - -import java.util.function.Predicate; - -import net.minecraft.resources.IResourceManager; -import net.minecraft.resources.IResourceManagerReloadListener; - -public interface ISelectiveResourceReloadListener extends IResourceManagerReloadListener -{ - @Override - default void onResourceManagerReload(IResourceManager resourceManager) - { - // For compatibility, call the selective version from the non-selective function - onResourceManagerReload(resourceManager, SelectiveReloadStateHandler.INSTANCE.get()); - } - - /** - * A version of onResourceManager that selectively chooses {@link net.minecraftforge.resource.IResourceType}s - * to reload. - * When using this, the given predicate should be called to ensure the relevant resources should - * be reloaded at this time. - * - * @param resourceManager the resource manager being reloaded - * @param resourcePredicate predicate to test whether any given resource type should be reloaded - */ - void onResourceManagerReload(IResourceManager resourceManager, Predicate resourcePredicate); -} diff --git a/src/main/java/net/minecraftforge/resource/SelectiveReloadStateHandler.java b/src/main/java/net/minecraftforge/resource/SelectiveReloadStateHandler.java deleted file mode 100644 index be6ecbc44b..0000000000 --- a/src/main/java/net/minecraftforge/resource/SelectiveReloadStateHandler.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.resource; - -import javax.annotation.Nullable; -import java.util.function.Predicate; - -import net.minecraft.resources.IResourceManagerReloadListener; -import net.minecraftforge.common.ForgeConfig; - -/** - * Handles reload parameters for selective loaders. - */ -public enum SelectiveReloadStateHandler -{ - INSTANCE; - - @Nullable - private Predicate currentPredicate = null; - - /*** - * Pushes a resource type predicate for the current reload. - * Should only be called when initiating a resource reload. - * If a reload is already in progress when this is called, an exception will be thrown. - * - * @param resourcePredicate the resource requirement predicate for the current reload - */ - public void beginReload(Predicate resourcePredicate) - { - if (this.currentPredicate != null) - { - throw new IllegalStateException("Recursive resource reloading detected"); - } - - this.currentPredicate = resourcePredicate; - } - - /** - * Gets the current reload resource predicate for the initiated reload. - * - * @return the active reload resource predicate, or an accepting one if none in progress - */ - public Predicate get() - { - if (this.currentPredicate == null || !ForgeConfig.CLIENT.selectiveResourceReloadEnabled.get()) - { - return ReloadRequirements.all(); - } - - return this.currentPredicate; - } - - /** - * Finishes the current reload and deletes the previously added reload predicate. - */ - public void endReload() - { - this.currentPredicate = null; - } - - //Helpder function for testing if vanilla listeners should reload. - @SuppressWarnings("deprecation") - public boolean test(IResourceManagerReloadListener listener) - { - IResourceType type = listener.getResourceType(); - return type == null || get() == null || get().test(type); - } -} diff --git a/src/main/java/net/minecraftforge/resource/package-info.java b/src/main/java/net/minecraftforge/resource/package-info.java index 66c6de816e..4302290154 100644 --- a/src/main/java/net/minecraftforge/resource/package-info.java +++ b/src/main/java/net/minecraftforge/resource/package-info.java @@ -21,6 +21,7 @@ @MethodsReturnNonnullByDefault package net.minecraftforge.resource; +import net.minecraft.MethodsReturnNonnullByDefault; + import javax.annotation.ParametersAreNonnullByDefault; -import mcp.MethodsReturnNonnullByDefault; diff --git a/src/main/java/net/minecraftforge/server/command/ChunkGenWorker.java b/src/main/java/net/minecraftforge/server/command/ChunkGenWorker.java index 85aff443d1..e218d9d79c 100644 --- a/src/main/java/net/minecraftforge/server/command/ChunkGenWorker.java +++ b/src/main/java/net/minecraftforge/server/command/ChunkGenWorker.java @@ -22,22 +22,21 @@ package net.minecraftforge.server.command; import java.util.ArrayDeque; import java.util.Queue; -import net.minecraft.command.CommandSource; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.TextComponent; -import net.minecraft.util.text.TranslationTextComponent; -import net.minecraft.world.server.ServerWorld; -import net.minecraft.world.DimensionType; -import net.minecraft.world.chunk.ChunkStatus; -import net.minecraft.world.chunk.IChunk; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.BaseComponent; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.chunk.ChunkStatus; +import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraftforge.common.WorldWorkerManager.IWorker; public class ChunkGenWorker implements IWorker { - private final CommandSource listener; + private final CommandSourceStack listener; protected final BlockPos start; protected final int total; - private final ServerWorld dim; + private final ServerLevel dim; private final Queue queue; private final int notificationFrequency; private int lastNotification = 0; @@ -45,7 +44,7 @@ public class ChunkGenWorker implements IWorker private int genned = 0; private Boolean keepingLoaded; - public ChunkGenWorker(CommandSource listener, BlockPos start, int total, ServerWorld dim, int interval) + public ChunkGenWorker(CommandSourceStack listener, BlockPos start, int total, ServerLevel dim, int interval) { this.listener = listener; this.start = start; @@ -82,9 +81,9 @@ public class ChunkGenWorker implements IWorker return ret; } - public TextComponent getStartMessage(CommandSource sender) + public BaseComponent getStartMessage(CommandSourceStack sender) { - return new TranslationTextComponent("commands.forge.gen.start", total, start.getX(), start.getZ(), dim); + return new TranslatableComponent("commands.forge.gen.start", total, start.getX(), start.getZ(), dim); } @Override @@ -122,7 +121,7 @@ public class ChunkGenWorker implements IWorker if (++lastNotification >= notificationFrequency || lastNotifcationTime < System.currentTimeMillis() - 60*1000) { - listener.sendSuccess(new TranslationTextComponent("commands.forge.gen.progress", total - queue.size(), total), true); + listener.sendSuccess(new TranslatableComponent("commands.forge.gen.progress", total - queue.size(), total), true); lastNotification = 0; lastNotifcationTime = System.currentTimeMillis(); } @@ -131,7 +130,7 @@ public class ChunkGenWorker implements IWorker int z = next.getZ(); if (!dim.hasChunk(x, z)) { //Chunk is unloaded - IChunk chunk = dim.getChunk(x, z, ChunkStatus.EMPTY, true); + ChunkAccess chunk = dim.getChunk(x, z, ChunkStatus.EMPTY, true); if (!chunk.getStatus().isOrAfter(ChunkStatus.FULL)) { chunk = dim.getChunk(x, z, ChunkStatus.FULL); genned++; //There isn't a way to check if the chunk is actually created just if it was loaded @@ -141,7 +140,7 @@ public class ChunkGenWorker implements IWorker if (queue.size() == 0) { - listener.sendSuccess(new TranslationTextComponent("commands.forge.gen.complete", genned, total, dim.dimension().location()), true); + listener.sendSuccess(new TranslatableComponent("commands.forge.gen.complete", genned, total, dim.dimension().location()), true); /* TODO: Readd if/when we introduce world unloading, or get Mojang to do it. if (keepingLoaded != null && !keepingLoaded) DimensionManager.keepLoaded(dim, false); diff --git a/src/main/java/net/minecraftforge/server/command/CommandDimensions.java b/src/main/java/net/minecraftforge/server/command/CommandDimensions.java index d4277702c1..80ca3d001f 100644 --- a/src/main/java/net/minecraftforge/server/command/CommandDimensions.java +++ b/src/main/java/net/minecraftforge/server/command/CommandDimensions.java @@ -19,17 +19,16 @@ package net.minecraftforge.server.command; -import net.minecraft.command.CommandSource; -import net.minecraft.command.Commands; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.registry.Registry; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TranslationTextComponent; -import net.minecraft.world.DimensionType; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.commands.Commands; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.Registry; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.world.level.dimension.DimensionType; +import net.minecraft.server.level.ServerLevel; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -39,21 +38,21 @@ import com.mojang.brigadier.builder.ArgumentBuilder; public class CommandDimensions { - static ArgumentBuilder register() + static ArgumentBuilder register() { return Commands.literal("dimensions") .requires(cs->cs.hasPermission(0)) //permission .executes(ctx -> { - ctx.getSource().sendSuccess(new TranslationTextComponent("commands.forge.dimensions.list"), true); + ctx.getSource().sendSuccess(new TranslatableComponent("commands.forge.dimensions.list"), true); final Registry reg = ctx.getSource().registryAccess().registryOrThrow(Registry.DIMENSION_TYPE_REGISTRY); Map> types = new HashMap<>(); - for (ServerWorld dim : ctx.getSource().getServer().getAllLevels()) { + for (ServerLevel dim : ctx.getSource().getServer().getAllLevels()) { types.computeIfAbsent(reg.getKey(dim.dimensionType()), k -> new ArrayList<>()).add(dim.dimension().location()); } types.keySet().stream().sorted().forEach(key -> { - ctx.getSource().sendSuccess(new StringTextComponent(key + ": " + types.get(key).stream().map(ResourceLocation::toString).sorted().collect(Collectors.joining(", "))), false); + ctx.getSource().sendSuccess(new TextComponent(key + ": " + types.get(key).stream().map(ResourceLocation::toString).sorted().collect(Collectors.joining(", "))), false); }); return 0; }); diff --git a/src/main/java/net/minecraftforge/server/command/CommandEntity.java b/src/main/java/net/minecraftforge/server/command/CommandEntity.java index 02f00ba693..e2868d6261 100644 --- a/src/main/java/net/minecraftforge/server/command/CommandEntity.java +++ b/src/main/java/net/minecraftforge/server/command/CommandEntity.java @@ -33,17 +33,17 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.exceptions.DynamicCommandExceptionType; import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; -import net.minecraft.command.CommandSource; -import net.minecraft.command.Commands; -import net.minecraft.command.ISuggestionProvider; -import net.minecraft.command.arguments.DimensionArgument; -import net.minecraft.util.RegistryKey; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.ChunkPos; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TranslationTextComponent; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.commands.Commands; +import net.minecraft.commands.SharedSuggestionProvider; +import net.minecraft.commands.arguments.DimensionArgument; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.world.level.Level; +import net.minecraft.server.level.ServerLevel; import net.minecraftforge.registries.ForgeRegistries; import org.apache.commons.lang3.tuple.MutablePair; @@ -51,7 +51,7 @@ import org.apache.commons.lang3.tuple.Pair; class CommandEntity { - static ArgumentBuilder register() + static ArgumentBuilder register() { return Commands.literal("entity") .then(EntityListCommand.register()); //TODO: //Kill, spawn, etc.. @@ -59,15 +59,15 @@ class CommandEntity private static class EntityListCommand { - private static final SimpleCommandExceptionType INVALID_FILTER = new SimpleCommandExceptionType(new TranslationTextComponent("commands.forge.entity.list.invalid")); - private static final DynamicCommandExceptionType INVALID_DIMENSION = new DynamicCommandExceptionType(dim -> new TranslationTextComponent("commands.forge.entity.list.invalidworld", dim)); - private static final SimpleCommandExceptionType NO_ENTITIES = new SimpleCommandExceptionType(new TranslationTextComponent("commands.forge.entity.list.none")); - static ArgumentBuilder register() + private static final SimpleCommandExceptionType INVALID_FILTER = new SimpleCommandExceptionType(new TranslatableComponent("commands.forge.entity.list.invalid")); + private static final DynamicCommandExceptionType INVALID_DIMENSION = new DynamicCommandExceptionType(dim -> new TranslatableComponent("commands.forge.entity.list.invalidworld", dim)); + private static final SimpleCommandExceptionType NO_ENTITIES = new SimpleCommandExceptionType(new TranslatableComponent("commands.forge.entity.list.none")); + static ArgumentBuilder register() { return Commands.literal("list") .requires(cs->cs.hasPermission(2)) //permission .then(Commands.argument("filter", StringArgumentType.string()) - .suggests((ctx, builder) -> ISuggestionProvider.suggest(ForgeRegistries.ENTITIES.getKeys().stream().map(ResourceLocation::toString).map(StringArgumentType::escapeIfRequired), builder)) + .suggests((ctx, builder) -> SharedSuggestionProvider.suggest(ForgeRegistries.ENTITIES.getKeys().stream().map(ResourceLocation::toString).map(StringArgumentType::escapeIfRequired), builder)) .then(Commands.argument("dim", DimensionArgument.dimension()) .executes(ctx -> execute(ctx.getSource(), StringArgumentType.getString(ctx, "filter"), DimensionArgument.getDimension(ctx, "dim").dimension())) ) @@ -76,7 +76,7 @@ class CommandEntity .executes(ctx -> execute(ctx.getSource(), "*", ctx.getSource().getLevel().dimension())); } - private static int execute(CommandSource sender, String filter, RegistryKey dim) throws CommandSyntaxException + private static int execute(CommandSourceStack sender, String filter, ResourceKey dim) throws CommandSyntaxException { final String cleanFilter = filter.replace("?", ".?").replace("*", ".*?"); @@ -85,12 +85,12 @@ class CommandEntity if (names.isEmpty()) throw INVALID_FILTER.create(); - ServerWorld world = sender.getServer().getLevel(dim); //TODO: DimensionManager so we can hotload? DimensionManager.getWorld(sender.getServer(), dim, false, false); + ServerLevel world = sender.getServer().getLevel(dim); //TODO: DimensionManager so we can hotload? DimensionManager.getWorld(sender.getServer(), dim, false, false); if (world == null) throw INVALID_DIMENSION.create(dim); Map>> list = Maps.newHashMap(); - world.getEntities().forEach(e -> { + world.getEntities().getAll().forEach(e -> { MutablePair> info = list.computeIfAbsent(e.getType().getRegistryName(), k -> MutablePair.of(0, Maps.newHashMap())); ChunkPos chunk = new ChunkPos(e.blockPosition()); info.left++; @@ -104,7 +104,7 @@ class CommandEntity if (info == null) throw NO_ENTITIES.create(); - sender.sendSuccess(new TranslationTextComponent("commands.forge.entity.list.single.header", name, info.getLeft()), false); + sender.sendSuccess(new TranslatableComponent("commands.forge.entity.list.single.header", name, info.getLeft()), false); List> toSort = new ArrayList<>(); toSort.addAll(info.getRight().entrySet()); toSort.sort((a, b) -> { @@ -118,7 +118,7 @@ class CommandEntity for (Map.Entry e : toSort) { if (limit-- == 0) break; - sender.sendSuccess(new StringTextComponent(" " + e.getValue() + ": " + e.getKey().x + ", " + e.getKey().z), false); + sender.sendSuccess(new TextComponent(" " + e.getValue() + ": " + e.getKey().x + ", " + e.getKey().z), false); } return toSort.size(); } @@ -144,8 +144,8 @@ class CommandEntity throw NO_ENTITIES.create(); int count = info.stream().mapToInt(Pair::getRight).sum(); - sender.sendSuccess(new TranslationTextComponent("commands.forge.entity.list.multiple.header", count), false); - info.forEach(e -> sender.sendSuccess(new StringTextComponent(" " + e.getValue() + ": " + e.getKey()), false)); + sender.sendSuccess(new TranslatableComponent("commands.forge.entity.list.multiple.header", count), false); + info.forEach(e -> sender.sendSuccess(new TextComponent(" " + e.getValue() + ": " + e.getKey()), false)); return info.size(); } } diff --git a/src/main/java/net/minecraftforge/server/command/CommandGenerate.java b/src/main/java/net/minecraftforge/server/command/CommandGenerate.java index 78f0cf957a..0d4122331b 100644 --- a/src/main/java/net/minecraftforge/server/command/CommandGenerate.java +++ b/src/main/java/net/minecraftforge/server/command/CommandGenerate.java @@ -23,18 +23,18 @@ import com.mojang.brigadier.arguments.IntegerArgumentType; import com.mojang.brigadier.builder.ArgumentBuilder; import com.mojang.brigadier.context.CommandContext; -import net.minecraft.command.CommandException; -import net.minecraft.command.CommandSource; -import net.minecraft.command.Commands; -import net.minecraft.command.arguments.BlockPosArgument; -import net.minecraft.command.arguments.DimensionArgument; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.commands.CommandRuntimeException; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.commands.Commands; +import net.minecraft.commands.arguments.coordinates.BlockPosArgument; +import net.minecraft.commands.arguments.DimensionArgument; +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; import net.minecraftforge.common.WorldWorkerManager; class CommandGenerate { - static ArgumentBuilder register() + static ArgumentBuilder register() { return Commands.literal("generate") .requires(cs->cs.hasPermission(4)) //permission @@ -42,21 +42,21 @@ class CommandGenerate .then(Commands.argument("count", IntegerArgumentType.integer(1)) .then(Commands.argument("dim", DimensionArgument.dimension()) .then(Commands.argument("interval", IntegerArgumentType.integer()) - .executes(ctx -> execute(ctx.getSource(), BlockPosArgument.getOrLoadBlockPos(ctx, "pos"), getInt(ctx, "count"), DimensionArgument.getDimension(ctx, "dim"), getInt(ctx, "interval"))) + .executes(ctx -> execute(ctx.getSource(), BlockPosArgument.getSpawnablePos(ctx, "pos"), getInt(ctx, "count"), DimensionArgument.getDimension(ctx, "dim"), getInt(ctx, "interval"))) ) - .executes(ctx -> execute(ctx.getSource(), BlockPosArgument.getOrLoadBlockPos(ctx, "pos"), getInt(ctx, "count"), DimensionArgument.getDimension(ctx, "dim"), -1)) + .executes(ctx -> execute(ctx.getSource(), BlockPosArgument.getSpawnablePos(ctx, "pos"), getInt(ctx, "count"), DimensionArgument.getDimension(ctx, "dim"), -1)) ) - .executes(ctx -> execute(ctx.getSource(), BlockPosArgument.getOrLoadBlockPos(ctx, "pos"), getInt(ctx, "count"), ctx.getSource().getLevel(), -1)) + .executes(ctx -> execute(ctx.getSource(), BlockPosArgument.getSpawnablePos(ctx, "pos"), getInt(ctx, "count"), ctx.getSource().getLevel(), -1)) ) ); } - private static int getInt(CommandContext ctx, String name) + private static int getInt(CommandContext ctx, String name) { return IntegerArgumentType.getInteger(ctx, name); } - private static int execute(CommandSource source, BlockPos pos, int count, ServerWorld dim, int interval) throws CommandException + private static int execute(CommandSourceStack source, BlockPos pos, int count, ServerLevel dim, int interval) throws CommandRuntimeException { BlockPos chunkpos = new BlockPos(pos.getX() >> 4, 0, pos.getZ() >> 4); diff --git a/src/main/java/net/minecraftforge/server/command/CommandModList.java b/src/main/java/net/minecraftforge/server/command/CommandModList.java index a0d9d92b9a..64577a87d8 100644 --- a/src/main/java/net/minecraftforge/server/command/CommandModList.java +++ b/src/main/java/net/minecraftforge/server/command/CommandModList.java @@ -20,19 +20,19 @@ package net.minecraftforge.server.command; import com.mojang.brigadier.builder.ArgumentBuilder; -import net.minecraft.command.CommandSource; -import net.minecraft.command.Commands; -import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.commands.Commands; +import net.minecraft.network.chat.TranslatableComponent; import net.minecraftforge.fml.ModList; import java.util.stream.Collectors; public class CommandModList { - static ArgumentBuilder register() + static ArgumentBuilder register() { return Commands.literal("mods") .requires(cs->cs.hasPermission(0)) //permission .executes(ctx -> { - ctx.getSource().sendSuccess(new TranslationTextComponent("commands.forge.mods.list", + ctx.getSource().sendSuccess(new TranslatableComponent("commands.forge.mods.list", ModList.get().applyForEachModFile(modFile -> // locator - filename : firstmod (version) - numberofmods\n String.format("%s %s : %s (%s) - %d", diff --git a/src/main/java/net/minecraftforge/server/command/CommandSetDimension.java b/src/main/java/net/minecraftforge/server/command/CommandSetDimension.java index 258ea8a473..f5be066bea 100644 --- a/src/main/java/net/minecraftforge/server/command/CommandSetDimension.java +++ b/src/main/java/net/minecraftforge/server/command/CommandSetDimension.java @@ -19,18 +19,18 @@ package net.minecraftforge.server.command; -import net.minecraft.command.CommandSource; -import net.minecraft.command.Commands; -import net.minecraft.command.arguments.BlockPosArgument; -import net.minecraft.command.arguments.DimensionArgument; -import net.minecraft.command.arguments.EntityArgument; -import net.minecraft.entity.Entity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.util.text.TranslationTextComponent; -import net.minecraft.util.text.event.ClickEvent; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.commands.Commands; +import net.minecraft.commands.arguments.coordinates.BlockPosArgument; +import net.minecraft.commands.arguments.DimensionArgument; +import net.minecraft.commands.arguments.EntityArgument; +import net.minecraft.world.entity.Entity; +import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.Component; +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.network.chat.ClickEvent; +import net.minecraft.server.level.ServerLevel; import com.mojang.brigadier.builder.ArgumentBuilder; import com.mojang.brigadier.context.CommandContext; @@ -47,23 +47,23 @@ import java.util.Collection; @Deprecated public class CommandSetDimension { - private static final SimpleCommandExceptionType NO_ENTITIES = new SimpleCommandExceptionType(new TranslationTextComponent("commands.forge.setdim.invalid.entity")); - private static final DynamicCommandExceptionType INVALID_DIMENSION = new DynamicCommandExceptionType(dim -> new TranslationTextComponent("commands.forge.setdim.invalid.dim", dim)); - static ArgumentBuilder register() + private static final SimpleCommandExceptionType NO_ENTITIES = new SimpleCommandExceptionType(new TranslatableComponent("commands.forge.setdim.invalid.entity")); + private static final DynamicCommandExceptionType INVALID_DIMENSION = new DynamicCommandExceptionType(dim -> new TranslatableComponent("commands.forge.setdim.invalid.dim", dim)); + static ArgumentBuilder register() { return Commands.literal("setdimension") .requires(cs->cs.hasPermission(2)) //permission .then(Commands.argument("targets", EntityArgument.entities()) .then(Commands.argument("dim", DimensionArgument.dimension()) .then(Commands.argument("pos", BlockPosArgument.blockPos()) - .executes(ctx -> execute(ctx, EntityArgument.getOptionalEntities(ctx, "targets"), DimensionArgument.getDimension(ctx, "dim"), BlockPosArgument.getOrLoadBlockPos(ctx, "pos"))) + .executes(ctx -> execute(ctx, EntityArgument.getOptionalEntities(ctx, "targets"), DimensionArgument.getDimension(ctx, "dim"), BlockPosArgument.getSpawnablePos(ctx, "pos"))) ) .executes(ctx -> execute(ctx, EntityArgument.getOptionalEntities(ctx, "targets"), DimensionArgument.getDimension(ctx, "dim"), new BlockPos(ctx.getSource().getPosition()))) ) ); } - private static int execute(CommandContext ctx, Collection entities, ServerWorld dim, BlockPos pos) throws CommandSyntaxException + private static int execute(CommandContext ctx, Collection entities, ServerLevel dim, BlockPos pos) throws CommandSyntaxException { entities.removeIf(e -> !canEntityTeleport(e)); if (entities.isEmpty()) @@ -71,9 +71,9 @@ public class CommandSetDimension String cmdTarget = "@s"; String posTarget = ""; - for (ParsedCommandNode parsed : ctx.getNodes()) + for (ParsedCommandNode parsed : ctx.getNodes()) { - final CommandNode node = parsed.getNode(); + final CommandNode node = parsed.getNode(); if (parsed.getNode() instanceof ArgumentCommandNode) { if ("target".equals(parsed.getNode().getName())) @@ -89,9 +89,9 @@ public class CommandSetDimension final String dimName = dim.dimension().location().toString(); final String finalCmdTarget = cmdTarget; final String finalPosTarget = posTarget; - ITextComponent suggestion = new TranslationTextComponent("/execute in %s run tp %s%s", dimName, cmdTarget, finalPosTarget) - .withStyle((style) -> style.withColor(TextFormatting.GREEN).withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/execute in " + dimName + " run tp " + finalCmdTarget + finalPosTarget))); - ctx.getSource().sendSuccess(new TranslationTextComponent("commands.forge.setdim.deprecated", suggestion), true); + Component suggestion = new TranslatableComponent("/execute in %s run tp %s%s", dimName, cmdTarget, finalPosTarget) + .withStyle((style) -> style.withColor(ChatFormatting.GREEN).withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/execute in " + dimName + " run tp " + finalCmdTarget + finalPosTarget))); + ctx.getSource().sendSuccess(new TranslatableComponent("commands.forge.setdim.deprecated", suggestion), true); return 0; } diff --git a/src/main/java/net/minecraftforge/server/command/CommandTps.java b/src/main/java/net/minecraftforge/server/command/CommandTps.java index f6c408fecd..c572f52a87 100644 --- a/src/main/java/net/minecraftforge/server/command/CommandTps.java +++ b/src/main/java/net/minecraftforge/server/command/CommandTps.java @@ -22,20 +22,20 @@ package net.minecraftforge.server.command; import java.text.DecimalFormat; import com.mojang.brigadier.builder.ArgumentBuilder; import com.mojang.brigadier.exceptions.CommandSyntaxException; -import net.minecraft.command.CommandSource; -import net.minecraft.command.Commands; -import net.minecraft.command.arguments.DimensionArgument; -import net.minecraft.util.registry.Registry; -import net.minecraft.util.text.TranslationTextComponent; -import net.minecraft.world.DimensionType; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.commands.Commands; +import net.minecraft.commands.arguments.DimensionArgument; +import net.minecraft.core.Registry; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.world.level.dimension.DimensionType; +import net.minecraft.server.level.ServerLevel; class CommandTps { private static final DecimalFormat TIME_FORMATTER = new DecimalFormat("########0.000"); private static final long[] UNLOADED = new long[] {0}; - static ArgumentBuilder register() + static ArgumentBuilder register() { return Commands.literal("tps") .requires(cs->cs.hasPermission(0)) //permission @@ -43,20 +43,20 @@ class CommandTps .executes(ctx -> sendTime(ctx.getSource(), DimensionArgument.getDimension(ctx, "dim"))) ) .executes(ctx -> { - for (ServerWorld dim : ctx.getSource().getServer().getAllLevels()) + for (ServerLevel dim : ctx.getSource().getServer().getAllLevels()) sendTime(ctx.getSource(), dim); @SuppressWarnings("resource") double meanTickTime = mean(ctx.getSource().getServer().tickTimes) * 1.0E-6D; double meanTPS = Math.min(1000.0/meanTickTime, 20); - ctx.getSource().sendSuccess(new TranslationTextComponent("commands.forge.tps.summary.all", TIME_FORMATTER.format(meanTickTime), TIME_FORMATTER.format(meanTPS)), false); + ctx.getSource().sendSuccess(new TranslatableComponent("commands.forge.tps.summary.all", TIME_FORMATTER.format(meanTickTime), TIME_FORMATTER.format(meanTPS)), false); return 0; } ); } - private static int sendTime(CommandSource cs, ServerWorld dim) throws CommandSyntaxException + private static int sendTime(CommandSourceStack cs, ServerLevel dim) throws CommandSyntaxException { long[] times = cs.getServer().getTickTime(dim.dimension()); @@ -66,7 +66,7 @@ class CommandTps final Registry reg = cs.registryAccess().registryOrThrow(Registry.DIMENSION_TYPE_REGISTRY); double worldTickTime = mean(times) * 1.0E-6D; double worldTPS = Math.min(1000.0 / worldTickTime, 20); - cs.sendSuccess(new TranslationTextComponent("commands.forge.tps.summary.named", dim.dimension().location().toString(), reg.getKey(dim.dimensionType()), TIME_FORMATTER.format(worldTickTime), TIME_FORMATTER.format(worldTPS)), false); + cs.sendSuccess(new TranslatableComponent("commands.forge.tps.summary.named", dim.dimension().location().toString(), reg.getKey(dim.dimensionType()), TIME_FORMATTER.format(worldTickTime), TIME_FORMATTER.format(worldTPS)), false); return 1; } diff --git a/src/main/java/net/minecraftforge/server/command/CommandTrack.java b/src/main/java/net/minecraftforge/server/command/CommandTrack.java index 62c52408aa..fc58f026d6 100644 --- a/src/main/java/net/minecraftforge/server/command/CommandTrack.java +++ b/src/main/java/net/minecraftforge/server/command/CommandTrack.java @@ -28,14 +28,14 @@ import java.util.Comparator; import java.util.List; import java.util.function.Function; -import net.minecraft.command.CommandException; -import net.minecraft.command.CommandSource; -import net.minecraft.command.Commands; -import net.minecraft.entity.Entity; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.commands.CommandRuntimeException; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.commands.Commands; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TranslatableComponent; import net.minecraftforge.server.timings.ForgeTimings; import net.minecraftforge.server.timings.TimeTracker; @@ -43,19 +43,19 @@ class CommandTrack { private static final DecimalFormat TIME_FORMAT = new DecimalFormat("#####0.00"); - static ArgumentBuilder register() + static ArgumentBuilder register() { return Commands.literal("track") .then(StartTrackingCommand.register()) .then(ResetTrackingCommand.register()) .then(TrackResultsEntity.register()) - .then(TrackResultsTileEntity.register()) + .then(TrackResultsBlockEntity.register()) .then(StartTrackingCommand.register()); } private static class StartTrackingCommand { - static ArgumentBuilder register() + static ArgumentBuilder register() { return Commands.literal("start") .requires(cs->cs.hasPermission(2)) //permission @@ -63,9 +63,9 @@ class CommandTrack .then(Commands.argument("duration", IntegerArgumentType.integer(1)) .executes(ctx -> { int duration = IntegerArgumentType.getInteger(ctx, "duration"); - TimeTracker.TILE_ENTITY_UPDATE.reset(); - TimeTracker.TILE_ENTITY_UPDATE.enable(duration); - ctx.getSource().sendSuccess(new TranslationTextComponent("commands.forge.tracking.te.enabled", duration), true); + TimeTracker.BLOCK_ENTITY_UPDATE.reset(); + TimeTracker.BLOCK_ENTITY_UPDATE.enable(duration); + ctx.getSource().sendSuccess(new TranslatableComponent("commands.forge.tracking.be.enabled", duration), true); return 0; }) ) @@ -76,7 +76,7 @@ class CommandTrack int duration = IntegerArgumentType.getInteger(ctx, "duration"); TimeTracker.ENTITY_UPDATE.reset(); TimeTracker.ENTITY_UPDATE.enable(duration); - ctx.getSource().sendSuccess(new TranslationTextComponent("commands.forge.tracking.entity.enabled", duration), true); + ctx.getSource().sendSuccess(new TranslatableComponent("commands.forge.tracking.entity.enabled", duration), true); return 0; }) ) @@ -86,21 +86,21 @@ class CommandTrack private static class ResetTrackingCommand { - static ArgumentBuilder register() + static ArgumentBuilder register() { return Commands.literal("reset") .requires(cs->cs.hasPermission(2)) //permission .then(Commands.literal("te") .executes(ctx -> { - TimeTracker.TILE_ENTITY_UPDATE.reset(); - ctx.getSource().sendSuccess(new TranslationTextComponent("commands.forge.tracking.te.reset"), true); + TimeTracker.BLOCK_ENTITY_UPDATE.reset(); + ctx.getSource().sendSuccess(new TranslatableComponent("commands.forge.tracking.be.reset"), true); return 0; }) ) .then(Commands.literal("entity") .executes(ctx -> { TimeTracker.ENTITY_UPDATE.reset(); - ctx.getSource().sendSuccess(new TranslationTextComponent("commands.forge.tracking.entity.reset"), true); + ctx.getSource().sendSuccess(new TranslatableComponent("commands.forge.tracking.entity.reset"), true); return 0; }) ); @@ -125,12 +125,12 @@ class CommandTrack return list; } - private static int execute(CommandSource source, TimeTracker tracker, Function, ITextComponent> toString) throws CommandException + private static int execute(CommandSourceStack source, TimeTracker tracker, Function, Component> toString) throws CommandRuntimeException { List> timingsList = getSortedTimings(tracker); if (timingsList.isEmpty()) { - source.sendSuccess(new TranslationTextComponent("commands.forge.tracking.no_data"), true); + source.sendSuccess(new TranslatableComponent("commands.forge.tracking.no_data"), true); } else { @@ -145,39 +145,39 @@ class CommandTrack private static class TrackResultsEntity { - static ArgumentBuilder register() + static ArgumentBuilder register() { return Commands.literal("entity").executes(ctx -> TrackResults.execute(ctx.getSource(), TimeTracker.ENTITY_UPDATE, data -> { Entity entity = data.getObject().get(); if (entity == null) - return new TranslationTextComponent("commands.forge.tracking.invalid"); + return new TranslatableComponent("commands.forge.tracking.invalid"); BlockPos pos = entity.blockPosition(); double averageTimings = data.getAverageTimings(); String tickTime = (averageTimings > 1000 ? TIME_FORMAT.format(averageTimings / 1000) : TIME_FORMAT.format(averageTimings)) + (averageTimings < 1000 ? "\u03bcs" : "ms"); - return new TranslationTextComponent("commands.forge.tracking.timing_entry", entity.getType().getRegistryName(), entity.level.dimension().location().toString(), pos.getX(), pos.getY(), pos.getZ(), tickTime); + return new TranslatableComponent("commands.forge.tracking.timing_entry", entity.getType().getRegistryName(), entity.level.dimension().location().toString(), pos.getX(), pos.getY(), pos.getZ(), tickTime); }) ); } } - private static class TrackResultsTileEntity + private static class TrackResultsBlockEntity { - static ArgumentBuilder register() + static ArgumentBuilder register() { - return Commands.literal("te").executes(ctx -> TrackResults.execute(ctx.getSource(), TimeTracker.TILE_ENTITY_UPDATE, data -> + return Commands.literal("te").executes(ctx -> TrackResults.execute(ctx.getSource(), TimeTracker.BLOCK_ENTITY_UPDATE, data -> { - TileEntity te = data.getObject().get(); + BlockEntity te = data.getObject().get(); if (te == null) - return new TranslationTextComponent("commands.forge.tracking.invalid"); + return new TranslatableComponent("commands.forge.tracking.invalid"); BlockPos pos = te.getBlockPos(); double averageTimings = data.getAverageTimings(); String tickTime = (averageTimings > 1000 ? TIME_FORMAT.format(averageTimings / 1000) : TIME_FORMAT.format(averageTimings)) + (averageTimings < 1000 ? "\u03bcs" : "ms"); - return new TranslationTextComponent("commands.forge.tracking.timing_entry", te.getType().getRegistryName(), te.getLevel().dimension().location().toString(), pos.getX(), pos.getY(), pos.getZ(), tickTime); + return new TranslatableComponent("commands.forge.tracking.timing_entry", te.getType().getRegistryName(), te.getLevel().dimension().location().toString(), pos.getX(), pos.getY(), pos.getZ(), tickTime); }) ); } diff --git a/src/main/java/net/minecraftforge/server/command/ConfigCommand.java b/src/main/java/net/minecraftforge/server/command/ConfigCommand.java index 0483a8989f..503644adcf 100644 --- a/src/main/java/net/minecraftforge/server/command/ConfigCommand.java +++ b/src/main/java/net/minecraftforge/server/command/ConfigCommand.java @@ -22,19 +22,19 @@ package net.minecraftforge.server.command; import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.builder.ArgumentBuilder; import com.mojang.brigadier.context.CommandContext; -import net.minecraft.command.CommandSource; -import net.minecraft.command.Commands; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.util.text.TranslationTextComponent; -import net.minecraft.util.text.event.ClickEvent; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.commands.Commands; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.network.chat.ClickEvent; import net.minecraftforge.fml.config.ConfigTracker; import net.minecraftforge.fml.config.ModConfig; import java.io.File; public class ConfigCommand { - public static void register(CommandDispatcher dispatcher) { + public static void register(CommandDispatcher dispatcher) { dispatcher.register( Commands.literal("config"). then(ShowFile.register()) @@ -42,7 +42,7 @@ public class ConfigCommand { } public static class ShowFile { - static ArgumentBuilder register() { + static ArgumentBuilder register() { return Commands.literal("showfile"). requires(cs->cs.hasPermission(0)). then(Commands.argument("mod", ModIdArgument.modIdArgument()). @@ -52,19 +52,19 @@ public class ConfigCommand { ); } - private static int showFile(final CommandContext context) { + private static int showFile(final CommandContext context) { final String modId = context.getArgument("mod", String.class); final ModConfig.Type type = context.getArgument("type", ModConfig.Type.class); final String configFileName = ConfigTracker.INSTANCE.getConfigFileName(modId, type); if (configFileName != null) { File f = new File(configFileName); - context.getSource().sendSuccess(new TranslationTextComponent("commands.config.getwithtype", + context.getSource().sendSuccess(new TranslatableComponent("commands.config.getwithtype", modId, type, - new StringTextComponent(f.getName()).withStyle(TextFormatting.UNDERLINE). + new TextComponent(f.getName()).withStyle(ChatFormatting.UNDERLINE). withStyle((style) -> style.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, f.getAbsolutePath()))) ), true); } else { - context.getSource().sendSuccess(new TranslationTextComponent("commands.config.noconfig", modId, type), + context.getSource().sendSuccess(new TranslatableComponent("commands.config.noconfig", modId, type), true); } return 0; diff --git a/src/main/java/net/minecraftforge/server/command/EnumArgument.java b/src/main/java/net/minecraftforge/server/command/EnumArgument.java index 3f785986f0..9f3b0eb19b 100644 --- a/src/main/java/net/minecraftforge/server/command/EnumArgument.java +++ b/src/main/java/net/minecraftforge/server/command/EnumArgument.java @@ -27,10 +27,10 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.exceptions.Dynamic2CommandExceptionType; import com.mojang.brigadier.suggestion.Suggestions; import com.mojang.brigadier.suggestion.SuggestionsBuilder; -import net.minecraft.command.ISuggestionProvider; -import net.minecraft.command.arguments.IArgumentSerializer; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.commands.SharedSuggestionProvider; +import net.minecraft.commands.synchronization.ArgumentSerializer; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.chat.TranslatableComponent; import java.util.Arrays; import java.util.Collection; @@ -40,7 +40,7 @@ import java.util.stream.Stream; public class EnumArgument> implements ArgumentType { private static final Dynamic2CommandExceptionType INVALID_ENUM = new Dynamic2CommandExceptionType( - (found, constants) -> new TranslationTextComponent("commands.forge.arguments.enum.invalid", constants, found)); + (found, constants) -> new TranslatableComponent("commands.forge.arguments.enum.invalid", constants, found)); private final Class enumClass; public static > EnumArgument enumArgument(Class enumClass) { @@ -62,7 +62,7 @@ public class EnumArgument> implements ArgumentType { @Override public CompletableFuture listSuggestions(final CommandContext context, final SuggestionsBuilder builder) { - return ISuggestionProvider.suggest(Stream.of(enumClass.getEnumConstants()).map(Object::toString), builder); + return SharedSuggestionProvider.suggest(Stream.of(enumClass.getEnumConstants()).map(Object::toString), builder); } @Override @@ -70,17 +70,17 @@ public class EnumArgument> implements ArgumentType { return Stream.of(enumClass.getEnumConstants()).map(Object::toString).collect(Collectors.toList()); } - public static class Serializer implements IArgumentSerializer> + public static class Serializer implements ArgumentSerializer> { @Override - public void serializeToNetwork(EnumArgument argument, PacketBuffer buffer) + public void serializeToNetwork(EnumArgument argument, FriendlyByteBuf buffer) { buffer.writeUtf(argument.enumClass.getName()); } @SuppressWarnings({"unchecked", "rawtypes"}) @Override - public EnumArgument deserializeFromNetwork(PacketBuffer buffer) + public EnumArgument deserializeFromNetwork(FriendlyByteBuf buffer) { try { diff --git a/src/main/java/net/minecraftforge/server/command/ForgeCommand.java b/src/main/java/net/minecraftforge/server/command/ForgeCommand.java index 0b647b7444..7916e564a0 100644 --- a/src/main/java/net/minecraftforge/server/command/ForgeCommand.java +++ b/src/main/java/net/minecraftforge/server/command/ForgeCommand.java @@ -21,14 +21,14 @@ package net.minecraftforge.server.command; import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.builder.LiteralArgumentBuilder; -import net.minecraft.command.CommandSource; +import net.minecraft.commands.CommandSourceStack; public class ForgeCommand { - public ForgeCommand(CommandDispatcher dispatcher) + public ForgeCommand(CommandDispatcher dispatcher) { dispatcher.register( - LiteralArgumentBuilder.literal("forge") + LiteralArgumentBuilder.literal("forge") .then(CommandTps.register()) .then(CommandTrack.register()) .then(CommandEntity.register()) diff --git a/src/main/java/net/minecraftforge/server/command/ModIdArgument.java b/src/main/java/net/minecraftforge/server/command/ModIdArgument.java index 87e7e4fcc9..7e6bd59fb4 100644 --- a/src/main/java/net/minecraftforge/server/command/ModIdArgument.java +++ b/src/main/java/net/minecraftforge/server/command/ModIdArgument.java @@ -26,7 +26,7 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.suggestion.Suggestions; import com.mojang.brigadier.suggestion.SuggestionsBuilder; -import net.minecraft.command.ISuggestionProvider; +import net.minecraft.commands.SharedSuggestionProvider; import net.minecraftforge.fml.ModContainer; import net.minecraftforge.fml.ModList; @@ -49,7 +49,7 @@ public class ModIdArgument implements ArgumentType { @Override public CompletableFuture listSuggestions(final CommandContext context, final SuggestionsBuilder builder) { - return ISuggestionProvider.suggest(ModList.get().applyForEachModContainer(ModContainer::getModId), builder); + return SharedSuggestionProvider.suggest(ModList.get().applyForEachModContainer(ModContainer::getModId), builder); } @Override diff --git a/src/main/java/net/minecraftforge/server/command/TextComponentHelper.java b/src/main/java/net/minecraftforge/server/command/TextComponentHelper.java index 04b6ac2ff6..612084328d 100644 --- a/src/main/java/net/minecraftforge/server/command/TextComponentHelper.java +++ b/src/main/java/net/minecraftforge/server/command/TextComponentHelper.java @@ -19,15 +19,15 @@ package net.minecraftforge.server.command; -import net.minecraft.command.ICommandSource; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.network.play.ServerPlayNetHandler; -import net.minecraft.util.text.LanguageMap; -import net.minecraft.util.text.TextComponent; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TranslationTextComponent; -import net.minecraftforge.fml.network.ConnectionType; -import net.minecraftforge.fml.network.NetworkHooks; +import net.minecraft.commands.CommandSource; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.network.ServerGamePacketListenerImpl; +import net.minecraft.locale.Language; +import net.minecraft.network.chat.BaseComponent; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraftforge.fmllegacy.network.ConnectionType; +import net.minecraftforge.fmllegacy.network.NetworkHooks; public class TextComponentHelper { @@ -37,21 +37,21 @@ public class 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 TextComponent createComponentTranslation(ICommandSource source, final String translation, final Object... args) + public static BaseComponent createComponentTranslation(CommandSource source, final String translation, final Object... args) { if (isVanillaClient(source)) { - return new StringTextComponent(String.format(LanguageMap.getInstance().getOrDefault(translation), args)); + return new TextComponent(String.format(Language.getInstance().getOrDefault(translation), args)); } - return new TranslationTextComponent(translation, args); + return new TranslatableComponent(translation, args); } - private static boolean isVanillaClient(ICommandSource sender) + private static boolean isVanillaClient(CommandSource sender) { - if (sender instanceof ServerPlayerEntity) + if (sender instanceof ServerPlayer) { - ServerPlayerEntity playerMP = (ServerPlayerEntity) sender; - ServerPlayNetHandler channel = playerMP.connection; + ServerPlayer playerMP = (ServerPlayer) sender; + ServerGamePacketListenerImpl channel = playerMP.connection; return NetworkHooks.getConnectionType(()->channel.connection) == ConnectionType.VANILLA; } return false; diff --git a/src/main/java/net/minecraftforge/server/command/package-info.java b/src/main/java/net/minecraftforge/server/command/package-info.java index 0a43d15f2d..b78acdaab9 100644 --- a/src/main/java/net/minecraftforge/server/command/package-info.java +++ b/src/main/java/net/minecraftforge/server/command/package-info.java @@ -21,6 +21,6 @@ @MethodsReturnNonnullByDefault package net.minecraftforge.server.command; -import javax.annotation.ParametersAreNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; -import mcp.MethodsReturnNonnullByDefault; +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/java/net/minecraftforge/server/console/ConsoleCommandCompleter.java b/src/main/java/net/minecraftforge/server/console/ConsoleCommandCompleter.java index a00f2b0cfc..ca3d81fe32 100644 --- a/src/main/java/net/minecraftforge/server/console/ConsoleCommandCompleter.java +++ b/src/main/java/net/minecraftforge/server/console/ConsoleCommandCompleter.java @@ -23,7 +23,7 @@ import com.mojang.brigadier.ParseResults; import com.mojang.brigadier.StringReader; import com.mojang.brigadier.suggestion.Suggestion; import com.mojang.brigadier.suggestion.Suggestions; -import net.minecraft.command.CommandSource; +import net.minecraft.commands.CommandSourceStack; import net.minecraft.server.dedicated.DedicatedServer; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -70,7 +70,7 @@ final class ConsoleCommandCompleter implements Completer try { - ParseResults results = this.server.getCommands().getDispatcher().parse(stringReader, this.server.createCommandSourceStack()); + ParseResults results = this.server.getCommands().getDispatcher().parse(stringReader, this.server.createCommandSourceStack()); Suggestions tabComplete = this.server.getCommands().getDispatcher().getCompletionSuggestions(results).get(); for (Suggestion suggestion : tabComplete.getList()) { diff --git a/src/main/java/net/minecraftforge/server/permission/DefaultPermissionHandler.java b/src/main/java/net/minecraftforge/server/permission/DefaultPermissionHandler.java index 5ff84d3074..5e1a95e47b 100644 --- a/src/main/java/net/minecraftforge/server/permission/DefaultPermissionHandler.java +++ b/src/main/java/net/minecraftforge/server/permission/DefaultPermissionHandler.java @@ -21,7 +21,7 @@ package net.minecraftforge.server.permission; import com.mojang.authlib.GameProfile; import net.minecraft.server.MinecraftServer; -import net.minecraftforge.fml.server.ServerLifecycleHooks; +import net.minecraftforge.fmllegacy.server.ServerLifecycleHooks; import net.minecraftforge.server.permission.context.IContext; import javax.annotation.Nullable; diff --git a/src/main/java/net/minecraftforge/server/permission/PermissionAPI.java b/src/main/java/net/minecraftforge/server/permission/PermissionAPI.java index 28cc8673e9..38ffbc7e4f 100644 --- a/src/main/java/net/minecraftforge/server/permission/PermissionAPI.java +++ b/src/main/java/net/minecraftforge/server/permission/PermissionAPI.java @@ -21,7 +21,7 @@ package net.minecraftforge.server.permission; import com.google.common.base.Preconditions; import com.mojang.authlib.GameProfile; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.entity.player.Player; import net.minecraftforge.server.permission.context.IContext; import net.minecraftforge.server.permission.context.PlayerContext; @@ -90,7 +90,7 @@ public class PermissionAPI * * @see PermissionAPI#hasPermission(GameProfile, String, IContext) */ - public static boolean hasPermission(PlayerEntity player, String node) + public static boolean hasPermission(Player player, String node) { Preconditions.checkNotNull(player, "Player can't be null!"); return hasPermission(player.getGameProfile(), node, new PlayerContext(player)); diff --git a/src/main/java/net/minecraftforge/server/permission/context/AreaContext.java b/src/main/java/net/minecraftforge/server/permission/context/AreaContext.java index 3f83c431c9..e23408311e 100644 --- a/src/main/java/net/minecraftforge/server/permission/context/AreaContext.java +++ b/src/main/java/net/minecraftforge/server/permission/context/AreaContext.java @@ -20,16 +20,16 @@ package net.minecraftforge.server.permission.context; import com.google.common.base.Preconditions; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.phys.AABB; import javax.annotation.Nullable; public class AreaContext extends PlayerContext { - private final AxisAlignedBB area; + private final AABB area; - public AreaContext(PlayerEntity ep, AxisAlignedBB aabb) + public AreaContext(Player ep, AABB aabb) { super(ep); area = Preconditions.checkNotNull(aabb, "AxisAlignedBB can't be null in AreaContext!"); diff --git a/src/main/java/net/minecraftforge/server/permission/context/BlockPosContext.java b/src/main/java/net/minecraftforge/server/permission/context/BlockPosContext.java index 148372f4c9..81d242dce3 100644 --- a/src/main/java/net/minecraftforge/server/permission/context/BlockPosContext.java +++ b/src/main/java/net/minecraftforge/server/permission/context/BlockPosContext.java @@ -20,11 +20,11 @@ package net.minecraftforge.server.permission.context; import com.google.common.base.Preconditions; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.ChunkPos; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.ChunkPos; import javax.annotation.Nullable; @@ -34,7 +34,7 @@ public class BlockPosContext extends PlayerContext private BlockState blockState; private Direction facing; - public BlockPosContext(PlayerEntity ep, BlockPos pos, @Nullable BlockState state, @Nullable Direction f) + public BlockPosContext(Player ep, BlockPos pos, @Nullable BlockState state, @Nullable Direction f) { super(ep); blockPos = Preconditions.checkNotNull(pos, "BlockPos can't be null in BlockPosContext!"); @@ -42,7 +42,7 @@ public class BlockPosContext extends PlayerContext facing = f; } - public BlockPosContext(PlayerEntity ep, ChunkPos pos) + public BlockPosContext(Player ep, ChunkPos pos) { this(ep, new BlockPos(pos.getMinBlockX() + 8, 0, pos.getMinBlockZ() + 8), null, null); } diff --git a/src/main/java/net/minecraftforge/server/permission/context/Context.java b/src/main/java/net/minecraftforge/server/permission/context/Context.java index 67b29fb6d0..9e86b24d29 100644 --- a/src/main/java/net/minecraftforge/server/permission/context/Context.java +++ b/src/main/java/net/minecraftforge/server/permission/context/Context.java @@ -19,8 +19,8 @@ package net.minecraftforge.server.permission.context; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.world.World; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.Level; import javax.annotation.Nullable; import java.util.HashMap; @@ -32,14 +32,14 @@ public class Context implements IContext @Override @Nullable - public World getWorld() + public Level getWorld() { return null; } @Override @Nullable - public PlayerEntity getPlayer() + public Player getPlayer() { return null; } diff --git a/src/main/java/net/minecraftforge/server/permission/context/ContextKeys.java b/src/main/java/net/minecraftforge/server/permission/context/ContextKeys.java index 1892d99c3d..8a27579d1a 100644 --- a/src/main/java/net/minecraftforge/server/permission/context/ContextKeys.java +++ b/src/main/java/net/minecraftforge/server/permission/context/ContextKeys.java @@ -19,11 +19,11 @@ package net.minecraftforge.server.permission.context; -import net.minecraft.block.BlockState; -import net.minecraft.entity.Entity; -import net.minecraft.util.Direction; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.Entity; +import net.minecraft.core.Direction; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; /** * Some default context keys, for easier compatibility @@ -41,6 +41,6 @@ public class ContextKeys public static final ContextKey TARGET = ContextKey.create("target", Entity.class); public static final ContextKey FACING = ContextKey.create("facing", Direction.class); - public static final ContextKey AREA = ContextKey.create("area", AxisAlignedBB.class); + public static final ContextKey AREA = ContextKey.create("area", AABB.class); public static final ContextKey BLOCK_STATE = ContextKey.create("blockstate", BlockState.class); } diff --git a/src/main/java/net/minecraftforge/server/permission/context/IContext.java b/src/main/java/net/minecraftforge/server/permission/context/IContext.java index 6a823d73f9..f6259b8d86 100644 --- a/src/main/java/net/minecraftforge/server/permission/context/IContext.java +++ b/src/main/java/net/minecraftforge/server/permission/context/IContext.java @@ -19,8 +19,8 @@ package net.minecraftforge.server.permission.context; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.world.World; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.Level; import javax.annotation.Nullable; @@ -33,13 +33,13 @@ public interface IContext * World from where permission is requested. Can be null */ @Nullable - World getWorld(); + Level getWorld(); /** * @return Player requesting permission. Can be null */ @Nullable - PlayerEntity getPlayer(); + Player getPlayer(); /** * @param key Context key diff --git a/src/main/java/net/minecraftforge/server/permission/context/PlayerContext.java b/src/main/java/net/minecraftforge/server/permission/context/PlayerContext.java index 95cb3e6f74..620467061c 100644 --- a/src/main/java/net/minecraftforge/server/permission/context/PlayerContext.java +++ b/src/main/java/net/minecraftforge/server/permission/context/PlayerContext.java @@ -20,26 +20,26 @@ package net.minecraftforge.server.permission.context; import com.google.common.base.Preconditions; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.world.World; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.Level; public class PlayerContext extends Context { - private final PlayerEntity player; + private final Player player; - public PlayerContext(PlayerEntity ep) + public PlayerContext(Player ep) { player = Preconditions.checkNotNull(ep, "Player can't be null in PlayerContext!"); } @Override - public World getWorld() + public Level getWorld() { return player.getCommandSenderWorld(); } @Override - public PlayerEntity getPlayer() + public Player getPlayer() { return player; } diff --git a/src/main/java/net/minecraftforge/server/permission/context/TargetContext.java b/src/main/java/net/minecraftforge/server/permission/context/TargetContext.java index 0b3f73946c..b38e6d047c 100644 --- a/src/main/java/net/minecraftforge/server/permission/context/TargetContext.java +++ b/src/main/java/net/minecraftforge/server/permission/context/TargetContext.java @@ -19,8 +19,8 @@ package net.minecraftforge.server.permission.context; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; import javax.annotation.Nullable; @@ -28,7 +28,7 @@ public class TargetContext extends PlayerContext { private final Entity target; - public TargetContext(PlayerEntity ep, @Nullable Entity entity) + public TargetContext(Player ep, @Nullable Entity entity) { super(ep); target = entity; diff --git a/src/main/java/net/minecraftforge/server/permission/context/WorldContext.java b/src/main/java/net/minecraftforge/server/permission/context/WorldContext.java index 6294bb2e49..9ef1538675 100644 --- a/src/main/java/net/minecraftforge/server/permission/context/WorldContext.java +++ b/src/main/java/net/minecraftforge/server/permission/context/WorldContext.java @@ -20,29 +20,29 @@ package net.minecraftforge.server.permission.context; import com.google.common.base.Preconditions; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.world.World; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.Level; import javax.annotation.Nullable; public class WorldContext extends Context { - private final World world; + private final Level world; - public WorldContext(World w) + public WorldContext(Level w) { world = Preconditions.checkNotNull(w, "World can't be null in WorldContext!"); } @Override - public World getWorld() + public Level getWorld() { return world; } @Override @Nullable - public PlayerEntity getPlayer() + public Player getPlayer() { return null; } diff --git a/src/main/java/net/minecraftforge/server/permission/context/package-info.java b/src/main/java/net/minecraftforge/server/permission/context/package-info.java index 45a4e18a40..8bc1264c13 100644 --- a/src/main/java/net/minecraftforge/server/permission/context/package-info.java +++ b/src/main/java/net/minecraftforge/server/permission/context/package-info.java @@ -17,6 +17,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -@javax.annotation.ParametersAreNonnullByDefault -@mcp.MethodsReturnNonnullByDefault +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault package net.minecraftforge.server.permission.context; + +import net.minecraft.MethodsReturnNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/java/net/minecraftforge/server/permission/package-info.java b/src/main/java/net/minecraftforge/server/permission/package-info.java index a2d6862acf..ea8bf450a4 100644 --- a/src/main/java/net/minecraftforge/server/permission/package-info.java +++ b/src/main/java/net/minecraftforge/server/permission/package-info.java @@ -17,6 +17,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -@javax.annotation.ParametersAreNonnullByDefault -@mcp.MethodsReturnNonnullByDefault +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault package net.minecraftforge.server.permission; + +import net.minecraft.MethodsReturnNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/java/net/minecraftforge/server/timings/ForgeTimings.java b/src/main/java/net/minecraftforge/server/timings/ForgeTimings.java index bacb732db7..122ab60650 100644 --- a/src/main/java/net/minecraftforge/server/timings/ForgeTimings.java +++ b/src/main/java/net/minecraftforge/server/timings/ForgeTimings.java @@ -20,7 +20,6 @@ package net.minecraftforge.server.timings; import java.lang.ref.WeakReference; -import java.util.Arrays; /** * ForgeTimings aggregates timings data collected by {@link TimeTracker} for an Object diff --git a/src/main/java/net/minecraftforge/server/timings/TimeTracker.java b/src/main/java/net/minecraftforge/server/timings/TimeTracker.java index 2638484db0..40ed9d2a6d 100644 --- a/src/main/java/net/minecraftforge/server/timings/TimeTracker.java +++ b/src/main/java/net/minecraftforge/server/timings/TimeTracker.java @@ -27,8 +27,8 @@ import java.util.concurrent.TimeUnit; import com.google.common.collect.ImmutableList; import com.google.common.collect.MapMaker; -import net.minecraft.entity.Entity; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.block.entity.BlockEntity; /** * A class to assist in the collection of data to measure the update times of ticking objects {currently Tile Entities and Entities} @@ -41,7 +41,7 @@ public class TimeTracker /** * A tracker for timing tile entity update */ - public static final TimeTracker TILE_ENTITY_UPDATE = new TimeTracker<>(); + public static final TimeTracker BLOCK_ENTITY_UPDATE = new TimeTracker<>(); /** * A tracker for timing entity updates */ diff --git a/src/main/java/net/minecraftforge/versions/forge/ForgeVersion.java b/src/main/java/net/minecraftforge/versions/forge/ForgeVersion.java index b5392e319d..21a29469c9 100644 --- a/src/main/java/net/minecraftforge/versions/forge/ForgeVersion.java +++ b/src/main/java/net/minecraftforge/versions/forge/ForgeVersion.java @@ -21,6 +21,7 @@ package net.minecraftforge.versions.forge; import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.VersionChecker; +import net.minecraftforge.fml.loading.FMLLoader; import net.minecraftforge.fml.loading.JarVersionLookupHandler; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -41,11 +42,11 @@ public class ForgeVersion static { LOGGER.debug(CORE, "Forge Version package {} from {}", ForgeVersion.class.getPackage(), ForgeVersion.class.getClassLoader()); - String vers = JarVersionLookupHandler.getImplementationVersion(ForgeVersion.class).orElse(System.getenv("FORGE_VERSION")); + String vers = JarVersionLookupHandler.getImplementationVersion(ForgeVersion.class).orElse(FMLLoader.versionInfo().forgeVersion()); if (vers == null) throw new RuntimeException("Missing forge version, cannot continue"); String spec = JarVersionLookupHandler.getSpecificationVersion(ForgeVersion.class).orElse(System.getenv("FORGE_SPEC")); if (spec == null) throw new RuntimeException("Missing forge spec, cannot continue"); - String group = JarVersionLookupHandler.getImplementationTitle(ForgeVersion.class).orElse(System.getenv("FORGE_GROUP")); + String group = JarVersionLookupHandler.getImplementationTitle(ForgeVersion.class).orElse(FMLLoader.versionInfo().forgeGroup()); if (group == null) { group = "net.minecraftforge"; // If all else fails, Our normal group } @@ -64,14 +65,14 @@ public class ForgeVersion public static VersionChecker.Status getStatus() { - return VersionChecker.getResult(ModList.get().getModFileById(MOD_ID).getMods().get(0)).status; + return VersionChecker.getResult(ModList.get().getModFileById(MOD_ID).getMods().get(0)).status(); } @Nullable public static String getTarget() { VersionChecker.CheckResult res = VersionChecker.getResult(ModList.get().getModFileById(MOD_ID).getMods().get(0)); - return res.target == null ? "" : res.target.toString(); + return res.target() == null ? "" : res.target().toString(); } public static String getSpec() { diff --git a/src/main/java/net/minecraftforge/versions/mcp/MCPVersion.java b/src/main/java/net/minecraftforge/versions/mcp/MCPVersion.java index 867553083b..26d2de6754 100644 --- a/src/main/java/net/minecraftforge/versions/mcp/MCPVersion.java +++ b/src/main/java/net/minecraftforge/versions/mcp/MCPVersion.java @@ -22,6 +22,9 @@ package net.minecraftforge.versions.mcp; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import net.minecraftforge.fml.loading.FMLLoader; +import net.minecraftforge.fml.loading.JarVersionLookupHandler; + import static net.minecraftforge.fml.Logging.CORE; public class MCPVersion { @@ -29,19 +32,13 @@ public class MCPVersion { private static final String mcVersion; private static final String mcpVersion; static { - String vers = MCPVersion.class.getPackage().getSpecificationVersion(); - if (vers == null) { - vers = System.getenv("MC_VERSION"); - } - if (vers == null) throw new RuntimeException("Missing MC version, cannot continue"); - mcVersion = vers; + LOGGER.debug(CORE, "MCP Version package {} from {}", MCPVersion.class.getPackage(), MCPVersion.class.getClassLoader()); + mcVersion = JarVersionLookupHandler.getSpecificationVersion(MCPVersion.class).orElse(FMLLoader.versionInfo().mcVersion()); + if (mcVersion == null) throw new RuntimeException("Missing MC version, cannot continue"); + + mcpVersion = JarVersionLookupHandler.getImplementationVersion(MCPVersion.class).orElse(FMLLoader.versionInfo().mcpVersion()); + if (mcpVersion == null) throw new RuntimeException("Missing MCP version, cannot continue"); - vers = MCPVersion.class.getPackage().getImplementationVersion(); - if (vers == null) { - vers = System.getenv("MCP_VERSION"); - } - if (vers == null) throw new RuntimeException("Missing MCP version, cannot continue"); - mcpVersion = vers; LOGGER.debug(CORE, "Found MC version information {}", mcVersion); LOGGER.debug(CORE, "Found MCP version information {}", mcpVersion); } diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index 0e1b137e72..0d967d9235 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -1,338 +1,401 @@ -public net.minecraft.advancements.CriteriaTriggers func_192118_a(Lnet/minecraft/advancements/ICriterionTrigger;)Lnet/minecraft/advancements/ICriterionTrigger; # register -#group public net.minecraft.block.Block -public net.minecraft.block.AbstractCoralPlantBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.AirBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.AttachedStemBlock (Lnet/minecraft/block/StemGrownBlock;Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.BarrierBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.BlastFurnaceBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.BreakableBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.BushBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.CactusBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.CakeBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.CarpetBlock (Lnet/minecraft/item/DyeColor;Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.CartographyTableBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.CarvedPumpkinBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.ChestBlock (Lnet/minecraft/block/AbstractBlock$Properties;Ljava/util/function/Supplier;)V # constructor -public net.minecraft.block.ChorusFlowerBlock (Lnet/minecraft/block/ChorusPlantBlock;Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.ChorusPlantBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.CoralFanBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.CoralFinBlock (Lnet/minecraft/block/Block;Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.CoralPlantBlock (Lnet/minecraft/block/Block;Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.CoralWallFanBlock (Lnet/minecraft/block/Block;Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.CraftingTableBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.CropsBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.DeadBushBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.DeadCoralPlantBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.DeadCoralWallFanBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.DispenserBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.DoorBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.EnchantingTableBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.EndGatewayBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.EndPortalBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.EndRodBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.EnderChestBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.FarmlandBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.FletchingTableBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.FlowingFluidBlock (Lnet/minecraft/fluid/FlowingFluid;Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.FourWayBlock (FFFFFLnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.FungusBlock (Lnet/minecraft/block/AbstractBlock$Properties;Ljava/util/function/Supplier;)V # constructor -public net.minecraft.block.FurnaceBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.GrassPathBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.GrindstoneBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.HorizontalFaceBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.JigsawBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.JukeboxBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.KelpBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.KelpTopBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.LadderBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.LecternBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.LeverBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.LilyPadBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.LoomBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.MelonBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.NetherRootsBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.NetherWartBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.NyliumBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.PaneBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.PoweredRailBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.PressurePlateBlock (Lnet/minecraft/block/PressurePlateBlock$Sensitivity;Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.PumpkinBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.RailBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.RedstoneTorchBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.RedstoneWallTorchBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.RepeaterBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.SaplingBlock (Lnet/minecraft/block/trees/Tree;Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.ScaffoldingBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.SeaGrassBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.SeaPickleBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.SixWayBlock (FLnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.SkullBlock (Lnet/minecraft/block/SkullBlock$ISkullType;Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.SkullPlayerBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.SkullWallPlayerBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.SmithingTableBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.SmokerBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.SnowBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.SnowyDirtBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.SpawnerBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.SpongeBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.StairsBlock (Lnet/minecraft/block/BlockState;Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.StemBlock (Lnet/minecraft/block/StemGrownBlock;Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.StoneButtonBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.StructureBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.StructureVoidBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.SugarCaneBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.TallGrassBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.TorchBlock (Lnet/minecraft/block/AbstractBlock$Properties;Lnet/minecraft/particles/IParticleData;)V # constructor -public net.minecraft.block.TrapDoorBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.WallSkullBlock (Lnet/minecraft/block/SkullBlock$ISkullType;Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.WallTorchBlock (Lnet/minecraft/block/AbstractBlock$Properties;Lnet/minecraft/particles/IParticleData;)V # constructor -public net.minecraft.block.WeightedPressurePlateBlock (ILnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.WetSpongeBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.WitherSkeletonSkullBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.WitherSkeletonWallSkullBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor -public net.minecraft.block.WoodButtonBlock (Lnet/minecraft/block/AbstractBlock$Properties;)V # constructor +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_91122_(Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/level/block/entity/BlockEntity;)Lnet/minecraft/world/item/ItemStack; # addCustomNbtData +public net.minecraft.client.Minecraft m_91271_()V # createSearchTrees +public-f net.minecraft.client.Options f_92059_ # keyMappings +#group protected net.minecraft.client.gui.Gui * +protected net.minecraft.client.gui.Gui f_168664_ # scopeScale +protected net.minecraft.client.gui.Gui f_168665_ # SPYGLASS_SCOPE_LOCATION +protected net.minecraft.client.gui.Gui f_168666_ # POWDER_SNOW_OUTLINE_LOCATION +protected net.minecraft.client.gui.Gui f_168667_ # COLOR_WHITE +protected net.minecraft.client.gui.Gui f_168668_ # MIN_CROSSHAIR_ATTACK_SPEED +protected net.minecraft.client.gui.Gui f_168669_ # NUM_HEARTS_PER_ROW +protected net.minecraft.client.gui.Gui f_168670_ # LINE_HEIGHT +protected net.minecraft.client.gui.Gui f_168671_ # SPACER +protected net.minecraft.client.gui.Gui f_168672_ # PORTAL_OVERLAY_ALPHA_MIN +protected net.minecraft.client.gui.Gui f_168673_ # HEART_SIZE +protected net.minecraft.client.gui.Gui f_168674_ # HEART_SEPARATION +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 +protected net.minecraft.client.gui.Gui f_92973_ # lastHealth +protected net.minecraft.client.gui.Gui f_92974_ # displayHealth +protected net.minecraft.client.gui.Gui f_92975_ # lastHealthTime +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_92979_ # chatListeners +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 +protected net.minecraft.client.gui.Gui f_92986_ # minecraft +protected net.minecraft.client.gui.Gui f_92987_ # itemRenderer +protected net.minecraft.client.gui.Gui f_92988_ # chat +protected net.minecraft.client.gui.Gui f_92989_ # tickCount +protected net.minecraft.client.gui.Gui f_92990_ # overlayMessageString +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 +protected net.minecraft.client.gui.Gui f_92999_ # bossOverlay +protected net.minecraft.client.gui.Gui f_93000_ # titleTime +protected net.minecraft.client.gui.Gui f_93001_ # title +protected net.minecraft.client.gui.Gui f_93002_ # subtitle #endgroup -public net.minecraft.block.Block func_180637_b(Lnet/minecraft/world/server/ServerWorld;Lnet/minecraft/util/math/BlockPos;I)V # popExperience -public net.minecraft.block.FireBlock func_220274_q(Lnet/minecraft/block/BlockState;)I # getBurnOdd -public net.minecraft.block.FireBlock func_220275_r(Lnet/minecraft/block/BlockState;)I # getFlameOdds -public net.minecraft.block.WoodType func_227047_a_(Lnet/minecraft/block/WoodType;)Lnet/minecraft/block/WoodType; # register -public-f net.minecraft.client.GameSettings field_74324_K # keyMappings -public net.minecraft.client.Minecraft field_71446_o # textureManager -public net.minecraft.client.Minecraft func_184119_a(Lnet/minecraft/item/ItemStack;Lnet/minecraft/tileentity/TileEntity;)Lnet/minecraft/item/ItemStack; # addCustomNbtData -public net.minecraft.client.Minecraft func_193986_ar()V # createSearchTrees -public net.minecraft.client.audio.SoundEngine field_148622_c # soundManager -#group protected net.minecraft.client.gui.IngameGui * -protected net.minecraft.client.gui.IngameGui field_110328_d # PUMPKIN_BLUR_LOCATION -protected net.minecraft.client.gui.IngameGui field_110329_b # VIGNETTE_LOCATION -protected net.minecraft.client.gui.IngameGui field_110330_c # WIDGETS_LOCATION -protected net.minecraft.client.gui.IngameGui field_175189_D # displayHealth -protected net.minecraft.client.gui.IngameGui field_175190_E # lastHealthTime -protected net.minecraft.client.gui.IngameGui field_175191_F # healthBlinkTime -protected net.minecraft.client.gui.IngameGui field_175192_A # titleStayTime -protected net.minecraft.client.gui.IngameGui field_175193_B # titleFadeOutTime -protected net.minecraft.client.gui.IngameGui field_175194_C # lastHealth -protected net.minecraft.client.gui.IngameGui field_175195_w # titleTime -protected net.minecraft.client.gui.IngameGui field_175196_v # tabList -protected net.minecraft.client.gui.IngameGui field_175197_u # spectatorGui -protected net.minecraft.client.gui.IngameGui field_175198_t # debugScreen -protected net.minecraft.client.gui.IngameGui field_175199_z # titleFadeInTime -protected net.minecraft.client.gui.IngameGui field_175200_y # subtitle -protected net.minecraft.client.gui.IngameGui field_175201_x # title -protected net.minecraft.client.gui.IngameGui field_184049_t # subtitleOverlay -protected net.minecraft.client.gui.IngameGui field_184050_w # bossOverlay -protected net.minecraft.client.gui.IngameGui field_191743_I # chatListeners -protected net.minecraft.client.gui.IngameGui field_194811_H # screenWidth -protected net.minecraft.client.gui.IngameGui field_194812_I # screenHeight -protected net.minecraft.client.gui.IngameGui field_243249_e # DEMO_EXPIRED_TEXT -protected net.minecraft.client.gui.IngameGui field_73837_f # tickCount -protected net.minecraft.client.gui.IngameGui field_73838_g # overlayMessageString -protected net.minecraft.client.gui.IngameGui field_73839_d # minecraft -protected net.minecraft.client.gui.IngameGui field_73840_e # chat -protected net.minecraft.client.gui.IngameGui field_73841_b # itemRenderer -protected net.minecraft.client.gui.IngameGui field_73842_c # random -protected net.minecraft.client.gui.IngameGui field_73844_j # animateOverlayMessageColor -protected net.minecraft.client.gui.IngameGui field_73845_h # overlayMessageTime -protected net.minecraft.client.gui.IngameGui field_92016_l # lastToolHighlight -protected net.minecraft.client.gui.IngameGui field_92017_k # toolHighlightTimer +protected net.minecraft.client.gui.Gui m_168675_(F)V # renderSpyglassOverlay +protected net.minecraft.client.gui.Gui m_168688_(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/world/entity/player/Player;IIIIFIIIZ)V # renderHearts +protected net.minecraft.client.gui.Gui m_168708_(Lnet/minecraft/resources/ResourceLocation;F)V # renderTextureOverlay +protected net.minecraft.client.gui.Gui m_93007_(F)V # renderPortalOverlay +protected net.minecraft.client.gui.Gui m_93009_(FLcom/mojang/blaze3d/vertex/PoseStack;)V # renderHotbar +protected net.minecraft.client.gui.Gui m_93036_(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/world/scores/Objective;)V # displayScoreboardSidebar +protected net.minecraft.client.gui.Gui m_93039_(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/gui/Font;III)V # drawBackdrop +protected net.minecraft.client.gui.Gui m_93067_(Lnet/minecraft/world/entity/Entity;)V # renderVignette +protected net.minecraft.client.gui.Gui m_93080_(Lcom/mojang/blaze3d/vertex/PoseStack;)V # renderCrosshair +protected net.minecraft.client.gui.components.AbstractSelectionList$Entry f_93521_ # list +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 +public net.minecraft.client.gui.screens.MenuScreens$ScreenConstructor +public net.minecraft.client.gui.screens.Screen f_169369_ # renderables +public net.minecraft.client.gui.screens.worldselection.WorldGenSettingsComponent m_101404_(Lnet/minecraft/world/level/levelgen/WorldGenSettings;)V # updateSettings +public net.minecraft.client.model.geom.LayerDefinitions f_171106_ # OUTER_ARMOR_DEFORMATION +public net.minecraft.client.model.geom.LayerDefinitions f_171107_ # INNER_ARMOR_DEFORMATION +public net.minecraft.client.particle.ParticleEngine m_107378_(Lnet/minecraft/core/particles/ParticleType;Lnet/minecraft/client/particle/ParticleEngine$SpriteParticleRegistration;)V # register +public net.minecraft.client.particle.ParticleEngine m_107381_(Lnet/minecraft/core/particles/ParticleType;Lnet/minecraft/client/particle/ParticleProvider;)V # register +public net.minecraft.client.particle.ParticleEngine$SpriteParticleRegistration +public net.minecraft.client.renderer.GameRenderer m_109128_(Lnet/minecraft/resources/ResourceLocation;)V # loadEffect +protected-f net.minecraft.client.renderer.RenderStateShard f_110131_ # setupState +public net.minecraft.client.renderer.RenderStateShard$TextureStateShard +protected-f net.minecraft.client.renderer.RenderStateShard$TextureStateShard f_110329_ # blur +protected-f net.minecraft.client.renderer.RenderStateShard$TextureStateShard f_110330_ # mipmap +public net.minecraft.client.renderer.RenderType m_173215_(Ljava/lang/String;Lcom/mojang/blaze3d/vertex/VertexFormat;Lcom/mojang/blaze3d/vertex/VertexFormat$Mode;IZZLnet/minecraft/client/renderer/RenderType$CompositeState;)Lnet/minecraft/client/renderer/RenderType$CompositeRenderType; # create +public net.minecraft.client.renderer.RenderType$CompositeState +public net.minecraft.client.renderer.block.model.BlockElement m_111320_(Lnet/minecraft/core/Direction;)[F # uvsByFace +public net.minecraft.client.renderer.block.model.BlockElement$Deserializer +public net.minecraft.client.renderer.block.model.BlockElement$Deserializer ()V # constructor +public net.minecraft.client.renderer.block.model.BlockElementFace$Deserializer +public net.minecraft.client.renderer.block.model.BlockElementFace$Deserializer ()V # constructor +public net.minecraft.client.renderer.block.model.BlockFaceUV$Deserializer +public net.minecraft.client.renderer.block.model.BlockFaceUV$Deserializer ()V # constructor +public net.minecraft.client.renderer.block.model.BlockModel f_111417_ # textureMap +public net.minecraft.client.renderer.block.model.BlockModel f_111418_ # parent +public net.minecraft.client.renderer.block.model.BlockModel f_111424_ # hasAmbientOcclusion +public net.minecraft.client.renderer.block.model.ItemOverride$Deserializer +public net.minecraft.client.renderer.block.model.ItemOverride$Deserializer ()V # constructor +protected net.minecraft.client.renderer.block.model.ItemOverrides ()V # constructor +public net.minecraft.client.renderer.block.model.ItemOverrides$BakedOverride +public net.minecraft.client.renderer.block.model.ItemTransform$Deserializer +public net.minecraft.client.renderer.block.model.ItemTransform$Deserializer ()V # constructor +public net.minecraft.client.renderer.block.model.ItemTransform$Deserializer f_111769_ # DEFAULT_ROTATION +public net.minecraft.client.renderer.block.model.ItemTransform$Deserializer f_111770_ # DEFAULT_TRANSLATION +public net.minecraft.client.renderer.block.model.ItemTransform$Deserializer f_111771_ # DEFAULT_SCALE +public net.minecraft.client.renderer.block.model.ItemTransforms$Deserializer +public net.minecraft.client.renderer.block.model.ItemTransforms$Deserializer ()V # constructor +public net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher f_112253_ # fontRenderer - needed for rendering text in TESR items before entering world +public net.minecraft.client.renderer.blockentity.BlockEntityRenderers m_173590_(Lnet/minecraft/world/level/block/entity/BlockEntityType;Lnet/minecraft/client/renderer/blockentity/BlockEntityRendererProvider;)V # register +private-f net.minecraft.client.renderer.blockentity.PistonHeadRenderer f_112441_ # blockRenderer - it's static so we need to un-finalize in case this class loads to early. +public net.minecraft.client.renderer.entity.EntityRenderDispatcher f_114362_ # renderers +public net.minecraft.client.renderer.entity.EntityRenderers m_174036_(Lnet/minecraft/world/entity/EntityType;Lnet/minecraft/client/renderer/entity/EntityRendererProvider;)V # register +protected net.minecraft.client.renderer.entity.ItemEntityRenderer m_115042_(Lnet/minecraft/world/item/ItemStack;)I # getRenderAmount +public net.minecraft.client.renderer.entity.ItemRenderer m_115162_(Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/blaze3d/vertex/VertexConsumer;Ljava/util/List;Lnet/minecraft/world/item/ItemStack;II)V # renderQuadList +public net.minecraft.client.renderer.entity.ItemRenderer m_115189_(Lnet/minecraft/client/resources/model/BakedModel;Lnet/minecraft/world/item/ItemStack;IILcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/blaze3d/vertex/VertexConsumer;)V # renderModelLists +public net.minecraft.client.renderer.entity.LivingEntityRenderer m_115326_(Lnet/minecraft/client/renderer/entity/layers/RenderLayer;)Z # addLayer +public net.minecraft.client.renderer.texture.TextureAtlasSprite m_118415_()I # getFrameCount +public net.minecraft.client.resources.ClientPackSource f_174791_ # BUILT_IN +private-f net.minecraft.client.resources.model.ModelBakery f_119216_ # atlasPreparations - need to un-finalize so that we can delay initialization to after calling super() in ModelLoader +protected net.minecraft.client.resources.model.ModelBakery f_119234_ # UNREFERENCED_TEXTURES +protected net.minecraft.client.resources.model.ModelBakery f_119243_ # resourceManager +protected net.minecraft.client.resources.model.ModelBakery m_119364_(Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/renderer/block/model/BlockModel; # loadBlockModel +public net.minecraft.client.sounds.SoundEngine f_120217_ # soundManager +public net.minecraft.commands.arguments.selector.EntitySelectorParser m_121229_()V # finalizePredicates +public net.minecraft.commands.arguments.selector.EntitySelectorParser m_121317_()V # parseOptions +public net.minecraft.commands.arguments.selector.options.EntitySelectorOptions m_121453_(Ljava/lang/String;Lnet/minecraft/commands/arguments/selector/options/EntitySelectorOptions$Modifier;Ljava/util/function/Predicate;Lnet/minecraft/network/chat/Component;)V # register +protected net.minecraft.core.IdMapper f_122653_ # nextId +protected net.minecraft.core.IdMapper f_122654_ # tToId - internal map +protected net.minecraft.core.IdMapper f_122655_ # idToT - internal index list +public net.minecraft.core.particles.ParticleType (ZLnet/minecraft/core/particles/ParticleOptions$Deserializer;)V # constructor +public net.minecraft.core.particles.SimpleParticleType (Z)V # constructor +protected net.minecraft.data.loot.BlockLoot m_124126_(Lnet/minecraft/world/level/ItemLike;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createSingleItemTable +protected net.minecraft.data.loot.BlockLoot m_124131_(Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/level/storage/loot/functions/FunctionUserBuilder;)Ljava/lang/Object; # applyExplosionDecay +protected net.minecraft.data.loot.BlockLoot m_124134_(Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/level/storage/loot/predicates/ConditionUserBuilder;)Ljava/lang/Object; # applyExplosionCondition +protected net.minecraft.data.loot.BlockLoot m_124139_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/item/Item;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createOreDrop +protected net.minecraft.data.loot.BlockLoot m_124142_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/item/Item;Lnet/minecraft/world/item/Item;Lnet/minecraft/world/level/storage/loot/predicates/LootItemCondition$Builder;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createCropDrops +protected net.minecraft.data.loot.BlockLoot m_124157_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;[F)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createLeavesDrops +protected net.minecraft.data.loot.BlockLoot m_124161_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/state/properties/Property;Ljava/lang/Comparable;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createSinglePropConditionTable +protected net.minecraft.data.loot.BlockLoot m_124165_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/storage/loot/LootTable$Builder;)V # add +protected net.minecraft.data.loot.BlockLoot m_124168_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/storage/loot/entries/LootPoolEntryContainer$Builder;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createSilkTouchDispatchTable +protected net.minecraft.data.loot.BlockLoot m_124171_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/storage/loot/predicates/LootItemCondition$Builder;Lnet/minecraft/world/level/storage/loot/entries/LootPoolEntryContainer$Builder;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createSelfDropDispatchTable +protected net.minecraft.data.loot.BlockLoot m_124175_(Lnet/minecraft/world/level/block/Block;Ljava/util/function/Function;)V # add +protected net.minecraft.data.loot.BlockLoot m_124250_(Lnet/minecraft/world/level/ItemLike;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createSilkTouchOnlyTable +protected net.minecraft.data.loot.BlockLoot m_124254_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/item/Item;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createStemDrops +protected net.minecraft.data.loot.BlockLoot m_124257_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/ItemLike;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createSingleItemTableWithSilkTouch +protected net.minecraft.data.loot.BlockLoot m_124260_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createDoublePlantWithSeedDrops +protected net.minecraft.data.loot.BlockLoot m_124263_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;[F)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createOakLeavesDrops +protected net.minecraft.data.loot.BlockLoot m_124267_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/storage/loot/entries/LootPoolEntryContainer$Builder;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createShearsDispatchTable +protected net.minecraft.data.loot.BlockLoot m_124270_(Lnet/minecraft/world/level/ItemLike;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createPotFlowerItemTable +protected net.minecraft.data.loot.BlockLoot m_124274_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/item/Item;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createAttachedStemDrops +protected net.minecraft.data.loot.BlockLoot m_124277_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/ItemLike;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createMushroomBlockDrop +protected net.minecraft.data.loot.BlockLoot m_124283_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/storage/loot/entries/LootPoolEntryContainer$Builder;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createSilkTouchOrShearsDispatchTable +protected net.minecraft.data.loot.BlockLoot m_124286_(Lnet/minecraft/world/level/ItemLike;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createShearsOnlyDrop +protected net.minecraft.data.loot.BlockLoot m_124290_(Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createSlabItemTable +protected net.minecraft.data.loot.BlockLoot m_124292_(Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createNameableBlockEntityTable +protected net.minecraft.data.loot.BlockLoot m_124294_(Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createShulkerBoxDrop +protected net.minecraft.data.loot.BlockLoot m_124296_(Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createBannerDrop +protected net.minecraft.data.loot.BlockLoot m_124298_(Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createBeeNestDrop +protected net.minecraft.data.loot.BlockLoot m_124300_(Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createBeeHiveDrop +protected net.minecraft.data.loot.BlockLoot m_124302_(Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createGrassDrops +protected net.minecraft.data.loot.BlockLoot m_124304_(Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createDoublePlantShearsDrop +protected net.minecraft.data.loot.BlockLoot m_176039_(Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/level/storage/loot/providers/number/NumberProvider;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createSingleItemTable +protected net.minecraft.data.loot.BlockLoot m_176042_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/level/storage/loot/providers/number/NumberProvider;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createSingleItemTableWithSilkTouch +protected net.minecraft.data.loot.BlockLoot m_176046_(Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createCopperOreDrops +protected net.minecraft.data.loot.BlockLoot m_176048_(Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createLapisOreDrops +protected net.minecraft.data.loot.BlockLoot m_176050_(Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createRedstoneOreDrops +protected net.minecraft.data.loot.BlockLoot m_176052_(Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createCaveVinesDrop +protected net.minecraft.data.loot.BlockLoot m_176054_(Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createGlowLichenDrops +protected net.minecraft.data.loot.BlockLoot m_176056_(Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createCandleDrops +protected net.minecraft.data.loot.BlockLoot m_176058_(Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createCandleCakeDrops +protected net.minecraft.data.loot.EntityLoot f_124366_ # ENTITY_ON_FIRE +protected net.minecraft.data.loot.EntityLoot m_124371_(Lnet/minecraft/world/entity/EntityType;Lnet/minecraft/world/level/storage/loot/LootTable$Builder;)V # add +protected net.minecraft.data.loot.EntityLoot m_124380_(Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/world/level/storage/loot/LootTable$Builder;)V # add +protected net.minecraft.data.recipes.RecipeProvider f_125970_ # generator +protected net.minecraft.data.recipes.RecipeProvider m_125975_(Lnet/minecraft/tags/Tag;)Lnet/minecraft/advancements/critereon/InventoryChangeTrigger$TriggerInstance; # has +protected net.minecraft.data.recipes.RecipeProvider m_125977_(Lnet/minecraft/world/level/ItemLike;)Lnet/minecraft/advancements/critereon/InventoryChangeTrigger$TriggerInstance; # has +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_126013_(Lnet/minecraft/data/HashCache;Lcom/google/gson/JsonObject;Ljava/nio/file/Path;)V # saveAdvancement +protected net.minecraft.data.recipes.RecipeProvider m_176531_(Ljava/util/function/Consumer;)V # buildCraftingRecipes +public net.minecraft.data.recipes.ShapedRecipeBuilder$Result +protected net.minecraft.data.tags.TagsProvider f_126543_ # builders +public net.minecraft.network.protocol.status.ClientboundStatusResponsePacket f_134885_ # GSON +protected net.minecraft.server.MinecraftServer f_129726_ # nextTickTime +public net.minecraft.server.dedicated.DedicatedServer f_139600_ # consoleInput +public net.minecraft.server.level.ServerChunkCache f_8328_ # generator +public net.minecraft.server.level.ServerChunkCache f_8329_ # level +public net.minecraft.server.level.ServerLevel m_142646_()Lnet/minecraft/world/level/entity/LevelEntityGetter; # getEntities +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.packs.AbstractPackResources f_10203_ # file +public net.minecraft.server.packs.resources.FallbackResourceManager f_10599_ # fallbacks +public net.minecraft.tags.BlockTags m_13116_(Ljava/lang/String;)Lnet/minecraft/tags/Tag$Named; # bind +public net.minecraft.tags.EntityTypeTags m_13127_(Ljava/lang/String;)Lnet/minecraft/tags/Tag$Named; # bind +public net.minecraft.tags.FluidTags m_13134_(Ljava/lang/String;)Lnet/minecraft/tags/Tag$Named; # bind +public net.minecraft.tags.ItemTags m_13194_(Ljava/lang/String;)Lnet/minecraft/tags/Tag$Named; # bind +protected net.minecraft.tags.StaticTagHelper$Wrapper f_13251_ # tag +public net.minecraft.tags.TagContainer (Ljava/util/Map;)V # constructor +public net.minecraft.tags.TagContainer f_144433_ # collections +public net.minecraft.util.WeighedRandom$WeighedRandomItem f_14482_ # weight +public net.minecraft.util.thread.BlockableEventLoop m_18689_(Ljava/lang/Runnable;)Ljava/util/concurrent/CompletableFuture; # submitAsync +#group public net.minecraft.world.damagesource.DamageSource *() #All methods public, most are already +public net.minecraft.world.damagesource.DamageSource (Ljava/lang/String;)V # constructor +public net.minecraft.world.damagesource.DamageSource m_146706_()Lnet/minecraft/world/damagesource/DamageSource; # damageHelmet +public net.minecraft.world.damagesource.DamageSource m_19380_()Lnet/minecraft/world/damagesource/DamageSource; # bypassArmor +public net.minecraft.world.damagesource.DamageSource m_19381_()Lnet/minecraft/world/damagesource/DamageSource; # bypassInvul +public net.minecraft.world.damagesource.DamageSource m_19382_()Lnet/minecraft/world/damagesource/DamageSource; # bypassMagic +public net.minecraft.world.damagesource.DamageSource m_19383_()Lnet/minecraft/world/damagesource/DamageSource; # setIsFire #endgroup -protected net.minecraft.client.gui.IngameGui func_194805_e(F)V # renderPortalOverlay -protected net.minecraft.client.gui.IngameGui func_194808_p()V # renderPumpkin -protected net.minecraft.client.gui.IngameGui func_212303_b(Lnet/minecraft/entity/Entity;)V # renderVignette -protected net.minecraft.client.gui.IngameGui func_238447_a_(Lcom/mojang/blaze3d/matrix/MatrixStack;Lnet/minecraft/scoreboard/ScoreObjective;)V # displayScoreboardSidebar -protected net.minecraft.client.gui.IngameGui func_238448_a_(Lcom/mojang/blaze3d/matrix/MatrixStack;Lnet/minecraft/client/gui/FontRenderer;III)V # drawBackdrop -protected net.minecraft.client.gui.IngameGui func_238456_d_(Lcom/mojang/blaze3d/matrix/MatrixStack;)V # renderCrosshair -public net.minecraft.client.gui.ScreenManager func_216911_a(Lnet/minecraft/inventory/container/ContainerType;Lnet/minecraft/client/gui/ScreenManager$IScreenFactory;)V # registerFactory -public net.minecraft.client.gui.ScreenManager$IScreenFactory -protected net.minecraft.client.gui.overlay.DebugOverlayGui field_211537_g # block -protected net.minecraft.client.gui.overlay.DebugOverlayGui field_211538_h # liquid -public net.minecraft.client.gui.screen.WorldOptionsScreen func_239043_a_(Lnet/minecraft/world/gen/settings/DimensionGeneratorSettings;)V # updateSettings -protected net.minecraft.client.gui.widget.list.AbstractList$AbstractListEntry field_230666_a_ # list -public net.minecraft.client.particle.ParticleManager func_199283_a(Lnet/minecraft/particles/ParticleType;Lnet/minecraft/client/particle/IParticleFactory;)V # registerFactory -public net.minecraft.client.particle.ParticleManager func_215234_a(Lnet/minecraft/particles/ParticleType;Lnet/minecraft/client/particle/ParticleManager$IParticleMetaFactory;)V # registerFactory -public net.minecraft.client.particle.ParticleManager$IParticleMetaFactory -public net.minecraft.client.renderer.GameRenderer func_175069_a(Lnet/minecraft/util/ResourceLocation;)V # loadEffect -private net.minecraft.client.renderer.ItemModelMesher field_199313_a # shapes - force public -> private -public net.minecraft.client.renderer.ItemRenderer func_229112_a_(Lcom/mojang/blaze3d/matrix/MatrixStack;Lcom/mojang/blaze3d/vertex/IVertexBuilder;Ljava/util/List;Lnet/minecraft/item/ItemStack;II)V # renderQuadList -public net.minecraft.client.renderer.ItemRenderer func_229114_a_(Lnet/minecraft/client/renderer/model/IBakedModel;Lnet/minecraft/item/ItemStack;IILcom/mojang/blaze3d/matrix/MatrixStack;Lcom/mojang/blaze3d/vertex/IVertexBuilder;)V # renderModelLists -protected-f net.minecraft.client.renderer.RenderState field_228507_Q_ # setupState -protected-f net.minecraft.client.renderer.RenderState$TextureState field_228603_R_ # blur -protected-f net.minecraft.client.renderer.RenderState$TextureState field_228604_S_ # mipmap -public net.minecraft.client.renderer.entity.EntityRendererManager field_78729_o # renderers -public net.minecraft.client.renderer.entity.EntityRendererManager func_229087_a_(Lnet/minecraft/entity/EntityType;Lnet/minecraft/client/renderer/entity/EntityRenderer;)V # register -protected net.minecraft.client.renderer.entity.ItemRenderer func_177078_a(Lnet/minecraft/item/ItemStack;)I # getRenderAmount -public net.minecraft.client.renderer.entity.LivingRenderer func_177094_a(Lnet/minecraft/client/renderer/entity/layers/LayerRenderer;)Z # addLayer -public net.minecraft.client.renderer.model.BlockFaceUV$Deserializer ()V # constructor -public net.minecraft.client.renderer.model.BlockModel field_178315_d # parent -public net.minecraft.client.renderer.model.BlockModel field_178318_c # textureMap -public net.minecraft.client.renderer.model.BlockModel field_178322_i # hasAmbientOcclusion -public net.minecraft.client.renderer.model.BlockPart func_178236_a(Lnet/minecraft/util/Direction;)[F # uvsByFace -public net.minecraft.client.renderer.model.BlockPart$Deserializer ()V # constructor -public net.minecraft.client.renderer.model.BlockPartFace$Deserializer ()V # constructor -public net.minecraft.client.renderer.model.ItemCameraTransforms$Deserializer ()V # constructor -public net.minecraft.client.renderer.model.ItemOverride$Deserializer ()V # constructor -protected net.minecraft.client.renderer.model.ItemOverrideList ()V # constructor -public net.minecraft.client.renderer.model.ItemTransformVec3f$Deserializer ()V # constructor -public net.minecraft.client.renderer.model.ItemTransformVec3f$Deserializer field_178360_b # DEFAULT_TRANSLATION -public net.minecraft.client.renderer.model.ItemTransformVec3f$Deserializer field_178361_c # DEFAULT_SCALE -public net.minecraft.client.renderer.model.ItemTransformVec3f$Deserializer field_178362_a # DEFAULT_ROTATION -protected net.minecraft.client.renderer.model.ModelBakery field_177598_f # resourceManager -protected net.minecraft.client.renderer.model.ModelBakery field_177602_b # UNREFERENCED_TEXTURES -private-f net.minecraft.client.renderer.model.ModelBakery field_217853_J # atlasPreparations - need to un-finalize so that we can delay initialization to after calling super() in ModelLoader -protected net.minecraft.client.renderer.model.ModelBakery func_177594_c(Lnet/minecraft/util/ResourceLocation;)Lnet/minecraft/client/renderer/model/BlockModel; # loadBlockModel -private-f net.minecraft.client.renderer.tileentity.PistonTileEntityRenderer field_178462_c # blockRenderer - it's static so we need to un-finalize in case this class loads to early. -public net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher field_147557_n # fontRenderer - needed for rendering text in TESR items before entering world -default net.minecraft.client.settings.KeyBinding field_74513_e # isDown -public net.minecraft.command.arguments.EntityOptions func_202024_a(Ljava/lang/String;Lnet/minecraft/command/arguments/EntityOptions$IFilter;Ljava/util/function/Predicate;Lnet/minecraft/util/text/ITextComponent;)V # register -public net.minecraft.command.arguments.EntitySelectorParser func_197396_n()V # finalizePredicates -public net.minecraft.command.arguments.EntitySelectorParser func_197404_d()V # parseOptions -protected net.minecraft.data.RecipeProvider field_200413_c # generator -protected net.minecraft.data.RecipeProvider func_200403_a(Lnet/minecraft/util/IItemProvider;)Lnet/minecraft/advancements/criterion/InventoryChangeTrigger$Instance; # hasItem -protected net.minecraft.data.RecipeProvider func_200404_a(Ljava/util/function/Consumer;)V # buildShapelessRecipes -protected net.minecraft.data.RecipeProvider func_200405_a([Lnet/minecraft/advancements/criterion/ItemPredicate;)Lnet/minecraft/advancements/criterion/InventoryChangeTrigger$Instance; # inventoryTrigger -protected net.minecraft.data.RecipeProvider func_200407_a(Lnet/minecraft/block/Block;)Lnet/minecraft/advancements/criterion/EnterBlockTrigger$Instance; # insideOf -protected net.minecraft.data.RecipeProvider func_200409_a(Lnet/minecraft/tags/ITag;)Lnet/minecraft/advancements/criterion/InventoryChangeTrigger$Instance; # hasItem -protected net.minecraft.data.RecipeProvider func_208310_b(Lnet/minecraft/data/DirectoryCache;Lcom/google/gson/JsonObject;Ljava/nio/file/Path;)V # saveAdvancement -public net.minecraft.data.ShapedRecipeBuilder$Result -protected net.minecraft.data.TagsProvider field_200434_b # builders -protected net.minecraft.data.loot.BlockLootTables func_218463_a(Lnet/minecraft/util/IItemProvider;Lnet/minecraft/loot/IRandomRange;)Lnet/minecraft/loot/LootTable$Builder; # createSingleItemTable -protected net.minecraft.data.loot.BlockLootTables func_218475_b(Lnet/minecraft/block/Block;Lnet/minecraft/item/Item;)Lnet/minecraft/loot/LootTable$Builder; # createStemDrops -protected net.minecraft.data.loot.BlockLootTables func_218476_a(Lnet/minecraft/block/Block;Lnet/minecraft/item/Item;)Lnet/minecraft/loot/LootTable$Builder; # createOreDrop -protected net.minecraft.data.loot.BlockLootTables func_218481_e(Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder; # createNameableBlockEntityTable -protected net.minecraft.data.loot.BlockLootTables func_218486_d(Lnet/minecraft/util/IItemProvider;)Lnet/minecraft/loot/LootTable$Builder; # createShearsOnlyDrop -protected net.minecraft.data.loot.BlockLootTables func_218491_c(Lnet/minecraft/block/Block;Lnet/minecraft/util/IItemProvider;)Lnet/minecraft/loot/LootTable$Builder; # createMushroomBlockDrop -protected net.minecraft.data.loot.BlockLootTables func_218494_a(Lnet/minecraft/block/Block;Lnet/minecraft/loot/conditions/ILootCondition$IBuilder;Lnet/minecraft/loot/LootEntry$Builder;)Lnet/minecraft/loot/LootTable$Builder; # createSelfDropDispatchTable -protected net.minecraft.data.loot.BlockLootTables func_218507_a(Lnet/minecraft/block/Block;Lnet/minecraft/loot/LootTable$Builder;)V # add -protected net.minecraft.data.loot.BlockLootTables func_218511_b(Lnet/minecraft/block/Block;Lnet/minecraft/loot/LootEntry$Builder;)Lnet/minecraft/loot/LootTable$Builder; # createShearsDispatchTable -protected net.minecraft.data.loot.BlockLootTables func_218513_d(Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder; # createSlabItemTable -protected net.minecraft.data.loot.BlockLootTables func_218515_b(Lnet/minecraft/block/Block;Lnet/minecraft/util/IItemProvider;)Lnet/minecraft/loot/LootTable$Builder; # createSingleItemTableWithSilkTouch -protected net.minecraft.data.loot.BlockLootTables func_218519_a(Lnet/minecraft/block/Block;Lnet/minecraft/loot/LootEntry$Builder;)Lnet/minecraft/loot/LootTable$Builder; # createSilkTouchDispatchTable -protected net.minecraft.data.loot.BlockLootTables func_218522_a(Lnet/minecraft/block/Block;Ljava/util/function/Function;)V # add -protected net.minecraft.data.loot.BlockLootTables func_218523_c(Lnet/minecraft/util/IItemProvider;)Lnet/minecraft/loot/LootTable$Builder; # createPotFlowerItemTable -protected net.minecraft.data.loot.BlockLootTables func_218526_b(Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;[F)Lnet/minecraft/loot/LootTable$Builder; # createOakLeavesDrops -protected net.minecraft.data.loot.BlockLootTables func_218530_a(Lnet/minecraft/block/Block;Lnet/minecraft/util/IItemProvider;Lnet/minecraft/loot/IRandomRange;)Lnet/minecraft/loot/LootTable$Builder; # createSingleItemTableWithSilkTouch -protected net.minecraft.data.loot.BlockLootTables func_218535_c(Lnet/minecraft/block/Block;Lnet/minecraft/loot/LootEntry$Builder;)Lnet/minecraft/loot/LootTable$Builder; # createSilkTouchOrShearsDispatchTable -protected net.minecraft.data.loot.BlockLootTables func_218540_a(Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;[F)Lnet/minecraft/loot/LootTable$Builder; # createLeavesDrops -protected net.minecraft.data.loot.BlockLootTables func_218541_a(Lnet/minecraft/block/Block;Lnet/minecraft/item/Item;Lnet/minecraft/item/Item;Lnet/minecraft/loot/conditions/ILootCondition$IBuilder;)Lnet/minecraft/loot/LootTable$Builder; # createCropDrops -protected net.minecraft.data.loot.BlockLootTables func_218544_f(Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder; # createShulkerBoxDrop -protected net.minecraft.data.loot.BlockLootTables func_218546_a(Lnet/minecraft/util/IItemProvider;)Lnet/minecraft/loot/LootTable$Builder; # createSingleItemTable -protected net.minecraft.data.loot.BlockLootTables func_218552_a(Lnet/minecraft/util/IItemProvider;Lnet/minecraft/loot/ILootFunctionConsumer;)Ljava/lang/Object; # applyExplosionDecay -protected net.minecraft.data.loot.BlockLootTables func_218559_g(Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder; # createBannerDrop -protected net.minecraft.data.loot.BlockLootTables func_218560_a(Lnet/minecraft/util/IItemProvider;Lnet/minecraft/loot/ILootConditionConsumer;)Ljava/lang/Object; # applyExplosionCondition -protected net.minecraft.data.loot.BlockLootTables func_218561_b(Lnet/minecraft/util/IItemProvider;)Lnet/minecraft/loot/LootTable$Builder; # createSilkTouchOnlyTable -protected net.minecraft.data.loot.BlockLootTables func_218562_a(Lnet/minecraft/block/Block;Lnet/minecraft/state/Property;Ljava/lang/Comparable;)Lnet/minecraft/loot/LootTable$Builder; # createSinglePropConditionTable -protected net.minecraft.data.loot.BlockLootTables func_218570_h(Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder; # createGrassDrops -protected net.minecraft.data.loot.EntityLootTables field_218586_a # ENTITY_ON_FIRE -protected net.minecraft.data.loot.EntityLootTables func_218582_a(Lnet/minecraft/entity/EntityType;Lnet/minecraft/loot/LootTable$Builder;)V # add -protected net.minecraft.data.loot.EntityLootTables func_218585_a(Lnet/minecraft/util/ResourceLocation;Lnet/minecraft/loot/LootTable$Builder;)V # add -public net.minecraft.entity.Entity func_70022_Q()Ljava/lang/String; # getEncodeId -public net.minecraft.entity.EntitySpawnPlacementRegistry func_209343_a(Lnet/minecraft/entity/EntityType;Lnet/minecraft/entity/EntitySpawnPlacementRegistry$PlacementType;Lnet/minecraft/world/gen/Heightmap$Type;Lnet/minecraft/entity/EntitySpawnPlacementRegistry$IPlacementPredicate;)V # register -public net.minecraft.entity.MobEntity field_70714_bg # goalSelector -public net.minecraft.entity.MobEntity field_70715_bh # targetSelector -public net.minecraft.entity.ai.brain.memory.MemoryModuleType (Ljava/util/Optional;)V # constructor -public net.minecraft.entity.ai.brain.schedule.Activity (Ljava/lang/String;)V # constructor -public net.minecraft.entity.ai.brain.sensor.SensorType (Ljava/util/function/Supplier;)V # constructor -public net.minecraft.entity.item.ExperienceOrbEntity field_70530_e # value -protected net.minecraft.entity.item.TNTEntity func_70515_d()V # explode - make it easier to extend TNTEntity with custom explosion logic -public net.minecraft.entity.merchant.villager.VillagerProfession (Ljava/lang/String;Lnet/minecraft/village/PointOfInterestType;Lcom/google/common/collect/ImmutableSet;Lcom/google/common/collect/ImmutableSet;Lnet/minecraft/util/SoundEvent;)V # constructor -protected net.minecraft.entity.monster.AbstractSkeletonEntity func_190727_o()Lnet/minecraft/util/SoundEvent; # getStepSound - make AbstractSkeletonEntity implementable -protected net.minecraft.entity.monster.SkeletonEntity func_190727_o()Lnet/minecraft/util/SoundEvent; # getStepSound - make AbstractSkeletonEntity implementable -protected net.minecraft.entity.monster.StrayEntity func_190727_o()Lnet/minecraft/util/SoundEvent; # getStepSound - make AbstractSkeletonEntity implementable -protected net.minecraft.entity.monster.WitherSkeletonEntity func_190727_o()Lnet/minecraft/util/SoundEvent; # getStepSound - make AbstractSkeletonEntity implementable -public net.minecraft.entity.player.PlayerEntity func_71053_j()V # closeContainer -public net.minecraft.entity.player.ServerPlayerEntity field_71139_cq # containerCounter -public net.minecraft.entity.player.ServerPlayerEntity func_71117_bO()V # nextContainerCounter -public net.minecraft.inventory.container.ContainerType (Lnet/minecraft/inventory/container/ContainerType$IFactory;)V # constructor -public net.minecraft.inventory.container.ContainerType$IFactory -public net.minecraft.inventory.container.RepairContainer field_82856_l # repairItemCountCost -public net.minecraft.item.BlockItemUseContext (Lnet/minecraft/world/World;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;Lnet/minecraft/item/ItemStack;Lnet/minecraft/util/math/BlockRayTraceResult;)V # constructor -#group public net.minecraft.item.Item -public net.minecraft.item.AxeItem (Lnet/minecraft/item/IItemTier;FFLnet/minecraft/item/Item$Properties;)V # constructor -public net.minecraft.item.HoeItem (Lnet/minecraft/item/IItemTier;IFLnet/minecraft/item/Item$Properties;)V # constructor -public net.minecraft.item.MusicDiscItem (ILnet/minecraft/util/SoundEvent;Lnet/minecraft/item/Item$Properties;)V # constructor -public net.minecraft.item.PickaxeItem (Lnet/minecraft/item/IItemTier;IFLnet/minecraft/item/Item$Properties;)V # constructor -public net.minecraft.item.ToolItem (FFLnet/minecraft/item/IItemTier;Ljava/util/Set;Lnet/minecraft/item/Item$Properties;)V # constructor +public net.minecraft.world.entity.Entity m_20078_()Ljava/lang/String; # getEncodeId +public net.minecraft.world.entity.ExperienceOrb f_20770_ # value +public net.minecraft.world.entity.Mob f_21345_ # goalSelector +public net.minecraft.world.entity.Mob f_21346_ # targetSelector +public net.minecraft.world.entity.SpawnPlacements m_21754_(Lnet/minecraft/world/entity/EntityType;Lnet/minecraft/world/entity/SpawnPlacements$Type;Lnet/minecraft/world/level/levelgen/Heightmap$Types;Lnet/minecraft/world/entity/SpawnPlacements$SpawnPredicate;)V # register +public net.minecraft.world.entity.ai.memory.MemoryModuleType (Ljava/util/Optional;)V # constructor +public net.minecraft.world.entity.ai.sensing.SensorType (Ljava/util/function/Supplier;)V # constructor +public net.minecraft.world.entity.ai.village.poi.PoiType (Ljava/lang/String;Ljava/util/Set;II)V # constructor +public net.minecraft.world.entity.ai.village.poi.PoiType (Ljava/lang/String;Ljava/util/Set;ILjava/util/function/Predicate;I)V # constructor +public net.minecraft.world.entity.ai.village.poi.PoiType m_27372_(Lnet/minecraft/world/level/block/Block;)Ljava/util/Set; # getBlockStates +protected net.minecraft.world.entity.item.PrimedTnt m_32103_()V # explode - make it easier to extend TNTEntity with custom explosion logic +protected net.minecraft.world.entity.monster.AbstractSkeleton m_7878_()Lnet/minecraft/sounds/SoundEvent; # getStepSound - make AbstractSkeletonEntity implementable +protected net.minecraft.world.entity.monster.Skeleton m_7878_()Lnet/minecraft/sounds/SoundEvent; # getStepSound - make AbstractSkeletonEntity implementable +protected net.minecraft.world.entity.monster.Stray m_7878_()Lnet/minecraft/sounds/SoundEvent; # getStepSound - make AbstractSkeletonEntity implementable +protected net.minecraft.world.entity.monster.WitherSkeleton m_7878_()Lnet/minecraft/sounds/SoundEvent; # getStepSound - make AbstractSkeletonEntity implementable +public net.minecraft.world.entity.npc.VillagerProfession (Ljava/lang/String;Lnet/minecraft/world/entity/ai/village/poi/PoiType;Lcom/google/common/collect/ImmutableSet;Lcom/google/common/collect/ImmutableSet;Lnet/minecraft/sounds/SoundEvent;)V # constructor +public net.minecraft.world.entity.player.Player m_6915_()V # closeContainer +protected net.minecraft.world.entity.projectile.Projectile (Lnet/minecraft/world/entity/EntityType;Lnet/minecraft/world/level/Level;)V # constructor +private-f net.minecraft.world.entity.raid.Raid$RaiderType f_37813_ # VALUES +public net.minecraft.world.entity.schedule.Activity (Ljava/lang/String;)V # constructor +public net.minecraft.world.inventory.AnvilMenu f_39000_ # repairItemCountCost +public net.minecraft.world.inventory.MenuType (Lnet/minecraft/world/inventory/MenuType$MenuSupplier;)V # constructor +public net.minecraft.world.inventory.MenuType$MenuSupplier +public-f net.minecraft.world.item.CreativeModeTab f_40748_ # TABS - group array +#group public net.minecraft.world.item.Item +public net.minecraft.world.item.AxeItem (Lnet/minecraft/world/item/Tier;FFLnet/minecraft/world/item/Item$Properties;)V # constructor +public net.minecraft.world.item.DiggerItem (FFLnet/minecraft/world/item/Tier;Lnet/minecraft/tags/Tag;Lnet/minecraft/world/item/Item$Properties;)V # constructor +public net.minecraft.world.item.HoeItem (Lnet/minecraft/world/item/Tier;IFLnet/minecraft/world/item/Item$Properties;)V # constructor +public net.minecraft.world.item.PickaxeItem (Lnet/minecraft/world/item/Tier;IFLnet/minecraft/world/item/Item$Properties;)V # constructor +public net.minecraft.world.item.RecordItem (ILnet/minecraft/sounds/SoundEvent;Lnet/minecraft/world/item/Item$Properties;)V # constructor #endgroup -public-f net.minecraft.item.ItemGroup field_78032_a # TABS - group array -public net.minecraft.item.ItemModelsProperties func_239418_a_(Lnet/minecraft/item/Item;Lnet/minecraft/util/ResourceLocation;Lnet/minecraft/item/IItemPropertyGetter;)V # register -public net.minecraft.item.ItemUseContext (Lnet/minecraft/world/World;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;Lnet/minecraft/item/ItemStack;Lnet/minecraft/util/math/BlockRayTraceResult;)V # constructor -public-f net.minecraft.item.crafting.Ingredient -protected net.minecraft.item.crafting.Ingredient (Ljava/util/stream/Stream;)V # constructor -public+f net.minecraft.item.crafting.Ingredient func_199564_a(Lnet/minecraft/network/PacketBuffer;)V # toNetwork -public net.minecraft.item.crafting.Ingredient func_199803_a(Lcom/google/gson/JsonObject;)Lnet/minecraft/item/crafting/Ingredient$IItemList; # valueFromJson -public net.minecraft.item.crafting.Ingredient func_209357_a(Ljava/util/stream/Stream;)Lnet/minecraft/item/crafting/Ingredient; # fromValues -public net.minecraft.item.crafting.Ingredient$IItemList -public net.minecraft.item.crafting.Ingredient$SingleItemList -public net.minecraft.item.crafting.Ingredient$SingleItemList (Lnet/minecraft/item/ItemStack;)V # constructor -public net.minecraft.item.crafting.Ingredient$TagList -public net.minecraft.item.crafting.Ingredient$TagList (Lnet/minecraft/tags/ITag;)V # constructor -private-f net.minecraft.loot.LootPool field_186455_c # rolls -private-f net.minecraft.loot.LootPool field_186456_d # bonusRolls -public net.minecraft.network.status.server.SServerInfoPacket field_149297_a # GSON -public net.minecraft.particles.BasicParticleType (Z)V # constructor -public net.minecraft.particles.ParticleType (ZLnet/minecraft/particles/IParticleData$IDeserializer;)V # constructor -public net.minecraft.resources.FallbackResourceManager field_199023_a # fallbacks -public net.minecraft.resources.ResourcePack field_195771_a # file -protected net.minecraft.server.MinecraftServer field_211151_aa # nextTickTime -public net.minecraft.server.dedicated.DedicatedServer field_71341_l # consoleInput -public net.minecraft.tags.BlockTags func_199894_a(Ljava/lang/String;)Lnet/minecraft/tags/ITag$INamedTag; # bind -public net.minecraft.tags.EntityTypeTags func_232896_a_(Ljava/lang/String;)Lnet/minecraft/tags/ITag$INamedTag; # bind -public net.minecraft.tags.FluidTags func_206956_a(Ljava/lang/String;)Lnet/minecraft/tags/ITag$INamedTag; # bind -public net.minecraft.tags.ItemTags func_199901_a(Ljava/lang/String;)Lnet/minecraft/tags/ITag$INamedTag; # bind -protected-f net.minecraft.tags.NetworkTagManager field_199719_a # blocks -protected-f net.minecraft.tags.NetworkTagManager field_199720_b # items -protected-f net.minecraft.tags.NetworkTagManager field_205705_c # fluids -protected-f net.minecraft.tags.NetworkTagManager field_215299_d # entityTypes -protected net.minecraft.tags.TagRegistry$NamedTag field_232942_b_ # tagReference -public net.minecraft.tileentity.HopperTileEntity func_145896_c(I)V # setCooldown -public net.minecraft.tileentity.HopperTileEntity func_174914_o()Z # isOnCustomCooldown -#group public net.minecraft.util.DamageSource *() #All methods public, most are already -public net.minecraft.util.DamageSource (Ljava/lang/String;)V # constructor -public net.minecraft.util.DamageSource func_151518_m()Lnet/minecraft/util/DamageSource; # bypassMagic -public net.minecraft.util.DamageSource func_76348_h()Lnet/minecraft/util/DamageSource; # bypassArmor -public net.minecraft.util.DamageSource func_76359_i()Lnet/minecraft/util/DamageSource; # bypassInvul -public net.minecraft.util.DamageSource func_76361_j()Lnet/minecraft/util/DamageSource; # setIsFire +public net.minecraft.world.item.alchemy.PotionBrewing$Mix +public net.minecraft.world.item.alchemy.PotionBrewing$Mix f_43533_ # ingredient +public net.minecraft.world.item.context.BlockPlaceContext (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 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 +public net.minecraft.world.item.crafting.Ingredient$ItemValue (Lnet/minecraft/world/item/ItemStack;)V # constructor +public net.minecraft.world.item.crafting.Ingredient$TagValue +public net.minecraft.world.item.crafting.Ingredient$TagValue (Lnet/minecraft/tags/Tag;)V # constructor +public net.minecraft.world.item.crafting.Ingredient$Value +public net.minecraft.world.level.GameRules m_46189_(Ljava/lang/String;Lnet/minecraft/world/level/GameRules$Category;Lnet/minecraft/world/level/GameRules$Type;)Lnet/minecraft/world/level/GameRules$Key; # register +public net.minecraft.world.level.Level f_46437_ # oRainLevel +public net.minecraft.world.level.Level f_46438_ # rainLevel +public net.minecraft.world.level.Level f_46439_ # oThunderLevel +public net.minecraft.world.level.Level f_46440_ # thunderLevel +public net.minecraft.world.level.biome.Biome$ClimateSettings +public net.minecraft.world.level.biome.Biome$ClimateSettings (Lnet/minecraft/world/level/biome/Biome$Precipitation;FLnet/minecraft/world/level/biome/Biome$TemperatureModifier;F)V # constructor +public net.minecraft.world.level.biome.Biome$ClimateSettings f_47680_ # precipitation +public net.minecraft.world.level.biome.Biome$ClimateSettings f_47681_ # temperature +public net.minecraft.world.level.biome.Biome$ClimateSettings f_47682_ # temperatureModifier +public net.minecraft.world.level.biome.Biome$ClimateSettings f_47683_ # downfall +protected net.minecraft.world.level.biome.BiomeGenerationSettings$Builder f_47826_ # surfaceBuilder +protected net.minecraft.world.level.biome.BiomeGenerationSettings$Builder f_47827_ # carvers +protected net.minecraft.world.level.biome.BiomeGenerationSettings$Builder f_47828_ # features +protected net.minecraft.world.level.biome.BiomeGenerationSettings$Builder f_47829_ # structureStarts +protected net.minecraft.world.level.biome.BiomeGenerationSettings$Builder m_47832_(I)V # addFeatureStepsUpTo +protected net.minecraft.world.level.biome.MobSpawnSettings$Builder f_48362_ # spawners +protected net.minecraft.world.level.biome.MobSpawnSettings$Builder f_48363_ # mobSpawnCosts +protected net.minecraft.world.level.biome.MobSpawnSettings$Builder f_48364_ # creatureGenerationProbability +protected net.minecraft.world.level.biome.MobSpawnSettings$Builder f_48365_ # playerCanSpawn +#group public net.minecraft.world.level.block.Block +public net.minecraft.world.level.block.AirBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.AttachedStemBlock (Lnet/minecraft/world/level/block/StemGrownBlock;Ljava/util/function/Supplier;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.AzaleaBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.BarrierBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.BaseCoralFanBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.BaseCoralPlantBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.BaseCoralPlantTypeBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.BaseCoralWallFanBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.BigDripleafBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.BigDripleafStemBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.BlastFurnaceBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.BushBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.CactusBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.CakeBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.CandleCakeBlock (Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.CartographyTableBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.CarvedPumpkinBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.ChestBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;Ljava/util/function/Supplier;)V # constructor +public net.minecraft.world.level.block.ChorusFlowerBlock (Lnet/minecraft/world/level/block/ChorusPlantBlock;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.ChorusPlantBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.CoralFanBlock (Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.CoralPlantBlock (Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.CoralWallFanBlock (Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.CraftingTableBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.CropBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.CrossCollisionBlock (FFFFFLnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.DeadBushBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.DirtPathBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.DispenserBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.DoorBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.EnchantmentTableBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.EndGatewayBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.EndPortalBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.EndRodBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.EnderChestBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.FaceAttachedHorizontalDirectionalBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.FarmBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.FletchingTableBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.FungusBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;Ljava/util/function/Supplier;)V # constructor +public net.minecraft.world.level.block.FurnaceBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.GrindstoneBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.HalfTransparentBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.HangingRootsBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.IronBarsBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.JigsawBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.JukeboxBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.KelpBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.KelpPlantBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.LadderBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.LecternBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.LeverBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.LiquidBlock (Lnet/minecraft/world/level/material/FlowingFluid;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.LoomBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.MelonBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.NetherWartBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.NyliumBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.PipeBlock (FLnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.PlayerHeadBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.PlayerWallHeadBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.PoweredRailBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.PressurePlateBlock (Lnet/minecraft/world/level/block/PressurePlateBlock$Sensitivity;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.PumpkinBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.RailBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.RedstoneTorchBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.RedstoneWallTorchBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.RepeaterBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.RodBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.RootsBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.SaplingBlock (Lnet/minecraft/world/level/block/grower/AbstractTreeGrower;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.ScaffoldingBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.SeaPickleBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.SeagrassBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.SkullBlock (Lnet/minecraft/world/level/block/SkullBlock$Type;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.SmithingTableBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.SmokerBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.SnowLayerBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.SnowyDirtBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.SpawnerBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.SpongeBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.StairBlock (Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.StemBlock (Lnet/minecraft/world/level/block/StemGrownBlock;Ljava/util/function/Supplier;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.StoneButtonBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.StructureBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.StructureVoidBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.SugarCaneBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.TallGrassBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.TorchBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;Lnet/minecraft/core/particles/ParticleOptions;)V # constructor +public net.minecraft.world.level.block.TrapDoorBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.WallSkullBlock (Lnet/minecraft/world/level/block/SkullBlock$Type;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.WallTorchBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;Lnet/minecraft/core/particles/ParticleOptions;)V # constructor +public net.minecraft.world.level.block.WaterlilyBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.WeightedPressurePlateBlock (ILnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.WetSpongeBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.WitherSkullBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.WitherWallSkullBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.WoodButtonBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.WoolCarpetBlock (Lnet/minecraft/world/item/DyeColor;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor #endgroup -protected net.minecraft.util.ObjectIntIdentityMap field_148748_b # idToT - internal index list -protected net.minecraft.util.ObjectIntIdentityMap field_148749_a # tToId - internal map -protected net.minecraft.util.ObjectIntIdentityMap field_195868_a # nextId -public net.minecraft.util.WeightedRandom$Item field_76292_a # weight -public net.minecraft.util.concurrent.ThreadTaskExecutor func_213165_a(Ljava/lang/Runnable;)Ljava/util/concurrent/CompletableFuture; # submitAsync -public net.minecraft.village.PointOfInterestType (Ljava/lang/String;Ljava/util/Set;II)V # constructor -public net.minecraft.village.PointOfInterestType (Ljava/lang/String;Ljava/util/Set;ILjava/util/function/Predicate;I)V # constructor -public net.minecraft.village.PointOfInterestType func_221042_a(Lnet/minecraft/block/Block;)Ljava/util/Set; # getBlockStates -public net.minecraft.world.GameRules func_234903_a_(Ljava/lang/String;Lnet/minecraft/world/GameRules$Category;Lnet/minecraft/world/GameRules$RuleType;)Lnet/minecraft/world/GameRules$RuleKey; # register -protected net.minecraft.world.Teleporter field_85192_a # level -public net.minecraft.world.World field_73003_n # oRainLevel -public net.minecraft.world.World field_73004_o # rainLevel -public net.minecraft.world.World field_73017_q # thunderLevel -public net.minecraft.world.World field_73018_p # oThunderLevel -public net.minecraft.world.biome.Biome$Climate -public net.minecraft.world.biome.Biome$Climate (Lnet/minecraft/world/biome/Biome$RainType;FLnet/minecraft/world/biome/Biome$TemperatureModifier;F)V # constructor -public net.minecraft.world.biome.Biome$Climate field_242460_b # precipitation -public net.minecraft.world.biome.Biome$Climate field_242461_c # temperature -public net.minecraft.world.biome.Biome$Climate field_242462_d # temperatureModifier -public net.minecraft.world.biome.Biome$Climate field_242463_e # downfall -protected net.minecraft.world.biome.BiomeGenerationSettings$Builder field_242504_a # surfaceBuilder -protected net.minecraft.world.biome.BiomeGenerationSettings$Builder field_242505_b # carvers -protected net.minecraft.world.biome.BiomeGenerationSettings$Builder field_242506_c # features -protected net.minecraft.world.biome.BiomeGenerationSettings$Builder field_242507_d # structureStarts -protected net.minecraft.world.biome.BiomeGenerationSettings$Builder func_242509_a(I)V # addFeatureStepsUpTo -protected net.minecraft.world.biome.MobSpawnInfo$Builder field_242567_a # spawners -protected net.minecraft.world.biome.MobSpawnInfo$Builder field_242568_b # mobSpawnCosts -protected net.minecraft.world.biome.MobSpawnInfo$Builder field_242569_c # creatureGenerationProbability -protected net.minecraft.world.biome.MobSpawnInfo$Builder field_242570_d # playerCanSpawn -public net.minecraft.world.chunk.ChunkStatus (Ljava/lang/String;Lnet/minecraft/world/chunk/ChunkStatus;ILjava/util/EnumSet;Lnet/minecraft/world/chunk/ChunkStatus$Type;Lnet/minecraft/world/chunk/ChunkStatus$IGenerationWorker;Lnet/minecraft/world/chunk/ChunkStatus$ILoadingWorker;)V # constructor -private-f net.minecraft.world.gen.DebugChunkGenerator field_177462_b # GRID_WIDTH -private-f net.minecraft.world.gen.DebugChunkGenerator field_177464_a # ALL_BLOCKS -private-f net.minecraft.world.gen.DebugChunkGenerator field_181039_c # GRID_HEIGHT -public net.minecraft.world.gen.DimensionSettings (Lnet/minecraft/world/gen/settings/DimensionStructuresSettings;Lnet/minecraft/world/gen/settings/NoiseSettings;Lnet/minecraft/block/BlockState;Lnet/minecraft/block/BlockState;IIIZ)V # constructor -public net.minecraft.world.gen.DimensionSettings func_236120_h_()Z # disableMobGeneration -public net.minecraft.world.gen.blockplacer.BlockPlacerType (Lcom/mojang/serialization/Codec;)V # constructor -public net.minecraft.world.gen.blockstateprovider.BlockStateProviderType (Lcom/mojang/serialization/Codec;)V # constructor -public net.minecraft.world.gen.foliageplacer.FoliagePlacerType (Lcom/mojang/serialization/Codec;)V # constructor -public net.minecraft.world.gen.layer.LayerUtil func_202829_a(JLnet/minecraft/world/gen/layer/traits/IAreaTransformer1;Lnet/minecraft/world/gen/area/IAreaFactory;ILjava/util/function/LongFunction;)Lnet/minecraft/world/gen/area/IAreaFactory; # zoom -public net.minecraft.world.gen.treedecorator.TreeDecoratorType (Lcom/mojang/serialization/Codec;)V # constructor -private-f net.minecraft.world.raid.Raid$WaveMember field_221284_f # VALUES -public net.minecraft.world.server.ServerChunkProvider field_186029_c # generator -public net.minecraft.world.server.ServerChunkProvider field_73251_h # level -public net.minecraft.world.storage.FolderName (Ljava/lang/String;)V # constructor \ No newline at end of file +public net.minecraft.world.level.block.Block m_49805_(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/core/BlockPos;I)V # popExperience +public net.minecraft.world.level.block.FireBlock m_53492_(Lnet/minecraft/world/level/block/state/BlockState;)I # getBurnOdd +public net.minecraft.world.level.block.FireBlock m_53494_(Lnet/minecraft/world/level/block/state/BlockState;)I # getFlameOdds +public net.minecraft.world.level.block.entity.BlockEntityType$BlockEntitySupplier +public net.minecraft.world.level.block.entity.HopperBlockEntity m_59395_(I)V # setCooldown +public net.minecraft.world.level.block.entity.HopperBlockEntity m_59409_()Z # isOnCustomCooldown +public net.minecraft.world.level.block.state.properties.WoodType m_61844_(Lnet/minecraft/world/level/block/state/properties/WoodType;)Lnet/minecraft/world/level/block/state/properties/WoodType; # register +public net.minecraft.world.level.chunk.ChunkStatus (Ljava/lang/String;Lnet/minecraft/world/level/chunk/ChunkStatus;ILjava/util/EnumSet;Lnet/minecraft/world/level/chunk/ChunkStatus$ChunkType;Lnet/minecraft/world/level/chunk/ChunkStatus$GenerationTask;Lnet/minecraft/world/level/chunk/ChunkStatus$LoadingTask;)V # constructor +private-f net.minecraft.world.level.levelgen.DebugLevelSource f_64114_ # ALL_BLOCKS +private-f net.minecraft.world.level.levelgen.DebugLevelSource f_64115_ # GRID_WIDTH +private-f net.minecraft.world.level.levelgen.DebugLevelSource f_64116_ # GRID_HEIGHT +#group public net.minecraft.world.level.levelgen.NoiseGeneratorSettings *() +public net.minecraft.world.level.levelgen.NoiseGeneratorSettings (Lnet/minecraft/world/level/levelgen/StructureSettings;Lnet/minecraft/world/level/levelgen/NoiseSettings;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockState;IIIIZZZZZZ)V # constructor +public net.minecraft.world.level.levelgen.NoiseGeneratorSettings m_158553_(Lnet/minecraft/world/level/levelgen/StructureSettings;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockState;)Lnet/minecraft/world/level/levelgen/NoiseGeneratorSettings; # netherLikePreset +public net.minecraft.world.level.levelgen.NoiseGeneratorSettings m_158557_(Lnet/minecraft/world/level/levelgen/StructureSettings;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockState;ZZ)Lnet/minecraft/world/level/levelgen/NoiseGeneratorSettings; # endLikePreset +public net.minecraft.world.level.levelgen.NoiseGeneratorSettings m_158563_(Lnet/minecraft/world/level/levelgen/StructureSettings;Z)Lnet/minecraft/world/level/levelgen/NoiseGeneratorSettings; # overworld +public net.minecraft.world.level.levelgen.NoiseGeneratorSettings m_158567_()Z # isAquifersEnabled +public net.minecraft.world.level.levelgen.NoiseGeneratorSettings m_158568_()Z # isNoiseCavesEnabled +public net.minecraft.world.level.levelgen.NoiseGeneratorSettings m_158569_()Z # isDeepslateEnabled +public net.minecraft.world.level.levelgen.NoiseGeneratorSettings m_158570_()Z # isOreVeinsEnabled +public net.minecraft.world.level.levelgen.NoiseGeneratorSettings m_158571_()Z # isNoodleCavesEnabled +public net.minecraft.world.level.levelgen.NoiseGeneratorSettings m_64474_(Lcom/mojang/serialization/codecs/RecordCodecBuilder$Instance;)Lcom/mojang/datafixers/kinds/App; # lambda$static$0 +public net.minecraft.world.level.levelgen.NoiseGeneratorSettings m_64478_(Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/world/level/levelgen/NoiseGeneratorSettings;)Lnet/minecraft/world/level/levelgen/NoiseGeneratorSettings; # register +public net.minecraft.world.level.levelgen.NoiseGeneratorSettings m_64487_()Z # disableMobGeneration +#endgroup +public net.minecraft.world.level.levelgen.feature.blockplacers.BlockPlacerType (Lcom/mojang/serialization/Codec;)V # constructor +public net.minecraft.world.level.levelgen.feature.foliageplacers.FoliagePlacerType (Lcom/mojang/serialization/Codec;)V # constructor +public net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProviderType (Lcom/mojang/serialization/Codec;)V # constructor +public net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecoratorType (Lcom/mojang/serialization/Codec;)V # constructor +public net.minecraft.world.level.newbiome.layer.Layers m_76729_(JLnet/minecraft/world/level/newbiome/layer/traits/AreaTransformer1;Lnet/minecraft/world/level/newbiome/area/AreaFactory;ILjava/util/function/LongFunction;)Lnet/minecraft/world/level/newbiome/area/AreaFactory; # zoom +protected net.minecraft.world.level.portal.PortalForcer f_77648_ # level +public net.minecraft.world.level.storage.LevelResource (Ljava/lang/String;)V # constructor +private-f net.minecraft.world.level.storage.loot.LootPool f_79028_ # rolls +private-f net.minecraft.world.level.storage.loot.LootPool f_79029_ # bonusRolls \ No newline at end of file diff --git a/src/main/resources/META-INF/coremods.json b/src/main/resources/META-INF/coremods.json index f81cf60290..bc26fe0f09 100644 --- a/src/main/resources/META-INF/coremods.json +++ b/src/main/resources/META-INF/coremods.json @@ -1,5 +1,5 @@ { - "fieldtomethodtransformers": "META-INF/fieldtomethodtransformers.js", + "field_to_method": "coremods/field_to_method.js", "field_to_instanceof": "coremods/field_to_instanceof.js", "add_bouncer_method": "coremods/add_bouncer_method.js" } diff --git a/src/main/resources/META-INF/fieldtomethodtransformers.js b/src/main/resources/META-INF/fieldtomethodtransformers.js deleted file mode 100644 index a681db2802..0000000000 --- a/src/main/resources/META-INF/fieldtomethodtransformers.js +++ /dev/null @@ -1,90 +0,0 @@ -function initializeCoreMod() { - return { - 'potion': { - 'target': { - 'type': 'CLASS', - 'name': 'net.minecraft.potion.EffectInstance' - }, - 'transformer': function(classNode) { - var asmapi=Java.type('net.minecraftforge.coremod.api.ASMAPI') - var fn = asmapi.mapField('field_188420_b') // potion field - remap to mcp if necessary - asmapi.redirectFieldToMethod(classNode, fn, asmapi.mapMethod('func_188419_a')) - return classNode; - } - }, - 'flowingfluidblock': { - 'target': { - 'type': 'CLASS', - 'name': 'net.minecraft.block.FlowingFluidBlock' - }, - 'transformer': function(classNode) { - var asmapi=Java.type('net.minecraftforge.coremod.api.ASMAPI') - var fn = asmapi.mapField('field_204517_c') // fluid field - remap to mcp if necessary - asmapi.redirectFieldToMethod(classNode, fn, 'getFluid') // forge added method, doesn't need mapping - return classNode; - } - }, - 'bucketitem': { - 'target': { - 'type': 'CLASS', - 'name': 'net.minecraft.item.BucketItem' - }, - 'transformer': function(classNode) { - var asmapi=Java.type('net.minecraftforge.coremod.api.ASMAPI') - var fn = asmapi.mapField('field_77876_a') // containerFluid (wrongly named containedBlock) field - remap to mcp if necessary - asmapi.redirectFieldToMethod(classNode, fn, 'getFluid') // forge added method, doesn't need mapping - return classNode; - } - }, - 'stairsblock': { - 'target': { - 'type': 'CLASS', - 'name': 'net.minecraft.block.StairsBlock' - }, - 'transformer': function(classNode) { - var asmapi=Java.type('net.minecraftforge.coremod.api.ASMAPI') - var blockField = asmapi.mapField('field_150149_b') // modelBlock - remap to mcp if necessary - asmapi.redirectFieldToMethod(classNode, blockField, 'getModelBlock') // forge added method, doesn't need mapping - var stateField = asmapi.mapField('field_150151_M') // modelState - remap to mcp if necessary - asmapi.redirectFieldToMethod(classNode, stateField, 'getModelState') // forge added method, doesn't need mapping - return classNode; - } - }, - 'flowerpotblock': { - 'target': { - 'type': 'CLASS', - 'name': 'net.minecraft.block.FlowerPotBlock' - }, - 'transformer': function(classNode) { - var asmapi=Java.type('net.minecraftforge.coremod.api.ASMAPI') - var fn = asmapi.mapField('field_196452_c') // flower - remap to mcp if necessary - asmapi.redirectFieldToMethod(classNode, fn, asmapi.mapMethod('func_220276_d')) - return classNode; - } - }, - 'fishbucketitem': { - 'target': { - 'type': 'CLASS', - 'name': 'net.minecraft.item.FishBucketItem' - }, - 'transformer': function(classNode) { - var asmapi=Java.type('net.minecraftforge.coremod.api.ASMAPI') - var fn = asmapi.mapField('field_203794_a') // fishType - remap to mcp if necessary - asmapi.redirectFieldToMethod(classNode, fn, asmapi.mapMethod('getFishType')) - return classNode; - } - }, - 'itemstack': { - 'target': { - 'type': 'CLASS', - 'name': 'net.minecraft.item.ItemStack' - }, - 'transformer': function(classNode) { - var asmapi=Java.type('net.minecraftforge.coremod.api.ASMAPI') - var fn = asmapi.mapField('field_151002_e') // item - remap to mcp if necessary - asmapi.redirectFieldToMethod(classNode, fn, asmapi.mapMethod('func_77973_b')) - return classNode; - } - } - } -} diff --git a/src/main/resources/META-INF/services/net.minecraftforge.fml.IBindingsProvider b/src/main/resources/META-INF/services/net.minecraftforge.fml.IBindingsProvider new file mode 100644 index 0000000000..9c9e602fc7 --- /dev/null +++ b/src/main/resources/META-INF/services/net.minecraftforge.fml.IBindingsProvider @@ -0,0 +1 @@ +net.minecraftforge.fmllegacy.ForgeBindings \ No newline at end of file diff --git a/src/main/resources/META-INF/services/net.minecraftforge.fml.IModStateProvider b/src/main/resources/META-INF/services/net.minecraftforge.fml.IModStateProvider new file mode 100644 index 0000000000..106ec46513 --- /dev/null +++ b/src/main/resources/META-INF/services/net.minecraftforge.fml.IModStateProvider @@ -0,0 +1,2 @@ +net.minecraftforge.fml.core.ModStateProvider +net.minecraftforge.fmllegacy.ForgeStatesProvider \ No newline at end of file diff --git a/src/main/resources/META-INF/services/net.minecraftforge.forgespi.language.IModLanguageProvider b/src/main/resources/META-INF/services/net.minecraftforge.forgespi.language.IModLanguageProvider deleted file mode 100644 index 9d1ae601bb..0000000000 --- a/src/main/resources/META-INF/services/net.minecraftforge.forgespi.language.IModLanguageProvider +++ /dev/null @@ -1,2 +0,0 @@ -net.minecraftforge.fml.javafmlmod.FMLJavaModLanguageProvider -net.minecraftforge.fml.mclanguageprovider.MinecraftModLanguageProvider \ No newline at end of file diff --git a/src/main/resources/assets/forge/lang/en_us.json b/src/main/resources/assets/forge/lang/en_us.json index 7cbcc65f6a..fd00753e0e 100644 --- a/src/main/resources/assets/forge/lang/en_us.json +++ b/src/main/resources/assets/forge/lang/en_us.json @@ -108,8 +108,8 @@ "commands.forge.tracking.entity.enabled": "Entity tracking enabled for %d seconds.", "commands.forge.tracking.entity.reset": "Entity timings data has been cleared!", "commands.forge.tracking.invalid": "Invalid tracking data.", - "commands.forge.tracking.te.enabled": "Tile Entity tracking enabled for %d seconds.", - "commands.forge.tracking.te.reset": "Tile entity timings data has been cleared!", + "commands.forge.tracking.be.enabled": "Block Entity tracking enabled for %d seconds.", + "commands.forge.tracking.be.reset": "Block entity timings data has been cleared!", "commands.forge.tracking.timing_entry": "{0} - {1} [{2}, {3}, {4}]: {5}", "commands.forge.tracking.no_data": "No data has been recorded yet.", @@ -123,8 +123,8 @@ "forge.configgui.removeErroringEntities.tooltip": "Set this to true to remove any Entity that throws an error in its update method instead of closing the server and reporting a crash log. BE WARNED THIS COULD SCREW UP EVERYTHING USE SPARINGLY WE ARE NOT RESPONSIBLE FOR DAMAGES.", "forge.configgui.removeErroringEntities": "Remove Erroring Entities", - "forge.configgui.removeErroringTileEntities.tooltip": "Set this to true to remove any TileEntity that throws an error in its update method instead of closing the server and reporting a crash log. BE WARNED THIS COULD SCREW UP EVERYTHING USE SPARINGLY WE ARE NOT RESPONSIBLE FOR DAMAGES.", - "forge.configgui.removeErroringTileEntities": "Remove Erroring Tile Entities", + "forge.configgui.removeErroringBlockEntities.tooltip": "Set this to true to remove any BlockEntity that throws an error in its update method instead of closing the server and reporting a crash log. BE WARNED THIS COULD SCREW UP EVERYTHING USE SPARINGLY WE ARE NOT RESPONSIBLE FOR DAMAGES.", + "forge.configgui.removeErroringBlockEntities": "Remove Erroring Block Entities", "forge.configgui.fullBoundingBoxLadders.tooltip": "Set this to true to check the entire entity's collision bounding box for ladders instead of just the block they are in. Causes noticeable differences in mechanics so default is vanilla behavior. Default: false.", "forge.configgui.fullBoundingBoxLadders": "Full Bounding Box Ladders", "forge.configgui.zombieBaseSummonChance.tooltip": "Base zombie summoning spawn chance. Allows changing the bonus zombie summoning mechanic.", diff --git a/src/main/resources/assets/forge/lang/en_us.lang b/src/main/resources/assets/forge/lang/en_us.lang deleted file mode 100644 index 7dd5c97528..0000000000 --- a/src/main/resources/assets/forge/lang/en_us.lang +++ /dev/null @@ -1,171 +0,0 @@ -forge.texture.preload.warning=Warning: Texture %s not preloaded, will cause render glitches! -forge.client.shutdown.internal=Shutting down internal server... -forge.update.newversion=New Forge version available: %s -forge.update.beta.1=%sWARNING: %sForge Beta -forge.update.beta.2=Major issues may arise, verify before reporting. - -forge.configgui.forgeConfigTitle=Minecraft Forge Configuration -forge.configgui.ctgy.forgeGeneralConfig.tooltip=This is where you can edit the settings contained in forge.cfg. -forge.configgui.ctgy.forgeGeneralConfig=General Settings -forge.configgui.ctgy.forgeClientConfig.tooltip=Settings in the forge.cfg that only concern the local client. Usually graphical settings. -forge.configgui.ctgy.forgeClientConfig=Client Settings -forge.configgui.ctgy.forgeChunkLoadingConfig.tooltip=This is where you can edit the settings contained in forgeChunkLoading.cfg. -forge.configgui.ctgy.forgeChunkLoadingConfig=Forge Chunk Loader Default Settings -forge.configgui.ctgy.forgeChunkLoadingModConfig.tooltip=This is where you can define mod-specific override settings that will be used instead of the defaults. -forge.configgui.ctgy.forgeChunkLoadingModConfig=Mod Overrides -forge.configgui.ctgy.forgeChunkLoadingAddModConfig.tooltip=Allows you to define mod-specific settings that will override the defaults. A value of zero in either entry effectively disables any chunkloading capabilities for that mod. -forge.configgui.ctgy.forgeChunkLoadingAddModConfig=+ Add New Mod Override -forge.configgui.ctgy.VersionCheckConfig=Version Check Settings - -forge.configgui.biomeSkyBlendRange.tooltip=Control the range of sky blending for colored skies in biomes. -forge.configgui.biomeSkyBlendRange=Biome Sky Blend Range -forge.configgui.forceDuplicateFluidBlockCrash.tooltip=Set this to true to force a crash if more than one block attempts to link back to the same Fluid. -forge.configgui.forceDuplicateFluidBlockCrash=Force Dupe Fluid Block Crash - -forge.configgui.stencilbits=Enable GL Stencil Bits -forge.configgui.replaceBuckets=Use Forge's bucket model - -forge.configgui.modID.tooltip=The mod ID that you want to define override settings for. -forge.configgui.modID=Mod ID -forge.configgui.asyncChunkLoading=Async Chunk Loading -forge.configgui.asyncChunkLoading.tooltip=Load chunks asynchronously for players, reducing load on the server thread. Can be disabled to help troubleshoot chunk loading issues. -forge.configgui.dormantChunkCacheSize.tooltip=Unloaded chunks can first be kept in a dormant cache for quicker loading times. Specify the size (in chunks) of that cache here. -forge.configgui.dormantChunkCacheSize=Dormant Chunk Cache Size -forge.configgui.enableModOverrides.tooltip=Enable this setting to allow custom per-mod settings to be defined. -forge.configgui.enableModOverrides=Enable Mod Overrides -forge.configgui.maximumChunksPerTicket.tooltip=This is the maximum number of chunks a single ticket can force. -forge.configgui.maximumChunksPerTicket=Chunks Per Ticket Limit -forge.configgui.maximumTicketCount.tooltip=This is the number of chunk loading requests a mod is allowed to make. -forge.configgui.maximumTicketCount=Mod Ticket Limit -forge.configgui.playerTicketCount.tooltip=The number of tickets a player can be assigned instead of a mod. This is shared across all mods and it is up to the mods to use it. -forge.configgui.playerTicketCount=Player Ticket Limit - -fml.config.sample.basicDouble.tooltip=A double property with no defined bounds. -fml.config.sample.basicDouble=Unbounded Double -fml.config.sample.basicInteger.tooltip=An integer property with no defined bounds. -fml.config.sample.basicInteger=Unbounded Integer -fml.config.sample.basicString.tooltip=A basic string property. The user can enter anything in this textbox. -fml.config.sample.basicString=Basic String -fml.config.sample.booleanList.tooltip=A boolean list with no max length and can be lengthened or shortened. -fml.config.sample.booleanList=Basic Boolean List -fml.config.sample.booleanListFixed.tooltip=A boolean list that has a fixed length of 8. -fml.config.sample.booleanListFixed=Fixed Length Boolean List -fml.config.sample.booleanListMax.tooltip=A boolean list that has a max length of 10. -fml.config.sample.booleanListMax=Max Length Boolean List -fml.config.sample.boundedDouble.tooltip=A double property with defined bounds. -fml.config.sample.boundedDouble=Bounded Double -fml.config.sample.boundedInteger.tooltip=An integer property with defined bounds. -fml.config.sample.boundedInteger=Bounded Integer -fml.config.sample.chatColorPicker.tooltip=A special property that allows the user to select a font color code. -fml.config.sample.chatColorPicker=Chat Color Picker -fml.config.sample.ctgy.lists.tooltip=Provides a variety of array-property controls to play with. -fml.config.sample.ctgy.lists=Sample Array Controls -fml.config.sample.ctgy.numbers.tooltip=Provides a listing of the numeric controls for toying with. -fml.config.sample.ctgy.numbers=Sample Numeric Controls -fml.config.sample.ctgy.strings.tooltip=Provides a listing of the different String-type controls to play with. -fml.config.sample.ctgy.strings=Sample String Controls -fml.config.sample.cycleString.tooltip=A string property that has a defined list of valid values that can be cycled through. -fml.config.sample.cycleString=Cycle Value String -fml.config.sample.doubleList.tooltip=A double list with no max length and can be lengthened or shortened. -fml.config.sample.doubleList=Basic Double List -fml.config.sample.doubleListBounded.tooltip=A double list with specific value bounds. -fml.config.sample.doubleListBounded=Double List with Value Bounds -fml.config.sample.doubleListFixed.tooltip=A double list that has a fixed length of 10. -fml.config.sample.doubleListFixed=Fixed Length Double List -fml.config.sample.doubleListMax.tooltip=A double list that has a max length of 15. -fml.config.sample.doubleListMax=Max Length Double List -fml.config.sample.imABoolean.tooltip=Yep, that's pretty much it... I'm a Boolean control. -fml.config.sample.imABoolean=I'm a Boolean -fml.config.sample.imADouble.tooltip=There are two of me. Or maybe I work for both the CIA and the KGB. Not sure. -fml.config.sample.imADouble=I'm a Double -fml.config.sample.imAString.tooltip=Aah. Now, I understand you want us to advertise your washing powder. \n<*String.*> \nString, washing powder, what's the difference? We can sell anything. \n<*Good. Well I have this large quantity of string, 122,000 miles of it to be exact, which I inherited, and I thought if I advertised it...*> \nOf course! A national campaign. Useful stuff, string, no trouble there. \n<*Ah, but there's a snag, you see. Due to bad planning, the 122,000 miles is in three inch lengths. So it's not very useful.*> \nWell, that's our selling point! SIMPSON'S INDIVIDUAL STRINGETTES! THE NOW STRING! READY CUT, EASY TO HANDLE, SIMPSON'S INDIVIDUAL EMPEROR STRINGETTES - JUST THE RIGHT LENGTH! -fml.config.sample.imAString=I'm a String -fml.config.sample.imAnInteger.tooltip=Did I say that I'm an Integer? Oh, I see. -fml.config.sample.imAnInteger=I'm an Integer -fml.config.sample.integerList.tooltip=An integer list with no max length and can be lengthened or shortened. -fml.config.sample.integerList=Basic Integer List -fml.config.sample.integerListBounded.tooltip=An integer list with specific value bounds. -fml.config.sample.integerListBounded=Integer List with Value Bounds -fml.config.sample.integerListFixed.tooltip=An integer list that has a fixed length of 10. -fml.config.sample.integerListFixed=Fixed Length Integer List -fml.config.sample.integerListMax.tooltip=An integer list that has a max length of 15. -fml.config.sample.integerListMax=Max Length Integer List -fml.config.sample.modIDSelector.tooltip=A special property that allows the user to select a mod ID from a list of all installed mods. There are many possibilities for how this could be used with a little custom code: selecting biomes, selecting entities, selecting items, selecting blocks, etc. -fml.config.sample.modIDSelector=Mod ID Selector -fml.config.sample.patternString.tooltip=A string property that is validated using a Pattern object. -fml.config.sample.patternString=Pattern Validated String -fml.config.sample.sliderDouble.tooltip=A double property with defined bounds using a slider control. -fml.config.sample.sliderDouble=Slider Double -fml.config.sample.sliderInteger.tooltip=An integer property with defined bounds using a slider control. -fml.config.sample.sliderInteger=Slider Integer -fml.config.sample.stringList.tooltip=A basic string list with no validation. -fml.config.sample.stringList=Basic String List -fml.config.sample.stringListFixed.tooltip=A string list that has a fixed length of 7. -fml.config.sample.stringListFixed=Fixed Length String List -fml.config.sample.stringListMax.tooltip=A string list that has a max length of 15. -fml.config.sample.stringListMax=Max Length String List -fml.config.sample.stringListPattern.tooltip=A string list that validates each value using a Pattern object. -fml.config.sample.stringListPattern=Pattern Validated String List -fml.config.sample.stringListCustom=Custom Entry List -fml.config.sample.title=This is for playing with the Config GUI behavior. Changes are not saved. - -fml.configgui.applyGlobally=Apply globally -fml.configgui.confirmRestartMessage=I Understand -fml.configgui.gameRestartRequired=One or more changed settings requires that Minecraft be restarted before taking effect. -fml.configgui.gameRestartTitle=Minecraft Restart Required -fml.configgui.sampletext=Sample Text -fml.configgui.tooltip.addNewEntryAbove=Add New Entry Above -fml.configgui.tooltip.applyGlobally=Apply Undo Changes or Reset to Default globally. -fml.configgui.tooltip.removeEntry=Remove Entry -fml.configgui.tooltip.resetAll=Reset All to Default. If the Apply globally checkbox is checked values on child screens will also be reset. -fml.configgui.tooltip.resetToDefault=Reset to Default -fml.configgui.tooltip.undoAll=Undo All Changes. If the Apply globally checkbox is checked changes to child screens will also be undone. -fml.configgui.tooltip.undoChanges=Undo Changes -fml.configgui.tooltip.default=[default: %s] -fml.configgui.tooltip.defaultNumeric=[range: %s ~ %s, default: %s] - -forge.controlsgui.shift=SHIFT + %s -forge.controlsgui.control=CTRL + %s -forge.controlsgui.control.mac=CMD + %s -forge.controlsgui.alt=ALT + %s - -fml.menu.mods=Mods -fml.menu.mods.normal=Normal -fml.menu.mods.search=Search: -fml.menu.modoptions=Mod Options... - -item.forge.bucketFilled.name=%s Bucket - -fml.messages.mod.missing.dependencies=%s is missing mods it depends on. -fml.messages.mod.missing.dependencies.fix=Include the following mods or remove %s. -fml.messages.mod.missing.dependencies.compatibility=You must include the right dependencies for %s: -fml.messages.mod.missing.dependencies.missing=missing -fml.messages.mod.missing.dependencies.compatible.with=Only compatible with %s -fml.messages.mod.missing.dependencies.requires=Requires %s -fml.messages.mod.missing.dependencies.you.have=you have %s -fml.messages.mod.missing.dependencies.see.log=See '%s' for technical information. -fml.messages.mod.missing.dependencies.multiple=Some mods are missing mods they depends on. -fml.messages.mod.missing.dependencies.multiple.issues=You must include the right dependencies for the following mods: -fml.messages.mod.missing.multiple=There were %s errors loading Minecraft -fml.messages.mod.wrongminecraft=The mods listed below can't run in Minecraft version %s -fml.messages.mod.wrongminecraft.requirement=%s (%s) requires Minecraft %s -fml.messages.mod.wrongminecraft.fix=Try to find an update or remove %s -fml.messages.mod.wrongminecraft.fix.multiple=Try to find an update or remove these mods -fml.messages.version.restriction.any=any -fml.messages.version.restriction.lower.inclusive=%s or above -fml.messages.version.restriction.lower.exclusive=above %s -fml.messages.version.restriction.upper.inclusive=%s or below -fml.messages.version.restriction.upper.exclusive=below %s -fml.messages.version.restriction.bounded=between %s and %s -fml.messages.version.restriction.bounded.inclusive=between %s and %s (inclusive) -fml.messages.version.restriction.bounded.exclusive=between %s and %s (exclusive) -fml.messages.version.restriction.bounded.lowerexclusive=above %s, and %s or below -fml.messages.version.restriction.bounded.upperexclusive=%s or above, and below %s - -fml.button.continue=Continue -fml.button.open.mods.folder=Open Mods Folder -fml.button.open.file=Open %s - -forge.container.enchant.limitedEnchantability=Limited Enchantability -attribute.name.generic.reachDistance=Reach Distance -attribute.name.forge.swimSpeed=Swim Speed diff --git a/src/main/resources/coremods/field_to_instanceof.json b/src/main/resources/coremods/field_to_instanceof.json index 41509a6a46..544b7b4ddd 100644 --- a/src/main/resources/coremods/field_to_instanceof.json +++ b/src/main/resources/coremods/field_to_instanceof.json @@ -1,182 +1,3 @@ { - "bows": { - "cls": "net/minecraft/item/Items", - "name": "field_151031_f", - "replacement": "net/minecraft/item/BowItem", - "targets": [ - { - "owner": "net/minecraft/client/entity/player/AbstractClientPlayerEntity", - "name": "func_175156_o", - "desc": "()F" - }, - { - "owner": "net/minecraft/client/renderer/FirstPersonRenderer", - "name": "func_228396_a_", - "desc": "(FLcom/mojang/blaze3d/matrix/MatrixStack;Lnet/minecraft/client/renderer/IRenderTypeBuffer$Impl;Lnet/minecraft/client/entity/player/ClientPlayerEntity;I)V" - }, - { - "owner": "net/minecraft/client/renderer/entity/model/SkeletonModel", - "name": "func_212843_a_", - "desc": "(Lnet/minecraft/entity/MobEntity;FFF)V" - }, - { - "owner": "net/minecraft/client/renderer/entity/model/SkeletonModel", - "name": "func_225597_a_", - "desc": "(Lnet/minecraft/entity/MobEntity;FFFFF)V" - }, - { - "owner": "net/minecraft/entity/monster/AbstractSkeletonEntity", - "name": "func_230280_a_", - "desc": "(Lnet/minecraft/item/ShootableItem;)Z" - }, - { - "owner": "net/minecraft/entity/monster/AbstractSkeletonEntity", - "name": "func_85036_m", - "desc": "()V" - } - ] - }, - "crossbows": { - "cls": "net/minecraft/item/Items", - "name": "field_222114_py", - "replacement": "net/minecraft/item/CrossbowItem", - "targets": [ - { - "owner": "net/minecraft/client/renderer/FirstPersonRenderer", - "name": "func_228396_a_", - "desc": "(FLcom/mojang/blaze3d/matrix/MatrixStack;Lnet/minecraft/client/renderer/IRenderTypeBuffer$Impl;Lnet/minecraft/client/entity/player/ClientPlayerEntity;I)V" - }, - { - "owner": "net/minecraft/client/renderer/FirstPersonRenderer", - "name": "func_228405_a_", - "desc": "(Lnet/minecraft/client/entity/player/AbstractClientPlayerEntity;FFLnet/minecraft/util/Hand;FLnet/minecraft/item/ItemStack;FLcom/mojang/blaze3d/matrix/MatrixStack;Lnet/minecraft/client/renderer/IRenderTypeBuffer;I)V" - }, - { - "owner": "net/minecraft/client/renderer/entity/PlayerRenderer", - "name": "func_241741_a_", - "desc": "(Lnet/minecraft/client/entity/player/AbstractClientPlayerEntity;Lnet/minecraft/util/Hand;)Lnet/minecraft/client/renderer/entity/model/BipedModel$ArmPose;" - }, - { - "owner": "net/minecraft/entity/monster/PillagerEntity", - "name": "func_230280_a_", - "desc": "(Lnet/minecraft/item/ShootableItem;)Z" - }, - { - "owner": "net/minecraft/entity/monster/PillagerEntity", - "name": "func_241844_w", - "desc": "(F)V" - }, - { - "owner": "net/minecraft/entity/monster/piglin/PiglinEntity", - "name": "func_208003_a", - "desc": "(Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ItemStack;)Z" - }, - { - "owner": "net/minecraft/entity/monster/piglin/PiglinEntity", - "name": "func_230280_a_", - "desc": "(Lnet/minecraft/item/ShootableItem;)Z" - }, - { - "owner": "net/minecraft/item/CrossbowItem", - "name": "func_220013_l", - "desc": "(Lnet/minecraft/item/ItemStack;)F" - }, - { - "owner": "net/minecraft/item/Item", - "name": "func_219970_i", - "desc": "(Lnet/minecraft/item/ItemStack;)Z" - } - ] - }, - "filled_map": { - "cls": "net/minecraft/item/Items", - "name": "field_151098_aY", - "replacement": "net/minecraft/item/FilledMapItem", - "targets": [ - { - "owner": "net/minecraft/client/renderer/FirstPersonRenderer", - "name": "func_228405_a_", - "desc": "(Lnet/minecraft/client/entity/player/AbstractClientPlayerEntity;FFLnet/minecraft/util/Hand;FLnet/minecraft/item/ItemStack;FLcom/mojang/blaze3d/matrix/MatrixStack;Lnet/minecraft/client/renderer/IRenderTypeBuffer;I)V" - }, - { - "owner": "net/minecraft/entity/item/ItemFrameEntity", - "name": "func_110131_b", - "desc": "(Lnet/minecraft/item/ItemStack;)V" - }, - { - "owner": "net/minecraft/inventory/container/CartographyContainer$3", - "name": "func_75214_a", - "desc": "(Lnet/minecraft/item/ItemStack;)Z" - }, - { - "owner": "net/minecraft/inventory/container/CartographyContainer", - "name": "func_82846_b", - "desc": "(Lnet/minecraft/entity/player/PlayerEntity;I)Lnet/minecraft/item/ItemStack;" - }, - { - "owner": "net/minecraft/item/ItemStack", - "name": "func_82840_a", - "desc": "(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/client/util/ITooltipFlag;)Ljava/util/List;" - } - ] - }, - "fishing_rod": { - "cls": "net/minecraft/item/Items", - "name": "field_151112_aM", - "replacement": "net/minecraft/item/FishingRodItem", - "targets": [ - { - "owner": "net/minecraft/client/renderer/entity/FishRenderer", - "name": "func_225623_a_", - "desc": "(Lnet/minecraft/entity/projectile/FishingBobberEntity;FFLcom/mojang/blaze3d/matrix/MatrixStack;Lnet/minecraft/client/renderer/IRenderTypeBuffer;I)V" - }, - { - "owner": "net/minecraft/entity/projectile/FishingBobberEntity", - "name": "func_234600_a_", - "desc": "(Lnet/minecraft/entity/player/PlayerEntity;)Z" - } - ] - }, - "shears": { - "cls": "net/minecraft/item/Items", - "name": "field_151097_aZ", - "replacement": "net/minecraft/item/ShearsItem", - "targets": [ - { - "owner": "net/minecraft/block/BeehiveBlock", - "name": "func_225533_a_", - "desc": "(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;Lnet/minecraft/util/math/BlockRayTraceResult;)Lnet/minecraft/util/ActionResultType;" - }, - { - "owner": "net/minecraft/block/PumpkinBlock", - "name": "func_225533_a_", - "desc": "(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;Lnet/minecraft/util/math/BlockRayTraceResult;)Lnet/minecraft/util/ActionResultType;" - }, - { - "owner": "net/minecraft/block/TripWireBlock", - "name": "func_176208_a", - "desc": "(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Lnet/minecraft/entity/player/PlayerEntity;)V" - }, - { - "owner": "net/minecraft/enchantment/EfficiencyEnchantment", - "name": "func_92089_a", - "desc": "(Lnet/minecraft/item/ItemStack;)Z" - }, - { - "owner": "net/minecraft/entity/passive/MooshroomEntity", - "name": "func_230254_b_", - "desc": "(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;)Lnet/minecraft/util/ActionResultType;" - }, - { - "owner": "net/minecraft/entity/passive/SheepEntity", - "name": "func_230254_b_", - "desc": "(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;)Lnet/minecraft/util/ActionResultType;" - }, - { - "owner": "net/minecraft/entity/passive/SnowGolemEntity", - "name": "func_230254_b_", - "desc": "(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;)Lnet/minecraft/util/ActionResultType;" - } - ] - } + } \ No newline at end of file diff --git a/src/main/resources/coremods/field_to_method.js b/src/main/resources/coremods/field_to_method.js new file mode 100644 index 0000000000..d9168f5c4c --- /dev/null +++ b/src/main/resources/coremods/field_to_method.js @@ -0,0 +1,81 @@ +var ASMAPI = Java.type('net.minecraftforge.coremod.api.ASMAPI') + +function initializeCoreMod() { + return { + 'potion': { + 'target': { + 'type': 'CLASS', + 'name': 'net.minecraft.world.effect.MobEffectInstance' + }, + 'transformer': function(classNode) { + ASMAPI.redirectFieldToMethod(classNode, ASMAPI.mapField('f_19502_'), ASMAPI.mapMethod('m_19544_')) // potion + return classNode; + } + }, + /* TODO + 'flowing_fluid_block': { + 'target': { + 'type': 'CLASS', + 'name': 'net.minecraft.world.level.block.LiquidBlock' + }, + 'transformer': function(classNode) { + ASMAPI.redirectFieldToMethod(classNode, ASMAPI.mapField('f_54689_'), 'getFluid') + return classNode; + } + }, + */ + 'bucketitem': { + 'target': { + 'type': 'CLASS', + 'name': 'net.minecraft.world.item.BucketItem' + }, + 'transformer': function(classNode) { + ASMAPI.redirectFieldToMethod(classNode, ASMAPI.mapField('f_40687_'), 'getFluid') + return classNode; + } + }, + 'stairsblock': { + 'target': { + 'type': 'CLASS', + 'name': 'net.minecraft.world.level.block.StairBlock' + }, + 'transformer': function(classNode) { + ASMAPI.redirectFieldToMethod(classNode, ASMAPI.mapField('f_56858_'), 'getModelBlock') + ASMAPI.redirectFieldToMethod(classNode, ASMAPI.mapField('f_56859_'), 'getModelState') + return classNode; + } + }, + 'flowerpotblock': { + 'target': { + 'type': 'CLASS', + 'name': 'net.minecraft.world.level.block.FlowerPotBlock' + }, + 'transformer': function(classNode) { + ASMAPI.redirectFieldToMethod(classNode, ASMAPI.mapField('f_53525_'), ASMAPI.mapMethod('m_53560_')) // flower + return classNode; + } + }, + /* + 'mob_bucket_item': { + 'target': { + 'type': 'CLASS', + 'name': 'net.minecraft.world.item.MobBucketItem' + }, + 'transformer': function(classNode) { + ASMAPI.redirectFieldToMethod(classNode, ASMAPI.mapField('f_41262_'), ASMAPI.mapMethod('getFishType')) // type - Not implemented + return classNode; + } + }, + */ + 'itemstack': { + 'target': { + 'type': 'CLASS', + 'name': 'net.minecraft.world.item.ItemStack' + }, + 'transformer': function(classNode) { + ASMAPI.redirectFieldToMethod(classNode, ASMAPI.mapField('f_41589_'), ASMAPI.mapMethod('m_41720_')) // item + return classNode; + } + } + } +} diff --git a/src/main/resources/forge.exc b/src/main/resources/forge.exc index 1056712ae8..525ea1ddf4 100644 --- a/src/main/resources/forge.exc +++ b/src/main/resources/forge.exc @@ -1,63 +1,51 @@ -net/minecraft/block/FireBlock.tryCatchFire(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;ILjava/util/Random;ILnet/minecraft/util/Direction;)V=|p_176536_1_,p_176536_2_,p_176536_3_,p_176536_4_,p_176536_5_,face -net/minecraft/block/FlowerPotBlock.(Ljava/util/function/Supplier;Ljava/util/function/Supplier;Lnet/minecraft/block/AbstractBlock$Properties;)V=|emptyPot,p_i48395_1_,properties -net/minecraft/block/FlowingFluidBlock.(Ljava/util/function/Supplier;Lnet/minecraft/block/AbstractBlock$Properties;)V=|supplier,p_i48368_1_ -net/minecraft/block/RedstoneWireBlock.canConnectTo(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/IBlockReader;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/Direction;)Z=|p_176343_0_,world,pos,p_176343_1_ -net/minecraft/client/Minecraft.loadWorld(Ljava/lang/String;Lnet/minecraft/util/registry/DynamicRegistries$Impl;Ljava/util/function/Function;Lcom/mojang/datafixers/util/Function4;ZLnet/minecraft/client/Minecraft$WorldSelectionType;Z)V=|p_238195_1_,p_238195_2_,p_238195_3_,p_238195_4_,p_238195_5_,p_238195_6_,creating -net/minecraft/client/gui/ScreenManager.getScreenFactory(Lnet/minecraft/inventory/container/ContainerType;Lnet/minecraft/client/Minecraft;ILnet/minecraft/util/text/ITextComponent;)Ljava/util/Optional;=|p_216909_0_,p_216909_1_,p_216909_2_,p_216909_3_ -net/minecraft/client/gui/screens/Screen.renderToolTip(Lcom/mojang/blaze3d/vertex/PoseStack;Ljava/util/List;IILnet/minecraft/client/gui/Font;)V=|p_238654_1_,p_238654_2_,p_238654_3_,p_238654_4_,font -net/minecraft/client/particle/ParticleManager.renderParticles(Lcom/mojang/blaze3d/matrix/MatrixStack;Lnet/minecraft/client/renderer/IRenderTypeBuffer$Impl;Lnet/minecraft/client/renderer/LightTexture;Lnet/minecraft/client/renderer/ActiveRenderInfo;FLnet/minecraft/client/renderer/culling/ClippingHelper;)V=|p_228345_1_,p_228345_2_,p_228345_3_,p_228345_4_,p_228345_5_,clippingHelper -net/minecraft/client/renderer/BlockModelRenderer.renderModel(Lcom/mojang/blaze3d/matrix/MatrixStack$Entry;Lcom/mojang/blaze3d/vertex/IVertexBuilder;Lnet/minecraft/block/BlockState;Lnet/minecraft/client/renderer/model/IBakedModel;FFFIILnet/minecraftforge/client/model/data/IModelData;)V=|p_228804_1_,p_228804_2_,p_228804_3_,p_228804_4_,p_228804_5_,p_228804_6_,p_228804_7_,p_228804_8_,p_228804_9_,modelData -net/minecraft/client/renderer/BlockRendererDispatcher.renderBlock(Lnet/minecraft/block/BlockState;Lcom/mojang/blaze3d/matrix/MatrixStack;Lnet/minecraft/client/renderer/IRenderTypeBuffer;IILnet/minecraftforge/client/model/data/IModelData;)V=|p_228791_1_,p_228791_2_,p_228791_3_,p_228791_4_,p_228791_5_,modelData -net/minecraft/client/renderer/FogRenderer.setupFog(Lnet/minecraft/client/renderer/ActiveRenderInfo;Lnet/minecraft/client/renderer/FogRenderer$FogType;FZF)V=|p_228372_0_,p_228372_1_,p_228372_2_,p_228372_3_,partialTicks -net/minecraft/client/renderer/OverlayRenderer.getOverlayBlock(Lnet/minecraft/entity/player/PlayerEntity;)Lorg/apache/commons/lang3/tuple/Pair;=|p_230018_0_ -net/minecraft/client/renderer/WorldRenderer.playRecord(Lnet/minecraft/util/SoundEvent;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/item/MusicDiscItem;)V=|p_184377_1_,p_184377_2_,musicDiscItem -net/minecraft/client/renderer/chunk/ChunkRenderDispatcher$ChunkRender$ChunkRenderTask.(Lnet/minecraft/client/renderer/chunk/ChunkRenderDispatcher$ChunkRender;Lnet/minecraft/util/math/ChunkPos;D)V=|p_i226023_1_,pos,p_i226023_2_ -net/minecraft/client/renderer/chunk/ChunkRenderDispatcher$ChunkRender$RebuildTask.(Lnet/minecraft/client/renderer/chunk/ChunkRenderDispatcher$ChunkRender;Lnet/minecraft/util/math/ChunkPos;DLnet/minecraft/client/renderer/chunk/ChunkRenderCache;)V=|p_i226024_1_,pos,p_i226024_2_,p_i226024_4_ -net/minecraft/client/renderer/chunk/ChunkRenderDispatcher$ChunkRender$SortTransparencyTask.(Lnet/minecraft/client/renderer/chunk/ChunkRenderDispatcher$ChunkRender;Lnet/minecraft/util/math/ChunkPos;DLnet/minecraft/client/renderer/chunk/ChunkRenderDispatcher$CompiledChunk;)V=|p_i226025_1_,pos,p_i226025_2_,p_i226025_4_ -net/minecraft/client/renderer/chunk/ChunkRenderDispatcher.(Lnet/minecraft/world/World;Lnet/minecraft/client/renderer/WorldRenderer;Ljava/util/concurrent/Executor;ZLnet/minecraft/client/renderer/RegionRenderCacheBuilder;I)V=|p_i226020_1_,p_i226020_2_,p_i226020_3_,p_i226020_4_,p_i226020_5_,countRenderBuilders -net/minecraft/client/renderer/model/BlockModel.bakeVanilla(Lnet/minecraft/client/renderer/model/ModelBakery;Lnet/minecraft/client/renderer/model/BlockModel;Ljava/util/function/Function;Lnet/minecraft/client/renderer/model/IModelTransform;Lnet/minecraft/util/ResourceLocation;Z)Lnet/minecraft/client/renderer/model/IBakedModel;=|p_228813_1_,p_228813_2_,p_228813_3_,p_228813_4_,p_228813_5_,p_228813_6_ -net/minecraft/client/renderer/model/BlockModel.getOverrides(Lnet/minecraft/client/renderer/model/ModelBakery;Lnet/minecraft/client/renderer/model/BlockModel;Ljava/util/function/Function;)Lnet/minecraft/client/renderer/model/ItemOverrideList;=|p_217646_1_,p_217646_2_,textureGetter -net/minecraft/client/renderer/model/BlockModel.makeBakedQuad(Lnet/minecraft/client/renderer/model/BlockPart;Lnet/minecraft/client/renderer/model/BlockPartFace;Lnet/minecraft/client/renderer/texture/TextureAtlasSprite;Lnet/minecraft/util/Direction;Lnet/minecraft/client/renderer/model/IModelTransform;Lnet/minecraft/util/ResourceLocation;)Lnet/minecraft/client/renderer/model/BakedQuad;=|p_228812_0_,p_228812_1_,p_228812_2_,p_228812_3_,p_228812_4_,p_228812_5_ -net/minecraft/client/renderer/model/ItemOverrideList.(Lnet/minecraft/client/renderer/model/ModelBakery;Lnet/minecraft/client/renderer/model/IUnbakedModel;Ljava/util/function/Function;Ljava/util/function/Function;Ljava/util/List;)V=|p_i50984_1_,p_i50984_2_,p_i50984_3_,textureGetter,p_i50984_4_ -net/minecraft/client/renderer/model/ModelBakery.(Lnet/minecraft/resources/IResourceManager;Lnet/minecraft/client/renderer/color/BlockColors;Z)V=|p_i226056_1_,p_i226056_2_,vanillaBakery -net/minecraft/client/renderer/model/ModelBakery.addModelToCache(Lnet/minecraft/util/ResourceLocation;)V=|p_217843_1_ -net/minecraft/client/renderer/model/ModelBakery.getBakedModel(Lnet/minecraft/util/ResourceLocation;Lnet/minecraft/client/renderer/model/IModelTransform;Ljava/util/function/Function;)Lnet/minecraft/client/renderer/model/IBakedModel;=|p_217845_1_,p_217845_2_,textureGetter -net/minecraft/client/renderer/model/ModelBakery.processLoading(Lnet/minecraft/profiler/IProfiler;I)V=|p_i226056_3_,p_i226056_4_ -net/minecraft/client/renderer/model/MultipartBakedModel.getQuads(Lnet/minecraft/block/BlockState;Lnet/minecraft/util/Direction;Ljava/util/Random;Lnet/minecraftforge/client/model/data/IModelData;)Ljava/util/List;=|p_200117_1_,p_200117_2_,p_200117_3_,modelData -net/minecraft/client/renderer/model/WeightedBakedModel.getQuads(Lnet/minecraft/block/BlockState;Lnet/minecraft/util/Direction;Ljava/util/Random;Lnet/minecraftforge/client/model/data/IModelData;)Ljava/util/List;=|p_200117_1_,p_200117_2_,p_200117_3_,modelData -net/minecraft/data/BlockTagsProvider.(Lnet/minecraft/data/DataGenerator;Ljava/lang/String;Lnet/minecraftforge/common/data/ExistingFileHelper;)V=|p_i48256_1_,modId,existingFileHelper -net/minecraft/data/EntityTypeTagsProvider.(Lnet/minecraft/data/DataGenerator;Ljava/lang/String;Lnet/minecraftforge/common/data/ExistingFileHelper;)V=|p_i50784_1_,modId,existingFileHelper -net/minecraft/data/FluidTagsProvider.(Lnet/minecraft/data/DataGenerator;Ljava/lang/String;Lnet/minecraftforge/common/data/ExistingFileHelper;)V=|p_i49156_1_,modId,existingFileHelper -net/minecraft/data/ItemTagsProvider.(Lnet/minecraft/data/DataGenerator;Lnet/minecraft/data/BlockTagsProvider;Ljava/lang/String;Lnet/minecraftforge/common/data/ExistingFileHelper;)V=|p_i232552_1_,p_i232552_2_,modId,existingFileHelper -net/minecraft/data/TagsProvider.(Lnet/minecraft/data/DataGenerator;Lnet/minecraft/util/registry/Registry;Ljava/lang/String;Lnet/minecraftforge/common/data/ExistingFileHelper;)V=|p_i49827_1_,p_i49827_2_,modId,existingFileHelper -net/minecraft/data/TagsProvider.(Lnet/minecraft/data/DataGenerator;Lnet/minecraft/util/registry/Registry;Ljava/lang/String;Lnet/minecraftforge/common/data/ExistingFileHelper;Ljava/lang/String;)V=|p_i49827_1_,p_i49827_2_,modId,existingFileHelper,folder -net/minecraft/entity/Entity.changeDimension(Lnet/minecraft/world/server/ServerWorld;Lnet/minecraftforge/common/util/ITeleporter;)Lnet/minecraft/entity/Entity;=|p_241206_1_,teleporter -net/minecraft/entity/EntityType.(Lnet/minecraft/entity/EntityType$IFactory;Lnet/minecraft/entity/EntityClassification;ZZZZLcom/google/common/collect/ImmutableSet;Lnet/minecraft/entity/EntitySize;IILjava/util/function/Predicate;Ljava/util/function/ToIntFunction;Ljava/util/function/ToIntFunction;Ljava/util/function/BiFunction;)V=|p_i231489_1_,p_i231489_2_,p_i231489_3_,p_i231489_4_,p_i231489_5_,p_i231489_6_,p_i231489_7_,p_i231489_8_,p_i231489_9_,p_i231489_10_,velocityUpdateSupplier,trackingRangeSupplier,updateIntervalSupplier,customClientFactory -net/minecraft/entity/item/EnderPearlEntity.changeDimension(Lnet/minecraft/world/server/ServerWorld;Lnet/minecraftforge/common/util/ITeleporter;)Lnet/minecraft/entity/Entity;=|p_241206_1_,teleporter -net/minecraft/entity/item/ItemEntity.changeDimension(Lnet/minecraft/world/server/ServerWorld;Lnet/minecraftforge/common/util/ITeleporter;)Lnet/minecraft/entity/Entity;=|p_241206_1_,teleporter -net/minecraft/entity/item/minecart/ContainerMinecartEntity.changeDimension(Lnet/minecraft/world/server/ServerWorld;Lnet/minecraftforge/common/util/ITeleporter;)Lnet/minecraft/entity/Entity;=|p_241206_1_,teleporter -net/minecraft/entity/merchant/villager/AbstractVillagerEntity.changeDimension(Lnet/minecraft/world/server/ServerWorld;Lnet/minecraftforge/common/util/ITeleporter;)Lnet/minecraft/entity/Entity;=|p_241206_1_,teleporter -net/minecraft/entity/player/PlayerEntity.getDigSpeed(Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;)F=|p_184813_1_,pos -net/minecraft/entity/player/ServerPlayerEntity.changeDimension(Lnet/minecraft/world/server/ServerWorld;Lnet/minecraftforge/common/util/ITeleporter;)Lnet/minecraft/entity/Entity;=|p_241206_1_,teleporter -net/minecraft/item/BoneMealItem.applyBonemeal(Lnet/minecraft/item/ItemStack;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/entity/player/PlayerEntity;)Z=|p_195966_0_,p_195966_1_,p_195966_2_,player -net/minecraft/item/DyeableHorseArmorItem.(ILnet/minecraft/util/ResourceLocation;Lnet/minecraft/item/Item$Properties;)V=|p_i50047_1_,texture,p_i50047_3_ -net/minecraft/item/FilledMapItem.getCustomMapData(Lnet/minecraft/item/ItemStack;Lnet/minecraft/world/World;)Lnet/minecraft/world/storage/MapData;=|p_195950_0_,p_195950_1_ -net/minecraft/item/FishBucketItem.(Ljava/util/function/Supplier;Ljava/util/function/Supplier;Lnet/minecraft/item/Item$Properties;)V=|fishTypeIn,p_i49022_2_,builder -net/minecraft/item/HorseArmorItem.(ILnet/minecraft/util/ResourceLocation;Lnet/minecraft/item/Item$Properties;)V=|p_i50042_1_,texture,p_i50042_3_ -net/minecraft/item/ItemStack.(Lnet/minecraft/util/IItemProvider;ILnet/minecraft/nbt/CompoundNBT;)V=|p_i48204_1_,p_i48204_2_,capNBT -net/minecraft/item/ItemStack.onItemUseFirst(Lnet/minecraft/item/ItemUseContext;)Lnet/minecraft/util/ActionResultType;=|p_196084_1_ -net/minecraft/item/ItemStack.onItemUse(Lnet/minecraft/item/ItemUseContext;Ljava/util/function/Function;)Lnet/minecraft/util/ActionResultType;=|p_196084_1_,callback -net/minecraft/network/PacketBuffer.writeItemStack(Lnet/minecraft/item/ItemStack;Z)Lnet/minecraft/network/PacketBuffer;=|p_150788_1_,limitedTag -net/minecraft/potion/PotionBrewing$MixPredicate.(Lnet/minecraftforge/registries/ForgeRegistryEntry;Lnet/minecraft/item/crafting/Ingredient;Lnet/minecraftforge/registries/ForgeRegistryEntry;)V=|p_i47570_1_,p_i47570_2_,p_i47570_3_ -net/minecraft/server/dedicated/DedicatedServer.sendMessage(Lnet/minecraft/util/text/ITextComponent;Ljava/util/UUID;)V=|message,p_145747_2_ -net/minecraft/server/management/PlayerInteractionManager.removeBlock(Lnet/minecraft/util/math/BlockPos;Z)Z=|p_180235_1_,canHarvest -net/minecraft/util/math/shapes/EntitySelectionContext.(Lnet/minecraft/entity/Entity;ZDLnet/minecraft/item/Item;Ljava/util/function/Predicate;)V=|entity,p_i232177_1_,p_i232177_2_,p_i232177_4_,p_i232177_5_ -net/minecraft/world/World.markAndNotifyBlock(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/world/chunk/Chunk;Lnet/minecraft/block/BlockState;Lnet/minecraft/block/BlockState;II)V=|p_241211_1_,chunk,blockstate,p_241211_2_,p_241211_3_,p_241211_4_ -net/minecraft/world/gen/feature/jigsaw/JigsawPattern$PlacementBehaviour.create(Ljava/lang/String;Ljava/lang/String;Lcom/google/common/collect/ImmutableList;)Lnet/minecraft/world/gen/feature/jigsaw/JigsawPattern$PlacementBehaviour;=|enumName,p_i50487_3_,p_i50487_4_ -net/minecraft/world/gen/feature/template/Template.processEntityInfos(Lnet/minecraft/world/gen/feature/template/Template;Lnet/minecraft/world/IWorld;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/world/gen/feature/template/PlacementSettings;Ljava/util/List;)Ljava/util/List;=|template,p_215387_0_,p_215387_1_,p_215387_2_,p_215387_3_ -net/minecraft/world/server/ServerWorld.removeEntity(Lnet/minecraft/entity/Entity;Z)V=|p_217467_1_,keepData -net/minecraft/world/server/ServerWorld.removeEntityComplete(Lnet/minecraft/entity/Entity;Z)V=|p_217484_1_,keepData -net/minecraft/world/server/ServerWorld.removePlayer(Lnet/minecraft/entity/player/ServerPlayerEntity;Z)V=|p_217434_1_,keepData -net/minecraft/world/server/Ticket.(Lnet/minecraft/world/server/TicketType;ILjava/lang/Object;Z)V=|p_i226095_1_,p_i226095_2_,p_i226095_3_,forceTicks -net/minecraft/world/spawner/WorldEntitySpawner.canSpawnAtBody(Lnet/minecraft/entity/EntitySpawnPlacementRegistry$PlacementType;Lnet/minecraft/world/IWorldReader;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/entity/EntityType;)Z=|p_209382_0_,p_209382_1_,p_209382_2_,p_209382_3_ -net/minecraft/world/storage/SaveFormat.getReader(Lcom/mojang/serialization/DynamicOps;Lnet/minecraft/util/datafix/codec/DatapackCodec;Lnet/minecraft/world/storage/SaveFormat$LevelSave;)Ljava/util/function/BiFunction;=|p_237270_0_,p_237270_1_,levelSave \ No newline at end of file +net/minecraft/client/gui/screens/MenuScreens.getScreenFactory(Lnet/minecraft/world/inventory/MenuType;Lnet/minecraft/client/Minecraft;ILnet/minecraft/network/chat/Component;)Ljava/util/Optional;=|p_96202_,p_96203_,p_96204_,p_96205_ +net/minecraft/client/gui/screens/Screen.renderToolTip(Lcom/mojang/blaze3d/vertex/PoseStack;Ljava/util/List;IILnet/minecraft/client/gui/Font;)V=|p_96618_,p_96619_,p_96620_,p_96621_,font +net/minecraft/client/renderer/FogRenderer.setupFog(Lnet/minecraft/client/Camera;Lnet/minecraft/client/renderer/FogRenderer$FogMode;FZF)V=|p_109025_,p_109026_,p_109027_,p_109028_,partialTicks +net/minecraft/client/renderer/ScreenEffectRenderer.getOverlayBlock(Lnet/minecraft/world/entity/player/Player;)Lorg/apache/commons/lang3/tuple/Pair;=|p_110717_ +net/minecraft/client/renderer/block/BlockModelShaper.getTexture(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;)Lnet/minecraft/client/renderer/texture/TextureAtlasSprite;=|p_110883_,level,pos +net/minecraft/client/renderer/block/model/BlockModel.bakeVanilla(Lnet/minecraft/client/resources/model/ModelBakery;Lnet/minecraft/client/renderer/block/model/BlockModel;Ljava/util/function/Function;Lnet/minecraft/client/resources/model/ModelState;Lnet/minecraft/resources/ResourceLocation;Z)Lnet/minecraft/client/resources/model/BakedModel;=|p_111450_,p_111451_,p_111452_,p_111453_,p_111454_,p_111455_ +net/minecraft/client/renderer/chunk/ChunkRenderDispatcher$RenderChunk$ChunkCompileTask.(Lnet/minecraft/client/renderer/chunk/ChunkRenderDispatcher$RenderChunk;Lnet/minecraft/world/level/ChunkPos;D)V=|p_112851_,pos,p_112852_ +net/minecraft/client/renderer/chunk/ChunkRenderDispatcher$RenderChunk$RebuildTask.(Lnet/minecraft/client/renderer/chunk/ChunkRenderDispatcher$RenderChunk;Lnet/minecraft/world/level/ChunkPos;DLnet/minecraft/client/renderer/chunk/RenderChunkRegion;)V=|p_112861_,pos,p_112862_,p_112863_ +net/minecraft/client/renderer/chunk/ChunkRenderDispatcher$RenderChunk$ResortTransparencyTask.(Lnet/minecraft/client/renderer/chunk/ChunkRenderDispatcher$RenderChunk;Lnet/minecraft/world/level/ChunkPos;DLnet/minecraft/client/renderer/chunk/ChunkRenderDispatcher$CompiledChunk;)V=|p_112888_,pos,p_112889_,p_112890_ +net/minecraft/client/renderer/chunk/ChunkRenderDispatcher.(Lnet/minecraft/world/level/Level;Lnet/minecraft/client/renderer/LevelRenderer;Ljava/util/concurrent/Executor;ZLnet/minecraft/client/renderer/ChunkBufferBuilderPack;I)V=|p_112686_,p_112687_,p_112688_,p_112689_,p_112690_,countRenderBuilders +net/minecraft/client/resources/model/ModelBakery.(Lnet/minecraft/server/packs/resources/ResourceManager;Lnet/minecraft/client/color/block/BlockColors;Z)V=|p_119247_,p_119248_,vanillaBakery +net/minecraft/client/resources/model/ModelBakery.processLoading(Lnet/minecraft/util/profiling/ProfilerFiller;I)V=|p_119249_,p_119250_ +net/minecraft/client/resources/model/MultiPartBakedModel.getQuads(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/Direction;Ljava/util/Random;Lnet/minecraftforge/client/model/data/IModelData;)Ljava/util/List;=|p_119465_,p_119466_,p_119467_,modelData +net/minecraft/client/resources/model/WeightedBakedModel.getQuads(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/Direction;Ljava/util/Random;Lnet/minecraftforge/client/model/data/IModelData;)Ljava/util/List;=|p_119547_,p_119548_,p_119549_,modelData +net/minecraft/data/tags/BlockTagsProvider.(Lnet/minecraft/data/DataGenerator;Ljava/lang/String;Lnet/minecraftforge/common/data/ExistingFileHelper;)V=|p_126511_,modId,existingFileHelper +net/minecraft/data/tags/EntityTypeTagsProvider.(Lnet/minecraft/data/DataGenerator;Ljava/lang/String;Lnet/minecraftforge/common/data/ExistingFileHelper;)V=|p_126517_,modId,existingFileHelper +net/minecraft/data/tags/FluidTagsProvider.(Lnet/minecraft/data/DataGenerator;Ljava/lang/String;Lnet/minecraftforge/common/data/ExistingFileHelper;)V=|p_126523_,modId,existingFileHelper +net/minecraft/data/tags/ItemTagsProvider.(Lnet/minecraft/data/DataGenerator;Lnet/minecraft/data/tags/BlockTagsProvider;Ljava/lang/String;Lnet/minecraftforge/common/data/ExistingFileHelper;)V=|p_126530_,p_126531_,modId,existingFileHelper +net/minecraft/data/tags/TagsProvider.(Lnet/minecraft/data/DataGenerator;Lnet/minecraft/core/Registry;Ljava/lang/String;Lnet/minecraftforge/common/data/ExistingFileHelper;)V=|p_126546_,p_126547_,modId,existingFileHelper +net/minecraft/data/tags/TagsProvider.(Lnet/minecraft/data/DataGenerator;Lnet/minecraft/core/Registry;Ljava/lang/String;Lnet/minecraftforge/common/data/ExistingFileHelper;Ljava/lang/String;)V=|p_126546_,p_126547_,modId,existingFileHelper,folder +net/minecraft/network/FriendlyByteBuf.writeItemStack(Lnet/minecraft/world/item/ItemStack;Z)Lnet/minecraft/network/FriendlyByteBuf;=|p_130056_,limitedTag +net/minecraft/server/dedicated/DedicatedServer.sendMessage(Lnet/minecraft/network/chat/Component;Ljava/util/UUID;)V=|message,p_108776_ +net/minecraft/server/level/ServerLevel.removeEntity(Lnet/minecraft/world/entity/Entity;Z)V=|p_8868_,keepData +net/minecraft/server/level/ServerLevel.removeEntityComplete(Lnet/minecraft/world/entity/Entity;Z)V=|p_8865_,keepData +net/minecraft/server/level/ServerLevel.removePlayer(Lnet/minecraft/server/level/ServerPlayer;Z)V=|p_8850_,keepData +net/minecraft/server/level/ServerPlayer.changeDimension(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraftforge/common/util/ITeleporter;)Lnet/minecraft/world/entity/Entity;=|p_9180_,teleporter +net/minecraft/server/level/ServerPlayerGameMode.removeBlock(Lnet/minecraft/core/BlockPos;Z)Z=|p_180235_1_,canHarvest +net/minecraft/server/level/Ticket.(Lnet/minecraft/server/level/TicketType;ILjava/lang/Object;Z)V=|p_9425_,p_9426_,p_9427_,forceTicks +net/minecraft/server/packs/repository/Pack.(Ljava/lang/String;ZLjava/util/function/Supplier;Lnet/minecraft/network/chat/Component;Lnet/minecraft/network/chat/Component;Lnet/minecraft/server/packs/repository/PackCompatibility;Lnet/minecraft/server/packs/repository/Pack$Position;ZLnet/minecraft/server/packs/repository/PackSource;Z)V=|p_10420_,p_10421_,p_10422_,p_10423_,p_10424_,p_10425_,p_10426_,p_10427_,p_10428_,hidden +net/minecraft/world/entity/Entity.changeDimension(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraftforge/common/util/ITeleporter;)Lnet/minecraft/world/entity/Entity;=|p_20118_,teleporter +net/minecraft/world/entity/EntityType.(Lnet/minecraft/world/entity/EntityType$EntityFactory;Lnet/minecraft/world/entity/MobCategory;ZZZZLcom/google/common/collect/ImmutableSet;Lnet/minecraft/world/entity/EntityDimensions;IILjava/util/function/Predicate;Ljava/util/function/ToIntFunction;Ljava/util/function/ToIntFunction;Ljava/util/function/BiFunction;)V=|p_20574_,p_20575_,p_20576_,p_20577_,p_20578_,p_20579_,p_20580_,p_20581_,p_20582_,p_20583_,velocityUpdateSupplier,trackingRangeSupplier,updateIntervalSupplier,customClientFactory +net/minecraft/world/entity/item/ItemEntity.changeDimension(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraftforge/common/util/ITeleporter;)Lnet/minecraft/world/entity/Entity;=|p_32042_,teleporter +net/minecraft/world/entity/npc/AbstractVillager.changeDimension(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraftforge/common/util/ITeleporter;)Lnet/minecraft/world/entity/Entity;=|p_35295_,teleporter +net/minecraft/world/entity/player/Player.getDigSpeed(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;)F=|p_36282_,pos +net/minecraft/world/entity/projectile/ThrownEnderpearl.changeDimension(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraftforge/common/util/ITeleporter;)Lnet/minecraft/world/entity/Entity;=|p_37506_,teleporter +net/minecraft/world/entity/vehicle/AbstractMinecartContainer.changeDimension(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraftforge/common/util/ITeleporter;)Lnet/minecraft/world/entity/Entity;=|p_38246_,teleporter +net/minecraft/world/item/BoneMealItem.applyBonemeal(Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/entity/player/Player;)Z=|p_40628_,p_40629_,p_40630_,player +net/minecraft/world/item/DyeableHorseArmorItem.(ILnet/minecraft/resources/ResourceLocation;Lnet/minecraft/world/item/Item$Properties;)V=|p_41110_,p_41111_,p_41112_ +net/minecraft/world/item/HorseArmorItem.(ILnet/minecraft/resources/ResourceLocation;Lnet/minecraft/world/item/Item$Properties;)V=|p_41364_,p_41111_,p_41366_ +net/minecraft/world/item/ItemStack.(Lnet/minecraft/world/level/ItemLike;ILnet/minecraft/nbt/CompoundTag;)V=|p_41604_,p_41605_,p_41606_ +net/minecraft/world/item/ItemStack.onItemUse(Lnet/minecraft/world/item/context/UseOnContext;Ljava/util/function/Function;)Lnet/minecraft/world/InteractionResult;=|p_41662_,callback +net/minecraft/world/item/ItemStack.onItemUseFirst(Lnet/minecraft/world/item/context/UseOnContext;)Lnet/minecraft/world/InteractionResult;=|p_41662_ +net/minecraft/world/item/MapItem.getCustomMapData(Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/level/Level;)Lnet/minecraft/world/level/saveddata/maps/MapItemSavedData;=|p_42910_,p_42911_ +net/minecraft/world/item/alchemy/PotionBrewing$Mix.(Lnet/minecraftforge/registries/ForgeRegistryEntry;Lnet/minecraft/world/item/crafting/Ingredient;Lnet/minecraftforge/registries/ForgeRegistryEntry;)V=|p_43536_,p_43537_,p_43538_ +net/minecraft/world/level/Level.markAndNotifyBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/chunk/LevelChunk;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockState;II)V=|p_46605_,levelchunk,blockstate,p_46606_,p_46607_,p_46608_ +net/minecraft/world/level/block/FireBlock.tryCatchFire(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;ILjava/util/Random;ILnet/minecraft/core/Direction;)V=|p_53432_,p_53433_,p_53434_,p_53435_,p_53436_,face +net/minecraft/world/level/block/FlowerPotBlock.(Ljava/util/function/Supplier;Ljava/util/function/Supplier;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V=|emptyPot,p_53528_,properties +net/minecraft/world/level/block/LiquidBlock.(Ljava/util/function/Supplier;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V=|p_54694_,p_54695_ +net/minecraft/world/level/chunk/PalettedContainer.setBits(IZ)V=|p_63122_,forceBits +net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.processEntityInfos(Lnet/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate;Lnet/minecraft/world/level/LevelAccessor;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/levelgen/structure/templatesystem/StructurePlaceSettings;Ljava/util/List;)Ljava/util/List;=|template,p_215387_0_,p_215387_1_,p_215387_2_,p_215387_3_ +net/minecraft/world/level/storage/loot/LootPool.([Lnet/minecraft/world/level/storage/loot/entries/LootPoolEntryContainer;[Lnet/minecraft/world/level/storage/loot/predicates/LootItemCondition;[Lnet/minecraft/world/level/storage/loot/functions/LootItemFunction;Lnet/minecraft/world/level/storage/loot/providers/number/NumberProvider;Lnet/minecraft/world/level/storage/loot/providers/number/NumberProvider;Ljava/lang/String;)V=|p_165128_,p_165129_,p_165130_,p_165131_,p_165132_,name \ No newline at end of file diff --git a/src/main/resources/forge.sas b/src/main/resources/forge.sas index 4b870ca561..7aa71f6787 100644 --- a/src/main/resources/forge.sas +++ b/src/main/resources/forge.sas @@ -6,114 +6,115 @@ # and remove the access modifier. #================================================================================================================================== # Block.getItem called from Block.getPickBlock. -net/minecraft/block/Block func_185473_a(Lnet/minecraft/world/IBlockReader;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Lnet/minecraft/item/ItemStack; - net/minecraft/block/AbstractBannerBlock func_185473_a(Lnet/minecraft/world/IBlockReader;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Lnet/minecraft/item/ItemStack; - net/minecraft/block/AbstractBodyPlantBlock func_185473_a(Lnet/minecraft/world/IBlockReader;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Lnet/minecraft/item/ItemStack; - net/minecraft/block/AttachedStemBlock func_185473_a(Lnet/minecraft/world/IBlockReader;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Lnet/minecraft/item/ItemStack; - net/minecraft/block/BambooSaplingBlock func_185473_a(Lnet/minecraft/world/IBlockReader;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Lnet/minecraft/item/ItemStack; - net/minecraft/block/CropsBlock func_185473_a(Lnet/minecraft/world/IBlockReader;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Lnet/minecraft/item/ItemStack; - net/minecraft/block/EndGatewayBlock func_185473_a(Lnet/minecraft/world/IBlockReader;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Lnet/minecraft/item/ItemStack; - net/minecraft/block/EndPortalBlock func_185473_a(Lnet/minecraft/world/IBlockReader;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Lnet/minecraft/item/ItemStack; - net/minecraft/block/FlowerPotBlock func_185473_a(Lnet/minecraft/world/IBlockReader;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Lnet/minecraft/item/ItemStack; - net/minecraft/block/FrostedIceBlock func_185473_a(Lnet/minecraft/world/IBlockReader;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Lnet/minecraft/item/ItemStack; - net/minecraft/block/MovingPistonBlock func_185473_a(Lnet/minecraft/world/IBlockReader;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Lnet/minecraft/item/ItemStack; - net/minecraft/block/NetherPortalBlock func_185473_a(Lnet/minecraft/world/IBlockReader;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Lnet/minecraft/item/ItemStack; - net/minecraft/block/NetherWartBlock func_185473_a(Lnet/minecraft/world/IBlockReader;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Lnet/minecraft/item/ItemStack; - net/minecraft/block/PistonHeadBlock func_185473_a(Lnet/minecraft/world/IBlockReader;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Lnet/minecraft/item/ItemStack; - net/minecraft/block/ShulkerBoxBlock func_185473_a(Lnet/minecraft/world/IBlockReader;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Lnet/minecraft/item/ItemStack; - net/minecraft/block/SpawnerBlock func_185473_a(Lnet/minecraft/world/IBlockReader;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Lnet/minecraft/item/ItemStack; - net/minecraft/block/StemBlock func_185473_a(Lnet/minecraft/world/IBlockReader;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Lnet/minecraft/item/ItemStack; - net/minecraft/block/SweetBerryBushBlock func_185473_a(Lnet/minecraft/world/IBlockReader;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Lnet/minecraft/item/ItemStack; - net/minecraft/block/TallSeaGrassBlock func_185473_a(Lnet/minecraft/world/IBlockReader;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Lnet/minecraft/item/ItemStack; +net/minecraft/world/level/block/Block m_7397_(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Lnet/minecraft/world/item/ItemStack; + net/minecraft/world/level/block/AbstractBannerBlock m_7397_(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Lnet/minecraft/world/item/ItemStack; + net/minecraft/world/level/block/AttachedStemBlock m_7397_(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Lnet/minecraft/world/item/ItemStack; + net/minecraft/world/level/block/BambooSaplingBlock m_7397_(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Lnet/minecraft/world/item/ItemStack; + net/minecraft/world/level/block/BigDripleafStemBlock m_7397_(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Lnet/minecraft/world/item/ItemStack; + net/minecraft/world/level/block/CandleCakeBlock m_7397_(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Lnet/minecraft/world/item/ItemStack; + net/minecraft/world/level/block/CaveVinesBlock m_7397_(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Lnet/minecraft/world/item/ItemStack; + net/minecraft/world/level/block/CaveVinesPlantBlock m_7397_(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Lnet/minecraft/world/item/ItemStack; + net/minecraft/world/level/block/CropBlock m_7397_(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Lnet/minecraft/world/item/ItemStack; + net/minecraft/world/level/block/EndGatewayBlock m_7397_(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Lnet/minecraft/world/item/ItemStack; + net/minecraft/world/level/block/EndPortalBlock m_7397_(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Lnet/minecraft/world/item/ItemStack; + net/minecraft/world/level/block/FlowerPotBlock m_7397_(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Lnet/minecraft/world/item/ItemStack; + net/minecraft/world/level/block/FrostedIceBlock m_7397_(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Lnet/minecraft/world/item/ItemStack; + net/minecraft/world/level/block/GrowingPlantBodyBlock m_7397_(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Lnet/minecraft/world/item/ItemStack; + net/minecraft/world/level/block/LightBlock m_7397_(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Lnet/minecraft/world/item/ItemStack; + net/minecraft/world/level/block/NetherPortalBlock m_7397_(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Lnet/minecraft/world/item/ItemStack; + net/minecraft/world/level/block/NetherWartBlock m_7397_(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Lnet/minecraft/world/item/ItemStack; + net/minecraft/world/level/block/ShulkerBoxBlock m_7397_(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Lnet/minecraft/world/item/ItemStack; + net/minecraft/world/level/block/SpawnerBlock m_7397_(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Lnet/minecraft/world/item/ItemStack; + net/minecraft/world/level/block/StemBlock m_7397_(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Lnet/minecraft/world/item/ItemStack; + net/minecraft/world/level/block/SweetBerryBushBlock m_7397_(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Lnet/minecraft/world/item/ItemStack; + net/minecraft/world/level/block/TallSeagrassBlock m_7397_(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Lnet/minecraft/world/item/ItemStack; + net/minecraft/world/level/block/piston/MovingPistonBlock m_7397_(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Lnet/minecraft/world/item/ItemStack; + net/minecraft/world/level/block/piston/PistonHeadBlock m_7397_(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Lnet/minecraft/world/item/ItemStack; # Vanilla blocks calling these sided methods in getItem -net/minecraft/tileentity/BannerTileEntity func_190615_l(Lnet/minecraft/block/BlockState;)Lnet/minecraft/item/ItemStack; -net/minecraft/block/BannerBlock func_196287_a(Lnet/minecraft/item/DyeColor;)Lnet/minecraft/block/Block; -net/minecraft/block/AttachedStemBlock func_196279_O_()Lnet/minecraft/item/Item; -net/minecraft/block/StemBlock func_176481_j()Lnet/minecraft/item/Item; +net/minecraft/world/level/block/BannerBlock m_49014_(Lnet/minecraft/world/item/DyeColor;)Lnet/minecraft/world/level/block/Block; #===================================== -net/minecraft/block/CropsBlock func_199772_f()Lnet/minecraft/util/IItemProvider; # getSeedsItem - net/minecraft/block/BeetrootBlock func_199772_f()Lnet/minecraft/util/IItemProvider; - net/minecraft/block/CarrotBlock func_199772_f()Lnet/minecraft/util/IItemProvider; - net/minecraft/block/PotatoBlock func_199772_f()Lnet/minecraft/util/IItemProvider; -net/minecraft/block/SoundType func_185845_c()Lnet/minecraft/util/SoundEvent; # getBreakSound -net/minecraft/block/SoundType func_185846_f()Lnet/minecraft/util/SoundEvent; # getHitSound -net/minecraft/block/WoodType func_227046_a_()Ljava/util/stream/Stream; # getValues -net/minecraft/block/WoodType func_227048_b_()Ljava/lang/String; # getName -net/minecraft/item/DyeColor func_218388_g()I # getTextColor -net/minecraft/item/DyeColor func_196058_b(I)Lnet/minecraft/item/DyeColor; # byFireworkColor -net/minecraft/item/crafting/Ingredient func_193365_a()[Lnet/minecraft/item/ItemStack; # getMatchingStacks -net/minecraft/item/crafting/Ingredient func_193369_a([Lnet/minecraft/item/ItemStack;)Lnet/minecraft/item/crafting/Ingredient; # fromStacks -net/minecraft/item/crafting/IRecipe func_222128_h()Lnet/minecraft/item/ItemStack; # getIcon - net/minecraft/item/crafting/BlastingRecipe func_222128_h()Lnet/minecraft/item/ItemStack; - net/minecraft/item/crafting/CampfireCookingRecipe func_222128_h()Lnet/minecraft/item/ItemStack; - net/minecraft/item/crafting/FurnaceRecipe func_222128_h()Lnet/minecraft/item/ItemStack; - net/minecraft/item/crafting/SmithingRecipe func_222128_h()Lnet/minecraft/item/ItemStack; - net/minecraft/item/crafting/SmokingRecipe func_222128_h()Lnet/minecraft/item/ItemStack; - net/minecraft/item/crafting/StonecuttingRecipe func_222128_h()Lnet/minecraft/item/ItemStack; -net/minecraft/item/crafting/IRecipe func_194133_a(II)Z # canFit - net/minecraft/item/crafting/AbstractCookingRecipe func_194133_a(II)Z - net/minecraft/item/crafting/ArmorDyeRecipe func_194133_a(II)Z - net/minecraft/item/crafting/BannerDuplicateRecipe func_194133_a(II)Z - net/minecraft/item/crafting/BookCloningRecipe func_194133_a(II)Z - net/minecraft/item/crafting/FireworkRocketRecipe func_194133_a(II)Z - net/minecraft/item/crafting/FireworkStarFadeRecipe func_194133_a(II)Z - net/minecraft/item/crafting/FireworkStarRecipe func_194133_a(II)Z - net/minecraft/item/crafting/MapCloningRecipe func_194133_a(II)Z - net/minecraft/item/crafting/RepairItemRecipe func_194133_a(II)Z - net/minecraft/item/crafting/ShapedRecipe func_194133_a(II)Z - net/minecraft/item/crafting/ShapelessRecipe func_194133_a(II)Z - net/minecraft/item/crafting/ShieldRecipes func_194133_a(II)Z - net/minecraft/item/crafting/ShulkerBoxColoringRecipe func_194133_a(II)Z - net/minecraft/item/crafting/SingleItemRecipe func_194133_a(II)Z - net/minecraft/item/crafting/SmithingRecipe func_194133_a(II)Z - net/minecraft/item/crafting/SuspiciousStewRecipe func_194133_a(II)Z - net/minecraft/item/crafting/TippedArrowRecipe func_194133_a(II)Z -net/minecraft/item/crafting/IRecipe func_193358_e()Ljava/lang/String; # getGroup - net/minecraft/item/crafting/AbstractCookingRecipe func_193358_e()Ljava/lang/String; - net/minecraft/item/crafting/ShapedRecipe func_193358_e()Ljava/lang/String; - net/minecraft/item/crafting/ShapelessRecipe func_193358_e()Ljava/lang/String; - net/minecraft/item/crafting/SingleItemRecipe func_193358_e()Ljava/lang/String; -net/minecraft/network/PacketBuffer func_186873_b([J)[J -net/minecraft/network/PacketBuffer func_189423_a([JI)[J -net/minecraft/network/PacketBuffer func_218666_n()Ljava/lang/String; -net/minecraft/network/PacketBuffer func_218667_g()Lnet/minecraft/util/math/SectionPos; -net/minecraft/nbt/CompressedStreamTools func_74797_a(Ljava/io/File;)Lnet/minecraft/nbt/CompoundNBT; # read -net/minecraft/nbt/CompressedStreamTools func_74795_b(Lnet/minecraft/nbt/CompoundNBT;Ljava/io/File;)V # write -net/minecraft/network/play/server/SCommandListPacket func_197693_a()Lcom/mojang/brigadier/tree/RootCommandNode; # getRoot -net/minecraft/network/play/server/SEntityPropertiesPacket func_149441_d()Ljava/util/List; # getSnapshots -net/minecraft/network/play/server/SEntityPropertiesPacket func_149442_c()I # getEntityId -net/minecraft/potion/Effect func_220303_e()Lnet/minecraft/potion/EffectType; # getEffectType -net/minecraft/potion/Effect func_111186_k()Ljava/util/Map; # getAttributeModifierMap -net/minecraft/potion/Effect func_188408_i()Z # isBeneficial -net/minecraft/potion/EffectType func_220306_a()Lnet/minecraft/util/text/TextFormatting; # getColor -net/minecraft/resources/IResourceManager func_199001_a()Ljava/util/Set; # getResourceNamespaces - net/minecraft/resources/FallbackResourceManager func_199001_a()Ljava/util/Set; - net/minecraft/resources/IResourceManager$Instance func_199001_a()Ljava/util/Set; - net/minecraft/resources/SimpleReloadableResourceManager func_199001_a()Ljava/util/Set; -net/minecraft/resources/IResourceManager func_219533_b(Lnet/minecraft/util/ResourceLocation;)Z # hasResource - net/minecraft/resources/FallbackResourceManager func_219533_b(Lnet/minecraft/util/ResourceLocation;)Z - net/minecraft/resources/IResourceManager$Instance func_219533_b(Lnet/minecraft/util/ResourceLocation;)Z - net/minecraft/resources/SimpleReloadableResourceManager func_219533_b(Lnet/minecraft/util/ResourceLocation;)Z -net/minecraft/tags/ITagCollection func_199913_a(Ljava/lang/Object;)Ljava/util/Collection; # getOwningTags -net/minecraft/util/Direction func_176739_a(Ljava/lang/String;)Lnet/minecraft/util/Direction; # byName -net/minecraft/util/Direction$Axis func_176717_a(Ljava/lang/String;)Lnet/minecraft/util/Direction$Axis; # byName -net/minecraft/util/math/vector/Vector3d func_216371_e()Lnet/minecraft/util/math/vector/Vector3d; -net/minecraft/util/math/vector/Vector3d func_189984_a(Lnet/minecraft/util/math/vector/Vector2f;)Lnet/minecraft/util/math/vector/Vector3d; # fromPitchYaw -net/minecraft/util/math/vector/Vector3d func_189986_a(FF)Lnet/minecraft/util/math/vector/Vector3d; # fromPitchYaw -net/minecraft/util/math/vector/Vector4f # Vector 4f Class -net/minecraft/util/text/Style func_240719_a_(Lnet/minecraft/util/ResourceLocation;)Lnet/minecraft/util/text/Style; #setFontId -net/minecraft/util/text/Style func_240723_c_(Lnet/minecraft/util/text/TextFormatting;)Lnet/minecraft/util/text/Style; #forceFormatting -# BiomeAmbiance getters, needed for it to be useful during BiomeLoadingEvent to be useful -net/minecraft/world/biome/BiomeAmbience func_235213_a_()I # getFogColor -net/minecraft/world/biome/BiomeAmbience func_235216_b_()I # getWaterColor -net/minecraft/world/biome/BiomeAmbience func_235218_c_()I # getWaterFogColor -net/minecraft/world/biome/BiomeAmbience func_242527_d()I # getSkyColor -net/minecraft/world/biome/BiomeAmbience func_242528_e()Ljava/util/Optional; # getFoliageColor -net/minecraft/world/biome/BiomeAmbience func_242529_f()Ljava/util/Optional; # getGrassColor -net/minecraft/world/biome/BiomeAmbience func_242531_g()Lnet/minecraft/world/biome/BiomeAmbience$GrassColorModifier; # getGrassColorModifier -net/minecraft/world/biome/BiomeAmbience func_235220_d_()Ljava/util/Optional; # getParticle -net/minecraft/world/biome/BiomeAmbience func_235222_e_()Ljava/util/Optional; # getAmbientSound -net/minecraft/world/biome/BiomeAmbience func_235224_f_()Ljava/util/Optional; # getMoodSound -net/minecraft/world/biome/BiomeAmbience func_235226_g_()Ljava/util/Optional; # getAdditionsSound -net/minecraft/world/biome/BiomeAmbience func_235228_h_()Ljava/util/Optional; # getMusic -net/minecraft/client/renderer/model/ModelResourceLocation # ModelResourceLocation class \ No newline at end of file +net/minecraft/world/level/block/CropBlock m_6404_()Lnet/minecraft/world/level/ItemLike; # getSeedsItem + net/minecraft/world/level/block/BeetrootBlock m_6404_()Lnet/minecraft/world/level/ItemLike; + net/minecraft/world/level/block/CarrotBlock m_6404_()Lnet/minecraft/world/level/ItemLike; + net/minecraft/world/level/block/PotatoBlock m_6404_()Lnet/minecraft/world/level/ItemLike; +net/minecraft/world/level/block/SoundType m_56775_()Lnet/minecraft/sounds/SoundEvent; # getBreakSound +net/minecraft/world/level/block/SoundType m_56778_()Lnet/minecraft/sounds/SoundEvent; # getHitSound +net/minecraft/world/level/block/state/properties/WoodType m_61843_()Ljava/util/stream/Stream; # getValues +net/minecraft/world/level/block/state/properties/WoodType m_61846_()Ljava/lang/String; # getName +net/minecraft/world/item/DyeColor m_41071_()I # getTextColor +net/minecraft/world/item/DyeColor m_41061_(I)Lnet/minecraft/world/item/DyeColor; # byFireworkColor +net/minecraft/world/item/crafting/Ingredient m_43908_()[Lnet/minecraft/world/item/ItemStack; # getMatchingStacks +net/minecraft/world/item/crafting/Ingredient m_43927_([Lnet/minecraft/world/item/ItemStack;)Lnet/minecraft/world/item/crafting/Ingredient; # fromStacks +net/minecraft/world/item/crafting/Recipe m_8042_()Lnet/minecraft/world/item/ItemStack; # getIcon + net/minecraft/world/item/crafting/BlastingRecipe m_8042_()Lnet/minecraft/world/item/ItemStack; + net/minecraft/world/item/crafting/CampfireCookingRecipe m_8042_()Lnet/minecraft/world/item/ItemStack; + net/minecraft/world/item/crafting/SmeltingRecipe m_8042_()Lnet/minecraft/world/item/ItemStack; + net/minecraft/world/item/crafting/SmokingRecipe m_8042_()Lnet/minecraft/world/item/ItemStack; + net/minecraft/world/item/crafting/StonecutterRecipe m_8042_()Lnet/minecraft/world/item/ItemStack; + net/minecraft/world/item/crafting/UpgradeRecipe m_8042_()Lnet/minecraft/world/item/ItemStack; +net/minecraft/world/item/crafting/Recipe m_8004_(II)Z # canFit + net/minecraft/world/item/crafting/AbstractCookingRecipe m_8004_(II)Z + net/minecraft/world/item/crafting/ArmorDyeRecipe m_8004_(II)Z + net/minecraft/world/item/crafting/BannerDuplicateRecipe m_8004_(II)Z + net/minecraft/world/item/crafting/BookCloningRecipe m_8004_(II)Z + net/minecraft/world/item/crafting/FireworkRocketRecipe m_8004_(II)Z + net/minecraft/world/item/crafting/FireworkStarFadeRecipe m_8004_(II)Z + net/minecraft/world/item/crafting/FireworkStarRecipe m_8004_(II)Z + net/minecraft/world/item/crafting/MapCloningRecipe m_8004_(II)Z + net/minecraft/world/item/crafting/RepairItemRecipe m_8004_(II)Z + net/minecraft/world/item/crafting/ShapedRecipe m_8004_(II)Z + net/minecraft/world/item/crafting/ShapelessRecipe m_8004_(II)Z + net/minecraft/world/item/crafting/ShieldDecorationRecipe m_8004_(II)Z + net/minecraft/world/item/crafting/ShulkerBoxColoring m_8004_(II)Z + net/minecraft/world/item/crafting/SingleItemRecipe m_8004_(II)Z + net/minecraft/world/item/crafting/SuspiciousStewRecipe m_8004_(II)Z + net/minecraft/world/item/crafting/TippedArrowRecipe m_8004_(II)Z + net/minecraft/world/item/crafting/UpgradeRecipe m_8004_(II)Z +net/minecraft/world/item/crafting/Recipe m_6076_()Ljava/lang/String; # getGroup + net/minecraft/world/item/crafting/AbstractCookingRecipe m_6076_()Ljava/lang/String; + net/minecraft/world/item/crafting/ShapedRecipe m_6076_()Ljava/lang/String; + net/minecraft/world/item/crafting/ShapelessRecipe m_6076_()Ljava/lang/String; + net/minecraft/world/item/crafting/SingleItemRecipe m_6076_()Ljava/lang/String; +net/minecraft/network/PacketBuffer m_130105_([J)[J +net/minecraft/network/PacketBuffer m_130093_([JI)[J +net/minecraft/network/PacketBuffer m_130277_()Ljava/lang/String; +net/minecraft/network/PacketBuffer m_130157_()Lnet/minecraft/util/math/SectionPos; +net/minecraft/nbt/NbtIo m_128953_(Ljava/io/File;)Lnet/minecraft/nbt/CompoundTag; # read +net/minecraft/nbt/NbtIo m_128955_(Lnet/minecraft/nbt/CompoundTag;Ljava/io/File;)V # write +net/minecraft/network/protocol/game/ClientboundCommandsPacket m_131884_()Lcom/mojang/brigadier/tree/RootCommandNode; # getRoot +net/minecraft/network/protocol/game/ClientboundUpdateAttributesPacket m_133591_()Ljava/util/List; # getSnapshots +net/minecraft/network/protocol/game/ClientboundUpdateAttributesPacket m_133588_()I # getEntityId +net/minecraft/world/effect/MobEffect m_19483_()Lnet/minecraft/world/effect/MobEffectCategory; # getEffectType +net/minecraft/world/effect/MobEffect m_19485_()Ljava/util/Map; # getAttributeModifierMap +net/minecraft/world/effect/MobEffect m_19486_()Z # isBeneficial +net/minecraft/world/effect/MobEffectCategory m_19497_()Lnet/minecraft/ChatFormatting; # getColor +net/minecraft/server/packs/resources/ResourceManager m_7187_()Ljava/util/Set; # getResourceNamespaces + net/minecraft/server/packs/resources/FallbackResourceManager m_7187_()Ljava/util/Set; + net/minecraft/server/packs/resources/ResourceManager$Empty m_7187_()Ljava/util/Set; + net/minecraft/server/packs/resources/SimpleReloadableResourceManager m_7187_()Ljava/util/Set; +net/minecraft/server/packs/resources/ResourceManager m_7165_(Lnet/minecraft/resources/ResourceLocation;)Z # hasResource + net/minecraft/server/packs/resources/FallbackResourceManager m_7165_(Lnet/minecraft/resources/ResourceLocation;)Z + net/minecraft/server/packs/resources/ResourceManager$Empty m_7165_(Lnet/minecraft/resources/ResourceLocation;)Z + net/minecraft/server/packs/resources/SimpleReloadableResourceManager m_7165_(Lnet/minecraft/resources/ResourceLocation;)Z +net/minecraft/core/Direction m_122402_(Ljava/lang/String;)Lnet/minecraft/core/Direction; # byName +net/minecraft/core/Direction$Axis m_122473_(Ljava/lang/String;)Lnet/minecraft/core/Direction$Axis; # byName +net/minecraft/world/phys/Vec3 m_82548_()Lnet/minecraft/world/phys/Vec3; +net/minecraft/world/phys/Vec3 m_82503_(Lnet/minecraft/world/phys/Vec2;)Lnet/minecraft/world/phys/Vec3; # fromPitchYaw +net/minecraft/world/phys/Vec3 m_82498_(FF)Lnet/minecraft/world/phys/Vec3; # fromPitchYaw +com/mojang/math/Vector4f # Vector 4f Class +net/minecraft/network/chat/Style m_131150_(Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/network/chat/Style; #setFontId +net/minecraft/network/chat/Style m_131164_(Lnet/minecraft/ChatFormatting;)Lnet/minecraft/network/chat/Style; #forceFormatting +# BiomeSpecialEffects getters, needed for it to be useful during BiomeLoadingEvent to be useful +net/minecraft/world/level/biome/BiomeSpecialEffects m_47967_()I # getFogColor +net/minecraft/world/level/biome/BiomeSpecialEffects m_47972_()I # getWaterColor +net/minecraft/world/level/biome/BiomeSpecialEffects m_47975_()I # getWaterFogColor +net/minecraft/world/level/biome/BiomeSpecialEffects m_47978_()I # getSkyColor +net/minecraft/world/level/biome/BiomeSpecialEffects m_47981_()Ljava/util/Optional; # getFoliageColor +net/minecraft/world/level/biome/BiomeSpecialEffects m_47984_()Ljava/util/Optional; # getGrassColor +net/minecraft/world/level/biome/BiomeSpecialEffects m_47987_()Lnet/minecraft/world/level/biome/BiomeSpecialEffects$GrassColorModifier; # getGrassColorModifier +net/minecraft/world/level/biome/BiomeSpecialEffects m_47990_()Ljava/util/Optional; # getParticle +net/minecraft/world/level/biome/BiomeSpecialEffects m_47993_()Ljava/util/Optional; # getAmbientSound +net/minecraft/world/level/biome/BiomeSpecialEffects m_47996_()Ljava/util/Optional; # getMoodSound +net/minecraft/world/level/biome/BiomeSpecialEffects m_47999_()Ljava/util/Optional; # getAdditionsSound +net/minecraft/world/level/biome/BiomeSpecialEffects m_48002_()Ljava/util/Optional; # getMusic +net/minecraft/client/resources/model/ModelResourceLocation # ModelResourceLocation class \ No newline at end of file diff --git a/src/test/java/net/minecraftforge/common/ForgeConfigSpecTest.java b/src/test/java/net/minecraftforge/commontest/ForgeConfigSpecTest.java similarity index 90% rename from src/test/java/net/minecraftforge/common/ForgeConfigSpecTest.java rename to src/test/java/net/minecraftforge/commontest/ForgeConfigSpecTest.java index f305aa6a16..4b4aeee85a 100644 --- a/src/test/java/net/minecraftforge/common/ForgeConfigSpecTest.java +++ b/src/test/java/net/minecraftforge/commontest/ForgeConfigSpecTest.java @@ -17,29 +17,46 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.common; +package net.minecraftforge.commontest; import com.electronwill.nightconfig.core.file.CommentedFileConfig; import com.electronwill.nightconfig.core.io.WritingMode; import com.google.common.base.Stopwatch; import com.google.common.collect.Lists; +import net.minecraftforge.common.ForgeConfigSpec; import org.junit.Assert; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.TestRule; import java.io.File; import java.io.IOException; +import java.lang.reflect.Field; import java.nio.file.Files; import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeUnit; -import java.util.function.ToLongFunction; public class ForgeConfigSpecTest { private final String TEST_CONFIG_PATH_TEMPLATE = "./tests/config/%s.toml"; private final int TEST_SIZE = 10000; + private static final Field useCachesField; + + static { + try { + useCachesField = ForgeConfigSpec.ConfigValue.class.getDeclaredField("USE_CACHES"); + useCachesField.setAccessible(true); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + private static void setUseCachesField(boolean value) { + try { + useCachesField.setBoolean(null, value); + } catch (Exception e) { + throw new RuntimeException(e); + } + } @Test public void simpleSpeedTest() throws IOException @@ -122,7 +139,7 @@ public class ForgeConfigSpecTest private TestResult runTestOnce(final T defaultKeyValue, final String testName, final ForgeConfigSpec.ConfigValue simpleValue, final ForgeConfigSpec spec) { spec.afterReload(); - ForgeConfigSpec.ConfigValue.USE_CACHES = false; + setUseCachesField(true); final Stopwatch watchDisabled = Stopwatch.createStarted(); for (int i = 0; i < TEST_SIZE; i++) { @@ -131,7 +148,7 @@ public class ForgeConfigSpecTest watchDisabled.stop(); spec.afterReload(); - ForgeConfigSpec.ConfigValue.USE_CACHES = true; + setUseCachesField(false); final Stopwatch watchEnabled = Stopwatch.createStarted(); for (int i = 0; i < TEST_SIZE; i++) { diff --git a/src/test/java/net/minecraftforge/debug/CodecsTest.java b/src/test/java/net/minecraftforge/debug/CodecsTest.java index 126335bb32..300a8732af 100644 --- a/src/test/java/net/minecraftforge/debug/CodecsTest.java +++ b/src/test/java/net/minecraftforge/debug/CodecsTest.java @@ -19,9 +19,9 @@ package net.minecraftforge.debug; -import net.minecraft.fluid.Fluids; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.NBTDynamicOps; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtOps; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fml.common.Mod; import org.apache.logging.log4j.LogManager; @@ -49,13 +49,13 @@ public class CodecsTest FluidStack withTag = new FluidStack(Fluids.LAVA, 10); withTag.getOrCreateChildTag("test").putString("value", "This is a test"); - CompoundNBT noTag_write = noTag.writeToNBT(new CompoundNBT()); - CompoundNBT withTag_write = withTag.writeToNBT(new CompoundNBT()); + CompoundTag noTag_write = noTag.writeToNBT(new CompoundTag()); + CompoundTag withTag_write = withTag.writeToNBT(new CompoundTag()); - CompoundNBT noTag_encode = (CompoundNBT)FluidStack.CODEC.encodeStart(NBTDynamicOps.INSTANCE, noTag).getOrThrow(false, error -> { + CompoundTag noTag_encode = (CompoundTag)FluidStack.CODEC.encodeStart(NbtOps.INSTANCE, noTag).getOrThrow(false, error -> { LOGGER.error("Error encoding noTag: {}", error); }); - CompoundNBT withTag_encode = (CompoundNBT)FluidStack.CODEC.encodeStart(NBTDynamicOps.INSTANCE, withTag).getOrThrow(false, error -> { + CompoundTag withTag_encode = (CompoundTag)FluidStack.CODEC.encodeStart(NbtOps.INSTANCE, withTag).getOrThrow(false, error -> { LOGGER.error("Error encoding withTag: {}", error); }); @@ -64,10 +64,10 @@ public class CodecsTest if (!withTag_write.equals(withTag_encode)) throw new IllegalStateException("Encoded withTag does not match"); - FluidStack noTag_decode = FluidStack.CODEC.decode(NBTDynamicOps.INSTANCE, noTag_encode).getOrThrow(false, error -> { + FluidStack noTag_decode = FluidStack.CODEC.decode(NbtOps.INSTANCE, noTag_encode).getOrThrow(false, error -> { LOGGER.error("Error decoding noTag: {}", error); }).getFirst(); - FluidStack withTag_decode = FluidStack.CODEC.decode(NBTDynamicOps.INSTANCE, withTag_encode).getOrThrow(false, error -> { + FluidStack withTag_decode = FluidStack.CODEC.decode(NbtOps.INSTANCE, withTag_encode).getOrThrow(false, error -> { LOGGER.error("Error decoding withTag: {}", error); }).getFirst(); diff --git a/src/test/java/net/minecraftforge/debug/CustomSoundTypeTest.java b/src/test/java/net/minecraftforge/debug/CustomSoundTypeTest.java index 2d5af4eec1..a114724041 100644 --- a/src/test/java/net/minecraftforge/debug/CustomSoundTypeTest.java +++ b/src/test/java/net/minecraftforge/debug/CustomSoundTypeTest.java @@ -19,18 +19,18 @@ package net.minecraftforge.debug; -import net.minecraft.block.AbstractBlock; -import net.minecraft.block.Block; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.SoundEvent; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.sounds.SoundEvent; import net.minecraftforge.common.util.ForgeSoundType; import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fml.RegistryObject; +import net.minecraftforge.fmllegacy.RegistryObject; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.DeferredRegister; @@ -50,10 +50,10 @@ public class CustomSoundTypeTest private static final SoundType TEST_SOUND_TYPE = new ForgeSoundType(1.0F, 1.0F, TEST_STEP_EVENT, TEST_STEP_EVENT, TEST_STEP_EVENT, TEST_STEP_EVENT, TEST_STEP_EVENT); private static final RegistryObject TEST_STEP_BLOCK = BLOCKS.register("test_block", - () -> new Block(AbstractBlock.Properties.of(Material.WOOD).sound(TEST_SOUND_TYPE))); + () -> new Block(BlockBehaviour.Properties.of(Material.WOOD).sound(TEST_SOUND_TYPE))); private static final RegistryObject TEST_STEP_BLOCK_ITEM = ITEMS.register("test_block", - () -> new BlockItem(TEST_STEP_BLOCK.get(), new Item.Properties().tab(ItemGroup.TAB_MISC))); + () -> new BlockItem(TEST_STEP_BLOCK.get(), new Item.Properties().tab(CreativeModeTab.TAB_MISC))); public CustomSoundTypeTest() { diff --git a/src/test/java/net/minecraftforge/debug/DataGeneratorTest.java b/src/test/java/net/minecraftforge/debug/DataGeneratorTest.java index 0897ac387a..73cdfd7d28 100644 --- a/src/test/java/net/minecraftforge/debug/DataGeneratorTest.java +++ b/src/test/java/net/minecraftforge/debug/DataGeneratorTest.java @@ -40,8 +40,7 @@ import java.util.stream.Stream; import com.google.gson.JsonNull; import com.google.gson.JsonPrimitive; -import net.minecraft.block.*; -import net.minecraft.util.SoundEvents; +import net.minecraft.sounds.SoundEvents; import net.minecraftforge.common.data.SoundDefinition; import net.minecraftforge.common.data.SoundDefinitionsProvider; import org.apache.commons.lang3.tuple.Triple; @@ -63,26 +62,26 @@ import com.google.gson.JsonObject; import net.minecraft.advancements.Advancement; import net.minecraft.advancements.AdvancementRewards; import net.minecraft.advancements.FrameType; -import net.minecraft.client.renderer.model.ItemCameraTransforms; -import net.minecraft.client.renderer.model.ItemTransformVec3f; -import net.minecraft.client.renderer.model.Variant; -import net.minecraft.client.renderer.model.BlockModel.GuiLight; -import net.minecraft.data.BlockTagsProvider; +import net.minecraft.client.renderer.block.model.ItemTransforms; +import net.minecraft.client.renderer.block.model.ItemTransform; +import net.minecraft.client.renderer.block.model.Variant; +import net.minecraft.client.renderer.block.model.BlockModel.GuiLight; +import net.minecraft.data.tags.BlockTagsProvider; import net.minecraft.data.DataGenerator; -import net.minecraft.data.DirectoryCache; -import net.minecraft.data.IFinishedRecipe; -import net.minecraft.data.RecipeProvider; -import net.minecraft.data.ShapedRecipeBuilder; -import net.minecraft.enchantment.Enchantments; -import net.minecraft.entity.EntityType; -import net.minecraft.item.Items; -import net.minecraft.potion.Effects; -import net.minecraft.resources.IResource; -import net.minecraft.resources.ResourcePackType; +import net.minecraft.data.HashCache; +import net.minecraft.data.recipes.FinishedRecipe; +import net.minecraft.data.recipes.RecipeProvider; +import net.minecraft.data.recipes.ShapedRecipeBuilder; +import net.minecraft.world.item.enchantment.Enchantments; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.item.Items; +import net.minecraft.world.effect.MobEffects; +import net.minecraft.server.packs.resources.Resource; +import net.minecraft.server.packs.PackType; import net.minecraft.tags.BlockTags; -import net.minecraft.util.Direction; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.StringTextComponent; +import net.minecraft.core.Direction; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.network.chat.TextComponent; import net.minecraftforge.client.model.generators.BlockStateProvider; import net.minecraftforge.client.model.generators.ConfiguredModel; import net.minecraftforge.client.model.generators.ItemModelProvider; @@ -100,7 +99,21 @@ import net.minecraftforge.common.data.LanguageProvider; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus; -import net.minecraftforge.fml.event.lifecycle.GatherDataEvent; +import net.minecraftforge.forge.event.lifecycle.GatherDataEvent; + +import net.minecraft.world.level.block.BarrelBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.DoorBlock; +import net.minecraft.world.level.block.FenceBlock; +import net.minecraft.world.level.block.FenceGateBlock; +import net.minecraft.world.level.block.FurnaceBlock; +import net.minecraft.world.level.block.IronBarsBlock; +import net.minecraft.world.level.block.RotatedPillarBlock; +import net.minecraft.world.level.block.SlabBlock; +import net.minecraft.world.level.block.StairBlock; +import net.minecraft.world.level.block.TrapDoorBlock; +import net.minecraft.world.level.block.WallBlock; @SuppressWarnings("deprecation") @Mod(MODID) @@ -116,8 +129,8 @@ public class DataGeneratorTest { GSON = new GsonBuilder() .registerTypeAdapter(Variant.class, new Variant.Deserializer()) - .registerTypeAdapter(ItemCameraTransforms.class, new ItemCameraTransforms.Deserializer()) - .registerTypeAdapter(ItemTransformVec3f.class, new ItemTransformVec3f.Deserializer()) + .registerTypeAdapter(ItemTransforms.class, new ItemTransforms.Deserializer()) + .registerTypeAdapter(ItemTransform.class, new ItemTransform.Deserializer()) .create(); DataGenerator gen = event.getGenerator(); @@ -145,7 +158,8 @@ public class DataGeneratorTest super(gen); } - protected void buildShapelessRecipes(Consumer consumer) + @Override + protected void buildCraftingRecipes(Consumer consumer) { ResourceLocation ID = new ResourceLocation("data_gen_test", "conditional"); @@ -180,8 +194,8 @@ public class DataGeneratorTest Advancement.Builder.advancement() .parent(new ResourceLocation("minecraft", "root")) .display(Blocks.DIAMOND_BLOCK, - new StringTextComponent("Dirt2Diamonds"), - new StringTextComponent("The BEST crafting recipe in the game!"), + new TextComponent("Dirt2Diamonds"), + new TextComponent("The BEST crafting recipe in the game!"), null, FrameType.TASK, false, false, false ) .rewards(AdvancementRewards.Builder.recipe(ID)) @@ -290,7 +304,7 @@ public class DataGeneratorTest } @Override - public void run(DirectoryCache cache) throws IOException + public void run(HashCache cache) throws IOException { super.run(cache); test(); @@ -308,7 +322,7 @@ public class DataGeneratorTest throw new RuntimeException("Unable to test for errors due to reflection error", e); } final JsonObject actual = GSON.fromJson( - new InputStreamReader(this.helper.getResource(new ResourceLocation("sounds.json"), ResourcePackType.CLIENT_RESOURCES).getInputStream()), + new InputStreamReader(this.helper.getResource(new ResourceLocation("sounds.json"), PackType.CLIENT_RESOURCES).getInputStream()), JsonObject.class ); @@ -432,7 +446,6 @@ public class DataGeneratorTest } } - public static class Tags extends BlockTagsProvider { public Tags(DataGenerator gen, ExistingFileHelper existingFileHelper) @@ -478,7 +491,7 @@ public class DataGeneratorTest add(Blocks.STONE, "Stone"); add(Items.DIAMOND, "Diamond"); //add(Biomes.BEACH, "Beach"); - add(Effects.POISON, "Poison"); + add(MobEffects.POISON, "Poison"); add(Enchantments.SHARPNESS, "Sharpness"); add(EntityType.CAT, "Cat"); add(MODID + ".test.unicode", "\u0287s\u01DD\u2534 \u01DDpo\u0254\u1D09u\u2229"); @@ -533,7 +546,7 @@ public class DataGeneratorTest ); @Override - public void run(DirectoryCache cache) throws IOException + public void run(HashCache cache) throws IOException { super.run(cache); List errors = testModelResults(this.generatedModels, existingFileHelper, IGNORED_MODELS.stream().map(s -> new ResourceLocation(MODID, folder + "/" + s)).collect(Collectors.toSet())); @@ -673,7 +686,7 @@ public class DataGeneratorTest logBlock((RotatedPillarBlock) Blocks.ACACIA_LOG); - stairsBlock((StairsBlock) Blocks.ACACIA_STAIRS, "acacia", mcLoc("block/acacia_planks")); + stairsBlock((StairBlock) Blocks.ACACIA_STAIRS, "acacia", mcLoc("block/acacia_planks")); slabBlock((SlabBlock) Blocks.ACACIA_SLAB, Blocks.ACACIA_PLANKS.getRegistryName(), mcLoc("block/acacia_planks")); fenceBlock((FenceBlock) Blocks.ACACIA_FENCE, "acacia", mcLoc("block/acacia_planks")); @@ -681,7 +694,7 @@ public class DataGeneratorTest wallBlock((WallBlock) Blocks.COBBLESTONE_WALL, "cobblestone", mcLoc("block/cobblestone")); - paneBlock((PaneBlock) Blocks.GLASS_PANE, "glass", mcLoc("block/glass"), mcLoc("block/glass_pane_top")); + paneBlock((IronBarsBlock) Blocks.GLASS_PANE, "glass", mcLoc("block/glass"), mcLoc("block/glass_pane_top")); doorBlock((DoorBlock) Blocks.ACACIA_DOOR, "acacia", mcLoc("block/acacia_door_bottom"), mcLoc("block/acacia_door_top")); trapdoorBlock((TrapDoorBlock) Blocks.ACACIA_TRAPDOOR, "acacia", mcLoc("block/acacia_trapdoor"), true); @@ -705,7 +718,7 @@ public class DataGeneratorTest private List errors = new ArrayList<>(); @Override - public void run(DirectoryCache cache) throws IOException + public void run(HashCache cache) throws IOException { super.run(cache); this.errors.addAll(testModelResults(models().generatedModels, models().existingFileHelper, Sets.union(IGNORED_MODELS, CUSTOM_MODELS))); @@ -713,7 +726,7 @@ public class DataGeneratorTest if (IGNORED_BLOCKS.contains(block)) return; JsonObject generated = state.toJson(); try { - IResource vanillaResource = models().existingFileHelper.getResource(block.getRegistryName(), ResourcePackType.CLIENT_RESOURCES, ".json", "blockstates"); + Resource vanillaResource = models().existingFileHelper.getResource(block.getRegistryName(), PackType.CLIENT_RESOURCES, ".json", "blockstates"); JsonObject existing = GSON.fromJson(new InputStreamReader(vanillaResource.getInputStream()), JsonObject.class); if (state instanceof VariantBlockStateBuilder) { compareVariantBlockstates(block, generated, existing); @@ -891,7 +904,7 @@ public class DataGeneratorTest generated.addProperty("parent", toVanillaModel(generated.get("parent").getAsString())); } try { - IResource vanillaResource = existingFileHelper.getResource(new ResourceLocation(loc.getPath()), ResourcePackType.CLIENT_RESOURCES, ".json", "models"); + Resource vanillaResource = existingFileHelper.getResource(new ResourceLocation(loc.getPath()), PackType.CLIENT_RESOURCES, ".json", "models"); JsonObject existing = GSON.fromJson(new InputStreamReader(vanillaResource.getInputStream()), JsonObject.class); JsonElement generatedDisplay = generated.remove("display"); @@ -903,8 +916,8 @@ public class DataGeneratorTest ret.add("Model " + loc + " has transforms when vanilla equivalent does not"); return; } else if (generatedDisplay != null) { // Both must be non-null - ItemCameraTransforms generatedTransforms = GSON.fromJson(generatedDisplay, ItemCameraTransforms.class); - ItemCameraTransforms vanillaTransforms = GSON.fromJson(vanillaDisplay, ItemCameraTransforms.class); + ItemTransforms generatedTransforms = GSON.fromJson(generatedDisplay, ItemTransforms.class); + ItemTransforms vanillaTransforms = GSON.fromJson(vanillaDisplay, ItemTransforms.class); for (Perspective type : Perspective.values()) { if (!generatedTransforms.getTransform(type.vanillaType).equals(vanillaTransforms.getTransform(type.vanillaType))) { ret.add("Model " + loc + " has transforms that differ from vanilla equivalent for perspective " + type.name()); diff --git a/src/test/java/net/minecraftforge/debug/DeferredRegistryTest.java b/src/test/java/net/minecraftforge/debug/DeferredRegistryTest.java index dd97ca0e7d..82add731f5 100644 --- a/src/test/java/net/minecraftforge/debug/DeferredRegistryTest.java +++ b/src/test/java/net/minecraftforge/debug/DeferredRegistryTest.java @@ -24,19 +24,18 @@ import java.util.function.Supplier; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.material.Material; import net.minecraft.data.DataGenerator; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; -import net.minecraft.util.ResourceLocation; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.CreativeModeTab; import net.minecraftforge.client.model.generators.BlockStateProvider; import net.minecraftforge.client.model.generators.ModelFile; import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fml.RegistryObject; +import net.minecraftforge.fmllegacy.RegistryObject; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.event.lifecycle.GatherDataEvent; +import net.minecraftforge.forge.event.lifecycle.GatherDataEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; @@ -55,7 +54,7 @@ public class DeferredRegistryTest { private static final DeferredRegister CUSTOMS = DeferredRegister.create(Custom.class, MODID); private static final RegistryObject BLOCK = BLOCKS.register("test", () -> new Block(Block.Properties.of(Material.STONE))); - private static final RegistryObject ITEM = ITEMS .register("test", () -> new BlockItem(BLOCK.get(), new Item.Properties().tab(ItemGroup.TAB_BUILDING_BLOCKS))); + private static final RegistryObject ITEM = ITEMS .register("test", () -> new BlockItem(BLOCK.get(), new Item.Properties().tab(CreativeModeTab.TAB_BUILDING_BLOCKS))); private static final RegistryObject CUSTOM = CUSTOMS.register("test", () -> new Custom(){}); private static final Supplier> CUSTOM_REG = CUSTOMS.makeRegistry("test_registry", () -> diff --git a/src/test/java/net/minecraftforge/debug/PotionEventTest.java b/src/test/java/net/minecraftforge/debug/PotionEventTest.java index ba3dd5c505..9a6d83c0b3 100644 --- a/src/test/java/net/minecraftforge/debug/PotionEventTest.java +++ b/src/test/java/net/minecraftforge/debug/PotionEventTest.java @@ -22,9 +22,9 @@ package net.minecraftforge.debug; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.item.crafting.Ingredient; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.crafting.Ingredient; import net.minecraftforge.common.brewing.BrewingRecipeRegistry; import net.minecraftforge.event.entity.living.PotionEvent; import net.minecraftforge.eventbus.api.Event.Result; diff --git a/src/test/java/net/minecraftforge/debug/block/BasePlaceEventTest.java b/src/test/java/net/minecraftforge/debug/block/BasePlaceEventTest.java index 1836ed372c..6c004467a3 100644 --- a/src/test/java/net/minecraftforge/debug/block/BasePlaceEventTest.java +++ b/src/test/java/net/minecraftforge/debug/block/BasePlaceEventTest.java @@ -19,7 +19,7 @@ package net.minecraftforge.debug.block; -import net.minecraft.entity.item.FallingBlockEntity; +import net.minecraft.world.entity.item.FallingBlockEntity; import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; diff --git a/src/test/java/net/minecraftforge/debug/block/CustomPlantTypeTest.java b/src/test/java/net/minecraftforge/debug/block/CustomPlantTypeTest.java index ef0ac67c3a..1615f9d6c0 100644 --- a/src/test/java/net/minecraftforge/debug/block/CustomPlantTypeTest.java +++ b/src/test/java/net/minecraftforge/debug/block/CustomPlantTypeTest.java @@ -19,18 +19,18 @@ package net.minecraftforge.debug.block; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.FlowerBlock; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; -import net.minecraft.potion.Effects; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorldReader; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.FlowerBlock; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.effect.MobEffects; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelReader; import net.minecraftforge.common.IPlantable; import net.minecraftforge.common.PlantType; import net.minecraftforge.event.RegistryEvent; @@ -69,12 +69,12 @@ public class CustomPlantTypeTest { public CustomBlock() { - super(Block.Properties.of(Material.STONE)); + super(Properties.of(Material.STONE)); this.setRegistryName(MODID, CUSTOM_SOIL_BLOCK); } @Override - public boolean canSustainPlant(BlockState state, IBlockReader world, BlockPos pos, Direction facing, IPlantable plantable) + public boolean canSustainPlant(BlockState state, BlockGetter world, BlockPos pos, Direction facing, IPlantable plantable) { PlantType type = plantable.getPlantType(world, pos.relative(facing)); if (type != null && type == CustomPlantBlock.pt) @@ -91,31 +91,31 @@ public class CustomPlantTypeTest public CustomPlantBlock() { - super(Effects.WEAKNESS, 9, Block.Properties.of(Material.PLANT).noCollission().sound(SoundType.GRASS)); + super(MobEffects.WEAKNESS, 9, Properties.of(Material.PLANT).noCollission().sound(SoundType.GRASS)); this.setRegistryName(MODID, CUSTOM_PLANT_BLOCK); } @Override - public PlantType getPlantType(IBlockReader world, BlockPos pos) + public PlantType getPlantType(BlockGetter world, BlockPos pos) { return pt; } @Override - public BlockState getPlant(IBlockReader world, BlockPos pos) + public BlockState getPlant(BlockGetter world, BlockPos pos) { return defaultBlockState(); } @Override - public boolean canSurvive(BlockState state, IWorldReader world, BlockPos pos) + public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { BlockState soil = world.getBlockState(pos.below()); return soil.canSustainPlant(world, pos, Direction.UP, this); } @Override - public boolean mayPlaceOn(BlockState state, IBlockReader worldIn, BlockPos pos) + public boolean mayPlaceOn(BlockState state, BlockGetter worldIn, BlockPos pos) { Block block = state.getBlock(); return block == CUSTOM_SOIL; diff --git a/src/test/java/net/minecraftforge/debug/block/CustomRespawnTest.java b/src/test/java/net/minecraftforge/debug/block/CustomRespawnTest.java index 317d210b77..a8a18d0a57 100644 --- a/src/test/java/net/minecraftforge/debug/block/CustomRespawnTest.java +++ b/src/test/java/net/minecraftforge/debug/block/CustomRespawnTest.java @@ -19,34 +19,33 @@ package net.minecraftforge.debug.block; -import java.util.Optional; - -import javax.annotation.Nullable; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.RespawnAnchorBlock; -import net.minecraft.block.material.Material; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.IWorldReader; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.RespawnAnchorBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fml.RegistryObject; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.fmllegacy.RegistryObject; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; +import javax.annotation.Nullable; +import java.util.Optional; + @Mod(CustomRespawnTest.MODID) public class CustomRespawnTest { @@ -78,17 +77,17 @@ public class CustomRespawnTest } @Override - public ActionResultType use(BlockState p_225533_1_, World world, BlockPos pos, PlayerEntity p_225533_4_, Hand p_225533_5_, BlockRayTraceResult p_225533_6_) + public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult blockHitResult) { - if (!world.isClientSide && p_225533_4_ instanceof ServerPlayerEntity) + if (!world.isClientSide && player instanceof ServerPlayer serverPlayer) { - ((ServerPlayerEntity)p_225533_4_).setRespawnPosition(world.dimension(), pos, 0, false, true); + serverPlayer.setRespawnPosition(world.dimension(), pos, 0, false, true); } - return ActionResultType.sidedSuccess(world.isClientSide); + return InteractionResult.sidedSuccess(world.isClientSide); } @Override - public Optional getRespawnPosition(BlockState state, EntityType type, IWorldReader world, BlockPos pos, float orientation, @Nullable LivingEntity entity) + public Optional getRespawnPosition(BlockState state, EntityType type, LevelReader world, BlockPos pos, float orientation, @Nullable LivingEntity entity) { return RespawnAnchorBlock.findStandUpPosition(type, world, pos); } diff --git a/src/test/java/net/minecraftforge/debug/block/CustomSignsTest.java b/src/test/java/net/minecraftforge/debug/block/CustomSignsTest.java index 17ec9bace5..aca2896d08 100644 --- a/src/test/java/net/minecraftforge/debug/block/CustomSignsTest.java +++ b/src/test/java/net/minecraftforge/debug/block/CustomSignsTest.java @@ -19,21 +19,20 @@ package net.minecraftforge.debug.block; -import net.minecraft.block.*; -import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.Atlases; -import net.minecraft.client.renderer.tileentity.SignTileEntityRenderer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; -import net.minecraft.item.SignItem; -import net.minecraft.tileentity.SignTileEntity; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.IBlockReader; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderers; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.material.Material; +import net.minecraft.client.renderer.Sheets; +import net.minecraft.client.renderer.blockentity.SignRenderer; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.SignItem; +import net.minecraft.world.level.block.entity.SignBlockEntity; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fml.RegistryObject; -import net.minecraftforge.fml.client.registry.ClientRegistry; +import net.minecraftforge.fmllegacy.RegistryObject; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; @@ -41,23 +40,31 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.StandingSignBlock; +import net.minecraft.world.level.block.WallSignBlock; +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.WoodType; + @Mod(CustomSignsTest.MODID) public class CustomSignsTest { - public static final boolean ENABLE = true; + public static final boolean ENABLE = false; // TODO fix public static final String MODID = "custom_signs_test"; public static final WoodType TEST_WOOD_TYPE = WoodType.create(new ResourceLocation(MODID, "test").toString()); private static final DeferredRegister BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID); - public static final RegistryObject TEST_STANDING_SIGN = BLOCKS.register("test_sign", () -> new CustomStandingSignBlock(Block.Properties.of(Material.WOOD).noCollission().strength(1.0F).sound(SoundType.WOOD), CustomSignsTest.TEST_WOOD_TYPE)); - public static final RegistryObject TEST_WALL_SIGN = BLOCKS.register("test_wall_sign", () -> new CustomWallSignBlock(Block.Properties.of(Material.WOOD).noCollission().strength(1.0F).sound(SoundType.WOOD), CustomSignsTest.TEST_WOOD_TYPE)); + public static final RegistryObject TEST_STANDING_SIGN = BLOCKS.register("test_sign", () -> new CustomStandingSignBlock(Properties.of(Material.WOOD).noCollission().strength(1.0F).sound(SoundType.WOOD), CustomSignsTest.TEST_WOOD_TYPE)); + public static final RegistryObject TEST_WALL_SIGN = BLOCKS.register("test_wall_sign", () -> new CustomWallSignBlock(Properties.of(Material.WOOD).noCollission().strength(1.0F).sound(SoundType.WOOD), CustomSignsTest.TEST_WOOD_TYPE)); private static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID); - public static final RegistryObject TEST_SIGN = ITEMS.register("test_sign", () -> new SignItem((new Item.Properties()).stacksTo(16).tab(ItemGroup.TAB_DECORATIONS), TEST_STANDING_SIGN.get(), TEST_WALL_SIGN.get())); + public static final RegistryObject TEST_SIGN = ITEMS.register("test_sign", () -> new SignItem((new Item.Properties()).stacksTo(16).tab(CreativeModeTab.TAB_DECORATIONS), TEST_STANDING_SIGN.get(), TEST_WALL_SIGN.get())); - private static final DeferredRegister> TILE_ENTITIES = DeferredRegister.create(ForgeRegistries.TILE_ENTITIES, MODID); - public static final RegistryObject> CUSTOM_SIGN = TILE_ENTITIES.register("custom_sign", () -> TileEntityType.Builder.of(CustomSignTileEntity::new, TEST_WALL_SIGN.get(), TEST_STANDING_SIGN.get()).build(null)); + private static final DeferredRegister> BLOCK_ENTITIES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITIES, MODID); + public static final RegistryObject> CUSTOM_SIGN = BLOCK_ENTITIES.register("custom_sign", () -> BlockEntityType.Builder.of(CustomSignBlockEntity::new, TEST_WALL_SIGN.get(), TEST_STANDING_SIGN.get()).build(null)); public CustomSignsTest() { @@ -66,7 +73,7 @@ public class CustomSignsTest final IEventBus eventBus = FMLJavaModLoadingContext.get().getModEventBus(); BLOCKS.register(eventBus); ITEMS.register(eventBus); - TILE_ENTITIES.register(eventBus); + BLOCK_ENTITIES.register(eventBus); eventBus.addListener(this::clientSetup); eventBus.addListener(this::commonSetup); @@ -75,9 +82,9 @@ public class CustomSignsTest private void clientSetup(final FMLClientSetupEvent event) { - ClientRegistry.bindTileEntityRenderer(CUSTOM_SIGN.get(), SignTileEntityRenderer::new); + BlockEntityRenderers.register(CUSTOM_SIGN.get(), SignRenderer::new); event.enqueueWork(() -> { - Atlases.addWoodType(TEST_WOOD_TYPE); + Sheets.addWoodType(TEST_WOOD_TYPE); }); } @@ -95,15 +102,9 @@ public class CustomSignsTest } @Override - public boolean hasTileEntity(BlockState stateIn) + public BlockEntity newBlockEntity(BlockPos pos, BlockState state) { - return true; - } - - @Override - public TileEntity newBlockEntity(IBlockReader worldIn) - { - return new CustomSignTileEntity(); + return new CustomSignBlockEntity(pos, state); } } @@ -116,22 +117,20 @@ public class CustomSignsTest } @Override - public boolean hasTileEntity(BlockState stateIn) + public BlockEntity newBlockEntity(BlockPos pos, BlockState state) { - return true; - } - - @Override - public TileEntity newBlockEntity(IBlockReader worldIn) - { - return new CustomSignTileEntity(); + return new CustomSignBlockEntity(pos, state); } } - public static class CustomSignTileEntity extends SignTileEntity + public static class CustomSignBlockEntity extends SignBlockEntity { + public CustomSignBlockEntity(BlockPos pos, BlockState state) { + super(pos, state); + } + @Override - public TileEntityType getType() + public BlockEntityType getType() { return CUSTOM_SIGN.get(); } diff --git a/src/test/java/net/minecraftforge/debug/block/FlowerPotTest.java b/src/test/java/net/minecraftforge/debug/block/FlowerPotTest.java index ca21ce940c..cfaf2f38e9 100644 --- a/src/test/java/net/minecraftforge/debug/block/FlowerPotTest.java +++ b/src/test/java/net/minecraftforge/debug/block/FlowerPotTest.java @@ -19,15 +19,15 @@ package net.minecraftforge.debug.block; -import net.minecraft.block.Block; -import net.minecraft.block.Blocks; -import net.minecraft.block.FlowerPotBlock; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.FlowerPotBlock; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.Item; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.RegistryObject; +import net.minecraftforge.fmllegacy.RegistryObject; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; diff --git a/src/test/java/net/minecraftforge/debug/block/HarvestToolTest.java b/src/test/java/net/minecraftforge/debug/block/HarvestToolTest.java index c8bff32cb5..259c2f1ac2 100644 --- a/src/test/java/net/minecraftforge/debug/block/HarvestToolTest.java +++ b/src/test/java/net/minecraftforge/debug/block/HarvestToolTest.java @@ -19,9 +19,9 @@ package net.minecraftforge.debug.block; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.util.text.StringTextComponent; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.network.chat.TextComponent; import net.minecraftforge.common.ToolType; import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -34,11 +34,11 @@ public class HarvestToolTest @SubscribeEvent public static void onBlockBreak(BlockEvent.BreakEvent event) { - PlayerEntity player = event.getPlayer(); + Player player = event.getPlayer(); BlockState state = event.getState(); for (ToolType toolType : player.getMainHandItem().getToolTypes()) { if (state.isToolEffective(toolType)) { - player.sendMessage(new StringTextComponent(String.format("Tool was effective. tool type: %s | harvest level: %d", toolType.getName(), state.getHarvestLevel())), player.getUUID()); + player.sendMessage(new TextComponent(String.format("Tool was effective. tool type: %s | harvest level: %d", toolType.getName(), state.getHarvestLevel())), player.getUUID()); break; } } diff --git a/src/test/java/net/minecraftforge/debug/block/NeighborNotifyEventTest.java b/src/test/java/net/minecraftforge/debug/block/NeighborNotifyEventTest.java index 3b7951d3f7..a54c11d148 100644 --- a/src/test/java/net/minecraftforge/debug/block/NeighborNotifyEventTest.java +++ b/src/test/java/net/minecraftforge/debug/block/NeighborNotifyEventTest.java @@ -19,7 +19,7 @@ package net.minecraftforge.debug.block; -import net.minecraft.block.Blocks; +import net.minecraft.world.level.block.Blocks; import net.minecraftforge.event.world.BlockEvent.NeighborNotifyEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.eventbus.api.SubscribeEvent; diff --git a/src/test/java/net/minecraftforge/debug/block/PistonEventTest.java b/src/test/java/net/minecraftforge/debug/block/PistonEventTest.java index aa6c94d98c..027c3d8460 100644 --- a/src/test/java/net/minecraftforge/debug/block/PistonEventTest.java +++ b/src/test/java/net/minecraftforge/debug/block/PistonEventTest.java @@ -21,22 +21,22 @@ package net.minecraftforge.debug.block; import java.util.List; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.PistonBlock; -import net.minecraft.block.PistonBlockStructureHelper; -import net.minecraft.block.material.Material; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.piston.PistonBaseBlock; +import net.minecraft.world.level.block.piston.PistonStructureResolver; +import net.minecraft.world.level.material.Material; import net.minecraft.client.Minecraft; import net.minecraft.data.DataGenerator; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.world.World; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.model.generators.BlockStateProvider; import net.minecraftforge.client.model.generators.ModelFile; @@ -46,9 +46,9 @@ import net.minecraftforge.event.world.PistonEvent.PistonMoveType; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.DistExecutor; -import net.minecraftforge.fml.RegistryObject; +import net.minecraftforge.fmllegacy.RegistryObject; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.event.lifecycle.GatherDataEvent; +import net.minecraftforge.forge.event.lifecycle.GatherDataEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; @@ -70,7 +70,7 @@ public class PistonEventTest private static RegistryObject shiftOnMove = BLOCKS.register(blockName, () -> new Block(Block.Properties.of(Material.STONE))); static { - ITEMS.register(blockName, () -> new BlockItem(shiftOnMove.get(), new Item.Properties().tab(ItemGroup.TAB_BUILDING_BLOCKS))); + ITEMS.register(blockName, () -> new BlockItem(shiftOnMove.get(), new Item.Properties().tab(CreativeModeTab.TAB_BUILDING_BLOCKS))); } public PistonEventTest() @@ -86,18 +86,18 @@ public class PistonEventTest { if (event.getPistonMoveType() == PistonMoveType.EXTEND) { - World world = (World) event.getWorld(); - PistonBlockStructureHelper pistonHelper = event.getStructureHelper(); - PlayerEntity player = DistExecutor.safeCallWhenOn(Dist.CLIENT, () -> () -> Minecraft.getInstance().player); + Level world = (Level) event.getWorld(); + PistonStructureResolver pistonHelper = event.getStructureHelper(); + Player player = DistExecutor.safeCallWhenOn(Dist.CLIENT, () -> () -> Minecraft.getInstance().player); if (world.isClientSide && player != null) { if (pistonHelper.resolve()) { - player.sendMessage(new StringTextComponent(String.format("Piston will extend moving %d blocks and destroy %d blocks", pistonHelper.getToPush().size(), pistonHelper.getToDestroy().size())), player.getUUID()); + player.sendMessage(new TextComponent(String.format("Piston will extend moving %d blocks and destroy %d blocks", pistonHelper.getToPush().size(), pistonHelper.getToDestroy().size())), player.getUUID()); } else { - player.sendMessage(new StringTextComponent("Piston won't extend"), player.getUUID()); + player.sendMessage(new TextComponent("Piston won't extend"), player.getUUID()); } } @@ -130,19 +130,19 @@ public class PistonEventTest { boolean isSticky = event.getWorld().getBlockState(event.getPos()).getBlock() == Blocks.STICKY_PISTON; - PlayerEntity player = DistExecutor.safeCallWhenOn(Dist.CLIENT, () -> () -> Minecraft.getInstance().player); + Player player = DistExecutor.safeCallWhenOn(Dist.CLIENT, () -> () -> Minecraft.getInstance().player); if (event.getWorld().isClientSide() && player != null) { if (isSticky) { BlockPos targetPos = event.getFaceOffsetPos().relative(event.getDirection()); - boolean canPush = PistonBlock.isPushable(event.getWorld().getBlockState(targetPos), (World) event.getWorld(), event.getFaceOffsetPos(), event.getDirection().getOpposite(), false, event.getDirection()); + boolean canPush = PistonBaseBlock.isPushable(event.getWorld().getBlockState(targetPos), (Level) event.getWorld(), event.getFaceOffsetPos(), event.getDirection().getOpposite(), false, event.getDirection()); boolean isAir = event.getWorld().isEmptyBlock(targetPos); - player.sendMessage(new StringTextComponent(String.format("Piston will retract moving %d blocks", !isAir && canPush ? 1 : 0)), player.getUUID()); + player.sendMessage(new TextComponent(String.format("Piston will retract moving %d blocks", !isAir && canPush ? 1 : 0)), player.getUUID()); } else { - player.sendMessage(new StringTextComponent("Piston will retract"), player.getUUID()); + player.sendMessage(new TextComponent("Piston will retract"), player.getUUID()); } } // Offset twice to see if retraction will pull cobblestone diff --git a/src/test/java/net/minecraftforge/debug/block/PlaceEventTest.java b/src/test/java/net/minecraftforge/debug/block/PlaceEventTest.java index 2b5557fdcb..447ff341a2 100644 --- a/src/test/java/net/minecraftforge/debug/block/PlaceEventTest.java +++ b/src/test/java/net/minecraftforge/debug/block/PlaceEventTest.java @@ -19,7 +19,7 @@ package net.minecraftforge.debug.block; -import net.minecraft.block.Blocks; +import net.minecraft.world.level.block.Blocks; import net.minecraftforge.event.world.BlockEvent.EntityPlaceEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; diff --git a/src/test/java/net/minecraftforge/debug/block/ScaffoldingTest.java b/src/test/java/net/minecraftforge/debug/block/ScaffoldingTest.java index f7bd4028d3..bfe02ec9b8 100644 --- a/src/test/java/net/minecraftforge/debug/block/ScaffoldingTest.java +++ b/src/test/java/net/minecraftforge/debug/block/ScaffoldingTest.java @@ -19,33 +19,32 @@ package net.minecraftforge.debug.block; -import net.minecraft.block.AbstractBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.ScaffoldingBlock; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.material.MaterialColor; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.ScaffoldingBlock; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.material.MaterialColor; import net.minecraft.data.DataGenerator; -import net.minecraft.entity.LivingEntity; +import net.minecraft.world.entity.LivingEntity; import net.minecraft.tags.BlockTags; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IWorldReader; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.LevelReader; import net.minecraftforge.client.model.generators.BlockStateProvider; import net.minecraftforge.client.model.generators.ConfiguredModel; import net.minecraftforge.client.model.generators.ModelFile; import net.minecraftforge.common.Tags.IOptionalNamedTag; import net.minecraftforge.common.data.ExistingFileHelper; import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fml.RegistryObject; +import net.minecraftforge.fmllegacy.RegistryObject; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.event.lifecycle.GatherDataEvent; +import net.minecraftforge.forge.event.lifecycle.GatherDataEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; -import net.minecraft.block.AbstractBlock.Properties; +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; /** * This test mod allows a custom scaffolding to move down @@ -58,7 +57,7 @@ public class ScaffoldingTest static final DeferredRegister BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID); static final IOptionalNamedTag SCAFFOLDING = BlockTags.createOptional(new ResourceLocation("forge", "scaffolding")); - static final RegistryObject SCAFFOLDING_METHOD_TEST = BLOCKS.register("scaffolding_method_test", () -> new ScaffoldingMethodTestBlock(AbstractBlock.Properties.of(Material.DECORATION, MaterialColor.SAND).noCollission().sound(SoundType.SCAFFOLDING).dynamicShape())); + static final RegistryObject SCAFFOLDING_METHOD_TEST = BLOCKS.register("scaffolding_method_test", () -> new ScaffoldingMethodTestBlock(Properties.of(Material.DECORATION, MaterialColor.SAND).noCollission().sound(SoundType.SCAFFOLDING).dynamicShape())); public ScaffoldingTest() { @@ -96,7 +95,7 @@ public class ScaffoldingTest } @Override - public boolean isScaffolding(BlockState state, IWorldReader world, BlockPos pos, LivingEntity entity) + public boolean isScaffolding(BlockState state, LevelReader world, BlockPos pos, LivingEntity entity) { return true; } diff --git a/src/test/java/net/minecraftforge/debug/block/SlipperinessTest.java b/src/test/java/net/minecraftforge/debug/block/SlipperinessTest.java index 39e3a11659..d181f47fba 100644 --- a/src/test/java/net/minecraftforge/debug/block/SlipperinessTest.java +++ b/src/test/java/net/minecraftforge/debug/block/SlipperinessTest.java @@ -19,15 +19,15 @@ package net.minecraftforge.debug.block; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.material.Material; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.BoatEntity; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IWorldReader; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.vehicle.Boat; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.Item; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.LevelReader; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; @@ -50,9 +50,9 @@ public class SlipperinessTest e.getRegistry().register((new Block(Block.Properties.of(Material.ICE_SOLID)) { @Override - public float getSlipperiness(BlockState state, IWorldReader world, BlockPos pos, Entity entity) + public float getFriction(BlockState state, LevelReader world, BlockPos pos, Entity entity) { - return entity instanceof BoatEntity ? 2 : super.getSlipperiness(state, world, pos, entity); + return entity instanceof Boat ? 2 : super.getFriction(state, world, pos, entity); } }).setRegistryName(MOD_ID, BLOCK_ID)); } diff --git a/src/test/java/net/minecraftforge/debug/block/StickyBlockTest.java b/src/test/java/net/minecraftforge/debug/block/StickyBlockTest.java index a572c07e15..0d66fe9b5e 100644 --- a/src/test/java/net/minecraftforge/debug/block/StickyBlockTest.java +++ b/src/test/java/net/minecraftforge/debug/block/StickyBlockTest.java @@ -19,11 +19,11 @@ package net.minecraftforge.debug.block; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.material.Material; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.Item; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; diff --git a/src/test/java/net/minecraftforge/debug/block/package-info.java b/src/test/java/net/minecraftforge/debug/block/package-info.java index d7889f633f..daf554e426 100644 --- a/src/test/java/net/minecraftforge/debug/block/package-info.java +++ b/src/test/java/net/minecraftforge/debug/block/package-info.java @@ -22,4 +22,4 @@ package net.minecraftforge.debug.block; import javax.annotation.ParametersAreNonnullByDefault; -import mcp.MethodsReturnNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; diff --git a/src/test/java/net/minecraftforge/debug/chat/CommandEventTest.java b/src/test/java/net/minecraftforge/debug/chat/CommandEventTest.java index 57a368bc6f..174ca661f2 100644 --- a/src/test/java/net/minecraftforge/debug/chat/CommandEventTest.java +++ b/src/test/java/net/minecraftforge/debug/chat/CommandEventTest.java @@ -21,9 +21,9 @@ package net.minecraftforge.debug.chat; import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.context.ParsedCommandNode; -import net.minecraft.command.CommandException; -import net.minecraft.command.CommandSource; -import net.minecraft.util.text.StringTextComponent; +import net.minecraft.commands.CommandRuntimeException; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.network.chat.TextComponent; import net.minecraftforge.event.CommandEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; @@ -41,9 +41,9 @@ public class CommandEventTest @SubscribeEvent public static void onCommand(CommandEvent event) { - CommandDispatcher dispatcher = event.getParseResults().getContext().getDispatcher(); - List> nodes = event.getParseResults().getContext().getNodes(); - CommandSource source = event.getParseResults().getContext().getSource(); + CommandDispatcher dispatcher = event.getParseResults().getContext().getDispatcher(); + List> nodes = event.getParseResults().getContext().getNodes(); + CommandSourceStack source = event.getParseResults().getContext().getSource(); // test: when the /time command is used with no arguments, automatically add default arguments (/time set day) if (nodes.size() == 1 && nodes.get(0).getNode() == dispatcher.getRoot().getChild("time")) @@ -56,17 +56,18 @@ public class CommandEventTest if (nodes.size() > 0 && nodes.get(0).getNode() == dispatcher.getRoot().getChild("give")) { String msg = source.getTextName() + " used the give command: " + event.getParseResults().getReader().getString(); - source.getServer().getPlayerList().getPlayers().forEach(player -> player.sendMessage(new StringTextComponent(msg), player.getUUID())); + source.getServer().getPlayerList().getPlayers().forEach(player -> player.sendMessage(new TextComponent(msg), player.getUUID())); return; } + // this is annoying so I disabled it // test: when the /kill command is used with no arguments, throw a custom exception - if (nodes.size() == 1 && nodes.get(0).getNode() == dispatcher.getRoot().getChild("kill")) - { - event.setException(new CommandException(new StringTextComponent("You tried to use the /kill command with no arguments"))); - event.setCanceled(true); - return; - } + // if (nodes.size() == 1 && nodes.get(0).getNode() == dispatcher.getRoot().getChild("kill")) + // { + // event.setException(new CommandRuntimeException(new TextComponent("You tried to use the /kill command with no arguments"))); + // event.setCanceled(true); + // return; + // } } } diff --git a/src/test/java/net/minecraftforge/debug/chat/EntitySelectorTest.java b/src/test/java/net/minecraftforge/debug/chat/EntitySelectorTest.java index e108de3a37..b103a639fb 100644 --- a/src/test/java/net/minecraftforge/debug/chat/EntitySelectorTest.java +++ b/src/test/java/net/minecraftforge/debug/chat/EntitySelectorTest.java @@ -20,14 +20,14 @@ package net.minecraftforge.debug.chat; import com.mojang.brigadier.exceptions.CommandSyntaxException; -import net.minecraft.advancements.criterion.MinMaxBounds; -import net.minecraft.command.arguments.EntityOptions; -import net.minecraft.command.arguments.EntitySelector; -import net.minecraft.command.arguments.EntitySelectorParser; -import net.minecraft.entity.Entity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; +import net.minecraft.advancements.critereon.MinMaxBounds; +import net.minecraft.commands.arguments.selector.options.EntitySelectorOptions; +import net.minecraft.commands.arguments.selector.EntitySelector; +import net.minecraft.commands.arguments.selector.EntitySelectorParser; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; import net.minecraftforge.common.command.EntitySelectorManager; import net.minecraftforge.common.command.IEntitySelectorType; import net.minecraftforge.fml.common.Mod; @@ -44,7 +44,7 @@ public class EntitySelectorTest public void setup(FMLCommonSetupEvent event) { - EntityOptions.register("health", this::healthArgument, parser -> true, new StringTextComponent("Selects entities based on their current health.")); + EntitySelectorOptions.register("health", this::healthArgument, parser -> true, new TextComponent("Selects entities based on their current health.")); EntitySelectorManager.register("er", new ExampleCustomSelector()); } @@ -53,7 +53,7 @@ public class EntitySelectorTest */ private void healthArgument(EntitySelectorParser parser) throws CommandSyntaxException { - MinMaxBounds.FloatBound bound = MinMaxBounds.FloatBound.fromReader(parser.getReader()); + MinMaxBounds.Doubles bound = MinMaxBounds.Doubles.fromReader(parser.getReader()); parser.addPredicate(entity -> entity instanceof LivingEntity && bound.matches(((LivingEntity) entity).getHealth())); } @@ -76,7 +76,7 @@ public class EntitySelectorTest parser.getReader().skip(); parser.setSuggestions((builder, consumer) -> { builder.suggest(String.valueOf(']')); - EntityOptions.suggestNames(parser, builder); + EntitySelectorOptions.suggestNames(parser, builder); return builder.buildFuture(); }); @@ -88,9 +88,9 @@ public class EntitySelectorTest } @Override - public ITextComponent getSuggestionTooltip() + public Component getSuggestionTooltip() { - return new StringTextComponent("Example: Selects a random entity"); + return new TextComponent("Example: Selects a random entity"); } } } diff --git a/src/test/java/net/minecraftforge/debug/chat/package-info.java b/src/test/java/net/minecraftforge/debug/chat/package-info.java index f3abed0bef..f7a56b5ed9 100644 --- a/src/test/java/net/minecraftforge/debug/chat/package-info.java +++ b/src/test/java/net/minecraftforge/debug/chat/package-info.java @@ -22,4 +22,4 @@ package net.minecraftforge.debug.chat; import javax.annotation.ParametersAreNonnullByDefault; -import mcp.MethodsReturnNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; diff --git a/src/test/java/net/minecraftforge/debug/client/CustomTASTest.java b/src/test/java/net/minecraftforge/debug/client/CustomTASTest.java index 337262df26..a4df3b878c 100644 --- a/src/test/java/net/minecraftforge/debug/client/CustomTASTest.java +++ b/src/test/java/net/minecraftforge/debug/client/CustomTASTest.java @@ -23,35 +23,35 @@ import java.util.Random; import javax.annotation.Nonnull; -import net.minecraft.client.renderer.texture.AtlasTexture; -import net.minecraft.client.renderer.texture.NativeImage; +import com.mojang.blaze3d.platform.NativeImage; +import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.item.Item; -import net.minecraft.resources.IResource; -import net.minecraft.resources.IResourceManager; -import net.minecraft.util.ResourceLocation; +import net.minecraft.client.renderer.texture.Tickable; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.packs.resources.Resource; +import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.world.item.Item; import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.client.textures.ITextureAtlasSpriteLoader; -import net.minecraftforge.fml.RegistryObject; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.fml.loading.FMLLoader; +import net.minecraftforge.fmllegacy.RegistryObject; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; @Mod(CustomTASTest.MOD_ID) public class CustomTASTest { - - private static final boolean enabled = true; + 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) + if (ENABLED) { if (FMLLoader.getDist().isClient()) { @@ -70,23 +70,21 @@ public class CustomTASTest { @Override @Nonnull - public TextureAtlasSprite load(AtlasTexture atlas, IResourceManager resourceManager, TextureAtlasSprite.Info textureInfo, IResource resource, int atlasWidth, int atlasHeight, int spriteX, int spriteY, int mipmapLevel, NativeImage image) + public TextureAtlasSprite load(TextureAtlas atlas, ResourceManager resourceManager, TextureAtlasSprite.Info textureInfo, Resource resource, int atlasWidth, int atlasHeight, int spriteX, int spriteY, int mipmapLevel, NativeImage image) { return new TextureAtlasSprite( atlas, textureInfo, mipmapLevel, atlasWidth, atlasHeight, spriteX, spriteY, image ) { - private final Random random = new Random(); @Override - public boolean isAnimation() + public Tickable getAnimationTicker() { - return true; + return this::tick; } - @Override - public void cycleFrames() + private void tick() { this.mainImage[0].fillRect(0, 0, 16, 16, 0xFF000000 | random.nextInt(0xFFFFFF)); this.uploadFirstFrame(); diff --git a/src/test/java/net/minecraftforge/debug/client/OverlayLayersTest.java b/src/test/java/net/minecraftforge/debug/client/OverlayLayersTest.java new file mode 100644 index 0000000000..7132f4a38a --- /dev/null +++ b/src/test/java/net/minecraftforge/debug/client/OverlayLayersTest.java @@ -0,0 +1,104 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.debug.client; + +import net.minecraft.client.Minecraft; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.client.event.InputEvent; +import net.minecraftforge.client.event.RenderGameOverlayEvent; +import net.minecraftforge.client.gui.OverlayRegistry; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.loading.FMLEnvironment; +import org.lwjgl.glfw.GLFW; + +import java.util.List; + +@Mod("overlay_layers_test") +public class OverlayLayersTest +{ + public static final boolean ENABLE = true; + private boolean visible = false; + + public OverlayLayersTest() + { + if (ENABLE && FMLEnvironment.dist == Dist.CLIENT) + { + MinecraftForge.EVENT_BUS.addListener(this::renderTextEvent); + MinecraftForge.EVENT_BUS.addListener(this::keyInputEvent); + } + } + + int overlayIndex = 0; + + public void renderTextEvent(RenderGameOverlayEvent.Text event) + { + if (event.getType() != RenderGameOverlayEvent.ElementType.TEXT || !visible) + return; + + List overlays = OverlayRegistry.orderedEntries(); + for(int i=0;i %s [%s] <" : " %s [%s] ", entry.getDisplayName(), entry.isEnabled())); + } + } + + public void keyInputEvent(InputEvent.KeyInputEvent event) + { + if (event.getAction() != GLFW.GLFW_PRESS || Minecraft.getInstance().level == null || Minecraft.getInstance().screen != null) + return; + + if (event.getKey() == GLFW.GLFW_KEY_H) + { + visible = !visible; + return; + } + if (!visible) + return; + if (event.getKey() == GLFW.GLFW_KEY_J) + { + List overlays = OverlayRegistry.orderedEntries(); + if (overlayIndex >= overlays.size()) + overlayIndex = 0; + else + overlayIndex = (overlayIndex + overlays.size() - 1) % overlays.size(); + } + else if (event.getKey() == GLFW.GLFW_KEY_K) + { + List overlays = OverlayRegistry.orderedEntries(); + if (overlayIndex >= overlays.size()) + overlayIndex = 0; + else + overlayIndex = (overlayIndex + 1) % overlays.size(); + } + else if (event.getKey() == GLFW.GLFW_KEY_I) + { + List overlays = OverlayRegistry.orderedEntries(); + if (overlayIndex >= overlays.size()) + overlayIndex = 0; + else + { + OverlayRegistry.OverlayEntry entry = overlays.get(overlayIndex); + OverlayRegistry.enableOverlay(entry.getOverlay(), !entry.isEnabled()); + } + } + } +} diff --git a/src/test/java/net/minecraftforge/debug/client/model/CompositeModelTest.java b/src/test/java/net/minecraftforge/debug/client/model/CompositeModelTest.java index ff7659a043..1a968923f3 100644 --- a/src/test/java/net/minecraftforge/debug/client/model/CompositeModelTest.java +++ b/src/test/java/net/minecraftforge/debug/client/model/CompositeModelTest.java @@ -19,25 +19,25 @@ package net.minecraftforge.debug.client.model; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.material.Material; -import net.minecraft.entity.Entity; -import net.minecraft.inventory.EquipmentSlotType; -import net.minecraft.item.BlockItem; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; -import net.minecraft.item.ItemStack; -import net.minecraft.state.StateContainer; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.shapes.VoxelShapes; -import net.minecraft.world.IBlockReader; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.phys.shapes.Shapes; +import net.minecraft.world.level.BlockGetter; import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fml.RegistryObject; +import net.minecraftforge.fmllegacy.RegistryObject; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.DeferredRegister; @@ -55,14 +55,14 @@ public class CompositeModelTest public static RegistryObject composite_block = BLOCKS.register("composite_block", () -> new Block(Block.Properties.of(Material.WOOD).strength(10)) { @Override - protected void createBlockStateDefinition(StateContainer.Builder builder) + protected void createBlockStateDefinition(StateDefinition.Builder builder) { builder.add(BlockStateProperties.HORIZONTAL_FACING); } @Nullable @Override - public BlockState getStateForPlacement(BlockItemUseContext context) + public BlockState getStateForPlacement(BlockPlaceContext context) { return defaultBlockState().setValue( BlockStateProperties.HORIZONTAL_FACING, context.getHorizontalDirection() @@ -70,8 +70,8 @@ public class CompositeModelTest } @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { - return VoxelShapes.or( + public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) { + return Shapes.or( box(5.6, 5.6, 5.6, 10.4, 10.4, 10.4), box(0, 0, 0, 4.8, 4.8, 4.8), box(11.2, 0, 0, 16, 4.8, 4.8), @@ -87,11 +87,11 @@ public class CompositeModelTest ); public static RegistryObject composite_item = ITEMS.register("composite_block", () -> - new BlockItem(composite_block.get(), new Item.Properties().tab(ItemGroup.TAB_MISC)) { + new BlockItem(composite_block.get(), new Item.Properties().tab(CreativeModeTab.TAB_MISC)) { @Override - public boolean canEquip(ItemStack stack, EquipmentSlotType armorType, Entity entity) + public boolean canEquip(ItemStack stack, EquipmentSlot armorType, Entity entity) { - return armorType == EquipmentSlotType.HEAD; + return armorType == EquipmentSlot.HEAD; } } ); diff --git a/src/test/java/net/minecraftforge/debug/client/model/DynBucketModelTest.java b/src/test/java/net/minecraftforge/debug/client/model/DynBucketModelTest.java index feeebb9e19..009640398e 100644 --- a/src/test/java/net/minecraftforge/debug/client/model/DynBucketModelTest.java +++ b/src/test/java/net/minecraftforge/debug/client/model/DynBucketModelTest.java @@ -19,10 +19,10 @@ package net.minecraftforge.debug.client.model; -import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.CreativeModeTab; import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fml.RegistryObject; +import net.minecraftforge.fmllegacy.RegistryObject; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.DeferredRegister; @@ -31,15 +31,19 @@ import net.minecraftforge.registries.ForgeRegistries; @Mod(DynBucketModelTest.MODID) public class DynBucketModelTest { + public static final boolean ENABLE = false; // TODO fix public static final String MODID = "dyn_bucket_model_test"; public static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID); - public static final RegistryObject DRIP_BUCKET = ITEMS.register("drip_bucket", () -> new Item(new Item.Properties().tab(ItemGroup.TAB_MISC))); - public static final RegistryObject LAVA_OBSIDIAN = ITEMS.register("lava_obsidian", () -> new Item(new Item.Properties().tab(ItemGroup.TAB_MISC))); + public static final RegistryObject DRIP_BUCKET = ITEMS.register("drip_bucket", () -> new Item(new Item.Properties().tab(CreativeModeTab.TAB_MISC))); + public static final RegistryObject LAVA_OBSIDIAN = ITEMS.register("lava_obsidian", () -> new Item(new Item.Properties().tab(CreativeModeTab.TAB_MISC))); public DynBucketModelTest() { - IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); - ITEMS.register(modEventBus); + if (ENABLE) + { + IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); + ITEMS.register(modEventBus); + } } } diff --git a/src/test/java/net/minecraftforge/debug/client/model/MultiLayerModelTest.java b/src/test/java/net/minecraftforge/debug/client/model/MultiLayerModelTest.java index f5b31cae92..6cc103bf30 100644 --- a/src/test/java/net/minecraftforge/debug/client/model/MultiLayerModelTest.java +++ b/src/test/java/net/minecraftforge/debug/client/model/MultiLayerModelTest.java @@ -19,14 +19,14 @@ package net.minecraftforge.debug.client.model; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.material.Material; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.RenderTypeLookup; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; -import net.minecraft.util.ResourceLocation; +import net.minecraft.client.renderer.ItemBlockRenderTypes; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; @@ -64,7 +64,7 @@ public class MultiLayerModelTest { if (!ENABLED) return; - event.getRegistry().register(new BlockItem(TEST_BLOCK, new Item.Properties().tab(ItemGroup.TAB_MISC)).setRegistryName(TEST_BLOCK.getRegistryName())); + event.getRegistry().register(new BlockItem(TEST_BLOCK, new Item.Properties().tab(CreativeModeTab.TAB_MISC)).setRegistryName(TEST_BLOCK.getRegistryName())); } @net.minecraftforge.eventbus.api.SubscribeEvent @@ -72,7 +72,7 @@ public class MultiLayerModelTest { if (!ENABLED) return; - RenderTypeLookup.setRenderLayer(TEST_BLOCK, (layer) -> { + ItemBlockRenderTypes.setRenderLayer(TEST_BLOCK, (layer) -> { return layer == RenderType.solid() || layer == RenderType.translucent(); }); } diff --git a/src/test/java/net/minecraftforge/debug/client/model/NewModelLoaderTest.java b/src/test/java/net/minecraftforge/debug/client/model/NewModelLoaderTest.java index 8e97604a55..90351e7dfa 100644 --- a/src/test/java/net/minecraftforge/debug/client/model/NewModelLoaderTest.java +++ b/src/test/java/net/minecraftforge/debug/client/model/NewModelLoaderTest.java @@ -23,32 +23,32 @@ import com.google.common.collect.ImmutableList; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonObject; import com.mojang.datafixers.util.Pair; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.model.*; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.client.renderer.vertex.VertexFormatElement; +import com.mojang.blaze3d.vertex.DefaultVertexFormat; +import com.mojang.blaze3d.vertex.VertexFormatElement; import net.minecraft.data.DataGenerator; -import net.minecraft.entity.Entity; -import net.minecraft.inventory.EquipmentSlotType; -import net.minecraft.item.*; -import net.minecraft.resources.IResourceManager; -import net.minecraft.state.StateContainer; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.util.Direction; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.core.Direction; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.BlockGetter; import net.minecraftforge.client.event.ModelRegistryEvent; import net.minecraftforge.client.model.IModelBuilder; import net.minecraftforge.client.model.IModelConfiguration; import net.minecraftforge.client.model.IModelLoader; import net.minecraftforge.client.model.ModelLoaderRegistry; +import net.minecraftforge.client.model.generators.BlockModelBuilder; import net.minecraftforge.client.model.generators.BlockStateProvider; +import net.minecraftforge.client.model.generators.ConfiguredModel; import net.minecraftforge.client.model.generators.ItemModelProvider; import net.minecraftforge.client.model.generators.loaders.ItemLayersModelBuilder; import net.minecraftforge.client.model.generators.loaders.OBJLoaderBuilder; @@ -57,9 +57,9 @@ import net.minecraftforge.client.model.geometry.ISimpleModelGeometry; import net.minecraftforge.client.model.pipeline.BakedQuadBuilder; import net.minecraftforge.common.data.ExistingFileHelper; import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fml.RegistryObject; +import net.minecraftforge.fmllegacy.RegistryObject; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.event.lifecycle.GatherDataEvent; +import net.minecraftforge.forge.event.lifecycle.GatherDataEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; @@ -70,6 +70,16 @@ import java.util.Collections; import java.util.Set; import java.util.function.Function; +import net.minecraft.client.renderer.block.model.ItemTransforms; +import net.minecraft.client.resources.model.ModelBakery; +import net.minecraft.client.resources.model.ModelState; +import net.minecraft.client.resources.model.UnbakedModel; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.BlockPlaceContext; + @Mod(NewModelLoaderTest.MODID) public class NewModelLoaderTest { @@ -80,14 +90,14 @@ public class NewModelLoaderTest public static RegistryObject obj_block = BLOCKS.register("obj_block", () -> new Block(Block.Properties.of(Material.WOOD).strength(10)) { @Override - protected void createBlockStateDefinition(StateContainer.Builder builder) + protected void createBlockStateDefinition(StateDefinition.Builder builder) { builder.add(BlockStateProperties.HORIZONTAL_FACING); } @Nullable @Override - public BlockState getStateForPlacement(BlockItemUseContext context) + public BlockState getStateForPlacement(BlockPlaceContext context) { return defaultBlockState().setValue( BlockStateProperties.HORIZONTAL_FACING, context.getHorizontalDirection() @@ -95,7 +105,7 @@ public class NewModelLoaderTest } @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) + public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) { return Block.box(2,2,2,14,14,14); } @@ -103,33 +113,33 @@ public class NewModelLoaderTest ); public static RegistryObject obj_item = ITEMS.register("obj_block", () -> - new BlockItem(obj_block.get(), new Item.Properties().tab(ItemGroup.TAB_MISC)) { + new BlockItem(obj_block.get(), new Item.Properties().tab(CreativeModeTab.TAB_MISC)) { @Override - public boolean canEquip(ItemStack stack, EquipmentSlotType armorType, Entity entity) + public boolean canEquip(ItemStack stack, EquipmentSlot armorType, Entity entity) { - return armorType == EquipmentSlotType.HEAD; + return armorType == EquipmentSlot.HEAD; } } ); public static RegistryObject custom_transforms = ITEMS.register("custom_transforms", () -> - new Item(new Item.Properties().tab(ItemGroup.TAB_MISC)) + new Item(new Item.Properties().tab(CreativeModeTab.TAB_MISC)) ); public static RegistryObject custom_vanilla_loader = ITEMS.register("custom_vanilla_loader", () -> - new Item(new Item.Properties().tab(ItemGroup.TAB_MISC)) + new Item(new Item.Properties().tab(CreativeModeTab.TAB_MISC)) ); public static RegistryObject custom_loader = ITEMS.register("custom_loader", () -> - new Item(new Item.Properties().tab(ItemGroup.TAB_MISC)) + new Item(new Item.Properties().tab(CreativeModeTab.TAB_MISC)) ); public static RegistryObject item_layers = ITEMS.register("item_layers", () -> - new Item(new Item.Properties().tab(ItemGroup.TAB_MISC)) + new Item(new Item.Properties().tab(CreativeModeTab.TAB_MISC)) ); public static RegistryObject separate_perspective = ITEMS.register("separate_perspective", () -> - new Item(new Item.Properties().tab(ItemGroup.TAB_MISC)) + new Item(new Item.Properties().tab(CreativeModeTab.TAB_MISC)) ); public NewModelLoaderTest() @@ -151,7 +161,7 @@ public class NewModelLoaderTest static class TestLoader implements IModelLoader { @Override - public void onResourceManagerReload(IResourceManager resourceManager) + public void onResourceManagerReload(ResourceManager resourceManager) { } @@ -165,7 +175,7 @@ public class NewModelLoaderTest static class TestModel implements ISimpleModelGeometry { @Override - public void addQuads(IModelConfiguration owner, IModelBuilder modelBuilder, ModelBakery bakery, Function spriteGetter, IModelTransform modelTransform, ResourceLocation modelLocation) + public void addQuads(IModelConfiguration owner, IModelBuilder modelBuilder, ModelBakery bakery, Function< net.minecraft.client.resources.model.Material, TextureAtlasSprite> spriteGetter, ModelState modelTransform, ResourceLocation modelLocation) { TextureAtlasSprite texture = spriteGetter.apply(owner.resolveTexture("particle")); @@ -184,7 +194,7 @@ public class NewModelLoaderTest private void putVertex(BakedQuadBuilder builder, int x, float y, float z, float u, float v, float red, float green, float blue) { - ImmutableList elements = DefaultVertexFormats.BLOCK.getElements(); + ImmutableList elements = DefaultVertexFormat.BLOCK.getElements(); for(int i=0;i getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors) + public Collection< net.minecraft.client.resources.model.Material> getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors) { return Collections.singleton(owner.resolveTexture("particle")); } @@ -247,8 +257,8 @@ public class NewModelLoaderTest withExistingParent(NewModelLoaderTest.separate_perspective.getId().getPath(), "forge:item/default") .customLoader(SeparatePerspectiveModelBuilder::begin) .base(nested().parent(getExistingFile(mcLoc("minecraft:item/coal")))) - .perspective(ItemCameraTransforms.TransformType.GUI, nested().parent(getExistingFile(mcLoc("minecraft:item/snowball")))) - .perspective(ItemCameraTransforms.TransformType.FIRST_PERSON_LEFT_HAND, nested().parent(getExistingFile(mcLoc("minecraft:item/bone")))) + .perspective(ItemTransforms.TransformType.GUI, nested().parent(getExistingFile(mcLoc("minecraft:item/snowball")))) + .perspective(ItemTransforms.TransformType.FIRST_PERSON_LEFT_HAND, nested().parent(getExistingFile(mcLoc("minecraft:item/bone")))) .end(); } } @@ -263,15 +273,28 @@ public class NewModelLoaderTest @Override protected void registerStatesAndModels() { - simpleBlock(NewModelLoaderTest.obj_block.get(), models() + BlockModelBuilder model = models() .getBuilder(NewModelLoaderTest.obj_block.getId().getPath()) .customLoader(OBJLoaderBuilder::begin) .modelLocation(new ResourceLocation("new_model_loader_test:models/item/sugar_glider.obj")) .flipV(true) .end() .texture("qr", "minecraft:block/oak_planks") - .texture("particle", "#qr") - ); + .texture("particle", "#qr"); + getVariantBuilder(NewModelLoaderTest.obj_block.get()) + .partialState() + .with(BlockStateProperties.HORIZONTAL_FACING, Direction.EAST) + .addModels(new ConfiguredModel(model, 0, 90, false)) + .partialState() + .with(BlockStateProperties.HORIZONTAL_FACING, Direction.WEST) + .addModels(new ConfiguredModel(model, 0, 270, false)) + .partialState() + .with(BlockStateProperties.HORIZONTAL_FACING, Direction.NORTH) + .addModels(new ConfiguredModel(model)) + .partialState() + .with(BlockStateProperties.HORIZONTAL_FACING, Direction.SOUTH) + .addModels(new ConfiguredModel(model, 0, 180, false)) + .partialState(); } } } diff --git a/src/test/java/net/minecraftforge/debug/client/model/TRSRTransformerTest.java b/src/test/java/net/minecraftforge/debug/client/model/TRSRTransformerTest.java index d7b6e1e7d3..ad9728dcee 100644 --- a/src/test/java/net/minecraftforge/debug/client/model/TRSRTransformerTest.java +++ b/src/test/java/net/minecraftforge/debug/client/model/TRSRTransformerTest.java @@ -26,21 +26,21 @@ import javax.annotation.Nullable; import com.google.common.collect.ImmutableList; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.model.BakedQuad; -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.model.ItemOverrideList; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; +import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.renderer.block.model.ItemOverrides; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; -import net.minecraft.util.Direction; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.vector.Quaternion; -import net.minecraft.util.math.vector.TransformationMatrix; -import net.minecraft.util.math.vector.Vector3f; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.core.Direction; +import net.minecraft.resources.ResourceLocation; +import com.mojang.math.Quaternion; +import com.mojang.math.Transformation; +import com.mojang.math.Vector3f; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.event.ModelBakeEvent; import net.minecraftforge.client.model.data.IDynamicBakedModel; @@ -50,7 +50,7 @@ import net.minecraftforge.client.model.pipeline.TRSRTransformer; import net.minecraftforge.common.model.TransformationHelper; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.DistExecutor; -import net.minecraftforge.fml.RegistryObject; +import net.minecraftforge.fmllegacy.RegistryObject; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.DeferredRegister; @@ -64,7 +64,7 @@ public class TRSRTransformerTest { private static final RegistryObject TEST_BLOCK = BLOCKS.register("test", () -> new Block(Block.Properties.of(Material.STONE))); @SuppressWarnings("unused") - private static final RegistryObject TEST_ITEM = ITEMS.register("test", () -> new BlockItem(TEST_BLOCK.get(), new Item.Properties().tab(ItemGroup.TAB_MISC))); + private static final RegistryObject TEST_ITEM = ITEMS.register("test", () -> new BlockItem(TEST_BLOCK.get(), new Item.Properties().tab(CreativeModeTab.TAB_MISC))); public TRSRTransformerTest() { final IEventBus mod = FMLJavaModLoadingContext.get().getModEventBus(); @@ -82,9 +82,9 @@ public class TRSRTransformerTest { } public class MyBakedModel implements IDynamicBakedModel { - private final IBakedModel base; + private final BakedModel base; - public MyBakedModel(IBakedModel base) { + public MyBakedModel(BakedModel base) { this.base = base; } @@ -95,7 +95,7 @@ public class TRSRTransformerTest { Quaternion rot = TransformationHelper.quatFromXYZ(new Vector3f(0, 45, 0), true); Vector3f translation = new Vector3f(0, 0.33f, 0); - TransformationMatrix trans = new TransformationMatrix(translation, rot, null, null).blockCenterToCorner(); + Transformation trans = new Transformation(translation, rot, null, null).blockCenterToCorner(); for (BakedQuad quad : base.getQuads(state, side, rand, data)) { @@ -143,7 +143,7 @@ public class TRSRTransformerTest { } @Override - public ItemOverrideList getOverrides() { + public ItemOverrides getOverrides() { return base.getOverrides(); } } diff --git a/src/test/java/net/minecraftforge/debug/client/model/package-info.java b/src/test/java/net/minecraftforge/debug/client/model/package-info.java index 9094636b34..d8748c8473 100644 --- a/src/test/java/net/minecraftforge/debug/client/model/package-info.java +++ b/src/test/java/net/minecraftforge/debug/client/model/package-info.java @@ -22,4 +22,4 @@ package net.minecraftforge.debug.client.model; import javax.annotation.ParametersAreNonnullByDefault; -import mcp.MethodsReturnNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; diff --git a/src/test/java/net/minecraftforge/debug/client/rendering/LinearTextTextureFilteringTest.java b/src/test/java/net/minecraftforge/debug/client/rendering/LinearTextTextureFilteringTest.java index fe41b3d5fd..fe50cd97eb 100644 --- a/src/test/java/net/minecraftforge/debug/client/rendering/LinearTextTextureFilteringTest.java +++ b/src/test/java/net/minecraftforge/debug/client/rendering/LinearTextTextureFilteringTest.java @@ -19,7 +19,7 @@ package net.minecraftforge.debug.client.rendering; -import net.minecraft.client.gui.screen.MainMenuScreen; +import net.minecraft.client.gui.screens.TitleScreen; import net.minecraftforge.client.ForgeRenderTypes; import net.minecraftforge.client.event.GuiScreenEvent.DrawScreenEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -36,7 +36,7 @@ public class LinearTextTextureFilteringTest @SubscribeEvent public static void onGuiRenderPre(DrawScreenEvent.Pre event) { - if (ENABLED && event.getGui() instanceof MainMenuScreen) + if (ENABLED && event.getGui() instanceof TitleScreen) { ForgeRenderTypes.enableTextTextureLinearFiltering = true; } @@ -45,7 +45,7 @@ public class LinearTextTextureFilteringTest @SubscribeEvent public static void onGuiRenderPost(DrawScreenEvent.Post event) { - if (ENABLED && event.getGui() instanceof MainMenuScreen) + if (ENABLED && event.getGui() instanceof TitleScreen) { ForgeRenderTypes.enableTextTextureLinearFiltering = false; } diff --git a/src/test/java/net/minecraftforge/debug/client/rendering/NameplateRenderingEventTest.java b/src/test/java/net/minecraftforge/debug/client/rendering/NameplateRenderingEventTest.java index d5d7871c6a..5c452f3ba0 100644 --- a/src/test/java/net/minecraftforge/debug/client/rendering/NameplateRenderingEventTest.java +++ b/src/test/java/net/minecraftforge/debug/client/rendering/NameplateRenderingEventTest.java @@ -19,10 +19,10 @@ package net.minecraftforge.debug.client.rendering; -import net.minecraft.entity.passive.CowEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TextFormatting; +import net.minecraft.world.entity.animal.Cow; +import net.minecraft.world.entity.player.Player; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.ChatFormatting; import net.minecraftforge.client.event.RenderNameplateEvent; import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -46,15 +46,15 @@ public class NameplateRenderingEventTest return; } - if(event.getEntity() instanceof CowEntity) + if(event.getEntity() instanceof Cow) { - event.setContent(new StringTextComponent("Evil Cow").withStyle(TextFormatting.RED)); + event.setContent(new TextComponent("Evil Cow").withStyle(ChatFormatting.RED)); event.setResult(Event.Result.ALLOW); } - if(event.getEntity() instanceof PlayerEntity) + if(event.getEntity() instanceof Player) { - event.setContent(event.getEntity().getDisplayName().copy().withStyle(TextFormatting.GOLD)); + event.setContent(event.getEntity().getDisplayName().copy().withStyle(ChatFormatting.GOLD)); } } } diff --git a/src/test/java/net/minecraftforge/debug/client/rendering/RenderLocalPlayerTest.java b/src/test/java/net/minecraftforge/debug/client/rendering/RenderLocalPlayerTest.java index 5712955cf5..678a77c862 100644 --- a/src/test/java/net/minecraftforge/debug/client/rendering/RenderLocalPlayerTest.java +++ b/src/test/java/net/minecraftforge/debug/client/rendering/RenderLocalPlayerTest.java @@ -20,8 +20,8 @@ package net.minecraftforge.debug.client.rendering; import net.minecraft.client.Minecraft; -import net.minecraft.item.Items; -import net.minecraft.util.ActionResultType; +import net.minecraft.world.item.Items; +import net.minecraft.world.InteractionResult; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -44,7 +44,7 @@ public class RenderLocalPlayerTest { mc.setCameraEntity(event.getTarget()); - event.setCancellationResult(ActionResultType.SUCCESS); + event.setCancellationResult(InteractionResult.SUCCESS); event.setCanceled(true); } } @@ -60,7 +60,7 @@ public class RenderLocalPlayerTest { mc.setCameraEntity(mc.player); - event.setCancellationResult(ActionResultType.SUCCESS); + event.setCancellationResult(InteractionResult.SUCCESS); event.setCanceled(true); } } diff --git a/src/test/java/net/minecraftforge/debug/client/rendering/ShaderFixTest.java b/src/test/java/net/minecraftforge/debug/client/rendering/ShaderFixTest.java index 8d3feda3ff..2b8f6c4b7b 100644 --- a/src/test/java/net/minecraftforge/debug/client/rendering/ShaderFixTest.java +++ b/src/test/java/net/minecraftforge/debug/client/rendering/ShaderFixTest.java @@ -19,11 +19,11 @@ package net.minecraftforge.debug.client.rendering; -import net.minecraft.client.entity.player.ClientPlayerEntity; -import net.minecraft.util.ResourceLocation; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.client.registry.ClientRegistry; +import net.minecraftforge.fmlclient.registry.ClientRegistry; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; @@ -34,6 +34,6 @@ public class ShaderFixTest @SubscribeEvent public static void clientSetup(final FMLClientSetupEvent event) { - ClientRegistry.registerEntityShader(ClientPlayerEntity.class, new ResourceLocation("shaders/post/desaturate.json")); + ClientRegistry.registerEntityShader(LocalPlayer.class, new ResourceLocation("shaders/post/desaturate.json")); } } \ No newline at end of file diff --git a/src/test/java/net/minecraftforge/debug/client/rendering/package-info.java b/src/test/java/net/minecraftforge/debug/client/rendering/package-info.java index d95502fc39..9ad21ce9ea 100644 --- a/src/test/java/net/minecraftforge/debug/client/rendering/package-info.java +++ b/src/test/java/net/minecraftforge/debug/client/rendering/package-info.java @@ -22,4 +22,4 @@ package net.minecraftforge.debug.client.rendering; import javax.annotation.ParametersAreNonnullByDefault; -import mcp.MethodsReturnNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; diff --git a/src/test/java/net/minecraftforge/debug/command/EnumArgumentTest.java b/src/test/java/net/minecraftforge/debug/command/EnumArgumentTest.java index 1c2361452f..94117f2739 100644 --- a/src/test/java/net/minecraftforge/debug/command/EnumArgumentTest.java +++ b/src/test/java/net/minecraftforge/debug/command/EnumArgumentTest.java @@ -19,8 +19,8 @@ package net.minecraftforge.debug.command; -import net.minecraft.command.Commands; -import net.minecraft.util.text.StringTextComponent; +import net.minecraft.commands.Commands; +import net.minecraft.network.chat.TextComponent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.RegisterCommandsEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -46,14 +46,14 @@ public class EnumArgumentTest event.getDispatcher().register(Commands.literal("enumargumenttest") .then(Commands.argument("string", StringArgumentType.string()) .executes(context -> { - context.getSource().sendSuccess(new StringTextComponent("string: " + StringArgumentType.getString(context, "string")), false); + context.getSource().sendSuccess(new TextComponent("string: " + StringArgumentType.getString(context, "string")), false); return 1; })) .then(Commands.argument("enum", EnumArgument.enumArgument(ExampleEnum.class)) .executes(context -> { context.getSource() - .sendSuccess(new StringTextComponent("enum: " + context.getArgument("enum", ExampleEnum.class)), false); + .sendSuccess(new TextComponent("enum: " + context.getArgument("enum", ExampleEnum.class)), false); return 1; }))); diff --git a/src/test/java/net/minecraftforge/debug/command/package-info.java b/src/test/java/net/minecraftforge/debug/command/package-info.java index b14d5058ed..0a7df19bbb 100644 --- a/src/test/java/net/minecraftforge/debug/command/package-info.java +++ b/src/test/java/net/minecraftforge/debug/command/package-info.java @@ -21,6 +21,6 @@ @MethodsReturnNonnullByDefault package net.minecraftforge.debug.command; -import mcp.MethodsReturnNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/test/java/net/minecraftforge/debug/entity/AddEntityAttributeTest.java b/src/test/java/net/minecraftforge/debug/entity/AddEntityAttributeTest.java index 95e7f5aafb..c3c7100f99 100644 --- a/src/test/java/net/minecraftforge/debug/entity/AddEntityAttributeTest.java +++ b/src/test/java/net/minecraftforge/debug/entity/AddEntityAttributeTest.java @@ -19,11 +19,11 @@ package net.minecraftforge.debug.entity; -import net.minecraft.entity.ai.attributes.Attribute; -import net.minecraft.entity.ai.attributes.RangedAttribute; +import net.minecraft.world.entity.ai.attributes.Attribute; +import net.minecraft.world.entity.ai.attributes.RangedAttribute; import net.minecraftforge.event.entity.EntityAttributeModificationEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.RegistryObject; +import net.minecraftforge.fmllegacy.RegistryObject; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.DeferredRegister; diff --git a/src/test/java/net/minecraftforge/debug/entity/CreateEntityClassificationTest.java b/src/test/java/net/minecraftforge/debug/entity/CreateEntityClassificationTest.java index d33644f8d0..aca9929c49 100644 --- a/src/test/java/net/minecraftforge/debug/entity/CreateEntityClassificationTest.java +++ b/src/test/java/net/minecraftforge/debug/entity/CreateEntityClassificationTest.java @@ -19,11 +19,11 @@ package net.minecraftforge.debug.entity; -import net.minecraft.entity.EntityClassification; +import net.minecraft.world.entity.MobCategory; import net.minecraftforge.fml.common.Mod; @Mod("create_entity_classification_test") public class CreateEntityClassificationTest { - public static EntityClassification test = EntityClassification.create("TEST", "test", 1, true, true, 128); + public static MobCategory test = MobCategory.create("TEST", "test", 1, true, true, 128); } diff --git a/src/test/java/net/minecraftforge/debug/entity/EntityTeleportEventTest.java b/src/test/java/net/minecraftforge/debug/entity/EntityTeleportEventTest.java index d713416d0f..c69d046439 100644 --- a/src/test/java/net/minecraftforge/debug/entity/EntityTeleportEventTest.java +++ b/src/test/java/net/minecraftforge/debug/entity/EntityTeleportEventTest.java @@ -20,7 +20,7 @@ package net.minecraftforge.debug.entity; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.entity.living.EntityTeleportEvent; +import net.minecraftforge.event.entity.EntityTeleportEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; diff --git a/src/test/java/net/minecraftforge/debug/entity/FishingBobberEventTest.java b/src/test/java/net/minecraftforge/debug/entity/FishingBobberEventTest.java index c3525ef763..434ee36c1f 100644 --- a/src/test/java/net/minecraftforge/debug/entity/FishingBobberEventTest.java +++ b/src/test/java/net/minecraftforge/debug/entity/FishingBobberEventTest.java @@ -19,12 +19,12 @@ package net.minecraftforge.debug.entity; -import net.minecraft.entity.Entity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.projectile.FishingBobberEntity; -import net.minecraft.util.math.EntityRayTraceResult; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.projectile.FishingHook; +import net.minecraft.world.phys.EntityHitResult; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.ProjectileImpactEvent; import net.minecraftforge.fml.common.Mod; @@ -43,19 +43,19 @@ public class FishingBobberEventTest } } - public static void handleImpact(ProjectileImpactEvent.FishingBobber event) + public static void handleImpact(ProjectileImpactEvent event) { - FishingBobberEntity bob = event.getFishingBobber(); - RayTraceResult trace = event.getRayTraceResult(); - if (trace.getType() == RayTraceResult.Type.ENTITY) + FishingHook fishingHook = event.getProjectile(); + HitResult trace = event.getRayTraceResult(); + if (trace.getType() == HitResult.Type.ENTITY) { - Vector3d vector3d = bob.getDeltaMovement().multiply(1.0D, 0.0D, 1.0D).normalize().scale(0.6); + Vec3 vector3d = fishingHook.getDeltaMovement().multiply(1.0D, 0.0D, 1.0D).normalize().scale(0.6); if (vector3d.lengthSqr() > 0.0D) { - Entity entity = ((EntityRayTraceResult) trace).getEntity(); + Entity entity = ((EntityHitResult) trace).getEntity(); if (entity instanceof LivingEntity) { - ((LivingEntity) entity).push(vector3d.x, 0.3D, vector3d.z); + entity.push(vector3d.x, 0.3D, vector3d.z); } } } diff --git a/src/test/java/net/minecraftforge/debug/entity/GravityAttributeTest.java b/src/test/java/net/minecraftforge/debug/entity/GravityAttributeTest.java index 10afaeb6dd..6d28c11033 100644 --- a/src/test/java/net/minecraftforge/debug/entity/GravityAttributeTest.java +++ b/src/test/java/net/minecraftforge/debug/entity/GravityAttributeTest.java @@ -24,27 +24,28 @@ import java.util.List; import java.util.UUID; import java.util.stream.Collectors; import java.util.stream.Stream; +import java.util.stream.StreamSupport; -import net.minecraft.entity.ai.attributes.ModifiableAttributeInstance; +import net.minecraft.world.entity.ai.attributes.AttributeInstance; import net.minecraftforge.common.ForgeMod; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import com.google.common.collect.Multimap; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.entity.Entity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.ai.attributes.Attribute; -import net.minecraft.entity.ai.attributes.AttributeModifier; -import net.minecraft.entity.ai.attributes.AttributeModifier.Operation; -import net.minecraft.inventory.EquipmentSlotType; -import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; -import net.minecraft.item.Rarity; -import net.minecraft.world.World; -import net.minecraft.world.biome.Biome.Category; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.ai.attributes.Attribute; +import net.minecraft.world.entity.ai.attributes.AttributeModifier; +import net.minecraft.world.entity.ai.attributes.AttributeModifier.Operation; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.Rarity; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.biome.Biome.BiomeCategory; +import net.minecraft.server.level.ServerLevel; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.event.TickEvent; @@ -52,7 +53,7 @@ import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraft.item.Item.Properties; +import net.minecraft.world.item.Item.Properties; @Mod("gravity_attribute_test") public class GravityAttributeTest @@ -81,11 +82,11 @@ public class GravityAttributeTest if (ticks++ > 60) { ticks = 0; - World w = event.world; + Level w = event.world; List list; if(w.isClientSide) { - ClientWorld cw = (ClientWorld)w; + ClientLevel cw = (ClientLevel)w; list = new ArrayList<>(100); for(Entity e : cw.entitiesForRendering()) { @@ -95,15 +96,18 @@ public class GravityAttributeTest } else { - ServerWorld sw = (ServerWorld)w; - Stream s = sw.getEntities().filter(Entity::isAlive).filter(e -> e instanceof LivingEntity).map(e -> (LivingEntity)e); + ServerLevel sw = (ServerLevel)w; + Stream s = StreamSupport.stream(sw.getEntities().getAll().spliterator(), false) + .filter(Entity::isAlive) + .filter(e -> e instanceof LivingEntity) + .map(e -> (LivingEntity)e); list = s.collect(Collectors.toList()); } for(LivingEntity liv : list) { - ModifiableAttributeInstance grav = liv.getAttribute(ForgeMod.ENTITY_GRAVITY.get()); - boolean inPlains = liv.level.getBiome(liv.blockPosition()).getBiomeCategory() == Category.PLAINS; + AttributeInstance grav = liv.getAttribute(ForgeMod.ENTITY_GRAVITY.get()); + boolean inPlains = liv.level.getBiome(liv.blockPosition()).getBiomeCategory() == BiomeCategory.PLAINS; if (inPlains && !grav.hasModifier(REDUCED_GRAVITY)) { logger.info("Granted low gravity to Entity: {}", liv); @@ -123,7 +127,7 @@ public class GravityAttributeTest @SubscribeEvent public void registerItems(RegistryEvent.Register event) { - event.getRegistry().register(new ItemGravityStick(new Item.Properties().tab(ItemGroup.TAB_TOOLS).rarity(Rarity.RARE)).setRegistryName("gravity_attribute_test:gravity_stick")); + event.getRegistry().register(new ItemGravityStick(new Properties().tab(CreativeModeTab.TAB_TOOLS).rarity(Rarity.RARE)).setRegistryName("gravity_attribute_test:gravity_stick")); } public static class ItemGravityStick extends Item @@ -136,11 +140,11 @@ public class GravityAttributeTest } @Override - public Multimap getDefaultAttributeModifiers(EquipmentSlotType slot) + public Multimap getDefaultAttributeModifiers(EquipmentSlot slot) { @SuppressWarnings("deprecation") Multimap multimap = super.getDefaultAttributeModifiers(slot); - if (slot == EquipmentSlotType.MAINHAND) + if (slot == EquipmentSlot.MAINHAND) multimap.put(ForgeMod.ENTITY_GRAVITY.get(), new AttributeModifier(GRAVITY_MODIFIER, "More Gravity", 1.0D, Operation.ADDITION)); return multimap; diff --git a/src/test/java/net/minecraftforge/debug/entity/living/LivingConversionEventTest.java b/src/test/java/net/minecraftforge/debug/entity/living/LivingConversionEventTest.java index 65da043f47..b6cf92e243 100644 --- a/src/test/java/net/minecraftforge/debug/entity/living/LivingConversionEventTest.java +++ b/src/test/java/net/minecraftforge/debug/entity/living/LivingConversionEventTest.java @@ -19,10 +19,10 @@ package net.minecraftforge.debug.entity.living; -import net.minecraft.entity.merchant.villager.VillagerEntity; -import net.minecraft.entity.monster.piglin.PiglinEntity; -import net.minecraft.potion.EffectInstance; -import net.minecraft.potion.Effects; +import net.minecraft.world.entity.npc.Villager; +import net.minecraft.world.entity.monster.piglin.Piglin; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.effect.MobEffects; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingConversionEvent; import net.minecraftforge.fml.common.Mod; @@ -38,7 +38,7 @@ public class LivingConversionEventTest public void canLivingConversion(LivingConversionEvent.Pre event) { - if (event.getEntityLiving() instanceof PiglinEntity) + if (event.getEntityLiving() instanceof Piglin) { event.setCanceled(true); event.setConversionTimer(0); @@ -47,7 +47,7 @@ public class LivingConversionEventTest public void onLivingConversion(LivingConversionEvent.Post event) { - if (event.getEntityLiving() instanceof VillagerEntity) - event.getEntityLiving().addEffect(new EffectInstance(Effects.LUCK, 20)); + if (event.getEntityLiving() instanceof Villager) + event.getEntityLiving().addEffect(new MobEffectInstance(MobEffects.LUCK, 20)); } } diff --git a/src/test/java/net/minecraftforge/debug/entity/package-info.java b/src/test/java/net/minecraftforge/debug/entity/package-info.java index 78e465776b..d1c6be99c8 100644 --- a/src/test/java/net/minecraftforge/debug/entity/package-info.java +++ b/src/test/java/net/minecraftforge/debug/entity/package-info.java @@ -22,4 +22,4 @@ package net.minecraftforge.debug.entity; import javax.annotation.ParametersAreNonnullByDefault; -import mcp.MethodsReturnNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; diff --git a/src/test/java/net/minecraftforge/debug/entity/player/PlayerAttackKnockbackTest.java b/src/test/java/net/minecraftforge/debug/entity/player/PlayerAttackKnockbackTest.java index 85f6f41331..c5cd303aae 100644 --- a/src/test/java/net/minecraftforge/debug/entity/player/PlayerAttackKnockbackTest.java +++ b/src/test/java/net/minecraftforge/debug/entity/player/PlayerAttackKnockbackTest.java @@ -21,15 +21,19 @@ package net.minecraftforge.debug.entity.player; import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.Multimap; -import net.minecraft.entity.ai.attributes.Attribute; -import net.minecraft.entity.ai.attributes.AttributeModifier; -import net.minecraft.entity.ai.attributes.Attributes; -import net.minecraft.inventory.EquipmentSlotType; -import net.minecraft.item.*; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.entity.ai.attributes.Attribute; +import net.minecraft.world.entity.ai.attributes.AttributeModifier; +import net.minecraft.world.entity.ai.attributes.Attributes; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.SwordItem; +import net.minecraft.world.item.Tier; +import net.minecraft.world.item.Tiers; import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fml.RegistryObject; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.fmllegacy.RegistryObject; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; @@ -51,7 +55,7 @@ public class PlayerAttackKnockbackTest { static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID); static RegistryObject KNOCKBACK_SWORD = ITEMS.register("knockback_sword", () -> - new KnockbackSwordItem(ItemTier.IRON, 3, -2.4F, ATTACK_KNOCKBACK_VALUE, (new Item.Properties()).tab(ItemGroup.TAB_COMBAT)) + new KnockbackSwordItem(Tiers.IRON, 3, -2.4F, ATTACK_KNOCKBACK_VALUE, (new Item.Properties()).tab(CreativeModeTab.TAB_COMBAT)) ); public PlayerAttackKnockbackTest() @@ -60,19 +64,19 @@ public class PlayerAttackKnockbackTest { ITEMS.register(modEventBus); } - static class KnockbackSwordItem extends SwordItem{ + static class KnockbackSwordItem extends SwordItem { private final float attackKnockback; private final Multimap defaultModifiers = ArrayListMultimap.create(); // initialize as empty protected static final UUID BASE_ATTACK_KNOCKBACK_UUID = UUID.fromString("01efce91-ab3a-4163-b464-5c7bd1ae5496"); - KnockbackSwordItem(IItemTier itemTier, int attackDamageIn, float attackSpeedIn, float attackKnockbackIn, Properties properties) { + KnockbackSwordItem(Tier itemTier, int attackDamageIn, float attackSpeedIn, float attackKnockbackIn, Properties properties) { super(itemTier, attackDamageIn, attackSpeedIn, properties); this.attackKnockback = attackKnockbackIn; } @Override - public Multimap getDefaultAttributeModifiers(EquipmentSlotType equipmentSlotType) { - if(equipmentSlotType == EquipmentSlotType.MAINHAND){ + public Multimap getDefaultAttributeModifiers(EquipmentSlot equipmentSlotType) { + if(equipmentSlotType == EquipmentSlot.MAINHAND){ if(this.defaultModifiers.isEmpty()){ Multimap oldAttributeModifiers = super.getDefaultAttributeModifiers(equipmentSlotType); this.defaultModifiers.putAll(oldAttributeModifiers); diff --git a/src/test/java/net/minecraftforge/debug/entity/player/PlayerGameModeEventTest.java b/src/test/java/net/minecraftforge/debug/entity/player/PlayerGameModeEventTest.java index 794e4e2f33..dba5fb9d8b 100644 --- a/src/test/java/net/minecraftforge/debug/entity/player/PlayerGameModeEventTest.java +++ b/src/test/java/net/minecraftforge/debug/entity/player/PlayerGameModeEventTest.java @@ -19,7 +19,7 @@ package net.minecraftforge.debug.entity.player; -import net.minecraft.world.GameType; +import net.minecraft.world.level.GameType; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.event.ClientPlayerChangeGameModeEvent; import net.minecraftforge.event.entity.player.PlayerEvent; @@ -44,7 +44,7 @@ public class PlayerGameModeEventTest if (event.getNewGameMode() == GameType.SURVIVAL) event.setCanceled(true); } - + @Mod.EventBusSubscriber(modid="player_game_mode_event_test", value=Dist.CLIENT, bus=Mod.EventBusSubscriber.Bus.FORGE) public static class PlayerGameModeEventTestClientForgeEvents { diff --git a/src/test/java/net/minecraftforge/debug/entity/player/PlayerNameEventTest.java b/src/test/java/net/minecraftforge/debug/entity/player/PlayerNameEventTest.java index 1f8ad22a06..853c2d230c 100644 --- a/src/test/java/net/minecraftforge/debug/entity/player/PlayerNameEventTest.java +++ b/src/test/java/net/minecraftforge/debug/entity/player/PlayerNameEventTest.java @@ -19,7 +19,7 @@ package net.minecraftforge.debug.entity.player; -import net.minecraft.util.text.StringTextComponent; +import net.minecraft.network.chat.TextComponent; import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; @@ -34,6 +34,6 @@ public class PlayerNameEventTest public static void onPlayerNameEvent(PlayerEvent.NameFormat event) { if (!ENABLE) return; - event.setDisplayname(new StringTextComponent("Test Name")); + event.setDisplayname(new TextComponent("Test Name")); } } diff --git a/src/test/java/net/minecraftforge/debug/entity/player/package-info.java b/src/test/java/net/minecraftforge/debug/entity/player/package-info.java index 5e9b76944f..ae8e33d678 100644 --- a/src/test/java/net/minecraftforge/debug/entity/player/package-info.java +++ b/src/test/java/net/minecraftforge/debug/entity/player/package-info.java @@ -22,4 +22,4 @@ package net.minecraftforge.debug.entity.player; import javax.annotation.ParametersAreNonnullByDefault; -import mcp.MethodsReturnNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; diff --git a/src/test/java/net/minecraftforge/debug/fluid/FiniteWaterTest.java b/src/test/java/net/minecraftforge/debug/fluid/FiniteWaterTest.java index 1690831101..7847602542 100644 --- a/src/test/java/net/minecraftforge/debug/fluid/FiniteWaterTest.java +++ b/src/test/java/net/minecraftforge/debug/fluid/FiniteWaterTest.java @@ -19,9 +19,9 @@ package net.minecraftforge.debug.fluid; -import net.minecraft.block.BlockState; -import net.minecraft.fluid.FluidState; -import net.minecraft.fluid.Fluids; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.level.material.Fluids; import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.eventbus.api.SubscribeEvent; diff --git a/src/test/java/net/minecraftforge/debug/fluid/MilkFluidTest.java b/src/test/java/net/minecraftforge/debug/fluid/MilkFluidTest.java index 2fe78b210c..421af207d0 100644 --- a/src/test/java/net/minecraftforge/debug/fluid/MilkFluidTest.java +++ b/src/test/java/net/minecraftforge/debug/fluid/MilkFluidTest.java @@ -19,9 +19,9 @@ package net.minecraftforge.debug.fluid; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.util.text.StringTextComponent; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.network.chat.TextComponent; import net.minecraftforge.common.ForgeMod; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.PlayerInteractEvent; @@ -48,7 +48,7 @@ public class MilkFluidTest ItemStack stack = event.getItemStack(); if (stack.getItem() == Items.MILK_BUCKET) { - FluidUtil.getFluidContained(stack).ifPresent((fluid) -> event.getPlayer().displayClientMessage(new StringTextComponent("Contains ").append(fluid.getDisplayName()), true)); + FluidUtil.getFluidContained(stack).ifPresent((fluid) -> event.getPlayer().displayClientMessage(new TextComponent("Contains ").append(fluid.getDisplayName()), true)); } } } diff --git a/src/test/java/net/minecraftforge/debug/fluid/NewFluidTest.java b/src/test/java/net/minecraftforge/debug/fluid/NewFluidTest.java index c63183ff47..13de4dbde6 100644 --- a/src/test/java/net/minecraftforge/debug/fluid/NewFluidTest.java +++ b/src/test/java/net/minecraftforge/debug/fluid/NewFluidTest.java @@ -19,40 +19,50 @@ package net.minecraftforge.debug.fluid; -import net.minecraft.block.*; -import net.minecraft.block.material.Material; -import net.minecraft.fluid.FluidState; -import net.minecraft.item.*; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.StateContainer; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorld; -import net.minecraftforge.common.util.Lazy; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelAccessor; import net.minecraftforge.fluids.DispenseFluidContainer; import org.apache.commons.lang3.Validate; -import net.minecraft.fluid.FlowingFluid; -import net.minecraft.fluid.Fluid; -import net.minecraft.fluid.Fluids; -import net.minecraft.util.ResourceLocation; +import net.minecraft.world.level.material.FlowingFluid; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fluids.FluidAttributes; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.ForgeFlowingFluid; -import net.minecraftforge.fml.RegistryObject; +import net.minecraftforge.fmllegacy.RegistryObject; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; -import net.minecraft.block.AbstractBlock.Properties; +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; + +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.BucketItem; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.DispenserBlock; +import net.minecraft.world.level.block.LiquidBlock; +import net.minecraft.world.level.block.SimpleWaterloggedBlock; +import net.minecraft.world.level.block.state.BlockState; @Mod(NewFluidTest.MODID) public class NewFluidTest { + public static final boolean ENABLE = false; // TODO fix public static final String MODID = "new_fluid_test"; public static final ResourceLocation FLUID_STILL = new ResourceLocation("minecraft:block/brown_mushroom_block"); @@ -77,30 +87,33 @@ public class NewFluidTest new ForgeFlowingFluid.Flowing(makeProperties()) ); - public static RegistryObject test_fluid_block = BLOCKS.register("test_fluid_block", () -> - new FlowingFluidBlock(test_fluid, Block.Properties.of(net.minecraft.block.material.Material.WATER).noCollission().strength(100.0F).noDrops()) + public static RegistryObject test_fluid_block = BLOCKS.register("test_fluid_block", () -> + new LiquidBlock(test_fluid, Properties.of(Material.WATER).noCollission().strength(100.0F).noDrops()) ); public static RegistryObject test_fluid_bucket = ITEMS.register("test_fluid_bucket", () -> - new BucketItem(test_fluid, new Item.Properties().craftRemainder(Items.BUCKET).stacksTo(1).tab(ItemGroup.TAB_MISC)) + new BucketItem(test_fluid, new Item.Properties().craftRemainder(Items.BUCKET).stacksTo(1).tab(CreativeModeTab.TAB_MISC)) ); // WARNING: this doesn't allow "any fluid", only the fluid from this test mod! public static RegistryObject fluidloggable_block = BLOCKS.register("fluidloggable_block", () -> - new FluidloggableBlock(Block.Properties.of(Material.WOOD).noCollission().strength(100.0F).noDrops()) + new FluidloggableBlock(Properties.of(Material.WOOD).noCollission().strength(100.0F).noDrops()) ); public static RegistryObject fluidloggable_blockitem = ITEMS.register("fluidloggable_block", () -> - new BlockItem(fluidloggable_block.get(), new Item.Properties().tab(ItemGroup.TAB_MISC)) + new BlockItem(fluidloggable_block.get(), new Item.Properties().tab(CreativeModeTab.TAB_MISC)) ); public NewFluidTest() { - IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); + if (ENABLE) + { + IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); - modEventBus.addListener(this::loadComplete); + modEventBus.addListener(this::loadComplete); - BLOCKS.register(modEventBus); - ITEMS.register(modEventBus); - FLUIDS.register(modEventBus); + BLOCKS.register(modEventBus); + ITEMS.register(modEventBus); + FLUIDS.register(modEventBus); + } } public void loadComplete(FMLLoadCompleteEvent event) @@ -115,7 +128,7 @@ public class NewFluidTest } // WARNING: this doesn't allow "any fluid", only the fluid from this test mod! - private static class FluidloggableBlock extends Block implements IWaterLoggable + private static class FluidloggableBlock extends Block implements SimpleWaterloggedBlock { public static final BooleanProperty FLUIDLOGGED = BooleanProperty.create("fluidlogged"); @@ -126,18 +139,18 @@ public class NewFluidTest } @Override - protected void createBlockStateDefinition(StateContainer.Builder builder) + protected void createBlockStateDefinition(StateDefinition.Builder builder) { builder.add(FLUIDLOGGED); } @Override - public boolean canPlaceLiquid(IBlockReader worldIn, BlockPos pos, BlockState state, Fluid fluidIn) { + public boolean canPlaceLiquid(BlockGetter worldIn, BlockPos pos, BlockState state, Fluid fluidIn) { return !state.getValue(FLUIDLOGGED) && fluidIn == test_fluid.get(); } @Override - public boolean placeLiquid(IWorld worldIn, BlockPos pos, BlockState state, FluidState fluidStateIn) { + public boolean placeLiquid(LevelAccessor worldIn, BlockPos pos, BlockState state, FluidState fluidStateIn) { if (canPlaceLiquid(worldIn, pos, state, fluidStateIn.getType())) { if (!worldIn.isClientSide()) { worldIn.setBlock(pos, state.setValue(FLUIDLOGGED, true), 3); @@ -151,12 +164,12 @@ public class NewFluidTest } @Override - public Fluid takeLiquid(IWorld worldIn, BlockPos pos, BlockState state) { + public ItemStack pickupBlock(LevelAccessor worldIn, BlockPos pos, BlockState state) { if (state.getValue(FLUIDLOGGED)) { worldIn.setBlock(pos, state.setValue(FLUIDLOGGED, false), 3); - return test_fluid.get(); + return new ItemStack(test_fluid_bucket.get()); } else { - return Fluids.EMPTY; + return ItemStack.EMPTY; } } diff --git a/src/test/java/net/minecraftforge/debug/fluid/package-info.java b/src/test/java/net/minecraftforge/debug/fluid/package-info.java index d99fb6b093..422162c9bf 100644 --- a/src/test/java/net/minecraftforge/debug/fluid/package-info.java +++ b/src/test/java/net/minecraftforge/debug/fluid/package-info.java @@ -22,4 +22,4 @@ package net.minecraftforge.debug.fluid; import javax.annotation.ParametersAreNonnullByDefault; -import mcp.MethodsReturnNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; 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 cebe8bf492..58e18bffcd 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/loot/GlobalLootModifiersTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/loot/GlobalLootModifiersTest.java @@ -21,42 +21,41 @@ package net.minecraftforge.debug.gameplay.loot; import com.google.gson.JsonObject; import com.google.gson.JsonParseException; -import net.minecraft.advancements.criterion.EnchantmentPredicate; -import net.minecraft.advancements.criterion.ItemPredicate; -import net.minecraft.advancements.criterion.MinMaxBounds; -import net.minecraft.block.Blocks; +import net.minecraft.advancements.critereon.EnchantmentPredicate; +import net.minecraft.advancements.critereon.ItemPredicate; +import net.minecraft.advancements.critereon.MinMaxBounds; +import net.minecraft.world.level.block.Blocks; import net.minecraft.data.DataGenerator; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.enchantment.Enchantment.Rarity; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.enchantment.EnchantmentType; -import net.minecraft.enchantment.Enchantments; -import net.minecraft.inventory.EquipmentSlotType; -import net.minecraft.inventory.Inventory; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.item.crafting.FurnaceRecipe; -import net.minecraft.item.crafting.IRecipeType; -import net.minecraft.loot.LootContext; -import net.minecraft.loot.LootParameterSets; -import net.minecraft.loot.LootParameters; -import net.minecraft.loot.LootTable; -import net.minecraft.loot.conditions.BlockStateProperty; -import net.minecraft.loot.conditions.ILootCondition; -import net.minecraft.loot.conditions.MatchTool; -import net.minecraft.util.JSONUtils; -import net.minecraft.util.ResourceLocation; +import net.minecraft.world.item.enchantment.Enchantment; +import net.minecraft.world.item.enchantment.Enchantment.Rarity; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.item.enchantment.EnchantmentCategory; +import net.minecraft.world.item.enchantment.Enchantments; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.SimpleContainer; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.crafting.SmeltingRecipe; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets; +import net.minecraft.world.level.storage.loot.parameters.LootContextParams; +import net.minecraft.world.level.storage.loot.LootTable; +import net.minecraft.world.level.storage.loot.predicates.LootItemBlockStatePropertyCondition; +import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; +import net.minecraft.world.level.storage.loot.predicates.MatchTool; +import net.minecraft.util.GsonHelper; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.common.data.GlobalLootModifierProvider; import net.minecraftforge.common.loot.GlobalLootModifierSerializer; -import net.minecraftforge.common.loot.IGlobalLootModifier; import net.minecraftforge.common.loot.LootModifier; import net.minecraftforge.common.loot.LootTableIdCondition; import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.RegistryObject; +import net.minecraftforge.fmllegacy.RegistryObject; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; -import net.minecraftforge.fml.event.lifecycle.GatherDataEvent; +import net.minecraftforge.forge.event.lifecycle.GatherDataEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.registries.DeferredRegister; @@ -88,7 +87,7 @@ public class GlobalLootModifiersTest { private static final RegistryObject SMELTING = GLM.register("smelting", SmeltingEnchantmentModifier.Serializer::new); private static final RegistryObject WHEATSEEDS = GLM.register("wheat_harvest", WheatSeedsConverterModifier.Serializer::new); private static final RegistryObject SILKTOUCH = GLM.register("silk_touch_bamboo", SilkTouchTestModifier.Serializer::new); - private static final RegistryObject SMELT = ENCHANTS.register("smelt", () -> new SmelterEnchantment(Rarity.UNCOMMON, EnchantmentType.DIGGER, EquipmentSlotType.MAINHAND)); + private static final RegistryObject SMELT = ENCHANTS.register("smelt", () -> new SmelterEnchantment(Rarity.UNCOMMON, EnchantmentCategory.DIGGER, EquipmentSlot.MAINHAND)); @EventBusSubscriber(modid = MODID, bus = EventBusSubscriber.Bus.MOD) public static class EventHandlers { @@ -111,30 +110,30 @@ public class GlobalLootModifiersTest { protected void start() { add("smelting", SMELTING.get(), new SmeltingEnchantmentModifier( - new ILootCondition[]{ + new LootItemCondition[]{ MatchTool.toolMatches( ItemPredicate.Builder.item().hasEnchantment( - new EnchantmentPredicate(SMELT.get(), MinMaxBounds.IntBound.atLeast(1)))) + new EnchantmentPredicate(SMELT.get(), MinMaxBounds.Ints.atLeast(1)))) .build() }) ); add("wheat_harvest", WHEATSEEDS.get(), new WheatSeedsConverterModifier( - new ILootCondition[] { + new LootItemCondition[] { MatchTool.toolMatches(ItemPredicate.Builder.item().of(Items.SHEARS)).build(), - BlockStateProperty.hasBlockStateProperties(Blocks.WHEAT).build() + LootItemBlockStatePropertyCondition.hasBlockStateProperties(Blocks.WHEAT).build() }, 3, Items.WHEAT_SEEDS, Items.WHEAT) ); add("dungeon_loot", DUNGEON_LOOT.get(), new DungeonLootEnhancerModifier( - new ILootCondition[] { LootTableIdCondition.builder(new ResourceLocation("chests/simple_dungeon")).build() }) + new LootItemCondition[] { LootTableIdCondition.builder(new ResourceLocation("chests/simple_dungeon")).build() }) ); } } private static class SmelterEnchantment extends Enchantment { - protected SmelterEnchantment(Rarity rarityIn, EnchantmentType typeIn, EquipmentSlotType... slots) { + protected SmelterEnchantment(Rarity rarityIn, EnchantmentCategory typeIn, EquipmentSlot... slots) { super(rarityIn, typeIn, slots); } } @@ -144,7 +143,7 @@ public class GlobalLootModifiersTest { * */ private static class SmeltingEnchantmentModifier extends LootModifier { - public SmeltingEnchantmentModifier(ILootCondition[] conditionsIn) { + public SmeltingEnchantmentModifier(LootItemCondition[] conditionsIn) { super(conditionsIn); } @@ -157,8 +156,8 @@ public class GlobalLootModifiersTest { } private static ItemStack smelt(ItemStack stack, LootContext context) { - return context.getLevel().getRecipeManager().getRecipeFor(IRecipeType.SMELTING, new Inventory(stack), context.getLevel()) - .map(FurnaceRecipe::getResultItem) + return context.getLevel().getRecipeManager().getRecipeFor(RecipeType.SMELTING, new SimpleContainer(stack), context.getLevel()) + .map(SmeltingRecipe::getResultItem) .filter(itemStack -> !itemStack.isEmpty()) .map(itemStack -> ItemHandlerHelper.copyStackWithSize(itemStack, stack.getCount() * itemStack.getCount())) .orElse(stack); @@ -166,7 +165,7 @@ public class GlobalLootModifiersTest { private static class Serializer extends GlobalLootModifierSerializer { @Override - public SmeltingEnchantmentModifier read(ResourceLocation name, JsonObject json, ILootCondition[] conditionsIn) { + public SmeltingEnchantmentModifier read(ResourceLocation name, JsonObject json, LootItemCondition[] conditionsIn) { return new SmeltingEnchantmentModifier(conditionsIn); } @@ -182,28 +181,28 @@ public class GlobalLootModifiersTest { * */ private static class SilkTouchTestModifier extends LootModifier { - public SilkTouchTestModifier(ILootCondition[] conditionsIn) { + public SilkTouchTestModifier(LootItemCondition[] conditionsIn) { super(conditionsIn); } @Nonnull @Override public List doApply(List generatedLoot, LootContext context) { - ItemStack ctxTool = context.getParamOrNull(LootParameters.TOOL); + ItemStack ctxTool = context.getParamOrNull(LootContextParams.TOOL); //return early if silk-touch is already applied (otherwise we'll get stuck in an infinite loop). if(EnchantmentHelper.getEnchantments(ctxTool).containsKey(Enchantments.SILK_TOUCH)) return generatedLoot; ItemStack fakeTool = ctxTool.copy(); fakeTool.enchant(Enchantments.SILK_TOUCH, 1); LootContext.Builder builder = new LootContext.Builder(context); - builder.withParameter(LootParameters.TOOL, fakeTool); - LootContext ctx = builder.create(LootParameterSets.BLOCK); - LootTable loottable = context.getLevel().getServer().getLootTables().get(context.getParamOrNull(LootParameters.BLOCK_STATE).getBlock().getLootTable()); + builder.withParameter(LootContextParams.TOOL, fakeTool); + LootContext ctx = builder.create(LootContextParamSets.BLOCK); + LootTable loottable = context.getLevel().getServer().getLootTables().get(context.getParamOrNull(LootContextParams.BLOCK_STATE).getBlock().getLootTable()); return loottable.getRandomItems(ctx); } private static class Serializer extends GlobalLootModifierSerializer { @Override - public SilkTouchTestModifier read(ResourceLocation name, JsonObject json, ILootCondition[] conditionsIn) { + public SilkTouchTestModifier read(ResourceLocation name, JsonObject json, LootItemCondition[] conditionsIn) { return new SilkTouchTestModifier(conditionsIn); } @@ -223,7 +222,7 @@ public class GlobalLootModifiersTest { private final int numSeedsToConvert; private final Item itemToCheck; private final Item itemReward; - public WheatSeedsConverterModifier(ILootCondition[] conditionsIn, int numSeeds, Item itemCheck, Item reward) { + public WheatSeedsConverterModifier(LootItemCondition[] conditionsIn, int numSeeds, Item itemCheck, Item reward) { super(conditionsIn); numSeedsToConvert = numSeeds; itemToCheck = itemCheck; @@ -255,10 +254,10 @@ public class GlobalLootModifiersTest { private static class Serializer extends GlobalLootModifierSerializer { @Override - public WheatSeedsConverterModifier read(ResourceLocation name, JsonObject object, ILootCondition[] conditionsIn) { - int numSeeds = JSONUtils.getAsInt(object, "numSeeds"); - Item seed = ForgeRegistries.ITEMS.getValue(new ResourceLocation((JSONUtils.getAsString(object, "seedItem")))); - Item wheat = ForgeRegistries.ITEMS.getValue(new ResourceLocation(JSONUtils.getAsString(object, "replacement"))); + public WheatSeedsConverterModifier read(ResourceLocation name, JsonObject object, LootItemCondition[] conditionsIn) { + int numSeeds = GsonHelper.getAsInt(object, "numSeeds"); + Item seed = ForgeRegistries.ITEMS.getValue(new ResourceLocation((GsonHelper.getAsString(object, "seedItem")))); + Item wheat = ForgeRegistries.ITEMS.getValue(new ResourceLocation(GsonHelper.getAsString(object, "replacement"))); return new WheatSeedsConverterModifier(conditionsIn, numSeeds, seed, wheat); } @@ -276,12 +275,12 @@ public class GlobalLootModifiersTest { private static class DungeonLootEnhancerModifier extends LootModifier { private final int multiplicationFactor; - public DungeonLootEnhancerModifier(final ILootCondition[] conditionsIn, final int multiplicationFactor) { + public DungeonLootEnhancerModifier(final LootItemCondition[] conditionsIn, final int multiplicationFactor) { super(conditionsIn); this.multiplicationFactor = multiplicationFactor; } - public DungeonLootEnhancerModifier(final ILootCondition[] conditionsIn) { + public DungeonLootEnhancerModifier(final LootItemCondition[] conditionsIn) { this(conditionsIn, 2); } @@ -295,8 +294,8 @@ public class GlobalLootModifiersTest { private static class Serializer extends GlobalLootModifierSerializer { @Override - public DungeonLootEnhancerModifier read(ResourceLocation location, JsonObject object, ILootCondition[] conditions) { - final int multiplicationFactor = JSONUtils.getAsInt(object, "multiplication_factor", 2); + public DungeonLootEnhancerModifier read(ResourceLocation location, JsonObject object, LootItemCondition[] conditions) { + final int multiplicationFactor = GsonHelper.getAsInt(object, "multiplication_factor", 2); if (multiplicationFactor <= 0) throw new JsonParseException("Unable to set a multiplication factor to a number lower than 1"); return new DungeonLootEnhancerModifier(conditions, multiplicationFactor); } diff --git a/src/test/java/net/minecraftforge/debug/gameplay/loot/package-info.java b/src/test/java/net/minecraftforge/debug/gameplay/loot/package-info.java index 5204a368e5..dc1eaf0227 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/loot/package-info.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/loot/package-info.java @@ -22,4 +22,4 @@ package net.minecraftforge.debug.gameplay.loot; import javax.annotation.ParametersAreNonnullByDefault; -import mcp.MethodsReturnNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; diff --git a/src/test/java/net/minecraftforge/debug/item/CustomElytraTest.java b/src/test/java/net/minecraftforge/debug/item/CustomElytraTest.java index ef602f4021..f706a4690d 100644 --- a/src/test/java/net/minecraftforge/debug/item/CustomElytraTest.java +++ b/src/test/java/net/minecraftforge/debug/item/CustomElytraTest.java @@ -19,20 +19,21 @@ package net.minecraftforge.debug.item; -import net.minecraft.block.DispenserBlock; +import net.minecraft.client.model.geom.EntityModelSet; +import net.minecraft.client.renderer.entity.LivingEntityRenderer; +import net.minecraft.world.level.block.DispenserBlock; import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.player.AbstractClientPlayerEntity; -import net.minecraft.client.renderer.entity.IEntityRenderer; +import net.minecraft.client.player.AbstractClientPlayer; +import net.minecraft.client.renderer.entity.RenderLayerParent; import net.minecraft.client.renderer.entity.layers.ElytraLayer; -import net.minecraft.client.renderer.entity.model.PlayerModel; -import net.minecraft.entity.LivingEntity; -import net.minecraft.inventory.EquipmentSlotType; -import net.minecraft.item.*; -import net.minecraft.util.ResourceLocation; +import net.minecraft.client.model.PlayerModel; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fml.RegistryObject; +import net.minecraftforge.fmllegacy.RegistryObject; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; @@ -41,7 +42,12 @@ import net.minecraftforge.registries.ForgeRegistries; import javax.annotation.Nullable; -import net.minecraft.item.Item.Properties; +import net.minecraft.world.item.Item.Properties; + +import net.minecraft.world.item.ArmorItem; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; @Mod(CustomElytraTest.MOD_ID) @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, modid = CustomElytraTest.MOD_ID) @@ -49,7 +55,7 @@ public class CustomElytraTest { public static final String MOD_ID = "custom_elytra_test"; private static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MOD_ID); - private static final RegistryObject TEST_ELYTRA = ITEMS.register("test_elytra",() -> new CustomElytra(new Item.Properties().durability(100).tab(ItemGroup.TAB_MISC))); + private static final RegistryObject TEST_ELYTRA = ITEMS.register("test_elytra",() -> new CustomElytra(new Properties().durability(100).tab(CreativeModeTab.TAB_MISC))); public CustomElytraTest() { @@ -63,10 +69,13 @@ public class CustomElytraTest registerElytraLayer(); } + @SuppressWarnings({"unchecked", "rawtypes"}) @OnlyIn(Dist.CLIENT) private void registerElytraLayer() { - Minecraft.getInstance().getEntityRenderDispatcher().getSkinMap().values().forEach(player -> player.addLayer(new CustomElytraLayer(player))); + Minecraft mc = Minecraft.getInstance(); + mc.getEntityRenderDispatcher().getSkinMap().values() + .forEach(player -> ((LivingEntityRenderer) player).addLayer(new CustomElytraLayer((LivingEntityRenderer) player, mc.getEntityModels()))); } public static class CustomElytra extends Item @@ -80,9 +89,9 @@ public class CustomElytraTest @Nullable @Override - public EquipmentSlotType getEquipmentSlot(ItemStack stack) + public EquipmentSlot getEquipmentSlot(ItemStack stack) { - return EquipmentSlotType.CHEST; //Or you could just extend ItemArmor + return EquipmentSlot.CHEST; //Or you could just extend ItemArmor } @Override @@ -97,30 +106,30 @@ public class CustomElytraTest //Adding 1 to ticksElytraFlying prevents damage on the very first tick. if (!entity.level.isClientSide && (flightTicks + 1) % 20 == 0) { - stack.hurtAndBreak(1, entity, e -> e.broadcastBreakEvent(EquipmentSlotType.CHEST)); + stack.hurtAndBreak(1, entity, e -> e.broadcastBreakEvent(EquipmentSlot.CHEST)); } return true; } } @OnlyIn(Dist.CLIENT) - public static class CustomElytraLayer extends ElytraLayer> + public static class CustomElytraLayer extends ElytraLayer> { private static final ResourceLocation TEXTURE_ELYTRA = new ResourceLocation(MOD_ID, "textures/entity/custom_elytra.png"); - public CustomElytraLayer(IEntityRenderer> rendererIn) + public CustomElytraLayer(RenderLayerParent> renderer, EntityModelSet modelSet) { - super(rendererIn); + super(renderer, modelSet); } @Override - public boolean shouldRender(ItemStack stack, AbstractClientPlayerEntity entity) + public boolean shouldRender(ItemStack stack, AbstractClientPlayer entity) { return stack.getItem() == TEST_ELYTRA.get(); } @Override - public ResourceLocation getElytraTexture(ItemStack stack, AbstractClientPlayerEntity entity) + public ResourceLocation getElytraTexture(ItemStack stack, AbstractClientPlayer entity) { return TEXTURE_ELYTRA; } diff --git a/src/test/java/net/minecraftforge/debug/item/EnderMaskTest.java b/src/test/java/net/minecraftforge/debug/item/EnderMaskTest.java index 949f4625e8..3f21cfdef0 100644 --- a/src/test/java/net/minecraftforge/debug/item/EnderMaskTest.java +++ b/src/test/java/net/minecraftforge/debug/item/EnderMaskTest.java @@ -19,17 +19,22 @@ package net.minecraftforge.debug.item; -import net.minecraft.entity.monster.EndermanEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.inventory.EquipmentSlotType; -import net.minecraft.item.*; +import net.minecraft.world.entity.monster.EnderMan; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.EquipmentSlot; import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fml.RegistryObject; +import net.minecraftforge.fmllegacy.RegistryObject; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; +import net.minecraft.world.item.ArmorItem; +import net.minecraft.world.item.ArmorMaterials; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; + @Mod(EnderMaskTest.MODID) public class EnderMaskTest { @@ -37,10 +42,10 @@ public class EnderMaskTest public static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID); public static RegistryObject ender_mask = ITEMS.register("ender_mask", () -> - new ArmorItem(ArmorMaterial.LEATHER, EquipmentSlotType.HEAD, (new Item.Properties().tab(ItemGroup.TAB_MISC))) + new ArmorItem(ArmorMaterials.LEATHER, EquipmentSlot.HEAD, (new Item.Properties().tab(CreativeModeTab.TAB_MISC))) { @Override - public boolean isEnderMask(ItemStack stack, PlayerEntity player, EndermanEntity endermanEntity) + public boolean isEnderMask(ItemStack stack, Player player, EnderMan endermanEntity) { return player.experienceLevel > 10; } diff --git a/src/test/java/net/minecraftforge/debug/item/ItemAttributeModifierTest.java b/src/test/java/net/minecraftforge/debug/item/ItemAttributeModifierTest.java index 581b8a82a9..97c055738b 100644 --- a/src/test/java/net/minecraftforge/debug/item/ItemAttributeModifierTest.java +++ b/src/test/java/net/minecraftforge/debug/item/ItemAttributeModifierTest.java @@ -19,12 +19,12 @@ package net.minecraftforge.debug.item; -import net.minecraft.entity.ai.attributes.AttributeModifier; -import net.minecraft.entity.ai.attributes.AttributeModifier.Operation; -import net.minecraft.entity.ai.attributes.Attributes; -import net.minecraft.inventory.EquipmentSlotType; -import net.minecraft.item.Item; -import net.minecraft.item.Items; +import net.minecraft.world.entity.ai.attributes.AttributeModifier; +import net.minecraft.world.entity.ai.attributes.AttributeModifier.Operation; +import net.minecraft.world.entity.ai.attributes.Attributes; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.Items; import net.minecraftforge.event.ItemAttributeModifierEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; @@ -40,7 +40,7 @@ public class ItemAttributeModifierTest @SubscribeEvent public static void onItemAttribute(ItemAttributeModifierEvent event) { - if (ENABLED && event.getSlotType() == EquipmentSlotType.MAINHAND) + if (ENABLED && event.getSlotType() == EquipmentSlot.MAINHAND) { final Item item = event.getItemStack().getItem(); if (item == Items.APPLE) diff --git a/src/test/java/net/minecraftforge/debug/item/MusicDiscTest.java b/src/test/java/net/minecraftforge/debug/item/MusicDiscTest.java index f57080b67b..3dddba07da 100644 --- a/src/test/java/net/minecraftforge/debug/item/MusicDiscTest.java +++ b/src/test/java/net/minecraftforge/debug/item/MusicDiscTest.java @@ -19,13 +19,13 @@ package net.minecraftforge.debug.item; -import net.minecraft.item.Item; -import net.minecraft.item.MusicDiscItem; -import net.minecraft.item.Rarity; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.SoundEvent; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.RecordItem; +import net.minecraft.world.item.Rarity; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.sounds.SoundEvent; import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fml.RegistryObject; +import net.minecraftforge.fmllegacy.RegistryObject; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.DeferredRegister; @@ -44,7 +44,7 @@ public class MusicDiscTest () -> new SoundEvent(new ResourceLocation(MOD_ID, "test_sound_event"))); private static final RegistryObject TEST_MUSIC_DISC = ITEMS.register("test_music_disc", - () -> new MusicDiscItem(1, TEST_SOUND_EVENT, new Item.Properties().stacksTo(1).rarity(Rarity.EPIC))); + () -> new RecordItem(1, TEST_SOUND_EVENT, new Item.Properties().stacksTo(1).rarity(Rarity.EPIC))); public MusicDiscTest() { diff --git a/src/test/java/net/minecraftforge/debug/item/RangedMobsUseModdedWeaponsTest.java b/src/test/java/net/minecraftforge/debug/item/RangedMobsUseModdedWeaponsTest.java index db886b4e6a..3ec8604e1c 100644 --- a/src/test/java/net/minecraftforge/debug/item/RangedMobsUseModdedWeaponsTest.java +++ b/src/test/java/net/minecraftforge/debug/item/RangedMobsUseModdedWeaponsTest.java @@ -19,25 +19,28 @@ package net.minecraftforge.debug.item; -import net.minecraft.item.*; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.client.renderer.item.ItemProperties; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.BowItem; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.CrossbowItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.Items; import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fml.RegistryObject; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.fmllegacy.RegistryObject; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; @Mod(RangedMobsUseModdedWeaponsTest.MOD_ID) public class RangedMobsUseModdedWeaponsTest { - //Testing if the new alternative for ProjectileHelper.getWeaponHoldingHand works for vanilla mobs - // as well as replacing their usages of LivingEntity#isHolding(Item) with LivingEntity#isHolding(Predicate) + // Skeletons and Illusioners should be able to use the modded bow. + // Piglins and Pillagers should be able to use the modded crossbow. public static final boolean ENABLE = true; @@ -45,10 +48,10 @@ public class RangedMobsUseModdedWeaponsTest { private static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MOD_ID); private static final RegistryObject MODDED_BOW = ITEMS.register("modded_bow", () -> - new BowItem(new Item.Properties().tab(ItemGroup.TAB_COMBAT).defaultDurability(384)) + new BowItem(new Item.Properties().tab(CreativeModeTab.TAB_COMBAT).defaultDurability(384)) ); private static final RegistryObject MODDED_CROSSBOW = ITEMS.register("modded_crossbow", () -> - new CrossbowItem(new Item.Properties().tab(ItemGroup.TAB_COMBAT).defaultDurability(326)) + new CrossbowItem(new Item.Properties().tab(CreativeModeTab.TAB_COMBAT).defaultDurability(326)) ); public RangedMobsUseModdedWeaponsTest() @@ -70,7 +73,7 @@ public class RangedMobsUseModdedWeaponsTest { { static void initBowModelProperties() { - ItemModelsProperties.register(MODDED_BOW.get(), new ResourceLocation("pull"), (itemStack, clientWorld, livingEntity) -> { + ItemProperties.register(MODDED_BOW.get(), new ResourceLocation("pull"), (itemStack, clientWorld, livingEntity, seed) -> { if (livingEntity == null) { return 0.0F; @@ -78,12 +81,12 @@ public class RangedMobsUseModdedWeaponsTest { return livingEntity.getUseItem() != itemStack ? 0.0F : (float)(itemStack.getUseDuration() - livingEntity.getUseItemRemainingTicks()) / 20.0F; } }); - ItemModelsProperties.register(MODDED_BOW.get(), new ResourceLocation("pulling"), (itemStack, clientWorld, livingEntity) -> livingEntity != null && livingEntity.isUsingItem() && livingEntity.getUseItem() == itemStack ? 1.0F : 0.0F); + ItemProperties.register(MODDED_BOW.get(), new ResourceLocation("pulling"), (itemStack, clientWorld, livingEntity, seed) -> livingEntity != null && livingEntity.isUsingItem() && livingEntity.getUseItem() == itemStack ? 1.0F : 0.0F); } static void initCrossbowModelProperties() { - ItemModelsProperties.register(MODDED_CROSSBOW.get(), new ResourceLocation("pull"), (itemStack, clientWorld, livingEntity) -> { + ItemProperties.register(MODDED_CROSSBOW.get(), new ResourceLocation("pull"), (itemStack, clientWorld, livingEntity, seed) -> { if (livingEntity == null) { return 0.0F; @@ -91,9 +94,9 @@ public class RangedMobsUseModdedWeaponsTest { return CrossbowItem.isCharged(itemStack) ? 0.0F : (float)(itemStack.getUseDuration() - livingEntity.getUseItemRemainingTicks()) / (float)CrossbowItem.getChargeDuration(itemStack); } }); - ItemModelsProperties.register(MODDED_CROSSBOW.get(), new ResourceLocation("pulling"), (itemStack, clientWorld, livingEntity) -> livingEntity != null && livingEntity.isUsingItem() && livingEntity.getUseItem() == itemStack && !CrossbowItem.isCharged(itemStack) ? 1.0F : 0.0F); - ItemModelsProperties.register(MODDED_CROSSBOW.get(), new ResourceLocation("charged"), (itemStack, clientWorld, livingEntity) -> livingEntity != null && CrossbowItem.isCharged(itemStack) ? 1.0F : 0.0F); - ItemModelsProperties.register(MODDED_CROSSBOW.get(), new ResourceLocation("firework"), (itemStack, clientWorld, livingEntity) -> livingEntity != null && CrossbowItem.isCharged(itemStack) && CrossbowItem.containsChargedProjectile(itemStack, Items.FIREWORK_ROCKET) ? 1.0F : 0.0F); + ItemProperties.register(MODDED_CROSSBOW.get(), new ResourceLocation("pulling"), (itemStack, clientWorld, livingEntity, seed) -> livingEntity != null && livingEntity.isUsingItem() && livingEntity.getUseItem() == itemStack && !CrossbowItem.isCharged(itemStack) ? 1.0F : 0.0F); + ItemProperties.register(MODDED_CROSSBOW.get(), new ResourceLocation("charged"), (itemStack, clientWorld, livingEntity, seed) -> livingEntity != null && CrossbowItem.isCharged(itemStack) ? 1.0F : 0.0F); + ItemProperties.register(MODDED_CROSSBOW.get(), new ResourceLocation("firework"), (itemStack, clientWorld, livingEntity, seed) -> livingEntity != null && CrossbowItem.isCharged(itemStack) && CrossbowItem.containsChargedProjectile(itemStack, Items.FIREWORK_ROCKET) ? 1.0F : 0.0F); } } } \ No newline at end of file diff --git a/src/test/java/net/minecraftforge/debug/item/package-info.java b/src/test/java/net/minecraftforge/debug/item/package-info.java index c63f11140a..c9eb936b20 100644 --- a/src/test/java/net/minecraftforge/debug/item/package-info.java +++ b/src/test/java/net/minecraftforge/debug/item/package-info.java @@ -22,4 +22,4 @@ package net.minecraftforge.debug.item; import javax.annotation.ParametersAreNonnullByDefault; -import mcp.MethodsReturnNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; diff --git a/src/test/java/net/minecraftforge/debug/misc/ContainerTypeTest.java b/src/test/java/net/minecraftforge/debug/misc/ContainerTypeTest.java index 05eda0367d..7f6fbf7609 100644 --- a/src/test/java/net/minecraftforge/debug/misc/ContainerTypeTest.java +++ b/src/test/java/net/minecraftforge/debug/misc/ContainerTypeTest.java @@ -19,24 +19,24 @@ package net.minecraftforge.debug.misc; -import com.mojang.blaze3d.matrix.MatrixStack; -import net.minecraft.block.Blocks; -import net.minecraft.client.gui.ScreenManager; -import net.minecraft.client.gui.screen.inventory.ContainerScreen; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.inventory.Inventory; -import net.minecraft.inventory.container.Container; -import net.minecraft.inventory.container.ContainerType; -import net.minecraft.inventory.container.INamedContainerProvider; -import net.minecraft.inventory.container.Slot; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.Hand; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; +import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.client.gui.screens.MenuScreens; +import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.SimpleContainer; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.MenuProvider; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.InteractionHand; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.extensions.IForgeContainerType; import net.minecraftforge.event.RegistryEvent; @@ -44,24 +44,24 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.fml.network.NetworkHooks; +import net.minecraftforge.fmllegacy.network.NetworkHooks; import net.minecraftforge.registries.ObjectHolder; @Mod("containertypetest") public class ContainerTypeTest { @ObjectHolder("containertypetest:container") - public static final ContainerType TYPE = null; - public class TestContainer extends Container + public static final MenuType TYPE = null; + public class TestContainer extends AbstractContainerMenu { private final String text; - protected TestContainer(int windowId, PlayerInventory playerInv, PacketBuffer extraData) + protected TestContainer(int windowId, Inventory playerInv, FriendlyByteBuf extraData) { - this(windowId, new Inventory(9), extraData.readUtf(128)); + this(windowId, new SimpleContainer(9), extraData.readUtf(128)); } - public TestContainer(int windowId, Inventory inv, String text) + public TestContainer(int windowId, SimpleContainer inv, String text) { super(TYPE, windowId); this.text = text; @@ -72,21 +72,21 @@ public class ContainerTypeTest } @Override - public boolean stillValid(PlayerEntity playerIn) + public boolean stillValid(Player playerIn) { return true; } } - public class TestGui extends ContainerScreen + public class TestGui extends AbstractContainerScreen { - public TestGui(TestContainer container, PlayerInventory inv, ITextComponent name) + public TestGui(TestContainer container, Inventory inv, Component name) { super(container, inv, name); } @Override - protected void renderBg(MatrixStack mStack, float partialTicks, int mouseX, int mouseY) + protected void renderBg(PoseStack mStack, float partialTicks, int mouseX, int mouseY) { drawString(mStack, this.font, getMenu().text, mouseX, mouseY, -1); } @@ -94,34 +94,34 @@ public class ContainerTypeTest public ContainerTypeTest() { - FMLJavaModLoadingContext.get().getModEventBus().addGenericListener(ContainerType.class, this::registerContainers); + FMLJavaModLoadingContext.get().getModEventBus().addGenericListener(MenuType.class, this::registerContainers); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); MinecraftForge.EVENT_BUS.addListener(this::onRightClick); } - private void registerContainers(final RegistryEvent.Register> event) + private void registerContainers(final RegistryEvent.Register> event) { event.getRegistry().register(IForgeContainerType.create(TestContainer::new).setRegistryName("container")); } private void setup(FMLClientSetupEvent event) { - ScreenManager.register(TYPE, TestGui::new); + MenuScreens.register(TYPE, TestGui::new); } private void onRightClick(PlayerInteractEvent.RightClickBlock event) { - if (!event.getWorld().isClientSide && event.getHand() == Hand.MAIN_HAND) + if (!event.getWorld().isClientSide && event.getHand() == InteractionHand.MAIN_HAND) { if (event.getWorld().getBlockState(event.getPos()).getBlock() == Blocks.SPONGE) { String text = "Hello World!"; - NetworkHooks.openGui((ServerPlayerEntity) event.getPlayer(), new INamedContainerProvider() + NetworkHooks.openGui((ServerPlayer) event.getPlayer(), new MenuProvider() { @Override - public Container createMenu(int p_createMenu_1_, PlayerInventory p_createMenu_2_, PlayerEntity p_createMenu_3_) + public AbstractContainerMenu createMenu(int p_createMenu_1_, Inventory p_createMenu_2_, Player p_createMenu_3_) { - Inventory inv = new Inventory(9); + SimpleContainer inv = new SimpleContainer(9); for (int i = 0; i < inv.getContainerSize(); i++) { inv.setItem(i, new ItemStack(Items.DIAMOND)); @@ -130,9 +130,9 @@ public class ContainerTypeTest } @Override - public ITextComponent getDisplayName() + public Component getDisplayName() { - return new StringTextComponent("Test"); + return new TextComponent("Test"); } }, extraData -> { extraData.writeUtf(text); diff --git a/src/test/java/net/minecraftforge/debug/misc/CustomTagTypesTest.java b/src/test/java/net/minecraftforge/debug/misc/CustomTagTypesTest.java index 63dce3cdee..2b33295171 100644 --- a/src/test/java/net/minecraftforge/debug/misc/CustomTagTypesTest.java +++ b/src/test/java/net/minecraftforge/debug/misc/CustomTagTypesTest.java @@ -23,23 +23,24 @@ import com.google.common.collect.Sets; import java.util.Set; import java.util.function.Supplier; import javax.annotation.Nullable; +import net.minecraft.core.Registry; import net.minecraft.data.DataGenerator; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.enchantment.Enchantments; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.item.PotionItem; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionUtils; -import net.minecraft.potion.Potions; -import net.minecraft.tags.ITag; +import net.minecraft.world.item.enchantment.Enchantment; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.item.enchantment.Enchantments; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.PotionItem; +import net.minecraft.world.item.alchemy.Potion; +import net.minecraft.world.item.alchemy.PotionUtils; +import net.minecraft.world.item.alchemy.Potions; +import net.minecraft.tags.Tag; import net.minecraft.tags.ItemTags; -import net.minecraft.tags.TagCollectionManager; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.ResourceLocation; +import net.minecraft.tags.SerializationTags; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.common.ForgeTagHandler; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.data.ExistingFileHelper; @@ -47,9 +48,9 @@ import net.minecraftforge.common.data.ForgeRegistryTagsProvider; import net.minecraftforge.common.util.ReverseTagWrapper; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fml.RegistryObject; +import net.minecraftforge.fmllegacy.RegistryObject; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.event.lifecycle.GatherDataEvent; +import net.minecraftforge.forge.event.lifecycle.GatherDataEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; @@ -69,11 +70,11 @@ public class CustomTagTypesTest private static final RegistryObject CUSTOM = CUSTOMS.register("custom", Custom::new); private static final Supplier> CUSTOM_REG = CUSTOMS.makeRegistry(customRegistryName.getPath(), () -> new RegistryBuilder().tagFolder(MODID + "/custom_types")); - private static final ITag.INamedTag TESTS = ForgeTagHandler.createOptionalTag(customRegistryName, new ResourceLocation(MODID, "tests"), Sets.newHashSet(CUSTOM)); - private static final ITag.INamedTag OPTIONAL_TEST = ItemTags.createOptional(new ResourceLocation(MODID, "optional_test"), Sets.newHashSet(() -> Items.BONE)); - private static final ITag.INamedTag FIRE = ForgeTagHandler.createOptionalTag(ForgeRegistries.ENCHANTMENTS, new ResourceLocation(MODID, "fire")); - private static final ITag.INamedTag DAMAGE = ForgeTagHandler.createOptionalTag(ForgeRegistries.POTION_TYPES, new ResourceLocation(MODID, "damage")); - private static final ITag.INamedTag> STORAGE = ForgeTagHandler.createOptionalTag(ForgeRegistries.TILE_ENTITIES, new ResourceLocation(MODID, "storage")); + private static final Tag.Named TESTS = ForgeTagHandler.createOptionalTag(customRegistryName, new ResourceLocation(MODID, "tests"), Sets.newHashSet(CUSTOM)); + private static final Tag.Named OPTIONAL_TEST = ItemTags.createOptional(new ResourceLocation(MODID, "optional_test"), Sets.newHashSet(() -> Items.BONE)); + private static final Tag.Named FIRE = ForgeTagHandler.createOptionalTag(ForgeRegistries.ENCHANTMENTS, new ResourceLocation(MODID, "fire")); + private static final Tag.Named DAMAGE = ForgeTagHandler.createOptionalTag(ForgeRegistries.POTION_TYPES, new ResourceLocation(MODID, "damage")); + private static final Tag.Named> STORAGE = ForgeTagHandler.createOptionalTag(ForgeRegistries.BLOCK_ENTITIES, new ResourceLocation(MODID, "storage")); public CustomTagTypesTest() { @@ -92,7 +93,7 @@ public class CustomTagTypesTest gen.addProvider(new CustomRegistryTags(gen, existingFileHelper)); gen.addProvider(new EnchantmentTags(gen, existingFileHelper)); gen.addProvider(new PotionTags(gen, existingFileHelper)); - gen.addProvider(new TileEntityTypeTags(gen, existingFileHelper)); + gen.addProvider(new BlockEntityTypeTags(gen, existingFileHelper)); } } @@ -101,11 +102,11 @@ public class CustomTagTypesTest ItemStack itemStack = event.getItemStack(); if (!itemStack.isEmpty()) { - LOGGER.info("{} {} {}", Items.BONE.getTags(), OPTIONAL_TEST.getValues().size(), TagCollectionManager.getInstance().getItems().getTag(new ResourceLocation(MODID, "optional_test"))); + LOGGER.info("{} {} {}", Items.BONE.getTags(), OPTIONAL_TEST.getValues().size(), SerializationTags.getInstance().getOrEmpty(Registry.ITEM_REGISTRY).getTag(new ResourceLocation(MODID, "optional_test"))); EnchantmentHelper.getEnchantments(itemStack).forEach((enchantment, level) -> logTagsIfPresent(enchantment.getTags())); if (itemStack.getItem() instanceof PotionItem) logTagsIfPresent(PotionUtils.getPotion(itemStack).getTags()); - TileEntity tileEntity = event.getWorld().getBlockEntity(event.getPos()); - if (tileEntity != null) logTagsIfPresent(tileEntity.getType().getTags()); + BlockEntity blockEntity = event.getWorld().getBlockEntity(event.getPos()); + if (blockEntity != null) logTagsIfPresent(blockEntity.getType().getTags()); } } @@ -119,14 +120,14 @@ public class CustomTagTypesTest public static class Custom extends ForgeRegistryEntry { - private final ReverseTagWrapper reverseTags = new ReverseTagWrapper<>(this, () -> TagCollectionManager.getInstance().getCustomTypeCollection(CUSTOM_REG.get())); + private final ReverseTagWrapper reverseTags = new ReverseTagWrapper<>(this, () -> SerializationTags.getInstance().getCustomTypeCollection(CUSTOM_REG.get())); public Set getTags() { return reverseTags.getTagNames(); } - public boolean isIn(ITag tag) + public boolean isIn(Tag tag) { return tag.contains(this); } @@ -192,17 +193,17 @@ public class CustomTagTypesTest } } - public static class TileEntityTypeTags extends ForgeRegistryTagsProvider> + public static class BlockEntityTypeTags extends ForgeRegistryTagsProvider> { - public TileEntityTypeTags(DataGenerator gen, @Nullable ExistingFileHelper existingFileHelper) + public BlockEntityTypeTags(DataGenerator gen, @Nullable ExistingFileHelper existingFileHelper) { - super(gen, ForgeRegistries.TILE_ENTITIES, MODID, existingFileHelper); + super(gen, ForgeRegistries.BLOCK_ENTITIES, MODID, existingFileHelper); } @Override protected void addTags() { - tag(STORAGE).add(TileEntityType.BARREL, TileEntityType.CHEST, TileEntityType.ENDER_CHEST); + tag(STORAGE).add(BlockEntityType.BARREL, BlockEntityType.CHEST, BlockEntityType.ENDER_CHEST); } @Override diff --git a/src/test/java/net/minecraftforge/debug/misc/FakePlayerTest.java b/src/test/java/net/minecraftforge/debug/misc/FakePlayerTest.java index 87a2e18a59..859e4924b5 100644 --- a/src/test/java/net/minecraftforge/debug/misc/FakePlayerTest.java +++ b/src/test/java/net/minecraftforge/debug/misc/FakePlayerTest.java @@ -19,12 +19,12 @@ package net.minecraftforge.debug.misc; -import net.minecraft.command.Commands; -import net.minecraft.command.arguments.EntityArgument; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.util.Hand; +import net.minecraft.commands.Commands; +import net.minecraft.commands.arguments.EntityArgument; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.FakePlayerFactory; import net.minecraftforge.event.RegisterCommandsEvent; @@ -57,8 +57,8 @@ public class FakePlayerTest //Makes sure fake player does not crash when its `connection` is accessed [#7604] .then(Commands.literal("opencontainer") .executes(context -> { - ServerPlayerEntity fakePlayer = FakePlayerFactory.getMinecraft(context.getSource().getLevel()); - Hand hand = Hand.MAIN_HAND; + ServerPlayer fakePlayer = FakePlayerFactory.getMinecraft(context.getSource().getLevel()); + InteractionHand hand = InteractionHand.MAIN_HAND; ItemStack stack = Items.WRITABLE_BOOK.getDefaultInstance(); fakePlayer.setItemInHand(hand, stack); fakePlayer.openItemGui(stack, hand); diff --git a/src/test/java/net/minecraftforge/debug/misc/package-info.java b/src/test/java/net/minecraftforge/debug/misc/package-info.java index 3e3d4fb4fb..999e05f1f4 100644 --- a/src/test/java/net/minecraftforge/debug/misc/package-info.java +++ b/src/test/java/net/minecraftforge/debug/misc/package-info.java @@ -22,4 +22,4 @@ package net.minecraftforge.debug.misc; import javax.annotation.ParametersAreNonnullByDefault; -import mcp.MethodsReturnNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; diff --git a/src/test/java/net/minecraftforge/debug/package-info.java b/src/test/java/net/minecraftforge/debug/package-info.java index c175c1734e..457448221f 100644 --- a/src/test/java/net/minecraftforge/debug/package-info.java +++ b/src/test/java/net/minecraftforge/debug/package-info.java @@ -21,6 +21,5 @@ @MethodsReturnNonnullByDefault package net.minecraftforge.debug; -import mcp.MethodsReturnNonnullByDefault; - import javax.annotation.ParametersAreNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; diff --git a/src/test/java/net/minecraftforge/debug/world/BiomeLoadingEventTest.java b/src/test/java/net/minecraftforge/debug/world/BiomeLoadingEventTest.java index d61d030cc2..82c09e6b62 100644 --- a/src/test/java/net/minecraftforge/debug/world/BiomeLoadingEventTest.java +++ b/src/test/java/net/minecraftforge/debug/world/BiomeLoadingEventTest.java @@ -19,7 +19,7 @@ package net.minecraftforge.debug.world; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.world.BiomeLoadingEvent; import net.minecraftforge.fml.common.Mod; diff --git a/src/test/java/net/minecraftforge/debug/world/ChunkWatchEventTest.java b/src/test/java/net/minecraftforge/debug/world/ChunkWatchEventTest.java index 71ca145247..d174a26c02 100644 --- a/src/test/java/net/minecraftforge/debug/world/ChunkWatchEventTest.java +++ b/src/test/java/net/minecraftforge/debug/world/ChunkWatchEventTest.java @@ -21,8 +21,8 @@ package net.minecraftforge.debug.world; import it.unimi.dsi.fastutil.objects.Object2IntMap; import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.World; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.Level; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.world.ChunkWatchEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -75,7 +75,7 @@ public class ChunkWatchEventTest } @Nullable - private static ResourceLocation getDimensionName(World w) + private static ResourceLocation getDimensionName(Level w) { return w.dimension().location(); } diff --git a/src/test/java/net/minecraftforge/debug/world/DimensionSettingsTest.java b/src/test/java/net/minecraftforge/debug/world/DimensionSettingsTest.java index 62836530a1..9589bf9592 100644 --- a/src/test/java/net/minecraftforge/debug/world/DimensionSettingsTest.java +++ b/src/test/java/net/minecraftforge/debug/world/DimensionSettingsTest.java @@ -19,12 +19,13 @@ package net.minecraftforge.debug.world; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.registry.WorldGenRegistries; -import net.minecraft.world.gen.DimensionSettings; -import net.minecraft.world.gen.feature.structure.Structure; -import net.minecraft.world.gen.settings.DimensionStructuresSettings; -import net.minecraft.world.gen.settings.StructureSeparationSettings; +import com.sun.jna.Structure; +import net.minecraft.data.BuiltinRegistries; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.levelgen.NoiseGeneratorSettings; +import net.minecraft.world.level.levelgen.StructureSettings; +import net.minecraft.world.level.levelgen.feature.StructureFeature; +import net.minecraft.world.level.levelgen.feature.configurations.StructureFeatureConfiguration; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent; @@ -68,8 +69,8 @@ public class DimensionSettingsTest { event.enqueueWork(() -> { LOGGER.info("Registering custom DimensionSettings for Dimension: {}", TEST_OVERWORLD); - DimensionSettings dimensionSettings = createDimensionSettings(); - WorldGenRegistries.register(WorldGenRegistries.NOISE_GENERATOR_SETTINGS, TEST_OVERWORLD, dimensionSettings); + NoiseGeneratorSettings noiseGenSettings = createNoiseGenerationSettings(); + BuiltinRegistries.register(BuiltinRegistries.NOISE_GENERATOR_SETTINGS, TEST_OVERWORLD, noiseGenSettings); }); } @@ -80,33 +81,33 @@ public class DimensionSettingsTest { { event.enqueueWork(() -> { - StructureSeparationSettings settings = new StructureSeparationSettings(2, 1, 0); + StructureFeatureConfiguration config = new StructureFeatureConfiguration(2, 1, 0); - WorldGenRegistries.NOISE_GENERATOR_SETTINGS.entrySet().forEach(entry -> + BuiltinRegistries.NOISE_GENERATOR_SETTINGS.entrySet().forEach(entry -> { ResourceLocation dimensionName = entry.getKey().location(); // Example: blacklisting all vanilla dimensions if (dimensionName.getNamespace().equals("minecraft")) return; - LOGGER.info("Adding Structure: {} to Dimension: {}", Structure.RUINED_PORTAL.getFeatureName(), dimensionName); - entry.getValue().structureSettings().structureConfig().put(Structure.RUINED_PORTAL, settings); + LOGGER.info("Adding Structure: {} to Dimension: {}", StructureFeature.RUINED_PORTAL.getFeatureName(), dimensionName); + entry.getValue().structureSettings().structureConfig().put(StructureFeature.RUINED_PORTAL, config); }); }); } /** - * Create a DimensionSettings instance copying all but the structure settings from overworld. + * Create a NoiseGeneratorSettings instance copying all but the structure settings from overworld. */ - private static DimensionSettings createDimensionSettings() + private static NoiseGeneratorSettings createNoiseGenerationSettings() { - DimensionSettings overworld = WorldGenRegistries.NOISE_GENERATOR_SETTINGS.getOrThrow(DimensionSettings.OVERWORLD); + NoiseGeneratorSettings overworld = BuiltinRegistries.NOISE_GENERATOR_SETTINGS.getOrThrow(NoiseGeneratorSettings.OVERWORLD); - // Make a new DimensionStructuresSettings with no structures - DimensionStructuresSettings structures = new DimensionStructuresSettings(Optional.empty(), new HashMap<>()); + // Make a new StructureSettings with no structures + StructureSettings structures = new StructureSettings(Optional.empty(), new HashMap<>()); - // Build a new DimensionSettings copying all the other options from 'overworld' - return new DimensionSettings( + // Build a new NoiseGeneratorSettings copying all the other options from 'overworld' + return new NoiseGeneratorSettings( structures, overworld.noiseSettings(), overworld.getDefaultBlock(), @@ -114,6 +115,13 @@ public class DimensionSettingsTest { overworld.getBedrockRoofPosition(), overworld.getBedrockFloorPosition(), overworld.seaLevel(), - overworld.disableMobGeneration()); + overworld.getMinSurfaceLevel(), + overworld.disableMobGeneration(), + overworld.isAquifersEnabled(), + overworld.isNoiseCavesEnabled(), + overworld.isDeepslateEnabled(), + overworld.isOreVeinsEnabled(), + overworld.isNoodleCavesEnabled() + ); } } diff --git a/src/test/java/net/minecraftforge/debug/world/ForgeChunkManagerTest.java b/src/test/java/net/minecraftforge/debug/world/ForgeChunkManagerTest.java index 8ff5ae9dce..d3c47838fe 100644 --- a/src/test/java/net/minecraftforge/debug/world/ForgeChunkManagerTest.java +++ b/src/test/java/net/minecraftforge/debug/world/ForgeChunkManagerTest.java @@ -23,20 +23,20 @@ import com.mojang.datafixers.util.Pair; import it.unimi.dsi.fastutil.longs.LongSet; import java.util.Map; import java.util.UUID; -import net.minecraft.block.AbstractBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.material.Material; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.ChunkPos; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; + +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.Level; +import net.minecraft.server.level.ServerLevel; import net.minecraftforge.common.world.ForgeChunkManager; import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fml.RegistryObject; +import net.minecraftforge.fmllegacy.RegistryObject; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; @@ -45,7 +45,7 @@ import net.minecraftforge.registries.ForgeRegistries; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import net.minecraft.block.AbstractBlock.Properties; +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; @Mod(ForgeChunkManagerTest.MODID) public class ForgeChunkManagerTest @@ -54,8 +54,8 @@ public class ForgeChunkManagerTest private static final Logger LOGGER = LogManager.getLogger(MODID); private static final DeferredRegister BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID); private static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID); - private static final RegistryObject CHUNK_LOADER_BLOCK = BLOCKS.register("chunk_loader", () -> new ChunkLoaderBlock(AbstractBlock.Properties.of(Material.STONE))); - private static final RegistryObject CHUNK_LOADER_ITEM = ITEMS.register("chunk_loader", () -> new BlockItem(CHUNK_LOADER_BLOCK.get(), new Item.Properties().tab(ItemGroup.TAB_MISC))); + private static final RegistryObject CHUNK_LOADER_BLOCK = BLOCKS.register("chunk_loader", () -> new ChunkLoaderBlock(Properties.of(Material.STONE))); + private static final RegistryObject CHUNK_LOADER_ITEM = ITEMS.register("chunk_loader", () -> new BlockItem(CHUNK_LOADER_BLOCK.get(), new Item.Properties().tab(CreativeModeTab.TAB_MISC))); public ForgeChunkManagerTest() { @@ -100,24 +100,24 @@ public class ForgeChunkManagerTest } @Override - public void onPlace(BlockState state, World worldIn, BlockPos pos, BlockState oldState, boolean isMoving) + public void onPlace(BlockState state, Level worldIn, BlockPos pos, BlockState oldState, boolean isMoving) { super.onPlace(state, worldIn, pos, oldState, isMoving); - if (worldIn instanceof ServerWorld) + if (worldIn instanceof ServerLevel) { ChunkPos chunkPos = new ChunkPos(pos); - ForgeChunkManager.forceChunk((ServerWorld) worldIn, MODID, pos, chunkPos.x, chunkPos.z, true, false); + ForgeChunkManager.forceChunk((ServerLevel) worldIn, MODID, pos, chunkPos.x, chunkPos.z, true, false); } } @Deprecated - public void onRemove(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) + public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) { super.onRemove(state, worldIn, pos, newState, isMoving); - if (worldIn instanceof ServerWorld && !state.is(newState.getBlock())) + if (worldIn instanceof ServerLevel && !state.is(newState.getBlock())) { ChunkPos chunkPos = new ChunkPos(pos); - ForgeChunkManager.forceChunk((ServerWorld) worldIn, MODID, pos, chunkPos.x, chunkPos.z, false, false); + ForgeChunkManager.forceChunk((ServerLevel) worldIn, MODID, pos, chunkPos.x, chunkPos.z, false, false); } } } diff --git a/src/test/java/net/minecraftforge/debug/world/ForgeWorldTypeTest.java b/src/test/java/net/minecraftforge/debug/world/ForgeWorldTypeTest.java index 91c4ab8076..87f7a9a0ab 100644 --- a/src/test/java/net/minecraftforge/debug/world/ForgeWorldTypeTest.java +++ b/src/test/java/net/minecraftforge/debug/world/ForgeWorldTypeTest.java @@ -20,14 +20,14 @@ package net.minecraftforge.debug.world; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.gui.widget.button.Button; -import net.minecraft.util.registry.Registry; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.world.biome.Biome; -import net.minecraft.world.gen.ChunkGenerator; -import net.minecraft.world.gen.DimensionSettings; -import net.minecraft.world.gen.settings.DimensionGeneratorSettings; +import net.minecraft.client.gui.components.Button; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.core.Registry; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.world.level.biome.Biome; +import net.minecraft.world.level.chunk.ChunkGenerator; +import net.minecraft.world.level.levelgen.NoiseGeneratorSettings; +import net.minecraft.world.level.levelgen.WorldGenSettings; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.ForgeWorldTypeScreens; import net.minecraftforge.common.world.ForgeWorldType; @@ -53,16 +53,16 @@ public class ForgeWorldTypeTest private void registerWorldTypes(RegistryEvent.Register event) { event.getRegistry().registerAll( - new ForgeWorldType(DimensionGeneratorSettings::makeDefaultOverworld).setRegistryName("test_world_type") + new ForgeWorldType(WorldGenSettings::makeDefaultOverworld).setRegistryName("test_world_type") ); event.getRegistry().registerAll( new ForgeWorldType(this::createChunkGenerator).setRegistryName("test_world_type2") ); } - private ChunkGenerator createChunkGenerator(Registry biomes, Registry dimensionSettings, long seed, String settings) + private ChunkGenerator createChunkGenerator(Registry biomes, Registry dimensionSettings, long seed, String settings) { - return DimensionGeneratorSettings.makeDefaultOverworld(biomes, dimensionSettings, seed); + return WorldGenSettings.makeDefaultOverworld(biomes, dimensionSettings, seed); } @Mod.EventBusSubscriber(modid="forge_world_type_test", value=Dist.CLIENT, bus=Bus.MOD) @@ -78,7 +78,7 @@ public class ForgeWorldTypeTest { super.init(); - addButton(new Button(0, 0, 120, 20, new StringTextComponent("close"), btn -> { + addRenderableWidget(new Button(0, 0, 120, 20, new TextComponent("close"), btn -> { Minecraft.getInstance().setScreen(returnTo); })); } diff --git a/src/test/java/net/minecraftforge/debug/world/RaidEnumTest.java b/src/test/java/net/minecraftforge/debug/world/RaidEnumTest.java index 86fd148f67..76b664c725 100644 --- a/src/test/java/net/minecraftforge/debug/world/RaidEnumTest.java +++ b/src/test/java/net/minecraftforge/debug/world/RaidEnumTest.java @@ -19,8 +19,8 @@ package net.minecraftforge.debug.world; -import net.minecraft.entity.EntityType; -import net.minecraft.world.raid.Raid; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.raid.Raid; import net.minecraftforge.fml.common.Mod; @Mod("raid_enum_test") @@ -31,6 +31,6 @@ public class RaidEnumTest public RaidEnumTest() { if (ENABLE) - Raid.WaveMember.create("thebluemengroup", EntityType.ILLUSIONER, new int[]{0, 5, 0, 1, 0, 1, 0, 2}); + Raid.RaiderType.create("thebluemengroup", EntityType.ILLUSIONER, new int[]{0, 5, 0, 1, 0, 1, 0, 2}); } } diff --git a/src/test/java/net/minecraftforge/debug/world/StructureSpawnListGatherEventTest.java b/src/test/java/net/minecraftforge/debug/world/StructureSpawnListGatherEventTest.java index 92f8c612f4..2af6873dbe 100644 --- a/src/test/java/net/minecraftforge/debug/world/StructureSpawnListGatherEventTest.java +++ b/src/test/java/net/minecraftforge/debug/world/StructureSpawnListGatherEventTest.java @@ -19,10 +19,10 @@ package net.minecraftforge.debug.world; -import net.minecraft.entity.EntityClassification; -import net.minecraft.entity.EntityType; -import net.minecraft.world.biome.MobSpawnInfo; -import net.minecraft.world.gen.feature.structure.Structure; +import net.minecraft.world.entity.MobCategory; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.level.biome.MobSpawnSettings; +import net.minecraft.world.level.levelgen.feature.StructureFeature; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.world.StructureSpawnListGatherEvent; import net.minecraftforge.eventbus.api.EventPriority; @@ -44,15 +44,15 @@ public class StructureSpawnListGatherEventTest private void onStructureSpawnListGather(StructureSpawnListGatherEvent event) { - if (event.getStructure() == Structure.STRONGHOLD) + if (event.getStructure() == StructureFeature.STRONGHOLD) { - event.addEntitySpawn(EntityClassification.MONSTER, new MobSpawnInfo.Spawners(EntityType.WITHER_SKELETON, 100, 5, 15)); + event.addEntitySpawn(MobCategory.MONSTER, new MobSpawnSettings.SpawnerData(EntityType.WITHER_SKELETON, 100, 5, 15)); LOGGER.info("Adding wither skeleton spawns to strong holds"); } - else if (event.getStructure() == Structure.SHIPWRECK) + else if (event.getStructure() == StructureFeature.SHIPWRECK) { event.setInsideOnly(false); - event.addEntitySpawn(EntityClassification.MONSTER, new MobSpawnInfo.Spawners(EntityType.GUARDIAN, 100, 5, 15)); + event.addEntitySpawn(MobCategory.MONSTER, new MobSpawnSettings.SpawnerData(EntityType.GUARDIAN, 100, 5, 15)); LOGGER.info("Adding guardians spawns to shipwrecks"); } } diff --git a/src/test/java/net/minecraftforge/debug/world/WorldgenRegistryDesyncTest.java b/src/test/java/net/minecraftforge/debug/world/WorldgenRegistryDesyncTest.java index dea098f14a..faf03c6ddf 100644 --- a/src/test/java/net/minecraftforge/debug/world/WorldgenRegistryDesyncTest.java +++ b/src/test/java/net/minecraftforge/debug/world/WorldgenRegistryDesyncTest.java @@ -19,13 +19,13 @@ package net.minecraftforge.debug.world; -import net.minecraft.world.biome.Biome; -import net.minecraft.world.biome.BiomeMaker; -import net.minecraft.world.gen.feature.DungeonsFeature; -import net.minecraft.world.gen.feature.Feature; -import net.minecraft.world.gen.feature.NoFeatureConfig; +import net.minecraft.world.level.biome.Biome; +import net.minecraft.data.worldgen.biome.VanillaBiomes; +import net.minecraft.world.level.levelgen.feature.MonsterRoomFeature; +import net.minecraft.world.level.levelgen.feature.Feature; +import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration; import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fml.RegistryObject; +import net.minecraftforge.fmllegacy.RegistryObject; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.DeferredRegister; @@ -36,9 +36,9 @@ import net.minecraftforge.registries.ForgeRegistries; public class WorldgenRegistryDesyncTest { public static final DeferredRegister> FEATURES = DeferredRegister.create(ForgeRegistries.FEATURES, "worldgen_registry_desync_test"); - public static final RegistryObject> dungeon = FEATURES.register("dungeon", () -> new DungeonsFeature(NoFeatureConfig.CODEC)); + public static final RegistryObject> dungeon = FEATURES.register("dungeon", () -> new MonsterRoomFeature(NoneFeatureConfiguration.CODEC)); public static final DeferredRegister BIOMES = DeferredRegister.create(ForgeRegistries.BIOMES, "worldgen_registry_desync_test"); - public static final RegistryObject biome = BIOMES.register("biome", BiomeMaker::theVoidBiome); + public static final RegistryObject biome = BIOMES.register("biome", VanillaBiomes::theVoidBiome); public WorldgenRegistryDesyncTest() { diff --git a/src/test/java/net/minecraftforge/debug/world/package-info.java b/src/test/java/net/minecraftforge/debug/world/package-info.java index 0e8a1e8388..01526af83e 100644 --- a/src/test/java/net/minecraftforge/debug/world/package-info.java +++ b/src/test/java/net/minecraftforge/debug/world/package-info.java @@ -22,4 +22,4 @@ package net.minecraftforge.debug.world; import javax.annotation.ParametersAreNonnullByDefault; -import mcp.MethodsReturnNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; diff --git a/src/test/resources/META-INF/mods.toml b/src/test/resources/META-INF/mods.toml index f05369e8e8..8b79299800 100644 --- a/src/test/resources/META-INF/mods.toml +++ b/src/test/resources/META-INF/mods.toml @@ -138,3 +138,5 @@ license="LGPL v2.1" modId="dimension_settings_test" [[mods]] modId="player_attack_knockback_test" +[[mods]] + modId="overlay_layers_test" diff --git a/src/test/resources/assets/new_model_loader_test/blockstates/obj_block.json b/src/test/resources/assets/new_model_loader_test/blockstates/obj_block.json deleted file mode 100644 index f09b752a5d..0000000000 --- a/src/test/resources/assets/new_model_loader_test/blockstates/obj_block.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "variants": { - "facing=east": { "model": "new_model_loader_test:block/obj_block", "y": 90 }, - "facing=west": { "model": "new_model_loader_test:block/obj_block", "y": 270 }, - "facing=north": { "model": "new_model_loader_test:block/obj_block", "y": 0 }, - "facing=south": { "model": "new_model_loader_test:block/obj_block", "y": 180 } - } -} diff --git a/src/test/resources/assets/new_model_loader_test/models/block/obj_block.json b/src/test/resources/assets/new_model_loader_test/models/block/obj_block.json deleted file mode 100644 index 08465b0bad..0000000000 --- a/src/test/resources/assets/new_model_loader_test/models/block/obj_block.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "parent": "forge:item/default", - "loader": "forge:obj", - "model": "new_model_loader_test:models/item/sugar_glider.obj", - "ambientToFullbright": true, - "textures": { - "qr": "minecraft:block/oak_planks", - "particle": "block/oak_planks" - } -} diff --git a/src/test/resources/assets/new_model_loader_test/models/item/item_layers.json b/src/test/resources/assets/new_model_loader_test/models/item/item_layers.json deleted file mode 100644 index c052343d9b..0000000000 --- a/src/test/resources/assets/new_model_loader_test/models/item/item_layers.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "parent": "forge:item/default", - "loader": "forge:item-layers", - "textures": { - "layer0": "minecraft:item/coal", - "layer1": "minecraft:item/stick" - }, - "fullbright_layers": [ 1 ] -} \ No newline at end of file diff --git a/src/test/resources/assets/new_model_loader_test/models/item/separate_perspective.json b/src/test/resources/assets/new_model_loader_test/models/item/separate_perspective.json deleted file mode 100644 index df94f4e587..0000000000 --- a/src/test/resources/assets/new_model_loader_test/models/item/separate_perspective.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "parent":"forge:item/default", - "loader":"forge:separate-perspective", - "base": { - "parent": "minecraft:item/coal" - }, - "perspectives": { - "gui": { - "parent": "minecraft:item/snowball" - }, - "first_person_left_hand": { - "parent": "minecraft:item/bone" - } - } -} \ No newline at end of file diff --git a/src/test/resources/data/forge/loot_modifiers/global_loot_modifiers.json b/src/test/resources/data/forge/loot_modifiers/global_loot_modifiers.json deleted file mode 100644 index 84c06361c2..0000000000 --- a/src/test/resources/data/forge/loot_modifiers/global_loot_modifiers.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "replace": false, - "entries": [ - "global_loot_test:silk_touch_bamboo", - "global_loot_test:smelting", - "global_loot_test:wheat_harvest" - ] -} \ No newline at end of file diff --git a/src/test/resources/data/global_loot_test/loot_modifiers/smelting.json b/src/test/resources/data/global_loot_test/loot_modifiers/smelting.json deleted file mode 100644 index 09b17fd901..0000000000 --- a/src/test/resources/data/global_loot_test/loot_modifiers/smelting.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "type": "global_loot_test:smelting", - "conditions": [ - { - "condition": "minecraft:match_tool", - "predicate": { - "enchantments": [ - { - "enchantment": "global_loot_test:smelt", - "levels": { - "min": 1 - } - } - ] - } - } - ] -} \ No newline at end of file diff --git a/src/test/resources/data/global_loot_test/loot_modifiers/wheat_harvest.json b/src/test/resources/data/global_loot_test/loot_modifiers/wheat_harvest.json deleted file mode 100644 index 4f2491ed2e..0000000000 --- a/src/test/resources/data/global_loot_test/loot_modifiers/wheat_harvest.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "type": "global_loot_test:wheat_harvest", - "conditions": [ - { - "condition": "minecraft:match_tool", - "predicate": { - "item": "minecraft:shears" - } - }, - { - "condition": "block_state_property", - "block":"minecraft:wheat" - } - ], - "seedItem": "minecraft:wheat_seeds", - "numSeeds": 3, - "replacement": "minecraft:wheat" -} \ No newline at end of file diff --git a/src/userdev/java/net/minecraftforge/userdev/ClasspathLocator.java b/src/userdev/java/net/minecraftforge/userdev/ClasspathLocator.java deleted file mode 100644 index 4eaad8a8be..0000000000 --- a/src/userdev/java/net/minecraftforge/userdev/ClasspathLocator.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.userdev; - -import static net.minecraftforge.fml.loading.LogMarkers.CORE; - -import java.io.IOException; -import java.net.URL; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Enumeration; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.function.Predicate; -import java.util.stream.Collectors; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import com.google.common.base.Predicates; - -import net.minecraftforge.fml.loading.LibraryFinder; -import net.minecraftforge.fml.loading.moddiscovery.AbstractJarFileLocator; -import net.minecraftforge.fml.loading.moddiscovery.ModFile; -import net.minecraftforge.forgespi.locating.IModFile; - -public class ClasspathLocator extends AbstractJarFileLocator { - private static final Logger LOGGER = LogManager.getLogger(); - private static final String MODS_TOML = "META-INF/mods.toml"; - private static final String MANIFEST = "META-INF/MANIFEST.MF"; - private Set modCoords; - - @Override - public List scanMods() { - return modCoords.stream(). - map(mc -> ModFile.newFMLInstance(mc, this)). - peek(f->modJars.compute(f, (mf, fs)->createFileSystem(mf))). - collect(Collectors.toList()); - } - - @Override - public String name() { - return "userdev classpath"; - } - - @Override - public void initArguments(Map arguments) { - try { - modCoords = new LinkedHashSet<>(); - locateMods(MODS_TOML, "classpath_mod", Predicates.alwaysTrue()); - locateMods(MANIFEST, "manifest_jar", path -> findManifest(path).map(m -> m.getMainAttributes().getValue(ModFile.TYPE)).isPresent()); - } catch (IOException e) { - LOGGER.fatal(CORE,"Error trying to find resources", e); - throw new RuntimeException("wha?", e); - } - } - - private void locateMods(String resource, String name, Predicate filter) throws IOException { - final Enumeration modsTomls = ClassLoader.getSystemClassLoader().getResources(resource); - while (modsTomls.hasMoreElements()) { - URL url = modsTomls.nextElement(); - Path path = LibraryFinder.findJarPathFor(resource, name, url); - if (Files.isDirectory(path)) - continue; - - if (filter.test(path)) { - LOGGER.debug(CORE, "Found classpath mod: {}", path); - this.modCoords.add(path); - } - } - } -} diff --git a/src/userdev/java/net/minecraftforge/userdev/FMLDevClientLaunchProvider.java b/src/userdev/java/net/minecraftforge/userdev/FMLDevClientLaunchProvider.java deleted file mode 100644 index 421dd3eafd..0000000000 --- a/src/userdev/java/net/minecraftforge/userdev/FMLDevClientLaunchProvider.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.userdev; - -import cpw.mods.modlauncher.api.IEnvironment; -import cpw.mods.modlauncher.api.ILaunchHandlerService; -import cpw.mods.modlauncher.api.ITransformingClassLoader; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.fml.loading.FMLCommonLaunchHandler; -import net.minecraftforge.fml.loading.LibraryFinder; - -import org.apache.commons.lang3.tuple.Pair; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.concurrent.Callable; - -import static net.minecraftforge.fml.loading.LogMarkers.CORE; - -public class FMLDevClientLaunchProvider extends FMLCommonLaunchHandler implements ILaunchHandlerService -{ - - private static final Logger LOGGER = LogManager.getLogger(); - private Path compiledClasses; - private Path resources; - - @Override - public String name() - { - return "fmldevclient"; - } - - @Override - public Path getForgePath(final String mcVersion, final String forgeVersion, final String forgeGroup) { - // In forge dev, we just find the path for ForgeVersion for everything - compiledClasses = LibraryFinder.findJarPathFor("net/minecraftforge/versions/forge/ForgeVersion.class", "forge"); - resources = LibraryFinder.findJarPathFor("assets/minecraft/lang/en_us.json", "mcassets"); - return compiledClasses; - } - - @Override - public Path[] getMCPaths(final String mcVersion, final String mcpVersion, final String forgeVersion, final String forgeGroup) { - // In forge dev, we just find the path for ForgeVersion for everything - return new Path[] { compiledClasses, resources }; - } - - @Override - public Callable launchService(String[] arguments, ITransformingClassLoader launchClassLoader) - { - return () -> { - LOGGER.debug(CORE, "Launching minecraft in {} with arguments {}", launchClassLoader, arguments); - super.beforeStart(launchClassLoader); - launchClassLoader.addTargetPackageFilter(getPackagePredicate()); - Class.forName("net.minecraft.client.main.Main", true, launchClassLoader.getInstance()).getMethod("main", String[].class).invoke(null, (Object)arguments); - return null; - }; - } - - @SuppressWarnings("unchecked") - @Override - public void setup(IEnvironment environment, final Map arguments) - { - // we're injecting forge into the exploded dir finder - final Path forgemodstoml = LibraryFinder.findJarPathFor("META-INF/mods.toml", "forgemodstoml"); - ((Map>>>) arguments).computeIfAbsent("explodedTargets", a->new ArrayList<>()). - add(Pair.of(forgemodstoml, Collections.singletonList(compiledClasses))); - - processModClassesEnvironmentVariable((Map>>>) arguments); - } - - @Override - public Dist getDist() - { - return Dist.CLIENT; - } - - @Override - protected void validatePaths(final Path forgePath, final Path[] mcPaths, final String forgeVersion, final String mcVersion, final String mcpVersion) { - } - - @Override - protected String getNaming() { - return "mcp"; - } - -} diff --git a/src/userdev/java/net/minecraftforge/userdev/FMLDevDataLaunchProvider.java b/src/userdev/java/net/minecraftforge/userdev/FMLDevDataLaunchProvider.java deleted file mode 100644 index a54059c59c..0000000000 --- a/src/userdev/java/net/minecraftforge/userdev/FMLDevDataLaunchProvider.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.userdev; - -import cpw.mods.modlauncher.api.ILaunchHandlerService; -import cpw.mods.modlauncher.api.ITransformingClassLoader; -import net.minecraftforge.api.distmarker.Dist; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.util.concurrent.Callable; - -import static net.minecraftforge.fml.loading.LogMarkers.CORE; - -public class FMLDevDataLaunchProvider extends FMLDevServerLaunchProvider implements ILaunchHandlerService -{ - private static final Logger LOGGER = LogManager.getLogger(); - - @Override - public String name() - { - return "fmldevdata"; - } - - @Override - public Callable launchService(String[] arguments, ITransformingClassLoader launchClassLoader) - { - return () -> { - LOGGER.debug(CORE, "Launching minecraft in {} with arguments {}", launchClassLoader, arguments); - super.beforeStart(launchClassLoader); - launchClassLoader.addTargetPackageFilter(getPackagePredicate()); - Thread.currentThread().setContextClassLoader(launchClassLoader.getInstance()); - Class.forName("net.minecraft.data.Main", true, launchClassLoader.getInstance()).getMethod("main", String[].class).invoke(null, (Object)arguments); - return null; - }; - } - - @Override - public Dist getDist() - { - return Dist.CLIENT; - } - - @Override - protected String getNaming() { - return "mcp"; - } - - @Override - public boolean isData() { - return true; - } -} diff --git a/src/userdev/java/net/minecraftforge/userdev/FMLDevServerLaunchProvider.java b/src/userdev/java/net/minecraftforge/userdev/FMLDevServerLaunchProvider.java deleted file mode 100644 index acb97b180a..0000000000 --- a/src/userdev/java/net/minecraftforge/userdev/FMLDevServerLaunchProvider.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.userdev; - -import cpw.mods.modlauncher.api.IEnvironment; -import cpw.mods.modlauncher.api.ILaunchHandlerService; -import cpw.mods.modlauncher.api.ITransformingClassLoader; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.fml.loading.FMLCommonLaunchHandler; -import net.minecraftforge.fml.loading.LibraryFinder; - -import org.apache.commons.lang3.tuple.Pair; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.nio.file.Path; -import java.util.*; -import java.util.concurrent.Callable; - -import static net.minecraftforge.fml.loading.LogMarkers.CORE; - -public class FMLDevServerLaunchProvider extends FMLCommonLaunchHandler implements ILaunchHandlerService -{ - private static final Logger LOGGER = LogManager.getLogger(); - private Path compiledClasses; - private Path resources; - - @Override - public String name() - { - return "fmldevserver"; - } - - @Override - public Path getForgePath(final String mcVersion, final String forgeVersion, final String forgeGroup) { - // In forge dev, we just find the path for ForgeVersion for everything - compiledClasses = LibraryFinder.findJarPathFor("net/minecraftforge/versions/forge/ForgeVersion.class", "forge"); - resources = LibraryFinder.findJarPathFor("assets/minecraft/lang/en_us.json", "mcassets"); - return compiledClasses; - } - - @Override - public Path[] getMCPaths(final String mcVersion, final String mcpVersion, final String forgeVersion, final String forgeGroup) { - // In forge dev, we just find the path for ForgeVersion for everything - return new Path[] { compiledClasses, resources }; - } - - @Override - public Callable launchService(String[] arguments, ITransformingClassLoader launchClassLoader) - { - return () -> { - LOGGER.debug(CORE, "Launching minecraft in {} with arguments {}", launchClassLoader, arguments); - super.beforeStart(launchClassLoader); - launchClassLoader.addTargetPackageFilter(getPackagePredicate()); - Thread.currentThread().setContextClassLoader(launchClassLoader.getInstance()); - Class.forName("net.minecraft.server.Main", true, launchClassLoader.getInstance()).getMethod("main", String[].class).invoke(null, (Object)arguments); - return null; - }; - } - - @SuppressWarnings("unchecked") - @Override - public void setup(IEnvironment environment, final Map arguments) - { - // we're injecting forge into the exploded dir finder - final Path forgemodstoml = LibraryFinder.findJarPathFor("META-INF/mods.toml", "forgemodstoml"); - ((Map>>>) arguments).computeIfAbsent("explodedTargets", a->new ArrayList<>()). - add(Pair.of(forgemodstoml, Collections.singletonList(compiledClasses))); - - processModClassesEnvironmentVariable((Map>>>) arguments); - } - - @Override - public Dist getDist() - { - return Dist.DEDICATED_SERVER; - } - - @Override - protected String getNaming() { - return "mcp"; - } - -} diff --git a/src/userdev/java/net/minecraftforge/userdev/FMLUserdevClientLaunchProvider.java b/src/userdev/java/net/minecraftforge/userdev/FMLUserdevClientLaunchProvider.java deleted file mode 100644 index a68b5a7a01..0000000000 --- a/src/userdev/java/net/minecraftforge/userdev/FMLUserdevClientLaunchProvider.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.userdev; - -import cpw.mods.modlauncher.api.ILaunchHandlerService; -import cpw.mods.modlauncher.api.ITransformingClassLoader; -import net.minecraftforge.api.distmarker.Dist; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.util.concurrent.Callable; - -import static net.minecraftforge.fml.loading.LogMarkers.CORE; - -public class FMLUserdevClientLaunchProvider extends FMLUserdevLaunchProvider implements ILaunchHandlerService { - private static final Logger LOGGER = LogManager.getLogger(); - - @Override - public Dist getDist() { - return Dist.CLIENT; - } - - @Override - public String name() { - return "fmluserdevclient"; - } - - @Override - public Callable launchService(String[] arguments, ITransformingClassLoader launchClassLoader) - { - return () -> { - LOGGER.debug(CORE, "Launching minecraft in {} with arguments {}", launchClassLoader, arguments); - super.beforeStart(launchClassLoader); - launchClassLoader.addTargetPackageFilter(getPackagePredicate()); - Class.forName("net.minecraft.client.main.Main", true, launchClassLoader.getInstance()).getMethod("main", String[].class).invoke(null, (Object)arguments); - return null; - }; - } -} diff --git a/src/userdev/java/net/minecraftforge/userdev/FMLUserdevDataLaunchProvider.java b/src/userdev/java/net/minecraftforge/userdev/FMLUserdevDataLaunchProvider.java deleted file mode 100644 index 14108e7c0d..0000000000 --- a/src/userdev/java/net/minecraftforge/userdev/FMLUserdevDataLaunchProvider.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.userdev; - -import cpw.mods.modlauncher.api.ILaunchHandlerService; -import cpw.mods.modlauncher.api.ITransformingClassLoader; -import net.minecraftforge.api.distmarker.Dist; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.util.concurrent.Callable; - -import static net.minecraftforge.fml.loading.LogMarkers.CORE; - -public class FMLUserdevDataLaunchProvider extends FMLUserdevLaunchProvider implements ILaunchHandlerService -{ - private static final Logger LOGGER = LogManager.getLogger(); - - @Override - public String name() - { - return "fmluserdevdata"; - } - - @Override - public Callable launchService(String[] arguments, ITransformingClassLoader launchClassLoader) - { - return () -> { - LOGGER.debug(CORE, "Launching minecraft in {} with arguments {}", launchClassLoader, arguments); - super.beforeStart(launchClassLoader); - launchClassLoader.addTargetPackageFilter(getPackagePredicate()); - Thread.currentThread().setContextClassLoader(launchClassLoader.getInstance()); - Class.forName("net.minecraft.data.Main", true, launchClassLoader.getInstance()).getMethod("main", String[].class).invoke(null, (Object)arguments); - return null; - }; - } - - @Override - public Dist getDist() - { - return Dist.CLIENT; - } - - @Override - public boolean isData() { - return true; - } -} diff --git a/src/userdev/java/net/minecraftforge/userdev/FMLUserdevLaunchProvider.java b/src/userdev/java/net/minecraftforge/userdev/FMLUserdevLaunchProvider.java deleted file mode 100644 index ee07846f5d..0000000000 --- a/src/userdev/java/net/minecraftforge/userdev/FMLUserdevLaunchProvider.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.userdev; - -import cpw.mods.modlauncher.api.IEnvironment; -import net.minecraftforge.fml.loading.FMLCommonLaunchHandler; -import net.minecraftforge.fml.loading.LibraryFinder; -import org.apache.commons.lang3.tuple.Pair; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.net.URL; -import java.nio.file.Path; -import java.util.*; -import static net.minecraftforge.fml.loading.LogMarkers.CORE; - -public abstract class FMLUserdevLaunchProvider extends FMLCommonLaunchHandler { - private static final Logger LOGGER = LogManager.getLogger(); - private Path forgeJar; - private Path mcJars; - private static final String FORGE_VERSION_CLASS = "net/minecraftforge/versions/forge/ForgeVersion.class"; - - @Override - public Path getForgePath(final String mcVersion, final String forgeVersion, final String forgeGroup) { - final URL forgePath = getClass().getClassLoader().getResource(FORGE_VERSION_CLASS); - if (forgePath == null) { - LOGGER.fatal(CORE, "Unable to locate forge on the classpath"); - throw new RuntimeException("Unable to locate forge on the classpath"); - } - forgeJar = LibraryFinder.findJarPathFor(FORGE_VERSION_CLASS, "forge", forgePath); - return forgeJar; - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void setup(final IEnvironment environment, final Map arguments) { - if (!forgeJar.getFileName().toString().endsWith(".jar")) { - LOGGER.fatal(CORE, "Userdev Launcher attempted to be used with non-jar version of Forge: {}", forgeJar); - throw new RuntimeException("Userdev Launcher can only be used with dev-jar version of Forge"); - } - - final List mavenRoots = new ArrayList<>((List) arguments.get("mavenRoots")); - final String forgeGroup = (String) arguments.get("forgeGroup"); - int dirs = forgeGroup.split("\\.").length + 2; - - Path fjroot = forgeJar; - do { - fjroot = fjroot.getParent(); - } while (dirs-- > 0); - final String fjpath = fjroot.toString(); - mavenRoots.add(fjpath); - LOGGER.debug(CORE, "Injecting maven path {}", fjpath); - - processModClassesEnvironmentVariable((Map>>>) arguments); - - // generics are gross yea? - ((Map)arguments).put("mavenRoots", mavenRoots); - } - - @Override - protected void validatePaths(final Path forgePath, final Path[] mcPaths, final String forgeVersion, final String mcVersion, final String mcpVersion) { - - } - - @Override - public Path[] getMCPaths(final String mcVersion, final String mcpVersion, final String forgeVersion, final String forgeGroup) { - final URL mcDataPath = getClass().getClassLoader().getResource("assets/minecraft/lang/en_us.json"); - if (mcDataPath == null) { - LOGGER.fatal(CORE, "Unable to locate minecraft data on the classpath"); - throw new RuntimeException("Unable to locate minecraft data on the classpath"); - } - mcJars = LibraryFinder.findJarPathFor("en_us.json","mcdata", mcDataPath); - return new Path[] {mcJars}; - } - - @Override - protected String getNaming() { - return "mcp"; - } - -} diff --git a/src/userdev/java/net/minecraftforge/userdev/FMLUserdevServerLaunchProvider.java b/src/userdev/java/net/minecraftforge/userdev/FMLUserdevServerLaunchProvider.java deleted file mode 100644 index 371e3a1103..0000000000 --- a/src/userdev/java/net/minecraftforge/userdev/FMLUserdevServerLaunchProvider.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.userdev; - -import cpw.mods.modlauncher.api.ILaunchHandlerService; -import cpw.mods.modlauncher.api.ITransformingClassLoader; -import net.minecraftforge.api.distmarker.Dist; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.util.concurrent.Callable; - -import static net.minecraftforge.fml.loading.LogMarkers.CORE; - -public class FMLUserdevServerLaunchProvider extends FMLUserdevLaunchProvider implements ILaunchHandlerService { - private static final Logger LOGGER = LogManager.getLogger(); - - @Override - public Dist getDist() { - return Dist.DEDICATED_SERVER; - } - - - @Override - public String name() { - return "fmluserdevserver"; - } - - @Override - public Callable launchService(String[] arguments, ITransformingClassLoader launchClassLoader) - { - return () -> { - LOGGER.debug(CORE, "Launching minecraft in {} with arguments {}", launchClassLoader, arguments); - super.beforeStart(launchClassLoader); - launchClassLoader.addTargetPackageFilter(getPackagePredicate()); - Thread.currentThread().setContextClassLoader(launchClassLoader.getInstance()); - Class.forName("net.minecraft.server.Main", true, launchClassLoader.getInstance()).getMethod("main", String[].class).invoke(null, (Object)arguments); - return null; - }; - } -} diff --git a/src/userdev/java/net/minecraftforge/userdev/LaunchTesting.java b/src/userdev/java/net/minecraftforge/userdev/LaunchTesting.java deleted file mode 100644 index 058f161376..0000000000 --- a/src/userdev/java/net/minecraftforge/userdev/LaunchTesting.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.userdev; - -import com.google.common.base.Strings; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.mojang.authlib.Agent; -import com.mojang.authlib.UserAuthentication; -import com.mojang.authlib.exceptions.AuthenticationException; -import com.mojang.authlib.properties.PropertyMap; -import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; -import cpw.mods.modlauncher.Launcher; - -import java.io.File; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.net.Proxy; -import java.util.Arrays; -import java.util.Locale; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.apache.logging.log4j.LogManager; - -public class LaunchTesting -{ - public static void main(String... args) throws InterruptedException - { - final String markerselection = System.getProperty("forge.logging.markers", ""); - Arrays.stream(markerselection.split(",")).forEach(marker-> System.setProperty("forge.logging.marker."+ marker.toLowerCase(Locale.ROOT), "ACCEPT")); - - ArgumentList lst = ArgumentList.from(args); - - String target = lst.getOrDefault("launchTarget", System.getenv().get("target")); - - if (target == null) { - throw new IllegalArgumentException("Environment variable target must be set."); - } - - lst.putLazy("gameDir", "."); - lst.putLazy("launchTarget", target); - lst.putLazy("fml.mcpVersion", System.getenv("MCP_VERSION")); - lst.putLazy("fml.mcVersion", System.getenv("MC_VERSION")); - lst.putLazy("fml.forgeGroup", System.getenv("FORGE_GROUP")); - lst.putLazy("fml.forgeVersion", System.getenv("FORGE_VERSION")); - - if (target.contains("client") || target.contains("data")) { - lst.putLazy("assetIndex", System.getenv("assetIndex")); - lst.putLazy("assetsDir", System.getenv().getOrDefault("assetDirectory", "assets")); - } - - if (target.contains("client")) { - hackNatives(); - lst.putLazy("version", "MOD_DEV"); - - String assets = lst.get("assetsDir"); - if (assets == null || !new File(assets).exists()) { - throw new IllegalArgumentException("Environment variable 'assetDirectory' must be set to a valid path."); - } - - if (!lst.hasValue("accessToken")) { - if (!login(lst)) { - String username = lst.get("username"); - if (username != null) { // Replace '#' placeholders with random numbers - Matcher m = Pattern.compile("#+").matcher(username); - StringBuffer replaced = new StringBuffer(); - while (m.find()) { - m.appendReplacement(replaced, getRandomNumbers(m.group().length())); - } - m.appendTail(replaced); - lst.put("username", replaced.toString()); - } else { - lst.putLazy("username", "Dev"); - } - lst.put("accessToken", "DONT_CRASH"); - lst.put("userProperties", "{}"); - } - } - } - - if (Arrays.asList( - "fmldevclient", "fmldevserver", "fmldevdata", - "fmluserdevclient", "fmluserdevserver", "fmluserdevdata" - ).contains(target)) { - //nop - } else { - throw new IllegalArgumentException("Unknown value for 'target' property: " + target); - } - - Launcher.main(lst.getArguments()); - Thread.sleep(10000);// Why do we have this? -Lex 03/06/19 // because there's daemon threads that should cleanly exit -cpw 04/10/20 - } - - private static String getRandomNumbers(int length) - { // Generate a time-based random number, to mimic how n.m.client.Main works - return Long.toString(System.nanoTime() % (int) Math.pow(10, length)); - } - - private static void hackNatives() - { - String paths = System.getProperty("java.library.path"); - String nativesDir = System.getenv().get("nativesDirectory"); - - if (Strings.isNullOrEmpty(paths)) - paths = nativesDir; - else - paths += File.pathSeparator + nativesDir; - - System.setProperty("java.library.path", paths); - - // hack the classloader now. - try - { - final Method initializePathMethod = ClassLoader.class.getDeclaredMethod("initializePath", String.class); - initializePathMethod.setAccessible(true); - final Object usrPathsValue = initializePathMethod.invoke(null, "java.library.path"); - final Field usrPathsField = ClassLoader.class.getDeclaredField("usr_paths"); - usrPathsField.setAccessible(true); - usrPathsField.set(null, usrPathsValue); - } - catch(Throwable t) {} - } - - /** - * Basic implementation of Mojang's 'Yggdrasil' login system, purely intended as a dev time bare bones login. - * Login errors are not handled. - * Do not use this unless you know what you are doing and must use it to debug things REQUIRING authentication. - * Forge is not responsible for any auth information passed in, saved to logs, run configs, etc... - * BE CAREFUL WITH YOUR LOGIN INFO - */ - private static boolean login(ArgumentList args) { - if (!args.hasValue("username") || !args.hasValue("password")) { - args.remove("password"); //Just in case, so it shouldn't show up anywhere. - return false; - } - - UserAuthentication auth = new YggdrasilAuthenticationService(Proxy.NO_PROXY, "1").createUserAuthentication(Agent.MINECRAFT); - auth.setUsername(args.get("username")); - auth.setPassword(args.remove("password")); - - try { - auth.logIn(); - } catch (AuthenticationException e) { - LogManager.getLogger().error("Login failed!", e); - throw new RuntimeException(e); // don't set other variables - } - - Gson gson = (new GsonBuilder()).registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer()).create(); - args.put("username", auth.getSelectedProfile().getName()); - args.put("uuid", auth.getSelectedProfile().getId().toString().replace("-", "")); - args.put("accessToken", auth.getAuthenticatedToken()); - args.put("userProperties", gson.toJson(auth.getUserProperties())); - return true; - } -} diff --git a/src/userdev/resources/META-INF/services/cpw.mods.modlauncher.api.ILaunchHandlerService b/src/userdev/resources/META-INF/services/cpw.mods.modlauncher.api.ILaunchHandlerService deleted file mode 100644 index 5fe859dabd..0000000000 --- a/src/userdev/resources/META-INF/services/cpw.mods.modlauncher.api.ILaunchHandlerService +++ /dev/null @@ -1,6 +0,0 @@ -net.minecraftforge.userdev.FMLUserdevClientLaunchProvider -net.minecraftforge.userdev.FMLUserdevServerLaunchProvider -net.minecraftforge.userdev.FMLUserdevDataLaunchProvider -net.minecraftforge.userdev.FMLDevClientLaunchProvider -net.minecraftforge.userdev.FMLDevServerLaunchProvider -net.minecraftforge.userdev.FMLDevDataLaunchProvider diff --git a/src/userdev/resources/META-INF/services/cpw.mods.modlauncher.api.INameMappingService b/src/userdev/resources/META-INF/services/cpw.mods.modlauncher.api.INameMappingService deleted file mode 100644 index 2c3e934f6f..0000000000 --- a/src/userdev/resources/META-INF/services/cpw.mods.modlauncher.api.INameMappingService +++ /dev/null @@ -1 +0,0 @@ -net.minecraftforge.userdev.MCPNamingService \ No newline at end of file diff --git a/src/userdev/resources/META-INF/services/net.minecraftforge.forgespi.locating.IModLocator b/src/userdev/resources/META-INF/services/net.minecraftforge.forgespi.locating.IModLocator deleted file mode 100644 index 077df5309f..0000000000 --- a/src/userdev/resources/META-INF/services/net.minecraftforge.forgespi.locating.IModLocator +++ /dev/null @@ -1 +0,0 @@ -net.minecraftforge.userdev.ClasspathLocator