Compare commits

...
4 Commits
616 changed files with 5690 additions and 9382 deletions

No files matched your search

+1 -1
View File
@@ -2,7 +2,7 @@ name: Publish
on: on:
push: push:
branches: [ '26.2' ] branches: [ '26.3' ]
permissions: permissions:
contents: read contents: read
+34 -27
View File
@@ -29,6 +29,9 @@ jarSigner.autoDetect('forge')
// We have to tell ForgeDev to use the exact versions of tools we ship in the installer // We have to tell ForgeDev to use the exact versions of tools we ship in the installer
fdtools { fdtools {
configure('mavenizer') {
version = '0.5.22'
}
configure('binpatcher') { configure('binpatcher') {
version = buildLibs.binarypatcher.get().version version = buildLibs.binarypatcher.get().version
} }
@@ -182,17 +185,12 @@ forgedev.runs {
mainClass = 'net.minecraftforge.bootstrap.ForgeBootstrap' mainClass = 'net.minecraftforge.bootstrap.ForgeBootstrap'
args '--gameDir', '.' args '--gameDir', '.'
jvmArgs '-Djava.net.preferIPv6Addresses=system', '-XX:+UseCompactObjectHeaders' jvmArgs '-Djava.net.preferIPv6Addresses=system', '-XX:+UseCompactObjectHeaders', '-XX:StackShadowPages=32'
systemProperty 'bsl.debug', 'true' systemProperty 'bsl.debug', 'true'
systemProperty 'terminal.jline', 'true' systemProperty 'terminal.jline', 'true'
with(sourceSets.test) {
systemProperty 'forge.enableGameTest', 'true'
systemProperty 'forgedev.enableTestMods', 'true'
}
} }
} }
create('client') { create('client') {
options { options {
systemProperty 'eventbus.api.strictRuntimeChecks', 'true' systemProperty 'eventbus.api.strictRuntimeChecks', 'true'
@@ -206,6 +204,11 @@ forgedev.runs {
'--versionType', 'release', '--versionType', 'release',
'--assetsDir', '{assets_root}', '--assetsDir', '{assets_root}',
'--assetIndex', '{asset_index}' '--assetIndex', '{asset_index}'
with(sourceSets.test) {
systemProperty 'forge.enableGameTest', 'true'
systemProperty 'forgedev.enableTestMods', 'true'
}
} }
} }
@@ -217,8 +220,13 @@ forgedev.runs {
create('gameTestServer') { create('gameTestServer') {
options { options {
systemProperty 'forge.enableGameTest', 'true'
args '--launchTarget', 'forge_dev_server_gametest' args '--launchTarget', 'forge_dev_server_gametest'
args '--uniqueWorld' // Unique world is used so that the world regenerates, as well as the world config isn't influenced by other runs args '--uniqueWorld' // Unique world is used so that the world regenerates, as well as the world config isn't influenced by other runs
with(sourceSets.test) {
systemProperty 'forgedev.enableTestMods', 'true'
}
} }
} }
@@ -236,6 +244,8 @@ forgedev.runs {
} }
with(sourceSets.test) { with(sourceSets.test) {
systemProperty 'forge.enableGameTest', 'true'
systemProperty 'forgedev.enableTestMods', 'true'
args '--mod', '.+', args '--mod', '.+',
'--existing', sourceSets.test.resources.srcDirs[0], '--existing', sourceSets.test.resources.srcDirs[0],
'--output', rootProject.file('src/test/generated/') '--output', rootProject.file('src/test/generated/')
@@ -245,23 +255,20 @@ forgedev.runs {
create('clientData') { create('clientData') {
options { options {
args '--all', args '--launchTarget', 'forge_dev_client_data',
'--existing', sourceSets.main.resources.srcDirs[0], '--all',
'--assetsDir', '{assets_root}', '--existing', sourceSets.main.resources.srcDirs[0],
'--assetIndex', '{asset_index}' '--assetsDir', '{assets_root}',
'--assetIndex', '{asset_index}'
with(sourceSets.main) { with(sourceSets.main) {
args '--launchTarget', 'forge_dev_client_data', args '--mod', 'forge',
'--mod', 'forge', '--output', rootProject.file('src/main/generated/')
'--output', rootProject.file('src/main/generated/'),
'--mod', 'forge'
} }
with(sourceSets.test) { with(sourceSets.test) {
args '--launchTarget', 'forge_dev', systemProperty 'forgedev.enableTestMods', 'true'
'--launchEntry', 'minecraft/net.minecraft.client.data.Main', args '--mod', '.+',
'--launchData',
'--mod', '.+',
'--existing', sourceSets.test.resources.srcDirs[0], '--existing', sourceSets.test.resources.srcDirs[0],
'--output', rootProject.file('src/test/generated/') '--output', rootProject.file('src/test/generated/')
} }
@@ -400,7 +407,7 @@ forgedev.userDev {
parents = [] parents = []
main = 'net.minecraftforge.bootstrap.ForgeBootstrap' main = 'net.minecraftforge.bootstrap.ForgeBootstrap'
args '--gameDir', '.' args '--gameDir', '.'
jvmArgs '-Djava.net.preferIPv6Addresses=system', '-XX:+UseCompactObjectHeaders' jvmArgs '-Djava.net.preferIPv6Addresses=system', '-XX:+UseCompactObjectHeaders', '-XX:StackShadowPages=32'
client = it.name.containsIgnoreCase('client') client = it.name.containsIgnoreCase('client')
environment 'MCP_MAPPINGS', '{mcp_mappings}' environment 'MCP_MAPPINGS', '{mcp_mappings}'
} }
@@ -454,8 +461,8 @@ forgedev.userdevCompatibility(minecraftVersion) {
final clientBinPatches = forgedev.binaryPatches('client') { final clientBinPatches = forgedev.binaryPatches('client') {
clean = minecraftFiles.client clean = minecraftFiles.client
// Workaround for 3rd party launcher issues, marker needed to locate MC, store needed to fix zlib-ng issues // Workaround for 3rd party launcher issues, marker needed to locate MC, store needed to fix zlib-ng issues
apply { apply {
store = true store = true
marker = '.forge_patched_minecraft' marker = '.forge_patched_minecraft'
} }
} }
@@ -595,12 +602,12 @@ forgedev.installer {
inheritsFrom = minecraftVersion inheritsFrom = minecraftVersion
mainClass = 'net.minecraftforge.bootstrap.ForgeBootstrap' mainClass = 'net.minecraftforge.bootstrap.ForgeBootstrap'
gameArgs = [ '--launchTarget', 'forge_client' ] gameArgs = [ '--launchTarget', 'forge_client' ]
jvmArgs = [ '-Djava.net.preferIPv6Addresses=system', '-XX:+UseCompactObjectHeaders' ] jvmArgs = [ '-Djava.net.preferIPv6Addresses=system', '-XX:+UseCompactObjectHeaders', '-XX:StackShadowPages=32' ]
} }
} }
final mdkGradleWrapper = tasks.register('mdkGradleWrapper', Wrapper) { final mdkGradleWrapper = tasks.register('mdkGradleWrapper', Wrapper) {
gradleVersion = '9.5.0' gradleVersion = '9.7.1'
scriptFile = layout.buildDirectory.dir("wrapper/" + gradleVersion + "/gradlew") scriptFile = layout.buildDirectory.dir("wrapper/" + gradleVersion + "/gradlew")
jarFile = layout.buildDirectory.dir("wrapper/" + gradleVersion + "/gradle/wrapper/gradle-wrapper.jar") jarFile = layout.buildDirectory.dir("wrapper/" + gradleVersion + "/gradle/wrapper/gradle-wrapper.jar")
} }
@@ -759,16 +766,16 @@ publishing {
def all = tasks.register('all') {} def all = tasks.register('all') {}
afterEvaluate { afterEvaluate {
if (gradle.startParameter.taskNames.contains('all')) { if (gradle.startParameter.taskNames.contains('all')) {
tasks.forEach { task -> // This forces everything to be realized, which is why we have the startParameter check tasks.forEach { task -> // This forces everything to be realized, which is why we have the startParameter check
if (!gradle.startParameter.isTaskGraph() && task.name.startsWith('run')) return if (!gradle.startParameter.isTaskGraph() && task.name.startsWith('run')) return
if (task.name in [all.name, 'dependencyInsight', 'dependencies', 'dependencyUpdates', 'init', 'buildEnvironment', 'idea', if (task.name in [all.name, 'dependencyInsight', 'dependencies', 'dependencyUpdates', 'init', 'buildEnvironment', 'idea',
'eclipse', 'javaToolchains', 'outgoingVariants', 'projects', 'properties', 'resolvableConfigurations', 'tasks', 'updateDaemonJvm', 'eclipse', 'javaToolchains', 'outgoingVariants', 'projects', 'properties', 'resolvableConfigurations', 'tasks', 'updateDaemonJvm',
'generateActionsWorkflow' 'generateActionsWorkflow'
]) return ]) return
if (task.name.startsWith('clean')) return if (task.name.startsWith('clean')) return
if (task.name == 'checkJarCompatibility') return // This doesn't work in FG6 dev, I think it's cuz we check vs srg names. Will need to look at later if (task.name == 'checkJarCompatibility') return // This doesn't work in FG6 dev, I think it's cuz we check vs srg names. Will need to look at later
all.configure { dependsOn(task) } all.configure { dependsOn(task) }
} }
} }
} }
*/ */
+1 -1
View File
@@ -3,7 +3,7 @@
MinecraftForge MinecraftForge
============= =============
[![Stable Release](https://img.shields.io/badge/dynamic/json?url=https://files.minecraftforge.net/net/minecraftforge/forge/promotions_slim.json&label=Stable&prefix=26.2-&query=$.promos["26.2-recommended"]&color=brightgreen&logo=data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyBjbGFzcz0ic3ZnLWlubGluZS0tZmEgZmEtc3RhciBmYS13LTE4IiBhcmlhLWhpZGRlbj0idHJ1ZSIgZGF0YS1pY29uPSJzdGFyIiBkYXRhLXByZWZpeD0iZmFzIiBmb2N1c2FibGU9ImZhbHNlIiByb2xlPSJpbWciIHZpZXdCb3g9IjAgMCA1NzYgNTEyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBkPSJNMjU5LjMgMTcuOEwxOTQgMTUwLjIgNDcuOSAxNzEuNWMtMjYuMiAzLjgtMzYuNyAzNi4xLTE3LjcgNTQuNmwxMDUuNyAxMDMtMjUgMTQ1LjVjLTQuNSAyNi4zIDIzLjIgNDYgNDYuNCAzMy43TDI4OCA0MzkuNmwxMzAuNyA2OC43YzIzLjIgMTIuMiA1MC45LTcuNCA0Ni40LTMzLjdsLTI1LTE0NS41IDEwNS43LTEwM2MxOS0xOC41IDguNS01MC44LTE3LjctNTQuNkwzODIgMTUwLjIgMzE2LjcgMTcuOGMtMTEuNy0yMy42LTQ1LjYtMjMuOS01Ny40IDB6IiBmaWxsPSJ3aGl0ZSIvPgo8L3N2Zz4K)][Download] [![Stable Release](https://img.shields.io/badge/dynamic/json?url=https://files.minecraftforge.net/net/minecraftforge/forge/promotions_slim.json&label=Stable&prefix=26.2-&query=$.promos["26.2-recommended"]&color=brightgreen&logo=data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyBjbGFzcz0ic3ZnLWlubGluZS0tZmEgZmEtc3RhciBmYS13LTE4IiBhcmlhLWhpZGRlbj0idHJ1ZSIgZGF0YS1pY29uPSJzdGFyIiBkYXRhLXByZWZpeD0iZmFzIiBmb2N1c2FibGU9ImZhbHNlIiByb2xlPSJpbWciIHZpZXdCb3g9IjAgMCA1NzYgNTEyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBkPSJNMjU5LjMgMTcuOEwxOTQgMTUwLjIgNDcuOSAxNzEuNWMtMjYuMiAzLjgtMzYuNyAzNi4xLTE3LjcgNTQuNmwxMDUuNyAxMDMtMjUgMTQ1LjVjLTQuNSAyNi4zIDIzLjIgNDYgNDYuNCAzMy43TDI4OCA0MzkuNmwxMzAuNyA2OC43YzIzLjIgMTIuMiA1MC45LTcuNCA0Ni40LTMzLjdsLTI1LTE0NS41IDEwNS43LTEwM2MxOS0xOC41IDguNS01MC44LTE3LjctNTQuNkwzODIgMTUwLjIgMzE2LjcgMTcuOGMtMTEuNy0yMy42LTQ1LjYtMjMuOS01Ny40IDB6IiBmaWxsPSJ3aGl0ZSIvPgo8L3N2Zz4K)][Download]
[![Latest Release](https://img.shields.io/badge/dynamic/json?url=https://files.minecraftforge.net/net/minecraftforge/forge/promotions_slim.json&label=Latest&prefix=26.2-&query=$.promos["26.2-latest"]&color=blue&logo=data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyBjbGFzcz0ic3ZnLWlubGluZS0tZmEgZmEtYnVnIGZhLXctMTYiIGFyaWEtaGlkZGVuPSJ0cnVlIiBkYXRhLWljb249ImJ1ZyIgZGF0YS1wcmVmaXg9ImZhcyIgZm9jdXNhYmxlPSJmYWxzZSIgcm9sZT0iaW1nIiB2aWV3Qm94PSIwIDAgNTEyIDUxMiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTUxMS45ODggMjg4LjljLS40NzggMTcuNDMtMTUuMjE3IDMxLjEtMzIuNjUzIDMxLjFINDI0djE2YzAgMjEuODY0LTQuODgyIDQyLjU4NC0xMy42IDYxLjE0NWw2MC4yMjggNjAuMjI4YzEyLjQ5NiAxMi40OTcgMTIuNDk2IDMyLjc1OCAwIDQ1LjI1NS0xMi40OTggMTIuNDk3LTMyLjc1OSAxMi40OTYtNDUuMjU2IDBsLTU0LjczNi01NC43MzZDMzQ1Ljg4NiA0NjcuOTY1IDMxNC4zNTEgNDgwIDI4MCA0ODBWMjM2YzAtNi42MjctNS4zNzMtMTItMTItMTJoLTI0Yy02LjYyNyAwLTEyIDUuMzczLTEyIDEydjI0NGMtMzQuMzUxIDAtNjUuODg2LTEyLjAzNS05MC42MzYtMzIuMTA4bC01NC43MzYgNTQuNzM2Yy0xMi40OTggMTIuNDk3LTMyLjc1OSAxMi40OTYtNDUuMjU2IDAtMTIuNDk2LTEyLjQ5Ny0xMi40OTYtMzIuNzU4IDAtNDUuMjU1bDYwLjIyOC02MC4yMjhDOTIuODgyIDM3OC41ODQgODggMzU3Ljg2NCA4OCAzMzZ2LTE2SDMyLjY2NkMxNS4yMyAzMjAgLjQ5MSAzMDYuMzMuMDEzIDI4OC45LS40ODQgMjcwLjgxNiAxNC4wMjggMjU2IDMyIDI1Nmg1NnYtNTguNzQ1bC00Ni42MjgtNDYuNjI4Yy0xMi40OTYtMTIuNDk3LTEyLjQ5Ni0zMi43NTggMC00NS4yNTUgMTIuNDk4LTEyLjQ5NyAzMi43NTgtMTIuNDk3IDQ1LjI1NiAwTDE0MS4yNTUgMTYwaDIyOS40ODlsNTQuNjI3LTU0LjYyN2MxMi40OTgtMTIuNDk3IDMyLjc1OC0xMi40OTcgNDUuMjU2IDAgMTIuNDk2IDEyLjQ5NyAxMi40OTYgMzIuNzU4IDAgNDUuMjU1TDQyNCAxOTcuMjU1VjI1Nmg1NmMxNy45NzIgMCAzMi40ODQgMTQuODE2IDMxLjk4OCAzMi45ek0yNTcgMGMtNjEuODU2IDAtMTEyIDUwLjE0NC0xMTIgMTEyaDIyNEMzNjkgNTAuMTQ0IDMxOC44NTYgMCAyNTcgMHoiIGZpbGw9IndoaXRlIi8+Cjwvc3ZnPgo= [![Latest Release](https://img.shields.io/badge/dynamic/json?url=https://files.minecraftforge.net/net/minecraftforge/forge/promotions_slim.json&label=Latest&prefix=26.3-&query=$.promos["26.3-latest"]&color=blue&logo=data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyBjbGFzcz0ic3ZnLWlubGluZS0tZmEgZmEtYnVnIGZhLXctMTYiIGFyaWEtaGlkZGVuPSJ0cnVlIiBkYXRhLWljb249ImJ1ZyIgZGF0YS1wcmVmaXg9ImZhcyIgZm9jdXNhYmxlPSJmYWxzZSIgcm9sZT0iaW1nIiB2aWV3Qm94PSIwIDAgNTEyIDUxMiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTUxMS45ODggMjg4LjljLS40NzggMTcuNDMtMTUuMjE3IDMxLjEtMzIuNjUzIDMxLjFINDI0djE2YzAgMjEuODY0LTQuODgyIDQyLjU4NC0xMy42IDYxLjE0NWw2MC4yMjggNjAuMjI4YzEyLjQ5NiAxMi40OTcgMTIuNDk2IDMyLjc1OCAwIDQ1LjI1NS0xMi40OTggMTIuNDk3LTMyLjc1OSAxMi40OTYtNDUuMjU2IDBsLTU0LjczNi01NC43MzZDMzQ1Ljg4NiA0NjcuOTY1IDMxNC4zNTEgNDgwIDI4MCA0ODBWMjM2YzAtNi42MjctNS4zNzMtMTItMTItMTJoLTI0Yy02LjYyNyAwLTEyIDUuMzczLTEyIDEydjI0NGMtMzQuMzUxIDAtNjUuODg2LTEyLjAzNS05MC42MzYtMzIuMTA4bC01NC43MzYgNTQuNzM2Yy0xMi40OTggMTIuNDk3LTMyLjc1OSAxMi40OTYtNDUuMjU2IDAtMTIuNDk2LTEyLjQ5Ny0xMi40OTYtMzIuNzU4IDAtNDUuMjU1bDYwLjIyOC02MC4yMjhDOTIuODgyIDM3OC41ODQgODggMzU3Ljg2NCA4OCAzMzZ2LTE2SDMyLjY2NkMxNS4yMyAzMjAgLjQ5MSAzMDYuMzMuMDEzIDI4OC45LS40ODQgMjcwLjgxNiAxNC4wMjggMjU2IDMyIDI1Nmg1NnYtNTguNzQ1bC00Ni42MjgtNDYuNjI4Yy0xMi40OTYtMTIuNDk3LTEyLjQ5Ni0zMi43NTggMC00NS4yNTUgMTIuNDk4LTEyLjQ5NyAzMi43NTgtMTIuNDk3IDQ1LjI1NiAwTDE0MS4yNTUgMTYwaDIyOS40ODlsNTQuNjI3LTU0LjYyN2MxMi40OTgtMTIuNDk3IDMyLjc1OC0xMi40OTcgNDUuMjU2IDAgMTIuNDk2IDEyLjQ5NyAxMi40OTYgMzIuNzU4IDAgNDUuMjU1TDQyNCAxOTcuMjU1VjI1Nmg1NmMxNy45NzIgMCAzMi40ODQgMTQuODE2IDMxLjk4OCAzMi45ek0yNTcgMGMtNjEuODU2IDAtMTEyIDUwLjE0NC0xMTIgMTEyaDIyNEMzNjkgNTAuMTQ0IDMxOC44NTYgMCAyNTcgMHoiIGZpbGw9IndoaXRlIi8+Cjwvc3ZnPgo=
)][Download] [![Discord](https://img.shields.io/discord/313125603924639766.svg?color=%237289da&label=Discord&logo=discord&logoColor=%237289da)][Discord] [![Support](https://img.shields.io/badge/Patreon-Support-orange.svg?logo=Patreon)][Patreon] )][Download] [![Discord](https://img.shields.io/discord/313125603924639766.svg?color=%237289da&label=Discord&logo=discord&logoColor=%237289da)][Discord] [![Support](https://img.shields.io/badge/Patreon-Support-orange.svg?logo=Patreon)][Patreon]
Forge is a free, open-source modding API all of your favourite mods use! Forge is a free, open-source modding API all of your favourite mods use!
@@ -16,7 +16,7 @@ import java.util.function.Supplier;
/** /**
* Used to allow access to certain things from the game layer * Used to allow access to certain things from the game layer
*/ */
public class Bindings { public final class Bindings {
private Bindings() {} private Bindings() {}
/** /**
@@ -27,7 +27,7 @@ public class Bindings {
.findFirst().orElseThrow(() -> new IllegalStateException("Could not find bindings provider")); .findFirst().orElseThrow(() -> new IllegalStateException("Could not find bindings provider"));
/** /**
* @return A supplier of net.minecraftforge.common.MinecraftForge#EVENT_BUS * @return A supplier of {@link BusGroup#DEFAULT}
*/ */
public static Supplier<BusGroup> getForgeBus() { public static Supplier<BusGroup> getForgeBus() {
return PROVIDER.getForgeBusSupplier(); return PROVIDER.getForgeBusSupplier();
@@ -101,7 +101,7 @@ public final class ModList {
} }
public static Optional<? extends ModContainer> getModContainerById(String modId) { public static Optional<? extends ModContainer> getModContainerById(String modId) {
return Optional.ofNullable(indexedMods.get(modId)); return Optional.ofNullable(indexedMods == null ? null : indexedMods.get(modId));
} }
public static Optional<? extends ModContainer> getModContainerByObject(Object obj) { public static Optional<? extends ModContainer> getModContainerByObject(Object obj) {
+2 -2
View File
@@ -55,9 +55,9 @@ dependencies {
// We are making the list of providers first BEFORE mapping them to a provider of the resolved objects so that they can be finalized after configuration. // We are making the list of providers first BEFORE mapping them to a provider of the resolved objects so that they can be finalized after configuration.
var lwjglTestLibs = [ var lwjglTestLibs = [
dependencies.variantOf(earlyDisplayTestLibs.lwjgl) { classifier lwjglNatives }, dependencies.variantOf(earlyDisplayTestLibs.lwjgl) { classifier lwjglNatives },
dependencies.variantOf(earlyDisplayTestLibs.lwjgl.glfw) { classifier lwjglNatives },
dependencies.variantOf(earlyDisplayTestLibs.lwjgl.opengl) { classifier lwjglNatives }, dependencies.variantOf(earlyDisplayTestLibs.lwjgl.opengl) { classifier lwjglNatives },
dependencies.variantOf(earlyDisplayTestLibs.lwjgl.stb) { classifier lwjglNatives } dependencies.variantOf(earlyDisplayTestLibs.lwjgl.stb) { classifier lwjglNatives },
dependencies.variantOf(earlyDisplayTestLibs.lwjgl.sdl) { classifier lwjglNatives }
].with { list -> ].with { list ->
provider { list.collect { it.get() } } provider { list.collect { it.get() } }
} }
@@ -13,10 +13,12 @@ import net.minecraftforge.fml.loading.ImmediateWindowHandler;
import net.minecraftforge.fml.loading.ImmediateWindowProvider; import net.minecraftforge.fml.loading.ImmediateWindowProvider;
import net.minecraftforge.fml.loading.progress.StartupNotificationManager; import net.minecraftforge.fml.loading.progress.StartupNotificationManager;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.lwjgl.PointerBuffer; import org.lwjgl.opengl.GL;
import org.lwjgl.glfw.GLFWVidMode; import org.lwjgl.sdl.SDLError;
import org.lwjgl.sdl.SDLVideo;
import org.lwjgl.sdl.SDL_Event;
import org.lwjgl.sdl.SDL_Rect;
import org.lwjgl.system.MemoryStack; import org.lwjgl.system.MemoryStack;
import org.lwjgl.system.MemoryUtil;
import org.lwjgl.util.tinyfd.TinyFileDialogs; import org.lwjgl.util.tinyfd.TinyFileDialogs;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -29,12 +31,10 @@ import java.net.URI;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar; import java.util.Calendar;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.Optional; import java.util.Optional;
import java.util.StringJoiner;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
@@ -43,17 +43,18 @@ import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.BiConsumer;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.IntConsumer; import java.util.function.IntConsumer;
import java.util.function.Supplier; import java.util.function.Supplier;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import static org.lwjgl.glfw.GLFW.*;
import static org.lwjgl.opengl.GL.createCapabilities;
import static org.lwjgl.opengl.GL32C.*; import static org.lwjgl.opengl.GL32C.*;
import static org.lwjgl.sdl.SDLError.*;
import static org.lwjgl.sdl.SDLEvents.*;
import static org.lwjgl.sdl.SDLHints.*;
import static org.lwjgl.sdl.SDLInit.*;
import static org.lwjgl.sdl.SDLVideo.*;
/** /**
* The Loading Window that is opened Immediately after Forge starts. * The Loading Window that is opened Immediately after Forge starts.
* It is called from the ModDirTransformerDiscoverer, the soonest method that ModLauncher calls into Forge code. * It is called from the ModDirTransformerDiscoverer, the soonest method that ModLauncher calls into Forge code.
@@ -83,10 +84,10 @@ public class DisplayWindow implements ImmediateWindowProvider {
private ScheduledFuture<?> initializationFuture; private ScheduledFuture<?> initializationFuture;
private PerformanceInfo performanceInfo; private PerformanceInfo performanceInfo;
@SuppressWarnings("unused")
private ScheduledFuture<?> performanceTick;
// The GL ID of the window. Used for all operations // The GL ID of the window. Used for all operations
private long window; private long window;
// The SDL Context we use for switching between threads
private long sdlContext;
// The thread that contains and ticks the window while Forge is loading mods // The thread that contains and ticks the window while Forge is loading mods
private static final ScheduledExecutorService renderScheduler = Executors.newSingleThreadScheduledExecutor(r -> { private static final ScheduledExecutorService renderScheduler = Executors.newSingleThreadScheduledExecutor(r -> {
final var thread = Executors.defaultThreadFactory().newThread(r); final var thread = Executors.defaultThreadFactory().newThread(r);
@@ -116,8 +117,8 @@ public class DisplayWindow implements ImmediateWindowProvider {
@Override @Override
public ImmediateWindowProvider selectBackend(String backend) { public ImmediateWindowProvider selectBackend(String backend) {
// We only support opengl // We only support opengl
if ("default".equals(backend) || "opengl".equals(backend)) //if ("default".equals(backend) || "opengl".equals(backend))
return this; // return this;
return ImmediateWindowProvider.getFallbackHandler(); return ImmediateWindowProvider.getFallbackHandler();
} }
@@ -184,7 +185,7 @@ public class DisplayWindow implements ImmediateWindowProvider {
return; return;
} }
nextFrameTime = nt + MINFRAMETIME; nextFrameTime = nt + MINFRAMETIME;
glfwMakeContextCurrent(window); SDL_GL_MakeCurrent(window, sdlContext);
framebuffer.activate(); framebuffer.activate();
glViewport(0, 0, this.context.scaledWidth(), this.context.scaledHeight()); glViewport(0, 0, this.context.scaledWidth(), this.context.scaledHeight());
this.context.elementShader().activate(); this.context.elementShader().activate();
@@ -196,11 +197,12 @@ public class DisplayWindow implements ImmediateWindowProvider {
glViewport(0, 0, fbWidth, fbHeight); glViewport(0, 0, fbWidth, fbHeight);
framebuffer.draw(this.fbWidth, this.fbHeight); framebuffer.draw(this.fbWidth, this.fbHeight);
// Swap buffers; we're done // Swap buffers; we're done
glfwSwapBuffers(window); SDL_GL_SwapWindow(window);
} catch (Throwable t) { } catch (Throwable t) {
LOGGER.error("BARF", t); LOGGER.error("BARF", t);
} finally { } finally {
if (this.windowTick != null) glfwMakeContextCurrent(0); // we release the gl context IF we're running off the main thread if (this.windowTick != null)
SDL_GL_MakeCurrent(window, 0); // we release the gl context IF we're running off the main thread
renderLock.release(); renderLock.release();
} }
} }
@@ -212,12 +214,18 @@ public class DisplayWindow implements ImmediateWindowProvider {
* Nothing fancy, we just want to draw and render text. * Nothing fancy, we just want to draw and render text.
*/ */
private void initRender(final @Nullable String mcVersion, final String forgeVersion) { private void initRender(final @Nullable String mcVersion, final String forgeVersion) {
this.sdlContext = SDL_GL_CreateContext(window);
if (sdlContext == 0)
throw new IllegalStateException("Failed to create OpenGL context: " + SDL_GetError());
// This thread owns the GL render context now. We should make a note of that. // This thread owns the GL render context now. We should make a note of that.
glfwMakeContextCurrent(window); bindGlContext();
GL.createCapabilities();
// Wait for one frame to be complete before swapping; enable vsync in other words. // Wait for one frame to be complete before swapping; enable vsync in other words.
glfwSwapInterval(1); SDL_GL_SetSwapInterval(1);
createCapabilities();
LOGGER.info("GL info: "+ glGetString(GL_RENDERER) + " GL version " + glGetString(GL_VERSION) + ", " + glGetString(GL_VENDOR)); LOGGER.info("GL info: " + glGetString(GL_RENDERER) + " GL version " + glGetString(GL_VERSION) + ", " + glGetString(GL_VENDOR));
elementShader = new ElementShader(); elementShader = new ElementShader();
try { try {
@@ -227,7 +235,7 @@ public class DisplayWindow implements ImmediateWindowProvider {
crashElegantly("An error occurred initializing shaders."); crashElegantly("An error occurred initializing shaders.");
} }
// Set the clear color based on the colour scheme // Set the clear color based on the color scheme
glClearColor(colourScheme.background().redf(), colourScheme.background().greenf(), colourScheme.background().bluef(), 1f); glClearColor(colourScheme.background().redf(), colourScheme.background().greenf(), colourScheme.background().bluef(), 1f);
// we always render to an 854x480 texture and then fit that to the screen - with a scale factor // we always render to an 854x480 texture and then fit that to the screen - with a scale factor
@@ -253,11 +261,15 @@ public class DisplayWindow implements ImmediateWindowProvider {
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glfwMakeContextCurrent(0);
releaseGlContext();
this.windowTick = renderScheduler.scheduleAtFixedRate(this::renderThreadFunc, 50, 50, TimeUnit.MILLISECONDS); this.windowTick = renderScheduler.scheduleAtFixedRate(this::renderThreadFunc, 50, 50, TimeUnit.MILLISECONDS);
this.performanceTick = renderScheduler.scheduleAtFixedRate(performanceInfo::update, 0, 500, TimeUnit.MILLISECONDS);
// Update the performance information every 1/2 second
renderScheduler.scheduleAtFixedRate(performanceInfo::update, 0, 500, TimeUnit.MILLISECONDS);
// schedule a 50 ms ticker to try and smooth out the rendering // schedule a 50 ms ticker to try and smooth out the rendering
renderScheduler.scheduleAtFixedRate(()-> animationTimerTrigger.set(true), 1, 50, TimeUnit.MILLISECONDS); //renderScheduler.scheduleAtFixedRate(() -> animationTimerTrigger.set(true), 1, 50, TimeUnit.MILLISECONDS);
} }
/** /**
@@ -294,6 +306,7 @@ public class DisplayWindow implements ImmediateWindowProvider {
glBindVertexArray(currentVAO); glBindVertexArray(currentVAO);
glBindFramebuffer(GL_FRAMEBUFFER, currentFB); glBindFramebuffer(GL_FRAMEBUFFER, currentFB);
} }
/** /**
* Start the window and Render Thread; we're ready to go. * Start the window and Render Thread; we're ready to go.
*/ */
@@ -342,71 +355,65 @@ public class DisplayWindow implements ImmediateWindowProvider {
* As long as we can verify that, then GL (and things like OS X) have no complaints with doing this. * As long as we can verify that, then GL (and things like OS X) have no complaints with doing this.
* *
* @param mcVersion Minecraft Version * @param mcVersion Minecraft Version
* @return The selected GL profile as an integer pair
*/ */
public void initWindow(@Nullable String mcVersion) { public void initWindow(@Nullable String mcVersion) {
// Initialize GLFW with a time guard, in case something goes wrong // Initialize a time guard, in case something goes wrong
long glfwInitBegin = System.nanoTime(); long initBegin = System.nanoTime();
if (!glfwInit()) { if (!SDL_Init(SDL_INIT_VIDEO)) {
crashElegantly("We are unable to initialize the graphics system.\nglfwInit failed.\n"); crashElegantly("We are unable to initialize the graphics system.\nSDL_Init failed.\n");
throw new IllegalStateException("Unable to initialize GLFW"); throw new IllegalStateException("Unable to initialize SDL");
} }
long glfwInitEnd = System.nanoTime(); long initEnd = System.nanoTime();
if (glfwInitEnd - glfwInitBegin > 1e9) { if (initEnd - initBegin > 1e9)
LOGGER.error("WARNING : glfwInit took {} seconds to start.", (glfwInitEnd - glfwInitBegin) / 1.0e9); LOGGER.error("WARNING : Window init took {} seconds to start.", (initEnd - initBegin) / 1.0e9);
}
// Clear the Last Exception (#7285 - Prevent Vanilla throwing an IllegalStateException due to invalid controller mappings)
handleLastGLFWError((error, description) -> LOGGER.error(String.format("Suppressing Last GLFW error: [0x%X]%s", error, description)));
// Set window hints for the new window we're gonna create. // Set window hints for the new window we're gonna create.
glfwDefaultWindowHints(); SDL_ResetHints();
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API);
glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_NATIVE_CONTEXT_API);
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);
String vanillaWindowTitle = "Minecraft* "; String vanillaWindowTitle = "Minecraft* ";
if (mcVersion != null) vanillaWindowTitle += mcVersion; if (mcVersion != null)
vanillaWindowTitle += mcVersion;
// this emulates what we would get without early progress window var primaryMonitor = SDL_GetPrimaryDisplay();
// as vanilla never sets these, so GLFW uses the first window title
// set them explicitly to avoid it using "FML early loading progress" as the class
glfwWindowHintString(GLFW_X11_CLASS_NAME, vanillaWindowTitle);
glfwWindowHintString(GLFW_X11_INSTANCE_NAME, vanillaWindowTitle);
long primaryMonitor = glfwGetPrimaryMonitor();
if (primaryMonitor == 0) { if (primaryMonitor == 0) {
LOGGER.error("Failed to find a primary monitor - this means LWJGL isn't working properly"); LOGGER.error("Failed to find a primary monitor - this means LWJGL isn't working properly");
crashElegantly("Failed to locate a primary monitor.\nglfwGetPrimaryMonitor failed.\n"); crashElegantly("Failed to locate a primary monitor.\nSDL_GetPrimaryDisplay failed.\n");
throw new IllegalStateException("Can't find a primary monitor"); throw new IllegalStateException("Can't find a primary monitor");
} }
GLFWVidMode vidmode = glfwGetVideoMode(primaryMonitor);
var vidmode = SDL_GetDesktopDisplayMode(primaryMonitor);
if (vidmode == null) { if (vidmode == null) {
LOGGER.error("Failed to get the current display video mode."); LOGGER.error("Failed to get the current display video mode.");
crashElegantly("Failed to get current display resolution.\nglfwGetVideoMode failed.\n"); crashElegantly("Failed to get current display resolution.\nSDL_GetDesktopDisplayMode failed.\n");
throw new IllegalStateException("Can't get a resolution"); throw new IllegalStateException("Can't get a resolution");
} }
long window = 0; long window = 0;
var successfulWindow = new AtomicBoolean(false); var successfulWindow = new AtomicBoolean(false);
var windowFailFuture = renderScheduler.schedule(()->{ var windowFailFuture = renderScheduler.schedule(() -> {
if (!successfulWindow.get()) crashElegantly("Timed out trying to setup the Game Window."); if (!successfulWindow.get())
crashElegantly("Timed out trying to setup the Game Window.");
}, 10, TimeUnit.SECONDS); }, 10, TimeUnit.SECONDS);
int versidx = 0;
var skipVersions = FMLConfig.<String>getListConfigValue(FMLConfig.ConfigValue.EARLY_WINDOW_SKIP_GL_VERSIONS); var skipVersions = FMLConfig.<String>getListConfigValue(FMLConfig.ConfigValue.EARLY_WINDOW_SKIP_GL_VERSIONS);
boolean showHelpLog = FMLConfig.getBoolConfigValue(FMLConfig.ConfigValue.EARLY_WINDOW_LOG_HELP_MSG); boolean showHelpLog = FMLConfig.getBoolConfigValue(FMLConfig.ConfigValue.EARLY_WINDOW_LOG_HELP_MSG);
final String[] lastGLError = new String[GL_VERSIONS.length];
do { record Attempt(String vesion, String error) {}
final var glVersionToTry = GL_VERSIONS[versidx][0] + "." + GL_VERSIONS[versidx][1]; final List<Attempt> attempts = new ArrayList<>();
if (skipVersions.contains(glVersionToTry)) { String requestedVersion = null;
LOGGER.info("Skipping GL version "+ glVersionToTry+" because of configuration");
versidx++; for (int x = 0; x < GL_VERSIONS.length; x++) {
var version = GL_VERSIONS[x];
requestedVersion = version[0] + "." + version[1];
if (skipVersions.contains(requestedVersion)) {
LOGGER.info("Skipping GL version " + requestedVersion + " because of configuration");
continue; continue;
} }
LOGGER.info("Trying GL version " + glVersionToTry);
if (showHelpLog && versidx == 0) { LOGGER.info("Trying GL version " + requestedVersion);
if (showHelpLog && x == 0) {
LOGGER.info(""" LOGGER.info("""
If this message is the only thing at the bottom of your log before a crash, you probably have a driver issue. If this message is the only thing at the bottom of your log before a crash, you probably have a driver issue.
@@ -418,132 +425,105 @@ public class DisplayWindow implements ImmediateWindowProvider {
You can safely ignore this message if the game starts up successfully."""); You can safely ignore this message if the game starts up successfully.""");
} }
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, GL_VERSIONS[versidx][0]); // we try our versions one at a time
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, GL_VERSIONS[versidx][1]);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
window = glfwCreateWindow(winWidth, winHeight, vanillaWindowTitle, 0L, 0L);
var erridx = versidx;
handleLastGLFWError((error, description) -> lastGLError[erridx] = String.format("Trying %d.%d: GLFW error: [0x%X]%s", GL_VERSIONS[erridx][0], GL_VERSIONS[erridx][1], error, description));
if (lastGLError[versidx] != null) {
LOGGER.trace(lastGLError[versidx]);
}
versidx++;
} while (window == 0 && versidx < GL_VERSIONS.length);
// LockSupport.parkNanos(TimeUnit.SECONDS.toNanos(12));
if (versidx== GL_VERSIONS.length && window == 0) {
LOGGER.error("Failed to find any valid GLFW profile. "+lastGLError[0]);
crashElegantly("Failed to find a valid GLFW profile.\nWe tried "+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, version[0]);
Arrays.stream(GL_VERSIONS).map(p->p[0]+"."+p[1]).filter(o -> !skipVersions.contains(o)) SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, version[1]);
.collect(Collector.of(()->new StringJoiner(", ").setEmptyValue("no versions"), StringJoiner::add, StringJoiner::merge, StringJoiner::toString))+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
" but none of them worked.\n"+ Arrays.stream(lastGLError).filter(Objects::nonNull).collect(Collectors.joining("\n"))); SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG);
SDL_GL_SetAttribute(SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, GL_TRUE);
window = SDL_CreateWindow(vanillaWindowTitle, winWidth, winHeight,
SDL_WINDOW_OPENGL
| SDL_WINDOW_RESIZABLE
| SDL_WINDOW_HIGH_PIXEL_DENSITY
);
if (window == 0) {
var error = Objects.requireNonNullElse(SDLError.SDL_GetError(), "<no error>");
attempts.add(new Attempt(requestedVersion, error));
LOGGER.trace("Failed to create window using %d.%d: %s", version[0], version[1], error);
} else {
SDLVideo.SDL_SetWindowMinimumSize(window, 320, 240);
LOGGER.info("Created window using SDL video driver: {}", SDLVideo.SDL_GetCurrentVideoDriver());
break; // We got a valid window!
}
}
if (window == 0) {
LOGGER.error("Failed to find any valid GLFW profile.");
var message = new StringBuilder()
.append("Failed to find a valid GLFW profile.\n");
if (attempts.isEmpty()) {
message.append("All GL Versions were skipped");
} else {
message.append("We tried:");
for (var attempt : attempts)
message.append("\n\t").append(attempt.vesion).append(':').append(attempt.error);
}
crashElegantly(message.toString());
throw new IllegalStateException("Failed to create a GLFW window with any profile"); throw new IllegalStateException("Failed to create a GLFW window with any profile");
} }
successfulWindow.set(true); successfulWindow.set(true);
if (!windowFailFuture.cancel(true)) throw new IllegalStateException("We died but didn't somehow?"); if (!windowFailFuture.cancel(true))
var requestedVersion = GL_VERSIONS[versidx-1][0]+"."+GL_VERSIONS[versidx-1][1]; throw new IllegalStateException("We died but didn't somehow?");
var maj = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MAJOR);
var min = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MINOR); try (var stack = org.lwjgl.system.MemoryStack.stackPush()) {
var gotVersion = maj+"."+min; var majBuf = stack.mallocInt(1);
LOGGER.info("Requested GL version "+requestedVersion+" got version "+gotVersion); var minBuf = stack.mallocInt(1);
this.glVersion = gotVersion; SDL_GL_GetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, majBuf);
SDL_GL_GetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, minBuf);
this.glVersion = majBuf.get(0) + "." + minBuf.get(0);
}
LOGGER.info("Requested GL version " + requestedVersion + " got version " + this.glVersion);
this.window = window; this.window = window;
if (showHelpLog) if (showHelpLog)
FMLConfig.updateConfig(FMLConfig.ConfigValue.EARLY_WINDOW_LOG_HELP_MSG, false); FMLConfig.updateConfig(FMLConfig.ConfigValue.EARLY_WINDOW_LOG_HELP_MSG, false);
int[] x = new int[1]; if (this.maximized)
int[] y = new int[1]; SDL_MaximizeWindow(window);
glfwGetMonitorPos(primaryMonitor, x, y);
int monitorX = x[0];
int monitorY = y[0];
// glfwSetWindowSizeLimits(window, 854, 480, GLFW_DONT_CARE, GLFW_DONT_CARE);
if (this.maximized) {
glfwMaximizeWindow(window);
}
glfwGetWindowSize(window, x, y); var size = getWindowSize(window);
this.winWidth = x[0]; this.onWindowResize(size.x, size.y);
this.winHeight = y[0];
// Setting the window position isn't supported on wayland, so check the error here var monitor = getMonitorSize(primaryMonitor);
glfwSetWindowPos(window, (vidmode.width() - this.winWidth) / 2 + monitorX, (vidmode.height() - this.winHeight) / 2 + monitorY); if (monitor != null)
handleLastGLFWError(); SDL_SetWindowPosition(window, (monitor.width - size.x) / 2 + monitor.x, (monitor.height - size.y) / 2 + monitor.y);
// Attempt setting the icon pollEvents();
// int[] channels = new int[1];
// try (var glfwImgBuffer = GLFWImage.create(MemoryUtil.getAllocator().malloc(GLFWImage.SIZEOF), 1)) {
// final ByteBuffer imgBuffer;
// try (GLFWImage glfwImages = GLFWImage.malloc()) {
// imgBuffer = STBHelper.loadImageFromClasspath("forge_logo.png", 20000, x, y, channels);
// glfwImgBuffer.put(glfwImages.set(x[0], y[0], imgBuffer));
// glfwSetWindowIcon(window, glfwImgBuffer);
// STBImage.stbi_image_free(imgBuffer);
// }
// } catch (NullPointerException e) {
// System.err.println("Failed to load forge logo");
// }
// handleLastGLFWError((error, description) -> LOGGER.debug(String.format("Suppressing GLFW icon error: [0x%X]%s", error, description)));
glfwSetFramebufferSizeCallback(window, this::fbResize); SDL_ShowWindow(window);
glfwSetWindowPosCallback(window, this::winMove);
glfwSetWindowSizeCallback(window, this::winResize);
// Show the window
glfwShowWindow(window);
// Getting the window position isn't supported on wayland, so check the error here
glfwGetWindowPos(window, x, y);
handleLastGLFWError();
this.winX = x[0];
this.winY = y[0];
glfwGetFramebufferSize(window, x, y);
this.fbWidth = x[0];
this.fbHeight = y[0];
glfwPollEvents();
} }
private static void handleLastGLFWError() { private record Point(int x, int y) {}
handleLastGLFWError((error, description) -> { private record Rect(int x, int y, int width, int height) {}
if (error == GLFW_FEATURE_UNAVAILABLE) {
// suppress window pos errors for unsupported platforms (wayland) private static @Nullable Rect getMonitorSize(int monitor) {
LOGGER.debug(String.format("Suppressing GLFW error: [0x%X]%s", error, description)); try (var bounds = SDL_Rect.malloc()) {
return; // Fetch the display bounds for the current index
if (SDL_GetDisplayBounds(monitor, bounds)) {
int x = bounds.x();
int y = bounds.y();
int width = bounds.w();
int height = bounds.h();
LOGGER.info("Display {} Bounds -> X: {}, Y: {}, Width: {}, Height: {}", monitor, x, y, width, height);
return new Rect(x, y, width, height);
} else {
LOGGER.warn("Could not get bounds for display: " + SDL_GetError());
return null;
} }
throw new IllegalStateException(String.format("GLFW error: [0x%X]%s", error, description));
});
}
private void winResize(long window, int width, int height) {
if (window == this.window && width != 0 && height != 0) {
this.winWidth = width;
this.winHeight = height;
}
}
private void fbResize(long window, int width, int height) {
if (window == this.window && width != 0 && height != 0) {
this.fbWidth = width;
this.fbHeight = height;
} }
} }
private void winMove(long window, int x, int y) { private static Point getWindowSize(long window) {
if (window == this.window) { try (var stack = MemoryStack.stackPush()) {
this.winX = x; var width = stack.mallocInt(1);
this.winY = y; var height = stack.mallocInt(1);
} SDL_GetWindowSize(window, width, height);
} return new Point(width.get(0), height.get(0));
private static void handleLastGLFWError(BiConsumer<Integer, String> handler) {
try (MemoryStack memorystack = MemoryStack.stackPush()) {
PointerBuffer pointerbuffer = memorystack.mallocPointer(1);
int error = glfwGetError(pointerbuffer);
if (error != GLFW_NO_ERROR) {
long pDescription = pointerbuffer.get();
String description = pDescription == 0L ? "" : MemoryUtil.memUTF8(pDescription);
handler.accept(error, description);
}
} }
} }
@@ -553,7 +533,8 @@ public class DisplayWindow implements ImmediateWindowProvider {
* *
* @return the Window we own. * @return the Window we own.
*/ */
public long setupMinecraftWindow(final int width, final int height, final String title, final long monitorSupplier, final Supplier<Object> backend) { @Override
public long setupMinecraftWindow(final int width, final int height, final String title, final Supplier<Object> backend) {
// wait for the window to actually be initialized // wait for the window to actually be initialized
try { try {
this.initializationFuture.get(30, TimeUnit.SECONDS); this.initializationFuture.get(30, TimeUnit.SECONDS);
@@ -585,14 +566,10 @@ public class DisplayWindow implements ImmediateWindowProvider {
// we don't want the lock, just making sure it's back on the main thread // we don't want the lock, just making sure it's back on the main thread
renderLock.release(); renderLock.release();
glfwMakeContextCurrent(window); SDL_GL_MakeCurrent(window, sdlContext);
// Set the title to what the game wants // Set the title to what the game wants
glfwSetWindowTitle(window, title); SDL_SetWindowTitle(window, title);
glfwSwapInterval(0); SDL_GL_SetSwapInterval(0); // Disable vsync, let Minecraft control it
// Clean up our hooks
glfwSetFramebufferSizeCallback(window, null).free();
glfwSetWindowPosCallback(window, null).free();
glfwSetWindowSizeCallback(window, null).free();
this.repaintTick = this::renderThreadFunc; // the repaint will continue to be called until the overlay takes over this.repaintTick = this::renderThreadFunc; // the repaint will continue to be called until the overlay takes over
this.windowTick = null; // this tells the render thread that the async ticker is done this.windowTick = null; // this tells the render thread that the async ticker is done
return window; return window;
@@ -658,7 +635,7 @@ public class DisplayWindow implements ImmediateWindowProvider {
@Override @Override
public void periodicTick() { public void periodicTick() {
glfwPollEvents(); pollEvents();
repaintTick.run(); repaintTick.run();
} }
@@ -673,4 +650,67 @@ public class DisplayWindow implements ImmediateWindowProvider {
this.context.elementShader().close(); this.context.elementShader().close();
SimpleBufferBuilder.destroy(); SimpleBufferBuilder.destroy();
} }
private void bindGlContext() {
SDL_GL_MakeCurrent(window, sdlContext);
//if (!SDL_GL_MakeCurrent(window, sdlContext))
// throw new IllegalStateException("Failed to make OpenGL context current: " + SDL_GetError());
}
private void releaseGlContext() {
SDL_GL_MakeCurrent(window, 0);
}
private void pollEvents() {
try (var event = SDL_Event.malloc()) {
while (SDL_PollEvent(event)) {
switch (event.type()) {
case SDL_EVENT_WINDOW_MOVED:
this.onWindowMove(event.window().data1(), event.window().data2());
break;
case SDL_EVENT_WINDOW_RESIZED:
this.onWindowResize(event.window().data1(), event.window().data2());
break;
case SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED:
this.onFrameBufferResize(event.window().data1(), event.window().data2());
break;
/*
We were told to quit for some reason, find a way to abort?
case SDL_EVENT_QUIT:
case SDL_EVENT_WINDOW_CLOSE_REQUESTED:
case SDL_EVENT_TERMINATING:
Window was minimized or restored, maybe stop rendering?
case SDL_EVENT_WINDOW_MINIMIZED:
case SDL_EVENT_WINDOW_MAXIMIZED:
case SDL_EVENT_WINDOW_RESTORED:
*/
}
}
}
}
private void onWindowResize(int width, int height) {
if (width == 0 || height == 0)
return;
this.winWidth = width;
this.winHeight = height;
}
private void onFrameBufferResize(int width, int height) {
if (width == 0 || height == 0)
return;
this.fbWidth = width;
this.fbHeight = height;
}
private void onWindowMove(int x, int y) {
this.winX = x;
this.winY = y;
}
} }
@@ -11,8 +11,6 @@ import net.minecraftforge.fml.loading.progress.StartupNotificationManager;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.function.Supplier;
import static org.lwjgl.opengl.GL32C.*; import static org.lwjgl.opengl.GL32C.*;
public class RenderElement { public class RenderElement {
@@ -39,11 +37,6 @@ public class RenderElement {
void accept(SimpleBufferBuilder bb, DisplayContext context, int[] size, int frame); void accept(SimpleBufferBuilder bb, DisplayContext context, int[] size, int frame);
} }
/** @deprecated Use {@link Renderer} directly. This was always eagerly resolved, making it an unnecessary wrapper. */
@Deprecated(since = "1.21.5", forRemoval = true)
@FunctionalInterface
interface Initializer extends Supplier<Renderer> {}
@FunctionalInterface @FunctionalInterface
interface TextGenerator { interface TextGenerator {
void accept(SimpleBufferBuilder bb, SimpleFont fh, DisplayContext ctx); void accept(SimpleBufferBuilder bb, SimpleFont fh, DisplayContext ctx);
@@ -59,13 +52,6 @@ public class RenderElement {
} }
} }
/** @deprecated Use {@link RenderElement#RenderElement(Renderer)} instead */
@Deprecated(since = "1.21.5", forRemoval = true)
public RenderElement(final Initializer rendererInitializer) {
this.bb = new SimpleBufferBuilder(1);
this.renderer = rendererInitializer.get();
}
public RenderElement(Renderer renderer) { public RenderElement(Renderer renderer) {
this.bb = new SimpleBufferBuilder(1); this.bb = new SimpleBufferBuilder(1);
this.renderer = renderer; this.renderer = renderer;
@@ -136,7 +136,7 @@ public class RuntimeEnumExtender implements ILaunchPluginService {
classNode.methods.stream().filter(m -> m.name.equals("<init>")).forEach(m -> sb.append(" : ").append(m.desc).append("\n")); classNode.methods.stream().filter(m -> m.name.equals("<init>")).forEach(m -> sb.append(" : ").append(m.desc).append("\n"));
LOGGER.error(LogUtils.FATAL_MARKER, sb.toString()); LOGGER.error(LogUtils.FATAL_MARKER, sb.toString());
} }
throw new IllegalStateException("Enum has create method with no matching constructor: " + desc); throw new IllegalStateException("Enum has create method with no matching constructor: " + classType.getClassName() + " " + desc);
} }
if (values == null) if (values == null)
@@ -102,8 +102,8 @@ public class ImmediateWindowHandler {
return "default"; return "default";
} }
public static long setupMinecraftWindow(final int width, final int height, final String title, final long monitor, final Supplier<Object> backend) { public static long setupMinecraftWindow(final int width, final int height, final String title, final Supplier<Object> backend) {
return provider.setupMinecraftWindow(width, height, title, monitor, backend); return provider.setupMinecraftWindow(width, height, title, backend);
} }
public static boolean positionWindow(Optional<Object> monitor,IntConsumer widthSetter, IntConsumer heightSetter, IntConsumer xSetter, IntConsumer ySetter) { public static boolean positionWindow(Optional<Object> monitor,IntConsumer widthSetter, IntConsumer heightSetter, IntConsumer xSetter, IntConsumer ySetter) {
@@ -155,9 +155,9 @@ public class ImmediateWindowHandler {
} }
@Override @Override
public long setupMinecraftWindow(final int width, final int height, final String title, final long monitor, final Supplier<Object> backend) { public long setupMinecraftWindow(final int width, final int height, final String title, final Supplier<Object> backend) {
try { try {
var longsupplier = (LongSupplier)NV_HANDOFF.invoke(null, width, height, title, monitor, backend); var longsupplier = (LongSupplier)NV_HANDOFF.invoke(null, width, height, title, backend);
return longsupplier.getAsLong(); return longsupplier.getAsLong();
} catch (Throwable e) { } catch (Throwable e) {
throw new IllegalStateException("How did you get here?", e); throw new IllegalStateException("How did you get here?", e);
@@ -86,10 +86,9 @@ public interface ImmediateWindowProvider {
* @param width This is the width of the window Mojang expects * @param width This is the width of the window Mojang expects
* @param height This is the height of the Window Mojang expects. * @param height This is the height of the Window Mojang expects.
* @param title This is the title for the window. * @param title This is the title for the window.
* @param monitor This is the monitor it should appear on.
* @return The window id * @return The window id
*/ */
long setupMinecraftWindow(final int width, final int height, final String title, final long monitor, final Supplier<Object> backend); long setupMinecraftWindow(final int width, final int height, final String title, final Supplier<Object> backend);
/** /**
* This is called after window handoff to allow us to tell Mojang about our window's position. This might give a * This is called after window handoff to allow us to tell Mojang about our window's position. This might give a
@@ -32,12 +32,6 @@ record FieldToMethodTransformer(String className, Map<String, String> fields) im
// TODO [Forge][Transformer] Make this properly data driven or configurable. // TODO [Forge][Transformer] Make this properly data driven or configurable.
// It was hard-coded like this before when using JS CoreMods, though. // It was hard-coded like this before when using JS CoreMods, though.
static final Map<String, Map<String, String>> TARGETS = Map.of( static final Map<String, Map<String, String>> TARGETS = Map.of(
"net.minecraft.world.level.biome.Biome",
Map.of(
"climateSettings", "getModifiedClimateSettings",
"specialEffects", "getModifiedSpecialEffects"
),
"net.minecraft.world.effect.MobEffectInstance", "net.minecraft.world.effect.MobEffectInstance",
Map.of( Map.of(
"effect", "getEffect" "effect", "getEffect"
@@ -95,7 +95,7 @@
"class": "net/minecraft/world/level/NaturalSpawner", "class": "net/minecraft/world/level/NaturalSpawner",
"methods": [ "methods": [
"spawnCategoryForPosition(Lnet/minecraft/world/entity/MobCategory;Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/chunk/ChunkAccess;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/NaturalSpawner$SpawnPredicate;Lnet/minecraft/world/level/NaturalSpawner$AfterSpawnCallback;)V", "spawnCategoryForPosition(Lnet/minecraft/world/entity/MobCategory;Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/chunk/ChunkAccess;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/NaturalSpawner$SpawnPredicate;Lnet/minecraft/world/level/NaturalSpawner$AfterSpawnCallback;)V",
"spawnMobsForChunkGeneration(Lnet/minecraft/world/level/ServerLevelAccessor;Lnet/minecraft/core/Holder;Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/util/RandomSource;)V" "spawnMobsForChunkGeneration(Lnet/minecraft/world/level/ServerLevelAccessor;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/util/RandomSource;)V"
] ]
}, },
{ {
@@ -37,8 +37,7 @@ public @interface Mod {
/** /**
* Annotate a class which will be subscribed to an Event Bus at mod construction time. * Annotate a class which will be subscribed to an Event Bus at mod construction time.
* Defaults to subscribing the current modid to the {@code MinecraftForge#EVENT_BUS} * Defaults to subscribing the current modid to the {@link Bus#BOTH} on both sides.
* on both sides.
* *
* @see Bus * @see Bus
*/ */
@@ -45,7 +45,7 @@ import java.util.stream.Collectors;
/** /**
* Automatic eventbus subscriber - reads {@link EventBusSubscriber} * Automatic eventbus subscriber - reads {@link EventBusSubscriber}
* annotations and passes the class instances to the {@link Bus} * annotations and passes the class instances to the {@link Bus}
* defined by the annotation. Defaults to {@code MinecraftForge#EVENT_BUS} * defined by the annotation. Defaults to {@code Bus.BOTH} if not specified.
*/ */
public final class AutomaticEventSubscriber { public final class AutomaticEventSubscriber {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogManager.getLogger();
+4 -4
View File
@@ -1,6 +1,6 @@
[versions] [versions]
java = "25" java = "25"
minecraft = "26.2" minecraft = "26.3"
minecraft-next = "26.3" minecraft-next = "26.4"
mcp = "20260616.103818" mcp = "20260918.230105"
changelog-base = "65.0" changelog-base = "66.0"
@@ -1,30 +0,0 @@
--- a/com/mojang/blaze3d/opengl/GlTexture.java
+++ b/com/mojang/blaze3d/opengl/GlTexture.java
@@ -27,9 +_,14 @@
final int id,
final FrameBufferCache frameBufferCache
) {
+ this(usage, label, format, width, height, depthOrLayers, mipLevels, id, frameBufferCache, false);
+ }
+
+ protected GlTexture(@GpuTexture.Usage int usage, String label, GpuFormat format, int width, int height, int depthOrLayers, int mipLevels, int id, FrameBufferCache frameBufferCache, boolean stencil) {
super(usage, label, format, width, height, depthOrLayers, mipLevels);
this.id = id;
this.frameBufferCache = frameBufferCache;
+ this.stencilEnabled = stencil;
}
@Override
@@ -84,5 +_,12 @@
if (this.closed && this.views == 0) {
this.destroyImmediately();
}
+ }
+
+ private final boolean stencilEnabled;
+
+ @Override
+ public boolean isStencilEnabled() {
+ return this.stencilEnabled;
}
}
@@ -1,18 +1,18 @@
--- a/com/mojang/blaze3d/pipeline/RenderTarget.java --- a/com/mojang/blaze3d/pipeline/RenderTarget.java
+++ b/com/mojang/blaze3d/pipeline/RenderTarget.java +++ b/com/mojang/blaze3d/pipeline/RenderTarget.java
@@ -83,7 +_,7 @@ @@ -96,7 +_,7 @@
this.width = width; this.width = width;
this.height = height; this.height = height;
if (this.useDepth) { if (this.depthFormat != null) {
- this.depthTexture = device.createTexture(() -> this.label + " / Depth", 15, GpuFormat.D32_FLOAT, width, height, 1, 1); - this.depthTexture = device.createTexture(() -> this.label + " / Depth", 15, this.depthFormat, width, height, 1, 1);
+ this.depthTexture = device.createTexture(() -> this.label + " / Depth", 15, GpuFormat.D32_FLOAT, width, height, 1, 1, this.stencilEnabled); + this.depthTexture = device.createTexture(() -> this.label + " / Depth", 15, this.depthFormat, width, height, 1, 1, this.stencilEnabled);
this.depthTextureView = device.createTextureView(this.depthTexture); this.depthTextureView = device.createTextureView(this.depthTexture);
} }
@@ -121,5 +_,26 @@ @@ -140,5 +_,26 @@
public @Nullable GpuTextureView getDepthTextureView() { public boolean hasDepth() {
return this.depthTextureView; return this.depthFormat != null;
+ } + }
+ +
+ private boolean stencilEnabled = false; + private boolean stencilEnabled = false;
@@ -1,31 +1,33 @@
--- a/com/mojang/blaze3d/platform/Window.java --- a/com/mojang/blaze3d/platform/Window.java
+++ b/com/mojang/blaze3d/platform/Window.java +++ b/com/mojang/blaze3d/platform/Window.java
@@ -101,8 +_,9 @@ @@ -114,9 +_,10 @@
Monitor initialMonitor = monitorManager.getMonitor(GLFW.glfwGetPrimaryMonitor()); Monitor initialMonitor = monitorManager.getMonitor(SDLVideo.SDL_GetPrimaryDisplay());
this.windowedWidth = this.width = allowedWindowMinSize(displayData.width()); this.windowedWidth = this.width = allowedWindowMinSize(displayData.width(), 320);
this.windowedHeight = this.height = allowedWindowMinSize(displayData.height()); this.windowedHeight = this.height = allowedWindowMinSize(displayData.height(), 240);
- this.handle = this.createWindow(backend, this.width, this.height, title, this.fullscreen && initialMonitor != null ? initialMonitor.monitor() : 0L); - this.handle = this.createWindow(backend, this.width, this.height, title);
+ this.handle = net.minecraftforge.fml.loading.ImmediateWindowHandler.setupMinecraftWindow(this.width, this.height, title, this.fullscreen && initialMonitor != null ? initialMonitor.monitor() : 0L, () -> backend); + this.handle = net.minecraftforge.fml.loading.ImmediateWindowHandler.setupMinecraftWindow(this.width, this.height, title, () -> backend);
this.backend = backend; this.setWindowMaxSize(maximumSize, maximumSize);
MacosUtil.disableCloseWindowMenuItem();
+ if (!net.minecraftforge.fml.loading.ImmediateWindowHandler.positionWindow(Optional.ofNullable(initialMonitor), w->this.width = this.windowedWidth = w, h->this.height = this.windowedHeight = h, x->this.x = this.windowedX = x, y->this.y = this.windowedY = y)) { + if (!net.minecraftforge.fml.loading.ImmediateWindowHandler.positionWindow(Optional.ofNullable(initialMonitor), w->this.width = this.windowedWidth = w, h->this.height = this.windowedHeight = h, x->this.x = this.windowedX = x, y->this.y = this.windowedY = y)) {
if (initialMonitor != null) { if (initialMonitor != null) {
VideoMode mode = initialMonitor.getPreferredVidMode(this.fullscreen ? this.preferredFullscreenVideoMode : Optional.empty()); this.windowedX = this.x = initialMonitor.x() + (initialMonitor.w() - this.width) / 2;
this.windowedX = this.x = initialMonitor.x() + mode.getWidth() / 2 - this.width / 2; this.windowedY = this.y = initialMonitor.y() + (initialMonitor.h() - this.height) / 2;
@@ -114,6 +_,7 @@ @@ -132,6 +_,7 @@
this.windowedX = this.x = actualX[0]; this.windowedY = this.y = actualY.get(0);
this.windowedY = this.y = actualY[0]; }
} }
+ } + }
this.setMode(); this.setMode();
this.refreshFramebufferSize(); this.refreshFramebufferSize();
@@ -306,6 +_,9 @@ @@ -148,6 +_,10 @@
outHeight[0] = this.isSoftScreen() ? outHeight[0] - 1 : outHeight[0];
this.framebufferWidth = outWidth[0] > 0 ? outWidth[0] : 1;
this.framebufferHeight = outHeight[0] > 0 ? outHeight[0] : 1;
+ if (this.framebufferHeight == 0 || this.framebufferWidth == 0) {
+ net.minecraftforge.fml.loading.ImmediateWindowHandler.updateFBSize(w -> this.framebufferWidth = w, h -> this.framebufferHeight = h);
+ }
} }
private void onResize(final long handle, final int newWidth, final int newHeight) { private long createWindow(final GpuBackend backend, final int width, final int height, final String title) {
+ return createWindowStatic(backend, width, height, title);
+ }
+
+ public static long createWindowStatic(final GpuBackend backend, final int width, final int height, final String title) {
long flags = 8224L;
long windowHandle = backend.createWindow(title, width, height, 8224L);
if (windowHandle == 0L) {
@@ -1,20 +0,0 @@
--- a/com/mojang/blaze3d/systems/GpuDeviceBackend.java
+++ b/com/mojang/blaze3d/systems/GpuDeviceBackend.java
@@ -32,7 +_,17 @@
@Nullable Supplier<String> label, @GpuTexture.Usage int usage, GpuFormat format, int width, int height, int depthOrLayers, int mipLevels
);
+ /** Forge: same as {@link #createTexture(Supplier<String>, int, GpuFormat, int, int, int)} but with stencil support */
+ default GpuTexture createTexture(@Nullable Supplier<String> label, @GpuTexture.Usage final int usage, GpuFormat format, int width, int height, int depthOrLayers, int mipLevels, boolean stencil) {
+ return createTexture(label, usage, format, width, height, depthOrLayers, mipLevels);
+ }
+
GpuTexture createTexture(@Nullable String label, @GpuTexture.Usage int usage, GpuFormat format, int width, int height, int depthOrLayers, int mipLevels);
+
+ /** Forge: same as {@link #createTexture(String, int, GpuFormat, int, int, int)} but with stencil support */
+ default GpuTexture createTexture(@Nullable String label, @GpuTexture.Usage final int usage, GpuFormat format, int width, int height, int depthOrLayers, int mipLevels, boolean stencil) {
+ return createTexture(label, usage, format, width, height, depthOrLayers, mipLevels);
+ }
GpuTextureView createTextureView(GpuTexture texture);
@@ -1,11 +0,0 @@
--- a/com/mojang/blaze3d/textures/GpuTexture.java
+++ b/com/mojang/blaze3d/textures/GpuTexture.java
@@ -9,7 +_,7 @@
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
-public abstract class GpuTexture implements AutoCloseable {
+public abstract class GpuTexture implements AutoCloseable, net.minecraftforge.client.extensions.IForgeGpuTexture {
public static final int USAGE_COPY_DST = 1;
public static final int USAGE_COPY_SRC = 2;
public static final int USAGE_TEXTURE_BINDING = 4;
@@ -1,6 +1,6 @@
--- a/com/mojang/blaze3d/vertex/PoseStack.java --- a/com/mojang/blaze3d/vertex/PoseStack.java
+++ b/com/mojang/blaze3d/vertex/PoseStack.java +++ b/com/mojang/blaze3d/vertex/PoseStack.java
@@ -16,7 +_,7 @@ @@ -17,7 +_,7 @@
import org.joml.Vector3fc; import org.joml.Vector3fc;
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
@@ -5,7 +5,7 @@
@Override @Override
+ public boolean keyPressed(net.minecraft.client.input.KeyEvent event) { + public boolean keyPressed(net.minecraft.client.input.KeyEvent event) {
+ if (event.key() == org.lwjgl.glfw.GLFW.GLFW_KEY_ESCAPE) { + if (event.isEscape()) {
+ minecraft.gui.setScreen(this.nextScreen); + minecraft.gui.setScreen(this.nextScreen);
+ return true; + return true;
+ } + }
@@ -0,0 +1,20 @@
--- a/com/mojang/renderpearl/api/device/GpuDevice.java
+++ b/com/mojang/renderpearl/api/device/GpuDevice.java
@@ -37,7 +_,17 @@
@Nullable Supplier<String> label, @GpuTexture.Usage int usage, GpuFormat format, int width, int height, int depthOrLayers, int mipLevels
);
+ default GpuTexture createTexture(
+ @Nullable Supplier<String> label, @GpuTexture.Usage int usage, GpuFormat format, int width, int height, int depthOrLayers, int mipLevels, boolean stencil
+ ) {
+ return createTexture(label, usage, format, width, height, depthOrLayers, mipLevels);
+ }
+
GpuTexture createTexture(@Nullable String label, @GpuTexture.Usage int usage, GpuFormat format, int width, int height, int depthOrLayers, int mipLevels);
+
+ default GpuTexture createTexture(@Nullable String label, @GpuTexture.Usage int usage, GpuFormat format, int width, int height, int depthOrLayers, int mipLevels, boolean stencil) {
+ return createTexture(label, usage, format, width, height, depthOrLayers, mipLevels, stencil);
+ }
GpuTextureView createTextureView(GpuTexture texture);
@@ -0,0 +1,11 @@
--- a/com/mojang/renderpearl/api/textures/GpuTexture.java
+++ b/com/mojang/renderpearl/api/textures/GpuTexture.java
@@ -10,7 +_,7 @@
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
-public interface GpuTexture extends UncheckedAutoCloseable {
+public interface GpuTexture extends UncheckedAutoCloseable, net.minecraftforge.client.extensions.IForgeGpuTexture {
int USAGE_COPY_DST = 1;
int USAGE_COPY_SRC = 2;
int USAGE_TEXTURE_BINDING = 4;
@@ -1,5 +1,5 @@
--- a/com/mojang/blaze3d/vertex/VertexFormat.java --- a/com/mojang/renderpearl/api/vertex/VertexFormat.java
+++ b/com/mojang/blaze3d/vertex/VertexFormat.java +++ b/com/mojang/renderpearl/api/vertex/VertexFormat.java
@@ -19,6 +_,7 @@ @@ -19,6 +_,7 @@
private final int vertexSize; private final int vertexSize;
private final int stepRate; private final int stepRate;
@@ -8,7 +8,7 @@
private VertexFormat(final List<VertexFormatElement> elements, final int vertexSize, final int stepRate) { private VertexFormat(final List<VertexFormatElement> elements, final int vertexSize, final int stepRate) {
this.vertexSize = vertexSize; this.vertexSize = vertexSize;
@@ -29,6 +_,11 @@ @@ -29,7 +_,14 @@
} }
this.elementValues = elements; this.elementValues = elements;
@@ -18,14 +18,8 @@
+ elementMapping.put(element.name(), element); + elementMapping.put(element.name(), element);
+ this.elementMapping = elementMapping.buildOrThrow(); + this.elementMapping = elementMapping.buildOrThrow();
} }
public static VertexFormat.Builder builder(final int stepRate) {
@@ -69,6 +_,8 @@
public int hashCode() {
return this.elementValues.hashCode();
}
+ +
+ public com.google.common.collect.ImmutableMap<String, VertexFormatElement> getElementMapping() { return elementMapping; } + public com.google.common.collect.ImmutableMap<String, VertexFormatElement> getElementMapping() { return elementMapping; }
@OnlyIn(Dist.CLIENT) public static VertexFormat.Builder builder(final int stepRate) {
public static class Builder { return new VertexFormat.Builder(stepRate);
@@ -0,0 +1,13 @@
--- a/com/mojang/renderpearl/backend/api/GpuDeviceBackend.java
+++ b/com/mojang/renderpearl/backend/api/GpuDeviceBackend.java
@@ -30,6 +_,10 @@
GpuTexture createTexture(@Nullable String label, @GpuTexture.Usage int usage, GpuFormat format, int width, int height, int depthOrLayers, int mipLevels);
+ default GpuTexture createTexture(@Nullable String label, @GpuTexture.Usage int usage, GpuFormat format, int width, int height, int depthOrLayers, int mipLevels, boolean stencil) {
+ return createTexture(label, usage, format, width, height, depthOrLayers, mipLevels);
+ }
+
GpuTextureView createTextureView(GpuTexture texture, int baseMipLevel, int mipLevels);
GpuBuffer createBuffer(@Nullable Supplier<String> label, @GpuBuffer.Usage int usage, long size);
@@ -0,0 +1,43 @@
--- a/com/mojang/renderpearl/backend/common/BaseGpuTexture.java
+++ b/com/mojang/renderpearl/backend/common/BaseGpuTexture.java
@@ -24,6 +_,19 @@
final int depthOrLayers,
final int mipLevels
) {
+ this(usage, label, format, width, height, depthOrLayers, mipLevels, false);
+ }
+
+ public BaseGpuTexture(
+ final @GpuTexture.Usage int usage,
+ final String label,
+ final GpuFormat format,
+ final int width,
+ final int height,
+ final int depthOrLayers,
+ final int mipLevels,
+ final boolean stencil
+ ) {
this.usage = usage;
this.label = label;
this.format = format;
@@ -31,6 +_,7 @@
this.height = height;
this.depthOrLayers = depthOrLayers;
this.mipLevels = mipLevels;
+ this.stencilEnabled = stencil;
}
@Override
@@ -66,5 +_,12 @@
@Override
public String getLabel() {
return this.label;
+ }
+
+ private final boolean stencilEnabled;
+
+ @Override
+ public boolean isStencilEnabled() {
+ return this.stencilEnabled;
}
}
@@ -0,0 +1,11 @@
--- a/com/mojang/renderpearl/backend/opengl/GlBackend.java
+++ b/com/mojang/renderpearl/backend/opengl/GlBackend.java
@@ -38,6 +_,8 @@
"OpenGL is not supported: " + Objects.requireNonNullElse(SDLError.SDL_GetError(), "<no error>"),
BackendCreationException.Reason.OPENGL_MISSING
);
+ // If we have loaded the early loading screen, we expect the libraries to be loaded, so don't actually error
+ if (!"OpenGL is not supported: OpenGL library already loaded".equals(this.libraryLoadFailure.getMessage()))
throw this.libraryLoadFailure;
}
@@ -1,8 +1,8 @@
--- a/com/mojang/blaze3d/opengl/GlCommandEncoder.java --- a/com/mojang/renderpearl/backend/opengl/GlCommandEncoder.java
+++ b/com/mojang/blaze3d/opengl/GlCommandEncoder.java +++ b/com/mojang/renderpearl/backend/opengl/GlCommandEncoder.java
@@ -201,6 +_,9 @@ @@ -208,6 +_,9 @@
GlStateManager._colorMask(15); }
GlStateManager._clear(16384);
GlStateManager._glFramebufferTexture2D(36160, 36064, 3553, 0, 0); GlStateManager._glFramebufferTexture2D(36160, 36064, 3553, 0, 0);
+ // Forge: if using stencil, clear it as well (3553 = GlConst.GL_TEXTURE_2D) + // Forge: if using stencil, clear it as well (3553 = GlConst.GL_TEXTURE_2D)
+ if (colorTexture.isStencilEnabled()) + if (colorTexture.isStencilEnabled())
@@ -1,5 +1,5 @@
--- a/com/mojang/blaze3d/opengl/GlConst.java --- a/com/mojang/renderpearl/backend/opengl/GlConst.java
+++ b/com/mojang/blaze3d/opengl/GlConst.java +++ b/com/mojang/renderpearl/backend/opengl/GlConst.java
@@ -239,6 +_,10 @@ @@ -239,6 +_,10 @@
} }
@@ -1,5 +1,5 @@
--- a/com/mojang/blaze3d/opengl/GlDebug.java --- a/com/mojang/renderpearl/backend/opengl/GlDebug.java
+++ b/com/mojang/blaze3d/opengl/GlDebug.java +++ b/com/mojang/renderpearl/backend/opengl/GlDebug.java
@@ -22,6 +_,14 @@ @@ -22,6 +_,14 @@
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
@@ -1,20 +1,6 @@
--- a/com/mojang/blaze3d/opengl/GlDevice.java --- a/com/mojang/renderpearl/backend/opengl/GlDevice.java
+++ b/com/mojang/blaze3d/opengl/GlDevice.java +++ b/com/mojang/renderpearl/backend/opengl/GlDevice.java
@@ -150,7 +_,12 @@ @@ -200,6 +_,11 @@
final int depthOrLayers,
final int mipLevels
) {
- return this.createTexture(this.debugLabels.exists() && label != null ? label.get() : null, usage, format, width, height, depthOrLayers, mipLevels);
+ return this.createTexture(label, usage, format, width, height, depthOrLayers, mipLevels, false);
+ }
+
+ @Override
+ public GpuTexture createTexture(final @Nullable Supplier<String> label, @GpuTexture.Usage final int usage, final GpuFormat format, final int width, final int height, final int depthOrLayers, final int mipLevels, final boolean stencil) {
+ return this.createTexture(this.debugLabels.exists() && label != null ? label.get() : null, usage, format, width, height, depthOrLayers, mipLevels, stencil);
}
@Override
@@ -163,6 +_,11 @@
final int depthOrLayers, final int depthOrLayers,
final int mipLevels final int mipLevels
) { ) {
@@ -26,7 +12,7 @@
GlStateManager.clearGlErrors(); GlStateManager.clearGlErrors();
int id = GlStateManager._genTexture(); int id = GlStateManager._genTexture();
if (label == null) { if (label == null) {
@@ -186,9 +_,9 @@ @@ -223,9 +_,9 @@
GlStateManager._texParameter(target, 34892, 0); GlStateManager._texParameter(target, 34892, 0);
} }
@@ -39,7 +25,7 @@
if (glInternalID != 0 && glExternalID != 0 && glType != 0) { if (glInternalID != 0 && glExternalID != 0 && glType != 0) {
if (isCubemap) { if (isCubemap) {
for (int cubeTarget : GlConst.CUBEMAP_TARGETS) { for (int cubeTarget : GlConst.CUBEMAP_TARGETS) {
@@ -211,7 +_,7 @@ @@ -248,7 +_,7 @@
throw new IllegalStateException("OpenGL error " + error); throw new IllegalStateException("OpenGL error " + error);
} }
@@ -1,18 +1,18 @@
--- a/com/mojang/blaze3d/opengl/GlStateManager.java --- a/com/mojang/renderpearl/backend/opengl/GlStateManager.java
+++ b/com/mojang/blaze3d/opengl/GlStateManager.java +++ b/com/mojang/renderpearl/backend/opengl/GlStateManager.java
@@ -80,6 +_,11 @@ @@ -82,6 +_,11 @@
} }
} }
+ public static boolean _isBlendEnabled(int index) { + public static boolean _isBlendEnabled(int index) {
+ RenderSystem.assertOnRenderThread(); + RenderSystem.assertOnRenderThread();
+ return BLEND[index].mode.enabled; + return BLEND_ENABLE[index];
+ } + }
+ +
public static void _disableBlend(int index) { public static void _disableBlend(final int index) {
RenderSystem.assertOnRenderThread(); RenderSystem.assertOnRenderThread();
BLEND[index].mode.disable(); if (BLEND_ENABLE[index]) {
@@ -390,9 +_,17 @@ @@ -401,9 +_,17 @@
} }
} }
@@ -0,0 +1,15 @@
--- a/com/mojang/renderpearl/backend/opengl/GlTexture.java
+++ b/com/mojang/renderpearl/backend/opengl/GlTexture.java
@@ -28,7 +_,11 @@
final int id,
final FrameBufferCache frameBufferCache
) {
- super(usage, label, format, width, height, depthOrLayers, mipLevels);
+ this(usage, label, format, width, height, depthOrLayers, mipLevels, id, frameBufferCache, false);
+ }
+
+ protected GlTexture(@GpuTexture.Usage int usage, String label, GpuFormat format, int width, int height, int depthOrLayers, int mipLevels, int id, FrameBufferCache frameBufferCache, boolean stencil) {
+ super(usage, label, format, width, height, depthOrLayers, mipLevels, stencil);
this.id = id;
this.frameBufferCache = frameBufferCache;
}
@@ -0,0 +1,25 @@
--- a/com/mojang/renderpearl/backend/vulkan/VulkanDevice.java
+++ b/com/mojang/renderpearl/backend/vulkan/VulkanDevice.java
@@ -213,7 +_,21 @@
final int depthOrLayers,
final int mipLevels
) {
- return new VulkanGpuTexture(this, usage, this.isDebuggingEnabled() && label != null ? label : "", format, width, height, depthOrLayers, mipLevels);
+ return createTexture(label, usage, format, width, height, depthOrLayers, mipLevels, false);
+ }
+
+ @Override
+ public GpuTexture createTexture(
+ final @Nullable String label,
+ final @GpuTexture.Usage int usage,
+ final GpuFormat format,
+ final int width,
+ final int height,
+ final int depthOrLayers,
+ final int mipLevels,
+ final boolean stencil
+ ) {
+ return new VulkanGpuTexture(this, usage, this.isDebuggingEnabled() && label != null ? label : "", format, width, height, depthOrLayers, mipLevels, stencil);
}
@Override
@@ -0,0 +1,25 @@
--- a/com/mojang/renderpearl/backend/vulkan/VulkanGpuTexture.java
+++ b/com/mojang/renderpearl/backend/vulkan/VulkanGpuTexture.java
@@ -34,7 +_,21 @@
final int depthOrLayers,
final int mipLevels
) {
- super(usage, label, format, width, height, depthOrLayers, mipLevels);
+ this(device, usage, label, format, width, height, depthOrLayers, mipLevels, false);
+ }
+
+ public VulkanGpuTexture(
+ final VulkanDevice device,
+ final @GpuTexture.Usage int usage,
+ final String label,
+ final GpuFormat format,
+ final int width,
+ final int height,
+ final int depthOrLayers,
+ final int mipLevels,
+ final boolean stencil
+ ) {
+ super(usage, label, format, width, height, depthOrLayers, mipLevels, stencil);
this.device = device;
try (MemoryStack stack = MemoryStack.stackPush()) {
@@ -1,13 +1,14 @@
--- a/com/mojang/blaze3d/systems/GpuDevice.java --- a/com/mojang/renderpearl/frontend/FrontendGpuDevice.java
+++ b/com/mojang/blaze3d/systems/GpuDevice.java +++ b/com/mojang/renderpearl/frontend/FrontendGpuDevice.java
@@ -73,6 +_,21 @@ @@ -94,6 +_,21 @@
return this.backend.createTexture(label, usage, format, width, height, depthOrLayers, mipLevels); return this.createTexture(this.isDebuggingEnabled() && label != null ? label.get() : null, usage, format, width, height, depthOrLayers, mipLevels);
} }
+ /** Forge: same as {@link #createTexture(Supplier, int, GpuFormat, int, int, int)} but with stencil support */ + /** Forge: same as {@link #createTexture(Supplier, int, GpuFormat, int, int, int, int)} but with stencil support */
+ @Override
+ public GpuTexture createTexture( + public GpuTexture createTexture(
+ final @Nullable Supplier<String> label, + final @Nullable Supplier<String> label,
+ @GpuTexture.Usage final int usage, + final @GpuTexture.Usage int usage,
+ final GpuFormat format, + final GpuFormat format,
+ final int width, + final int width,
+ final int height, + final int height,
@@ -15,23 +16,23 @@
+ final int mipLevels, + final int mipLevels,
+ final boolean stencil + final boolean stencil
+ ) { + ) {
+ this.verifyTextureCreationArgs(usage, width, height, depthOrLayers, mipLevels); + return this.createTexture(this.isDebuggingEnabled() && label != null ? label.get() : null, usage, format, width, height, depthOrLayers, mipLevels, stencil);
+ return this.backend.createTexture(label, usage, format, width, height, depthOrLayers, mipLevels, stencil);
+ } + }
+ +
@Override
public GpuTexture createTexture( public GpuTexture createTexture(
final @Nullable String label, final @Nullable String label,
final @GpuTexture.Usage int usage, @@ -106,6 +_,22 @@
@@ -84,6 +_,21 @@
) { ) {
this.verifyTextureCreationArgs(usage, width, height, depthOrLayers, mipLevels); this.verifyTextureCreationArgs(usage, width, height, depthOrLayers, mipLevels);
return this.backend.createTexture(label, usage, format, width, height, depthOrLayers, mipLevels); return this.backend.createTexture(label, usage, format, width, height, depthOrLayers, mipLevels);
+ } + }
+ +
+ /** Forge: same as {@link #createTexture(Supplier, int, GpuFormat, int, int, int)} but with stencil support */ + /** Forge: same as {@link #createTexture(String, int, GpuFormat, int, int, int, int)} but with stencil support */
+ @Override
+ public GpuTexture createTexture( + public GpuTexture createTexture(
+ final @Nullable String label, + final @Nullable String label,
+ @GpuTexture.Usage final int usage, + final @GpuTexture.Usage int usage,
+ final GpuFormat format, + final GpuFormat format,
+ final int width, + final int width,
+ final int height, + final int height,
@@ -1,6 +1,6 @@
--- a/net/minecraft/SharedConstants.java --- a/net/minecraft/SharedConstants.java
+++ b/net/minecraft/SharedConstants.java +++ b/net/minecraft/SharedConstants.java
@@ -218,6 +_,7 @@ @@ -219,6 +_,7 @@
} }
static { static {
@@ -1,15 +1,62 @@
--- a/net/minecraft/advancements/Advancement.java --- a/net/minecraft/advancements/Advancement.java
+++ b/net/minecraft/advancements/Advancement.java +++ b/net/minecraft/advancements/Advancement.java
@@ -220,7 +_,11 @@ @@ -31,11 +_,12 @@
Map<String, Criterion<?>> criteria,
AdvancementRequirements requirements,
boolean sendsTelemetryEvent,
- Optional<Component> name
+ Optional<Component> name,
+ Optional<java.util.List<net.minecraftforge.common.crafting.ConditionalAdvancement>> forgeConditions
) {
private static final Codec<Map<String, Criterion<?>>> CRITERIA_CODEC = Codec.unboundedMap(Codec.STRING, Criterion.CODEC)
.validate(criteria -> criteria.isEmpty() ? DataResult.error(() -> "Advancement criteria cannot be empty") : DataResult.success(criteria));
- public static final Codec<Advancement> CODEC = RecordCodecBuilder.<Advancement>create(
+ public static final Codec<Advancement> CODEC = net.minecraftforge.common.crafting.ConditionalAdvancement.wrapCodec(RecordCodecBuilder.<Advancement>mapCodec(
i -> i.group(
Identifier.CODEC.optionalFieldOf("parent").forGetter(Advancement::parent),
DisplayInfo.CODEC.optionalFieldOf("display").forGetter(Advancement::display),
@@ -49,7 +_,7 @@
return new Advancement(parent, display, rewards, criteria, requirements, sendsTelemetryEvent);
})
)
- .validate(Advancement::validate);
+ .validate(Advancement::validate));
public static final StreamCodec<RegistryFriendlyByteBuf, Advancement> STREAM_CODEC = StreamCodec.composite(
Identifier.STREAM_CODEC.apply(ByteBufCodecs::optional),
Advancement::parent,
@@ -70,9 +_,21 @@
final AdvancementRewards rewards,
final Map<String, Criterion<?>> criteria,
final AdvancementRequirements requirements,
+ final boolean sendsTelemetryEvent,
+ final Optional<Component> name
+ ) {
+ this(parent, display, rewards, criteria, requirements, sendsTelemetryEvent, name, Optional.empty());
+ }
+
+ public Advancement(
+ final Optional<Identifier> parent,
+ final Optional<DisplayInfo> display,
+ final AdvancementRewards rewards,
+ final Map<String, Criterion<?>> criteria,
+ final AdvancementRequirements requirements,
final boolean sendsTelemetryEvent
) {
- this(parent, display, rewards, Map.copyOf(criteria), requirements, sendsTelemetryEvent, display.map(Advancement::decorateName));
+ this(parent, display, rewards, Map.copyOf(criteria), requirements, sendsTelemetryEvent, display.map(Advancement::decorateName), Optional.empty());
}
private static DataResult<Advancement> validate(final Advancement advancement) {
@@ -235,7 +_,11 @@
} }
public AdvancementHolder save(final Consumer<AdvancementHolder> output, final String name) { public AdvancementHolder save(final BootstrapContext<Advancement> output, final String name) {
- AdvancementHolder advancement = this.build(Identifier.parse(name)); - AdvancementHolder advancement = this.build(Identifier.parse(name));
+ return save(output, Identifier.parse(name)); + return save(output, Identifier.parse(name));
+ } + }
+ +
+ public AdvancementHolder save(Consumer<AdvancementHolder> output, Identifier id) { + public AdvancementHolder save(final BootstrapContext<Advancement> output, final Identifier id) {
+ AdvancementHolder advancement = this.build(id); + AdvancementHolder advancement = this.build(id);
output.accept(advancement); advancement.register(output);
return advancement; return advancement;
} }
@@ -1,6 +1,6 @@
--- a/net/minecraft/advancements/AdvancementRewards.java --- a/net/minecraft/advancements/AdvancementRewards.java
+++ b/net/minecraft/advancements/AdvancementRewards.java +++ b/net/minecraft/advancements/AdvancementRewards.java
@@ -43,6 +_,7 @@ @@ -46,6 +_,7 @@
LootParams params = new LootParams.Builder(level) LootParams params = new LootParams.Builder(level)
.withParameter(LootContextParams.THIS_ENTITY, player) .withParameter(LootContextParams.THIS_ENTITY, player)
.withParameter(LootContextParams.ORIGIN, player.position()) .withParameter(LootContextParams.ORIGIN, player.position())
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/Camera.java --- a/net/minecraft/client/Camera.java
+++ b/net/minecraft/client/Camera.java +++ b/net/minecraft/client/Camera.java
@@ -224,11 +_,13 @@ @@ -228,11 +_,13 @@
} }
float fov = this.minecraft.options.fov().get().intValue() * Mth.lerp(partialTicks, this.oldFovModifier, this.fovModifier); float fov = this.minecraft.options.fov().get().intValue() * Mth.lerp(partialTicks, this.oldFovModifier, this.fovModifier);
@@ -16,7 +16,7 @@
} }
private float modifyFovBasedOnDeathOrFluid(final float partialTicks, float fov) { private float modifyFovBasedOnDeathOrFluid(final float partialTicks, float fov) {
@@ -337,9 +_,13 @@ @@ -341,9 +_,13 @@
} }
protected void setRotation(final float yRot, final float xRot) { protected void setRotation(final float yRot, final float xRot) {
@@ -31,7 +31,7 @@
FORWARDS.rotate(this.rotation, this.forwards); FORWARDS.rotate(this.rotation, this.forwards);
UP.rotate(this.rotation, this.up); UP.rotate(this.rotation, this.up);
LEFT.rotate(this.rotation, this.left); LEFT.rotate(this.rotation, this.left);
@@ -370,6 +_,13 @@ @@ -374,6 +_,13 @@
public float yRot() { public float yRot() {
return this.yRot; return this.yRot;
@@ -70,7 +70,7 @@
return this.key.equals(that.key); return this.key.equals(that.key);
} }
@@ -179,11 +_,13 @@ @@ -177,11 +_,13 @@
} }
public Component getTranslatedKeyMessage() { public Component getTranslatedKeyMessage() {
@@ -85,7 +85,7 @@
} }
public String saveString() { public String saveString() {
@@ -195,11 +_,94 @@ @@ -193,11 +_,94 @@
} }
private void registerMapping(final InputConstants.Key key) { private void registerMapping(final InputConstants.Key key) {
@@ -1,15 +1,15 @@
--- a/net/minecraft/client/KeyboardHandler.java --- a/net/minecraft/client/KeyboardHandler.java
+++ b/net/minecraft/client/KeyboardHandler.java +++ b/net/minecraft/client/KeyboardHandler.java
@@ -478,7 +_,7 @@ @@ -496,7 +_,7 @@
if (screen != null) { if (screen != null) {
try { try {
if (action != 1 && action != 2) { if (action != 1 && action != -1) {
- if (action == 0 && screen.keyReleased(event)) { - if (action == 0 && screen.keyReleased(event)) {
+ if (action == 0 && net.minecraftforge.client.ForgeHooksClient.onScreenKeyReleased(screen, event)) { + if (action == 0 && net.minecraftforge.client.ForgeHooksClient.onScreenKeyReleased(screen, event)) {
if (options.keyDebugModifier.matches(event)) { if (options.keyDebugModifier.matches(event)) {
this.usedDebugKeyAsModifier = false; this.usedDebugKeyAsModifier = false;
} }
@@ -487,7 +_,7 @@ @@ -505,7 +_,7 @@
} }
} else { } else {
screen.afterKeyboardAction(); screen.afterKeyboardAction();
@@ -18,7 +18,7 @@
if (this.minecraft.gui.screen() == null) { if (this.minecraft.gui.screen() == null) {
InputConstants.Key key = InputConstants.getKey(event); InputConstants.Key key = InputConstants.getKey(event);
KeyMapping.set(key, false); KeyMapping.set(key, false);
@@ -562,6 +_,7 @@ @@ -578,6 +_,7 @@
} }
} }
} }
@@ -26,7 +26,7 @@
} }
} }
@@ -570,7 +_,7 @@ @@ -586,7 +_,7 @@
Screen screen = this.minecraft.gui.screen(); Screen screen = this.minecraft.gui.screen();
if (screen != null && this.minecraft.gui.overlay() == null) { if (screen != null && this.minecraft.gui.overlay() == null) {
try { try {
@@ -34,4 +34,4 @@
+ net.minecraftforge.client.ForgeHooksClient.onScreenCharTyped(screen, event); + net.minecraftforge.client.ForgeHooksClient.onScreenCharTyped(screen, event);
} catch (Throwable t) { } catch (Throwable t) {
CrashReport report = CrashReport.forThrowable(t, "charTyped event handler"); CrashReport report = CrashReport.forThrowable(t, "charTyped event handler");
screen.fillCrashDetails(report); CrashReportCategory keyDetails = report.addCategory("Key");
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/Minecraft.java --- a/net/minecraft/client/Minecraft.java
+++ b/net/minecraft/client/Minecraft.java +++ b/net/minecraft/client/Minecraft.java
@@ -258,7 +_,7 @@ @@ -265,7 +_,7 @@
import org.slf4j.Logger; import org.slf4j.Logger;
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
@@ -8,8 +8,8 @@
+public class Minecraft extends ReentrantBlockableEventLoop<Runnable> implements WindowEventHandler, net.minecraftforge.client.extensions.IForgeMinecraft { +public class Minecraft extends ReentrantBlockableEventLoop<Runnable> implements WindowEventHandler, net.minecraftforge.client.extensions.IForgeMinecraft {
private static Minecraft instance; private static Minecraft instance;
private static final Logger LOGGER = LogUtils.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
private static final int MAX_TICKS_PER_UPDATE = 10; private static final SectionCategory TRACY_CURRENT_LEVEL = TracyClient.createSectionCategory("Level");
@@ -410,7 +_,6 @@ @@ -420,7 +_,6 @@
} }
}, Util.nonCriticalIoPool()); }, Util.nonCriticalIoPool());
LOGGER.info("Setting user: {}", this.user.getName()); LOGGER.info("Setting user: {}", this.user.getName());
@@ -17,30 +17,23 @@
this.demo = gameConfig.game.demo; this.demo = gameConfig.game.demo;
this.allowsMultiplayer = !gameConfig.game.disableMultiplayer; this.allowsMultiplayer = !gameConfig.game.disableMultiplayer;
this.allowsChat = !gameConfig.game.disableChat; this.allowsChat = !gameConfig.game.disableChat;
@@ -547,12 +_,12 @@ @@ -568,6 +_,7 @@
LOGGER.error("Couldn't set icon", e);
}
+ // FORGE: Move mouse and keyboard handler setup further below
this.mouseHandler = new MouseHandler(this);
- this.mouseHandler.setup(this.window);
this.keyboardHandler = new KeyboardHandler(this); this.keyboardHandler = new KeyboardHandler(this);
- this.keyboardHandler.setup(this.window);
this.options.applyGraphicsPreset(this.options.graphicsPreset().get()); this.options.applyGraphicsPreset(this.options.graphicsPreset().get());
this.resourceManager = new ReloadableResourceManager(PackType.CLIENT_RESOURCES); this.resourceManager = new ReloadableResourceManager(PackType.CLIENT_RESOURCES);
+ net.minecraftforge.client.loading.ClientModLoader.begin(this, this.resourcePackRepository, this.resourceManager); + net.minecraftforge.client.loading.ClientModLoader.begin(this, this.resourcePackRepository, this.resourceManager);
this.resourcePackRepository.reload(); this.resourcePackRepository.reload();
this.options.loadSelectedResourcePacks(this.resourcePackRepository); this.options.loadSelectedResourcePacks(this.resourcePackRepository);
this.languageManager = new LanguageManager(this.options.languageCode, var1 -> { this.languageManager = new LanguageManager(this, this.options.languageCode, var1 -> {
@@ -630,6 +_,7 @@ @@ -645,6 +_,7 @@
ParticleResources particleResources = new ParticleResources(); ParticleResources particleResources = new ParticleResources();
this.resourceManager.registerReloadListener(particleResources); this.resourceManager.registerReloadListener(particleResources);
this.particleEngine = new ParticleEngine(this.level, particleResources); this.particleEngine = new ParticleEngine(this.level, particleResources);
+ net.minecraftforge.client.ForgeHooksClient.onRegisterParticleProviders(particleResources); + net.minecraftforge.client.ForgeHooksClient.onRegisterParticleProviders(particleResources);
particleResources.onReload(this.particleEngine::clearParticles); particleResources.onReload(this.particleEngine::clearParticles);
this.gameRenderer = new GameRenderer(this, this.entityRenderDispatcher.getItemInHandRenderer(), this.modelManager); this.gameRenderer = new GameRenderer(this, new FirstPersonHandsAndItemsRenderer(this), this.modelManager, this.itemModelResolver);
WindowRenderState windowRenderState = this.gameRenderer.gameRenderState().windowRenderState; this.resourceManager.registerReloadListener(this.gameRenderer);
@@ -647,6 +_,7 @@ @@ -663,6 +_,7 @@
this.window.getHeight() this.window.getHeight()
); );
this.levelExtractor = new LevelExtractor(this, this.gameRenderer.gameRenderState().levelRenderState, this.levelRenderer); this.levelExtractor = new LevelExtractor(this, this.gameRenderer.gameRenderState().levelRenderState, this.levelRenderer);
@@ -48,25 +41,15 @@
this.resourceManager.registerReloadListener(this.levelExtractor); this.resourceManager.registerReloadListener(this.levelExtractor);
this.resourceManager.registerReloadListener(this.levelRenderer.cloudRenderer()); this.resourceManager.registerReloadListener(this.levelRenderer.cloudRenderer());
this.gpuWarnlistManager = new GpuWarnlistManager(); this.gpuWarnlistManager = new GpuWarnlistManager();
@@ -654,6 +_,9 @@ @@ -694,6 +_,7 @@
this.resourceManager.registerReloadListener(this.regionalCompliancies); MessageBox.error(message.toString());
this.gui = new Gui(this, new Hud(this), this.gameRenderer.gameRenderState().guiRenderState);
this.gui.registerReloadListeners(this.resourceManager);
+ // FORGE: Moved keyboard and mouse handler setup below ingame gui creation to prevent NPEs in them.
+ this.mouseHandler.setup(this.window);
+ this.keyboardHandler.setup(this.window);
RealmsClient realmsClient = RealmsClient.getOrCreate(this);
this.realmsDataFetcher = new RealmsDataFetcher(realmsClient);
RenderSystem.setErrorCallback(this::onFullscreenError);
@@ -686,6 +_,7 @@
}
} }
+ net.minecraftforge.client.ForgeHooksClient.initClientHooks(this, this.resourceManager); + net.minecraftforge.client.ForgeHooksClient.initClientHooks(this, this.resourceManager);
this.window.updateRawMouseInput(this.options.rawMouseInput().get());
this.window.setAllowCursorChanges(this.options.allowCursorChanges().get()); this.window.setAllowCursorChanges(this.options.allowCursorChanges().get());
this.window.setDefaultErrorCallback(); this.window.setQuitShortcuts(this.options.quitShortcuts().get());
@@ -710,14 +_,15 @@ if (InputQuirks.EMULATE_RIGHT_CLICK_WITH_CTRL_KEY) {
@@ -721,14 +_,15 @@
.createReload(Util.backgroundExecutor().forName("resourceLoad"), this, RESOURCE_RELOAD_INITIAL_TASK, packs); .createReload(Util.backgroundExecutor().forName("resourceLoad"), this, RESOURCE_RELOAD_INITIAL_TASK, packs);
GameLoadTimesEvent.INSTANCE.beginStep(TelemetryProperty.LOAD_TIME_LOADING_OVERLAY_MS); GameLoadTimesEvent.INSTANCE.beginStep(TelemetryProperty.LOAD_TIME_LOADING_OVERLAY_MS);
GameLoadCookie loadCookie = new GameLoadCookie(realmsClient, gameConfig.quickPlay); GameLoadCookie loadCookie = new GameLoadCookie(realmsClient, gameConfig.quickPlay);
@@ -84,7 +67,7 @@
this.quickPlayLog = QuickPlayLog.of(gameConfig.quickPlay.logPath()); this.quickPlayLog = QuickPlayLog.of(gameConfig.quickPlay.logPath());
this.framerateLimitTracker = new FramerateLimitTracker(this.options, this); this.framerateLimitTracker = new FramerateLimitTracker(this.options, this);
this.fpsPieProfiler = new ContinuousProfiler(Util.timeSource(), () -> this.fpsPieRenderTicks, this.framerateLimitTracker::isHeavilyThrottled); this.fpsPieProfiler = new ContinuousProfiler(Util.timeSource(), () -> this.fpsPieRenderTicks, this.framerateLimitTracker::isHeavilyThrottled);
@@ -801,6 +_,7 @@ @@ -812,6 +_,7 @@
StringBuilder builder = new StringBuilder("Minecraft"); StringBuilder builder = new StringBuilder("Minecraft");
if (checkModStatus().shouldReportAsModified()) { if (checkModStatus().shouldReportAsModified()) {
builder.append("*"); builder.append("*");
@@ -92,16 +75,16 @@
} }
builder.append(" "); builder.append(" ");
@@ -824,6 +_,8 @@ @@ -835,6 +_,8 @@
} }
private static UserApiService createUserApiService(final YggdrasilAuthenticationService authService, final GameConfig config) { private static UserApiService createUserApiService(final MinecraftServicesDiscoveryService discoveryService, final GameConfig config) {
+ if ("0".equals(config.user.user.getAccessToken())) // Forge: We use "0" in dev. Short circuit to stop exception spam. + if ("0".equals(config.user.user.getAccessToken())) // Forge: We use "0" in dev. Short circuit to stop exception spam.
+ return UserApiService.OFFLINE; + return UserApiService.OFFLINE;
return config.game.offlineDeveloperMode ? UserApiService.OFFLINE : authService.createUserApiService(config.user.user.getAccessToken()); return config.game.offlineDeveloperMode ? UserApiService.OFFLINE : discoveryService.createUserApiService(config.user.user.getAccessToken());
} }
@@ -840,7 +_,7 @@ @@ -851,7 +_,7 @@
} }
private void rollbackResourcePacks(final Throwable t, final @Nullable GameLoadCookie loadCookie) { private void rollbackResourcePacks(final Throwable t, final @Nullable GameLoadCookie loadCookie) {
@@ -110,33 +93,33 @@
this.clearResourcePacksOnError(t, null, loadCookie); this.clearResourcePacksOnError(t, null, loadCookie);
} else { } else {
Util.throwAsRuntime(t); Util.throwAsRuntime(t);
@@ -1141,6 +_,7 @@ @@ -1148,6 +_,7 @@
Util.shutdownExecutors(); FreeTypeUtil.destroy();
this.windowSurface.close(); this.windowSurface.close();
RenderSystem.shutdownRenderer(); RenderSystem.shutdownRenderer();
+ net.minecraftforge.fml.config.ConfigTracker.forceUnload(); + net.minecraftforge.fml.config.ConfigTracker.forceUnload();
} catch (Throwable t) { } catch (Throwable t) {
LOGGER.error("Shutdown failure!", t); LOGGER.error("Shutdown failure!", t);
throw t; throw t;
@@ -1301,7 +_,9 @@ @@ -1305,7 +_,9 @@
profiler.popPush("gpuAsync"); profiler.popPush("gpuAsync");
RenderSystem.executePendingTasks(); RenderSystem.executePendingTasks();
profiler.pop(); profiler.pop();
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderTickStart(this.deltaTracker); + net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderTickStart(this.deltaTracker);
this.gameRenderer.render(this.deltaTracker, advanceGameTime); this.gameRenderer.render();
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderTickEnd(this.deltaTracker); + net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderTickEnd(this.deltaTracker);
} }
profiler.push("present"); profiler.push("swapchainBlit");
@@ -1425,6 +_,7 @@ @@ -1432,6 +_,7 @@
this.window.setGuiScale(guiScale); this.window.setGuiScale(guiScale);
if (this.gui.screen() != null) { if (this.gui.screen() != null) {
this.gui.screen().resize(this.window.getGuiScaledWidth(), this.window.getGuiScaledHeight()); this.gui.screen().resize(this.window.getGuiScaledWidth(), this.window.getGuiScaledHeight());
+ this.gui.resizeLayers(this.window.getGuiScaledWidth(), this.window.getGuiScaledHeight()); + this.gui.resizeLayers(this.window.getGuiScaledWidth(), this.window.getGuiScaledHeight());
} }
this.mouseHandler.setIgnoreFirstMove(); this.mouseHandler.resyncMousePosition();
@@ -1576,6 +_,7 @@ @@ -1595,6 +_,7 @@
} }
public void stop() { public void stop() {
@@ -144,38 +127,35 @@
this.running = false; this.running = false;
} }
@@ -1599,10 +_,18 @@ @@ -1622,9 +_,16 @@
if (down && this.hitResult != null && this.hitResult.getType() == HitResult.Type.BLOCK) { if (down && this.hitResult != null && this.hitResult.getType() == HitResult.Type.BLOCK) {
BlockHitResult blockHit = (BlockHitResult)this.hitResult; BlockHitResult blockHit = (BlockHitResult)this.hitResult;
BlockPos pos = blockHit.getBlockPos(); BlockPos pos = blockHit.getBlockPos();
- if (!this.level.getBlockState(pos).isAir()) { - if (!this.level.getBlockState(pos).isAir()) {
+ if (!this.level.isEmptyBlock(pos)) { + if (!this.level.isEmptyBlock(pos)) {
+ var inputEvent = new net.minecraftforge.client.event.InputEvent.InteractionKeyMappingTriggered(0, this.options.keyAttack, InteractionHand.MAIN_HAND); + var inputEvent = new net.minecraftforge.client.event.InputEvent.InteractionKeyMappingTriggered.Attack(this.options.keyAttack, InteractionHand.MAIN_HAND);
+ if (net.minecraftforge.client.event.InputEvent.InteractionKeyMappingTriggered.BUS.post(inputEvent)) { + if (net.minecraftforge.client.event.InputEvent.InteractionKeyMappingTriggered.Attack.BUS.post(inputEvent)) {
+ if (inputEvent.shouldSwingHand()) { + if (inputEvent.shouldSwingHand()) {
+ this.level.addBreakingBlockEffect(pos, blockHit); + this.player.swing(InteractionHand.MAIN_HAND, swingAnimation, false);
+ this.player.swing(InteractionHand.MAIN_HAND);
+ } + }
+ return; + return;
+ } + }
Direction direction = blockHit.getDirection(); Direction direction = blockHit.getDirection();
- if (this.gameMode.continueDestroyBlock(pos, direction)) { - if (this.gameMode.continueDestroyBlock(pos, direction)) {
- this.level.addBreakingBlockEffect(pos, direction);
+ if (this.gameMode.continueDestroyBlock(pos, direction) && inputEvent.shouldSwingHand()) { + if (this.gameMode.continueDestroyBlock(pos, direction) && inputEvent.shouldSwingHand()) {
+ this.level.addBreakingBlockEffect(pos, blockHit); this.player.swing(InteractionHand.MAIN_HAND, swingAnimation, false);
this.player.swing(InteractionHand.MAIN_HAND); this.player.connection.send(ServerboundPunchPacket.INSTANCE);
} }
} @@ -1679,6 +_,8 @@
@@ -1656,6 +_,8 @@
return true; return true;
} }
+ var inputEvent = new net.minecraftforge.client.event.InputEvent.InteractionKeyMappingTriggered(0, this.options.keyAttack, InteractionHand.MAIN_HAND); + var inputEvent = new net.minecraftforge.client.event.InputEvent.InteractionKeyMappingTriggered.Attack(this.options.keyAttack, InteractionHand.MAIN_HAND);
+ if (!net.minecraftforge.client.event.InputEvent.InteractionKeyMappingTriggered.BUS.post(inputEvent)) + if (!net.minecraftforge.client.event.InputEvent.InteractionKeyMappingTriggered.Attack.BUS.post(inputEvent))
switch (this.hitResult.getType()) { switch (this.hitResult.getType()) {
case ENTITY: case ENTITY:
AttackRange customItemRange = heldItem.get(DataComponents.ATTACK_RANGE); AttackRange customItemRange = heldItem.get(DataComponents.ATTACK_RANGE);
@@ -1666,7 +_,7 @@ @@ -1689,7 +_,7 @@
case BLOCK: case BLOCK:
BlockHitResult blockHit = (BlockHitResult)this.hitResult; BlockHitResult blockHit = (BlockHitResult)this.hitResult;
BlockPos pos = blockHit.getBlockPos(); BlockPos pos = blockHit.getBlockPos();
@@ -184,49 +164,53 @@
this.gameMode.startDestroyBlock(pos, blockHit.getDirection()); this.gameMode.startDestroyBlock(pos, blockHit.getDirection());
if (this.level.getBlockState(pos).isAir()) { if (this.level.getBlockState(pos).isAir()) {
endAttack = true; endAttack = true;
@@ -1679,8 +_,10 @@ @@ -1702,10 +_,13 @@
} }
this.player.resetAttackStrengthTicker(); this.player.resetAttackStrengthTicker();
+ net.minecraftforge.event.ForgeEventFactory.onLeftClickEmpty(this.player); + net.minecraftforge.event.ForgeEventFactory.onLeftClickEmpty(this.player);
} }
+ if (inputEvent.shouldSwingHand()) + if (inputEvent.shouldSwingHand()) {
this.player.swing(InteractionHand.MAIN_HAND); this.player.swing(InteractionHand.MAIN_HAND, attackAnimation, false);
this.player.connection.send(ServerboundPunchPacket.INSTANCE);
+ }
return endAttack; return endAttack;
} }
@@ -1696,6 +_,12 @@ }
} @@ -1726,6 +_,13 @@
}
for (InteractionHand hand : InteractionHand.values()) { SwingAnimation swingAnimation = heldItem.getInteractAnimation();
+ var inputEvent = new net.minecraftforge.client.event.InputEvent.InteractionKeyMappingTriggered(1, this.options.keyUse, hand); +
+ if (net.minecraftforge.client.event.InputEvent.InteractionKeyMappingTriggered.BUS.post(inputEvent)) { + var inputEvent = new net.minecraftforge.client.event.InputEvent.InteractionKeyMappingTriggered.UseItem(this.options.keyUse, hand);
+ if (inputEvent.shouldSwingHand()) this.player.swing(hand); + if (net.minecraftforge.client.event.InputEvent.InteractionKeyMappingTriggered.UseItem.BUS.post(inputEvent)) {
+ if (inputEvent.shouldSwingHand()) this.player.swing(hand, swingAnimation, false);
+ return; + return;
+ } + }
+ +
ItemStack heldItem = this.player.getItemInHand(hand); if (this.hitResult != null) {
if (!heldItem.isItemEnabled(this.level.enabledFeatures())) { switch (this.hitResult.getType()) {
return; case ENTITY:
@@ -1712,7 +_,7 @@ @@ -1737,7 +_,7 @@
if (this.player.isWithinEntityInteractionRange(entity, 0.0) if (this.player.isWithinEntityInteractionRange(entity, 0.0)
&& this.gameMode.interact(this.player, entity, entityHit, hand) instanceof InteractionResult.Success success) { && this.gameMode.interact(this.player, entity, entityHit, hand) instanceof InteractionResult.Success success) {
- if (success.swingSource() == InteractionResult.SwingSource.CLIENT) { - if (success.swingSource() == InteractionResult.SwingSource.PREDICTED) {
+ if (success.swingSource() == InteractionResult.SwingSource.CLIENT && inputEvent.shouldSwingHand()) { + if (success.swingSource() == InteractionResult.SwingSource.PREDICTED && inputEvent.shouldSwingHand()) {
this.player.swing(hand); this.player.swing(hand, swingAnimation, false);
} }
@@ -1724,7 +_,7 @@ @@ -1749,7 +_,7 @@
int oldCount = heldItem.getCount(); int oldCount = heldItem.getCount();
InteractionResult useResult = this.gameMode.useItemOn(this.player, hand, blockHit); InteractionResult useResult = this.gameMode.useItemOn(this.player, hand, blockHit);
if (useResult instanceof InteractionResult.Success success) { if (useResult instanceof InteractionResult.Success success) {
- if (success.swingSource() == InteractionResult.SwingSource.CLIENT) { - if (success.swingSource() == InteractionResult.SwingSource.PREDICTED) {
+ if (success.swingSource() == InteractionResult.SwingSource.CLIENT && inputEvent.shouldSwingHand()) { + if (success.swingSource() == InteractionResult.SwingSource.PREDICTED && inputEvent.shouldSwingHand()) {
this.player.swing(hand); this.player.swing(hand, swingAnimation, false);
if (!heldItem.isEmpty() && (heldItem.getCount() != oldCount || this.player.hasInfiniteMaterials())) { if (!heldItem.isEmpty() && (heldItem.getCount() != oldCount || this.player.hasInfiniteMaterials())) {
this.gameRenderer.itemInHandRenderer.itemUsed(hand); this.player.itemUsed(hand);
@@ -1740,6 +_,9 @@ @@ -1765,6 +_,9 @@
} }
} }
@@ -234,9 +218,9 @@
+ net.minecraftforge.event.ForgeEventFactory.onRightClickEmpty(this.player, hand); + net.minecraftforge.event.ForgeEventFactory.onRightClickEmpty(this.player, hand);
+ +
if (!heldItem.isEmpty() && this.gameMode.useItem(this.player, hand) instanceof InteractionResult.Success success) { if (!heldItem.isEmpty() && this.gameMode.useItem(this.player, hand) instanceof InteractionResult.Success success) {
if (success.swingSource() == InteractionResult.SwingSource.CLIENT) { if (success.swingSource() == InteractionResult.SwingSource.PREDICTED) {
this.player.swing(hand); this.player.swing(hand, swingAnimation, false);
@@ -1768,6 +_,8 @@ @@ -1793,6 +_,8 @@
} }
ProfilerFiller profiler = Profiler.get(); ProfilerFiller profiler = Profiler.get();
@@ -245,7 +229,7 @@
profiler.push("gameMode"); profiler.push("gameMode");
if (!this.pause && this.level != null) { if (!this.pause && this.level != null) {
this.gameMode.tick(); this.gameMode.tick();
@@ -1817,6 +_,7 @@ @@ -1845,6 +_,7 @@
this.tutorial.tick(); this.tutorial.tick();
@@ -253,7 +237,7 @@
try { try {
this.level.tick(() -> true); this.level.tick(() -> true);
} catch (Throwable t) { } catch (Throwable t) {
@@ -1830,6 +_,7 @@ @@ -1858,6 +_,7 @@
throw new ReportedException(report); throw new ReportedException(report);
} }
@@ -261,7 +245,7 @@
} }
profiler.popPush("animateTick"); profiler.popPush("animateTick");
@@ -1854,6 +_,7 @@ @@ -1882,6 +_,7 @@
profiler.popPush("keyboard"); profiler.popPush("keyboard");
this.keyboardHandler.tick(); this.keyboardHandler.tick();
profiler.pop(); profiler.pop();
@@ -269,7 +253,7 @@
} }
private boolean isLevelRunningNormally() { private boolean isLevelRunningNormally() {
@@ -2059,6 +_,7 @@ @@ -2088,6 +_,7 @@
} }
public void setLevel(final ClientLevel level) { public void setLevel(final ClientLevel level) {
@@ -277,7 +261,7 @@
this.level = level; this.level = level;
this.updateLevelInEngines(level); this.updateLevelInEngines(level);
} }
@@ -2120,6 +_,7 @@ @@ -2149,6 +_,7 @@
IntegratedServer server = this.singleplayerServer; IntegratedServer server = this.singleplayerServer;
this.singleplayerServer = null; this.singleplayerServer = null;
this.gameRenderer.resetData(); this.gameRenderer.resetData();
@@ -285,7 +269,7 @@
this.gameMode = null; this.gameMode = null;
this.narrator.clear(); this.narrator.clear();
this.gui.setClientLevelTeardownInProgress(true); this.gui.setClientLevelTeardownInProgress(true);
@@ -2127,6 +_,7 @@ @@ -2156,6 +_,7 @@
try { try {
if (this.level != null) { if (this.level != null) {
this.gui.hud.onDisconnected(); this.gui.hud.onDisconnected();
@@ -293,7 +277,7 @@
} }
this.level = null; this.level = null;
@@ -2141,6 +_,7 @@ @@ -2171,6 +_,7 @@
} }
profiler.pop(); profiler.pop();
@@ -301,7 +285,7 @@
} }
this.setScreenAndShow(screen); this.setScreenAndShow(screen);
@@ -2354,6 +_,7 @@ @@ -2403,6 +_,7 @@
private void pickBlockOrEntity() { private void pickBlockOrEntity() {
if (this.hitResult != null && this.hitResult.getType() != HitResult.Type.MISS) { if (this.hitResult != null && this.hitResult.getType() != HitResult.Type.MISS) {
@@ -1,23 +1,23 @@
--- a/net/minecraft/client/MouseHandler.java --- a/net/minecraft/client/MouseHandler.java
+++ b/net/minecraft/client/MouseHandler.java +++ b/net/minecraft/client/MouseHandler.java
@@ -77,6 +_,7 @@ @@ -79,6 +_,7 @@
this.activeButton = null; this.activeButton = null;
} }
+ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onMouseButtonPre(buttonInfo, action)) return; + if (net.minecraftforge.client.event.ForgeEventFactoryClient.onMouseButtonPre(rawButtonInfo, action)) return;
if (this.minecraft.gui.overlay() == null) { if (this.minecraft.gui.overlay() == null) {
if (pressed if (pressed
&& this.minecraft.handleGlobalKeyPress(InputConstants.Type.MOUSE.getOrCreate(buttonInfo.button()), buttonInfo.hasControlDownWithQuirk())) { && this.minecraft
@@ -101,7 +_,7 @@ @@ -104,7 +_,7 @@
&& currentTime - this.lastClick.time() < 250L && currentTime - this.lastClick.time() < 250L
&& this.lastClick.screen() == screen && this.lastClick.screen() == screen
&& this.lastClickButton == event.button(); && this.lastClickButton == event.button();
- if (screen.mouseClicked(event, doubleClick)) { - if (screen.mouseClicked(event, doubleClick)) {
+ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenMouseClicked(screen, xm, ym, event, doubleClick)) { + if (net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenMouseClicked(screen, xm, ym, event, doubleClick)) {
this.lastClick = new MouseHandler.LastClick(currentTime, screen); this.lastClick = new MouseHandler.LastClick(currentTime, screen);
this.lastClickButton = buttonInfo.button(); this.lastClickButton = rawButtonInfo.button();
return; return;
@@ -116,7 +_,7 @@ @@ -118,7 +_,7 @@
} }
} else { } else {
try { try {
@@ -26,15 +26,15 @@
return; return;
} }
} catch (Throwable t) { } catch (Throwable t) {
@@ -146,6 +_,7 @@ @@ -147,6 +_,7 @@
KeyMapping.click(mouseKey); KeyMapping.click(mouseKey);
} }
} }
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onMouseButtonPost(buttonInfo, action); + net.minecraftforge.client.event.ForgeEventFactoryClient.onMouseButtonPost(rawButtonInfo, action);
} }
} }
@@ -197,7 +_,9 @@ @@ -182,7 +_,9 @@
if (this.minecraft.gui.screen() != null) { if (this.minecraft.gui.screen() != null) {
double xm = this.getScaledXPos(this.minecraft.getWindow()); double xm = this.getScaledXPos(this.minecraft.getWindow());
double ym = this.getScaledYPos(this.minecraft.getWindow()); double ym = this.getScaledYPos(this.minecraft.getWindow());
@@ -45,7 +45,7 @@
this.minecraft.gui.screen().afterMouseAction(); this.minecraft.gui.screen().afterMouseAction();
} else if (this.minecraft.player != null) { } else if (this.minecraft.player != null) {
Vector2i wheelXY = this.scrollWheelHandler.onMouseScroll(scaledXOffset, scaledYOffset); Vector2i wheelXY = this.scrollWheelHandler.onMouseScroll(scaledXOffset, scaledYOffset);
@@ -206,6 +_,7 @@ @@ -191,6 +_,7 @@
} }
int wheel = wheelXY.y == 0 ? -wheelXY.x : wheelXY.y; int wheel = wheelXY.y == 0 ? -wheelXY.x : wheelXY.y;
@@ -53,7 +53,7 @@
if (this.minecraft.player.isSpectator()) { if (this.minecraft.player.isSpectator()) {
if (this.minecraft.gui.hud.getSpectatorGui().isMenuActive()) { if (this.minecraft.gui.hud.getSpectatorGui().isMenuActive()) {
this.minecraft.gui.hud.getSpectatorGui().onMouseScrolled(-wheel); this.minecraft.gui.hud.getSpectatorGui().onMouseScrolled(-wheel);
@@ -312,7 +_,7 @@ @@ -285,7 +_,7 @@
double dy = getScaledYPos(window, this.accumulatedDY); double dy = getScaledYPos(window, this.accumulatedDY);
try { try {
@@ -61,8 +61,8 @@
+ net.minecraftforge.client.ForgeHooksClient.onScreenMouseDrag(screen, new MouseButtonEvent(xm, ym, this.activeButton), dx, dy); + net.minecraftforge.client.ForgeHooksClient.onScreenMouseDrag(screen, new MouseButtonEvent(xm, ym, this.activeButton), dx, dy);
} catch (Throwable t) { } catch (Throwable t) {
CrashReport report = CrashReport.forThrowable(t, "mouseDragged event handler"); CrashReport report = CrashReport.forThrowable(t, "mouseDragged event handler");
screen.fillCrashDetails(report); CrashReportCategory mouseDetails = report.addCategory("Mouse");
@@ -397,6 +_,14 @@ @@ -369,6 +_,14 @@
public double ypos() { public double ypos() {
return this.ypos; return this.ypos;
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/Options.java --- a/net/minecraft/client/Options.java
+++ b/net/minecraft/client/Options.java +++ b/net/minecraft/client/Options.java
@@ -986,6 +_,7 @@ @@ -1011,6 +_,7 @@
); );
public boolean syncWrites; public boolean syncWrites;
public boolean startedCleanly = true; public boolean startedCleanly = true;
@@ -8,7 +8,7 @@
public static boolean isSoundDeviceDefault(final String deviceName) { public static boolean isSoundDeviceDefault(final String deviceName) {
return deviceName.equals(""); return deviceName.equals("");
@@ -1474,6 +_,7 @@ @@ -1510,6 +_,7 @@
} }
public Options(final Minecraft minecraft, final File workingDirectory) { public Options(final Minecraft minecraft, final File workingDirectory) {
@@ -16,7 +16,7 @@
this.minecraft = minecraft; this.minecraft = minecraft;
this.optionsFile = new File(workingDirectory, "options.txt"); this.optionsFile = new File(workingDirectory, "options.txt");
boolean largeDistances = Runtime.getRuntime().maxMemory() >= 1000000000L; boolean largeDistances = Runtime.getRuntime().maxMemory() >= 1000000000L;
@@ -1624,15 +_,28 @@ @@ -1663,20 +_,32 @@
this.startedCleanly = access.process("startedCleanly", this.startedCleanly); this.startedCleanly = access.process("startedCleanly", this.startedCleanly);
access.process("musicToast", this.musicToast); access.process("musicToast", this.musicToast);
access.process("musicFrequency", this.musicFrequency); access.process("musicFrequency", this.musicFrequency);
@@ -31,13 +31,18 @@
+ String currentValue = keyMapping.saveString() + (keyMapping.getKeyModifier() != net.minecraftforge.client.settings.KeyModifier.NONE ? ":" + keyMapping.getKeyModifier() : ""); + String currentValue = keyMapping.saveString() + (keyMapping.getKeyModifier() != net.minecraftforge.client.settings.KeyModifier.NONE ? ":" + keyMapping.getKeyModifier() : "");
String newValue = access.process("key_" + keyMapping.getName(), currentValue); String newValue = access.process("key_" + keyMapping.getName(), currentValue);
if (!currentValue.equals(newValue)) { if (!currentValue.equals(newValue)) {
keyMapping.setKey(InputConstants.getKey(newValue)); try {
+ if (newValue.indexOf(':') != -1) { - keyMapping.setKey(InputConstants.getKey(newValue));
+ String[] pts = newValue.split(":"); + if (newValue.indexOf(':') != -1) {
+ keyMapping.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.valueFromString(pts[1]), InputConstants.getKey(pts[0])); + String[] pts = newValue.split(":");
+ } else { + keyMapping.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.valueFromString(pts[1]), InputConstants.getKey(pts[0]));
+ keyMapping.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.NONE, InputConstants.getKey(newValue)); + } else {
+ } + keyMapping.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.NONE, InputConstants.getKey(newValue));
+ }
} catch (IllegalArgumentException e) {
LOGGER.warn("Invalid keyMapping {} = {}, unbinding", keyMapping.getName(), newValue, e);
keyMapping.setKey(InputConstants.UNKNOWN);
}
} }
} }
+ } + }
@@ -46,7 +51,7 @@
for (SoundSource source : SoundSource.values()) { for (SoundSource source : SoundSource.values()) {
access.process("soundCategory_" + source.getName(), this.soundSourceVolumes.get(source)); access.process("soundCategory_" + source.getName(), this.soundSourceVolumes.get(source));
} }
@@ -1647,6 +_,10 @@ @@ -1691,6 +_,10 @@
} }
public void load() { public void load() {
@@ -57,7 +62,7 @@
try { try {
if (!this.optionsFile.exists()) { if (!this.optionsFile.exists()) {
return; return;
@@ -1666,7 +_,8 @@ @@ -1710,7 +_,8 @@
} }
final CompoundTag options = this.dataFix(rawOptions); final CompoundTag options = this.dataFix(rawOptions);
@@ -67,7 +72,7 @@
new Options.FieldAccess() { new Options.FieldAccess() {
private @Nullable String getValue(final String name) { private @Nullable String getValue(final String name) {
Tag tag = options.get(name); Tag tag = options.get(name);
@@ -1748,6 +_,17 @@ @@ -1792,6 +_,17 @@
); );
options.getString("fullscreenResolution").ifPresent(fullscreenResolution -> this.fullscreenVideoModeString = fullscreenResolution); options.getString("fullscreenResolution").ifPresent(fullscreenResolution -> this.fullscreenVideoModeString = fullscreenResolution);
KeyMapping.resetMapping(); KeyMapping.resetMapping();
@@ -85,7 +90,7 @@
} catch (Exception e) { } catch (Exception e) {
LOGGER.error("Failed to load options", e); LOGGER.error("Failed to load options", e);
} }
@@ -1778,9 +_,11 @@ @@ -1821,9 +_,11 @@
public void save() { public void save() {
try (final PrintWriter writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(this.optionsFile), StandardCharsets.UTF_8))) { try (final PrintWriter writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(this.optionsFile), StandardCharsets.UTF_8))) {
writer.println("version:" + SharedConstants.getCurrentVersion().dataVersion().version()); writer.println("version:" + SharedConstants.getCurrentVersion().dataVersion().version());
@@ -97,7 +102,7 @@
writer.print(name); writer.print(name);
writer.print(':'); writer.print(':');
} }
@@ -1836,6 +_,12 @@ @@ -1879,6 +_,12 @@
if (fullscreenVideoModeString != null) { if (fullscreenVideoModeString != null) {
writer.println("fullscreenResolution:" + fullscreenVideoModeString); writer.println("fullscreenResolution:" + fullscreenVideoModeString);
} }
@@ -110,7 +115,7 @@
} catch (Exception e) { } catch (Exception e) {
LOGGER.error("Failed to save options", e); LOGGER.error("Failed to save options", e);
} }
@@ -1873,6 +_,7 @@ @@ -1916,6 +_,7 @@
} }
public void broadcastOptions() { public void broadcastOptions() {
@@ -118,7 +123,7 @@
if (this.minecraft.player != null) { if (this.minecraft.player != null) {
this.minecraft.player.connection.broadcastClientInformation(this.buildPlayerInformation()); this.minecraft.player.connection.broadcastClientInformation(this.buildPlayerInformation());
} }
@@ -1986,6 +_,23 @@ @@ -2029,6 +_,23 @@
public static Component genericValueLabel(final Component caption, final int value) { public static Component genericValueLabel(final Component caption, final int value) {
return genericValueLabel(caption, Component.literal(Integer.toString(value))); return genericValueLabel(caption, Component.literal(Integer.toString(value)));
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/data/models/ItemModelGenerators.java --- a/net/minecraft/client/data/models/ItemModelGenerators.java
+++ b/net/minecraft/client/data/models/ItemModelGenerators.java +++ b/net/minecraft/client/data/models/ItemModelGenerators.java
@@ -868,6 +_,9 @@ @@ -921,6 +_,9 @@
this.declareCustomModelItem(Items.COD); this.declareCustomModelItem(Items.COD);
this.declareCustomModelItem(Items.FEATHER); this.declareCustomModelItem(Items.FEATHER);
this.declareCustomModelItem(Items.LEAD); this.declareCustomModelItem(Items.LEAD);
@@ -1,15 +1,15 @@
--- a/net/minecraft/client/gui/Gui.java --- a/net/minecraft/client/gui/Gui.java
+++ b/net/minecraft/client/gui/Gui.java +++ b/net/minecraft/client/gui/Gui.java
@@ -64,7 +_,7 @@ @@ -67,7 +_,7 @@
import org.slf4j.Logger; import org.slf4j.Logger;
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
-public class Gui { -public class Gui {
+public class Gui extends net.minecraftforge.client.gui.overlay.ForgeLayerInstance { +public class Gui extends net.minecraftforge.client.gui.overlay.ForgeLayerInstance {
private static final Logger LOGGER = LogUtils.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
private static final SectionCategory TRACY_CURRENT_SCREEN = TracyClient.createSectionCategory("Current Screen");
private static final Component SOCIAL_INTERACTIONS_NOT_AVAILABLE = Component.translatable("multiplayer.socialInteractions.not_available"); private static final Component SOCIAL_INTERACTIONS_NOT_AVAILABLE = Component.translatable("multiplayer.socialInteractions.not_available");
public static final Component SAVING_LEVEL = Component.translatable("menu.savingLevel"); @@ -85,6 +_,7 @@
@@ -80,6 +_,7 @@
private @Nullable TutorialToast socialInteractionsToast; private @Nullable TutorialToast socialInteractionsToast;
public Gui(final Minecraft minecraft, final Hud hud, final GuiRenderState guiRenderState) { public Gui(final Minecraft minecraft, final Hud hud, final GuiRenderState guiRenderState) {
@@ -17,7 +17,7 @@
this.minecraft = minecraft; this.minecraft = minecraft;
this.hud = hud; this.hud = hud;
this.splashManager = new SplashManager(minecraft.getUser()); this.splashManager = new SplashManager(minecraft.getUser());
@@ -175,7 +_,7 @@ @@ -174,7 +_,7 @@
profiler.push("screen"); profiler.push("screen");
try { try {
@@ -26,11 +26,13 @@
} catch (Throwable t) { } catch (Throwable t) {
CrashReport report = CrashReport.forThrowable(t, "Rendering screen"); CrashReport report = CrashReport.forThrowable(t, "Rendering screen");
CrashReportCategory category = report.addCategory("Screen render details"); CrashReportCategory category = report.addCategory("Screen render details");
@@ -224,12 +_,6 @@ @@ -228,14 +_,6 @@
LOGGER.error("setScreen called from non-game thread"); this.screenTracySection = null;
} }
- if (this.screen != null) { - if (this.screen != null) {
- this.screen.clearFocus();
- this.minecraft.textInputManager().stopTextInput();
- this.screen.removed(); - this.screen.removed();
- } else { - } else {
- this.minecraft.setLastInputType(InputType.NONE); - this.minecraft.setLastInputType(InputType.NONE);
@@ -39,7 +41,7 @@
if (screen == null) { if (screen == null) {
if (this.clientLevelTeardownInProgress) { if (this.clientLevelTeardownInProgress) {
throw new IllegalStateException("Trying to return to in-game GUI during disconnection"); throw new IllegalStateException("Trying to return to in-game GUI during disconnection");
@@ -248,6 +_,22 @@ @@ -254,6 +_,24 @@
} }
} }
@@ -54,6 +56,8 @@
+ if (screen != old) { + if (screen != old) {
+ if (old != null) { + if (old != null) {
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenClose(old); + net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenClose(old);
+ this.screen.clearFocus();
+ this.minecraft.textInputManager().stopTextInput();
+ old.removed(); + old.removed();
+ } else { + } else {
+ this.minecraft.setLastInputType(InputType.NONE); + this.minecraft.setLastInputType(InputType.NONE);
@@ -62,7 +66,7 @@
this.screen = screen; this.screen = screen;
if (this.screen != null) { if (this.screen != null) {
this.screen.added(); this.screen.added();
@@ -465,5 +_,10 @@ @@ -474,5 +_,10 @@
} }
) )
); );
@@ -9,7 +9,7 @@
private static final int EXTRA_SPACE_AFTER_FIRST_TOOLTIP_LINE = 2; private static final int EXTRA_SPACE_AFTER_FIRST_TOOLTIP_LINE = 2;
private final Minecraft minecraft; private final Minecraft minecraft;
private final Matrix3x2fStack pose; private final Matrix3x2fStack pose;
@@ -912,6 +_,7 @@ @@ -914,6 +_,7 @@
CrashReport report = CrashReport.forThrowable(t, "Rendering item"); CrashReport report = CrashReport.forThrowable(t, "Rendering item");
CrashReportCategory category = report.addCategory("Item being rendered"); CrashReportCategory category = report.addCategory("Item being rendered");
category.setDetail("Item Type", () -> String.valueOf(itemStack.getItem())); category.setDetail("Item Type", () -> String.valueOf(itemStack.getItem()));
@@ -17,7 +17,7 @@
category.setDetail("Item Components", () -> String.valueOf(itemStack.getComponents())); category.setDetail("Item Components", () -> String.valueOf(itemStack.getComponents()));
category.setDetail("Item Foil", () -> String.valueOf(itemStack.hasFoil())); category.setDetail("Item Foil", () -> String.valueOf(itemStack.hasFoil()));
throw new ReportedException(report); throw new ReportedException(report);
@@ -938,6 +_,7 @@ @@ -940,6 +_,7 @@
this.itemCooldown(itemStack, x, y); this.itemCooldown(itemStack, x, y);
this.itemCount(font, itemStack, x, y, countText); this.itemCount(font, itemStack, x, y, countText);
this.pose.popMatrix(); this.pose.popMatrix();
@@ -25,7 +25,7 @@
} }
} }
@@ -1106,16 +_,25 @@ @@ -1109,16 +_,29 @@
this.setTooltipForNextFrame(this.minecraft.font, formattedCharSequences, DefaultTooltipPositioner.INSTANCE, x, y, false); this.setTooltipForNextFrame(this.minecraft.font, formattedCharSequences, DefaultTooltipPositioner.INSTANCE, x, y, false);
} }
@@ -33,7 +33,7 @@
public void setTooltipForNextFrame(final Font font, final ItemStack itemStack, final int xo, final int yo) { public void setTooltipForNextFrame(final Font font, final ItemStack itemStack, final int xo, final int yo) {
+ this.tooltipStack = itemStack; + this.tooltipStack = itemStack;
this.setTooltipForNextFrame( this.setTooltipForNextFrame(
font, Screen.getTooltipFromItem(this.minecraft, itemStack), itemStack.getTooltipImage(), xo, yo, itemStack.get(DataComponents.TOOLTIP_STYLE) font, Screen.getTooltipFromItem(this.minecraft, itemStack), itemStack.getTooltipImage(), xo, yo, itemStack.get(DataComponents.TOOLTIP_STYLE), true
); );
+ this.tooltipStack = ItemStack.EMPTY; + this.tooltipStack = ItemStack.EMPTY;
} }
@@ -43,17 +43,21 @@
} }
+ public void setTooltipForNextFrame(Font font, List<Component> texts, Optional<TooltipComponent> optionalImage, ItemStack stack, int xo, int yo) { + public void setTooltipForNextFrame(Font font, List<Component> texts, Optional<TooltipComponent> optionalImage, ItemStack stack, int xo, int yo) {
+ this.tooltipStack = stack; + this.setTooltipForNextFrame(font, texts, optionalImage, stack, xo, yo, false);
+ this.setTooltipForNextFrame(font, texts, optionalImage, xo, yo, stack.get(DataComponents.TOOLTIP_STYLE)); + }
+ this.tooltipStack = ItemStack.EMPTY; +
+ public void setTooltipForNextFrame(Font font, List<Component> texts, Optional<TooltipComponent> optionalImage, ItemStack stack, int xo, int yo, final boolean extraSpaceAfterFirstLine) {
+ this.tooltipStack = stack;
+ this.setTooltipForNextFrame(font, texts, optionalImage, xo, yo, stack.get(DataComponents.TOOLTIP_STYLE), extraSpaceAfterFirstLine);
+ this.tooltipStack = ItemStack.EMPTY;
+ } + }
+ +
public void setTooltipForNextFrame( public void setTooltipForNextFrame(
final Font font, final Font font,
final List<Component> texts, final List<Component> texts,
@@ -1124,11 +_,7 @@ @@ -1139,11 +_,7 @@
final int yo, final @Nullable Identifier style,
final @Nullable Identifier style final boolean extraSpaceAfterFirstLine
) { ) {
- List<ClientTooltipComponent> components = texts.stream() - List<ClientTooltipComponent> components = texts.stream()
- .map(Component::getVisualOrderText) - .map(Component::getVisualOrderText)
@@ -61,10 +65,10 @@
- .collect(Util.toMutableList()); - .collect(Util.toMutableList());
- optionalImage.ifPresent(image -> components.add(components.isEmpty() ? 0 : 1, ClientTooltipComponent.create(image))); - optionalImage.ifPresent(image -> components.add(components.isEmpty() ? 0 : 1, ClientTooltipComponent.create(image)));
+ List<ClientTooltipComponent> components = net.minecraftforge.client.ForgeHooksClient.gatherTooltipComponents(this.tooltipStack, texts, optionalImage, xo, guiWidth(), guiHeight(), font); + List<ClientTooltipComponent> components = net.minecraftforge.client.ForgeHooksClient.gatherTooltipComponents(this.tooltipStack, texts, optionalImage, xo, guiWidth(), guiHeight(), font);
this.setTooltipForNextFrameInternal(font, components, xo, yo, DefaultTooltipPositioner.INSTANCE, style, false); this.setTooltipForNextFrameInternal(font, components, xo, yo, DefaultTooltipPositioner.INSTANCE, style, false, extraSpaceAfterFirstLine);
} }
@@ -1156,7 +_,22 @@ @@ -1171,7 +_,22 @@
} }
public void setComponentTooltipForNextFrame(final Font font, final List<Component> lines, final int xo, final int yo) { public void setComponentTooltipForNextFrame(final Font font, final List<Component> lines, final int xo, final int yo) {
@@ -88,36 +92,34 @@
} }
public void setComponentTooltipForNextFrame(final Font font, final List<Component> lines, final int xo, final int yo, final @Nullable Identifier style) { public void setComponentTooltipForNextFrame(final Font font, final List<Component> lines, final int xo, final int yo, final @Nullable Identifier style) {
@@ -1207,10 +_,16 @@ @@ -1235,9 +_,14 @@
) { ) {
if (!lines.isEmpty()) { if (!lines.isEmpty()) {
if (this.deferredTooltip == null || replaceExisting) { if (this.deferredTooltip == null || replaceExisting) {
- this.deferredTooltip = () -> this.tooltip(font, lines, xo, yo, positioner, style); - this.deferredTooltip = () -> this.tooltip(font, lines, xo, yo, positioner, style, extraSpaceAfterFirstLine);
+ final var stackContext = this.tooltipStack; + final var stackContext = this.tooltipStack;
+ this.deferredTooltip = () -> this.tooltip(font, lines, xo, yo, positioner, style, stackContext); + this.deferredTooltip = () -> this.tooltip(font, lines, xo, yo, positioner, style, extraSpaceAfterFirstLine, stackContext);
} }
} }
}
+
+ public void tooltip(Font font, List<ClientTooltipComponent> lines, int xo, int yo, ClientTooltipPositioner positioner, @Nullable Identifier style) {
+ tooltip(font, lines, xo, yo, positioner, style, ItemStack.EMPTY);
+ } + }
+ +
+ public void tooltip(Font font, List<ClientTooltipComponent> lines, int xo, int yo, ClientTooltipPositioner positioner, @Nullable Identifier style, boolean extraSpaceAfterFirstLine) {
+ tooltip(font, lines, xo, yo, positioner, style, extraSpaceAfterFirstLine, ItemStack.EMPTY);
}
public void tooltip( public void tooltip(
final Font font, @@ -1247,13 +_,16 @@
@@ -1218,13 +_,16 @@
final int xo,
final int yo, final int yo,
final ClientTooltipPositioner positioner, final ClientTooltipPositioner positioner,
- final @Nullable Identifier style final @Nullable Identifier style,
+ final @Nullable Identifier style, - boolean extraSpaceAfterFirstLine
+ boolean extraSpaceAfterFirstLine,
+ ItemStack itemstack + ItemStack itemstack
) { ) {
+ var preEvent = net.minecraftforge.client.ForgeHooksClient.onRenderTooltipPre(itemstack, this, xo, yo, guiWidth(), guiHeight(), lines, font, positioner, style); + var preEvent = net.minecraftforge.client.ForgeHooksClient.onRenderTooltipPre(itemstack, this, xo, yo, guiWidth(), guiHeight(), lines, font, positioner, style);
+ if (preEvent == null) return; + if (preEvent == null) return;
int textWidth = 0; int textWidth = 0;
int tempHeight = lines.size() == 1 ? -2 : 0; int tempHeight = extraSpaceAfterFirstLine && lines.size() != 1 ? 0 : -2;
for (ClientTooltipComponent line : lines) { for (ClientTooltipComponent line : lines) {
- int lineWidth = line.getWidth(font); - int lineWidth = line.getWidth(font);
@@ -125,7 +127,7 @@
if (lineWidth > textWidth) { if (lineWidth > textWidth) {
textWidth = lineWidth; textWidth = lineWidth;
} }
@@ -1234,25 +_,25 @@ @@ -1263,25 +_,25 @@
int w = textWidth; int w = textWidth;
int h = tempHeight; int h = tempHeight;
@@ -141,9 +143,9 @@
for (int i = 0; i < lines.size(); i++) { for (int i = 0; i < lines.size(); i++) {
ClientTooltipComponent line = lines.get(i); ClientTooltipComponent line = lines.get(i);
- line.extractText(this, font, x, localY); - line.extractText(this, font, x, localY);
- localY += line.getHeight(font) + (i == 0 ? 2 : 0); - localY += line.getHeight(font) + (extraSpaceAfterFirstLine && i == 0 ? 2 : 0);
+ line.extractText(this, preEvent.getFont(), x, localY); + line.extractText(this, preEvent.getFont(), x, localY);
+ localY += line.getHeight(preEvent.getFont()) + (i == 0 ? 2 : 0); + localY += line.getHeight(preEvent.getFont()) + (extraSpaceAfterFirstLine && i == 0 ? 2 : 0);
} }
localY = y; localY = y;
@@ -151,13 +153,13 @@
for (int i = 0; i < lines.size(); i++) { for (int i = 0; i < lines.size(); i++) {
ClientTooltipComponent line = lines.get(i); ClientTooltipComponent line = lines.get(i);
- line.extractImage(font, x, localY, w, h, this); - line.extractImage(font, x, localY, w, h, this);
- localY += line.getHeight(font) + (i == 0 ? 2 : 0); - localY += line.getHeight(font) + (extraSpaceAfterFirstLine && i == 0 ? 2 : 0);
+ line.extractImage(preEvent.getFont(), x, localY, w, h, this); + line.extractImage(preEvent.getFont(), x, localY, w, h, this);
+ localY += line.getHeight(preEvent.getFont()) + (i == 0 ? 2 : 0); + localY += line.getHeight(preEvent.getFont()) + (extraSpaceAfterFirstLine && i == 0 ? 2 : 0);
} }
this.pose.popMatrix(); this.pose.popMatrix();
@@ -1326,6 +_,14 @@ @@ -1355,6 +_,14 @@
private ActiveTextCollector.Parameters createDefaultTextParameters(final float opacity) { private ActiveTextCollector.Parameters createDefaultTextParameters(final float opacity) {
return new ActiveTextCollector.Parameters(new Matrix3x2f(this.pose), opacity, this.scissorStack.peek()); return new ActiveTextCollector.Parameters(new Matrix3x2f(this.pose), opacity, this.scissorStack.peek());
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/Hud.java --- a/net/minecraft/client/gui/Hud.java
+++ b/net/minecraft/client/gui/Hud.java +++ b/net/minecraft/client/gui/Hud.java
@@ -156,7 +_,7 @@ @@ -157,7 +_,7 @@
public float vignetteBrightness = 1.0F; public float vignetteBrightness = 1.0F;
private int toolHighlightTimer; private int toolHighlightTimer;
private ItemStack lastToolHighlight = ItemStack.EMPTY; private ItemStack lastToolHighlight = ItemStack.EMPTY;
@@ -9,7 +9,7 @@
private final SubtitleOverlay subtitleOverlay; private final SubtitleOverlay subtitleOverlay;
private final SpectatorGui spectatorGui; private final SpectatorGui spectatorGui;
private final PlayerTabOverlay tabList; private final PlayerTabOverlay tabList;
@@ -198,6 +_,7 @@ @@ -199,6 +_,7 @@
() -> new JumpableVehicleBar(minecraft) () -> new JumpableVehicleBar(minecraft)
); );
this.resetTitleTimes(); this.resetTitleTimes();
@@ -17,7 +17,7 @@
} }
public void registerReloadListeners(final ReloadableResourceManager resourceManager) { public void registerReloadListeners(final ReloadableResourceManager resourceManager) {
@@ -221,6 +_,10 @@ @@ -222,6 +_,10 @@
public void extractRenderState(final GuiGraphicsExtractor graphics, final DeltaTracker deltaTracker) { public void extractRenderState(final GuiGraphicsExtractor graphics, final DeltaTracker deltaTracker) {
this.minecraft.gameRenderer.gameRenderState().guiRenderState.isHudHidden = this.isHidden; this.minecraft.gameRenderer.gameRenderState().guiRenderState.isHudHidden = this.isHidden;
if (!(this.minecraft.gui.screen() instanceof LevelLoadingScreen)) { if (!(this.minecraft.gui.screen() instanceof LevelLoadingScreen)) {
@@ -28,7 +28,7 @@
if (!this.isHidden) { if (!this.isHidden) {
this.extractCameraOverlays(graphics, deltaTracker); this.extractCameraOverlays(graphics, deltaTracker);
this.extractCrosshair(graphics, deltaTracker); this.extractCrosshair(graphics, deltaTracker);
@@ -404,7 +_,7 @@ @@ -405,7 +_,7 @@
int mouseX = Mth.floor(this.minecraft.mouseHandler.getScaledXPos(window)); int mouseX = Mth.floor(this.minecraft.mouseHandler.getScaledXPos(window));
int mouseY = Mth.floor(this.minecraft.mouseHandler.getScaledYPos(window)); int mouseY = Mth.floor(this.minecraft.mouseHandler.getScaledYPos(window));
graphics.nextStratum(); graphics.nextStratum();
@@ -37,7 +37,7 @@
} }
} }
@@ -497,6 +_,8 @@ @@ -500,6 +_,8 @@
for (MobEffectInstance instance : Ordering.natural().reverse().sortedCopy(activeEffects)) { for (MobEffectInstance instance : Ordering.natural().reverse().sortedCopy(activeEffects)) {
Holder<MobEffect> effect = instance.getEffect(); Holder<MobEffect> effect = instance.getEffect();
@@ -46,7 +46,7 @@
if (instance.showIcon()) { if (instance.showIcon()) {
int x = graphics.guiWidth(); int x = graphics.guiWidth();
int y = 1; int y = 1;
@@ -527,6 +_,7 @@ @@ -530,6 +_,7 @@
} }
} }
@@ -54,7 +54,7 @@
graphics.blitSprite(RenderPipelines.GUI_TEXTURED, getMobEffectSprite(effect), x + 3, y + 3, 18, 18, ARGB.white(alpha)); graphics.blitSprite(RenderPipelines.GUI_TEXTURED, getMobEffectSprite(effect), x + 3, y + 3, 18, 18, ARGB.white(alpha));
} }
} }
@@ -629,15 +_,37 @@ @@ -632,15 +_,37 @@
} }
public void extractSelectedItemName(final GuiGraphicsExtractor graphics) { public void extractSelectedItemName(final GuiGraphicsExtractor graphics) {
@@ -94,7 +94,7 @@
if (!this.minecraft.gameMode.canHurtPlayer()) { if (!this.minecraft.gameMode.canHurtPlayer()) {
y += 14; y += 14;
} }
@@ -648,7 +_,7 @@ @@ -651,7 +_,7 @@
} }
if (alpha > 0) { if (alpha > 0) {
@@ -103,7 +103,7 @@
} }
} }
} }
@@ -1216,7 +_,9 @@ @@ -1219,7 +_,9 @@
this.toolHighlightTimer = 0; this.toolHighlightTimer = 0;
} else if (this.lastToolHighlight.isEmpty() } else if (this.lastToolHighlight.isEmpty()
|| !selected.is(this.lastToolHighlight.getItem()) || !selected.is(this.lastToolHighlight.getItem())
@@ -1,8 +1,8 @@
--- a/net/minecraft/client/gui/screens/PauseScreen.java --- a/net/minecraft/client/gui/screens/PauseScreen.java
+++ b/net/minecraft/client/gui/screens/PauseScreen.java +++ b/net/minecraft/client/gui/screens/PauseScreen.java
@@ -165,6 +_,7 @@ @@ -163,6 +_,7 @@
Button.builder(OPTIONS, var1x -> this.minecraft.gui.setScreen(new OptionsScreen(this, this.minecraft.options, true))).width(204).build(), 2 helper.addChild(this.openScreenButton(OPTIONS, () -> new OptionsScreen(this, this.minecraft.options)));
); helper.addChild(this.openScreenButton(WORLD_OPTIONS, () -> new WorldOptionsScreen(this, this.minecraft.level)));
} }
+ helper.addChild(Button.builder(Component.translatable("fml.menu.mods"), button -> this.minecraft.gui.setScreen(new net.minecraftforge.client.gui.ModListScreen(this))).width(BUTTON_WIDTH_FULL).build(), 2); + helper.addChild(Button.builder(Component.translatable("fml.menu.mods"), button -> this.minecraft.gui.setScreen(new net.minecraftforge.client.gui.ModListScreen(this))).width(BUTTON_WIDTH_FULL).build(), 2);
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/Screen.java --- a/net/minecraft/client/gui/screens/Screen.java
+++ b/net/minecraft/client/gui/screens/Screen.java +++ b/net/minecraft/client/gui/screens/Screen.java
@@ -196,7 +_,7 @@ @@ -202,7 +_,7 @@
} }
public void onClose() { public void onClose() {
@@ -9,7 +9,7 @@
} }
protected <T extends GuiEventListener & Renderable & NarratableEntry> T addRenderableWidget(final T widget) { protected <T extends GuiEventListener & Renderable & NarratableEntry> T addRenderableWidget(final T widget) {
@@ -327,8 +_,10 @@ @@ -333,8 +_,10 @@
this.width = width; this.width = width;
this.height = height; this.height = height;
if (!this.initialized) { if (!this.initialized) {
@@ -20,7 +20,7 @@
} else { } else {
this.repositionElements(); this.repositionElements();
} }
@@ -345,8 +_,10 @@ @@ -351,8 +_,10 @@
protected void rebuildWidgets() { protected void rebuildWidgets() {
this.clearWidgets(); this.clearWidgets();
this.clearFocus(); this.clearFocus();
@@ -31,7 +31,7 @@
} }
protected void fadeWidgets(final float widgetFade) { protected void fadeWidgets(final float widgetFade) {
@@ -386,6 +_,8 @@ @@ -392,6 +_,8 @@
this.extractMenuBackground(graphics); this.extractMenuBackground(graphics);
} }
@@ -40,7 +40,7 @@
this.minecraft.gui.hud.extractDeferredSubtitles(); this.minecraft.gui.hud.extractDeferredSubtitles();
} }
@@ -471,6 +_,19 @@ @@ -472,6 +_,19 @@
} }
public void onFilesDrop(final List<Path> files) { public void onFilesDrop(final List<Path> files) {
@@ -59,4 +59,4 @@
+ this.children.add(guiEventListener); + this.children.add(guiEventListener);
} }
private void scheduleNarration(final long delay, final boolean ignoreSuppression) { private void scheduleNarration(final long delay, final boolean ignoreSuppression, final NarrationTrigger narrationTrigger) {
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/advancements/AdvancementTab.java --- a/net/minecraft/client/gui/screens/advancements/AdvancementTab.java
+++ b/net/minecraft/client/gui/screens/advancements/AdvancementTab.java +++ b/net/minecraft/client/gui/screens/advancements/AdvancementTab.java
@@ -41,6 +_,7 @@ @@ -38,6 +_,7 @@
private float fade; private float fade;
private boolean centered; private boolean centered;
private @Nullable AdvancementWidget hovered; private @Nullable AdvancementWidget hovered;
@@ -8,15 +8,22 @@
public AdvancementTab( public AdvancementTab(
final Minecraft minecraft, final Minecraft minecraft,
@@ -62,6 +_,15 @@ @@ -60,6 +_,11 @@
this.addWidget(this.root, rootNode.holder()); this.addWidget(root);
} }
+ public AdvancementTab(Minecraft mc, AdvancementsScreen screen, AdvancementTabType type, int index, int page, AdvancementNode adv, DisplayInfo info) { + public AdvancementTab(Minecraft mc, AdvancementsScreen screen, AdvancementTabType type, int index, int page, AdvancementWidget root, ItemStackTemplate icon, Component title, Identifier background) {
+ this(mc, screen, type, index, adv, info); + this(mc, screen, type, index, root, icon, title, background);
+ this.page = page; + this.page = page;
+ } + }
+ +
public void copyPosition(final AdvancementTab source) {
this.scrollX = source.scrollX;
this.scrollY = source.scrollY;
@@ -70,6 +_,10 @@
this.centered = source.centered;
}
+ public int getPage() { + public int getPage() {
+ return this.page; + return this.page;
+ } + }
@@ -24,14 +31,14 @@
public AdvancementTabType getType() { public AdvancementTabType getType() {
return this.type; return this.type;
} }
@@ -169,8 +_,8 @@ @@ -179,8 +_,8 @@
} Identifier background = rootDisplay.background().get().texturePath();
for (AdvancementTabType type : AdvancementTabType.values()) { for (AdvancementTabType type : AdvancementTabType.values()) {
- if (index < type.getMax()) { - if (index < type.getMax()) {
- return new AdvancementTab(minecraft, screen, type, index, root, display.get()); - return new AdvancementTab(minecraft, screen, type, index, rootWidget, rootDisplay.icon(), rootDisplay.title(), background);
+ if ((index % AdvancementTabType.MAX_TABS) < type.getMax()) { + if ((index % AdvancementTabType.MAX_TABS) < type.getMax()) {
+ return new AdvancementTab(minecraft, screen, type, index % AdvancementTabType.MAX_TABS, index / AdvancementTabType.MAX_TABS, root, display.get()); + return new AdvancementTab(minecraft, screen, type, index % AdvancementTabType.MAX_TABS, index / AdvancementTabType.MAX_TABS, rootWidget, rootDisplay.icon(), rootDisplay.title(), background);
} }
index -= type.getMax(); index -= type.getMax();
@@ -34,10 +34,10 @@
for (AdvancementTab tab : this.tabs.values()) { for (AdvancementTab tab : this.tabs.values()) {
- if (tab.isMouseOver(xo, yo, event.x(), event.y())) { - if (tab.isMouseOver(xo, yo, event.x(), event.y())) {
+ if (tab.getPage() == tabPage && tab.isMouseOver(xo, yo, event.x(), event.y())) { + if (tab.getPage() == tabPage && tab.isMouseOver(xo, yo, event.x(), event.y())) {
this.advancements.setSelectedTab(tab.getRootNode().holder(), true); this.advancements.setSelectedTab(tab.getRootAdvancement(), true);
break; break;
} }
@@ -208,10 +_,12 @@ @@ -212,10 +_,12 @@
graphics.blit(RenderPipelines.GUI_TEXTURED, WINDOW_LOCATION, this.leftPos, this.topPos, 0.0F, 0.0F, 252, 140, 256, 256); graphics.blit(RenderPipelines.GUI_TEXTURED, WINDOW_LOCATION, this.leftPos, this.topPos, 0.0F, 0.0F, 252, 140, 256, 256);
if (this.tabs.size() > 1) { if (this.tabs.size() > 1) {
for (AdvancementTab tab : this.tabs.values()) { for (AdvancementTab tab : this.tabs.values()) {
@@ -50,7 +50,7 @@
tab.extractIcon(graphics, this.leftPos, this.topPos); tab.extractIcon(graphics, this.leftPos, this.topPos);
} }
} }
@@ -230,6 +_,7 @@ @@ -234,6 +_,7 @@
if (this.tabs.size() > 1) { if (this.tabs.size() > 1) {
for (AdvancementTab tab : this.tabs.values()) { for (AdvancementTab tab : this.tabs.values()) {
@@ -20,8 +20,8 @@
ItemStack item = this.hoveredSlot.getItem(); ItemStack item = this.hoveredSlot.getItem();
if (this.menu.getCarried().isEmpty() || this.showTooltipWithItemInHand(item)) { if (this.menu.getCarried().isEmpty() || this.showTooltipWithItemInHand(item)) {
graphics.setTooltipForNextFrame( graphics.setTooltipForNextFrame(
- this.font, this.getTooltipFromContainerItem(item), item.getTooltipImage(), mouseX, mouseY, item.get(DataComponents.TOOLTIP_STYLE) - this.font, this.getTooltipFromContainerItem(item), item.getTooltipImage(), mouseX, mouseY, item.get(DataComponents.TOOLTIP_STYLE), true
+ this.font, this.getTooltipFromContainerItem(item), item.getTooltipImage(), item, mouseX, mouseY + this.font, this.getTooltipFromContainerItem(item), item.getTooltipImage(), item, mouseX, mouseY, true
); );
} }
} }
@@ -35,7 +35,7 @@
} }
protected void extractLabels(final GuiGraphicsExtractor graphics, final int xm, final int ym) { protected void extractLabels(final GuiGraphicsExtractor graphics, final int xm, final int ym) {
@@ -285,7 +_,8 @@ @@ -297,7 +_,8 @@
return true; return true;
} }
@@ -45,7 +45,7 @@
Slot slot = this.getHoveredSlot(event.x(), event.y()); Slot slot = this.getHoveredSlot(event.x(), event.y());
this.doubleclick = this.lastClickSlot == slot && doubleClick; this.doubleclick = this.lastClickSlot == slot && doubleClick;
this.skipNextRelease = false; this.skipNextRelease = false;
@@ -295,6 +_,7 @@ @@ -307,6 +_,7 @@
int xo = this.leftPos; int xo = this.leftPos;
int yo = this.topPos; int yo = this.topPos;
boolean clickedOutside = this.hasClickedOutside(event.x(), event.y(), xo, yo); boolean clickedOutside = this.hasClickedOutside(event.x(), event.y(), xo, yo);
@@ -53,25 +53,25 @@
int slotId = -1; int slotId = -1;
if (slot != null) { if (slot != null) {
slotId = slot.index; slotId = slot.index;
@@ -306,7 +_,7 @@ @@ -318,7 +_,7 @@
if (slotId != -1 && !this.isQuickCrafting) { if (slotId != -1 && !this.isQuickCrafting) {
if (this.menu.getCarried().isEmpty()) { if (this.menu.getCarried().isEmpty()) {
- if (cloning) { - if (cloning) {
+ if (this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey)) { + if (this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey)) {
this.slotClicked(slot, slotId, event.button(), ContainerInput.CLONE); this.slotClicked(slot, slotId, event, ContainerInput.CLONE);
} else { } else {
boolean quickKey = slotId != -999 && event.hasShiftDown(); boolean quickKey = slotId != -999 && event.hasShiftDown();
@@ -330,7 +_,7 @@ @@ -342,7 +_,7 @@
this.quickCraftingType = 0; this.quickCraftingType = 0;
} else if (event.button() == 1) { } else if (event.button() == 3) {
this.quickCraftingType = 1; this.quickCraftingType = 1;
- } else if (cloning) { - } else if (cloning) {
+ } else if (this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey)) { + } else if (this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey)) {
this.quickCraftingType = 2; this.quickCraftingType = 2;
} }
} }
@@ -374,10 +_,13 @@ @@ -386,10 +_,13 @@
@Override @Override
public boolean mouseReleased(final MouseButtonEvent event) { public boolean mouseReleased(final MouseButtonEvent event) {
@@ -85,25 +85,25 @@
int slotId = -1; int slotId = -1;
if (slot != null) { if (slot != null) {
slotId = slot.index; slotId = slot.index;
@@ -394,7 +_,7 @@ @@ -406,7 +_,7 @@
if (target != null if (target != null
&& target.mayPickup(this.minecraft.player) && target.mayPickup(this.minecraft.player)
&& target.hasItem() && target.hasItem()
- && target.container == slot.container - && target.container == slot.container
+ && target.isSameInventory(slot) + && target.isSameInventory(slot)
&& AbstractContainerMenu.canItemQuickReplace(target, this.lastQuickMoved, true)) { && AbstractContainerMenu.canItemQuickReplace(target, this.lastQuickMoved, true)) {
this.slotClicked(target, target.index, event.button(), ContainerInput.QUICK_MOVE); this.slotClicked(target, target.index, event, ContainerInput.QUICK_MOVE);
} }
@@ -421,7 +_,7 @@ @@ -433,7 +_,7 @@
if (this.isQuickCrafting && !this.quickCraftSlots.isEmpty()) { if (this.isQuickCrafting && !this.quickCraftSlots.isEmpty()) {
this.quickCraftToSlots(); this.quickCraftToSlots();
} else if (!this.menu.getCarried().isEmpty()) { } else if (!this.menu.getCarried().isEmpty()) {
- if (this.minecraft.options.keyPickItem.matchesMouse(event)) { - if (this.minecraft.options.keyPickItem.matchesMouse(event)) {
+ if (this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey)) { + if (this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey)) {
this.slotClicked(slot, slotId, event.button(), ContainerInput.CLONE); this.slotClicked(slot, slotId, event, ContainerInput.CLONE);
} else { } else {
boolean quickKey = slotId != -999 && event.hasShiftDown(); boolean quickKey = slotId != -999 && event.hasShiftDown();
@@ -489,7 +_,7 @@ @@ -501,7 +_,7 @@
return true; return true;
} }
@@ -112,7 +112,7 @@
this.onClose(); this.onClose();
return true; return true;
} }
@@ -587,4 +_,11 @@ @@ -599,4 +_,11 @@
super.onClose(); super.onClose();
} }
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java --- a/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java
+++ b/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java +++ b/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java
@@ -116,6 +_,8 @@ @@ -117,6 +_,8 @@
private final Set<TagKey<Item>> visibleTags = new HashSet<>(); private final Set<TagKey<Item>> visibleTags = new HashSet<>();
private final boolean displayOperatorCreativeTab; private final boolean displayOperatorCreativeTab;
private final EffectsInInventory effects; private final EffectsInInventory effects;
@@ -9,7 +9,7 @@
public CreativeModeInventoryScreen(final LocalPlayer player, final FeatureFlagSet enabledFeatures, final boolean displayOperatorCreativeTab) { public CreativeModeInventoryScreen(final LocalPlayer player, final FeatureFlagSet enabledFeatures, final boolean displayOperatorCreativeTab) {
super(new CreativeModeInventoryScreen.ItemPickerMenu(player), player.getInventory(), CommonComponents.EMPTY, 195, 136); super(new CreativeModeInventoryScreen.ItemPickerMenu(player), player.getInventory(), CommonComponents.EMPTY, 195, 136);
@@ -164,7 +_,7 @@ @@ -165,7 +_,7 @@
private void refreshCurrentTabContents(final Collection<ItemStack> displayList) { private void refreshCurrentTabContents(final Collection<ItemStack> displayList) {
int oldRowIndex = this.menu.getRowIndexForScroll(this.scrollOffs); int oldRowIndex = this.menu.getRowIndexForScroll(this.scrollOffs);
this.menu.items.clear(); this.menu.items.clear();
@@ -18,7 +18,7 @@
this.refreshSearchResults(); this.refreshSearchResults();
} else { } else {
this.menu.items.addAll(displayList); this.menu.items.addAll(displayList);
@@ -330,6 +_,36 @@ @@ -331,6 +_,36 @@
protected void init() { protected void init() {
if (this.minecraft.player.hasInfiniteMaterials()) { if (this.minecraft.player.hasInfiniteMaterials()) {
super.init(); super.init();
@@ -55,7 +55,7 @@
this.searchBox = new EditBox(this.font, this.leftPos + 82, this.topPos + 6, 80, 9, Component.translatable("itemGroup.search")); this.searchBox = new EditBox(this.font, this.leftPos + 82, this.topPos + 6, 80, 9, Component.translatable("itemGroup.search"));
this.searchBox.setMaxLength(50); this.searchBox.setMaxLength(50);
this.searchBox.setBordered(false); this.searchBox.setBordered(false);
@@ -379,7 +_,7 @@ @@ -380,7 +_,7 @@
return false; return false;
} }
@@ -64,7 +64,7 @@
return false; return false;
} }
@@ -407,7 +_,7 @@ @@ -408,7 +_,7 @@
@Override @Override
public boolean keyPressed(final KeyEvent event) { public boolean keyPressed(final KeyEvent event) {
this.ignoreTextInput = false; this.ignoreTextInput = false;
@@ -73,7 +73,7 @@
if (this.minecraft.options.keyChat.matches(event)) { if (this.minecraft.options.keyChat.matches(event)) {
this.ignoreTextInput = true; this.ignoreTextInput = true;
this.selectTab(CreativeModeTabs.searchTab()); this.selectTab(CreativeModeTabs.searchTab());
@@ -443,6 +_,7 @@ @@ -449,6 +_,7 @@
} }
private void refreshSearchResults() { private void refreshSearchResults() {
@@ -81,7 +81,7 @@
this.menu.items.clear(); this.menu.items.clear();
this.visibleTags.clear(); this.visibleTags.clear();
String searchTerm = this.searchBox.getValue(); String searchTerm = this.searchBox.getValue();
@@ -455,10 +_,10 @@ @@ -461,10 +_,10 @@
SearchTree<ItemStack> tree; SearchTree<ItemStack> tree;
if (searchTerm.startsWith("#")) { if (searchTerm.startsWith("#")) {
searchTerm = searchTerm.substring(1); searchTerm = searchTerm.substring(1);
@@ -94,7 +94,7 @@
} }
this.menu.items.addAll(tree.search(searchTerm.toLowerCase(Locale.ROOT))); this.menu.items.addAll(tree.search(searchTerm.toLowerCase(Locale.ROOT)));
@@ -486,7 +_,7 @@ @@ -492,7 +_,7 @@
@Override @Override
protected void extractLabels(final GuiGraphicsExtractor graphics, final int xm, final int ym) { protected void extractLabels(final GuiGraphicsExtractor graphics, final int xm, final int ym) {
if (selectedTab.showTitle()) { if (selectedTab.showTitle()) {
@@ -103,7 +103,7 @@
} }
} }
@@ -496,7 +_,7 @@ @@ -502,7 +_,7 @@
double xm = event.x() - this.leftPos; double xm = event.x() - this.leftPos;
double ym = event.y() - this.topPos; double ym = event.y() - this.topPos;
@@ -112,7 +112,7 @@
if (this.checkTabClicked(tab, xm, ym)) { if (this.checkTabClicked(tab, xm, ym)) {
return true; return true;
} }
@@ -518,7 +_,7 @@ @@ -524,7 +_,7 @@
double ym = event.y() - this.topPos; double ym = event.y() - this.topPos;
this.scrolling = false; this.scrolling = false;
@@ -121,7 +121,7 @@
if (this.checkTabClicked(tab, xm, ym)) { if (this.checkTabClicked(tab, xm, ym)) {
this.selectTab(tab); this.selectTab(tab);
return true; return true;
@@ -611,13 +_,15 @@ @@ -617,13 +_,15 @@
this.originalSlots = null; this.originalSlots = null;
} }
@@ -138,7 +138,7 @@
this.refreshSearchResults(); this.refreshSearchResults();
} else { } else {
@@ -682,7 +_,14 @@ @@ -688,7 +_,14 @@
this.effects.extractRenderState(graphics, mouseX, mouseY); this.effects.extractRenderState(graphics, mouseX, mouseY);
super.extractRenderState(graphics, mouseX, mouseY, a); super.extractRenderState(graphics, mouseX, mouseY, a);
@@ -154,7 +154,7 @@
if (this.checkTabHovering(graphics, tab, mouseX, mouseY)) { if (this.checkTabHovering(graphics, tab, mouseX, mouseY)) {
break; break;
} }
@@ -704,7 +_,7 @@ @@ -710,7 +_,7 @@
public List<Component> getTooltipFromContainerItem(final ItemStack itemStack) { public List<Component> getTooltipFromContainerItem(final ItemStack itemStack) {
boolean isCreativeSlot = this.hoveredSlot != null && this.hoveredSlot instanceof CreativeModeInventoryScreen.CustomCreativeSlot; boolean isCreativeSlot = this.hoveredSlot != null && this.hoveredSlot instanceof CreativeModeInventoryScreen.CustomCreativeSlot;
boolean isSingleCategoryTab = selectedTab.getType() == CreativeModeTab.Type.CATEGORY; boolean isSingleCategoryTab = selectedTab.getType() == CreativeModeTab.Type.CATEGORY;
@@ -163,7 +163,7 @@
TooltipFlag.Default originalTooltipStyle = this.minecraft.options.advancedItemTooltips ? TooltipFlag.Default.ADVANCED : TooltipFlag.Default.NORMAL; TooltipFlag.Default originalTooltipStyle = this.minecraft.options.advancedItemTooltips ? TooltipFlag.Default.ADVANCED : TooltipFlag.Default.NORMAL;
TooltipFlag tooltipStyle = isCreativeSlot ? originalTooltipStyle.asCreative() : originalTooltipStyle; TooltipFlag tooltipStyle = isCreativeSlot ? originalTooltipStyle.asCreative() : originalTooltipStyle;
List<Component> originalLines = itemStack.getTooltipLines(Item.TooltipContext.of(this.minecraft.level), this.minecraft.player, tooltipStyle); List<Component> originalLines = itemStack.getTooltipLines(Item.TooltipContext.of(this.minecraft.level), this.minecraft.player, tooltipStyle);
@@ -728,7 +_,7 @@ @@ -734,7 +_,7 @@
int i = 1; int i = 1;
for (CreativeModeTab tab : CreativeModeTabs.tabs()) { for (CreativeModeTab tab : CreativeModeTabs.tabs()) {
@@ -172,7 +172,7 @@
linesToDisplay.add(i++, tab.getDisplayName().copy().withStyle(ChatFormatting.BLUE)); linesToDisplay.add(i++, tab.getDisplayName().copy().withStyle(ChatFormatting.BLUE));
} }
} }
@@ -740,7 +_,7 @@ @@ -746,7 +_,7 @@
public void extractBackground(final GuiGraphicsExtractor graphics, final int mouseX, final int mouseY, final float a) { public void extractBackground(final GuiGraphicsExtractor graphics, final int mouseX, final int mouseY, final float a) {
super.extractBackground(graphics, mouseX, mouseY, a); super.extractBackground(graphics, mouseX, mouseY, a);
@@ -181,7 +181,7 @@
if (tab != selectedTab) { if (tab != selectedTab) {
this.extractTabButton(graphics, mouseX, mouseY, tab); this.extractTabButton(graphics, mouseX, mouseY, tab);
} }
@@ -775,6 +_,7 @@ @@ -781,6 +_,7 @@
graphics.blitSprite(RenderPipelines.GUI_TEXTURED, sprite, xscr, yscr + (int)((yscr2 - yscr - 17) * this.scrollOffs), 12, 15); graphics.blitSprite(RenderPipelines.GUI_TEXTURED, sprite, xscr, yscr + (int)((yscr2 - yscr - 17) * this.scrollOffs), 12, 15);
} }
@@ -189,7 +189,7 @@
this.extractTabButton(graphics, mouseX, mouseY, selectedTab); this.extractTabButton(graphics, mouseX, mouseY, selectedTab);
if (selectedTab.getType() == CreativeModeTab.Type.INVENTORY) { if (selectedTab.getType() == CreativeModeTab.Type.INVENTORY) {
InventoryScreen.extractEntityInInventoryFollowsMouse( InventoryScreen.extractEntityInInventoryFollowsMouse(
@@ -784,7 +_,7 @@ @@ -790,7 +_,7 @@
} }
private int getTabX(final CreativeModeTab tab) { private int getTabX(final CreativeModeTab tab) {
@@ -198,7 +198,7 @@
int spacing = 27; int spacing = 27;
int x = 27 * pos; int x = 27 * pos;
if (tab.isAlignedRight()) { if (tab.isAlignedRight()) {
@@ -796,7 +_,7 @@ @@ -802,7 +_,7 @@
private int getTabY(final CreativeModeTab tab) { private int getTabY(final CreativeModeTab tab) {
int y = 0; int y = 0;
@@ -207,7 +207,7 @@
y -= 32; y -= 32;
} else { } else {
y += this.imageHeight; y += this.imageHeight;
@@ -824,8 +_,8 @@ @@ -830,8 +_,8 @@
protected void extractTabButton(final GuiGraphicsExtractor graphics, final int mouseX, final int mouseY, final CreativeModeTab tab) { protected void extractTabButton(final GuiGraphicsExtractor graphics, final int mouseX, final int mouseY, final CreativeModeTab tab) {
boolean selected = tab == selectedTab; boolean selected = tab == selectedTab;
@@ -218,7 +218,7 @@
int x = this.leftPos + this.getTabX(tab); int x = this.leftPos + this.getTabX(tab);
int y = this.topPos - (isTop ? 28 : -(this.imageHeight - 4)); int y = this.topPos - (isTop ? 28 : -(this.imageHeight - 4));
Identifier[] sprites; Identifier[] sprites;
@@ -875,6 +_,14 @@ @@ -881,6 +_,14 @@
} }
} }
@@ -233,7 +233,7 @@
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
private static class CustomCreativeSlot extends Slot { private static class CustomCreativeSlot extends Slot {
public CustomCreativeSlot(final Container container, final int slot, final int x, final int y) { public CustomCreativeSlot(final Container container, final int slot, final int x, final int y) {
@@ -1055,6 +_,22 @@ @@ -1061,6 +_,22 @@
@Override @Override
public boolean mayPickup(final Player player) { public boolean mayPickup(final Player player) {
return this.target.mayPickup(player); return this.target.mayPickup(player);
@@ -1,11 +1,11 @@
--- a/net/minecraft/client/gui/screens/inventory/HangingSignEditScreen.java --- a/net/minecraft/client/gui/screens/inventory/HangingSignEditScreen.java
+++ b/net/minecraft/client/gui/screens/inventory/HangingSignEditScreen.java +++ b/net/minecraft/client/gui/screens/inventory/HangingSignEditScreen.java
@@ -16,7 +_,7 @@ @@ -17,7 +_,7 @@
private static final Vector3fc TEXT_SCALE = new Vector3f(1.0F, 1.0F, 1.0F); private static final Vector3fc TEXT_SCALE = new Vector3f(1.0F, 1.0F, 1.0F);
private static final int TEXTURE_WIDTH = 16; private static final int TEXTURE_WIDTH = 16;
private static final int TEXTURE_HEIGHT = 16; private static final int TEXTURE_HEIGHT = 16;
- private final Identifier texture = Identifier.withDefaultNamespace("textures/gui/hanging_signs/" + this.woodType.name() + ".png"); - private final Identifier texture = Identifier.withDefaultNamespace("textures/gui/hanging_signs/" + this.woodType.name() + ".png");
+ private final Identifier texture = Identifier.parse(this.woodType.name() + ".png").withPrefix("textures/gui/hanging_signs/"); + private final Identifier texture = Identifier.parse(this.woodType.name() + ".png").withPrefix("textures/gui/hanging_signs/");
public HangingSignEditScreen(final SignBlockEntity sign, final boolean isFrontText, final boolean shouldFilter) { public HangingSignEditScreen(final SignBlockEntity sign, final SignTextSlot slot, final boolean shouldFilter) {
super(sign, isFrontText, shouldFilter, Component.translatable("hanging_sign.edit")); super(sign, slot, shouldFilter, Component.translatable("hanging_sign.edit"));
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/options/controls/KeyBindsList.java --- a/net/minecraft/client/gui/screens/options/controls/KeyBindsList.java
+++ b/net/minecraft/client/gui/screens/options/controls/KeyBindsList.java +++ b/net/minecraft/client/gui/screens/options/controls/KeyBindsList.java
@@ -116,9 +_,10 @@ @@ -118,9 +_,10 @@
this.name = name; this.name = name;
this.changeButton = Button.builder(name, button -> { this.changeButton = Button.builder(name, button -> {
KeyBindsList.this.keyBindsScreen.selectedKey = key; KeyBindsList.this.keyBindsScreen.selectedKey = key;
@@ -12,7 +12,7 @@
.createNarration( .createNarration(
defaultNarrationSupplier -> key.isUnbound() defaultNarrationSupplier -> key.isUnbound()
? Component.translatable("narrator.controls.unbound", name) ? Component.translatable("narrator.controls.unbound", name)
@@ -126,7 +_,7 @@ @@ -128,7 +_,7 @@
) )
.build(); .build();
this.resetButton = Button.builder(RESET_BUTTON_TITLE, button -> { this.resetButton = Button.builder(RESET_BUTTON_TITLE, button -> {
@@ -21,7 +21,7 @@
KeyBindsList.this.resetMappingAndUpdateButtons(); KeyBindsList.this.resetMappingAndUpdateButtons();
}).bounds(0, 0, 50, 20).createNarration(defaultNarrationSupplier -> Component.translatable("narrator.controls.reset", name)).build(); }).bounds(0, 0, 50, 20).createNarration(defaultNarrationSupplier -> Component.translatable("narrator.controls.reset", name)).build();
this.refreshEntry(); this.refreshEntry();
@@ -167,7 +_,8 @@ @@ -169,7 +_,8 @@
MutableComponent tooltip = Component.empty(); MutableComponent tooltip = Component.empty();
if (!this.key.isUnbound()) { if (!this.key.isUnbound()) {
for (KeyMapping otherKey : KeyBindsList.this.minecraft.options.keyMappings) { for (KeyMapping otherKey : KeyBindsList.this.minecraft.options.keyMappings) {
@@ -9,7 +9,7 @@
} }
this.keyBindsList.resetMappingAndUpdateButtons(); this.keyBindsList.resetMappingAndUpdateButtons();
@@ -74,11 +_,12 @@ @@ -78,11 +_,12 @@
public boolean keyPressed(final KeyEvent event) { public boolean keyPressed(final KeyEvent event) {
if (this.selectedKey != null) { if (this.selectedKey != null) {
if (event.isEscape()) { if (event.isEscape()) {
@@ -24,7 +24,7 @@
this.selectedKey = null; this.selectedKey = null;
this.lastKeySelection = Util.getMillis(); this.lastKeySelection = Util.getMillis();
this.keyBindsList.resetMappingAndUpdateButtons(); this.keyBindsList.resetMappingAndUpdateButtons();
@@ -101,5 +_,18 @@ @@ -105,5 +_,18 @@
} }
this.resetButton.active = canReset; this.resetButton.active = canReset;
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java --- a/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java
+++ b/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java +++ b/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java
@@ -495,6 +_,8 @@ @@ -504,6 +_,8 @@
this.minecraft.setScreenAndShow(new GenericMessageScreen(Component.translatable("selectWorld.resource_load"))); this.minecraft.setScreenAndShow(new GenericMessageScreen(Component.translatable("selectWorld.resource_load")));
PackRepository packRepository = ServerPacksSource.createPackRepository(worldAccess); PackRepository packRepository = ServerPacksSource.createPackRepository(worldAccess);
@@ -9,7 +9,7 @@
WorldStem worldStem; WorldStem worldStem;
try { try {
worldStem = this.loadWorldStem(worldAccess, levelDataTag, safeMode, packRepository); worldStem = this.loadWorldStem(worldAccess, levelDataTag, safeMode, packRepository);
@@ -537,6 +_,8 @@ @@ -546,6 +_,8 @@
WorldData data = worldDataAndGenSettings.data(); WorldData data = worldDataAndGenSettings.data();
boolean oldCustomized = worldDataAndGenSettings.genSettings().options().isOldCustomizedWorld(); boolean oldCustomized = worldDataAndGenSettings.genSettings().options().isOldCustomizedWorld();
boolean unstable = data.worldGenSettingsLifecycle() != Lifecycle.stable(); boolean unstable = data.worldGenSettingsLifecycle() != Lifecycle.stable();
@@ -18,7 +18,7 @@
if (!oldCustomized && !unstable) { if (!oldCustomized && !unstable) {
this.openWorldLoadBundledResourcePack(worldAccess, worldStem, packRepository, onCancel); this.openWorldLoadBundledResourcePack(worldAccess, worldStem, packRepository, onCancel);
} else { } else {
@@ -553,6 +_,8 @@ @@ -562,6 +_,8 @@
private void openWorldLoadBundledResourcePack( private void openWorldLoadBundledResourcePack(
final LevelStorageSource.LevelStorageAccess worldAccess, final WorldStem worldStem, final PackRepository packRepository, final Runnable onCancel final LevelStorageSource.LevelStorageAccess worldAccess, final WorldStem worldStem, final PackRepository packRepository, final Runnable onCancel
) { ) {
@@ -1,24 +1,24 @@
--- a/net/minecraft/client/model/HumanoidModel.java --- a/net/minecraft/client/model/HumanoidModel.java
+++ b/net/minecraft/client/model/HumanoidModel.java +++ b/net/minecraft/client/model/HumanoidModel.java
@@ -391,6 +_,8 @@ @@ -380,6 +_,8 @@
break; break;
case SPEAR: case SPEAR:
SpearAnimations.thirdPersonHandUse(this.rightArm, this.head, true, state.getUseItemStackForArm(HumanoidArm.RIGHT), state); SpearAnimations.thirdPersonHandUse(this.rightArm, this.head, HumanoidArm.RIGHT, state.getUseItemStackForArm(HumanoidArm.RIGHT), state);
+ default: + default:
+ state.rightArmPose.applyTransform(this, state, net.minecraft.world.entity.HumanoidArm.RIGHT); + state.rightArmPose.applyTransform(this, state, HumanoidArm.RIGHT);
} }
} }
@@ -436,6 +_,8 @@ @@ -425,6 +_,8 @@
break; break;
case SPEAR: case SPEAR:
SpearAnimations.thirdPersonHandUse(this.leftArm, this.head, false, state.getUseItemStackForArm(HumanoidArm.LEFT), state); SpearAnimations.thirdPersonHandUse(this.leftArm, this.head, HumanoidArm.LEFT, state.getUseItemStackForArm(HumanoidArm.LEFT), state);
+ default: + default:
+ state.leftArmPose.applyTransform(this, state, net.minecraft.world.entity.HumanoidArm.LEFT); + state.leftArmPose.applyTransform(this, state, HumanoidArm.LEFT);
} }
} }
@@ -497,7 +_,7 @@ @@ -487,7 +_,7 @@
} }
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
@@ -27,7 +27,7 @@
EMPTY(false, false), EMPTY(false, false),
ITEM(false, false), ITEM(false, false),
BLOCK(false, false), BLOCK(false, false),
@@ -523,10 +_,29 @@ @@ -513,10 +_,29 @@
ArmPose(final boolean twoHanded, final boolean affectsOffhandPose) { ArmPose(final boolean twoHanded, final boolean affectsOffhandPose) {
this.twoHanded = twoHanded; this.twoHanded = twoHanded;
this.affectsOffhandPose = affectsOffhandPose; this.affectsOffhandPose = affectsOffhandPose;
@@ -1,9 +1,9 @@
--- a/net/minecraft/client/model/geom/LayerDefinitions.java --- a/net/minecraft/client/model/geom/LayerDefinitions.java
+++ b/net/minecraft/client/model/geom/LayerDefinitions.java +++ b/net/minecraft/client/model/geom/LayerDefinitions.java
@@ -557,6 +_,7 @@ @@ -561,6 +_,7 @@
result.put(ModelLayers.PALE_OAK_CHEST_BOAT, chestBoatModel);
result.put(ModelLayers.MANGROVE_BOAT, boatModel);
result.put(ModelLayers.MANGROVE_CHEST_BOAT, chestBoatModel); result.put(ModelLayers.MANGROVE_CHEST_BOAT, chestBoatModel);
result.put(ModelLayers.POPLAR_BOAT, boatModel);
result.put(ModelLayers.POPLAR_CHEST_BOAT, chestBoatModel);
+ net.minecraftforge.client.ForgeHooksClient.loadLayerDefinitions(result); + net.minecraftforge.client.ForgeHooksClient.loadLayerDefinitions(result);
ImmutableMap<ModelLayerLocation, LayerDefinition> definitions = result.build(); ImmutableMap<ModelLayerLocation, LayerDefinition> definitions = result.build();
List<ModelLayerLocation> missingDefinitions = ModelLayers.getKnownLocations().filter(l -> !definitions.containsKey(l)).toList(); List<ModelLayerLocation> missingDefinitions = ModelLayers.getKnownLocations().filter(l -> !definitions.containsKey(l)).toList();
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/multiplayer/ClientChunkCache.java --- a/net/minecraft/client/multiplayer/ClientChunkCache.java
+++ b/net/minecraft/client/multiplayer/ClientChunkCache.java +++ b/net/minecraft/client/multiplayer/ClientChunkCache.java
@@ -64,6 +_,7 @@ @@ -61,6 +_,7 @@
int index = this.storage.getIndex(pos.x(), pos.z()); int index = this.storage.getIndex(pos.x(), pos.z());
LevelChunk currentChunk = this.storage.getChunk(index); LevelChunk currentChunk = this.storage.getChunk(index);
if (isValidChunk(currentChunk, pos.x(), pos.z())) { if (isValidChunk(currentChunk, pos.x(), pos.z())) {
@@ -8,7 +8,7 @@
this.storage.drop(index, currentChunk); this.storage.drop(index, currentChunk);
} }
} }
@@ -124,6 +_,7 @@ @@ -115,6 +_,7 @@
} }
this.level.onChunkLoaded(pos); this.level.onChunkLoaded(pos);
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java --- a/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java
+++ b/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java +++ b/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java
@@ -157,6 +_,7 @@ @@ -158,6 +_,7 @@
@Override @Override
public void handleCustomPayload(final ClientboundCustomPayloadPacket packet) { public void handleCustomPayload(final ClientboundCustomPayloadPacket packet) {
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/multiplayer/ClientLevel.java --- a/net/minecraft/client/multiplayer/ClientLevel.java
+++ b/net/minecraft/client/multiplayer/ClientLevel.java +++ b/net/minecraft/client/multiplayer/ClientLevel.java
@@ -165,6 +_,7 @@ @@ -168,6 +_,7 @@
cache.put(BiomeColors.FOLIAGE_COLOR_RESOLVER, new BlockTintCache(pos -> this.calculateBlockTint(pos, BiomeColors.FOLIAGE_COLOR_RESOLVER))); cache.put(BiomeColors.FOLIAGE_COLOR_RESOLVER, new BlockTintCache(pos -> this.calculateBlockTint(pos, BiomeColors.FOLIAGE_COLOR_RESOLVER)));
cache.put(BiomeColors.DRY_FOLIAGE_COLOR_RESOLVER, new BlockTintCache(pos -> this.calculateBlockTint(pos, BiomeColors.DRY_FOLIAGE_COLOR_RESOLVER))); cache.put(BiomeColors.DRY_FOLIAGE_COLOR_RESOLVER, new BlockTintCache(pos -> this.calculateBlockTint(pos, BiomeColors.DRY_FOLIAGE_COLOR_RESOLVER)));
cache.put(BiomeColors.WATER_COLOR_RESOLVER, new BlockTintCache(pos -> this.calculateBlockTint(pos, BiomeColors.WATER_COLOR_RESOLVER))); cache.put(BiomeColors.WATER_COLOR_RESOLVER, new BlockTintCache(pos -> this.calculateBlockTint(pos, BiomeColors.WATER_COLOR_RESOLVER)));
@@ -8,7 +8,7 @@
}); });
private final ClientChunkCache chunkSource; private final ClientChunkCache chunkSource;
private final Deque<Runnable> lightUpdateQueue = Queues.newArrayDeque(); private final Deque<Runnable> lightUpdateQueue = Queues.newArrayDeque();
@@ -178,6 +_,8 @@ @@ -181,6 +_,8 @@
private final Long2ObjectMap<SortedSet<BlockDestructionProgress>> destructionProgress = new Long2ObjectOpenHashMap<>(); private final Long2ObjectMap<SortedSet<BlockDestructionProgress>> destructionProgress = new Long2ObjectOpenHashMap<>();
private final int seaLevel; private final int seaLevel;
private static final Set<Item> MARKER_PARTICLE_ITEMS = Set.of(Items.BARRIER, Items.LIGHT); private static final Set<Item> MARKER_PARTICLE_ITEMS = Set.of(Items.BARRIER, Items.LIGHT);
@@ -17,7 +17,7 @@
public void handleBlockChangedAck(final int sequence) { public void handleBlockChangedAck(final int sequence) {
if (SharedConstants.DEBUG_BLOCK_BREAK) { if (SharedConstants.DEBUG_BLOCK_BREAK) {
@@ -260,6 +_,8 @@ @@ -263,6 +_,8 @@
this.serverSimulationDistance = serverSimulationDistance; this.serverSimulationDistance = serverSimulationDistance;
this.environmentAttributes = this.addEnvironmentAttributeLayers(EnvironmentAttributeSystem.builder()).build(); this.environmentAttributes = this.addEnvironmentAttributeLayers(EnvironmentAttributeSystem.builder()).build();
this.updateSkyBrightness(); this.updateSkyBrightness();
@@ -26,15 +26,15 @@
} }
private EnvironmentAttributeSystem.Builder addEnvironmentAttributeLayers(final EnvironmentAttributeSystem.Builder environmentAttributes) { private EnvironmentAttributeSystem.Builder addEnvironmentAttributeLayers(final EnvironmentAttributeSystem.Builder environmentAttributes) {
@@ -471,6 +_,7 @@ @@ -473,6 +_,7 @@
entity.setOldPosAndRot(); public void tickNonPassenger(final Entity entity) {
entity.tickCount++;
Profiler.get().push(entity.typeHolder()::getRegisteredName); Profiler.get().push(entity.typeHolder()::getRegisteredName);
entity.commonTick();
+ if (entity.canUpdate()) + if (entity.canUpdate())
entity.tick(); entity.tick();
Profiler.get().pop(); Profiler.get().pop();
@@ -527,8 +_,10 @@ @@ -528,8 +_,10 @@
} }
public void addEntity(final Entity entity) { public void addEntity(final Entity entity) {
@@ -45,7 +45,7 @@
} }
public void removeEntity(final int id, final Entity.RemovalReason reason) { public void removeEntity(final int id, final Entity.RemovalReason reason) {
@@ -692,8 +_,10 @@ @@ -693,8 +_,10 @@
final float pitch, final float pitch,
final long seed final long seed
) { ) {
@@ -57,7 +57,7 @@
} }
} }
@@ -707,8 +_,10 @@ @@ -708,8 +_,10 @@
final float pitch, final float pitch,
final long seed final long seed
) { ) {
@@ -69,7 +69,7 @@
} }
} }
@@ -1081,7 +_,7 @@ @@ -1095,7 +_,7 @@
@Override @Override
public void addDestroyBlockEffect(final BlockPos pos, final BlockState blockState) { public void addDestroyBlockEffect(final BlockPos pos, final BlockState blockState) {
@@ -78,7 +78,7 @@
VoxelShape shape = blockState.getShape(this, pos); VoxelShape shape = blockState.getShape(this, pos);
double density = 0.25; double density = 0.25;
shape.forAllBoxes( shape.forAllBoxes(
@@ -1108,6 +_,7 @@ @@ -1122,6 +_,7 @@
new TerrainParticle( new TerrainParticle(
this, pos.getX() + x, pos.getY() + y, pos.getZ() + z, relX - 0.5, relY - 0.5, relZ - 0.5, blockState, pos this, pos.getX() + x, pos.getY() + y, pos.getZ() + z, relX - 0.5, relY - 0.5, relZ - 0.5, blockState, pos
) )
@@ -86,30 +86,29 @@
); );
} }
} }
@@ -1117,6 +_,13 @@ @@ -1138,6 +_,7 @@
} this.playBreakingSound(pos, blockState);
}
+ public void addBreakingBlockEffect(BlockPos pos, net.minecraft.world.phys.BlockHitResult target) {
+ var state = this.getBlockState(pos);
+ if (!net.minecraftforge.client.extensions.common.IClientBlockExtensions.of(state).addHitEffects(state, this, target, this.minecraft.particleEngine))
+ addBreakingBlockEffect(pos, target.getDirection());
+ }
+
+ /** @deprecated Forge - Use crack(BlockPos, BlockHitResult) as it has more context and gives more control to modders */
public void addBreakingBlockEffect(final BlockPos pos, final Direction direction) {
BlockState blockState = this.getBlockState(pos);
if (blockState.getRenderShape() != RenderShape.INVISIBLE && blockState.shouldSpawnTerrainParticles()) {
@@ -1152,7 +_,7 @@
xp = x + shape.maxX + 0.1F;
} }
- this.minecraft.particleEngine.add(new TerrainParticle(this, xp, yp, zp, 0.0, 0.0, 0.0, blockState, pos).setPower(0.2F).scale(0.6F)); + if (!net.minecraftforge.client.extensions.common.IClientBlockExtensions.of(blockState).addHitEffects(blockState, this, direction, this.minecraft.particleEngine))
+ this.minecraft.particleEngine.add(new TerrainParticle(this, xp, yp, zp, 0.0, 0.0, 0.0, blockState, pos).updateSprite(blockState, pos).setPower(0.2F).scale(0.6F)); if (blockState.getRenderShape() != RenderShape.INVISIBLE && blockState.shouldSpawnTerrainParticles()) {
this.addBreakingParticles(pos, direction, blockState);
}
@@ -1177,11 +_,11 @@
xp = x + shape.maxX + 0.1F;
} }
- this.minecraft.particleEngine.add(new TerrainParticle(this, xp, yp, zp, 0.0, 0.0, 0.0, blockState, pos).setPower(0.2F).scale(0.6F));
+ this.minecraft.particleEngine.add(new TerrainParticle(this, xp, yp, zp, 0.0, 0.0, 0.0, blockState, pos).updateSprite(blockState, pos).setPower(0.2F).scale(0.6F));
} }
@@ -1218,6 +_,16 @@ private void playBreakingSound(final BlockPos pos, final BlockState blockState) {
- SoundType soundType = blockState.getSoundType();
+ SoundType soundType = blockState.getSoundType(this, pos, this.minecraft.player);
this.minecraft
.getSoundManager()
.play(
@@ -1248,6 +_,16 @@
this.explosionTracker.track(center, radius, blockCount, blockParticles); this.explosionTracker.track(center, radius, blockCount, blockParticles);
} }
@@ -126,7 +125,7 @@
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public static class ClientLevelData implements WritableLevelData { public static class ClientLevelData implements WritableLevelData {
private final boolean hardcore; private final boolean hardcore;
@@ -1273,6 +_,7 @@ @@ -1303,6 +_,7 @@
} }
public void setDifficulty(final Difficulty difficulty) { public void setDifficulty(final Difficulty difficulty) {
@@ -134,7 +133,7 @@
this.difficulty = difficulty; this.difficulty = difficulty;
} }
@@ -1315,6 +_,12 @@ @@ -1345,6 +_,12 @@
break; break;
default: default:
} }
@@ -147,7 +146,7 @@
} }
public void onTrackingEnd(final Entity entity) { public void onTrackingEnd(final Entity entity) {
@@ -1327,6 +_,15 @@ @@ -1357,6 +_,15 @@
ClientLevel.this.dragonParts.removeAll(Arrays.asList(dragon.getSubEntities())); ClientLevel.this.dragonParts.removeAll(Arrays.asList(dragon.getSubEntities()));
break; break;
default: default:
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/multiplayer/ClientPacketListener.java --- a/net/minecraft/client/multiplayer/ClientPacketListener.java
+++ b/net/minecraft/client/multiplayer/ClientPacketListener.java +++ b/net/minecraft/client/multiplayer/ClientPacketListener.java
@@ -531,6 +_,7 @@ @@ -534,6 +_,7 @@
this.debugSubscriber.clear(); this.debugSubscriber.clear();
this.minecraft.levelExtractor.debugRenderer.refreshRendererList(); this.minecraft.levelExtractor.debugRenderer.refreshRendererList();
this.minecraft.player.resetPos(); this.minecraft.player.resetPos();
@@ -8,7 +8,7 @@
this.minecraft.player.setId(packet.playerId()); this.minecraft.player.setId(packet.playerId());
this.level.addEntity(this.minecraft.player); this.level.addEntity(this.minecraft.player);
this.minecraft.player.input = new KeyboardInput(this.minecraft.options); this.minecraft.player.input = new KeyboardInput(this.minecraft.options);
@@ -1323,6 +_,8 @@ @@ -1334,6 +_,8 @@
newPlayer.getAttributes().assignBaseValues(oldPlayer.getAttributes()); newPlayer.getAttributes().assignBaseValues(oldPlayer.getAttributes());
} }
@@ -17,7 +17,7 @@
this.level.addEntity(newPlayer); this.level.addEntity(newPlayer);
newPlayer.input = new KeyboardInput(this.minecraft.options); newPlayer.input = new KeyboardInput(this.minecraft.options);
this.minecraft.gameMode.adjustPlayer(newPlayer); this.minecraft.gameMode.adjustPlayer(newPlayer);
@@ -1478,7 +_,7 @@ @@ -1492,7 +_,7 @@
ProblemReporter.ScopedCollector reporter = new ProblemReporter.ScopedCollector(blockEntity.problemPath(), LOGGER); ProblemReporter.ScopedCollector reporter = new ProblemReporter.ScopedCollector(blockEntity.problemPath(), LOGGER);
try { try {
@@ -26,7 +26,7 @@
} catch (Throwable t$) { } catch (Throwable t$) {
try { try {
reporter.close(); reporter.close();
@@ -1686,7 +_,9 @@ @@ -1700,7 +_,9 @@
@Override @Override
public void handleCommands(final ClientboundCommandsPacket packet) { public void handleCommands(final ClientboundCommandsPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.minecraft.packetProcessor()); PacketUtils.ensureRunningOnSameThread(packet, this, this.minecraft.packetProcessor());
@@ -37,7 +37,7 @@
} }
@Override @Override
@@ -1787,6 +_,7 @@ @@ -1801,6 +_,7 @@
if (this.minecraft.gui.screen() instanceof RecipeUpdateListener updateListener) { if (this.minecraft.gui.screen() instanceof RecipeUpdateListener updateListener) {
updateListener.recipesUpdated(); updateListener.recipesUpdated();
} }
@@ -45,8 +45,8 @@
} }
@Override @Override
@@ -1830,6 +_,8 @@ @@ -1843,6 +_,8 @@
this.fuelValues = FuelValues.vanillaBurnTimes(this.registryAccess, this.enabledFeatures);
List<ItemStack> searchItems = List.copyOf(CreativeModeTabs.searchTab().getDisplayItems()); List<ItemStack> searchItems = List.copyOf(CreativeModeTabs.searchTab().getDisplayItems());
this.searchTrees.updateCreativeTags(searchItems); this.searchTrees.updateCreativeTags(searchItems);
+ +
@@ -54,7 +54,7 @@
} }
@Override @Override
@@ -2652,7 +_,9 @@ @@ -2672,7 +_,9 @@
} }
} }
@@ -65,7 +65,7 @@
Instant timeStamp = Instant.now(); Instant timeStamp = Instant.now();
long salt = Crypt.SaltSupplier.getLong(); long salt = Crypt.SaltSupplier.getLong();
LastSeenMessagesTracker.Update lastSeenUpdate = this.lastSeenMessages.generateAndApplyUpdate(); LastSeenMessagesTracker.Update lastSeenUpdate = this.lastSeenMessages.generateAndApplyUpdate();
@@ -2661,6 +_,7 @@ @@ -2681,6 +_,7 @@
} }
public void sendCommand(final String command) { public void sendCommand(final String command) {
@@ -73,7 +73,7 @@
SignableCommand<ClientSuggestionProvider> signableCommand = SignableCommand.of(this.commands.parse(command, this.suggestionsProvider)); SignableCommand<ClientSuggestionProvider> signableCommand = SignableCommand.of(this.commands.parse(command, this.suggestionsProvider));
if (signableCommand.arguments().isEmpty()) { if (signableCommand.arguments().isEmpty()) {
this.send(new ServerboundChatCommandPacket(command)); this.send(new ServerboundChatCommandPacket(command));
@@ -2677,6 +_,7 @@ @@ -2697,6 +_,7 @@
} }
public void sendUnattendedCommand(final String command, final @Nullable Screen screenAfterCommand) { public void sendUnattendedCommand(final String command, final @Nullable Screen screenAfterCommand) {
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/multiplayer/MultiPlayerGameMode.java --- a/net/minecraft/client/multiplayer/MultiPlayerGameMode.java
+++ b/net/minecraft/client/multiplayer/MultiPlayerGameMode.java +++ b/net/minecraft/client/multiplayer/MultiPlayerGameMode.java
@@ -115,6 +_,7 @@ @@ -120,6 +_,7 @@
} }
public boolean destroyBlock(final BlockPos pos) { public boolean destroyBlock(final BlockPos pos) {
@@ -8,7 +8,7 @@
if (this.minecraft.player.blockActionRestricted(this.minecraft.level, pos, this.localPlayerMode)) { if (this.minecraft.player.blockActionRestricted(this.minecraft.level, pos, this.localPlayerMode)) {
return false; return false;
} }
@@ -134,9 +_,8 @@ @@ -139,9 +_,8 @@
return false; return false;
} }
@@ -19,7 +19,7 @@
if (changed) { if (changed) {
oldBlock.destroy(level, pos, oldState); oldBlock.destroy(level, pos, oldState);
} }
@@ -165,6 +_,7 @@ @@ -170,6 +_,7 @@
} }
this.startPrediction(this.minecraft.level, sequence -> { this.startPrediction(this.minecraft.level, sequence -> {
@@ -27,7 +27,7 @@
this.destroyBlock(pos); this.destroyBlock(pos);
return new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, pos, direction, sequence); return new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, pos, direction, sequence);
}); });
@@ -178,6 +_,7 @@ @@ -183,6 +_,7 @@
this.connection this.connection
.send(new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK, this.destroyBlockPos, direction)); .send(new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK, this.destroyBlockPos, direction));
} }
@@ -35,7 +35,7 @@
BlockState state = this.minecraft.level.getBlockState(pos); BlockState state = this.minecraft.level.getBlockState(pos);
this.minecraft.getTutorial().onDestroyBlock(this.minecraft.level, pos, state, 0.0F); this.minecraft.getTutorial().onDestroyBlock(this.minecraft.level, pos, state, 0.0F);
@@ -188,9 +_,11 @@ @@ -193,9 +_,11 @@
this.startPrediction(this.minecraft.level, sequence -> { this.startPrediction(this.minecraft.level, sequence -> {
boolean notAir = !state.isAir(); boolean notAir = !state.isAir();
if (notAir && this.destroyProgress == 0.0F) { if (notAir && this.destroyProgress == 0.0F) {
@@ -47,15 +47,15 @@
if (notAir && state.getDestroyProgress(this.minecraft.player, this.minecraft.player.level(), pos) >= 1.0F) { if (notAir && state.getDestroyProgress(this.minecraft.player, this.minecraft.player.level(), pos) >= 1.0F) {
this.destroyBlock(pos); this.destroyBlock(pos);
} else { } else {
@@ -201,6 +_,7 @@ @@ -208,6 +_,7 @@
this.destroyTicks = 0.0F;
this.minecraft.level.destroyBlockProgress(this.minecraft.player.getId(), this.destroyBlockPos, this.getDestroyStage()); this.minecraft.level.destroyBlockProgress(this.minecraft.player.getId(), this.destroyBlockPos, this.getDestroyStage());
this.minecraft.level.addBreakingBlockEffects(this.destroyBlockPos, this.destroyDirection, true);
} }
+ } + }
return new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, pos, direction, sequence); return new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, pos, direction, sequence);
}); });
@@ -242,6 +_,7 @@ @@ -249,6 +_,7 @@
} }
this.startPrediction(this.minecraft.level, sequence -> { this.startPrediction(this.minecraft.level, sequence -> {
@@ -63,24 +63,15 @@
this.destroyBlock(pos); this.destroyBlock(pos);
return new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, pos, direction, sequence); return new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, pos, direction, sequence);
}); });
@@ -255,7 +_,7 @@ @@ -263,6 +_,7 @@
this.destroyProgress = this.destroyProgress + state.getDestroyProgress(this.minecraft.player, this.minecraft.player.level(), pos); this.destroyProgress = this.destroyProgress + state.getDestroyProgress(this.minecraft.player, this.minecraft.player.level(), pos);
if (this.destroyTicks % 4.0F == 0.0F) {
- SoundType soundType = state.getSoundType();
+ SoundType soundType = state.getSoundType(this.minecraft.level, pos, this.minecraft.player);
this.minecraft
.getSoundManager()
.play(
@@ -272,6 +_,7 @@
this.destroyTicks++; this.destroyTicks++;
this.minecraft.getTutorial().onDestroyBlock(this.minecraft.level, pos, state, Mth.clamp(this.destroyProgress, 0.0F, 1.0F)); this.minecraft.getTutorial().onDestroyBlock(this.minecraft.level, pos, state, Mth.clamp(this.destroyProgress, 0.0F, 1.0F));
+ if (net.minecraftforge.event.ForgeEventFactory.onLeftClickBlockHold(this.minecraft.player, pos, direction).getUseItem().isDenied()) return true; + if (net.minecraftforge.event.ForgeEventFactory.onLeftClickBlockHold(this.minecraft.player, pos, direction).getUseItem().isDenied()) return true;
if (this.destroyProgress >= 1.0F) { if (this.destroyProgress >= 1.0F) {
this.isDestroying = false; this.isDestroying = false;
if (SharedConstants.DEBUG_BLOCK_BREAK) { if (SharedConstants.DEBUG_BLOCK_BREAK) {
@@ -279,6 +_,7 @@ @@ -270,6 +_,7 @@
} }
this.startPrediction(this.minecraft.level, sequence -> { this.startPrediction(this.minecraft.level, sequence -> {
@@ -88,7 +79,7 @@
this.destroyBlock(pos); this.destroyBlock(pos);
return new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.STOP_DESTROY_BLOCK, pos, direction, sequence); return new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.STOP_DESTROY_BLOCK, pos, direction, sequence);
}); });
@@ -313,7 +_,7 @@ @@ -308,7 +_,7 @@
private boolean sameDestroyTarget(final BlockPos pos) { private boolean sameDestroyTarget(final BlockPos pos) {
ItemStack selected = this.minecraft.player.getMainHandItem(); ItemStack selected = this.minecraft.player.getMainHandItem();
@@ -97,7 +88,7 @@
} }
private void ensureHasSentCarriedItem() { private void ensureHasSentCarriedItem() {
@@ -341,13 +_,24 @@ @@ -336,13 +_,24 @@
private InteractionResult performUseItemOn(final LocalPlayer player, final InteractionHand hand, final BlockHitResult blockHit) { private InteractionResult performUseItemOn(final LocalPlayer player, final InteractionHand hand, final BlockHitResult blockHit) {
BlockPos pos = blockHit.getBlockPos(); BlockPos pos = blockHit.getBlockPos();
ItemStack itemStack = player.getItemInHand(hand); ItemStack itemStack = player.getItemInHand(hand);
@@ -124,7 +115,7 @@
BlockState blockState = this.minecraft.level.getBlockState(pos); BlockState blockState = this.minecraft.level.getBlockState(pos);
if (!this.connection.isFeatureEnabled(blockState.getBlock().requiredFeatures())) { if (!this.connection.isFeatureEnabled(blockState.getBlock().requiredFeatures())) {
return InteractionResult.FAIL; return InteractionResult.FAIL;
@@ -366,8 +_,10 @@ @@ -361,8 +_,10 @@
} }
} }
@@ -134,10 +125,10 @@
+ return InteractionResult.PASS; + return InteractionResult.PASS;
+ } + }
+ if (event.getUseItem().isAllowed() || (!itemStack.isEmpty() && !player.getCooldowns().isOnCooldown(itemStack))) { + if (event.getUseItem().isAllowed() || (!itemStack.isEmpty() && !player.getCooldowns().isOnCooldown(itemStack))) {
InteractionResult success; InteractionResult result;
if (player.hasInfiniteMaterials()) { if (player.hasInfiniteMaterials()) {
int count = itemStack.getCount(); int count = itemStack.getCount();
@@ -398,6 +_,12 @@ @@ -399,6 +_,12 @@
return packet; return packet;
} }
@@ -150,7 +141,7 @@
InteractionResult resultHolder = itemStack.use(this.minecraft.level, player, hand); InteractionResult resultHolder = itemStack.use(this.minecraft.level, player, hand);
ItemStack result; ItemStack result;
if (resultHolder instanceof InteractionResult.Success success) { if (resultHolder instanceof InteractionResult.Success success) {
@@ -408,6 +_,9 @@ @@ -409,6 +_,9 @@
if (result != itemStack) { if (result != itemStack) {
player.setItemInHand(hand, result); player.setItemInHand(hand, result);
@@ -160,7 +151,7 @@
} }
interactionResult.setValue(resultHolder); interactionResult.setValue(resultHolder);
@@ -445,6 +_,10 @@ @@ -456,6 +_,10 @@
this.ensureHasSentCarriedItem(); this.ensureHasSentCarriedItem();
Vec3 location = hitResult.getLocation().subtract(entity.getX(), entity.getY(), entity.getZ()); Vec3 location = hitResult.getLocation().subtract(entity.getX(), entity.getY(), entity.getZ());
this.connection.send(new ServerboundInteractPacket(entity.getId(), hand, location, player.isShiftKeyDown())); this.connection.send(new ServerboundInteractPacket(entity.getId(), hand, location, player.isShiftKeyDown()));
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/multiplayer/chat/ChatListener.java --- a/net/minecraft/client/multiplayer/chat/ChatListener.java
+++ b/net/minecraft/client/multiplayer/chat/ChatListener.java +++ b/net/minecraft/client/multiplayer/chat/ChatListener.java
@@ -142,6 +_,8 @@ @@ -138,6 +_,8 @@
LocalPlayer receiver = this.minecraft.player; LocalPlayer receiver = this.minecraft.player;
if (receiver != null && receiver.chatAbilities().canReceivePlayerMessages()) { if (receiver != null && receiver.chatAbilities().canReceivePlayerMessages()) {
Component decoratedMessage = boundChatType.decorate(message); Component decoratedMessage = boundChatType.decorate(message);
@@ -9,7 +9,7 @@
this.minecraft.gui.hud.getChat().addPlayerMessage(decoratedMessage, null, GuiMessageTag.system()); this.minecraft.gui.hud.getChat().addPlayerMessage(decoratedMessage, null, GuiMessageTag.system());
this.narrateChatMessage(boundChatType, message); this.narrateChatMessage(boundChatType, message);
this.logSystemMessage(decoratedMessage, received); this.logSystemMessage(decoratedMessage, received);
@@ -177,12 +_,16 @@ @@ -173,12 +_,16 @@
MessageSignature signature = message.signature(); MessageSignature signature = message.signature();
FilterMask filterMask = message.filterMask(); FilterMask filterMask = message.filterMask();
if (filterMask.isEmpty()) { if (filterMask.isEmpty()) {
@@ -28,7 +28,7 @@
this.narrateChatMessage(boundChatType, filteredContent); this.narrateChatMessage(boundChatType, filteredContent);
} }
} }
@@ -216,12 +_,14 @@ @@ -212,12 +_,14 @@
chatLog.push(LoggedChatMessage.system(message, timeStamp)); chatLog.push(LoggedChatMessage.system(message, timeStamp));
} }
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/particle/FireworkParticles.java --- a/net/minecraft/client/particle/FireworkParticles.java
+++ b/net/minecraft/client/particle/FireworkParticles.java +++ b/net/minecraft/client/particle/FireworkParticles.java
@@ -256,6 +_,10 @@ @@ -259,6 +_,10 @@
colors = IntList.of(DyeColor.BLACK.getFireworkColor()); colors = IntList.of(DyeColor.BLACK.getFireworkColor());
} }
@@ -8,7 +8,7 @@
private @Nullable Runnable onReload; private @Nullable Runnable onReload;
public ParticleResources() { public ParticleResources() {
@@ -183,14 +_,17 @@ @@ -186,14 +_,17 @@
this.register(ParticleTypes.SULFUR_CUBE_GOO, BreakingItemParticle.SulfurCubeProvider::new); this.register(ParticleTypes.SULFUR_CUBE_GOO, BreakingItemParticle.SulfurCubeProvider::new);
} }
@@ -27,7 +27,7 @@
} }
@Override @Override
@@ -281,8 +_,13 @@ @@ -284,8 +_,13 @@
} }
} }
@@ -0,0 +1,23 @@
--- a/net/minecraft/client/player/FirstPersonHandsAndItems.java
+++ b/net/minecraft/client/player/FirstPersonHandsAndItems.java
@@ -45,8 +_,18 @@
this.offHandHeight = Mth.clamp(this.offHandHeight - 0.4F, 0.0F, 1.0F);
} else {
float attackAnim = player.getItemSwapScale(1.0F);
- float mainHandTargetHeight = this.mainHandItem != nextMainHand ? 0.0F : attackAnim * attackAnim * attackAnim;
- float offHandTargetHeight = this.offHandItem != nextOffHand ? 0.0F : 1.0F;
+
+ boolean requipM = net.minecraftforge.client.ForgeHooksClient.shouldCauseReequipAnimation(this.mainHandItem, nextMainHand, player.getInventory().getSelectedSlot());
+ boolean requipO = net.minecraftforge.client.ForgeHooksClient.shouldCauseReequipAnimation(this.offHandItem, nextOffHand, -1);
+
+ if (!requipM && this.mainHandItem != nextMainHand)
+ this.mainHandItem = nextMainHand;
+ if (!requipO && this.offHandItem != nextOffHand)
+ this.offHandItem = nextOffHand;
+
+ float mainHandTargetHeight = requipM ? 0.0F : attackAnim * attackAnim * attackAnim;
+ float offHandTargetHeight = requipO ? 0.0F : 1.0F;
+
this.mainHandHeight = this.mainHandHeight + Mth.clamp(mainHandTargetHeight - this.mainHandHeight, -0.4F, 0.4F);
this.offHandHeight = this.offHandHeight + Mth.clamp(offHandTargetHeight - this.offHandHeight, -0.4F, 0.4F);
}
@@ -1,14 +1,6 @@
--- a/net/minecraft/client/player/LocalPlayer.java --- a/net/minecraft/client/player/LocalPlayer.java
+++ b/net/minecraft/client/player/LocalPlayer.java +++ b/net/minecraft/client/player/LocalPlayer.java
@@ -318,6 +_,7 @@ @@ -560,7 +_,10 @@
ServerboundPlayerActionPacket.Action action = all
? ServerboundPlayerActionPacket.Action.DROP_ALL_ITEMS
: ServerboundPlayerActionPacket.Action.DROP_ITEM;
+ if (isUsingItem() && getUsedItemHand() == InteractionHand.MAIN_HAND && (all || getUseItem().getCount() == 1)) stopUsingItem(); // Forge: fix MC-231097 on the clientside
ItemStack prediction = this.getInventory().removeFromSelected(all);
this.connection.send(new ServerboundPlayerActionPacket(action, BlockPos.ZERO, Direction.DOWN));
return !prediction.isEmpty();
@@ -545,7 +_,10 @@
@Override @Override
public void playSound(final SoundEvent sound, final float volume, final float pitch) { public void playSound(final SoundEvent sound, final float volume, final float pitch) {
@@ -20,7 +12,7 @@
} }
@Override @Override
@@ -787,6 +_,7 @@ @@ -803,6 +_,7 @@
&& this.canPlayerFitWithinBlocksAndEntitiesWhen(Pose.CROUCHING) && this.canPlayerFitWithinBlocksAndEntitiesWhen(Pose.CROUCHING)
&& (this.isShiftKeyDown() || !this.isSleeping() && !this.canPlayerFitWithinBlocksAndEntitiesWhen(Pose.STANDING)); && (this.isShiftKeyDown() || !this.isSleeping() && !this.canPlayerFitWithinBlocksAndEntitiesWhen(Pose.STANDING));
this.input.tick(); this.input.tick();
@@ -28,7 +20,7 @@
this.minecraft.getTutorial().onInput(this.input); this.minecraft.getTutorial().onInput(this.input);
boolean wasAutoJump = false; boolean wasAutoJump = false;
if (this.autoJumpTime > 0) { if (this.autoJumpTime > 0) {
@@ -859,8 +_,9 @@ @@ -875,8 +_,9 @@
} }
this.wasFallFlying = this.isFallFlying(); this.wasFallFlying = this.isFallFlying();
@@ -40,7 +32,7 @@
} }
if (this.isEyeInFluid(FluidTags.WATER)) { if (this.isEyeInFluid(FluidTags.WATER)) {
@@ -928,7 +_,7 @@ @@ -944,7 +_,7 @@
} }
private boolean shouldStopSwimSprinting() { private boolean shouldStopSwimSprinting() {
@@ -49,7 +41,7 @@
} }
public Portal.Transition getActivePortalLocalTransition() { public Portal.Transition getActivePortalLocalTransition() {
@@ -973,6 +_,8 @@ @@ -1004,6 +_,8 @@
@Override @Override
public void rideTick() { public void rideTick() {
super.rideTick(); super.rideTick();
@@ -58,7 +50,7 @@
this.handsBusy = false; this.handsBusy = false;
if (this.getControlledVehicle() instanceof AbstractBoat boat) { if (this.getControlledVehicle() instanceof AbstractBoat boat) {
boat.setInput(this.input.keyPresses.left(), this.input.keyPresses.right(), this.input.keyPresses.forward(), this.input.keyPresses.backward()); boat.setInput(this.input.keyPresses.left(), this.input.keyPresses.right(), this.input.keyPresses.forward(), this.input.keyPresses.backward());
@@ -1147,7 +_,7 @@ @@ -1178,7 +_,7 @@
&& this.isSprintingPossible(this.getAbilities().flying) && this.isSprintingPossible(this.getAbilities().flying)
&& !this.isSlowDueToUsingItem() && !this.isSlowDueToUsingItem()
&& (!this.isFallFlying() || this.isUnderWater()) && (!this.isFallFlying() || this.isUnderWater())
@@ -67,7 +59,7 @@
} }
private boolean vehicleCanSprint(final Entity vehicle) { private boolean vehicleCanSprint(final Entity vehicle) {
@@ -1222,6 +_,17 @@ @@ -1253,6 +_,17 @@
@Override @Override
public float getVisualRotationYInDegrees() { public float getVisualRotationYInDegrees() {
return this.getYRot(); return this.getYRot();
@@ -0,0 +1,35 @@
--- a/net/minecraft/client/renderer/FirstPersonHandsAndItemsRenderer.java
+++ b/net/minecraft/client/renderer/FirstPersonHandsAndItemsRenderer.java
@@ -352,6 +_,7 @@
if (state.handRenderSelection.renderMainHand) {
float mainHandAttack = attackHand == InteractionHand.MAIN_HAND ? attackValue : 0.0F;
float mainhandInverseArmHeight = state.mainHandSwapScale * (1.0F - Mth.lerp(partialTicks, state.oldMainHandHeight, state.mainHandHeight));
+ if (!net.minecraftforge.client.ForgeHooksClient.renderSpecificFirstPersonHand(InteractionHand.MAIN_HAND, poseStack, submitNodeCollector, playerState.avatarRenderState.lightCoords, partialTicks, xRot, mainHandAttack, mainhandInverseArmHeight, state.mainHandItem))
this.submitArmWithItem(
playerState,
state,
@@ -370,6 +_,7 @@
if (state.handRenderSelection.renderOffHand) {
float offHandAttack = attackHand == InteractionHand.OFF_HAND ? attackValue : 0.0F;
float offhandInverseArmHeight = state.offHandSwapScale * (1.0F - Mth.lerp(partialTicks, state.oldOffHandHeight, state.offHandHeight));
+ if (!net.minecraftforge.client.ForgeHooksClient.renderSpecificFirstPersonHand(InteractionHand.OFF_HAND, poseStack, submitNodeCollector, playerState.avatarRenderState.lightCoords, partialTicks, xRot, offHandAttack, offhandInverseArmHeight, state.offHandItem))
this.submitArmWithItem(
playerState,
state,
@@ -418,7 +_,7 @@
} else {
this.renderOneHandedMap(poseStack, submitNodeCollector, lightCoords, inverseArmHeight, arm, attack, itemStack, playerState, state);
}
- } else if (itemStack.is(Items.CROSSBOW)) {
+ } else if (itemStack.getItem() instanceof CrossbowItem) {
this.applyItemArmTransform(poseStack, arm, inverseArmHeight);
boolean charged = CrossbowItem.isCharged(itemStack);
boolean isRightArm = arm == HumanoidArm.RIGHT;
@@ -457,6 +_,7 @@
} else {
boolean isRightArm = arm == HumanoidArm.RIGHT;
int invert = isRightArm ? 1 : -1;
+ if (!net.minecraftforge.client.extensions.common.IClientItemExtensions.of(itemStack).applyForgeHandTransform(poseStack, minecraft.player, arm, itemStack, partialTicks, inverseArmHeight, attack)) // FORGE: Allow items to define custom arm animation
if (avatarRenderState.isUsingItem && state.useItemRemainingTicks > 0 && avatarRenderState.useItemHand == hand) {
ItemUseAnimation useAnimation = itemStack.getUseAnimation();
if (!useAnimation.hasCustomArmTransform()) {
@@ -1,33 +1,41 @@
--- a/net/minecraft/client/renderer/GameRenderer.java --- a/net/minecraft/client/renderer/GameRenderer.java
+++ b/net/minecraft/client/renderer/GameRenderer.java +++ b/net/minecraft/client/renderer/GameRenderer.java
@@ -220,6 +_,9 @@ @@ -240,6 +_,9 @@
case null: case null:
default: default:
this.clearPostEffect(); this.clearSpectatedEntityPostEffect();
+ var rl = cameraEntity == null ? null : net.minecraftforge.client.EntitySpectatorShaderManager.get(cameraEntity.getType()); + var rl = cameraEntity == null ? null : net.minecraftforge.client.EntitySpectatorShaderManager.get(cameraEntity.getType());
+ if (rl != null) + if (rl != null)
+ this.setPostEffect(rl); + this.setSpectatedEntityPostEffect(rl);
} }
} }
@@ -515,6 +_,10 @@ @@ -430,6 +_,8 @@
Registry<Block> blockRegistry = this.minecraft.level.registryAccess().lookupOrThrow(Registries.BLOCK); ProfilerFiller profiler = Profiler.get();
profiler.push("camera");
this.mainCamera.update(deltaTracker);
+ var cameraSetup = net.minecraftforge.client.event.ForgeEventFactoryClient.fireComputeCameraAngles(this, this.mainCamera, deltaTracker.getGameTimeDeltaPartialTick(true));
+ this.mainCamera.setRotation(cameraSetup.getYaw(), cameraSetup.getPitch(), cameraSetup.getRoll());
profiler.pop();
this.requestedPostEffects.clear();
this.requestedPostEffects.add(END_OF_FRAME_POST_EFFECT);
@@ -628,6 +_,10 @@
BlockInWorld blockInWorld = new BlockInWorld(this.minecraft.level, pos, false);
renderOutline = !itemStack.isEmpty() renderOutline = !itemStack.isEmpty()
&& (itemStack.canBreakBlockInAdventureMode(blockInWorld) || itemStack.canPlaceOnBlockInAdventureMode(blockInWorld)); && (itemStack.canBreakBlockInAdventureMode(blockInWorld) || itemStack.canPlaceOnBlockInAdventureMode(blockInWorld));
+ if (!renderOutline && blockState.hasBlockEntity()) { + if (!renderOutline && blockInWorld.getState().hasBlockEntity()) {
+ var blockEntity = this.minecraft.level.getBlockEntity(pos); + var blockEntity = this.minecraft.level.getBlockEntity(pos);
+ renderOutline = blockEntity != null && blockEntity.hasCustomOutlineRendering(); + renderOutline = blockEntity != null && blockEntity.hasCustomOutlineRendering();
+ } + }
} }
} }
} }
@@ -538,6 +_,9 @@ @@ -780,6 +_,8 @@
if (optionsState.bobView) {
this.bobView(cameraState, bobStack); private void extractCamera(final DeltaTracker deltaTracker, final float worldPartialTicks) {
} CameraRenderState cameraState = this.gameRenderState.levelRenderState.cameraRenderState;
+
+ var cameraSetup = net.minecraftforge.client.event.ForgeEventFactoryClient.fireComputeCameraAngles(this, this.mainCamera, worldPartialTicks); + var cameraSetup = net.minecraftforge.client.event.ForgeEventFactoryClient.fireComputeCameraAngles(this, this.mainCamera, worldPartialTicks);
+ this.mainCamera.setRotation(cameraSetup.getYaw(), cameraSetup.getPitch(), cameraSetup.getRoll()); + this.mainCamera.setRotation(cameraSetup.getYaw(), cameraSetup.getPitch(), cameraSetup.getRoll());
this.mainCamera.extractRenderState(cameraState, deltaTracker);
projectionMatrix.mul(bobStack.last().pose()); cameraState.fogType = this.mainCamera.getFluidInCamera();
float screenEffectScale = optionsState.screenEffectScale; cameraState.fogData = this.fogRenderer
@@ -1,57 +0,0 @@
--- a/net/minecraft/client/renderer/ItemInHandRenderer.java
+++ b/net/minecraft/client/renderer/ItemInHandRenderer.java
@@ -362,6 +_,7 @@
float mainHandAttack = attackHand == InteractionHand.MAIN_HAND ? attackValue : 0.0F;
float mainhandInverseArmHeight = this.itemModelResolver.swapAnimationScale(this.mainHandItem)
* (1.0F - Mth.lerp(frameInterp, this.oMainHandHeight, this.mainHandHeight));
+ if (!net.minecraftforge.client.ForgeHooksClient.renderSpecificFirstPersonHand(InteractionHand.MAIN_HAND, poseStack, submitNodeCollector, lightCoords, frameInterp, xRot, mainHandAttack, mainhandInverseArmHeight, this.mainHandItem))
this.submitArmWithItem(
player,
frameInterp,
@@ -380,6 +_,8 @@
float offHandAttack = attackHand == InteractionHand.OFF_HAND ? attackValue : 0.0F;
float offhandInverseArmHeight = this.itemModelResolver.swapAnimationScale(this.offHandItem)
* (1.0F - Mth.lerp(frameInterp, this.oOffHandHeight, this.offHandHeight));
+
+ if (!net.minecraftforge.client.ForgeHooksClient.renderSpecificFirstPersonHand(InteractionHand.OFF_HAND, poseStack, submitNodeCollector, lightCoords, frameInterp, xRot, offHandAttack, offhandInverseArmHeight, this.offHandItem))
this.submitArmWithItem(
player,
frameInterp,
@@ -454,7 +_,7 @@
} else {
this.renderOneHandedMap(poseStack, submitNodeCollector, lightCoords, inverseArmHeight, arm, attack, itemStack);
}
- } else if (itemStack.is(Items.CROSSBOW)) {
+ } else if (itemStack.getItem() instanceof CrossbowItem) {
this.applyItemArmTransform(poseStack, arm, inverseArmHeight);
boolean charged = CrossbowItem.isCharged(itemStack);
boolean isRightArm = arm == HumanoidArm.RIGHT;
@@ -499,6 +_,7 @@
} else {
boolean isRightArm = arm == HumanoidArm.RIGHT;
int invert = isRightArm ? 1 : -1;
+ if (!net.minecraftforge.client.extensions.common.IClientItemExtensions.of(itemStack).applyForgeHandTransform(poseStack, minecraft.player, arm, itemStack, frameInterp, inverseArmHeight, attack)) // FORGE: Allow items to define custom arm animation
if (player.isUsingItem() && player.getUseItemRemainingTicks() > 0 && player.getUsedItemHand() == hand) {
ItemUseAnimation useAnimation = itemStack.getUseAnimation();
if (!useAnimation.hasCustomArmTransform()) {
@@ -647,8 +_,18 @@
this.offHandHeight = Mth.clamp(this.offHandHeight - 0.4F, 0.0F, 1.0F);
} else {
float attackAnim = player.getItemSwapScale(1.0F);
- float mainHandTargetHeight = this.mainHandItem != nextMainHand ? 0.0F : attackAnim * attackAnim * attackAnim;
- float offHandTargetHeight = this.offHandItem != nextOffHand ? 0.0F : 1.0F;
+
+ boolean requipM = net.minecraftforge.client.ForgeHooksClient.shouldCauseReequipAnimation(this.mainHandItem, nextMainHand, player.getInventory().getSelectedSlot());
+ boolean requipO = net.minecraftforge.client.ForgeHooksClient.shouldCauseReequipAnimation(this.offHandItem, nextOffHand, -1);
+
+ if (!requipM && this.mainHandItem != nextMainHand)
+ this.mainHandItem = nextMainHand;
+ if (!requipO && this.offHandItem != nextOffHand)
+ this.offHandItem = nextOffHand;
+
+ float mainHandTargetHeight = requipM ? 0.0F : attackAnim * attackAnim * attackAnim;
+ float offHandTargetHeight = requipO ? 0.0F : 1.0F;
+
this.mainHandHeight = this.mainHandHeight + Mth.clamp(mainHandTargetHeight - this.mainHandHeight, -0.4F, 0.4F);
this.offHandHeight = this.offHandHeight + Mth.clamp(offHandTargetHeight - this.offHandHeight, -0.4F, 0.4F);
}
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/renderer/LevelEventHandler.java --- a/net/minecraft/client/renderer/LevelEventHandler.java
+++ b/net/minecraft/client/renderer/LevelEventHandler.java +++ b/net/minecraft/client/renderer/LevelEventHandler.java
@@ -305,7 +_,7 @@ @@ -312,7 +_,7 @@
case 2001: case 2001:
BlockState blockState = Block.stateById(data); BlockState blockState = Block.stateById(data);
if (!blockState.isAir()) { if (!blockState.isAir()) {
@@ -1,16 +1,16 @@
--- a/net/minecraft/client/renderer/LevelRenderer.java --- a/net/minecraft/client/renderer/LevelRenderer.java
+++ b/net/minecraft/client/renderer/LevelRenderer.java +++ b/net/minecraft/client/renderer/LevelRenderer.java
@@ -235,6 +_,7 @@ @@ -279,6 +_,7 @@
}
} }
this.addAlwaysOnTopPass(frame, featureFrame, terrainFog); + net.minecraftforge.client.FramePassManager.insertForgePasses(frame, targets, this.levelRenderState); // Forge: Modded passes are inserted here.
+ net.minecraftforge.client.FramePassManager.insertForgePasses(frame, targets, this.levelRenderState, deltaTracker); // Forge: Modded passes are inserted here.
profiler.popPush("executeFrameGraph"); profiler.popPush("executeFrameGraph");
frame.execute(resourceAllocator, new FrameGraphBuilder.Inspector() { frame.execute(resourceAllocator, new FrameGraphBuilder.Inspector() {
@Override @Override
@@ -285,7 +_,8 @@ @@ -335,7 +_,8 @@
this.submitBlockDestroyAnimation(poseStack, submitNodeCollector, levelRenderState);
levelRenderState.blockBreakingRenderStates.clear(); levelRenderState.blockBreakingRenderStates.clear();
this.submitTransientBlocks(poseStack, submitNodeCollector, levelRenderState);
levelRenderState.particlesRenderState.submit(submitNodeCollector, levelRenderState.cameraRenderState); levelRenderState.particlesRenderState.submit(submitNodeCollector, levelRenderState.cameraRenderState);
- if (renderOutline) { - if (renderOutline) {
+ var hasCustomOutline = this.levelRenderState.blockOutlineRenderState != null && this.levelRenderState.blockOutlineRenderState.customRenderer() != null; + var hasCustomOutline = this.levelRenderState.blockOutlineRenderState != null && this.levelRenderState.blockOutlineRenderState.customRenderer() != null;
@@ -18,7 +18,7 @@
this.submitBlockOutline(poseStack, this.submitNodeStorage, levelRenderState); this.submitBlockOutline(poseStack, this.submitNodeStorage, levelRenderState);
} }
@@ -705,6 +_,10 @@ @@ -1075,6 +_,10 @@
private void submitBlockOutline(final PoseStack poseStack, final SubmitNodeCollector submitNodeCollector, final LevelRenderState levelRenderState) { private void submitBlockOutline(final PoseStack poseStack, final SubmitNodeCollector submitNodeCollector, final LevelRenderState levelRenderState) {
BlockOutlineRenderState state = levelRenderState.blockOutlineRenderState; BlockOutlineRenderState state = levelRenderState.blockOutlineRenderState;
if (state != null) { if (state != null) {
@@ -29,7 +29,7 @@
Vec3 cameraPos = levelRenderState.cameraRenderState.pos; Vec3 cameraPos = levelRenderState.cameraRenderState.pos;
BlockPos pos = state.pos(); BlockPos pos = state.pos();
poseStack.pushPose(); poseStack.pushPose();
@@ -979,6 +_,14 @@ @@ -1331,6 +_,14 @@
public SectionOcclusionGraph sectionOcclusionGraph() { public SectionOcclusionGraph sectionOcclusionGraph() {
return this.sectionOcclusionGraph; return this.sectionOcclusionGraph;
@@ -1,70 +1,43 @@
--- a/net/minecraft/client/renderer/ScreenEffectRenderer.java --- a/net/minecraft/client/renderer/ScreenEffectRenderer.java
+++ b/net/minecraft/client/renderer/ScreenEffectRenderer.java +++ b/net/minecraft/client/renderer/ScreenEffectRenderer.java
@@ -61,8 +_,9 @@ @@ -40,6 +_,9 @@
PoseStack poseStack = new PoseStack(); PoseStack poseStack = new PoseStack();
Player player = this.minecraft.player; AvatarRenderState avatarRenderState = playerRenderState.avatarRenderState;
if (isFirstPerson && !isSleeping) { if (!cameraRenderState.entityRenderState.isSleeping && playerRenderState.hasPlayer && avatarRenderState != null) {
- BlockState blockState = getViewBlockingState(player); + if (playerRenderState.customBlockOverlay != null)
- if (blockState != null) { + playerRenderState.customBlockOverlay.render(poseStack, submitNodeCollector);
+ var overlay = getOverlayBlock(player); + else
+ BlockState blockState = overlay == null ? null : overlay.getLeft(); if (playerRenderState.blockOverlay != null) {
+ if (blockState != null && net.minecraftforge.client.ForgeHooksClient.renderBlockOverlay(player, poseStack, net.minecraftforge.client.event.RenderBlockScreenEffectEvent.OverlayType.BLOCK, overlay.getLeft(), overlay.getRight())) { submitBlockSprite(
BlockStateModelSet blockStateModelSet = this.minecraft.getModelManager().getBlockStateModelSet(); playerRenderState.blockOverlay.atlasLocation(),
TextureAtlasSprite sprite = blockStateModelSet.getParticleMaterial(blockState).sprite(); @@ -54,10 +_,16 @@
submitBlockSprite(sprite, poseStack, submitNodeCollector, -15132391); }
@@ -70,11 +_,15 @@
if (!this.minecraft.player.isSpectator()) { if (cameraRenderState.isFirstPerson && !avatarRenderState.isSpectator) {
if (this.minecraft.player.isEyeInFluid(FluidTags.WATER)) { + if (playerRenderState.customFluidOverlay != null)
+ if (!net.minecraftforge.client.ForgeHooksClient.renderWaterOverlay(player, poseStack)) + playerRenderState.customFluidOverlay.render(poseStack, submitNodeCollector);
submitWater(this.minecraft, poseStack, submitNodeCollector); + else
+ } else if (!player.getEyeInFluidType().isAir()) { if (playerRenderState.waterOverlay != null) {
+ net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions.of(player.getEyeInFluidType()).renderOverlay(this.minecraft, poseStack, submitNodeCollector); submitWater(playerRenderState.waterOverlay, poseStack, submitNodeCollector);
} }
if (this.minecraft.player.isOnFire()) { + if (playerRenderState.customFireOverlay != null)
+ playerRenderState.customFireOverlay.render(poseStack, submitNodeCollector);
+ else
if (playerRenderState.isOnFire) {
TextureAtlasSprite fireSprite = this.sprites.get(ModelBakery.FIRE_1); TextureAtlasSprite fireSprite = this.sprites.get(ModelBakery.FIRE_1);
+ if (!net.minecraftforge.client.ForgeHooksClient.renderFireOverlay(player, poseStack))
submitFire(poseStack, submitNodeCollector, fireSprite); submitFire(poseStack, submitNodeCollector, fireSprite);
} @@ -116,9 +_,12 @@
}
@@ -128,6 +_,11 @@
return null;
}
+ var ret = getOverlayBlock(player);
+ return ret == null ? null : ret.getLeft();
+ }
+
+ private static org.apache.commons.lang3.tuple.@Nullable Pair<BlockState, BlockPos> getOverlayBlock(Player player) {
BlockPos.MutableBlockPos testPos = new BlockPos.MutableBlockPos();
for (int i = 0; i < 8; i++) {
@@ -138,7 +_,7 @@
);
BlockState blockState = player.level().getBlockState(testPos);
if (blockState.getRenderShape() != RenderShape.INVISIBLE && blockState.isViewBlocking(player.level(), testPos)) {
- return blockState;
+ return org.apache.commons.lang3.tuple.Pair.of(blockState, testPos.immutable());
}
}
@@ -156,13 +_,17 @@
} }
private static void submitWater(final Minecraft minecraft, final PoseStack poseStack, final SubmitNodeCollector submitNodeCollector) { private static void submitWater(final PlayerRenderState.WaterOverlay waterOverlay, final PoseStack poseStack, final SubmitNodeCollector submitNodeCollector) {
+ renderFluid(minecraft, poseStack, submitNodeCollector, UNDERWATER_LOCATION); + submitFluid(waterOverlay, poseStack, submitNodeCollector, UNDERWATER_LOCATION);
+ } + }
+ + public static void submitFluid(final PlayerRenderState.WaterOverlay waterOverlay, final PoseStack poseStack, final SubmitNodeCollector submitNodeCollector, Identifier texture) {
+ public static void renderFluid(Minecraft minecraft, PoseStack poseStack, SubmitNodeCollector submitNodeCollector, Identifier texture) { submitNodeCollector.submitCustomGeometry(
LocalPlayer player = minecraft.player; poseStack,
BlockPos pos = BlockPos.containing(player.getEyePosition()); - RenderTypes.blockScreenEffect(UNDERWATER_LOCATION),
float brightness = Lightmap.getBrightness(player.level().dimensionType(), player.level().getMaxLocalRawBrightness(pos)); + RenderTypes.blockScreenEffect(texture),
int color = ARGB.colorFromFloat(0.1F, brightness, brightness, brightness); (pose, builder) -> {
float u0 = -player.getYRot() / 64.0F; float uvSize = 4.0F;
float v0 = player.getXRot() / 64.0F; buildQuad(
- submitNodeCollector.submitCustomGeometry(poseStack, RenderTypes.blockScreenEffect(UNDERWATER_LOCATION), (pose, builder) -> {
+ submitNodeCollector.submitCustomGeometry(poseStack, RenderTypes.blockScreenEffect(texture), (pose, builder) -> {
float uvSize = 4.0F;
buildQuad(builder, pose.pose(), -1.0F, -1.0F, 1.0F, 1.0F, -0.5F, u0 + 4.0F, v0 + 4.0F, u0, v0, color);
});
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/renderer/Sheets.java --- a/net/minecraft/client/renderer/Sheets.java
+++ b/net/minecraft/client/renderer/Sheets.java +++ b/net/minecraft/client/renderer/Sheets.java
@@ -120,4 +_,13 @@ @@ -153,4 +_,13 @@
case COPPER_OXIDIZED -> (SpriteId)CHEST_COPPER.oxidized().select(type); case COPPER_OXIDIZED -> (SpriteId)CHEST_COPPER.oxidized().select(type);
}; };
} }
@@ -1,50 +0,0 @@
--- a/net/minecraft/client/renderer/SpriteCoordinateExpander.java
+++ b/net/minecraft/client/renderer/SpriteCoordinateExpander.java
@@ -17,12 +_,14 @@
@Override
public VertexConsumer addVertex(final float x, final float y, final float z) {
- return this.delegate.addVertex(x, y, z);
+ this.delegate.addVertex(x, y, z);
+ return this; // Forge: Fix MC-263524 not working with chained methods
}
@Override
public VertexConsumer setColor(final int r, final int g, final int b, final int a) {
- return this.delegate.setColor(r, g, b, a);
+ this.delegate.setColor(r, g, b, a);
+ return this; // Forge: Fix MC-263524 not working with chained methods
}
@Override
@@ -32,22 +_,26 @@
@Override
public VertexConsumer setUv(final float u, final float v) {
- return this.delegate.setUv(this.sprite.getU(u), this.sprite.getV(v));
+ this.delegate.setUv(this.sprite.getU(u), this.sprite.getV(v));
+ return this; // Forge: Fix MC-263524 not working with chained methods
}
@Override
public VertexConsumer setUv1(final int u, final int v) {
- return this.delegate.setUv1(u, v);
+ this.delegate.setUv1(u, v);
+ return this; // Forge: Fix MC-263524 not working with chained methods
}
@Override
public VertexConsumer setUv2(final int u, final int v) {
- return this.delegate.setUv2(u, v);
+ this.delegate.setUv2(u, v);
+ return this; // Forge: Fix MC-263524 not working with chained methods
}
@Override
public VertexConsumer setNormal(final float x, final float y, final float z) {
- return this.delegate.setNormal(x, y, z);
+ this.delegate.setNormal(x, y, z);
+ return this; // Forge: Fix MC-263524 not working with chained methods
}
@Override
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/renderer/culling/Frustum.java --- a/net/minecraft/client/renderer/culling/Frustum.java
+++ b/net/minecraft/client/renderer/culling/Frustum.java +++ b/net/minecraft/client/renderer/culling/Frustum.java
@@ -83,6 +_,8 @@ @@ -84,6 +_,8 @@
} }
public boolean isVisible(final AABB bb) { public boolean isVisible(final AABB bb) {
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/renderer/debug/EntityHitboxDebugRenderer.java --- a/net/minecraft/client/renderer/debug/EntityHitboxDebugRenderer.java
+++ b/net/minecraft/client/renderer/debug/EntityHitboxDebugRenderer.java +++ b/net/minecraft/client/renderer/debug/EntityHitboxDebugRenderer.java
@@ -99,8 +_,8 @@ @@ -102,8 +_,8 @@
); );
} }
@@ -1,7 +1,7 @@
--- a/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java --- a/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java
+++ b/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java +++ b/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java
@@ -207,6 +_,14 @@ @@ -201,6 +_,14 @@
return this.itemInHandRenderer; return this.camera.position().distanceToSqr(entity.position());
} }
+ public Map<PlayerModelType, AvatarRenderer<AbstractClientPlayer>> getPlayerRenderers() { + public Map<PlayerModelType, AvatarRenderer<AbstractClientPlayer>> getPlayerRenderers() {
@@ -15,7 +15,7 @@
@Override @Override
public void onResourceManagerReload(final ResourceManager resourceManager) { public void onResourceManagerReload(final ResourceManager resourceManager) {
EntityRendererProvider.Context context = new EntityRendererProvider.Context( EntityRendererProvider.Context context = new EntityRendererProvider.Context(
@@ -224,5 +_,6 @@ @@ -219,5 +_,6 @@
this.renderers = EntityRenderers.createEntityRenderers(context); this.renderers = EntityRenderers.createEntityRenderers(context);
this.playerRenderers = EntityRenderers.createAvatarRenderers(context); this.playerRenderers = EntityRenderers.createAvatarRenderers(context);
this.mannequinRenderers = EntityRenderers.createAvatarRenderers(context); this.mannequinRenderers = EntityRenderers.createAvatarRenderers(context);
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/renderer/entity/HumanoidMobRenderer.java --- a/net/minecraft/client/renderer/entity/HumanoidMobRenderer.java
+++ b/net/minecraft/client/renderer/entity/HumanoidMobRenderer.java +++ b/net/minecraft/client/renderer/entity/HumanoidMobRenderer.java
@@ -69,7 +_,7 @@ @@ -67,7 +_,7 @@
state.isCrouching = entity.isCrouching(); state.isCrouching = entity.isCrouching();
state.isFallFlying = entity.isFallFlying(); state.isFallFlying = entity.isFallFlying();
state.isVisuallySwimming = entity.isVisuallySwimming(); state.isVisuallySwimming = entity.isVisuallySwimming();
@@ -3,9 +3,9 @@
@@ -82,6 +_,7 @@ @@ -82,6 +_,7 @@
if (state.mapId != null) { if (state.mapId != null) {
int rotation = state.rotation % 4 * 2; int rotation = state.rotation % 4 * 2;
poseStack.mulPose(Axis.ZP.rotationDegrees(rotation * 360.0F / 8.0F)); poseStack.rotateDegrees(Axis.ZP, rotation * 360.0F / 8.0F);
+ if (!net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderItemInFrame(state, this, poseStack, submitNodeCollector, state.lightCoords)) { + if (!net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderItemInFrame(state, this, poseStack, submitNodeCollector, state.lightCoords)) {
poseStack.mulPose(Axis.ZP.rotationDegrees(180.0F)); poseStack.rotateDegrees(Axis.ZP, 180.0F);
float s = 0.0078125F; float s = 0.0078125F;
poseStack.scale(0.0078125F, 0.0078125F, 0.0078125F); poseStack.scale(0.0078125F, 0.0078125F, 0.0078125F);
@@ -89,6 +_,7 @@ @@ -89,6 +_,7 @@
@@ -14,5 +14,5 @@
this.mapRenderer.render(state.mapRenderState, poseStack, submitNodeCollector, true, lightCoords); this.mapRenderer.render(state.mapRenderState, poseStack, submitNodeCollector, true, lightCoords);
+ } + }
} else if (!state.item.isEmpty()) { } else if (!state.item.isEmpty()) {
poseStack.mulPose(Axis.ZP.rotationDegrees(state.rotation * 360.0F / 8.0F)); poseStack.rotateDegrees(Axis.ZP, state.rotation * 360.0F / 8.0F);
int lightVal = this.getLightCoords(state.isGlowFrame, 15728880, state.lightCoords); int lightVal = this.getLightCoords(state.isGlowFrame, 15728880, state.lightCoords);
@@ -8,7 +8,7 @@
poseStack.pushPose(); poseStack.pushPose();
if (state.hasPose(Pose.SLEEPING)) { if (state.hasPose(Pose.SLEEPING)) {
Direction bedOrientation = state.bedOrientation; Direction bedOrientation = state.bedOrientation;
@@ -110,6 +_,7 @@ @@ -108,6 +_,7 @@
poseStack.popPose(); poseStack.popPose();
super.submit(state, poseStack, submitNodeCollector, camera); super.submit(state, poseStack, submitNodeCollector, camera);
@@ -16,7 +16,7 @@
} }
protected boolean shouldRenderLayers(final S state) { protected boolean shouldRenderLayers(final S state) {
@@ -278,7 +_,7 @@ @@ -276,7 +_,7 @@
state.isFullyFrozen = entity.isFullyFrozen(); state.isFullyFrozen = entity.isFullyFrozen();
state.isBaby = entity.isBaby(); state.isBaby = entity.isBaby();
@@ -1,26 +1,24 @@
--- a/net/minecraft/client/renderer/entity/player/AvatarRenderer.java --- a/net/minecraft/client/renderer/entity/player/AvatarRenderer.java
+++ b/net/minecraft/client/renderer/entity/player/AvatarRenderer.java +++ b/net/minecraft/client/renderer/entity/player/AvatarRenderer.java
@@ -98,7 +_,7 @@ @@ -94,7 +_,7 @@
return HumanoidModel.ArmPose.EMPTY; return HumanoidModel.ArmPose.EMPTY;
} }
- if (!avatar.swinging && itemInHand.is(Items.CROSSBOW) && CrossbowItem.isCharged(itemInHand)) { - if (!avatar.isSwinging() && itemInHand.is(Items.CROSSBOW) && CrossbowItem.isCharged(itemInHand)) {
+ if (!avatar.swinging && itemInHand.getItem() instanceof CrossbowItem && CrossbowItem.isCharged(itemInHand)) { + if (!avatar.isSwinging() && itemInHand.getItem() instanceof CrossbowItem && CrossbowItem.isCharged(itemInHand)) {
return HumanoidModel.ArmPose.CROSSBOW_HOLD; return HumanoidModel.ArmPose.CROSSBOW_HOLD;
} }
@@ -141,7 +_,9 @@ @@ -135,7 +_,7 @@
if (attack != null && attack.type() == SwingAnimationType.STAB && avatar.swinging) {
return HumanoidModel.ArmPose.SPEAR; return HumanoidMobRenderer.usesSpearPose(itemInHand, hand.asArm(avatar.getMainArm()), avatar)
} else { ? HumanoidModel.ArmPose.SPEAR
- return itemInHand.is(ItemTags.SPEARS) ? HumanoidModel.ArmPose.SPEAR : HumanoidModel.ArmPose.ITEM; - : HumanoidModel.ArmPose.ITEM;
+ if (itemInHand.is(ItemTags.SPEARS)) return HumanoidModel.ArmPose.SPEAR; + : net.minecraftforge.client.extensions.common.IClientItemExtensions.of(itemInHand).getArmPose(avatar, hand, itemInHand);
+ var pose = net.minecraftforge.client.extensions.common.IClientItemExtensions.of(itemInHand).getArmPose(avatar, hand, itemInHand);
+ return pose == null ? HumanoidModel.ArmPose.ITEM : pose;
}
} }
@@ -241,12 +_,14 @@ public Identifier getTextureLocation(final AvatarRenderState state) {
@@ -234,12 +_,14 @@
public void renderRightHand( public void renderRightHand(
final PoseStack poseStack, final SubmitNodeCollector submitNodeCollector, final int lightCoords, final Identifier skinTexture, final boolean hasSleeve final PoseStack poseStack, final SubmitNodeCollector submitNodeCollector, final int lightCoords, final Identifier skinTexture, final boolean hasSleeve
) { ) {
@@ -35,7 +33,7 @@
this.renderHand(poseStack, submitNodeCollector, lightCoords, skinTexture, this.model.leftArm, hasSleeve); this.renderHand(poseStack, submitNodeCollector, lightCoords, skinTexture, this.model.leftArm, hasSleeve);
} }
@@ -304,5 +_,12 @@ @@ -297,5 +_,12 @@
public static boolean isPlayerUpsideDown(final Player player) { public static boolean isPlayerUpsideDown(final Player player) {
return isUpsideDownName(player.getGameProfile().name()); return isUpsideDownName(player.getGameProfile().name());
@@ -1,15 +1,15 @@
--- a/net/minecraft/client/renderer/extract/LevelExtractor.java --- a/net/minecraft/client/renderer/extract/LevelExtractor.java
+++ b/net/minecraft/client/renderer/extract/LevelExtractor.java +++ b/net/minecraft/client/renderer/extract/LevelExtractor.java
@@ -172,7 +_,7 @@ @@ -188,7 +_,7 @@
profiler.popPush("entities"); profiler.popPush("entities");
this.extractVisibleEntities(camera, cullFrustum, deltaTracker, this.levelRenderState); this.extractVisibleEntities(camera, cullFrustum, deltaTracker, this.levelRenderState);
profiler.popPush("blockEntities"); profiler.popPush("blockEntities");
- this.extractVisibleBlockEntities(camera, deltaPartialTick, this.levelRenderState); - this.extractVisibleBlockEntities(camera, worldPartialTicks, this.levelRenderState);
+ this.extractVisibleBlockEntities(camera, deltaPartialTick, this.levelRenderState, cullFrustum); + this.extractVisibleBlockEntities(camera, worldPartialTicks, this.levelRenderState, cullFrustum);
profiler.popPush("blockOutline"); profiler.popPush("blockOutline");
this.extractBlockOutline(camera, this.levelRenderState); this.extractBlockOutline(camera, this.levelRenderState);
profiler.popPush("blockBreaking"); profiler.popPush("blockBreaking");
@@ -264,7 +_,7 @@ @@ -311,7 +_,7 @@
return this.levelRenderer.entityRenderDispatcher().extractEntity(entity, partialTickTime); return this.levelRenderer.entityRenderDispatcher().extractEntity(entity, partialTickTime);
} }
@@ -18,15 +18,15 @@
Vec3 cameraPos = camera.position(); Vec3 cameraPos = camera.position();
double camX = cameraPos.x(); double camX = cameraPos.x();
double camY = cameraPos.y(); double camY = cameraPos.y();
@@ -275,6 +_,7 @@ @@ -323,6 +_,7 @@
List<BlockEntity> renderableBlockEntities = section.getSectionMesh().getRenderableBlockEntities(); List<BlockEntity> renderableBlockEntities = section.getSectionMesh().getRenderableBlockEntities();
if (!renderableBlockEntities.isEmpty() && !(section.getVisibility(Util.getMillis()) < 0.3F)) { if (!renderableBlockEntities.isEmpty() && !(section.getVisibility(Util.getMillis(), chunkFadeDuration) < 0.3F)) {
for (BlockEntity blockEntity : renderableBlockEntities) { for (BlockEntity blockEntity : renderableBlockEntities) {
+ if (!frustum.isVisible(blockEntity.getRenderBoundingBox())) continue; + if (!frustum.isVisible(blockEntity.getRenderBoundingBox())) continue;
BlockPos blockPos = blockEntity.getBlockPos(); BlockPos blockPos = blockEntity.getBlockPos();
SortedSet<BlockDestructionProgress> progresses = this.level.destructionProgress().get(blockPos.asLong()); SortedSet<BlockDestructionProgress> progresses = this.level.destructionProgress().get(blockPos.asLong());
ModelFeatureRenderer.CrumblingOverlay breakProgress; ModelFeatureRenderer.CrumblingOverlay breakProgress;
@@ -304,6 +_,7 @@ @@ -352,6 +_,7 @@
if (blockEntity.isRemoved()) { if (blockEntity.isRemoved()) {
iterator.remove(); iterator.remove();
} else { } else {
@@ -34,7 +34,7 @@
BlockEntityRenderState state = this.levelRenderer BlockEntityRenderState state = this.levelRenderer
.blockEntityRenderDispatcher() .blockEntityRenderDispatcher()
.tryExtractRenderState(blockEntity, deltaPartialTick, null, true); .tryExtractRenderState(blockEntity, deltaPartialTick, null, true);
@@ -327,7 +_,7 @@ @@ -375,7 +_,7 @@
SortedSet<BlockDestructionProgress> progresses = entry.getValue(); SortedSet<BlockDestructionProgress> progresses = entry.getValue();
if (progresses != null && !progresses.isEmpty()) { if (progresses != null && !progresses.isEmpty()) {
int progress = progresses.last().getProgress(); int progress = progresses.last().getProgress();
@@ -43,7 +43,7 @@
} }
} }
} }
@@ -335,6 +_,12 @@ @@ -383,6 +_,12 @@
private void extractBlockOutline(final Camera camera, final LevelRenderState levelRenderState) { private void extractBlockOutline(final Camera camera, final LevelRenderState levelRenderState) {
levelRenderState.blockOutlineRenderState = null; levelRenderState.blockOutlineRenderState = null;
@@ -56,3 +56,60 @@
if (this.minecraft.hitResult instanceof BlockHitResult blockHitResult) { if (this.minecraft.hitResult instanceof BlockHitResult blockHitResult) {
if (blockHitResult.getType() != HitResult.Type.MISS) { if (blockHitResult.getType() != HitResult.Type.MISS) {
BlockPos pos = blockHitResult.getBlockPos(); BlockPos pos = blockHitResult.getBlockPos();
@@ -444,24 +_,32 @@
}
if (!(camera.entity() instanceof LivingEntity livingEntity && livingEntity.isSleeping())) {
- BlockState viewBlockingState = getViewBlockingState(player, camera.getCullFrustum());
+ var overlay = getOverlayBlock(player, camera.getCullFrustum());
+ BlockState viewBlockingState = overlay == null ? null : overlay.state();
if (viewBlockingState != null) {
TextureAtlasSprite sprite = this.minecraft.getModelManager().getBlockStateModelSet().getParticleMaterial(viewBlockingState).sprite();
state.blockOverlay = new PlayerRenderState.BlockOverlay(
sprite.atlasLocation(), sprite.getU0(), sprite.getV0(), sprite.getU1(), sprite.getV1()
);
+ state.customBlockOverlay = net.minecraftforge.client.ForgeHooksClient.renderBlockOverlay(player, overlay.state(), overlay.pos());
}
if (this.minecraft.options.getCameraType().isFirstPerson()) {
state.isEyeInWater = player.isEyeInFluid(FluidTags.WATER);
state.isOnFire = player.isOnFire();
- if (state.isEyeInWater) {
+ if (state.isEyeInWater || !player.getEyeInFluidType().isAir()) {
BlockPos eyePos = BlockPos.containing(player.getEyePosition());
float brightness = Lightmap.getBrightness(player.level().dimensionType(), player.level().getMaxLocalRawBrightness(eyePos));
state.waterOverlay = new PlayerRenderState.WaterOverlay(
ARGB.colorFromFloat(0.1F, brightness, brightness, brightness), -player.getYRot() / 64.0F, player.getXRot() / 64.0F
);
+ if (state.isEyeInWater)
+ state.customFluidOverlay = net.minecraftforge.client.ForgeHooksClient.renderWaterOverlay(player, state);
+ else
+ state.customFluidOverlay = net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions.of(player.getEyeInFluidType()).renderOverlay(this.minecraft, state);
}
+ if (state.isOnFire)
+ state.customFireOverlay = net.minecraftforge.client.ForgeHooksClient.renderFireOverlay(player);
}
}
} else {
@@ -475,6 +_,12 @@
return null;
}
+ var ret = getOverlayBlock(player, frustum);
+ return ret == null ? null : ret.state();
+ }
+
+ private record OverlayInfo(BlockState state, BlockPos pos) {}
+ private static @Nullable OverlayInfo getOverlayBlock(final LocalPlayer player, final Frustum frustum) {
AABB nearPlaneBB = frustum.getNearPlaneBounds().move(player.getEyePosition());
BlockPos.MutableBlockPos testPos = new BlockPos.MutableBlockPos();
@@ -486,7 +_,7 @@
);
BlockState blockState = player.level().getBlockState(testPos);
if (blockState.getRenderShape() != RenderShape.INVISIBLE && blockState.isViewBlocking(player.level(), testPos, nearPlaneBB)) {
- return blockState;
+ return new OverlayInfo(blockState, testPos.immutable());
}
}
@@ -1,7 +1,7 @@
--- a/net/minecraft/client/renderer/fog/FogRenderer.java --- a/net/minecraft/client/renderer/fog/FogRenderer.java
+++ b/net/minecraft/client/renderer/fog/FogRenderer.java +++ b/net/minecraft/client/renderer/fog/FogRenderer.java
@@ -159,6 +_,12 @@ @@ -154,6 +_,12 @@
fogBlue = Mth.lerp(brightenFactor, fogBlue, fogBlue * scale); fogBlue = Mth.lerp(brightenFactor, fogBlue, fogBlue * targetScale);
} }
+ var fogColor = net.minecraftforge.client.ForgeHooksClient.getFogColor(camera, partialTicks, level, renderDistance, darkenWorldAmount, fogRed, fogGreen, fogBlue); + var fogColor = net.minecraftforge.client.ForgeHooksClient.getFogColor(camera, partialTicks, level, renderDistance, darkenWorldAmount, fogRed, fogGreen, fogBlue);
@@ -13,7 +13,7 @@
dest.set(fogRed, fogGreen, fogBlue, 1.0F); dest.set(fogRed, fogGreen, fogBlue, 1.0F);
} }
@@ -186,6 +_,7 @@ @@ -181,6 +_,7 @@
float renderDistanceFogSpan = Mth.clamp(renderDistanceInBlocks / 10.0F, 4.0F, 64.0F); float renderDistanceFogSpan = Mth.clamp(renderDistanceInBlocks / 10.0F, 4.0F, 64.0F);
fog.renderDistanceStart = renderDistanceInBlocks - renderDistanceFogSpan; fog.renderDistanceStart = renderDistanceInBlocks - renderDistanceFogSpan;
fog.renderDistanceEnd = renderDistanceInBlocks; fog.renderDistanceEnd = renderDistanceInBlocks;
@@ -1,15 +1,15 @@
--- a/net/minecraft/client/renderer/rendertype/RenderTypes.java --- a/net/minecraft/client/renderer/rendertype/RenderTypes.java
+++ b/net/minecraft/client/renderer/rendertype/RenderTypes.java +++ b/net/minecraft/client/renderer/rendertype/RenderTypes.java
@@ -574,7 +_,7 @@ @@ -674,7 +_,7 @@
} }
public static RenderType text(final Identifier texture) { public static RenderType eyes(final Identifier texture) {
- return TEXT.apply(texture); - return EYES.apply(texture);
+ return net.minecraftforge.client.ForgeRenderTypes.getText(texture); + return net.minecraftforge.client.ForgeRenderTypes.getText(texture);
} }
public static RenderType textBackground() { public static RenderType breezeEyes(final Identifier texture) {
@@ -582,19 +_,19 @@ @@ -737,23 +_,23 @@
} }
public static RenderType textGrayscale(final Identifier texture) { public static RenderType textGrayscale(final Identifier texture) {
@@ -32,10 +32,6 @@
+ return net.minecraftforge.client.ForgeRenderTypes.getTextSeeThrough(texture); + return net.minecraftforge.client.ForgeRenderTypes.getTextSeeThrough(texture);
} }
public static RenderType textBackgroundSeeThrough() {
@@ -602,7 +_,7 @@
}
public static RenderType textGrayscaleSeeThrough(final Identifier texture) { public static RenderType textGrayscaleSeeThrough(final Identifier texture) {
- return TEXT_GRAYSCALE_SEE_THROUGH.apply(texture); - return TEXT_GRAYSCALE_SEE_THROUGH.apply(texture);
+ return net.minecraftforge.client.ForgeRenderTypes.getTextGrayscaleSeeThrough(texture); + return net.minecraftforge.client.ForgeRenderTypes.getTextGrayscaleSeeThrough(texture);
@@ -0,0 +1,22 @@
--- a/net/minecraft/client/renderer/state/level/PlayerRenderState.java
+++ b/net/minecraft/client/renderer/state/level/PlayerRenderState.java
@@ -24,12 +_,19 @@
public PlayerRenderState.@Nullable WaterOverlay waterOverlay;
public PlayerRenderState.@Nullable ItemActivationRenderState itemActivation;
+ public net.minecraftforge.client.@Nullable IRenderCallback customBlockOverlay;
+ public net.minecraftforge.client.@Nullable IRenderCallback customFluidOverlay;
+ public net.minecraftforge.client.@Nullable IRenderCallback customFireOverlay;
+
public void reset() {
this.hasPlayer = false;
this.avatarRenderState = null;
this.blockOverlay = null;
this.waterOverlay = null;
this.itemActivation = null;
+ this.customBlockOverlay = null;
+ this.customFluidOverlay = null;
+ this.customFireOverlay = null;
}
@OnlyIn(Dist.CLIENT)
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/renderer/texture/TextureAtlasSprite.java --- a/net/minecraft/client/renderer/texture/TextureAtlasSprite.java
+++ b/net/minecraft/client/renderer/texture/TextureAtlasSprite.java +++ b/net/minecraft/client/renderer/texture/TextureAtlasSprite.java
@@ -26,7 +_,7 @@ @@ -24,7 +_,7 @@
private final float v1; private final float v1;
private final int padding; private final int padding;
@@ -9,7 +9,7 @@
final Identifier atlasLocation, final SpriteContents contents, final int atlasWidth, final int atlasHeight, final int x, final int y, final int padding final Identifier atlasLocation, final SpriteContents contents, final int atlasWidth, final int atlasHeight, final int x, final int y, final int padding
) { ) {
this.atlasLocation = atlasLocation; this.atlasLocation = atlasLocation;
@@ -127,5 +_,14 @@ @@ -123,5 +_,14 @@
@Override @Override
public void close() { public void close() {
this.contents.close(); this.contents.close();
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/resources/language/ClientLanguage.java --- a/net/minecraft/client/resources/language/ClientLanguage.java
+++ b/net/minecraft/client/resources/language/ClientLanguage.java +++ b/net/minecraft/client/resources/language/ClientLanguage.java
@@ -78,4 +_,9 @@ @@ -83,4 +_,9 @@
public FormattedCharSequence getVisualOrder(final FormattedText logicalOrderText) { public FormattedCharSequence getVisualOrder(final FormattedText logicalOrderText) {
return FormattedBidiReorder.reorder(logicalOrderText, this.defaultRightToLeft); return FormattedBidiReorder.reorder(logicalOrderText, this.defaultRightToLeft);
} }
@@ -1,17 +1,17 @@
--- a/net/minecraft/client/resources/language/LanguageManager.java --- a/net/minecraft/client/resources/language/LanguageManager.java
+++ b/net/minecraft/client/resources/language/LanguageManager.java +++ b/net/minecraft/client/resources/language/LanguageManager.java
@@ -29,8 +_,8 @@ @@ -34,8 +_,8 @@
private final Consumer<ClientLanguage> reloadCallback;
public LanguageManager(final String languageCode, final Consumer<ClientLanguage> reloadCallback) { public LanguageManager(final Minecraft minecraft, final String languageCode, final Consumer<ClientLanguage> reloadCallback) {
this.minecraft = minecraft;
- this.currentCode = languageCode; - this.currentCode = languageCode;
this.reloadCallback = reloadCallback; this.reloadCallback = reloadCallback;
+ setSelected(languageCode); + setSelected(languageCode);
} }
private static Map<String, LanguageInfo> extractLanguages(final Stream<PackResources> resourcePacks) { private static Map<String, LanguageInfo> extractLanguages(final Stream<PackResources> resourcePacks) {
@@ -67,8 +_,12 @@ @@ -86,8 +_,12 @@
this.reloadCallback.accept(locale); }
} }
+ private java.util.Locale javaLocale; // Forge: add locale information for modders + private java.util.Locale javaLocale; // Forge: add locale information for modders
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/resources/model/ModelManager.java --- a/net/minecraft/client/resources/model/ModelManager.java
+++ b/net/minecraft/client/resources/model/ModelManager.java +++ b/net/minecraft/client/resources/model/ModelManager.java
@@ -61,6 +_,7 @@ @@ -60,6 +_,7 @@
private static final Logger LOGGER = LogUtils.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
private static final FileToIdConverter MODEL_LISTER = FileToIdConverter.json("models"); private static final FileToIdConverter MODEL_LISTER = FileToIdConverter.json("models");
private Map<Identifier, ItemModel> bakedItemStackModels = Map.of(); private Map<Identifier, ItemModel> bakedItemStackModels = Map.of();
@@ -8,7 +8,7 @@
private Map<Identifier, ClientItem.Properties> itemProperties = Map.of(); private Map<Identifier, ClientItem.Properties> itemProperties = Map.of();
private final AtlasManager atlasManager; private final AtlasManager atlasManager;
private final PlayerSkinRenderCache playerSkinRenderCache; private final PlayerSkinRenderCache playerSkinRenderCache;
@@ -71,6 +_,7 @@ @@ -70,6 +_,7 @@
private @Nullable BlockModelSet blockModelSet; private @Nullable BlockModelSet blockModelSet;
private @Nullable FluidStateModelSet fluidStateModelSet; private @Nullable FluidStateModelSet fluidStateModelSet;
private Object2IntMap<BlockState> modelGroups = Object2IntMaps.emptyMap(); private Object2IntMap<BlockState> modelGroups = Object2IntMaps.emptyMap();
@@ -16,7 +16,7 @@
public ModelManager(final BlockColors blockColors, final AtlasManager atlasManager, final PlayerSkinRenderCache playerSkinRenderCache) { public ModelManager(final BlockColors blockColors, final AtlasManager atlasManager, final PlayerSkinRenderCache playerSkinRenderCache) {
this.blockColors = blockColors; this.blockColors = blockColors;
@@ -82,6 +_,18 @@ @@ -81,6 +_,18 @@
return this.bakedItemStackModels.getOrDefault(id, this.missingModels.item()); return this.bakedItemStackModels.getOrDefault(id, this.missingModels.item());
} }
@@ -35,7 +35,7 @@
public ClientItem.Properties getItemProperties(final Identifier id) { public ClientItem.Properties getItemProperties(final Identifier id) {
return this.itemProperties.getOrDefault(id, ClientItem.Properties.DEFAULT); return this.itemProperties.getOrDefault(id, ClientItem.Properties.DEFAULT);
} }
@@ -105,6 +_,7 @@ @@ -104,6 +_,7 @@
final PreparableReloadListener.PreparationBarrier preparationBarrier, final PreparableReloadListener.PreparationBarrier preparationBarrier,
final Executor reloadExecutor final Executor reloadExecutor
) { ) {
@@ -43,13 +43,13 @@
ResourceManager manager = currentReload.resourceManager(); ResourceManager manager = currentReload.resourceManager();
CompletableFuture<EntityModelSet> entityModelSet = CompletableFuture.supplyAsync(EntityModelSet::vanilla, taskExecutor); CompletableFuture<EntityModelSet> entityModelSet = CompletableFuture.supplyAsync(EntityModelSet::vanilla, taskExecutor);
CompletableFuture<Map<Identifier, UnbakedModel>> modelCache = loadBlockModels(manager, taskExecutor); CompletableFuture<Map<Identifier, UnbakedModel>> modelCache = loadBlockModels(manager, taskExecutor);
@@ -224,12 +_,14 @@ @@ -221,12 +_,14 @@
bakedModelsFuture,
(bakingResult, bakedModels) -> { (bakingResult, bakedModels) -> {
blockItemMaterialBaker.logMissingTextures(); Map<Fluid, FluidModel> fluidModels = FluidStateModelSet.bake(materialBaker);
Map<Fluid, FluidModel> fluidModels = FluidStateModelSet.bake(blockOnlyMaterialBaker); + fluidModels = net.minecraftforge.client.ForgeHooksClient.onFluidModelBake(bakery, materialBaker, fluidModels);
+ fluidModels = net.minecraftforge.client.ForgeHooksClient.onFluidModelBake(bakery, blockOnlyMaterialBaker, fluidModels);
+ net.minecraftforge.client.ForgeHooksClient.onModifyBakingResult(bakery, bakingResult); + net.minecraftforge.client.ForgeHooksClient.onModifyBakingResult(bakery, bakingResult);
blockOnlyMaterialBaker.logMissingTextures(); materialBaker.logMissingTextures();
Map<BlockState, BlockStateModel> modelByStateCache = createBlockStateToModelDispatch( Map<BlockState, BlockStateModel> modelByStateCache = createBlockStateToModelDispatch(
bakingResult.blockStateModels(), bakingResult.missingModels().block() bakingResult.blockStateModels(), bakingResult.missingModels().block()
); );
@@ -59,7 +59,7 @@
); );
} }
); );
@@ -261,10 +_,15 @@ @@ -258,10 +_,15 @@
private void apply(final ModelManager.ReloadState preparations) { private void apply(final ModelManager.ReloadState preparations) {
ModelBakery.BakingResult bakedModels = preparations.bakedModels; ModelBakery.BakingResult bakedModels = preparations.bakedModels;
@@ -75,7 +75,7 @@
this.blockStateModelSet = new BlockStateModelSet(preparations.blockStateModels, this.missingModels.block()); this.blockStateModelSet = new BlockStateModelSet(preparations.blockStateModels, this.missingModels.block());
this.blockModelSet = new BlockModelSet(this.blockStateModelSet, preparations.blockModels, this.blockColors); this.blockModelSet = new BlockModelSet(this.blockStateModelSet, preparations.blockModels, this.blockColors);
this.fluidStateModelSet = new FluidStateModelSet(preparations.fluidModels, this.missingModels.fluid()); this.fluidStateModelSet = new FluidStateModelSet(preparations.fluidModels, this.missingModels.fluid());
@@ -333,7 +_,8 @@ @@ -297,7 +_,8 @@
Map<BlockState, BlockStateModel> blockStateModels, Map<BlockState, BlockStateModel> blockStateModels,
Map<BlockState, BlockModel> blockModels, Map<BlockState, BlockModel> blockModels,
Map<Fluid, FluidModel> fluidModels, Map<Fluid, FluidModel> fluidModels,
@@ -29,9 +29,9 @@
- Material.Baked material = modelBaker.materials().resolveSlot(textures, face.texture(), name); - Material.Baked material = modelBaker.materials().resolveSlot(textures, face.texture(), name);
+ Material.Baked material = materialMapper.apply(face.texture()); + Material.Baked material = materialMapper.apply(face.texture());
BakedQuad quad = FaceBakery.bakeQuad( BakedQuad quad = FaceBakery.bakeQuad(
modelBaker, from, to, face, material, facing, modelState, element.rotation(), element.shade(), element.lightEmission() modelBaker,
); from,
@@ -76,7 +_,5 @@ @@ -85,7 +_,5 @@
} }
} }
} }
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/resources/sounds/SoundInstance.java --- a/net/minecraft/client/resources/sounds/SoundInstance.java
+++ b/net/minecraft/client/resources/sounds/SoundInstance.java +++ b/net/minecraft/client/resources/sounds/SoundInstance.java
@@ -54,4 +_,8 @@ @@ -56,4 +_,8 @@
NONE, NONE,
LINEAR; LINEAR;
} }
@@ -15,7 +15,7 @@
} }
@Override @Override
@@ -371,6 +_,7 @@ @@ -397,6 +_,7 @@
@Override @Override
public void halt(final boolean wait) { public void halt(final boolean wait) {
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/sounds/SoundEngine.java --- a/net/minecraft/client/sounds/SoundEngine.java
+++ b/net/minecraft/client/sounds/SoundEngine.java +++ b/net/minecraft/client/sounds/SoundEngine.java
@@ -82,6 +_,7 @@ @@ -83,6 +_,7 @@
this.options = options; this.options = options;
this.soundBuffers = new SoundBufferLibrary(resourceProvider); this.soundBuffers = new SoundBufferLibrary(resourceProvider);
this.lastSeenDevices = this.deviceTracker.currentDevices(); this.lastSeenDevices = this.deviceTracker.currentDevices();
@@ -8,7 +8,7 @@
} }
public void reload() { public void reload() {
@@ -99,6 +_,7 @@ @@ -100,6 +_,7 @@
this.destroy(); this.destroy();
this.loadLibrary(); this.loadLibrary();
@@ -16,28 +16,30 @@
} }
private synchronized void loadLibrary() { private synchronized void loadLibrary() {
@@ -340,7 +_,7 @@ @@ -363,15 +_,18 @@
} }
} }
- public SoundEngine.PlayResult play(final SoundInstance instance) { - public SoundEngine.PlayResult play(final SoundInstance instance) {
+ public SoundEngine.PlayResult play(SoundInstance instance) { + public SoundEngine.PlayResult play(final SoundInstance instanceArg) {
if (!this.loaded) { if (!this.loaded) {
return SoundEngine.PlayResult.NOT_STARTED; return SoundEngine.PlayResult.NOT_STARTED;
} }
@@ -349,6 +_,9 @@
- if (!instance.canPlaySound()) {
+ if (!instanceArg.canPlaySound()) {
return SoundEngine.PlayResult.NOT_STARTED; return SoundEngine.PlayResult.NOT_STARTED;
} }
+ instance = net.minecraftforge.client.ForgeHooksClient.playSound(this, instance); + final var instance = net.minecraftforge.client.ForgeHooksClient.playSound(this, instanceArg);
+ if (instance == null || !instance.canPlaySound()) + if (instance == null || !instance.canPlaySound())
+ return SoundEngine.PlayResult.NOT_STARTED; + return SoundEngine.PlayResult.NOT_STARTED;
WeighedSoundEvents soundEvent = instance.resolve(this.soundManager); WeighedSoundEvents soundEvent = instance.getOrResolve(this.soundManager);
Identifier eventLocation = instance.getIdentifier(); Identifier eventLocation = instance.getIdentifier();
if (soundEvent == null) { if (soundEvent == null) {
@@ -430,15 +_,18 @@ @@ -447,15 +_,18 @@
channel.setSelfPosition(position); channel.setSelfPosition(position);
channel.setRelative(isRelative); channel.setRelative(instance.isRelative());
}); });
+ SoundInstance soundinstance = instance; + SoundInstance soundinstance = instance;
if (!isStreaming) { if (!isStreaming) {
Loaded 100 of 616 files, more files were not shown because too many files have changed in this diff. Show more