Compare commits

..
32 Commits
Author SHA1 Message Date
LexManosandPaint_Ninja b0ccf1a480 Minecraft 1.21.9 update.
There a lot of performance improvements related to events.
  No more InheritableEvent for abstract events that you shouldn't add listeners to anyway, like EntityEvent. Use their sub-events.
  Made a lot more events records and interfaces. Mostly just a binary break, but has better performance.
  Mod bus posting methods are now static, no more ModLoader.get() for those.

ObjectHolder was removed, use RegistryObject.
Changed RuntimeEnumExtender to only target Minecraft classes. If you want other modders to interact with your API, use an Interface instead of Enum.
Moved some abstract event methods to only the relevant sub-events now, e.g. can no longer check the side of a ClientTickEvent, because it'll always be client

Rendering has changed a lot, they now batch most things together so that the game will render faster.
RenderHighlightEvent changed a lot

See https://github.com/MinecraftForge/MinecraftForge-Experimental/tree/1.21.9-dev for unsquashed commits.

Co-authored-by: Paint_Ninja <[email protected]>
2025-10-01 13:05:12 -07:00
LexManos c1d703e395 Fix Crafters not inserting into IItemHandlers. Closes #10667 2025-09-23 13:42:29 -07:00
LexManos 728fd6ff24 Optimize ConcatenatedListView's Iterator and fix hidden CreativeTabs taking up page space. 2025-09-23 13:37:53 -07:00
Paint_Ninja 0a885a77e7 [1.21.8] Deprecate global IExtensibleEnum support (#10662)
This is intended for use with Minecraft classes only. Mod devs can support extending enums through other, more efficient means, such as converting their enum to a record and having static final fields of instances that correspond to each enum value.
2025-09-18 17:13:58 +01:00
Matt 15dbadaae6 Fix alpha channel of creative mode tab title color (#10661) 2025-09-18 08:56:02 -07:00
Jonathing 4c1c3aafdb Deprecate JS CoreMods, remove Forge's usages of them (#10659) 2025-09-16 20:13:30 +01:00
Joseph T. McQuigg f06727a205 Replace Blocks.FARMLAND checks with instanceof FarmBlock (#10647)
Signed-off-by: Joseph T. McQuigg <[email protected]>
2025-09-10 20:17:42 -07:00
LexManos ef0e7bc17f 1.21.8 RB 1 2025-08-27 12:17:25 -07:00
Matt ec7a098f81 Add event for adding framepasses (#10612) 2025-08-23 22:09:12 -07:00
Matt ff25961a05 Add ForgeLayeredDraw & AddGuiOverlayLayersEvent as API for gui overlay management. (#10579) (#10611) 2025-08-21 12:56:12 -07:00
LexManos c999a2d4eb Fix Inactivated activator rails, acting like inactivated powered rails. Closes #10643 2025-08-21 08:50:35 -07:00
LexManos ce79df9716 Fix Redstone power propagating between powered and activator rails. Fixed #10642 2025-08-20 12:20:11 -07:00
LexManos eae9b9145d Optimize VillagerTradingManager, avoid redundant work. Closes #10577 2025-08-12 18:02:33 -07:00
Paint_Ninja 7f56986027 Minor cleanup to FML, fix double parsing of mods.toml (#10597) 2025-08-04 12:50:39 -07:00
Jonathing c6874bce67 Update GradleUtils to 2.6.4 (#10600) 2025-08-02 21:21:24 -07:00
Paint_Ninja aa11175f41 Sync deps with MC (#10596) 2025-08-02 05:27:19 -07:00
Joseph T. McQuigg 2730559ff3 Allow command suggestions/autocomplete to search all modded paths at once without namespace provided (#10593) 2025-07-31 09:13:35 -07:00
Paint_Ninja e80c3402b7 Optimise WorldWorkerManager (#10578) 2025-07-23 18:37:02 +01:00
LexManos 837c259668 1.21.8 - Intel Graphic Fixes 2025-07-17 11:09:42 -07:00
LexManos 2e48910b4c Fix crash when clicking links in modlist without being in-world. 2025-07-16 10:21:55 -07:00
LexManos 70dd556db6 Use vanilla's entrypoint for GameTest servers 2025-07-01 23:56:59 -07:00
LexManos e44a558f37 Fix Forge error screen not rendering text correctly. Closes #10569 2025-07-01 23:41:08 -07:00
LexManos 1e154cbe3e Minecraft 1.21.7 - Lava Chickens! 2025-06-30 11:06:39 -07:00
Paint_NinjaandLexManos d5c5df1b64 Bump ASM and EventBus
Improves support for Java 25 and better stability of the compile-time EventBus checks, respectively.

Co-Authored-By: LexManos <[email protected]>
2025-06-25 20:54:00 +01:00
Joseph T. McQuigg 5e75de5eb7 Add WanderTradesEvent#Pool Constructor with List<ItemListing> and int directly (#10566) 2025-06-23 17:06:32 -07:00
Mysticdrew ddb1e52e99 Fix client commands not working when using clickable commands. 2025-06-20 14:39:16 -07:00
Mysticdrew 9e55363e2c Add Event for Picture in Picture renderers registration. 2025-06-20 14:21:27 -07:00
Paint_Ninja 219abfed22 Make more events records 2025-06-20 18:22:53 +01:00
Paint_Ninja 6915753b5a Fix posting cancellable child events with non-cancellable inheritable parents
Also made more events SelfDestructing to save a tad more memory
2025-06-20 10:16:26 +01:00
LexManos 1527738ddc Fix wrong order in filter vanilla commands patch. Fixes #10563 2025-06-19 00:49:08 -07:00
LexManos 18c806f1d0 Fix not being able to break blocks in survival. Closes #10561 2025-06-18 12:28:19 -07:00
Paint_Ninja 47f7c68ed5 Fix bug with strict bulk registration
See EventBus#89 for more details
2025-06-18 18:10:33 +01:00
570 changed files with 6922 additions and 7523 deletions

No files matched your search

+2 -3
View File
@@ -4,7 +4,7 @@ import net.minecraftforge.gradleutils.PomUtils
plugins {
id 'net.minecraftforge.licenser' version '1.0.1'
id 'com.github.ben-manes.versions' version '0.46.0'
id 'net.minecraftforge.gradleutils' version '[2.3.0,2.4.0)'
id 'net.minecraftforge.gradleutils' version '[2.6.4,2.7)'
id 'eclipse'
id 'de.undercouch.download' version '5.4.0'
id 'net.minecraftforge.gradle.patcher' version '[6.0.22,6.2)' apply false
@@ -16,8 +16,7 @@ plugins {
Util.init() //Init all our extension methods!
ext {
GIT_INFO = gradleutils.gitInfo
VERSION = gradleutils.getFilteredMCTagOffsetBranchVersion(true, '[0-9]', MC_VERSION)
VERSION = gitversion.getMCTagOffsetBranch(MC_VERSION)
FORGE_VERSION = VERSION.substring(MC_VERSION.length() + 1)
}
+2 -2
View File
@@ -4,8 +4,8 @@ repositories {
}
dependencies {
implementation 'org.ow2.asm:asm:9.7'
implementation 'org.ow2.asm:asm-tree:9.7'
implementation 'org.ow2.asm:asm:9.8'
implementation 'org.ow2.asm:asm-tree:9.8'
implementation 'net.minecraftforge:srgutils:0.5.10'
implementation 'commons-io:commons-io:2.13.0'
implementation 'com.google.code.gson:gson:2.10.1'
+6 -5
View File
@@ -71,7 +71,7 @@ sourceSets {
}
}
final String SPEC_VERSION = gradleutils.gitInfo.tag
final String SPEC_VERSION = gitversion.info.tag
// The new versioning sceme is <MCVersion>-<ForgeMC>.<RB>.<CommitsSinceRB>
// ForgeMC is a unique identifier for every MC version we have supported.
@@ -142,13 +142,14 @@ dependencies {
installer(project(':javafmllanguage'))
installer(project(':lowcodelanguage'))
installer(project(':mclanguage'))
installer(project(':forge-transformers'))
installerextra("${MCP_ARTIFACT.group}:${MCP_ARTIFACT.name}:${MCP_ARTIFACT.version}:srg2off")
runtimeOnly(libs.bootstrap)
runtimeOnly(libs.bootstrap.dev)
//annotationProcessor(libs.eventbus.validator)
annotationProcessor(libs.eventbus.validator)
}
tasks.named('extractRangeMap').configure {
@@ -168,7 +169,7 @@ patcher {
runs {
forge_client {
property 'eventbus.checkTypesOnDispatch', 'true'
property 'eventbus.api.strictRuntimeChecks', 'true'
property 'org.lwjgl.system.SharedLibraryExtractDirectory', 'lwjgl_dll'
args '--launchTarget', 'forge_dev_client',
@@ -414,7 +415,7 @@ tasks.register('extractInheritance', ExtractInheritance) {
}
tasks.register("findFinalizeSpawnTargets", BytecodePredicateFinder) {
jar = createClientOfficial.output
output = rootProject.file('src/main/resources/coremods/finalize_spawn_targets.json')
output = rootProject.file('forge-transformers/src/main/resources/coremods/finalize_spawn_targets.json')
predicate = {
parent, node, insn ->
return 'net/minecraft/world/level/BaseSpawner' != parent.name // Ignore this class as we special case it.
@@ -997,7 +998,7 @@ if (project.hasProperty('UPDATE_MAPPINGS')) {
tasks.named('javadoc', Javadoc).configure {
description 'Generates the combined javadocs for the FML projects and the main Forge project'
var includedProjects = [ ':fmlcore', ':fmlloader', ':javafmllanguage', ':mclanguage' ]
var includedProjects = [ ':fmlcore', ':fmlloader', ':javafmllanguage', ':mclanguage', ':forge-transformers' ]
source includedProjects.collect { project(it).sourceSets.main.allJava }
classpath = classpath + files(includedProjects.collect { project(it).sourceSets.main.compileClasspath })
+2 -2
View File
@@ -2,8 +2,8 @@
MinecraftForge
=============
[![Stable Release](https://img.shields.io/badge/dynamic/json?url=https://files.minecraftforge.net/net/minecraftforge/forge/promotions_slim.json&label=Stable&prefix=1.21.4-&query=$.promos["1.21.4-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=1.21.5-&query=$.promos["1.21.5-latest"]&color=blue&logo=data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyBjbGFzcz0ic3ZnLWlubGluZS0tZmEgZmEtYnVnIGZhLXctMTYiIGFyaWEtaGlkZGVuPSJ0cnVlIiBkYXRhLWljb249ImJ1ZyIgZGF0YS1wcmVmaXg9ImZhcyIgZm9jdXNhYmxlPSJmYWxzZSIgcm9sZT0iaW1nIiB2aWV3Qm94PSIwIDAgNTEyIDUxMiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTUxMS45ODggMjg4LjljLS40NzggMTcuNDMtMTUuMjE3IDMxLjEtMzIuNjUzIDMxLjFINDI0djE2YzAgMjEuODY0LTQuODgyIDQyLjU4NC0xMy42IDYxLjE0NWw2MC4yMjggNjAuMjI4YzEyLjQ5NiAxMi40OTcgMTIuNDk2IDMyLjc1OCAwIDQ1LjI1NS0xMi40OTggMTIuNDk3LTMyLjc1OSAxMi40OTYtNDUuMjU2IDBsLTU0LjczNi01NC43MzZDMzQ1Ljg4NiA0NjcuOTY1IDMxNC4zNTEgNDgwIDI4MCA0ODBWMjM2YzAtNi42MjctNS4zNzMtMTItMTItMTJoLTI0Yy02LjYyNyAwLTEyIDUuMzczLTEyIDEydjI0NGMtMzQuMzUxIDAtNjUuODg2LTEyLjAzNS05MC42MzYtMzIuMTA4bC01NC43MzYgNTQuNzM2Yy0xMi40OTggMTIuNDk3LTMyLjc1OSAxMi40OTYtNDUuMjU2IDAtMTIuNDk2LTEyLjQ5Ny0xMi40OTYtMzIuNzU4IDAtNDUuMjU1bDYwLjIyOC02MC4yMjhDOTIuODgyIDM3OC41ODQgODggMzU3Ljg2NCA4OCAzMzZ2LTE2SDMyLjY2NkMxNS4yMyAzMjAgLjQ5MSAzMDYuMzMuMDEzIDI4OC45LS40ODQgMjcwLjgxNiAxNC4wMjggMjU2IDMyIDI1Nmg1NnYtNTguNzQ1bC00Ni42MjgtNDYuNjI4Yy0xMi40OTYtMTIuNDk3LTEyLjQ5Ni0zMi43NTggMC00NS4yNTUgMTIuNDk4LTEyLjQ5NyAzMi43NTgtMTIuNDk3IDQ1LjI1NiAwTDE0MS4yNTUgMTYwaDIyOS40ODlsNTQuNjI3LTU0LjYyN2MxMi40OTgtMTIuNDk3IDMyLjc1OC0xMi40OTcgNDUuMjU2IDAgMTIuNDk2IDEyLjQ5NyAxMi40OTYgMzIuNzU4IDAgNDUuMjU1TDQyNCAxOTcuMjU1VjI1Nmg1NmMxNy45NzIgMCAzMi40ODQgMTQuODE2IDMxLjk4OCAzMi45ek0yNTcgMGMtNjEuODU2IDAtMTEyIDUwLjE0NC0xMTIgMTEyaDIyNEMzNjkgNTAuMTQ0IDMxOC44NTYgMCAyNTcgMHoiIGZpbGw9IndoaXRlIi8+Cjwvc3ZnPgo=
[![Stable Release](https://img.shields.io/badge/dynamic/json?url=https://files.minecraftforge.net/net/minecraftforge/forge/promotions_slim.json&label=Stable&prefix=1.21.8-&query=$.promos["1.21.8-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=1.21.8-&query=$.promos["1.21.8-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]
Forge is a free, open-source modding API all of your favourite mods use!
@@ -358,7 +358,7 @@ public class ModLoader {
return completedStates.contains(state);
}
public <T extends IModBusEvent> void runEventGenerator(Function<ModContainer, T> generator) {
public static <T extends IModBusEvent> void runEventGenerator(Function<ModContainer, T> generator) {
if (!loadingStateValid) {
LOGGER.error("Cowardly refusing to send event generator to a broken mod state");
return;
@@ -367,8 +367,7 @@ public class ModLoader {
mod.acceptEvent(generator.apply(mod));
}
public <T extends IModBusEvent> void postEvent(T e) {
var cls = e.getClass();
public static <T extends IModBusEvent> void postEvent(T e) {
if (!loadingStateValid) {
LOGGER.error("Cowardly refusing to send event {} to a broken mod state", e.getClass().getName());
return;
@@ -377,7 +376,7 @@ public class ModLoader {
mod.acceptEvent(e);
}
public <T extends IModBusEvent> T postEventWithReturn(T e) {
public static <T extends IModBusEvent> T postEventWithReturn(T e) {
if (!loadingStateValid) {
LOGGER.error("Cowardly refusing to send event {} to a broken mod state", e.getClass().getName());
return e;
@@ -388,14 +387,14 @@ public class ModLoader {
}
@SuppressWarnings("removal")
public <T extends IModBusEvent> void postEventWrapContainerInModOrder(T event) {
public static <T extends IModBusEvent> void postEventWrapContainerInModOrder(T event) {
postEventWithWrapInModOrder(event,
(mc, e) -> ModLoadingContext.get().setActiveContainer(mc),
(mc, e) -> ModLoadingContext.get().setActiveContainer(null)
);
}
public <T extends IModBusEvent> void postEventWithWrapInModOrder(T e, BiConsumer<ModContainer, T> pre, BiConsumer<ModContainer, T> post) {
public static <T extends IModBusEvent> void postEventWithWrapInModOrder(T e, BiConsumer<ModContainer, T> pre, BiConsumer<ModContainer, T> post) {
if (!loadingStateValid) {
LOGGER.error("Cowardly refusing to send event {} to a broken mod state", e.getClass().getName());
return;
@@ -1,131 +0,0 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.fml.common.asm;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.AnnotationNode;
import org.objectweb.asm.tree.ClassNode;
import cpw.mods.modlauncher.serviceapi.ILaunchPluginService;
/**
* Removes the final modifier from fields with the @ObjectHolder annotation, prevents the JITer from in lining them so our runtime replacements can work.
* Will also de-finalize all fields in on class level annotations.
*/
public class ObjectHolderDefinalize implements ILaunchPluginService {
// Hardcoded map of vanilla classes that should have object holders for each field of the given registry type.
// IMPORTANT: Updates to this collection must be reflected in ObjectHolderRegistry. Duplicated cuz classloaders, yay!
// Classnames are validated in ObjectHolderRegistry.
private static final Map<String, VanillaObjectHolderData> VANILLA_OBJECT_HOLDERS = Stream.of(
new VanillaObjectHolderData("net.minecraft.world.level.block.Blocks", "block", "net.minecraft.world.level.block.Block"),
new VanillaObjectHolderData("net.minecraft.world.item.Items", "item", "net.minecraft.world.item.Item"),
new VanillaObjectHolderData("net.minecraft.world.item.enchantment.Enchantments", "enchantment", "net.minecraft.world.item.enchantment.Enchantment"),
new VanillaObjectHolderData("net.minecraft.world.effect.MobEffects", "mob_effect", "net.minecraft.world.effect.MobEffect"),
new VanillaObjectHolderData("net.minecraft.core.particles.ParticleTypes", "particle_type", "net.minecraft.core.particles.ParticleType"),
new VanillaObjectHolderData("net.minecraft.sounds.SoundEvents", "sound_event", "net.minecraft.sounds.SoundEvent")
).collect(Collectors.toUnmodifiableMap(VanillaObjectHolderData::holderClass, Function.identity()));
private static final Set<String> VANILLA_OBJECT_HOLDER_CLASSES = VANILLA_OBJECT_HOLDERS.keySet().stream()
.map(it -> it.replace('.', '/'))
.collect(Collectors.toUnmodifiableSet());
private static final String OBJECT_HOLDER = "Lnet/minecraftforge/registries/ObjectHolder;"; //Don't directly reference this to prevent class loading.
private static final int PUBLIC_STATIC_FINAL_FLAGS = Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL;
@Override
public String name() {
return "object_holder_definalize";
}
private static final EnumSet<Phase> YAY = EnumSet.of(Phase.AFTER);
private static final EnumSet<Phase> NAY = EnumSet.noneOf(Phase.class);
@Override
public EnumSet<Phase> handlesClass(Type classType, boolean isEmpty) {
if (isEmpty)
return NAY;
// Let's skip processing classes that definitely don't have object holders
String internalName = classType.getInternalName();
// Forge classes that aren't in the debug package (that package is used for tests)
if (internalName.startsWith("net/minecraftforge/") && !internalName.substring(18).contains("debug"))
return NAY;
// Vanilla classes that don't have object holders
if (internalName.startsWith("com/mojang/"))
return NAY;
// ...except specific ones we added to the VANILLA_OBJECT_HOLDERS map
if (internalName.startsWith("net/minecraft/") && !VANILLA_OBJECT_HOLDER_CLASSES.contains(internalName))
return NAY;
return YAY;
}
private static boolean hasHolder(List<AnnotationNode> lst) {
return lst != null && lst.stream().anyMatch(n -> n.desc.equals(OBJECT_HOLDER));
}
@SuppressWarnings("unused")
private String getValue(List<AnnotationNode> lst)
{
AnnotationNode ann = lst.stream().filter(n -> n.desc.equals(OBJECT_HOLDER)).findFirst().get();
if (ann.values != null)
{
for (int x = 0; x < ann.values.size() - 1; x += 2) {
if (ann.values.get(x).equals("value")) {
return (String)ann.values.get(x + 1);
}
}
}
return null;
}
@Override
public int processClassWithFlags(final Phase phase, final ClassNode classNode, final Type classType, final String reason)
{
final AtomicBoolean changes = new AtomicBoolean();
//Must be public static finals, and non-array objects
//Fix Annotated Fields before injecting from class level
classNode.fields.stream().filter(f -> ((f.access & PUBLIC_STATIC_FINAL_FLAGS) == PUBLIC_STATIC_FINAL_FLAGS) && f.desc.startsWith("L") && hasHolder(f.visibleAnnotations)).forEach(f ->
{
int prev = f.access;
f.access &= ~Opcodes.ACC_FINAL; //Strip final
f.access |= Opcodes.ACC_SYNTHETIC; //Add Synthetic so we can check in runtime. ? Good idea?
changes.compareAndSet(false, prev != f.access);
});
if (VANILLA_OBJECT_HOLDERS.containsKey(classType.getClassName())) //Class level, de-finalize all fields and add @ObjectHolder to them!
{
classNode.fields.stream().filter(f -> ((f.access & PUBLIC_STATIC_FINAL_FLAGS) == PUBLIC_STATIC_FINAL_FLAGS) && f.desc.startsWith("L")).forEach(f ->
{
int prev = f.access;
f.access &= ~Opcodes.ACC_FINAL;
f.access |= Opcodes.ACC_SYNTHETIC;
/*if (!hasHolder(f.visibleAnnotations)) //Add field level annotation, doesn't do anything until after we figure out how ASMDataTable is gatherered
{
if (value == null)
f.visitAnnotation(OBJECT_HOLDER, true);
else
f.visitAnnotation(OBJECT_HOLDER, true).visit("value", value + ":" + f.name.toLowerCase());
}*/
changes.compareAndSet(false, prev != f.access);
});
}
return changes.get() ? ComputeFlags.SIMPLE_REWRITE : ComputeFlags.NO_REWRITE;
}
private record VanillaObjectHolderData(String holderClass, String registryName, String registryType) {}
}
@@ -7,9 +7,9 @@ package net.minecraftforge.fml.common.asm;
import java.util.EnumSet;
import java.util.List;
import java.util.stream.Collectors;
import com.mojang.logging.LogUtils;
import net.minecraftforge.fml.loading.LoadingModList;
import org.objectweb.asm.Label;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
@@ -47,16 +47,21 @@ public class RuntimeEnumExtender implements ILaunchPluginService {
private static final EnumSet<Phase> YAY = EnumSet.of(Phase.AFTER);
private static final EnumSet<Phase> NAY = EnumSet.noneOf(Phase.class);
private static final class LazyInit {
private LazyInit() {}
private static final boolean ANY_MODS = LoadingModList.get().getMods().size() > 2; // 2: forge, minecraft
}
@Override
public EnumSet<Phase> handlesClass(Type classType, boolean isEmpty) {
if (isEmpty)
if (isEmpty || !LazyInit.ANY_MODS)
return NAY;
String internalName = classType.getInternalName();
if (internalName.startsWith("net/minecraftforge/") || internalName.startsWith("com/mojang/"))
return NAY;
if (internalName.startsWith("net/minecraft/client/model") || internalName.startsWith("net/minecraft/world"))
return YAY;
return YAY;
return NAY;
}
@Override
@@ -39,14 +39,13 @@ import java.util.jar.Manifest;
public class ModFile implements IModFile {
private static final Logger LOGGER = LogUtils.getLogger();
private final String jarVersion;
private final ModFileFactory.ModFileInfoParser parser;
private Map<String, Object> fileProperties;
private List<IModLanguageProvider> loaders;
private Throwable scanError;
private final SecureJar jar;
private final Type modFileType;
private final IModProvider provider;
private IModFileInfo modFileInfo;
private final IModFileInfo modFileInfo;
private ModFileScanData fileModFileScanData;
private CompletableFuture<ModFileScanData> futureScanResult;
private List<CoreModFile> coreMods;
@@ -62,12 +61,11 @@ public class ModFile implements IModFile {
public ModFile(final SecureJar jar, final IModProvider provider, final ModFileFactory.ModFileInfoParser parser, String type) {
this.provider = provider;
this.jar = jar;
this.parser = parser;
var manifest = this.jar.moduleDataProvider().getManifest();
modFileType = Type.valueOf(type);
jarVersion = Optional.ofNullable(manifest.getMainAttributes().getValue(Attributes.Name.IMPLEMENTATION_VERSION)).orElse("0.0NONE");
this.modFileInfo = ModFileParser.readModList(this, this.parser);
this.modFileInfo = ModFileParser.readModList(this, parser);
}
@Override
@@ -99,11 +97,13 @@ public class ModFile implements IModFile {
}
public boolean identifyMods() {
this.modFileInfo = ModFileParser.readModList(this, this.parser);
if (this.modFileInfo == null) return this.getType() != Type.MOD;
LOGGER.debug(LogMarkers.LOADING,"Loading mod file {} with languages {}", this.getFilePath(), this.modFileInfo.requiredLanguageLoaders());
this.coreMods = ModFileParser.getCoreMods(this);
this.coreMods.forEach(mi-> LOGGER.debug(LogMarkers.LOADING,"Found coremod {}", mi.getPath()));
if (!this.coreMods.isEmpty())
LOGGER.warn("Mod file {} contains javascript coremods! JS CoreMods are deprecated and will be removed in a future release. Consider using Mixin or ModLauncher transformers.", this.getFileName());
for (var mi : this.coreMods)
LOGGER.debug(LogMarkers.LOADING, "Found coremod {}", mi.getPath());
this.accessTransformer = findResource("META-INF", "accesstransformer.cfg");
return true;
}
@@ -84,7 +84,7 @@ public abstract class CommonLaunchHandler implements ILaunchHandlerService {
protected static final LaunchType CLIENT_DATA = new LaunchType("client_data", "minecraft", "net.minecraft.client.data.Main", Dist.CLIENT, true);
protected static final LaunchType DATA = new LaunchType("data", "minecraft", "net.minecraft.data.Main", Dist.CLIENT, true);
protected static final LaunchType SERVER = new LaunchType("server", "minecraft", "net.minecraft.server.Main", Dist.DEDICATED_SERVER, false);
protected static final LaunchType SERVER_GAMETEST = new LaunchType("server_gametest", "net.minecraftforge.forge", "net.minecraftforge.gametest.GameTestMain", Dist.DEDICATED_SERVER, false);
protected static final LaunchType SERVER_GAMETEST = new LaunchType("server_gametest", "minecraft", "net.minecraft.gametest.Main", Dist.DEDICATED_SERVER, false);
protected void runTarget(String module, String target, final String[] arguments, final ModuleLayer layer) throws Throwable {
var mod = layer.findModule(module).orElse(null);
@@ -96,14 +96,14 @@ public final class ForgeDevLocator extends AbstractModProvider implements IModLo
// Find resource directories for every mod in this group
var paths = new LinkedHashSet<Path>();
for (var modid : modids) {
for (var modid : modids.stream().sorted().toList()) {
var rsc = path.resolve(modid);
if (Files.exists(rsc))
paths.add(rsc);
}
var root = memory.getPath(modids.iterator().next()); // use the first modid as our root
buildModsToml(paths, modids, root);
buildModsToml(paths, modids, root, pkg.startsWith("net/minecraftforge/debug/client/"));
buildPackMeta(paths, root);
moveModuleInfo(paths, root);
@@ -187,7 +187,7 @@ public final class ForgeDevLocator extends AbstractModProvider implements IModLo
}
// Builds or update the mods.toml file for all @Mods in this package
private static void buildModsToml(Set<Path> resources, Set<String> modids, Path root) {
private static void buildModsToml(Set<Path> resources, Set<String> modids, Path root, boolean clientOnly) {
var toml = resources.stream()
.map(p -> p.resolve(MODS_TOML))
.filter(Files::exists)
@@ -205,7 +205,8 @@ public final class ForgeDevLocator extends AbstractModProvider implements IModLo
var defaults = Map.of(
"modLoader", "javafml",
"loaderVersion", "[0,)",
"license", "Doesnt fucking matter"
"license", "Doesnt fucking matter",
"clientSideOnly", clientOnly
);
for (var key : defaults.keySet()) {
@@ -1,5 +1,4 @@
net.minecraftforge.fml.loading.log4j.SLF4JFixerLaunchPluginService
net.minecraftforge.fml.loading.RuntimeDistCleaner
net.minecraftforge.fml.common.asm.RuntimeEnumExtender
net.minecraftforge.fml.common.asm.ObjectHolderDefinalize
net.minecraftforge.fml.common.asm.CapabilityTokenSubclass
+73
View File
@@ -0,0 +1,73 @@
import net.minecraftforge.gradleutils.PomUtils
plugins {
id 'java-library'
id 'maven-publish'
id 'net.minecraftforge.licenser'
id 'net.minecraftforge.gradleutils'
alias(libs.plugins.apt)
}
apply from: rootProject.file('build_shared.gradle')
configurations.forEach{ it.transitive = false }
dependencies {
compileOnly(libs.jetbrains.annotations)
implementation(libs.bundles.asm) // Needed by all the black magic
implementation(libs.log4j.api)
implementation(libs.gson)
implementation(libs.modlauncher)
implementation(libs.coremods) // Used for ASMAPI (for now)
testCompileOnly(libs.jetbrains.annotations)
}
java {
toolchain.languageVersion = JavaLanguageVersion.of(JAVA_VERSION)
withSourcesJar()
}
tasks.named('jar', Jar) {
manifest {
attributes([
'Automatic-Module-Name': 'net.minecraftforge.forge.transformers',
'Forge-Module-Layer': 'boot'
] as LinkedHashMap)
attributes([
'Specification-Title': 'Forge Transformers',
'Specification-Vendor': 'Forge Development LLC',
'Specification-Version': '1',
'Implementation-Title': 'Forge Transformers',
'Implementation-Vendor': 'Forge Development LLC',
'Implementation-Version': FORGE_VERSION
] as LinkedHashMap, 'net/minecraftforge/forge/transformers/')
}
}
tasks.withType(JavaCompile).configureEach {
options.compilerArgs << '-Xlint:unchecked'
}
license {
header = rootProject.file('LICENSE-header.txt')
}
publishing {
publications.register('mavenJava', MavenPublication) {
from components.java
artifactId = 'forge-transformers'
pom {
name = project.name
description = 'Forge-specific transformers unrelated to the FML project.'
url = 'https://github.com/MinecraftForge/MinecraftForge'
PomUtils.setGitHubDetails(pom, 'MinecraftForge')
license PomUtils.Licenses.LGPLv2_1
}
}
repositories {
maven gradleutils.publishingForgeMaven
}
}
@@ -0,0 +1,78 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.forge.transformers;
import cpw.mods.modlauncher.api.ITransformer;
import cpw.mods.modlauncher.api.ITransformerVotingContext;
import cpw.mods.modlauncher.api.TransformerVoteResult;
import net.minecraftforge.coremod.api.ASMAPI;
import org.jetbrains.annotations.NotNull;
import org.objectweb.asm.tree.ClassNode;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
record FieldToMethodTransformer(String className, Map<String, String> fields) implements ITransformer<ClassNode> {
// TODO [Forge][Transformer] Make this properly data driven or configurable.
// It was hard-coded like this before when using JS CoreMods, though.
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",
Map.of(
"effect", "getEffect"
),
"net.minecraft.world.level.block.LiquidBlock",
Map.of(
"fluid", "getFluid"
),
"net.minecraft.world.item.BucketItem",
Map.of(
"content", "getFluid"
),
"net.minecraft.world.level.block.FlowerPotBlock",
Map.of(
"potted", "getPotted"
)
);
@SuppressWarnings("rawtypes")
static List<ITransformer> getAll() {
var ret = new ArrayList<ITransformer>(TARGETS.size());
for (var entry : TARGETS.entrySet()) {
ret.add(new FieldToMethodTransformer(entry.getKey(), entry.getValue()));
}
return ret;
}
@Override
public @NotNull ClassNode transform(ClassNode input, ITransformerVotingContext context) {
for (var entry : this.fields.entrySet()) {
ASMAPI.redirectFieldToMethod(input, entry.getKey(), entry.getValue());
}
return input;
}
@Override
public @NotNull TransformerVoteResult castVote(ITransformerVotingContext context) {
return TransformerVoteResult.YES;
}
@Override
public @NotNull Set<Target> targets() {
return Set.of(Target.targetClass(this.className));
}
}
@@ -0,0 +1,35 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.forge.transformers;
import cpw.mods.modlauncher.api.IEnvironment;
import cpw.mods.modlauncher.api.ITransformationService;
import cpw.mods.modlauncher.api.ITransformer;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
public record ForgeModTransformers(String name) implements ITransformationService {
public ForgeModTransformers() {
this("forge");
}
@Override
public void initialize(IEnvironment environment) { }
@Override
public void onLoad(IEnvironment env, Set<String> otherServices) { }
@Override
@SuppressWarnings("rawtypes")
public @NotNull List<ITransformer> transformers() {
List<ITransformer> transformers = FieldToMethodTransformer.getAll();
transformers.add(new MethodRedirector());
return transformers;
}
}
@@ -0,0 +1,142 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.forge.transformers;
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import cpw.mods.modlauncher.api.ITransformer;
import cpw.mods.modlauncher.api.ITransformerVotingContext;
import cpw.mods.modlauncher.api.TransformerVoteResult;
import net.minecraftforge.coremod.api.ASMAPI;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.MethodInsnNode;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.function.UnaryOperator;
import java.util.stream.Collectors;
// NOTE: THIS IS A SINGLETON!
record MethodRedirector() implements ITransformer<ClassNode> {
private static final Logger LOGGER = LogManager.getLogger();
private static final Gson GSON = new Gson();
private static final Replacement[] REPLACEMENTS = {
new Replacement(
// finalizeSpawn redirection to ForgeEventFactory.onFinalizeSpawn
ASMAPI.MethodType.VIRTUAL,
"finalizeSpawn",
"(Lnet/minecraft/world/level/ServerLevelAccessor;Lnet/minecraft/world/DifficultyInstance;Lnet/minecraft/world/entity/EntitySpawnReason;Lnet/minecraft/world/entity/SpawnGroupData;)Lnet/minecraft/world/entity/SpawnGroupData;",
GSON.fromJson(new InputStreamReader(sneak(() -> MethodRedirector.class.getModule().getResourceAsStream("coremods/finalize_spawn_targets.json"))), Target[].class),
insn -> ASMAPI.buildMethodCall(
ASMAPI.MethodType.STATIC,
"net/minecraftforge/event/ForgeEventFactory",
"onFinalizeSpawn",
"(Lnet/minecraft/world/entity/Mob;Lnet/minecraft/world/level/ServerLevelAccessor;Lnet/minecraft/world/DifficultyInstance;Lnet/minecraft/world/entity/EntitySpawnReason;Lnet/minecraft/world/entity/SpawnGroupData;)Lnet/minecraft/world/entity/SpawnGroupData;"
)
)
};
private static <T> T sneak(Callable<T> callable) {
try {
return callable.call();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
record Replacement(
ASMAPI.MethodType type,
String name,
String desc,
Target[] targets,
UnaryOperator<MethodInsnNode> factory
) { }
record Target(
@SerializedName("class") String className,
String[] methods
) { }
@Override
public @NotNull TransformerVoteResult castVote(ITransformerVotingContext context) {
return TransformerVoteResult.YES;
}
@Override
public @NotNull Set<ITransformer.Target> targets() {
return Arrays
.stream(REPLACEMENTS)
.map(Replacement::targets)
.flatMap(Arrays::stream)
.map(Target::className)
.map(ITransformer.Target::targetClass)
.collect(Collectors.toUnmodifiableSet());
}
@Override
public @NotNull ClassNode transform(ClassNode clazz, ITransformerVotingContext context) {
for (var replacement : REPLACEMENTS) {
for (var methodString : getClassTargetMethods(clazz, replacement)) {
// cut up the string since we've put both the name and desc as the target
var splitPos = methodString.indexOf('(');
var methodName = methodString.substring(0, splitPos);
var methodDesc = methodString.substring(splitPos);
var method = ASMAPI.findMethodNode(clazz, methodName, methodDesc);
if (method == null) {
LOGGER.error("Failed to redirect method call for {}! Method {} not found in class {}! This is a Forge bug, and is likely due to a Minecraft update changing something.", replacement.name, methodString, clazz.name);
continue;
}
for (var insn : method.instructions) {
if (!shouldReplace(insn, replacement)) continue;
var methodInsn = (MethodInsnNode) insn;
var redirection = replacement.factory.apply(methodInsn);
LOGGER.debug("Redirecting method call {}{} to {}{} inside of {}.{}", methodInsn.name, methodInsn.desc, redirection.name, redirection.desc, clazz.name, method.name);
ASMAPI.insertInsn(method, methodInsn, redirection, ASMAPI.InsertMode.REMOVE_ORIGINAL);
}
}
}
return clazz;
}
private static boolean shouldReplace(AbstractInsnNode insn, Replacement replacement) {
return insn.getOpcode() == replacement.type.toOpcode()
&& replacement.name.equals(((MethodInsnNode) insn).name)
&& replacement.desc.equals(((MethodInsnNode) insn).desc);
}
private static List<String> getClassTargetMethods(ClassNode clazz, Replacement replacement) {
for (var t : replacement.targets) {
if (!t.className.equals(clazz.name)) continue;
// declared methods
var targets = new ArrayList<>(Arrays.asList(t.methods));
// synthetic methods
for (var method : clazz.methods) {
if ((method.access & Opcodes.ACC_SYNTHETIC) != 0)
targets.add(method.name + method.desc);
}
return targets;
}
return List.of();
}
}
@@ -0,0 +1 @@
net.minecraftforge.forge.transformers.ForgeModTransformers
@@ -107,7 +107,7 @@
{
"class": "net/minecraft/world/level/levelgen/PhantomSpawner",
"methods": [
"tick(Lnet/minecraft/server/level/ServerLevel;ZZ)V"
"tick(Lnet/minecraft/server/level/ServerLevel;Z)V"
]
},
{
+3 -3
View File
@@ -5,11 +5,11 @@ org.gradle.daemon=false
org.gradle.parallel=true
JAVA_VERSION=21
MC_VERSION=1.21.6
MC_VERSION=1.21.9
MC_NEXT_VERSION=1.22
MCP_VERSION=20250618.020446
MCP_VERSION=20250930.103108
MAPPING_CHANNEL=official
MAPPING_VERSION=1.21.6
MAPPING_VERSION=1.21.9
# Set to true before the first build of a new MC version, so we don't do compatibility checks
CHECK_COMPATIBILITY=false
@@ -152,6 +152,9 @@ public class AutomaticEventSubscriber {
if (!Modifier.isStatic(method.getModifiers()))
continue;
if (method.isSynthetic())
continue; // EventBus#89
int paramCount = method.getParameterCount();
if (paramCount == 0 || paramCount > 2)
continue;
@@ -187,8 +190,10 @@ public class AutomaticEventSubscriber {
public static void registerStrict(BusGroup busGroup, Class<?> listenerClass) {
Class<? extends Event> firstValidListenerEventType = null;
Method[] declaredMethods = listenerClass.getDeclaredMethods();
if (declaredMethods.length == 0) {
List<Method> declaredMethods = Arrays.stream(listenerClass.getDeclaredMethods())
.filter(Predicate.not(Method::isSynthetic)) // EventBus#89
.toList();
if (declaredMethods.isEmpty()) {
var errMsg = "No declared methods found in " + listenerClass.getName();
var superClass = listenerClass.getSuperclass();
if (superClass != null && superClass != Record.class && superClass != Enum.class) {
@@ -8,8 +8,6 @@ package net.minecraftforge.fml.mclanguageprovider;
import net.minecraftforge.fml.ModContainer;
import net.minecraftforge.forgespi.language.IModInfo;
import java.util.Objects;
public class MinecraftModContainer extends ModContainer {
private static final String MCMODINSTANCE = "minecraft, the mod";
@@ -20,7 +18,7 @@ public class MinecraftModContainer extends ModContainer {
@Override
public boolean matches(final Object mod) {
return Objects.equals(mod, MCMODINSTANCE);
return MCMODINSTANCE.equals(mod);
}
@Override
@@ -10,7 +10,6 @@ import net.minecraftforge.forgespi.language.IModInfo;
import net.minecraftforge.forgespi.language.IModLanguageProvider;
import net.minecraftforge.forgespi.language.ModFileScanData;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;
@@ -20,7 +19,7 @@ import java.util.function.Supplier;
import static net.minecraftforge.fml.Logging.LOADING;
public class MinecraftModLanguageProvider implements IModLanguageProvider {
private static final Logger LOGGER = LogManager.getLogger();
@Override
public String name() {
return "minecraft";
@@ -45,7 +44,7 @@ public class MinecraftModLanguageProvider implements IModLanguageProvider {
final Class<?> mcModClass = Class.forName(getClass().getModule(), "net.minecraftforge.fml.mclanguageprovider.MinecraftModContainer");
return (T)mcModClass.getConstructor(IModInfo.class).newInstance(info);
} catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
LOGGER.fatal(LOADING,"Unable to load MinecraftModContainer, wut?", e);
LogManager.getLogger().fatal(LOADING, "Unable to load MinecraftModContainer, wut?", e);
throw new RuntimeException(e);
}
}
+1 -1
View File
@@ -145,7 +145,7 @@ dependencies {
// Forge 1.21.6+ uses EventBus 7, which shifts most of its runtime validation to compile-time via an annotation processor
// to improve performance in production environments. This line is required to enable said compile-time validation
// in your development environment, helping you catch issues early.
annotationProcessor 'net.minecraftforge:eventbus-validator:7.0-beta.7'
annotationProcessor 'net.minecraftforge:eventbus-validator:7.0-beta.10'
// Example mod dependency with JEI
// The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
@@ -1,6 +1,6 @@
--- a/com/mojang/blaze3d/opengl/GlCommandEncoder.java
+++ b/com/mojang/blaze3d/opengl/GlCommandEncoder.java
@@ -132,6 +_,9 @@
@@ -131,6 +_,9 @@
GlStateManager._colorMask(true, true, true, true);
GlStateManager._clear(16384);
GlStateManager._glFramebufferTexture2D(36160, 36064, 3553, 0, 0);
@@ -1,6 +1,6 @@
--- a/com/mojang/blaze3d/opengl/GlDevice.java
+++ b/com/mojang/blaze3d/opengl/GlDevice.java
@@ -88,8 +_,15 @@
@@ -90,8 +_,15 @@
public GpuTexture createTexture(
@Nullable Supplier<String> p_397830_, int p_394481_, TextureFormat p_394839_, int p_391831_, int p_395609_, int p_407582_, int p_408928_
) {
@@ -17,7 +17,7 @@
);
}
@@ -97,6 +_,15 @@
@@ -99,6 +_,15 @@
public GpuTexture createTexture(
@Nullable String p_394142_, int p_395535_, TextureFormat p_394951_, int p_393944_, int p_392329_, int p_408015_, int p_406483_
) {
@@ -33,7 +33,7 @@
if (p_406483_ < 1) {
throw new IllegalArgumentException("mipLevels must be at least 1");
} else if (p_408015_ < 1) {
@@ -147,11 +_,14 @@
@@ -149,11 +_,14 @@
GlStateManager._texImage2D(
k,
l,
@@ -48,7 +48,7 @@
GlConst.toGlType(p_394951_),
null
);
@@ -162,11 +_,14 @@
@@ -164,11 +_,14 @@
GlStateManager._texImage2D(
j,
i1,
@@ -63,7 +63,7 @@
GlConst.toGlType(p_394951_),
null
);
@@ -179,7 +_,7 @@
@@ -181,7 +_,7 @@
} else if (j1 != 0) {
throw new IllegalStateException("OpenGL error " + j1);
} else {
@@ -1,6 +1,6 @@
--- a/com/mojang/blaze3d/opengl/GlStateManager.java
+++ b/com/mojang/blaze3d/opengl/GlStateManager.java
@@ -89,6 +_,11 @@
@@ -85,6 +_,11 @@
}
}
@@ -12,7 +12,7 @@
public static void _disableBlend() {
RenderSystem.assertOnRenderThread();
BLEND.mode.disable();
@@ -404,9 +_,17 @@
@@ -371,9 +_,17 @@
}
}
@@ -1,6 +1,6 @@
--- a/com/mojang/blaze3d/pipeline/RenderTarget.java
+++ b/com/mojang/blaze3d/pipeline/RenderTarget.java
@@ -92,7 +_,7 @@
@@ -86,7 +_,7 @@
this.width = p_83951_;
this.height = p_83952_;
if (this.useDepth) {
@@ -9,7 +9,7 @@
this.depthTextureView = gpudevice.createTextureView(this.depthTexture);
this.depthTexture.setTextureFilter(FilterMode.NEAREST, false);
this.depthTexture.setAddressMode(AddressMode.CLAMP_TO_EDGE);
@@ -166,5 +_,26 @@
@@ -155,5 +_,26 @@
@Nullable
public GpuTextureView getDepthTextureView() {
return this.depthTextureView;
@@ -25,7 +25,7 @@
+ public void enableStencil() {
+ if (stencilEnabled) return;
+ stencilEnabled = true;
+ this.resize(viewWidth, viewHeight);
+ this.resize(width, height);
+ }
+
+ /**
@@ -1,16 +1,16 @@
--- a/com/mojang/blaze3d/platform/Window.java
+++ b/com/mojang/blaze3d/platform/Window.java
@@ -88,7 +_,8 @@
GLFW.glfwWindowHint(139267, 2);
@@ -91,7 +_,8 @@
GLFW.glfwWindowHint(139267, 3);
GLFW.glfwWindowHint(139272, 204801);
GLFW.glfwWindowHint(139270, 1);
- this.window = GLFW.glfwCreateWindow(this.width, this.height, p_85376_, this.fullscreen && monitor != null ? monitor.getMonitor() : 0L, 0L);
+ this.window = net.minecraftforge.fml.loading.ImmediateWindowHandler.setupMinecraftWindow(()->this.width, ()->this.height, ()->p_85376_, ()->this.fullscreen && monitor != null ? monitor.getMonitor() : 0L);
- this.handle = GLFW.glfwCreateWindow(this.width, this.height, p_85376_, this.fullscreen && monitor != null ? monitor.getMonitor() : 0L, 0L);
+ this.handle = net.minecraftforge.fml.loading.ImmediateWindowHandler.setupMinecraftWindow(()->this.width, ()->this.height, ()->p_85376_, ()->this.fullscreen && monitor != null ? monitor.getMonitor() : 0L);
+ if (!net.minecraftforge.fml.loading.ImmediateWindowHandler.positionWindow(Optional.ofNullable(monitor), w->this.width = this.windowedWidth = w, h->this.height = this.windowedHeight = h, x->this.x = this.windowedX = x, y->this.y = this.windowedY = y)) {
if (monitor != null) {
VideoMode videomode = monitor.getPreferredVidMode(this.fullscreen ? this.preferredFullscreenVideoMode : Optional.empty());
this.windowedX = this.x = monitor.getX() + videomode.getWidth() / 2 - this.width / 2;
@@ -100,6 +_,7 @@
@@ -103,6 +_,7 @@
this.windowedX = this.x = aint1[0];
this.windowedY = this.y = aint[0];
}
@@ -18,8 +18,8 @@
this.setMode();
this.refreshFramebufferSize();
@@ -266,6 +_,9 @@
GLFW.glfwGetFramebufferSize(this.window, aint, aint1);
@@ -269,6 +_,9 @@
GLFW.glfwGetFramebufferSize(this.handle, aint, aint1);
this.framebufferWidth = aint[0] > 0 ? aint[0] : 1;
this.framebufferHeight = aint1[0] > 0 ? aint1[0] : 1;
+ if (this.framebufferHeight == 0 || this.framebufferWidth == 0) {
@@ -9,7 +9,7 @@
VertexConsumer addVertex(float p_344294_, float p_342213_, float p_344859_);
VertexConsumer setColor(int p_342749_, int p_344324_, int p_343336_, int p_342831_);
@@ -135,9 +_,11 @@
@@ -131,9 +_,11 @@
int j1 = ARGB.color(k, (int)f3, (int)f4, (int)f5);
int k1 = LightTexture.lightCoordsWithEmission(p_331444_[i1], l);
@@ -1,6 +1,6 @@
--- a/com/mojang/blaze3d/vertex/VertexFormat.java
+++ b/com/mojang/blaze3d/vertex/VertexFormat.java
@@ -18,7 +_,7 @@
@@ -20,7 +_,7 @@
@OnlyIn(Dist.CLIENT)
@DontObfuscate
@@ -9,7 +9,7 @@
public static final int UNKNOWN_ELEMENT = -1;
private final List<VertexFormatElement> elements;
private final List<String> names;
@@ -29,6 +_,7 @@
@@ -31,6 +_,7 @@
private GpuBuffer immediateDrawVertexBuffer;
@Nullable
private GpuBuffer immediateDrawIndexBuffer;
@@ -17,7 +17,7 @@
VertexFormat(List<VertexFormatElement> p_343616_, List<String> p_345241_, IntList p_345522_, int p_344162_) {
this.elements = p_343616_;
@@ -41,6 +_,11 @@
@@ -43,6 +_,11 @@
int j = vertexformatelement != null ? p_343616_.indexOf(vertexformatelement) : -1;
this.offsetsByElement[i] = j != -1 ? p_345522_.getInt(j) : -1;
}
@@ -29,8 +29,8 @@
}
public static VertexFormat.Builder builder() {
@@ -138,6 +_,9 @@
@@ -141,6 +_,9 @@
this.immediateDrawIndexBuffer = uploadToBuffer(this.immediateDrawIndexBuffer, p_391835_, 72, () -> "Immediate index buffer for " + this);
return this.immediateDrawIndexBuffer;
}
+
@@ -4,12 +4,12 @@
}
@Override
+ public boolean keyPressed(int key, int scanCode, int modifiers) {
+ if (key == org.lwjgl.glfw.GLFW.GLFW_KEY_ESCAPE) {
+ public boolean keyPressed(net.minecraft.client.input.KeyEvent event) {
+ if (event.key() == org.lwjgl.glfw.GLFW.GLFW_KEY_ESCAPE) {
+ minecraft.setScreen(this.nextScreen);
+ return true;
+ }
+ return super.keyPressed(key, scanCode, modifiers);
+ return super.keyPressed(event);
+ }
+
+ @Override
@@ -1,6 +1,6 @@
--- a/net/minecraft/CrashReportCategory.java
+++ b/net/minecraft/CrashReportCategory.java
@@ -112,8 +_,10 @@
@@ -116,8 +_,10 @@
if (astacktraceelement.length <= 0) {
return 0;
} else {
@@ -13,7 +13,7 @@
return this.stackTrace.length;
}
}
@@ -160,16 +_,16 @@
@@ -164,16 +_,16 @@
if (this.stackTrace != null && this.stackTrace.length > 0) {
p_128169_.append("\nStacktrace:");
@@ -1,10 +1,10 @@
--- a/net/minecraft/SharedConstants.java
+++ b/net/minecraft/SharedConstants.java
@@ -175,6 +_,7 @@
@@ -224,6 +_,7 @@
}
static {
+ if (System.getProperty("io.netty.leakDetection.level") == null) // Forge: allow level to be manually specified
ResourceLeakDetector.setLevel(NETTY_LEAK_DETECTION);
CommandSyntaxException.ENABLE_COMMAND_STACK_TRACES = false;
CommandSyntaxException.ENABLE_COMMAND_STACK_TRACES = COMMAND_STACK_TRACES;
CommandSyntaxException.BUILT_IN_EXCEPTIONS = new BrigadierExceptions();
@@ -1,6 +1,6 @@
--- a/net/minecraft/Util.java
+++ b/net/minecraft/Util.java
@@ -268,7 +_,7 @@
@@ -266,7 +_,7 @@
.getSchema(DataFixUtils.makeKey(SharedConstants.getCurrentVersion().dataVersion().version()))
.getChoiceType(p_137552_, p_137553_);
} catch (IllegalArgumentException illegalargumentexception) {
@@ -1,6 +1,6 @@
--- a/net/minecraft/advancements/Advancement.java
+++ b/net/minecraft/advancements/Advancement.java
@@ -226,7 +_,11 @@
@@ -233,7 +_,11 @@
}
public AdvancementHolder save(Consumer<AdvancementHolder> p_138390_, String p_138391_) {
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/Camera.java
+++ b/net/minecraft/client/Camera.java
@@ -133,9 +_,13 @@
@@ -132,9 +_,13 @@
}
protected void setRotation(float p_90573_, float p_90574_) {
@@ -15,7 +15,7 @@
FORWARDS.rotate(this.rotation, this.forwards);
UP.rotate(this.rotation, this.up);
LEFT.rotate(this.rotation, this.left);
@@ -251,6 +_,13 @@
@@ -250,6 +_,13 @@
public float getPartialTickTime() {
return this.partialTickTime;
@@ -1,35 +1,27 @@
--- a/net/minecraft/client/KeyMapping.java
+++ b/net/minecraft/client/KeyMapping.java
@@ -15,9 +_,9 @@
@@ -19,9 +_,9 @@
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
-public class KeyMapping implements Comparable<KeyMapping> {
+public class KeyMapping implements Comparable<KeyMapping>, net.minecraftforge.client.extensions.IForgeKeyMapping {
private static final Map<String, KeyMapping> ALL = Maps.newHashMap();
- private static final Map<InputConstants.Key, KeyMapping> MAP = Maps.newHashMap();
- private static final Map<InputConstants.Key, List<KeyMapping>> MAP = Maps.newHashMap();
+ private static final net.minecraftforge.client.settings.KeyMappingLookup MAP = new net.minecraftforge.client.settings.KeyMappingLookup();
private static final Set<String> CATEGORIES = Sets.newHashSet();
public static final String CATEGORY_MOVEMENT = "key.categories.movement";
public static final String CATEGORY_MISC = "key.categories.misc";
@@ -43,14 +_,14 @@
private int clickCount;
public static void click(InputConstants.Key p_90836_) {
- KeyMapping keymapping = MAP.get(p_90836_);
+ for (KeyMapping keymapping : MAP.getAll(p_90836_))
if (keymapping != null) {
keymapping.clickCount++;
}
private final String name;
private final InputConstants.Key defaultKey;
private final KeyMapping.Category category;
@@ -38,7 +_,7 @@
}
public static void set(InputConstants.Key p_90838_, boolean p_90839_) {
- KeyMapping keymapping = MAP.get(p_90838_);
+ for (KeyMapping keymapping : MAP.getAll(p_90838_))
if (keymapping != null) {
keymapping.setDown(p_90839_);
}
@@ -101,7 +_,7 @@
private static void forAllKeyMappings(InputConstants.Key p_424096_, Consumer<KeyMapping> p_427756_) {
- List<KeyMapping> list = MAP.get(p_424096_);
+ List<KeyMapping> list = MAP.getAll(p_424096_);
if (list != null && !list.isEmpty()) {
for (KeyMapping keymapping : list) {
p_427756_.accept(keymapping);
@@ -100,7 +_,7 @@
}
public boolean isDown() {
@@ -37,26 +29,26 @@
+ return this.isDown && isConflictContextAndModifierActive();
}
public String getCategory() {
@@ -137,7 +_,16 @@
public KeyMapping.Category getCategory() {
@@ -140,7 +_,16 @@
public int compareTo(KeyMapping p_90841_) {
return this.category.equals(p_90841_.category)
return this.category == p_90841_.category
? I18n.get(this.name).compareTo(I18n.get(p_90841_.name))
- : CATEGORY_SORT_ORDER.get(this.category).compareTo(CATEGORY_SORT_ORDER.get(p_90841_.category));
- : Integer.compare(KeyMapping.Category.SORT_ORDER.indexOf(this.category), KeyMapping.Category.SORT_ORDER.indexOf(p_90841_.category));
+ : compareSort(this.category, p_90841_.category);
+ }
+
+ private static int compareSort(String c1, String c2) {
+ Integer o1 = CATEGORY_SORT_ORDER.get(c1);
+ Integer o2 = CATEGORY_SORT_ORDER.get(c2);
+ if (o1 == null && o2 != null) return 1;
+ if (o1 != null && o2 == null) return -1;
+ if (o1 == null && o2 == null) return I18n.get(c1).compareTo(I18n.get(c2));
+ return o1.compareTo(o2);
+ private static int compareSort(Category c1, Category c2) {
+ int o1 = KeyMapping.Category.SORT_ORDER.indexOf(c1);
+ int o2 = KeyMapping.Category.SORT_ORDER.indexOf(c2);
+ if (o1 == -1 && o2 != -1) return 1;
+ if (o1 != -1 && o2 == -1) return -1;
+ if (o1 == -1 && o2 == -1) return I18n.get(c1.id().toLanguageKey("key.category")).compareTo(I18n.get(c1.id().toLanguageKey("key.category")));
+ return o1 - o2;
}
public static Supplier<Component> createNameSupplier(String p_90843_) {
@@ -146,6 +_,20 @@
@@ -149,6 +_,20 @@
}
public boolean same(KeyMapping p_90851_) {
@@ -77,7 +69,7 @@
return this.key.equals(p_90851_.key);
}
@@ -164,11 +_,13 @@
@@ -167,11 +_,13 @@
}
public Component getTranslatedKeyMessage() {
@@ -92,7 +84,14 @@
}
public String saveString() {
@@ -182,5 +_,88 @@
@@ -183,12 +_,94 @@
}
private void registerMapping(InputConstants.Key p_423386_) {
- MAP.computeIfAbsent(p_423386_, p_420623_ -> new ArrayList<>()).add(this);
+ MAP.put(p_423386_, this);
}
@Nullable
public static KeyMapping get(String p_378660_) {
return ALL.get(p_378660_);
@@ -105,28 +104,28 @@
+ /**
+ * Convenience constructor for creating KeyBindings with keyConflictContext set.
+ */
+ public KeyMapping(String description, net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext, final InputConstants.Type inputType, final int keyCode, String category) {
+ public KeyMapping(String description, net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext, final InputConstants.Type inputType, final int keyCode, Category category) {
+ this(description, keyConflictContext, inputType.getOrCreate(keyCode), category);
+ }
+
+ /**
+ * Convenience constructor for creating KeyBindings with keyConflictContext set.
+ */
+ public KeyMapping(String description, net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext, InputConstants.Key keyCode, String category) {
+ public KeyMapping(String description, net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext, InputConstants.Key keyCode, Category category) {
+ this(description, keyConflictContext, net.minecraftforge.client.settings.KeyModifier.NONE, keyCode, category);
+ }
+
+ /**
+ * Convenience constructor for creating KeyBindings with keyConflictContext and keyModifier set.
+ */
+ public KeyMapping(String description, net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext, net.minecraftforge.client.settings.KeyModifier keyModifier, final InputConstants.Type inputType, final int keyCode, String category) {
+ public KeyMapping(String description, net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext, net.minecraftforge.client.settings.KeyModifier keyModifier, final InputConstants.Type inputType, final int keyCode, Category category) {
+ this(description, keyConflictContext, keyModifier, inputType.getOrCreate(keyCode), category);
+ }
+
+ /**
+ * Convenience constructor for creating KeyBindings with keyConflictContext and keyModifier set.
+ */
+ public KeyMapping(String description, net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext, net.minecraftforge.client.settings.KeyModifier keyModifier, InputConstants.Key keyCode, String category) {
+ public KeyMapping(String description, net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext, net.minecraftforge.client.settings.KeyModifier keyModifier, InputConstants.Key keyCode, Category category) {
+ this.name = description;
+ this.key = keyCode;
+ this.defaultKey = keyCode;
@@ -138,7 +137,6 @@
+ this.keyModifier = net.minecraftforge.client.settings.KeyModifier.NONE;
+ ALL.put(description, this);
+ MAP.put(keyCode, this);
+ CATEGORIES.add(category);
+ }
+
+ @Override
@@ -180,4 +178,5 @@
+
+ MAP.put(keyCode, this);
}
}
@OnlyIn(Dist.CLIENT)
@@ -1,39 +1,34 @@
--- a/net/minecraft/client/KeyboardHandler.java
+++ b/net/minecraft/client/KeyboardHandler.java
@@ -440,12 +_,12 @@
@@ -499,12 +_,12 @@
if (screen != null) {
try {
if (p_90897_ != 1 && p_90897_ != 2) {
- if (p_90897_ == 0 && screen.keyReleased(p_90895_, p_90896_, p_90898_)) {
+ if (p_90897_ == 0 && net.minecraftforge.client.ForgeHooksClient.onScreenKeyReleased(screen, p_90895_, p_90896_, p_90898_)) {
if (p_90895_ != 1 && p_90895_ != 2) {
- if (p_90895_ == 0 && screen.keyReleased(p_423534_)) {
+ if (p_90895_ == 0 && net.minecraftforge.client.ForgeHooksClient.onScreenKeyReleased(screen, p_423534_)) {
return;
}
} else {
screen.afterKeyboardAction();
- if (screen.keyPressed(p_90895_, p_90896_, p_90898_)) {
+ if (net.minecraftforge.client.ForgeHooksClient.onScreenKeyPressed(screen, p_90895_, p_90896_, p_90898_)) {
return;
}
}
@@ -504,6 +_,7 @@
- if (screen.keyPressed(p_423534_)) {
+ if (net.minecraftforge.client.ForgeHooksClient.onScreenKeyPressed(screen, p_423534_)) {
if (this.minecraft.screen == null) {
InputConstants.Key inputconstants$key = InputConstants.getKey(p_423534_);
KeyMapping.set(inputconstants$key, false);
@@ -568,6 +_,7 @@
}
}
}
+ net.minecraftforge.client.ForgeHooksClient.onKeyInput(p_90895_, p_90896_, p_90897_, p_90898_);
+ net.minecraftforge.client.ForgeHooksClient.onKeyInput(p_423534_, p_90895_);
}
}
@@ -513,10 +_,10 @@
@@ -576,7 +_,7 @@
Screen screen = this.minecraft.screen;
if (screen != null && this.minecraft.getOverlay() == null) {
try {
if (Character.isBmpCodePoint(p_90891_)) {
- screen.charTyped((char)p_90891_, p_90892_);
+ net.minecraftforge.client.ForgeHooksClient.onScreenCharTyped(screen, (char)p_90891_, p_90892_);
} else if (Character.isValidCodePoint(p_90891_)) {
- screen.charTyped(Character.highSurrogate(p_90891_), p_90892_);
- screen.charTyped(Character.lowSurrogate(p_90891_), p_90892_);
+ net.minecraftforge.client.ForgeHooksClient.onScreenCharTyped(screen, Character.highSurrogate(p_90891_), p_90892_);
+ net.minecraftforge.client.ForgeHooksClient.onScreenCharTyped(screen, Character.lowSurrogate(p_90891_), p_90892_);
}
- screen.charTyped(p_427531_);
+ net.minecraftforge.client.ForgeHooksClient.onScreenCharTyped(screen, p_427531_);
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "charTyped event handler");
screen.fillCrashDetails(crashreport);
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/Minecraft.java
+++ b/net/minecraft/client/Minecraft.java
@@ -256,7 +_,7 @@
@@ -260,7 +_,7 @@
import org.slf4j.Logger;
@OnlyIn(Dist.CLIENT)
@@ -8,8 +8,8 @@
+public class Minecraft extends ReentrantBlockableEventLoop<Runnable> implements WindowEventHandler, net.minecraftforge.client.extensions.IForgeMinecraft {
static Minecraft instance;
private static final Logger LOGGER = LogUtils.getLogger();
public static final boolean ON_OSX = Util.getPlatform() == Util.OS.OSX;
@@ -435,7 +_,6 @@
private static final int MAX_TICKS_PER_UPDATE = 10;
@@ -439,7 +_,6 @@
}
}, Util.nonCriticalIoPool());
LOGGER.info("Setting user: {}", this.user.getName());
@@ -17,19 +17,19 @@
this.demo = p_91084_.game.demo;
this.allowsMultiplayer = !p_91084_.game.disableMultiplayer;
this.allowsChat = !p_91084_.game.disableChat;
@@ -486,10 +_,9 @@
@@ -491,10 +_,9 @@
LOGGER.error("Couldn't set icon", (Throwable)ioexception);
}
+ // FORGE: Move mouse and keyboard handler setup further below
this.mouseHandler = new MouseHandler(this);
- this.mouseHandler.setup(this.window.getWindow());
- this.mouseHandler.setup(this.window);
this.keyboardHandler = new KeyboardHandler(this);
- this.keyboardHandler.setup(this.window.getWindow());
- this.keyboardHandler.setup(this.window);
RenderSystem.initRenderer(
this.window.getWindow(),
this.window.handle(),
this.options.glDebugVerbosity,
@@ -500,6 +_,7 @@
@@ -505,6 +_,7 @@
LOGGER.info("Using optional rendering extensions: {}", String.join(", ", RenderSystem.getDevice().getEnabledExtensions()));
this.mainRenderTarget = new MainTarget(this.window.getWidth(), this.window.getHeight());
this.resourceManager = new ReloadableResourceManager(PackType.CLIENT_RESOURCES);
@@ -37,33 +37,33 @@
this.resourcePackRepository.reload();
this.options.loadSelectedResourcePacks(this.resourcePackRepository);
this.languageManager = new LanguageManager(this.options.languageCode, p_340763_ -> {
@@ -578,6 +_,7 @@
this.blockEntityRenderDispatcher = new BlockEntityRenderDispatcher(this.font, this.modelManager.entityModels(), this.blockRenderer, this.itemModelResolver, this.itemRenderer, this.entityRenderDispatcher);
this.resourceManager.registerReloadListener(this.blockEntityRenderDispatcher);
this.particleEngine = new ParticleEngine(this.level, this.textureManager);
+ net.minecraftforge.client.ForgeHooksClient.onRegisterParticleProviders(this.particleEngine);
this.resourceManager.registerReloadListener(this.particleEngine);
this.paintingTextures = new PaintingTextureManager(this.textureManager);
this.resourceManager.registerReloadListener(this.paintingTextures);
@@ -593,6 +_,9 @@
@@ -593,6 +_,7 @@
this.particleResources = new ParticleResources();
this.resourceManager.registerReloadListener(this.particleResources);
this.particleEngine = new ParticleEngine(this.level, this.particleResources);
+ net.minecraftforge.client.ForgeHooksClient.onRegisterParticleProviders(this.particleResources);
this.particleResources.onReload(this.particleEngine::clearParticles);
this.waypointStyles = new WaypointStyleManager();
this.resourceManager.registerReloadListener(this.waypointStyles);
@@ -604,6 +_,9 @@
this.resourceManager.registerReloadListener(this.gpuWarnlistManager);
this.resourceManager.registerReloadListener(this.regionalCompliancies);
this.gui = new Gui(this);
+ // FORGE: Moved keyboard and mouse handler setup below ingame gui creation to prevent NPEs in them.
+ this.mouseHandler.setup(this.window.getWindow());
+ this.keyboardHandler.setup(this.window.getWindow());
this.debugRenderer = new DebugRenderer(this);
+ this.mouseHandler.setup(this.window);
+ this.keyboardHandler.setup(this.window);
RealmsClient realmsclient = RealmsClient.getOrCreate(this);
this.realmsDataFetcher = new RealmsDataFetcher(realmsclient);
@@ -626,6 +_,7 @@
RenderSystem.setErrorCallback(this::onFullscreenError);
@@ -636,6 +_,7 @@
}
}
+ net.minecraftforge.client.ForgeHooksClient.initClientHooks(this, this.resourceManager);
this.window.updateVsync(this.options.enableVsync().get());
this.window.updateRawMouseInput(this.options.rawMouseInput().get());
this.window.setDefaultErrorCallback();
@@ -648,16 +_,17 @@
this.window.setAllowCursorChanges(this.options.allowCursorChanges().get());
@@ -659,16 +_,17 @@
GameLoadTimesEvent.INSTANCE.beginStep(TelemetryProperty.LOAD_TIME_LOADING_OVERLAY_MS);
Minecraft.GameLoadCookie minecraft$gameloadcookie = new Minecraft.GameLoadCookie(realmsclient, p_91084_.quickPlay);
this.setOverlay(
@@ -84,7 +84,7 @@
);
this.quickPlayLog = QuickPlayLog.of(p_91084_.quickPlay.logPath());
this.framerateLimitTracker = new FramerateLimitTracker(this.options, this);
@@ -759,6 +_,7 @@
@@ -787,6 +_,7 @@
StringBuilder stringbuilder = new StringBuilder("Minecraft");
if (checkModStatus().shouldReportAsModified()) {
stringbuilder.append("*");
@@ -92,16 +92,16 @@
}
stringbuilder.append(" ");
@@ -782,6 +_,8 @@
@@ -810,6 +_,8 @@
}
private UserApiService createUserApiService(YggdrasilAuthenticationService p_193586_, GameConfig p_193587_) {
+ if ("0".equals(p_193587_.user.user.getAccessToken())) // Forge: We use "0" in dev. Short circuit to stop exception spam.
+ return UserApiService.OFFLINE;
return p_193587_.user.user.getType() != User.Type.MSA
? UserApiService.OFFLINE
: p_193586_.createUserApiService(p_193587_.user.user.getAccessToken());
@@ -792,7 +_,7 @@
return p_193587_.game.offlineDeveloperMode ? UserApiService.OFFLINE : p_193586_.createUserApiService(p_193587_.user.user.getAccessToken());
}
@@ -822,7 +_,7 @@
}
private void rollbackResourcePacks(Throwable p_91240_, @Nullable Minecraft.GameLoadCookie p_299515_) {
@@ -110,7 +110,7 @@
this.clearResourcePacksOnError(p_91240_, null, p_299515_);
} else {
Util.throwAsRuntime(p_91240_);
@@ -1078,12 +_,6 @@
@@ -1108,12 +_,6 @@
LOGGER.error("setScreen called from non-game thread");
}
@@ -120,34 +120,34 @@
- this.setLastInputType(InputType.NONE);
- }
-
if (p_91153_ == null && this.clientLevelTeardownInProgress) {
throw new IllegalStateException("Trying to return to in-game GUI during disconnection");
} else {
@@ -1097,6 +_,23 @@
}
if (p_91153_ == null) {
if (this.clientLevelTeardownInProgress) {
throw new IllegalStateException("Trying to return to in-game GUI during disconnection");
@@ -1132,6 +_,23 @@
}
}
+ net.minecraftforge.client.ForgeHooksClient.clearGuiLayers(this);
+ Screen old = this.screen;
+ if (p_91153_ != null) {
+ var event = net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenOpening(old, p_91153_);
+ if (event == null) return;
+ p_91153_ = event;
+ }
+ net.minecraftforge.client.ForgeHooksClient.clearGuiLayers(this);
+ Screen old = this.screen;
+ if (p_91153_ != null) {
+ var event = net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenOpening(old, p_91153_);
+ if (event == null) return;
+ p_91153_ = event;
+ }
+
+ if (p_91153_ != old) {
+ if (old != null) {
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenClose(old);
+ old.removed();
+ } else {
+ this.setLastInputType(InputType.NONE);
+ }
+ if (p_91153_ != old) {
+ if (old != null) {
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenClose(old);
+ old.removed();
+ } else {
+ this.setLastInputType(InputType.NONE);
+ }
+ }
+
this.screen = p_91153_;
if (this.screen != null) {
this.screen.added();
@@ -1180,6 +_,7 @@
this.screen = p_91153_;
if (this.screen != null) {
this.screen.added();
@@ -1214,6 +_,7 @@
FreeTypeUtil.destroy();
Util.shutdownExecutors();
RenderSystem.getDevice().close();
@@ -155,19 +155,17 @@
} catch (Throwable throwable) {
LOGGER.error("Shutdown failure!", throwable);
throw throwable;
@@ -1248,9 +_,11 @@
this.mouseHandler.handleAccumulatedMovement();
profilerfiller.pop();
@@ -1278,7 +_,9 @@
RenderSystem.getDevice().createCommandEncoder().clearColorAndDepthTextures(rendertarget.getColorTexture(), 0, rendertarget.getDepthTexture(), 1.0);
profilerfiller.push("gameRenderer");
if (!this.noRender) {
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderTickStart(this.deltaTracker);
profilerfiller.popPush("gameRenderer");
this.gameRenderer.render(this.deltaTracker, p_91384_);
profilerfiller.pop();
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderTickEnd(this.deltaTracker);
}
profilerfiller.push("blit");
@@ -1379,10 +_,12 @@
profilerfiller.popPush("blit");
@@ -1388,10 +_,12 @@
this.window.setGuiScale(i);
if (this.screen != null) {
this.screen.resize(this, this.window.getGuiScaledWidth(), this.window.getGuiScaledHeight());
@@ -180,7 +178,7 @@
this.gameRenderer.resize(this.window.getWidth(), this.window.getHeight());
this.mouseHandler.setIgnoreFirstMove();
}
@@ -1520,6 +_,7 @@
@@ -1529,6 +_,7 @@
}
public void stop() {
@@ -188,7 +186,7 @@
this.running = false;
}
@@ -1547,10 +_,18 @@
@@ -1556,10 +_,18 @@
if (p_91387_ && this.hitResult != null && this.hitResult.getType() == HitResult.Type.BLOCK) {
BlockHitResult blockhitresult = (BlockHitResult)this.hitResult;
BlockPos blockpos = blockhitresult.getBlockPos();
@@ -197,20 +195,20 @@
+ var inputEvent = new net.minecraftforge.client.event.InputEvent.InteractionKeyMappingTriggered(0, this.options.keyAttack, InteractionHand.MAIN_HAND);
+ if (net.minecraftforge.client.event.InputEvent.InteractionKeyMappingTriggered.BUS.post(inputEvent)) {
+ if (inputEvent.shouldSwingHand()) {
+ this.particleEngine.addBlockHitEffects(blockpos, blockhitresult);
+ this.level.addBreakingBlockEffect(blockpos, blockhitresult);
+ this.player.swing(InteractionHand.MAIN_HAND);
+ }
+ return;
+ }
Direction direction = blockhitresult.getDirection();
- if (this.gameMode.continueDestroyBlock(blockpos, direction)) {
- this.particleEngine.crack(blockpos, direction);
- this.level.addBreakingBlockEffect(blockpos, direction);
+ if (this.gameMode.continueDestroyBlock(blockpos, direction) && inputEvent.shouldSwingHand()) {
+ this.particleEngine.addBlockHitEffects(blockpos, blockhitresult);
+ this.level.addBreakingBlockEffect(blockpos, blockhitresult);
this.player.swing(InteractionHand.MAIN_HAND);
}
}
@@ -1578,6 +_,8 @@
@@ -1587,6 +_,8 @@
return false;
} else {
boolean flag = false;
@@ -219,7 +217,7 @@
switch (this.hitResult.getType()) {
case ENTITY:
this.gameMode.attack(this.player, ((EntityHitResult)this.hitResult).getEntity());
@@ -1585,7 +_,7 @@
@@ -1594,7 +_,7 @@
case BLOCK:
BlockHitResult blockhitresult = (BlockHitResult)this.hitResult;
BlockPos blockpos = blockhitresult.getBlockPos();
@@ -228,7 +226,7 @@
this.gameMode.startDestroyBlock(blockpos, blockhitresult.getDirection());
if (this.level.getBlockState(blockpos).isAir()) {
flag = true;
@@ -1598,8 +_,10 @@
@@ -1607,8 +_,10 @@
}
this.player.resetAttackStrengthTicker();
@@ -239,7 +237,7 @@
this.player.swing(InteractionHand.MAIN_HAND);
return flag;
}
@@ -1615,6 +_,12 @@
@@ -1624,6 +_,12 @@
}
for (InteractionHand interactionhand : InteractionHand.values()) {
@@ -252,7 +250,7 @@
ItemStack itemstack = this.player.getItemInHand(interactionhand);
if (!itemstack.isItemEnabled(this.level.enabledFeatures())) {
return;
@@ -1635,7 +_,7 @@
@@ -1644,7 +_,7 @@
}
if (interactionresult instanceof InteractionResult.Success interactionresult$success2) {
@@ -261,7 +259,7 @@
this.player.swing(interactionhand);
}
@@ -1647,7 +_,7 @@
@@ -1656,7 +_,7 @@
int i = itemstack.getCount();
InteractionResult interactionresult1 = this.gameMode.useItemOn(this.player, interactionhand, blockhitresult);
if (interactionresult1 instanceof InteractionResult.Success interactionresult$success) {
@@ -270,7 +268,7 @@
this.player.swing(interactionhand);
if (!itemstack.isEmpty() && (itemstack.getCount() != i || this.player.hasInfiniteMaterials())) {
this.gameRenderer.itemInHandRenderer.itemUsed(interactionhand);
@@ -1663,6 +_,9 @@
@@ -1672,6 +_,9 @@
}
}
@@ -280,7 +278,7 @@
if (!itemstack.isEmpty()
&& this.gameMode.useItem(this.player, interactionhand) instanceof InteractionResult.Success interactionresult$success1) {
if (interactionresult$success1.swingSource() == InteractionResult.SwingSource.CLIENT) {
@@ -1692,6 +_,8 @@
@@ -1701,6 +_,8 @@
}
ProfilerFiller profilerfiller = Profiler.get();
@@ -289,7 +287,7 @@
profilerfiller.push("gui");
this.chatListener.tick();
this.gui.tick(this.pause);
@@ -1778,6 +_,7 @@
@@ -1786,6 +_,7 @@
this.tutorial.tick();
@@ -297,7 +295,7 @@
try {
this.level.tick(() -> true);
} catch (Throwable throwable1) {
@@ -1791,6 +_,7 @@
@@ -1799,6 +_,7 @@
throw new ReportedException(crashreport1);
}
@@ -305,7 +303,7 @@
}
profilerfiller.popPush("animateTick");
@@ -1815,6 +_,7 @@
@@ -1823,6 +_,7 @@
profilerfiller.popPush("keyboard");
this.keyboardHandler.tick();
profilerfiller.pop();
@@ -313,15 +311,15 @@
}
private boolean isLevelRunningNormally() {
@@ -2031,6 +_,7 @@
@@ -2041,6 +_,7 @@
}
public void setLevel(ClientLevel p_91157_, ReceivingLevelScreen.Reason p_335893_) {
public void setLevel(ClientLevel p_91157_) {
+ if (this.level != null) net.minecraftforge.event.ForgeEventFactory.onLevelUnload(this.level);
this.updateScreenAndTick(new ReceivingLevelScreen(() -> false, p_335893_));
this.level = p_91157_;
this.updateLevelInEngines(p_91157_);
@@ -2068,6 +_,7 @@
}
@@ -2094,6 +_,7 @@
IntegratedServer integratedserver = this.singleplayerServer;
this.singleplayerServer = null;
this.gameRenderer.resetData();
@@ -329,27 +327,27 @@
this.gameMode = null;
this.narrator.clear();
this.clientLevelTeardownInProgress = true;
@@ -2075,6 +_,7 @@
@@ -2101,6 +_,7 @@
try {
this.updateScreenAndTick(p_335030_);
if (this.level != null) {
+ net.minecraftforge.event.ForgeEventFactory.onLevelUnload(this.level);
if (integratedserver != null) {
ProfilerFiller profilerfiller = Profiler.get();
profilerfiller.push("waitForServer");
@@ -2088,6 +_,7 @@
this.gui.onDisconnected();
this.isLocalServer = false;
+ net.minecraftforge.event.ForgeEventFactory.onLevelUnload(this.level);
}
if (integratedserver != null) {
@@ -2113,6 +_,7 @@
}
profilerfiller.pop();
+ net.minecraftforge.client.ForgeHooksClient.handleClientLevelClosing(this.level);
}
this.level = null;
@@ -2236,6 +_,7 @@
this.setScreenAndShow(p_335030_);
@@ -2254,6 +_,7 @@
private void pickBlock() {
if (this.hitResult != null && this.hitResult.getType() != HitResult.Type.MISS) {
+ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onClickInputPickBlock(this.options.keyPickItem)) return;
boolean flag = Screen.hasControlDown();
boolean flag = this.hasControlDown();
switch (this.hitResult) {
case BlockHitResult blockhitresult:
@@ -1,40 +1,40 @@
--- a/net/minecraft/client/MouseHandler.java
+++ b/net/minecraft/client/MouseHandler.java
@@ -90,6 +_,7 @@
this.activeButton = -1;
@@ -87,6 +_,7 @@
this.activeButton = null;
}
+ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onMouseButtonPre(p_91532_, p_91533_, p_91534_)) return;
+ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onMouseButtonPre(mousebuttoninfo.button(), p_423948_, mousebuttoninfo.modifiers())) return;
if (this.minecraft.getOverlay() == null) {
if (this.minecraft.screen == null) {
if (!this.mouseGrabbed && flag) {
@@ -103,7 +_,7 @@
screen.afterMouseAction();
try {
- if (screen.mouseClicked(d0, d1, i)) {
+ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenMouseClicked(screen, d0, d1, i)) {
long i = Util.getMillis();
boolean flag1 = i - this.lastClickTime < 250L && this.lastClickButton == mousebuttonevent.button();
- if (screen.mouseClicked(mousebuttonevent, flag1)) {
+ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenMouseClicked(screen, d0, d1, mousebuttonevent, flag1)) {
this.lastClickTime = i;
this.lastClickButton = mousebuttoninfo.button();
return;
}
} catch (Throwable throwable1) {
@@ -116,7 +_,7 @@
@@ -118,7 +_,7 @@
}
} else {
try {
- if (screen.mouseReleased(d0, d1, i)) {
+ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenMouseReleased(screen, d0, d1, i)) {
- if (screen.mouseReleased(mousebuttonevent)) {
+ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenMouseReleased(screen, d0, d1, mousebuttonevent)) {
return;
}
} catch (Throwable throwable) {
@@ -150,6 +_,7 @@
@@ -148,6 +_,7 @@
KeyMapping.click(inputconstants$key);
}
}
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onMouseButtonPost(mousebuttoninfo.button(), p_423948_, mousebuttoninfo.modifiers());
}
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onMouseButtonPost(p_91532_, p_91533_, p_91534_);
}
public void fillMousePositionDetails(CrashReportCategory p_398230_, Window p_398216_) {
@@ -189,7 +_,9 @@
@@ -204,7 +_,9 @@
if (this.minecraft.screen != null) {
double d3 = this.getScaledXPos(this.minecraft.getWindow());
double d4 = this.getScaledYPos(this.minecraft.getWindow());
@@ -45,7 +45,7 @@
this.minecraft.screen.afterMouseAction();
} else if (this.minecraft.player != null) {
Vector2i vector2i = this.scrollWheelHandler.onMouseScroll(d1, d2);
@@ -198,6 +_,7 @@
@@ -213,6 +_,7 @@
}
int i = vector2i.y == 0 ? -vector2i.x : vector2i.y;
@@ -53,16 +53,16 @@
if (this.minecraft.player.isSpectator()) {
if (this.minecraft.gui.getSpectatorGui().isMenuActive()) {
this.minecraft.gui.getSpectatorGui().onMouseScrolled(-i);
@@ -303,7 +_,7 @@
@@ -321,7 +_,7 @@
double d5 = getScaledYPos(window, this.accumulatedDY);
try {
- screen.mouseDragged(d2, d3, this.activeButton, d4, d5);
+ net.minecraftforge.client.ForgeHooksClient.onScreenMouseDrag(screen, d2, d3, this.activeButton, d4, d5);
- screen.mouseDragged(new MouseButtonEvent(d2, d3, this.activeButton), d4, d5);
+ net.minecraftforge.client.ForgeHooksClient.onScreenMouseDrag(screen, new MouseButtonEvent(d2, d3, this.activeButton), d4, d5);
} catch (Throwable throwable) {
CrashReport crashreport1 = CrashReport.forThrowable(throwable, "mouseDragged event handler");
screen.fillCrashDetails(crashreport1);
@@ -393,6 +_,14 @@
@@ -408,6 +_,14 @@
public double ypos() {
return this.ypos;
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/Options.java
+++ b/net/minecraft/client/Options.java
@@ -671,7 +_,8 @@
@@ -709,7 +_,8 @@
},
new OptionInstance.LazyEnum<>(
() -> Stream.concat(Stream.of(""), Minecraft.getInstance().getSoundManager().getAvailableSoundDevices().stream()).toList(),
@@ -10,7 +10,7 @@
? Optional.empty()
: Optional.of(p_232011_),
Codec.STRING
@@ -705,6 +_,7 @@
@@ -743,6 +_,7 @@
);
public boolean syncWrites;
public boolean startedCleanly = true;
@@ -18,7 +18,7 @@
public OptionInstance<Boolean> darkMojangStudiosBackground() {
return this.darkMojangStudiosBackground;
@@ -1088,6 +_,7 @@
@@ -1150,6 +_,7 @@
}
public Options(Minecraft p_92138_, File p_92139_) {
@@ -26,7 +26,7 @@
this.minecraft = p_92138_;
this.optionsFile = new File(p_92139_, "options.txt");
boolean flag = Runtime.getRuntime().maxMemory() >= 1000000000L;
@@ -1222,15 +_,28 @@
@@ -1290,15 +_,28 @@
this.startedCleanly = p_168428_.process("startedCleanly", this.startedCleanly);
p_168428_.process("showNowPlayingToast", this.showNowPlayingToast);
p_168428_.process("musicFrequency", this.musicFrequency);
@@ -56,7 +56,7 @@
for (SoundSource soundsource : SoundSource.values()) {
p_168428_.process("soundCategory_" + soundsource.getName(), this.soundSourceVolumes.get(soundsource));
}
@@ -1245,6 +_,10 @@
@@ -1313,6 +_,10 @@
}
public void load() {
@@ -67,7 +67,7 @@
try {
if (!this.optionsFile.exists()) {
return;
@@ -1269,7 +_,8 @@
@@ -1337,7 +_,8 @@
this.graphicsMode.set(isTrue(optional.get()) ? GraphicsStatus.FANCY : GraphicsStatus.FAST);
}
@@ -77,7 +77,7 @@
new Options.FieldAccess() {
@Nullable
private String getValue(String p_394210_) {
@@ -1350,6 +_,17 @@
@@ -1418,6 +_,17 @@
);
compoundtag1.getString("fullscreenResolution").ifPresent(p_389133_ -> this.fullscreenVideoModeString = p_389133_);
KeyMapping.resetMapping();
@@ -95,7 +95,7 @@
} catch (Exception exception) {
LOGGER.error("Failed to load options", (Throwable)exception);
}
@@ -1377,9 +_,11 @@
@@ -1445,9 +_,11 @@
public void save() {
try (final PrintWriter printwriter = new PrintWriter(new OutputStreamWriter(new FileOutputStream(this.optionsFile), StandardCharsets.UTF_8))) {
printwriter.println("version:" + SharedConstants.getCurrentVersion().dataVersion().version());
@@ -107,7 +107,7 @@
printwriter.print(p_168491_);
printwriter.print(':');
}
@@ -1435,6 +_,12 @@
@@ -1503,6 +_,12 @@
if (s != null) {
printwriter.println("fullscreenResolution:" + s);
}
@@ -120,7 +120,7 @@
} catch (Exception exception) {
LOGGER.error("Failed to save options", (Throwable)exception);
}
@@ -1473,6 +_,7 @@
@@ -1541,6 +_,7 @@
}
public void broadcastOptions() {
@@ -128,7 +128,7 @@
if (this.minecraft.player != null) {
this.minecraft.player.connection.broadcastClientInformation(this.buildPlayerInformation());
}
@@ -1586,6 +_,23 @@
@@ -1654,6 +_,23 @@
public static Component genericValueLabel(Component p_231901_, int p_231902_) {
return genericValueLabel(p_231901_, Component.literal(Integer.toString(p_231902_)));
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/ToggleKeyMapping.java
+++ b/net/minecraft/client/ToggleKeyMapping.java
@@ -17,7 +_,7 @@
@@ -31,7 +_,7 @@
@Override
public void setDown(boolean p_92534_) {
if (this.needsToggle.getAsBoolean()) {
@@ -9,7 +9,7 @@
super.setDown(!this.isDown());
}
} else {
@@ -27,5 +_,9 @@
@@ -56,5 +_,9 @@
protected void reset() {
super.setDown(false);
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/data/models/ItemModelGenerators.java
+++ b/net/minecraft/client/data/models/ItemModelGenerators.java
@@ -870,6 +_,9 @@
@@ -882,6 +_,9 @@
this.declareCustomModelItem(Items.COD);
this.declareCustomModelItem(Items.FEATHER);
this.declareCustomModelItem(Items.LEAD);
@@ -1,11 +1,11 @@
--- a/net/minecraft/client/gui/Font.java
+++ b/net/minecraft/client/gui/Font.java
@@ -32,7 +_,7 @@
@@ -31,7 +_,7 @@
import org.joml.Matrix4f;
@OnlyIn(Dist.CLIENT)
-public class Font {
+public class Font implements net.minecraftforge.client.extensions.IForgeFont {
private static final float EFFECT_DEPTH = 0.001F;
private static final float OVER_EFFECT_DEPTH = 0.001F;
private static final float UNDER_EFFECT_DEPTH = -0.001F;
private static final float EFFECT_DEPTH = 0.01F;
private static final float OVER_EFFECT_DEPTH = 0.01F;
private static final float UNDER_EFFECT_DEPTH = -0.01F;
@@ -9,7 +9,26 @@
private final SubtitleOverlay subtitleOverlay;
private final SpectatorGui spectatorGui;
private final PlayerTabOverlay tabList;
@@ -377,7 +_,7 @@
@@ -196,6 +_,7 @@
() -> new JumpableVehicleBarRenderer(p_330021_)
);
this.resetTitleTimes();
+ net.minecraftforge.client.gui.overlay.ForgeLayeredDraw.init(this, p_330021_);
}
public void resetTitleTimes() {
@@ -206,6 +_,10 @@
public void render(GuiGraphics p_282884_, DeltaTracker p_342095_) {
if (!(this.minecraft.screen instanceof LevelLoadingScreen)) {
+ if (Boolean.valueOf(true)) {
+ net.minecraftforge.client.gui.overlay.ForgeLayeredDraw.beginRender(p_282884_, p_342095_);
+ return;
+ }
if (!this.minecraft.options.hideGui) {
this.renderCameraOverlays(p_282884_, p_342095_);
this.renderCrosshair(p_282884_, p_342095_);
@@ -389,7 +_,7 @@
int i = Mth.floor(this.minecraft.mouseHandler.getScaledXPos(window));
int j = Mth.floor(this.minecraft.mouseHandler.getScaledYPos(window));
p_329202_.nextStratum();
@@ -18,7 +37,7 @@
}
}
@@ -472,6 +_,8 @@
@@ -477,6 +_,8 @@
for (MobEffectInstance mobeffectinstance : Ordering.natural().reverse().sortedCopy(collection)) {
Holder<MobEffect> holder = mobeffectinstance.getEffect();
@@ -27,7 +46,7 @@
if (mobeffectinstance.showIcon()) {
int k = p_282812_.guiWidth();
int l = 1;
@@ -502,6 +_,7 @@
@@ -507,6 +_,7 @@
}
}
@@ -35,10 +54,10 @@
p_282812_.blitSprite(RenderPipelines.GUI_TEXTURED, getMobEffectSprite(holder), k + 3, l + 3, 18, 18, ARGB.white(f));
}
}
@@ -598,6 +_,10 @@
@@ -603,6 +_,10 @@
}
private void renderSelectedItemName(GuiGraphics p_283501_) {
public void renderSelectedItemName(GuiGraphics p_283501_) {
+ renderSelectedItemName(p_283501_, 0);
+ }
+
@@ -46,7 +65,7 @@
Profiler.get().push("selectedItemName");
if (this.toolHighlightTimer > 0 && !this.lastToolHighlight.isEmpty()) {
MutableComponent mutablecomponent = Component.empty().append(this.lastToolHighlight.getHoverName()).withStyle(this.lastToolHighlight.getRarity().color());
@@ -605,9 +_,13 @@
@@ -610,9 +_,13 @@
mutablecomponent.withStyle(ChatFormatting.ITALIC);
}
@@ -62,7 +81,7 @@
if (!this.minecraft.gameMode.canHurtPlayer()) {
k += 14;
}
@@ -618,7 +_,7 @@
@@ -623,7 +_,7 @@
}
if (l > 0) {
@@ -71,7 +90,7 @@
}
}
@@ -1148,7 +_,7 @@
@@ -1151,7 +_,7 @@
ItemStack itemstack = this.minecraft.player.getInventory().getSelectedItem();
if (itemstack.isEmpty()) {
this.toolHighlightTimer = 0;
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/GuiGraphics.java
+++ b/net/minecraft/client/gui/GuiGraphics.java
@@ -72,7 +_,7 @@
@@ -83,7 +_,7 @@
import org.joml.Vector3f;
@OnlyIn(Dist.CLIENT)
@@ -9,7 +9,7 @@
private static final int EXTRA_SPACE_AFTER_FIRST_TOOLTIP_LINE = 2;
private final Minecraft minecraft;
private final Matrix3x2fStack pose;
@@ -870,6 +_,7 @@
@@ -950,6 +_,7 @@
CrashReport crashreport = CrashReport.forThrowable(throwable, "Rendering item");
CrashReportCategory crashreportcategory = crashreport.addCategory("Item being rendered");
crashreportcategory.setDetail("Item Type", () -> String.valueOf(p_283653_.getItem()));
@@ -17,7 +17,7 @@
crashreportcategory.setDetail("Item Components", () -> String.valueOf(p_283653_.getComponents()));
crashreportcategory.setDetail("Item Foil", () -> String.valueOf(p_283653_.hasFoil()));
throw new ReportedException(crashreport);
@@ -888,6 +_,7 @@
@@ -968,6 +_,7 @@
this.renderItemCooldown(p_283349_, p_282641_, p_282146_);
this.renderItemCount(p_282005_, p_283349_, p_282641_, p_282146_, p_282803_);
this.pose.popMatrix();
@@ -25,7 +25,7 @@
}
}
@@ -899,21 +_,30 @@
@@ -979,21 +_,30 @@
this.setTooltipForNextFrame(this.minecraft.font, p_407686_, DefaultTooltipPositioner.INSTANCE, p_410475_, p_407139_, false);
}
@@ -58,7 +58,7 @@
this.setTooltipForNextFrameInternal(p_407847_, list, p_409369_, p_407472_, DefaultTooltipPositioner.INSTANCE, p_410303_, false);
}
@@ -926,7 +_,22 @@
@@ -1006,7 +_,22 @@
}
public void setComponentTooltipForNextFrame(Font p_406239_, List<Component> p_410275_, int p_410594_, int p_409343_) {
@@ -82,7 +82,7 @@
}
public void setComponentTooltipForNextFrame(Font p_408650_, List<Component> p_407512_, int p_406019_, int p_408123_, @Nullable ResourceLocation p_409993_) {
@@ -989,11 +_,13 @@
@@ -1069,11 +_,13 @@
ClientTooltipPositioner p_409451_,
@Nullable ResourceLocation p_409298_
) {
@@ -97,7 +97,7 @@
if (k > i) {
i = k;
}
@@ -1003,16 +_,17 @@
@@ -1083,16 +_,17 @@
int l1 = i;
int i2 = j;
@@ -118,7 +118,7 @@
j1 += clienttooltipcomponent1.getHeight(p_283128_) + (k1 == 0 ? 2 : 0);
}
@@ -1020,7 +_,7 @@
@@ -1100,7 +_,7 @@
for (int j2 = 0; j2 < p_282716_.size(); j2++) {
ClientTooltipComponent clienttooltipcomponent2 = p_282716_.get(j2);
@@ -127,3 +127,18 @@
j1 += clienttooltipcomponent2.getHeight(p_283128_) + (j2 == 0 ? 2 : 0);
}
@@ -1315,6 +_,14 @@
public void submitProfilerChartRenderState(List<ResultField> p_408565_, int p_410147_, int p_406156_, int p_407365_, int p_408180_) {
this.guiRenderState.submitPicturesInPictureState(new GuiProfilerChartRenderState(p_408565_, p_410147_, p_406156_, p_407365_, p_408180_, this.scissorStack.peek()));
+ }
+
+ public GuiRenderState getRenderState() {
+ return this.guiRenderState;
+ }
+
+ public GuiGraphics.ScissorStack getScissorStack() {
+ return this.scissorStack;
}
public TextureAtlasSprite getSprite(Material p_430745_) {
@@ -1,11 +1,11 @@
--- a/net/minecraft/client/gui/components/AbstractButton.java
+++ b/net/minecraft/client/gui/components/AbstractButton.java
@@ -38,7 +_,7 @@
@@ -41,7 +_,7 @@
this.getHeight(),
ARGB.white(this.alpha)
);
- int i = ARGB.color(this.alpha, this.active ? -1 : -6250336);
+ int i = getFGColor();
this.renderString(p_281670_, minecraft.font, i);
}
if (this.isHovered()) {
p_281670_.requestCursor(this.isActive() ? CursorTypes.POINTING_HAND : CursorTypes.NOT_ALLOWED);
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/components/AbstractWidget.java
+++ b/net/minecraft/client/gui/components/AbstractWidget.java
@@ -236,6 +_,25 @@
@@ -238,6 +_,25 @@
this.focused = p_93693_;
}
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/components/Button.java
+++ b/net/minecraft/client/gui/components/Button.java
@@ -31,6 +_,12 @@
@@ -32,6 +_,12 @@
this.createNarration = p_259552_;
}
@@ -11,9 +11,9 @@
+ }
+
@Override
public void onPress() {
public void onPress(InputWithModifiers p_424878_) {
this.onPress.onPress(this);
@@ -95,9 +_,12 @@
@@ -96,9 +_,12 @@
}
public Button build() {
@@ -1,101 +0,0 @@
--- a/net/minecraft/client/gui/components/DebugScreenOverlay.java
+++ b/net/minecraft/client/gui/components/DebugScreenOverlay.java
@@ -139,9 +_,9 @@
@Nullable
private CompletableFuture<LevelChunk> serverChunk;
private boolean renderDebug;
- private boolean renderProfilerChart;
- private boolean renderFpsCharts;
- private boolean renderNetworkCharts;
+ protected boolean renderProfilerChart;
+ protected boolean renderFpsCharts;
+ protected boolean renderNetworkCharts;
private final LocalSampleLogger frameTimeLogger = new LocalSampleLogger(1);
private final LocalSampleLogger tickTimeLogger = new LocalSampleLogger(TpsDebugDimensions.values().length);
private final LocalSampleLogger pingLogger = new LocalSampleLogger(1);
@@ -183,15 +_,19 @@
this.clientChunk = null;
}
- public void render(GuiGraphics p_281427_) {
- ProfilerFiller profilerfiller = Profiler.get();
- profilerfiller.push("debug");
+ protected void update() {
Entity entity = this.minecraft.getCameraEntity();
this.block = entity.pick(20.0, 0.0F, false);
this.liquid = entity.pick(20.0, 0.0F, true);
+ }
+
+ protected void drawText(ProfilerFiller profilerfiller, GuiGraphics p_281427_) {
this.drawGameInformation(p_281427_);
this.drawSystemInformation(p_281427_);
p_281427_.nextStratum();
+ }
+
+ protected void drawFPSCharts(ProfilerFiller profilerfiller, GuiGraphics p_281427_) {
this.profilerPieChart.setBottomOffset(10);
if (this.renderFpsCharts) {
int i = p_281427_.guiWidth();
@@ -204,7 +_,9 @@
this.profilerPieChart.setBottomOffset(this.tpsChart.getFullHeight());
}
+ }
+ protected void drawNetworkCharts(ProfilerFiller profilerfiller, GuiGraphics p_281427_) {
if (this.renderNetworkCharts) {
int l = p_281427_.guiWidth();
int i1 = l / 2;
@@ -220,12 +_,22 @@
try (Zone zone = profilerfiller.zone("profilerPie")) {
this.profilerPieChart.render(p_281427_);
}
+ }
+
+ public void render(GuiGraphics p_281427_) {
+ ProfilerFiller profilerfiller = Profiler.get();
+ profilerfiller.push("debug");
+ this.update();
+
+ this.drawText(profilerfiller, p_281427_);
+ this.drawFPSCharts(profilerfiller, p_281427_);
+ this.drawNetworkCharts(profilerfiller, p_281427_);
profilerfiller.pop();
}
- protected void drawGameInformation(GuiGraphics p_281525_) {
- List<String> list = this.getGameInformation();
+ protected List<String> getOverlayHelp() {
+ List<String> list = Lists.newArrayList();
list.add("");
boolean flag = this.minecraft.getSingleplayerServer() != null;
list.add(
@@ -239,11 +_,18 @@
+ (this.renderNetworkCharts ? " visible" : " hidden")
);
list.add("For help: press F3 + Q");
- this.renderLines(p_281525_, list, true);
+ return list;
+ }
+ protected void drawGameInformation(GuiGraphics p_281525_) {
+ List<String> list = this.getGameInformation();
+ list.addAll(this.getOverlayHelp());
+ net.minecraftforge.client.ForgeHooksClient.onCustomizeDebugEvent(p_281525_, minecraft.getWindow(), minecraft.getDeltaTracker().getRealtimeDeltaTicks(), list, true);
+ this.renderLines(p_281525_, list, true);
}
protected void drawSystemInformation(GuiGraphics p_281261_) {
List<String> list = this.getSystemInformation();
+ net.minecraftforge.client.ForgeHooksClient.onCustomizeDebugEvent(p_281261_, minecraft.getWindow(), minecraft.getDeltaTracker().getRealtimeDeltaTicks(), list, false);
this.renderLines(p_281261_, list, false);
}
@@ -597,6 +_,7 @@
list.add("");
list.add(ChatFormatting.UNDERLINE + "Targeted Entity");
list.add(String.valueOf(BuiltInRegistries.ENTITY_TYPE.getKey(entity.getType())));
+ entity.getType().builtInRegistryHolder().tags().forEach(t -> list.add("#" + t.location()));
}
return list;
@@ -0,0 +1,10 @@
--- a/net/minecraft/client/gui/components/debug/DebugEntryLookingAtEntity.java
+++ b/net/minecraft/client/gui/components/debug/DebugEntryLookingAtEntity.java
@@ -25,6 +_,7 @@
if (entity != null) {
list.add(ChatFormatting.UNDERLINE + "Targeted Entity");
list.add(String.valueOf(BuiltInRegistries.ENTITY_TYPE.getKey(entity.getType())));
+ entity.getType().builtInRegistryHolder().tags().forEach(t -> list.add("#" + t.location()));
}
p_426755_.addToGroup(GROUP, list);
@@ -0,0 +1,10 @@
--- a/net/minecraft/client/gui/render/GuiRenderer.java
+++ b/net/minecraft/client/gui/render/GuiRenderer.java
@@ -146,6 +_,7 @@
builder.put((Class<? extends PictureInPictureRenderState>)pictureinpicturerenderer.getRenderStateClass(), pictureinpicturerenderer);
}
+ net.minecraftforge.client.ForgeHooksClient.onRegisterPictureInPictureRenderers(p_410565_, p_410441_, builder);
this.pictureInPictureRenderers = builder.buildOrThrow();
}
@@ -1,10 +1,10 @@
--- a/net/minecraft/client/gui/screens/ChatScreen.java
+++ b/net/minecraft/client/gui/screens/ChatScreen.java
@@ -89,6 +_,7 @@
return true;
} else if (p_95591_ == 257 || p_95591_ == 335) {
@@ -115,6 +_,7 @@
} else if (p_426273_.isConfirmation()) {
this.handleChatInput(this.input.getValue(), true);
this.exitReason = ChatScreen.ExitReason.DONE;
+ if (this.minecraft.screen == this) // FORGE: Prevent closing the screen if another screen has been opened.
this.minecraft.setScreen(null);
return true;
} else if (p_95591_ == 265) {
} else {
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/ConnectScreen.java
+++ b/net/minecraft/client/gui/screens/ConnectScreen.java
@@ -102,6 +_,8 @@
@@ -103,6 +_,8 @@
}
if (optional.isEmpty()) {
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/LoadingOverlay.java
+++ b/net/minecraft/client/gui/screens/LoadingOverlay.java
@@ -61,6 +_,8 @@
@@ -62,6 +_,8 @@
return p_169325_ & 16777215 | p_169326_ << 24;
}
@@ -9,7 +9,7 @@
@Override
public void render(GuiGraphics p_281839_, int p_282704_, int p_283650_, float p_283394_) {
int i = p_281839_.guiWidth();
@@ -97,6 +_,7 @@
@@ -102,6 +_,7 @@
f2 = 1.0F;
}
@@ -17,7 +17,7 @@
int l2 = (int)(p_281839_.guiWidth() * 0.5);
int i1 = (int)(p_281839_.guiHeight() * 0.5);
double d0 = Math.min(p_281839_.guiWidth() * 0.75, (double)p_281839_.guiHeight()) * 0.25;
@@ -112,12 +_,14 @@
@@ -117,6 +_,7 @@
if (f < 1.0F) {
this.drawProgressBar(p_281839_, i / 2 - k1, i2 - 5, i / 2 + k1, i2 + 5, 1.0F - Mth.clamp(f, 0.0F, 1.0F));
}
@@ -25,18 +25,19 @@
if (f >= 2.0F) {
this.minecraft.setOverlay(null);
}
if (this.fadeOutStart == -1L && this.reload.isDone() && (!this.fadeIn || f1 >= 2.0F)) {
@@ -126,6 +_,7 @@
@Override
public void tick() {
if (this.fadeOutStart == -1L && this.reload.isDone() && this.isReadyToFadeOut()) {
+ this.fadeOutStart = Util.getMillis(); // Forge: Moved up to guard against inf loops caused by callback
try {
this.reload.checkExceptions();
this.onFinish.accept(Optional.empty());
@@ -125,7 +_,6 @@
@@ -133,7 +_,6 @@
this.onFinish.accept(Optional.of(throwable));
}
- this.fadeOutStart = Util.getMillis();
if (this.minecraft.screen != null) {
this.minecraft.screen.init(this.minecraft, p_281839_.guiWidth(), p_281839_.guiHeight());
}
Window window = this.minecraft.getWindow();
this.minecraft.screen.init(this.minecraft, window.getGuiScaledWidth(), window.getGuiScaledHeight());
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/PauseScreen.java
+++ b/net/minecraft/client/gui/screens/PauseScreen.java
@@ -105,6 +_,7 @@
@@ -103,6 +_,7 @@
} else {
gridlayout$rowhelper.addChild(this.openScreenButton(PLAYER_REPORTING, () -> new SocialInteractionsScreen(this)));
}
@@ -9,7 +9,7 @@
}
protected <T extends GuiEventListener & Renderable & NarratableEntry> T addRenderableWidget(T p_169406_) {
@@ -339,8 +_,10 @@
@@ -343,8 +_,10 @@
this.width = p_96608_;
this.height = p_96609_;
if (!this.initialized) {
@@ -20,7 +20,7 @@
} else {
this.repositionElements();
}
@@ -353,8 +_,10 @@
@@ -361,8 +_,10 @@
protected void rebuildWidgets() {
this.clearWidgets();
this.clearFocus();
@@ -31,15 +31,16 @@
}
protected void fadeWidgets(float p_409453_) {
@@ -389,6 +_,7 @@
@@ -402,6 +_,8 @@
this.renderMenuBackground(p_283688_);
}
this.renderBlurredBackground(p_283688_);
this.renderMenuBackground(p_283688_);
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderScreenBackground(this, p_283688_);
+
this.minecraft.gui.renderDeferredSubtitles();
}
protected void renderBlurredBackground(GuiGraphics p_407253_) {
@@ -492,6 +_,19 @@
@@ -484,6 +_,19 @@
}
public void onFilesDrop(List<Path> p_96591_) {
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/TitleScreen.java
+++ b/net/minecraft/client/gui/screens/TitleScreen.java
@@ -54,6 +_,7 @@
@@ -55,6 +_,7 @@
private boolean fading;
private long fadeInStart;
private final LogoRenderer logoRenderer;
@@ -8,7 +8,7 @@
public TitleScreen() {
this(false);
@@ -106,11 +_,15 @@
@@ -107,11 +_,15 @@
int j = this.width - i - 2;
int k = 24;
int l = this.height / 4 + 48;
@@ -24,7 +24,7 @@
l = this.createTestWorldButton(l, 24);
SpriteIconButton spriteiconbutton = this.addRenderableWidget(
@@ -175,7 +_,7 @@
@@ -178,7 +_,7 @@
}).bounds(this.width / 2 - 100, i = p_96764_ + p_96765_, 200, 20).tooltip(tooltip).build()).active = flag;
this.addRenderableWidget(
Button.builder(Component.translatable("menu.online"), p_325369_ -> this.minecraft.setScreen(new RealmsMainScreen(this)))
@@ -33,7 +33,7 @@
.tooltip(tooltip)
.build()
)
@@ -295,9 +_,18 @@
@@ -298,9 +_,18 @@
s = s + I18n.get("menu.modded");
}
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java
+++ b/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java
@@ -51,6 +_,7 @@
@@ -53,6 +_,7 @@
@Nullable
private AdvancementTab selectedTab;
private boolean isScrolling;
@@ -8,7 +8,7 @@
public AdvancementsScreen(ClientAdvancements p_97340_) {
this(p_97340_, null);
@@ -64,6 +_,19 @@
@@ -66,6 +_,19 @@
@Override
protected void init() {
@@ -28,16 +28,16 @@
this.layout.addTitleHeader(TITLE, this.font);
this.tabs.clear();
this.selectedTab = null;
@@ -108,7 +_,7 @@
@@ -110,7 +_,7 @@
int j = (this.height - 140) / 2;
for (AdvancementTab advancementtab : this.tabs.values()) {
- if (advancementtab.isMouseOver(i, j, p_97343_, p_97344_)) {
+ if (advancementtab.getPage() == tabPage && advancementtab.isMouseOver(i, j, p_97343_, p_97344_)) {
- if (advancementtab.isMouseOver(i, j, p_431395_.x(), p_431395_.y())) {
+ if (advancementtab.getPage() == tabPage && advancementtab.isMouseOver(i, j, p_431395_.x(), p_431395_.y())) {
this.advancements.setSelectedTab(advancementtab.getRootNode().holder(), true);
break;
}
@@ -183,10 +_,12 @@
@@ -185,10 +_,12 @@
p_283395_.blit(RenderPipelines.GUI_TEXTURED, WINDOW_LOCATION, p_281890_, p_282532_, 0.0F, 0.0F, 252, 140, 256, 256);
if (this.tabs.size() > 1) {
for (AdvancementTab advancementtab : this.tabs.values()) {
@@ -50,7 +50,7 @@
advancementtab1.drawIcon(p_283395_, p_281890_, p_282532_);
}
}
@@ -205,6 +_,7 @@
@@ -207,6 +_,7 @@
if (this.tabs.size() > 1) {
for (AdvancementTab advancementtab : this.tabs.values()) {
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java
+++ b/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java
@@ -107,6 +_,7 @@
@@ -105,6 +_,7 @@
int i = this.leftPos;
int j = this.topPos;
super.render(p_409971_, p_409213_, p_408205_, p_408282_);
@@ -8,7 +8,7 @@
p_409971_.pose().pushMatrix();
p_409971_.pose().translate(i, j);
this.renderLabels(p_409971_, p_409213_, p_408205_);
@@ -119,6 +_,8 @@
@@ -117,6 +_,8 @@
this.onStopHovering(slot);
}
@@ -17,7 +17,7 @@
p_409971_.pose().popMatrix();
}
@@ -202,7 +_,7 @@
@@ -200,7 +_,7 @@
ItemStack itemstack = this.hoveredSlot.getItem();
if (this.menu.getCarried().isEmpty() || this.showTooltipWithItemInHand(itemstack)) {
p_283594_.setTooltipForNextFrame(
@@ -26,7 +26,7 @@
);
}
}
@@ -218,7 +_,8 @@
@@ -216,7 +_,8 @@
private void renderFloatingItem(GuiGraphics p_282567_, ItemStack p_281330_, int p_281772_, int p_281689_, @Nullable String p_282568_) {
p_282567_.renderItem(p_281330_, p_281772_, p_281689_);
@@ -36,87 +36,84 @@
}
protected void renderLabels(GuiGraphics p_281635_, int p_282681_, int p_283686_) {
@@ -319,7 +_,8 @@
if (super.mouseClicked(p_97748_, p_97749_, p_97750_)) {
@@ -317,7 +_,8 @@
if (super.mouseClicked(p_427253_, p_427622_)) {
return true;
} else {
- boolean flag = this.minecraft.options.keyPickItem.matchesMouse(p_97750_) && this.minecraft.player.hasInfiniteMaterials();
+ InputConstants.Key mouseKey = InputConstants.Type.MOUSE.getOrCreate(p_97750_);
+ boolean flag = this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey);
Slot slot = this.getHoveredSlot(p_97748_, p_97749_);
long i = Util.getMillis();
this.doubleclick = this.lastClickSlot == slot && i - this.lastClickTime < 250L && this.lastClickButton == p_97750_;
@@ -330,6 +_,7 @@
int j = this.leftPos;
int k = this.topPos;
boolean flag1 = this.hasClickedOutside(p_97748_, p_97749_, j, k, p_97750_);
- boolean flag = this.minecraft.options.keyPickItem.matchesMouse(p_427253_) && this.minecraft.player.hasInfiniteMaterials();
+ var mouseKey = com.mojang.blaze3d.platform.InputConstants.Type.MOUSE.getOrCreate(p_427253_.button());
+ boolean flag = this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey) && this.minecraft.player.hasInfiniteMaterials();
Slot slot = this.getHoveredSlot(p_427253_.x(), p_427253_.y());
this.doubleclick = this.lastClickSlot == slot && p_427622_;
this.skipNextRelease = false;
@@ -327,6 +_,7 @@
int i = this.leftPos;
int j = this.topPos;
boolean flag1 = this.hasClickedOutside(p_427253_.x(), p_427253_.y(), i, j);
+ if (slot != null) flag1 = false; // Forge, prevent dropping of items through slots outside of GUI boundaries
int l = -1;
int k = -1;
if (slot != null) {
l = slot.index;
@@ -355,7 +_,7 @@
k = slot.index;
@@ -352,7 +_,7 @@
}
} else if (!this.isQuickCrafting) {
if (this.menu.getCarried().isEmpty()) {
- if (flag) {
+ if (this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey)) {
this.slotClicked(slot, l, p_97750_, ClickType.CLONE);
this.slotClicked(slot, k, p_427253_.button(), ClickType.CLONE);
} else {
boolean flag2 = l != -999
@@ -383,7 +_,7 @@
boolean flag2 = k != -999 && p_427253_.hasShiftDown();
@@ -376,7 +_,7 @@
this.quickCraftingType = 0;
} else if (p_97750_ == 1) {
} else if (p_427253_.button() == 1) {
this.quickCraftingType = 1;
- } else if (flag) {
+ } else if (this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey)) {
this.quickCraftingType = 2;
}
}
@@ -459,10 +_,13 @@
@@ -453,10 +_,13 @@
@Override
public boolean mouseReleased(double p_97812_, double p_97813_, int p_97814_) {
+ super.mouseReleased(p_97812_, p_97813_, p_97814_); //Forge, Call parent to release buttons
Slot slot = this.getHoveredSlot(p_97812_, p_97813_);
public boolean mouseReleased(MouseButtonEvent p_430939_) {
+ super.mouseReleased(p_430939_); //Forge, Call parent to release buttons
Slot slot = this.getHoveredSlot(p_430939_.x(), p_430939_.y());
int i = this.leftPos;
int j = this.topPos;
boolean flag = this.hasClickedOutside(p_97812_, p_97813_, i, j, p_97814_);
boolean flag = this.hasClickedOutside(p_430939_.x(), p_430939_.y(), i, j);
+ if (slot != null) flag = false; // Forge, prevent dropping of items through slots outside of GUI boundaries
+ InputConstants.Key mouseKey = InputConstants.Type.MOUSE.getOrCreate(p_97814_);
+ var mouseKey = com.mojang.blaze3d.platform.InputConstants.Type.MOUSE.getOrCreate(p_430939_.button());
int k = -1;
if (slot != null) {
k = slot.index;
@@ -479,7 +_,7 @@
@@ -473,7 +_,7 @@
if (slot2 != null
&& slot2.mayPickup(this.minecraft.player)
&& slot2.hasItem()
- && slot2.container == slot.container
+ && slot2.isSameInventory(slot)
&& AbstractContainerMenu.canItemQuickReplace(slot2, this.lastQuickMoved, true)) {
this.slotClicked(slot2, slot2.index, p_97814_, ClickType.QUICK_MOVE);
this.slotClicked(slot2, slot2.index, p_430939_.button(), ClickType.QUICK_MOVE);
}
@@ -545,7 +_,7 @@
@@ -538,7 +_,7 @@
this.slotClicked(null, -999, AbstractContainerMenu.getQuickcraftMask(2, this.quickCraftingType), ClickType.QUICK_CRAFT);
} else if (!this.menu.getCarried().isEmpty()) {
- if (this.minecraft.options.keyPickItem.matchesMouse(p_97814_)) {
- if (this.minecraft.options.keyPickItem.matchesMouse(p_430939_)) {
+ if (this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey)) {
this.slotClicked(slot, k, p_97814_, ClickType.CLONE);
this.slotClicked(slot, k, p_430939_.button(), ClickType.CLONE);
} else {
boolean flag1 = k != -999
@@ -622,9 +_,10 @@
@Override
public boolean keyPressed(int p_97765_, int p_97766_, int p_97767_) {
+ InputConstants.Key mouseKey = InputConstants.getKey(p_97765_, p_97766_);
if (super.keyPressed(p_97765_, p_97766_, p_97767_)) {
boolean flag1 = k != -999 && p_430939_.hasShiftDown();
@@ -609,7 +_,7 @@
public boolean keyPressed(KeyEvent p_424324_) {
if (super.keyPressed(p_424324_)) {
return true;
- } else if (this.minecraft.options.keyInventory.matches(p_97765_, p_97766_)) {
+ } else if (this.minecraft.options.keyInventory.isActiveAndMatches(mouseKey)) {
- } else if (this.minecraft.options.keyInventory.matches(p_424324_)) {
+ } else if (this.minecraft.options.keyInventory.isActiveAndMatches(com.mojang.blaze3d.platform.InputConstants.getKey(p_424324_))) {
this.onClose();
return true;
} else {
@@ -698,6 +_,13 @@
@@ -688,6 +_,13 @@
super.onClose();
}
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java
+++ b/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java
@@ -113,6 +_,8 @@
@@ -116,6 +_,8 @@
private final Set<TagKey<Item>> visibleTags = new HashSet<>();
private final boolean displayOperatorCreativeTab;
private final EffectsInInventory effects;
@@ -9,7 +9,7 @@
public CreativeModeInventoryScreen(LocalPlayer p_344408_, FeatureFlagSet p_260074_, boolean p_259569_) {
super(new CreativeModeInventoryScreen.ItemPickerMenu(p_344408_), p_344408_.getInventory(), CommonComponents.EMPTY);
@@ -161,7 +_,7 @@
@@ -164,7 +_,7 @@
private void refreshCurrentTabContents(Collection<ItemStack> p_261591_) {
int i = this.menu.getRowIndexForScroll(this.scrollOffs);
this.menu.items.clear();
@@ -18,7 +18,7 @@
this.refreshSearchResults();
} else {
this.menu.items.addAll(p_261591_);
@@ -329,6 +_,35 @@
@@ -332,6 +_,36 @@
protected void init() {
if (this.minecraft.player.hasInfiniteMaterials()) {
super.init();
@@ -26,6 +26,7 @@
+ int tabIndex = 0;
+ List<CreativeModeTab> currentPage = new java.util.ArrayList<>();
+ for (CreativeModeTab sortedCreativeModeTab : net.minecraftforge.common.CreativeModeTabRegistry.getSortedCreativeModeTabs()) {
+ if (!sortedCreativeModeTab.shouldDisplay()) continue;
+ currentPage.add(sortedCreativeModeTab);
+ tabIndex++;
+ if (tabIndex == 10) {
@@ -54,8 +55,8 @@
this.searchBox = new EditBox(this.font, this.leftPos + 82, this.topPos + 6, 80, 9, Component.translatable("itemGroup.search"));
this.searchBox.setMaxLength(50);
this.searchBox.setBordered(false);
@@ -375,7 +_,7 @@
public boolean charTyped(char p_98521_, int p_98522_) {
@@ -378,7 +_,7 @@
public boolean charTyped(CharacterEvent p_424087_) {
if (this.ignoreTextInput) {
return false;
- } else if (selectedTab.getType() != CreativeModeTab.Type.SEARCH) {
@@ -63,16 +64,16 @@
return false;
} else {
String s = this.searchBox.getValue();
@@ -394,7 +_,7 @@
@@ -397,7 +_,7 @@
@Override
public boolean keyPressed(int p_98547_, int p_98548_, int p_98549_) {
public boolean keyPressed(KeyEvent p_429237_) {
this.ignoreTextInput = false;
- if (selectedTab.getType() != CreativeModeTab.Type.SEARCH) {
+ if (!selectedTab.hasSearchBar()) {
if (this.minecraft.options.keyChat.matches(p_98547_, p_98548_)) {
if (this.minecraft.options.keyChat.matches(p_429237_)) {
this.ignoreTextInput = true;
this.selectTab(CreativeModeTabs.searchTab());
@@ -430,6 +_,7 @@
@@ -433,6 +_,7 @@
}
private void refreshSearchResults() {
@@ -80,7 +81,7 @@
this.menu.items.clear();
this.visibleTags.clear();
String s = this.searchBox.getValue();
@@ -442,10 +_,10 @@
@@ -445,10 +_,10 @@
SearchTree<ItemStack> searchtree;
if (s.startsWith("#")) {
s = s.substring(1);
@@ -93,7 +94,7 @@
}
this.menu.items.addAll(searchtree.search(s.toLowerCase(Locale.ROOT)));
@@ -477,7 +_,8 @@
@@ -480,7 +_,8 @@
@Override
protected void renderLabels(GuiGraphics p_283168_, int p_281774_, int p_281466_) {
if (selectedTab.showTitle()) {
@@ -103,17 +104,17 @@
}
}
@@ -487,7 +_,7 @@
double d0 = p_98531_ - this.leftPos;
double d1 = p_98532_ - this.topPos;
@@ -490,7 +_,7 @@
double d0 = p_430803_.x() - this.leftPos;
double d1 = p_430803_.y() - this.topPos;
- for (CreativeModeTab creativemodetab : CreativeModeTabs.tabs()) {
+ for (CreativeModeTab creativemodetab : currentPage.getVisibleTabs()) {
if (this.checkTabClicked(creativemodetab, d0, d1)) {
return true;
}
@@ -509,7 +_,7 @@
double d1 = p_98623_ - this.topPos;
@@ -512,7 +_,7 @@
double d1 = p_423848_.y() - this.topPos;
this.scrolling = false;
- for (CreativeModeTab creativemodetab : CreativeModeTabs.tabs()) {
@@ -121,7 +122,7 @@
if (this.checkTabClicked(creativemodetab, d0, d1)) {
this.selectTab(creativemodetab);
return true;
@@ -603,13 +_,15 @@
@@ -606,13 +_,15 @@
this.originalSlots = null;
}
@@ -138,7 +139,7 @@
this.refreshSearchResults();
} else {
@@ -673,7 +_,14 @@
@@ -676,7 +_,14 @@
super.render(p_283000_, p_281317_, p_282770_, p_281295_);
this.effects.renderTooltip(p_283000_, p_281317_, p_282770_);
@@ -154,7 +155,7 @@
if (this.checkTabHovering(p_283000_, creativemodetab, p_281317_, p_282770_)) {
break;
}
@@ -697,7 +_,7 @@
@@ -700,7 +_,7 @@
public List<Component> getTooltipFromContainerItem(ItemStack p_281769_) {
boolean flag = this.hoveredSlot != null && this.hoveredSlot instanceof CreativeModeInventoryScreen.CustomCreativeSlot;
boolean flag1 = selectedTab.getType() == CreativeModeTab.Type.CATEGORY;
@@ -163,7 +164,7 @@
TooltipFlag.Default tooltipflag$default = this.minecraft.options.advancedItemTooltips ? TooltipFlag.Default.ADVANCED : TooltipFlag.Default.NORMAL;
TooltipFlag tooltipflag = flag ? tooltipflag$default.asCreative() : tooltipflag$default;
List<Component> list = p_281769_.getTooltipLines(Item.TooltipContext.of(this.minecraft.level), this.minecraft.player, tooltipflag);
@@ -718,7 +_,7 @@
@@ -721,7 +_,7 @@
int i = 1;
for (CreativeModeTab creativemodetab : CreativeModeTabs.tabs()) {
@@ -172,7 +173,7 @@
list1.add(i++, creativemodetab.getDisplayName().copy().withStyle(ChatFormatting.BLUE));
}
}
@@ -729,7 +_,7 @@
@@ -732,7 +_,7 @@
@Override
protected void renderBg(GuiGraphics p_282663_, float p_282504_, int p_282089_, int p_282249_) {
@@ -181,7 +182,7 @@
if (creativemodetab != selectedTab) {
this.renderTabButton(p_282663_, creativemodetab);
}
@@ -745,6 +_,7 @@
@@ -748,6 +_,7 @@
p_282663_.blitSprite(RenderPipelines.GUI_TEXTURED, resourcelocation, j, k + (int)((i - k - 17) * this.scrollOffs), 12, 15);
}
@@ -189,7 +190,7 @@
this.renderTabButton(p_282663_, selectedTab);
if (selectedTab.getType() == CreativeModeTab.Type.INVENTORY) {
InventoryScreen.renderEntityInInventoryFollowsMouse(
@@ -763,7 +_,7 @@
@@ -766,7 +_,7 @@
}
private int getTabX(CreativeModeTab p_260136_) {
@@ -198,7 +199,7 @@
int j = 27;
int k = 27 * i;
if (p_260136_.isAlignedRight()) {
@@ -775,7 +_,7 @@
@@ -778,7 +_,7 @@
private int getTabY(CreativeModeTab p_260181_) {
int i = 0;
@@ -207,7 +208,7 @@
i -= 32;
} else {
i += this.imageHeight;
@@ -803,8 +_,8 @@
@@ -806,8 +_,8 @@
protected void renderTabButton(GuiGraphics p_283590_, CreativeModeTab p_283489_) {
boolean flag = p_283489_ == selectedTab;
@@ -218,7 +219,7 @@
int j = this.leftPos + this.getTabX(p_283489_);
int k = this.topPos - (flag1 ? 28 : -(this.imageHeight - 4));
ResourceLocation[] aresourcelocation;
@@ -814,6 +_,7 @@
@@ -817,6 +_,7 @@
aresourcelocation = flag ? SELECTED_BOTTOM_TABS : UNSELECTED_BOTTOM_TABS;
}
@@ -226,7 +227,7 @@
p_283590_.blitSprite(RenderPipelines.GUI_TEXTURED, aresourcelocation[Mth.clamp(i, 0, aresourcelocation.length)], j, k, 26, 32);
int l = j + 13 - 8;
int i1 = k + 16 - 8 + (flag1 ? 1 : -1);
@@ -850,6 +_,14 @@
@@ -853,6 +_,14 @@
}
}
@@ -241,7 +242,7 @@
@OnlyIn(Dist.CLIENT)
static class CustomCreativeSlot extends Slot {
public CustomCreativeSlot(Container p_98633_, int p_98634_, int p_98635_, int p_98636_) {
@@ -1031,6 +_,22 @@
@@ -1034,6 +_,22 @@
@Override
public boolean mayPickup(Player p_98665_) {
return this.target.mayPickup(p_98665_);
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java
+++ b/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java
@@ -106,7 +_,7 @@
@@ -107,7 +_,7 @@
int l1 = 86 - this.font.width(s);
FormattedText formattedtext = EnchantmentNames.getInstance().getRandomName(this.font, l1);
int i2 = -9937334;
@@ -9,7 +9,7 @@
p_282430_.blitSprite(RenderPipelines.GUI_TEXTURED, ENCHANTMENT_SLOT_DISABLED_SPRITE, i1, j + 14 + 19 * l, 108, 19);
p_282430_.blitSprite(RenderPipelines.GUI_TEXTURED, DISABLED_LEVEL_SPRITES[l], i1 + 1, j + 15 + 19 * l, 16, 16);
p_282430_.drawWordWrap(this.font, formattedtext, j1, j + 16 + 19 * l, l1, ARGB.opaque((i2 & 16711422) >> 1), false);
@@ -157,13 +_,16 @@
@@ -158,13 +_,16 @@
.registryAccess()
.lookupOrThrow(Registries.ENCHANTMENT)
.get(this.menu.enchantClue[j]);
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/inventory/MerchantScreen.java
+++ b/net/minecraft/client/gui/screens/inventory/MerchantScreen.java
@@ -229,6 +_,14 @@
@@ -230,6 +_,14 @@
} else {
p_281357_.renderItemDecorations(this.font, p_282046_, p_282403_, p_283601_, p_282046_.getCount() == 1 ? "1" : null);
p_281357_.renderItemDecorations(this.font, p_283466_, p_282403_ + 14, p_283601_, p_283466_.getCount() == 1 ? "1" : null);
@@ -1,11 +1,11 @@
--- a/net/minecraft/client/gui/screens/multiplayer/ServerSelectionList.java
+++ b/net/minecraft/client/gui/screens/multiplayer/ServerSelectionList.java
@@ -371,6 +_,8 @@
p_281406_.setTooltipForNextFrame(Lists.transform(this.onlinePlayersTooltip, Component::getVisualOrderText), p_283567_, p_282864_);
@@ -363,6 +_,8 @@
p_425273_.setTooltipForNextFrame(Lists.transform(this.onlinePlayersTooltip, Component::getVisualOrderText), p_424268_, p_430737_);
}
+ net.minecraftforge.client.ForgeHooksClient.drawForgePingInfo(this.screen, serverData, p_281406_, p_281363_, p_282921_, p_283596_, p_283567_ - p_281363_, p_282864_ - p_282921_);
+ net.minecraftforge.client.ForgeHooksClient.drawForgePingInfo(this.screen, serverData, p_425273_, this.getContentX(), this.getContentY(), this.getContentWidth(), p_424268_ - this.getContentX(), p_430737_ - this.getContentY());
+
if (this.minecraft.options.touchscreen().get() || p_282999_) {
p_281406_.fill(p_281363_, p_282921_, p_281363_ + 32, p_282921_ + 32, -1601138544);
int l = p_283567_ - p_281363_;
if (this.minecraft.options.touchscreen().get() || p_425246_) {
p_425273_.fill(this.getContentX(), this.getContentY(), this.getContentX() + 32, this.getContentY() + 32, -1601138544);
int i1 = p_424268_ - this.getContentX();
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/options/controls/KeyBindsList.java
+++ b/net/minecraft/client/gui/screens/options/controls/KeyBindsList.java
@@ -148,9 +_,10 @@
@@ -115,9 +_,10 @@
this.name = p_343976_;
this.changeButton = Button.builder(p_343976_, p_342196_ -> {
KeyBindsList.this.keyBindsScreen.selectedKey = p_343088_;
@@ -12,7 +12,7 @@
.createNarration(
p_342179_ -> p_343088_.isUnbound()
? Component.translatable("narrator.controls.unbound", p_343976_)
@@ -158,7 +_,7 @@
@@ -125,7 +_,7 @@
)
.build();
this.resetButton = Button.builder(RESET_BUTTON_TITLE, p_357685_ -> {
@@ -21,12 +21,13 @@
KeyBindsList.this.resetMappingAndUpdateButtons();
}).bounds(0, 0, 50, 20).createNarration(p_344192_ -> Component.translatable("narrator.controls.reset", p_343976_)).build();
this.refreshEntry();
@@ -210,7 +_,7 @@
@@ -166,7 +_,8 @@
MutableComponent mutablecomponent = Component.empty();
if (!this.key.isUnbound()) {
for (KeyMapping keymapping : KeyBindsList.this.minecraft.options.keyMappings) {
- if (keymapping != this.key && this.key.same(keymapping)) {
+ if ((keymapping != this.key && this.key.same(keymapping)) || keymapping.hasKeyModifierConflict(this.key)) { // FORGE: gracefully handle conflicts like SHIFT vs SHIFT+G
- if (keymapping != this.key && this.key.same(keymapping) && (!keymapping.isDefault() || !this.key.isDefault())) {
+ var vanillConflict = keymapping != this.key && this.key.same(keymapping) && (!keymapping.isDefault() || !this.key.isDefault());
+ if (vanillConflict || keymapping.hasKeyModifierConflict(this.key)) { // FORGE: gracefully handle conflicts like SHIFT vs SHIFT+G
if (this.hasCollision) {
mutablecomponent.append(", ");
}
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/options/controls/KeyBindsScreen.java
+++ b/net/minecraft/client/gui/screens/options/controls/KeyBindsScreen.java
@@ -41,7 +_,7 @@
@@ -43,7 +_,7 @@
protected void addFooter() {
this.resetButton = Button.builder(Component.translatable("controls.resetAll"), p_343640_ -> {
for (KeyMapping keymapping : this.options.keyMappings) {
@@ -9,37 +9,37 @@
}
this.keyBindsList.resetMappingAndUpdateButtons();
@@ -73,11 +_,12 @@
public boolean keyPressed(int p_342715_, int p_342862_, int p_345515_) {
@@ -75,11 +_,12 @@
public boolean keyPressed(KeyEvent p_424487_) {
if (this.selectedKey != null) {
if (p_342715_ == 256) {
if (p_424487_.isEscape()) {
- this.selectedKey.setKey(InputConstants.UNKNOWN);
+ this.selectedKey.setKeyModifierAndCode(null, InputConstants.UNKNOWN);
} else {
- this.selectedKey.setKey(InputConstants.getKey(p_342715_, p_342862_));
+ this.selectedKey.setKeyModifierAndCode(null, InputConstants.getKey(p_342715_, p_342862_));
- this.selectedKey.setKey(InputConstants.getKey(p_424487_));
+ this.selectedKey.setKeyModifierAndCode(null, InputConstants.getKey(p_424487_));
}
+ if (p_342715_ == 256 || !net.minecraftforge.client.settings.KeyModifier.isKeyCodeModifier(this.selectedKey.getKey()))
+ if (p_424487_.isEscape() || !net.minecraftforge.client.settings.KeyModifier.isKeyCodeModifier(this.selectedKey.getKey()))
this.selectedKey = null;
this.lastKeySelection = Util.getMillis();
this.keyBindsList.resetMappingAndUpdateButtons();
@@ -100,5 +_,18 @@
@@ -102,5 +_,18 @@
}
this.resetButton.active = flag;
+ }
+
+ @Override
+ public boolean keyReleased(int keyCode, int scanCode, int modifiers) {
+ public boolean keyReleased(KeyEvent event) {
+ // Forge: We wait for a second key above if the first press is a modifier
+ // but if they release the modifier then set it explicitly.
+ var key = InputConstants.getKey(keyCode, scanCode);
+ var key = InputConstants.getKey(event);
+ if (this.selectedKey != null && this.selectedKey.getKey() == key) {
+ this.selectedKey = null;
+ this.lastKeySelection = Util.getMillis();
+ this.keyBindsList.resetMappingAndUpdateButtons();
+ }
+ return super.keyReleased(keyCode, scanCode, modifiers);
+ return super.keyReleased(event);
}
}
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/packs/PackSelectionModel.java
+++ b/net/minecraft/client/gui/screens/packs/PackSelectionModel.java
@@ -106,6 +_,10 @@
@@ -108,6 +_,10 @@
boolean canMoveUp();
boolean canMoveDown();
@@ -11,7 +11,7 @@
}
@OnlyIn(Dist.CLIENT)
@@ -205,6 +_,11 @@
@@ -207,6 +_,11 @@
@Override
public void moveDown() {
this.move(1);
@@ -1,11 +0,0 @@
--- a/net/minecraft/client/gui/screens/packs/PackSelectionScreen.java
+++ b/net/minecraft/client/gui/screens/packs/PackSelectionScreen.java
@@ -159,7 +_,7 @@
TransferableSelectionList.PackEntry transferableselectionlist$packentry = p_100014_.getSelected();
String s = transferableselectionlist$packentry == null ? "" : transferableselectionlist$packentry.getPackId();
p_100014_.setSelected(null);
- p_100015_.forEach(
+ p_100015_.filter(PackSelectionModel.Entry::notHidden).forEach(
p_404866_ -> {
TransferableSelectionList.PackEntry transferableselectionlist$packentry1 = new TransferableSelectionList.PackEntry(
this.minecraft, p_100014_, p_404866_
@@ -0,0 +1,11 @@
--- a/net/minecraft/client/gui/screens/packs/TransferableSelectionList.java
+++ b/net/minecraft/client/gui/screens/packs/TransferableSelectionList.java
@@ -64,7 +_,7 @@
Component component = Component.empty().append(this.title).withStyle(ChatFormatting.UNDERLINE, ChatFormatting.BOLD);
this.addEntry(new TransferableSelectionList.HeaderEntry(this.minecraft.font, component), (int)(9.0F * 1.5F));
this.setSelected(null);
- p_429245_.forEach(p_430444_ -> {
+ p_429245_.filter(PackSelectionModel.Entry::notHidden).forEach(p_430444_ -> {
TransferableSelectionList.PackEntry transferableselectionlist$packentry = new TransferableSelectionList.PackEntry(this.minecraft, this, p_430444_);
this.addEntry(transferableselectionlist$packentry);
if (p_430177_ != null && p_430177_.getId().equals(p_430444_.getId())) {
@@ -1,7 +1,7 @@
--- a/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java
+++ b/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java
@@ -329,6 +_,8 @@
this.minecraft.forceSetScreen(new GenericMessageScreen(Component.translatable("selectWorld.resource_load")));
this.minecraft.setScreenAndShow(new GenericMessageScreen(Component.translatable("selectWorld.resource_load")));
PackRepository packrepository = ServerPacksSource.createPackRepository(p_333651_);
+ net.minecraftforge.common.ForgeHooks.readAdditionalLevelSaveData(p_333651_, p_333651_.getLevelDirectory());
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/worldselection/WorldSelectionList.java
+++ b/net/minecraft/client/gui/screens/worldselection/WorldSelectionList.java
@@ -75,6 +_,7 @@
@@ -79,6 +_,7 @@
static final ResourceLocation JOIN_HIGHLIGHTED_SPRITE = ResourceLocation.withDefaultNamespace("world_list/join_highlighted");
static final ResourceLocation JOIN_SPRITE = ResourceLocation.withDefaultNamespace("world_list/join");
static final Logger LOGGER = LogUtils.getLogger();
@@ -8,31 +8,31 @@
static final Component FROM_NEWER_TOOLTIP_1 = Component.translatable("selectWorld.tooltip.fromNewerVersion1").withStyle(ChatFormatting.RED);
static final Component FROM_NEWER_TOOLTIP_2 = Component.translatable("selectWorld.tooltip.fromNewerVersion2").withStyle(ChatFormatting.RED);
static final Component SNAPSHOT_TOOLTIP_1 = Component.translatable("selectWorld.tooltip.snapshot1").withStyle(ChatFormatting.GOLD);
@@ -400,6 +_,7 @@
p_281612_.drawString(this.minecraft.font, s1, p_282820_ + 32 + 3, p_283181_ + 9 + 3, -8355712);
p_281612_.drawString(this.minecraft.font, component, p_282820_ + 32 + 3, p_283181_ + 9 + 9 + 3, -8355712);
p_281612_.blit(RenderPipelines.GUI_TEXTURED, this.icon.textureLocation(), p_282820_, p_283181_, 0.0F, 0.0F, 32, 32, 32, 32);
+ renderExperimentalWarning(p_281612_, p_283204_, p_283025_, p_283181_, p_282820_);
if (this.minecraft.options.touchscreen().get() || p_283396_) {
p_281612_.fill(p_282820_, p_283181_, p_282820_ + 32, p_283181_ + 32, -1601138544);
int j = p_283204_ - p_282820_;
@@ -450,6 +_,19 @@
p_281612_.blitSprite(RenderPipelines.GUI_TEXTURED, resourcelocation, p_282820_, p_283181_, 32, 32);
}
@@ -494,6 +_,19 @@
}
+ }
+
}
+ // FORGE: Patch in experimental warning icon for worlds in the world selection screen
+ private void renderExperimentalWarning(GuiGraphics guiGraphics, int mouseX, int mouseY, int top, int left) {
+ if (this.summary.isLifecycleExperimental()) {
+ int leftStart = left + WorldSelectionList.this.getRowWidth();
+ int leftStart = left + this.list.getRowWidth();
+ guiGraphics.blit(RenderPipelines.GUI_TEXTURED, WorldSelectionList.FORGE_EXPERIMENTAL_WARNING_ICON, leftStart - 36, top, 0.0F, 0.0F, 32, 32, 32, 32);
+ if (WorldSelectionList.this.getEntryAtPosition(mouseX, mouseY) == this && mouseX > leftStart - 36 && mouseX < leftStart) {
+ if (this.list.getEntryAtPosition(mouseX, mouseY) == this && mouseX > leftStart - 36 && mouseX < leftStart) {
+ var font = Minecraft.getInstance().font;
+ List<net.minecraft.util.FormattedCharSequence> tooltip = font.split(Component.translatable("forge.experimentalsettings.tooltip"), 200);
+ guiGraphics.setTooltipForNextFrame(font, tooltip, mouseX, mouseY);
+ }
+ }
}
+ }
+
@Override
public Component getNarration() {
Component component = Component.translatable(
@@ -520,6 +_,7 @@
this.infoText.setPosition(i, this.getContentY() + 9 + 9 + 3);
this.infoText.render(p_424437_, p_425443_, p_425024_, p_424775_);
p_424437_.blit(RenderPipelines.GUI_TEXTURED, this.icon.textureLocation(), this.getContentX(), this.getContentY(), 0.0F, 0.0F, 32, 32, 32, 32);
+ renderExperimentalWarning(p_424437_, p_425443_, p_425024_, this.getContentY(), this.getContentX());
if (this.list.entryType == WorldSelectionList.EntryType.SINGLEPLAYER && (this.minecraft.options.touchscreen().get() || p_430261_)) {
p_424437_.fill(this.getContentX(), this.getContentY(), this.getContentX() + 32, this.getContentY() + 32, -1601138544);
int j = p_425443_ - this.getContentX();
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/main/Main.java
+++ b/net/minecraft/client/main/Main.java
@@ -123,8 +_,8 @@
@@ -116,8 +_,8 @@
CrashReport.preload();
logger = LogUtils.getLogger();
s1 = "Bootstrap";
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/model/HumanoidModel.java
+++ b/net/minecraft/client/model/HumanoidModel.java
@@ -255,6 +_,8 @@
@@ -290,6 +_,8 @@
case BRUSH:
this.rightArm.xRot = this.rightArm.xRot * 0.5F - (float) (Math.PI / 5);
this.rightArm.yRot = 0.0F;
@@ -9,7 +9,7 @@
}
}
@@ -299,6 +_,8 @@
@@ -334,6 +_,8 @@
case BRUSH:
this.leftArm.xRot = this.leftArm.xRot * 0.5F - (float) (Math.PI / 5);
this.leftArm.yRot = 0.0F;
@@ -18,7 +18,7 @@
}
}
@@ -377,7 +_,7 @@
@@ -402,7 +_,7 @@
}
@OnlyIn(Dist.CLIENT)
@@ -27,7 +27,7 @@
EMPTY(false),
ITEM(false),
BLOCK(false),
@@ -393,10 +_,28 @@
@@ -418,10 +_,28 @@
private ArmPose(final boolean p_102896_) {
this.twoHanded = p_102896_;
@@ -1,10 +1,10 @@
--- a/net/minecraft/client/model/geom/LayerDefinitions.java
+++ b/net/minecraft/client/model/geom/LayerDefinitions.java
@@ -505,6 +_,7 @@
builder.put(ModelLayers.createHangingSignModelName(p_374591_, hangingsignrenderer$attachmenttype), layerdefinition60);
@@ -506,6 +_,7 @@
builder.put(ModelLayers.createHangingSignModelName(p_374591_, hangingsignrenderer$attachmenttype), layerdefinition57);
}
});
+ net.minecraftforge.client.ForgeHooksClient.loadLayerDefinitions(builder);
ImmutableMap<ModelLayerLocation, LayerDefinition> immutablemap = builder.build();
List<ModelLayerLocation> list = ModelLayers.getKnownLocations().filter(p_171117_ -> !immutablemap.containsKey(p_171117_)).collect(Collectors.toList());
List<ModelLayerLocation> list = ModelLayers.getKnownLocations().filter(p_171117_ -> !immutablemap.containsKey(p_171117_)).toList();
if (!list.isEmpty()) {
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/model/geom/ModelLayers.java
+++ b/net/minecraft/client/model/geom/ModelLayers.java
@@ -336,15 +_,18 @@
@@ -328,15 +_,18 @@
}
public static ModelLayerLocation createStandingSignModelName(WoodType p_171292_) {
@@ -1,10 +1,10 @@
--- a/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java
+++ b/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java
@@ -153,6 +_,7 @@
@@ -160,6 +_,7 @@
@Override
public void handleCustomPayload(ClientboundCustomPayloadPacket p_298103_) {
+ if (net.minecraftforge.common.ForgeHooks.onCustomPayload(p_298103_.payload(), this.connection)) return;
CustomPacketPayload custompacketpayload = p_298103_.payload();
if (!(custompacketpayload instanceof DiscardedPayload)) {
PacketUtils.ensureRunningOnSameThread(p_298103_, this, this.minecraft);
PacketUtils.ensureRunningOnSameThread(p_298103_, this, this.minecraft.packetProcessor());
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/multiplayer/ClientConfigurationPacketListenerImpl.java
+++ b/net/minecraft/client/multiplayer/ClientConfigurationPacketListenerImpl.java
@@ -157,6 +_,7 @@
@@ -184,6 +_,7 @@
return true;
}
}));
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java
+++ b/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java
@@ -208,6 +_,7 @@
@@ -214,6 +_,7 @@
Component component = this.wasTransferredTo ? CommonComponents.TRANSFER_CONNECT_FAILED : CommonComponents.CONNECT_FAILED;
if (this.serverData != null && this.serverData.isRealm()) {
this.minecraft.setScreen(new DisconnectedScreen(this.parent, component, p_342266_.reason(), CommonComponents.GUI_BACK));
@@ -8,7 +8,7 @@
} else {
this.minecraft.setScreen(new DisconnectedScreen(this.parent, component, p_342266_));
}
@@ -232,6 +_,7 @@
@@ -238,6 +_,7 @@
@Override
public void handleCustomQuery(ClientboundCustomQueryPacket p_104545_) {
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/multiplayer/ClientLevel.java
+++ b/net/minecraft/client/multiplayer/ClientLevel.java
@@ -130,6 +_,7 @@
@@ -145,6 +_,7 @@
p_389331_.put(BiomeColors.FOLIAGE_COLOR_RESOLVER, new BlockTintCache(p_194177_ -> this.calculateBlockTint(p_194177_, BiomeColors.FOLIAGE_COLOR_RESOLVER)));
p_389331_.put(BiomeColors.DRY_FOLIAGE_COLOR_RESOLVER, new BlockTintCache(p_389335_ -> this.calculateBlockTint(p_389335_, BiomeColors.DRY_FOLIAGE_COLOR_RESOLVER)));
p_389331_.put(BiomeColors.WATER_COLOR_RESOLVER, new BlockTintCache(p_194168_ -> this.calculateBlockTint(p_194168_, BiomeColors.WATER_COLOR_RESOLVER)));
@@ -8,7 +8,7 @@
});
private final ClientChunkCache chunkSource;
private final Deque<Runnable> lightUpdateQueue = Queues.newArrayDeque();
@@ -139,6 +_,8 @@
@@ -156,6 +_,8 @@
private final int seaLevel;
private boolean tickDayTime;
private static final Set<Item> MARKER_PARTICLE_ITEMS = Set.of(Items.BARRIER, Items.LIGHT);
@@ -16,8 +16,8 @@
+ private final net.minecraftforge.client.model.data.ModelDataManager modelDataManager = new net.minecraftforge.client.model.data.ModelDataManager(this);
public void handleBlockChangedAck(int p_233652_) {
this.blockStatePredictionHandler.endPredictionsUpTo(p_233652_, this);
@@ -217,6 +_,8 @@
if (SharedConstants.DEBUG_BLOCK_BREAK) {
@@ -239,6 +_,8 @@
this.serverSimulationDistance = p_364305_;
this.updateSkyBrightness();
this.prepareWeather();
@@ -26,7 +26,7 @@
}
public void queueLightUpdate(Runnable p_194172_) {
@@ -299,6 +_,7 @@
@@ -343,6 +_,7 @@
p_104640_.setOldPosAndRot();
p_104640_.tickCount++;
Profiler.get().push(() -> BuiltInRegistries.ENTITY_TYPE.getKey(p_104640_.getType()).toString());
@@ -34,7 +34,7 @@
p_104640_.tick();
Profiler.get().pop();
@@ -350,8 +_,10 @@
@@ -394,8 +_,10 @@
}
public void addEntity(Entity p_104741_) {
@@ -45,7 +45,7 @@
}
public void removeEntity(int p_171643_, Entity.RemovalReason p_171644_) {
@@ -532,6 +_,12 @@
@@ -576,6 +_,12 @@
float p_263349_,
long p_263408_
) {
@@ -58,7 +58,7 @@
if (p_394722_ == this.minecraft.player) {
this.playSound(p_263372_, p_263404_, p_263365_, p_263335_.value(), p_263417_, p_263416_, p_263349_, false, p_263408_);
}
@@ -541,6 +_,12 @@
@@ -585,6 +_,12 @@
public void playSeededSound(
@Nullable Entity p_263536_, Entity p_396496_, Holder<SoundEvent> p_263518_, SoundSource p_263487_, float p_263538_, float p_263524_, long p_263509_
) {
@@ -71,8 +71,48 @@
if (p_263536_ == this.minecraft.player) {
this.minecraft.getSoundManager().play(new EntityBoundSoundInstance(p_263518_.value(), p_263487_, p_263538_, p_263524_, p_396496_, p_263509_));
}
@@ -991,6 +_,16 @@
this.connection.registerForCleaning(p_396040_);
@@ -1032,7 +_,7 @@
@Override
public void addDestroyBlockEffect(BlockPos p_171667_, BlockState p_171668_) {
- if (!p_171668_.isAir() && p_171668_.shouldSpawnTerrainParticles()) {
+ if (!p_171668_.isAir() && !net.minecraftforge.client.extensions.common.IClientBlockExtensions.of(p_171668_).addDestroyEffects(p_171668_, this, p_171667_, this.minecraft.particleEngine)) {
VoxelShape voxelshape = p_171668_.getShape(this, p_171667_);
double d0 = 0.25;
voxelshape.forAllBoxes(
@@ -1067,6 +_,7 @@
p_171668_,
p_171667_
)
+ .updateSprite(p_171668_, p_171667_)
);
}
}
@@ -1076,6 +_,13 @@
}
}
+ public void addBreakingBlockEffect(BlockPos pos, net.minecraft.world.phys.BlockHitResult target) {
+ var state = this.getBlockState(pos);
+ if (!net.minecraftforge.client.extensions.common.IClientBlockExtensions.of(state).addHitEffects(state, this, target, this.minecraft.particleEngine))
+ addBreakingBlockEffect(pos, target.getDirection());
+ }
+
+ /** @deprecated Forge - Use crack(BlockPos, BlockHitResult) as it has more context and gives more control to modders */
public void addBreakingBlockEffect(BlockPos p_425440_, Direction p_431745_) {
BlockState blockstate = this.getBlockState(p_425440_);
if (blockstate.getRenderShape() != RenderShape.INVISIBLE && blockstate.shouldSpawnTerrainParticles()) {
@@ -1111,7 +_,7 @@
d0 = i + aabb.maxX + 0.1F;
}
- this.minecraft.particleEngine.add(new TerrainParticle(this, d0, d1, d2, 0.0, 0.0, 0.0, blockstate, p_425440_).setPower(0.2F).scale(0.6F));
+ this.minecraft.particleEngine.add(new TerrainParticle(this, d0, d1, d2, 0.0, 0.0, 0.0, blockstate, p_425440_).updateSprite(blockstate, p_425440_).setPower(0.2F).scale(0.6F));
}
}
@@ -1175,6 +_,16 @@
this.explosionTracker.track(p_429129_, p_428744_, p_431051_, p_431683_);
}
+ @Override
@@ -88,7 +128,7 @@
@OnlyIn(Dist.CLIENT)
public static class ClientLevelData implements WritableLevelData {
private final boolean hardcore;
@@ -1079,6 +_,7 @@
@@ -1256,6 +_,7 @@
}
public void setDifficulty(Difficulty p_104852_) {
@@ -96,7 +136,7 @@
this.difficulty = p_104852_;
}
@@ -1121,6 +_,12 @@
@@ -1298,6 +_,12 @@
break;
default:
}
@@ -109,7 +149,7 @@
}
public void onTrackingEnd(Entity p_171716_) {
@@ -1133,6 +_,15 @@
@@ -1310,6 +_,15 @@
ClientLevel.this.dragonParts.removeAll(Arrays.asList(enderdragon.getSubEntities()));
break;
default:
@@ -1,14 +1,14 @@
--- a/net/minecraft/client/multiplayer/ClientPacketListener.java
+++ b/net/minecraft/client/multiplayer/ClientPacketListener.java
@@ -528,6 +_,7 @@
this.minecraft.debugRenderer.clear();
@@ -514,6 +_,7 @@
this.debugSubscriber.clear();
this.minecraft.levelRenderer.debugRenderer.refreshRendererList();
this.minecraft.player.resetPos();
+ net.minecraftforge.client.event.ForgeEventFactoryClient.firePlayerLogin(this.minecraft.gameMode, this.minecraft.player, this.minecraft.getConnection().connection);
this.minecraft.player.setId(p_105030_.playerId());
this.level.addEntity(this.minecraft.player);
this.minecraft.player.input = new KeyboardInput(this.minecraft.options);
@@ -1315,6 +_,8 @@
@@ -1321,6 +_,8 @@
localplayer1.getAttributes().assignBaseValues(localplayer.getAttributes());
}
@@ -17,7 +17,7 @@
this.level.addEntity(localplayer1);
localplayer1.input = new KeyboardInput(this.minecraft.options);
this.minecraft.gameMode.adjustPlayer(localplayer1);
@@ -1462,7 +_,7 @@
@@ -1469,7 +_,7 @@
ProblemReporter.ScopedCollector problemreporter$scopedcollector = new ProblemReporter.ScopedCollector(p_404890_.problemPath(), LOGGER);
try {
@@ -26,10 +26,10 @@
} catch (Throwable throwable1) {
try {
problemreporter$scopedcollector.close();
@@ -1630,7 +_,9 @@
@@ -1646,7 +_,9 @@
@Override
public void handleCommands(ClientboundCommandsPacket p_104990_) {
PacketUtils.ensureRunningOnSameThread(p_104990_, this, this.minecraft);
PacketUtils.ensureRunningOnSameThread(p_104990_, this, this.minecraft.packetProcessor());
- this.commands = new CommandDispatcher<>(p_104990_.getRoot(CommandBuildContext.simple(this.registryAccess, this.enabledFeatures), COMMAND_NODE_BUILDER));
+ var context = CommandBuildContext.simple(this.registryAccess, this.enabledFeatures);
+ this.commands = new CommandDispatcher<>(p_104990_.getRoot(context, COMMAND_NODE_BUILDER));
@@ -37,7 +37,7 @@
}
@Override
@@ -1731,6 +_,7 @@
@@ -1747,6 +_,7 @@
if (this.minecraft.screen instanceof RecipeUpdateListener recipeupdatelistener) {
recipeupdatelistener.recipesUpdated();
}
@@ -45,7 +45,7 @@
}
@Override
@@ -1769,6 +_,8 @@
@@ -1785,6 +_,8 @@
this.fuelValues = FuelValues.vanillaBurnTimes(this.registryAccess, this.enabledFeatures);
List<ItemStack> list1 = List.copyOf(CreativeModeTabs.searchTab().getDisplayItems());
this.searchTrees.updateCreativeTags(list1);
@@ -54,7 +54,7 @@
}
@Override
@@ -2617,6 +_,8 @@
@@ -2614,6 +_,8 @@
}
public void sendChat(String p_249888_) {
@@ -63,7 +63,7 @@
Instant instant = Instant.now();
long i = Crypt.SaltSupplier.getLong();
LastSeenMessagesTracker.Update lastseenmessagestracker$update = this.lastSeenMessages.generateAndApplyUpdate();
@@ -2625,6 +_,7 @@
@@ -2622,6 +_,7 @@
}
public void sendCommand(String p_250092_) {
@@ -71,3 +71,11 @@
SignableCommand<ClientSuggestionProvider> signablecommand = SignableCommand.of(this.commands.parse(p_250092_, this.suggestionsProvider));
if (signablecommand.arguments().isEmpty()) {
this.send(new ServerboundChatCommandPacket(p_250092_));
@@ -2638,6 +_,7 @@
}
public void sendUnattendedCommand(String p_407213_, @Nullable Screen p_406262_) {
+ if (net.minecraftforge.client.ClientCommandHandler.runCommand(p_407213_)) return;
switch (this.verifyCommand(p_407213_)) {
case NO_ISSUES:
this.send(new ServerboundChatCommandPacket(p_407213_));
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/multiplayer/MultiPlayerGameMode.java
+++ b/net/minecraft/client/multiplayer/MultiPlayerGameMode.java
@@ -111,6 +_,7 @@
@@ -112,6 +_,7 @@
}
public boolean destroyBlock(BlockPos p_105268_) {
@@ -8,7 +8,7 @@
if (this.minecraft.player.blockActionRestricted(this.minecraft.level, p_105268_, this.localPlayerMode)) {
return false;
} else {
@@ -125,9 +_,8 @@
@@ -126,9 +_,8 @@
} else if (blockstate.isAir()) {
return false;
} else {
@@ -19,15 +19,15 @@
if (flag) {
block.destroy(level, p_105268_, blockstate);
}
@@ -148,6 +_,7 @@
BlockState blockstate = this.minecraft.level.getBlockState(p_105270_);
this.minecraft.getTutorial().onDestroyBlock(this.minecraft.level, p_105270_, blockstate, 1.0F);
@@ -157,6 +_,7 @@
}
this.startPrediction(this.minecraft.level, p_233757_ -> {
+ if (!net.minecraftforge.event.ForgeEventFactory.isLeftClickBlockCancelled(this.minecraft.player, p_105270_, p_105271_, ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK))
this.destroyBlock(p_105270_);
return new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, p_105270_, p_105271_, p_233757_);
});
@@ -157,15 +_,18 @@
@@ -170,6 +_,7 @@
this.connection
.send(new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK, this.destroyBlockPos, p_105271_));
}
@@ -35,6 +35,7 @@
BlockState blockstate1 = this.minecraft.level.getBlockState(p_105270_);
this.minecraft.getTutorial().onDestroyBlock(this.minecraft.level, p_105270_, blockstate1, 0.0F);
@@ -180,9 +_,11 @@
this.startPrediction(this.minecraft.level, p_233728_ -> {
boolean flag = !blockstate1.isAir();
if (flag && this.destroyProgress == 0.0F) {
@@ -46,7 +47,7 @@
if (flag && blockstate1.getDestroyProgress(this.minecraft.player, this.minecraft.player.level(), p_105270_) >= 1.0F) {
this.destroyBlock(p_105270_);
} else {
@@ -176,6 +_,7 @@
@@ -193,6 +_,7 @@
this.destroyTicks = 0.0F;
this.minecraft.level.destroyBlockProgress(this.minecraft.player.getId(), this.destroyBlockPos, this.getDestroyStage());
}
@@ -54,15 +55,15 @@
return new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, p_105270_, p_105271_, p_233728_);
});
@@ -208,6 +_,7 @@
BlockState blockstate1 = this.minecraft.level.getBlockState(p_105284_);
this.minecraft.getTutorial().onDestroyBlock(this.minecraft.level, p_105284_, blockstate1, 1.0F);
@@ -233,6 +_,7 @@
}
this.startPrediction(this.minecraft.level, p_233753_ -> {
+ if (!net.minecraftforge.event.ForgeEventFactory.isLeftClickBlockCancelled(this.minecraft.player, p_105284_, p_105285_, ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK))
this.destroyBlock(p_105284_);
return new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, p_105284_, p_105285_, p_233753_);
});
@@ -220,7 +_,7 @@
@@ -245,7 +_,7 @@
} else {
this.destroyProgress = this.destroyProgress + blockstate.getDestroyProgress(this.minecraft.player, this.minecraft.player.level(), p_105284_);
if (this.destroyTicks % 4.0F == 0.0F) {
@@ -71,15 +72,15 @@
this.minecraft
.getSoundManager()
.play(
@@ -237,6 +_,7 @@
@@ -262,6 +_,7 @@
this.destroyTicks++;
this.minecraft.getTutorial().onDestroyBlock(this.minecraft.level, p_105284_, blockstate, Mth.clamp(this.destroyProgress, 0.0F, 1.0F));
+ if (net.minecraftforge.event.ForgeEventFactory.onLeftClickBlockHold(this.minecraft.player, p_105284_, p_105285_).getUseItem().isDenied()) return true;
if (this.destroyProgress >= 1.0F) {
this.isDestroying = false;
this.startPrediction(this.minecraft.level, p_233739_ -> {
@@ -275,7 +_,7 @@
if (SharedConstants.DEBUG_BLOCK_BREAK) {
@@ -304,7 +_,7 @@
private boolean sameDestroyTarget(BlockPos p_105282_) {
ItemStack itemstack = this.minecraft.player.getMainHandItem();
@@ -88,7 +89,7 @@
}
private void ensureHasSentCarriedItem() {
@@ -303,12 +_,23 @@
@@ -332,12 +_,23 @@
private InteractionResult performUseItemOn(LocalPlayer p_233747_, InteractionHand p_233748_, BlockHitResult p_233749_) {
BlockPos blockpos = p_233749_.getBlockPos();
ItemStack itemstack = p_233747_.getItemInHand(p_233748_);
@@ -114,7 +115,7 @@
BlockState blockstate = this.minecraft.level.getBlockState(blockpos);
if (!this.connection.isFeatureEnabled(blockstate.getBlock().requiredFeatures())) {
return InteractionResult.FAIL;
@@ -329,8 +_,10 @@
@@ -358,8 +_,10 @@
}
}
@@ -127,7 +128,7 @@
InteractionResult interactionresult2;
if (p_233747_.hasInfiniteMaterials()) {
int i = itemstack.getCount();
@@ -364,6 +_,11 @@
@@ -393,6 +_,11 @@
mutableobject.setValue(InteractionResult.PASS);
return serverbounduseitempacket;
} else {
@@ -139,7 +140,7 @@
InteractionResult interactionresult = itemstack.use(this.minecraft.level, p_233722_, p_233723_);
ItemStack itemstack1;
if (interactionresult instanceof InteractionResult.Success interactionresult$success) {
@@ -374,6 +_,9 @@
@@ -403,6 +_,9 @@
if (itemstack1 != itemstack) {
p_233722_.setItemInHand(p_233723_, itemstack1);
@@ -149,7 +150,7 @@
}
mutableobject.setValue(interactionresult);
@@ -405,6 +_,10 @@
@@ -434,6 +_,10 @@
public InteractionResult interact(Player p_105227_, Entity p_105228_, InteractionHand p_105229_) {
this.ensureHasSentCarriedItem();
this.connection.send(ServerboundInteractPacket.createInteractionPacket(p_105228_, p_105227_.isShiftKeyDown(), p_105229_));
@@ -160,7 +161,7 @@
return (InteractionResult)(this.localPlayerMode == GameType.SPECTATOR ? InteractionResult.PASS : p_105227_.interactOn(p_105228_, p_105229_));
}
@@ -412,6 +_,10 @@
@@ -441,6 +_,10 @@
this.ensureHasSentCarriedItem();
Vec3 vec3 = p_105233_.getLocation().subtract(p_105232_.getX(), p_105232_.getY(), p_105232_.getZ());
this.connection.send(ServerboundInteractPacket.createInteractionPacket(p_105232_, p_105231_.isShiftKeyDown(), p_105234_, vec3));
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/multiplayer/PlayerInfo.java
+++ b/net/minecraft/client/multiplayer/PlayerInfo.java
@@ -88,6 +_,7 @@
@@ -76,6 +_,7 @@
}
protected void setGameMode(GameType p_105318_) {
@@ -1,8 +1,8 @@
--- a/net/minecraft/client/multiplayer/ServerData.java
+++ b/net/minecraft/client/multiplayer/ServerData.java
@@ -37,6 +_,7 @@
private byte[] iconBytes;
@@ -38,6 +_,7 @@
private ServerData.Type type;
private int acceptedCodeOfConduct;
private ServerData.State state = ServerData.State.INITIAL;
+ public net.minecraftforge.client.ExtendedServerListData forgeData = null;
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/multiplayer/ServerStatusPinger.java
+++ b/net/minecraft/client/multiplayer/ServerStatusPinger.java
@@ -99,6 +_,7 @@
@@ -107,6 +_,7 @@
p_105461_.run();
}
});
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/multiplayer/chat/ChatListener.java
+++ b/net/minecraft/client/multiplayer/chat/ChatListener.java
@@ -124,7 +_,9 @@
@@ -133,7 +_,9 @@
Instant instant = Instant.now();
this.handleMessage(null, () -> {
Component component = p_251256_.decorate(p_250375_);
@@ -11,7 +11,7 @@
this.narrateChatMessage(p_251256_, p_250375_);
this.logSystemMessage(component, instant);
this.previousMessageTime = Util.getMillis();
@@ -143,12 +_,16 @@
@@ -152,12 +_,16 @@
MessageSignature messagesignature = p_249430_.signature();
FilterMask filtermask = p_249430_.filterMask();
if (filtermask.isEmpty()) {
@@ -30,7 +30,7 @@
this.narrateChatMessage(p_251766_, component);
}
}
@@ -181,6 +_,8 @@
@@ -190,6 +_,8 @@
public void handleSystemMessage(Component p_240522_, boolean p_240642_) {
if (!this.minecraft.options.hideMatchedNames().get() || !this.minecraft.isBlocked(this.guessChatUUID(p_240522_))) {
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/particle/FireworkParticles.java
+++ b/net/minecraft/client/particle/FireworkParticles.java
@@ -263,6 +_,10 @@
@@ -268,6 +_,10 @@
intlist = IntList.of(DyeColor.BLACK.getFireworkColor());
}
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/particle/FlyTowardsPositionParticle.java
+++ b/net/minecraft/client/particle/FlyTowardsPositionParticle.java
@@ -104,6 +_,7 @@
@@ -114,6 +_,7 @@
this.x = this.xStart + this.xd * f;
this.y = this.yStart + this.yd * f - f1 * 1.2F;
this.z = this.zStart + this.zd * f;
@@ -1,17 +1,9 @@
--- a/net/minecraft/client/particle/Particle.java
+++ b/net/minecraft/client/particle/Particle.java
@@ -248,6 +_,18 @@
@@ -207,6 +_,10 @@
return Optional.empty();
}
+ /**
+ * Forge added method that controls if a particle should be culled to it's bounding box.
+ * Default behaviour is culling enabled
+ */
+ public boolean shouldCull() {
+ return true;
+ }
+
+ public net.minecraft.world.phys.Vec3 getPos() {
+ return new net.minecraft.world.phys.Vec3(this.x, this.y, this.z);
+ }
@@ -1,148 +1,29 @@
--- a/net/minecraft/client/particle/ParticleEngine.java
+++ b/net/minecraft/client/particle/ParticleEngine.java
@@ -72,10 +_,10 @@
private static final int MAX_PARTICLES_PER_LAYER = 16384;
private static final List<ParticleRenderType> RENDER_ORDER = List.of(ParticleRenderType.TERRAIN_SHEET, ParticleRenderType.PARTICLE_SHEET_OPAQUE, ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT);
@@ -26,7 +_,7 @@
public class ParticleEngine {
private static final List<ParticleRenderType> RENDER_ORDER = List.of(ParticleRenderType.SINGLE_QUADS, ParticleRenderType.ITEM_PICKUP, ParticleRenderType.ELDER_GUARDIANS);
protected ClientLevel level;
- private final Map<ParticleRenderType, Queue<Particle>> particles = Maps.newIdentityHashMap();
+ private final Map<ParticleRenderType, Queue<Particle>> particles = Maps.newTreeMap(net.minecraftforge.client.ForgeHooksClient.makeParticleRenderTypeComparator(RENDER_ORDER));
- private final Map<ParticleRenderType, ParticleGroup<?>> particles = Maps.newIdentityHashMap();
+ private final Map<ParticleRenderType, ParticleGroup<?>> particles = Maps.newTreeMap(net.minecraftforge.client.ForgeHooksClient.makeParticleRenderTypeComparator(RENDER_ORDER));
private final Queue<TrackingEmitter> trackingEmitters = Queues.newArrayDeque();
private final RandomSource random = RandomSource.create();
- private final Int2ObjectMap<ParticleProvider<?>> providers = new Int2ObjectOpenHashMap<>();
+ private final Map<ResourceLocation, ParticleProvider<?>> providers = new java.util.HashMap<>();
private final Queue<Particle> particlesToAdd = Queues.newArrayDeque();
private final Map<ResourceLocation, ParticleEngine.MutableSpriteSet> spriteSets = Maps.newHashMap();
private final TextureAtlas textureAtlas;
@@ -205,10 +_,14 @@
this.register(ParticleTypes.FIREFLY, FireflyParticle.FireflyProvider::new);
}
+ /** @deprecated Register via {@link net.minecraftforge.client.event.RegisterParticleProvidersEvent} */
+ @Deprecated
public <T extends ParticleOptions> void register(ParticleType<T> p_107382_, ParticleProvider<T> p_107383_) {
- this.providers.put(BuiltInRegistries.PARTICLE_TYPE.getId(p_107382_), p_107383_);
+ this.providers.put(BuiltInRegistries.PARTICLE_TYPE.getKey(p_107382_), p_107383_);
}
+ /** @deprecated Register via {@link net.minecraftforge.client.event.RegisterParticleProvidersEvent} */
+ @Deprecated
public <T extends ParticleOptions> void register(ParticleType<T> p_273423_, ParticleProvider.Sprite<T> p_273134_) {
this.register(
p_273423_,
@@ -225,10 +_,12 @@
);
}
+ /** @deprecated Register via {@link net.minecraftforge.client.event.RegisterParticleProvidersEvent} */
+ @Deprecated
public <T extends ParticleOptions> void register(ParticleType<T> p_107379_, ParticleEngine.SpriteParticleRegistration<T> p_107380_) {
ParticleEngine.MutableSpriteSet particleengine$mutablespriteset = new ParticleEngine.MutableSpriteSet();
this.spriteSets.put(BuiltInRegistries.PARTICLE_TYPE.getKey(p_107379_), particleengine$mutablespriteset);
- this.providers.put(BuiltInRegistries.PARTICLE_TYPE.getId(p_107379_), p_107380_.create(particleengine$mutablespriteset));
+ this.providers.put(BuiltInRegistries.PARTICLE_TYPE.getKey(p_107379_), p_107380_.create(particleengine$mutablespriteset));
}
@Override
@@ -348,7 +_,7 @@
private final Object2IntOpenHashMap<ParticleLimit> trackedParticleCounts = new Object2IntOpenHashMap<>();
@@ -63,7 +_,7 @@
private <T extends ParticleOptions> Particle makeParticle(
T p_107396_, double p_107397_, double p_107398_, double p_107399_, double p_107400_, double p_107401_, double p_107402_
) {
- ParticleProvider<T> particleprovider = (ParticleProvider<T>)this.providers.get(BuiltInRegistries.PARTICLE_TYPE.getId(p_107396_.getType()));
+ ParticleProvider<T> particleprovider = (ParticleProvider<T>)this.providers.get(BuiltInRegistries.PARTICLE_TYPE.getKey(p_107396_.getType()));
- ParticleProvider<T> particleprovider = (ParticleProvider<T>)this.resourceManager.getProviders().get(BuiltInRegistries.PARTICLE_TYPE.getId(p_107396_.getType()));
+ ParticleProvider<T> particleprovider = (ParticleProvider<T>)this.resourceManager.getProvider(p_107396_.getType());
return particleprovider == null
? null
: particleprovider.createParticle(p_107396_, this.level, p_107397_, p_107398_, p_107399_, p_107400_, p_107401_, p_107402_);
@@ -424,28 +_,36 @@
}
: particleprovider.createParticle(p_107396_, this.level, p_107397_, p_107398_, p_107399_, p_107400_, p_107401_, p_107402_, this.random);
@@ -123,7 +_,7 @@
}
+ /**@deprecated Forge: use {@link #render(Camera, float, net.minecraft.client.renderer.culling.Frustum)} with Frustum as additional parameter*/
+ @Deprecated
public void render(Camera p_107340_, float p_107341_, MultiBufferSource.BufferSource p_377798_) {
public void extract(ParticlesRenderState p_423938_, Frustum p_424803_, Camera p_430521_, float p_426823_) {
- for (ParticleRenderType particlerendertype : RENDER_ORDER) {
+ render(p_107340_, p_107341_, p_377798_, null);
+ }
+
+ public void render(Camera p_107340_, float p_107341_, MultiBufferSource.BufferSource p_377798_, @Nullable net.minecraft.client.renderer.culling.Frustum frustum) {
+ for (ParticleRenderType particlerendertype : this.particles.keySet()) { // Forge: allow custom IParticleRenderType's
+ if (particlerendertype.renderType() == null) continue;
Queue<Particle> queue = this.particles.get(particlerendertype);
if (queue != null && !queue.isEmpty()) {
- renderParticleType(p_107340_, p_107341_, p_377798_, particlerendertype, queue);
+ renderParticleType(p_107340_, p_107341_, p_377798_, particlerendertype, queue, frustum);
}
}
Queue<Particle> queue1 = this.particles.get(ParticleRenderType.CUSTOM);
if (queue1 != null && !queue1.isEmpty()) {
- renderCustomParticles(p_107340_, p_107341_, p_377798_, queue1);
+ renderCustomParticles(p_107340_, p_107341_, p_377798_, queue1, frustum);
}
p_377798_.endBatch();
}
private static void renderParticleType(
- Camera p_376120_, float p_375470_, MultiBufferSource.BufferSource p_377543_, ParticleRenderType p_378369_, Queue<Particle> p_376283_
+ Camera p_376120_, float p_375470_, MultiBufferSource.BufferSource p_377543_, ParticleRenderType p_378369_, Queue<Particle> p_376283_, @Nullable net.minecraft.client.renderer.culling.Frustum frustum
) {
VertexConsumer vertexconsumer = p_377543_.getBuffer(Objects.requireNonNull(p_378369_.renderType()));
for (Particle particle : p_376283_) {
+ if (frustum != null && particle.shouldCull() && !frustum.isVisible(particle.getBoundingBox())) continue;
try {
particle.render(vertexconsumer, p_376120_, p_375470_);
} catch (Throwable throwable) {
@@ -458,10 +_,11 @@
}
}
- private static void renderCustomParticles(Camera p_377913_, float p_376893_, MultiBufferSource.BufferSource p_376978_, Queue<Particle> p_375784_) {
+ private static void renderCustomParticles(Camera p_377913_, float p_376893_, MultiBufferSource.BufferSource p_376978_, Queue<Particle> p_375784_, @Nullable net.minecraft.client.renderer.culling.Frustum frustum) {
PoseStack posestack = new PoseStack();
for (Particle particle : p_375784_) {
+ if (frustum != null && particle.shouldCull() && !frustum.isVisible(particle.getBoundingBox())) continue;
try {
particle.renderCustom(posestack, p_376978_, p_377913_, p_376893_);
} catch (Throwable throwable) {
@@ -481,7 +_,7 @@
}
public void destroy(BlockPos p_107356_, BlockState p_107357_) {
- if (!p_107357_.isAir() && p_107357_.shouldSpawnTerrainParticles()) {
+ if (!p_107357_.isAir() && !net.minecraftforge.client.extensions.common.IClientBlockExtensions.of(p_107357_).addDestroyEffects(p_107357_, this.level, p_107356_, this)) {
VoxelShape voxelshape = p_107357_.getShape(this.level, p_107356_);
double d0 = 0.25;
voxelshape.forAllBoxes(
@@ -514,6 +_,7 @@
p_107357_,
p_107356_
)
+ .updateSprite(p_107357_, p_107356_)
);
}
}
@@ -523,6 +_,13 @@
}
}
+ public void addBlockHitEffects(BlockPos pos, net.minecraft.world.phys.BlockHitResult target) {
+ var state = level.getBlockState(pos);
+ if (!net.minecraftforge.client.extensions.common.IClientBlockExtensions.of(state).addHitEffects(state, level, target, this))
+ crack(pos, target.getDirection());
+ }
+
+ @Deprecated // Forge - Use addBlockHitEffects as it has more context and gives more control to modders
public void crack(BlockPos p_107368_, Direction p_107369_) {
BlockState blockstate = this.level.getBlockState(p_107368_);
if (blockstate.getRenderShape() != RenderShape.INVISIBLE && blockstate.shouldSpawnTerrainParticles()) {
@@ -558,7 +_,7 @@
d0 = i + aabb.maxX + 0.1F;
}
- this.add(new TerrainParticle(this.level, d0, d1, d2, 0.0, 0.0, 0.0, blockstate, p_107368_).setPower(0.2F).scale(0.6F));
+ this.add(new TerrainParticle(this.level, d0, d1, d2, 0.0, 0.0, 0.0, blockstate, p_107368_).updateSprite(blockstate, p_107368_).setPower(0.2F).scale(0.6F));
}
}
+ for (ParticleRenderType particlerendertype : this.particles.keySet()) { // Forge: allow custom ParticleRenderType's
ParticleGroup<?> particlegroup = this.particles.get(particlerendertype);
if (particlegroup != null && !particlegroup.isEmpty()) {
p_423938_.add(particlegroup.extractRenderState(p_424803_, p_430521_, p_426823_));
@@ -0,0 +1,43 @@
--- a/net/minecraft/client/particle/ParticleResources.java
+++ b/net/minecraft/client/particle/ParticleResources.java
@@ -45,6 +_,7 @@
private static final FileToIdConverter PARTICLE_LISTER = FileToIdConverter.json("particles");
private final Map<ResourceLocation, ParticleResources.MutableSpriteSet> spriteSets = Maps.newHashMap();
private final Int2ObjectMap<ParticleProvider<?>> providers = new Int2ObjectOpenHashMap<>();
+ private final Map<ResourceLocation, ParticleProvider<?>> providersByName = new java.util.HashMap<>();
@Nullable
private Runnable onReload;
@@ -174,14 +_,17 @@
this.register(ParticleTypes.FIREFLY, FireflyParticle.FireflyProvider::new);
}
+ /** @deprecated Register via {@link net.minecraftforge.client.event.RegisterParticleProvidersEvent} */
public <T extends ParticleOptions> void register(ParticleType<T> p_427222_, ParticleProvider<T> p_423729_) {
this.providers.put(BuiltInRegistries.PARTICLE_TYPE.getId(p_427222_), p_423729_);
+ this.providersByName.put(BuiltInRegistries.PARTICLE_TYPE.getKey(p_427222_), p_423729_);
}
+ /** @deprecated Register via {@link net.minecraftforge.client.event.RegisterParticleProvidersEvent} */
public <T extends ParticleOptions> void register(ParticleType<T> p_427223_, ParticleResources.SpriteParticleRegistration<T> p_423156_) {
ParticleResources.MutableSpriteSet particleresources$mutablespriteset = new ParticleResources.MutableSpriteSet();
this.spriteSets.put(BuiltInRegistries.PARTICLE_TYPE.getKey(p_427223_), particleresources$mutablespriteset);
- this.providers.put(BuiltInRegistries.PARTICLE_TYPE.getId(p_427223_), p_423156_.create(particleresources$mutablespriteset));
+ register(p_427223_, p_423156_.create(particleresources$mutablespriteset));
}
@Override
@@ -274,8 +_,13 @@
}
}
+ /** @deprecated Use getProvider(ProviderType) as these ids may not be in sync with servers */
public Int2ObjectMap<ParticleProvider<?>> getProviders() {
return this.providers;
+ }
+
+ public <T extends ParticleOptions> ParticleProvider<T> getProvider(ParticleType<T> type) {
+ return (ParticleProvider<T>)this.providersByName.get(BuiltInRegistries.PARTICLE_TYPE.getKey(type));
}
@OnlyIn(Dist.CLIENT)
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/particle/PortalParticle.java
+++ b/net/minecraft/client/particle/PortalParticle.java
@@ -80,6 +_,7 @@
@@ -91,6 +_,7 @@
this.x = this.xStart + this.xd * f2;
this.y = this.yStart + this.yd * f2 + (1.0F - f);
this.z = this.zStart + this.zd * f2;
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/particle/ReversePortalParticle.java
+++ b/net/minecraft/client/particle/ReversePortalParticle.java
@@ -31,6 +_,7 @@
@@ -42,6 +_,7 @@
this.x = this.x + this.xd * f;
this.y = this.y + this.yd * f;
this.z = this.z + this.zd * f;
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/particle/VibrationSignalParticle.java
+++ b/net/minecraft/client/particle/VibrationSignalParticle.java
@@ -76,6 +_,7 @@
@@ -80,6 +_,7 @@
this.x = Mth.lerp(d0, this.x, vec3.x());
this.y = Mth.lerp(d0, this.y, vec3.y());
this.z = Mth.lerp(d0, this.z, vec3.z());
@@ -1,10 +1,11 @@
--- a/net/minecraft/client/player/AbstractClientPlayer.java
+++ b/net/minecraft/client/player/AbstractClientPlayer.java
@@ -86,6 +_,6 @@
@@ -138,7 +_,7 @@
}
}
- return Mth.lerp(p_362521_, 1.0F, f);
+ return net.minecraftforge.client.event.ForgeEventFactoryClient.fireFovModifierEvent(this, f, p_362521_).getNewFovModifier();
}
}
@Override
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/player/LocalPlayer.java
+++ b/net/minecraft/client/player/LocalPlayer.java
@@ -297,6 +_,7 @@
@@ -295,6 +_,7 @@
ServerboundPlayerActionPacket.Action serverboundplayeractionpacket$action = p_108701_
? ServerboundPlayerActionPacket.Action.DROP_ALL_ITEMS
: ServerboundPlayerActionPacket.Action.DROP_ITEM;
@@ -8,7 +8,7 @@
ItemStack itemstack = this.getInventory().removeFromSelected(p_108701_);
this.connection.send(new ServerboundPlayerActionPacket(serverboundplayeractionpacket$action, BlockPos.ZERO, Direction.DOWN));
return !itemstack.isEmpty();
@@ -478,7 +_,11 @@
@@ -482,7 +_,11 @@
@Override
public void playSound(SoundEvent p_108651_, float p_108652_, float p_108653_) {
@@ -21,7 +21,7 @@
}
@Override
@@ -716,6 +_,7 @@
@@ -720,6 +_,7 @@
&& this.canPlayerFitWithinBlocksAndEntitiesWhen(Pose.CROUCHING)
&& (this.isShiftKeyDown() || !this.isSleeping() && !this.canPlayerFitWithinBlocksAndEntitiesWhen(Pose.STANDING));
this.input.tick();
@@ -29,7 +29,7 @@
this.minecraft.getTutorial().onInput(this.input);
boolean flag3 = false;
if (this.autoJumpTime > 0) {
@@ -788,8 +_,9 @@
@@ -792,8 +_,9 @@
}
this.wasFallFlying = this.isFallFlying();
@@ -41,24 +41,16 @@
}
if (this.isEyeInFluid(FluidTags.WATER)) {
@@ -856,13 +_,14 @@
|| !this.input.hasForwardImpulse()
|| !this.hasEnoughFoodToSprint()
|| this.horizontalCollision && !this.minorHorizontalCollision
- || this.isInWater() && !this.isUnderWater();
+ || this.isInWater() && !this.isUnderWater()
+ || this.isInFluidType((fluidType, height) -> this.canSwimInFluidType(fluidType)) && !this.canStartSwimming();
@@ -859,7 +_,7 @@
}
private boolean shouldStopSwimSprinting() {
return this.hasBlindness()
|| this.isPassenger() && !this.vehicleCanSprint(this.getVehicle())
- || !this.isInWater()
+ || !this.isInWaterOrSwimmable()
|| !this.input.hasForwardImpulse() && !this.onGround() && !this.input.keyPresses.shift()
|| !this.hasEnoughFoodToSprint();
- return !this.isSprintingPossible(true) || !this.isInWater() || !this.input.hasForwardImpulse() && !this.onGround() && !this.input.keyPresses.shift();
+ return !this.isSprintingPossible(true) || !this.isInWaterOrSwimmable() || !this.input.hasForwardImpulse() && !this.onGround() && !this.input.keyPresses.shift();
}
@@ -914,6 +_,8 @@
public Portal.Transition getActivePortalLocalTransition() {
@@ -902,6 +_,8 @@
@Override
public void rideTick() {
super.rideTick();
@@ -67,16 +59,16 @@
this.handsBusy = false;
if (this.getControlledVehicle() instanceof AbstractBoat abstractboat) {
abstractboat.setInput(
@@ -1090,7 +_,7 @@
&& (!this.isPassenger() || this.vehicleCanSprint(this.getVehicle()))
@@ -1079,7 +_,7 @@
&& this.isSprintingPossible(this.getAbilities().flying)
&& !this.isUsingItem()
&& (!this.isFallFlying() || this.isUnderWater())
&& (!this.isMovingSlowly() || this.isUnderWater())
- && (!this.isInWater() || this.isUnderWater());
+ && (!this.isInWater() || this.isUnderWater() || this.canStartSwimming());
- && (!this.isMovingSlowly() || this.isUnderWater());
+ && (!this.isMovingSlowly() || this.isUnderWater() || this.canStartSwimming());
}
private boolean vehicleCanSprint(Entity p_265184_) {
@@ -1169,6 +_,17 @@
@@ -1158,6 +_,17 @@
@Override
public float getVisualRotationYInDegrees() {
return this.getYRot();
@@ -1,17 +1,16 @@
--- a/net/minecraft/client/renderer/GameRenderer.java
+++ b/net/minecraft/client/renderer/GameRenderer.java
@@ -194,6 +_,10 @@
this.setPostEffect(ResourceLocation.withDefaultNamespace("spider"));
} else if (p_109107_ instanceof EnderMan) {
this.setPostEffect(ResourceLocation.withDefaultNamespace("invert"));
+ } else if (p_109107_ != null) {
+ var rl = net.minecraftforge.client.EntitySpectatorShaderManager.get(p_109107_.getType());
+ if (rl != null)
+ this.setPostEffect(rl);
@@ -233,6 +_,9 @@
case null:
default:
this.clearPostEffect();
+ var rl = p_109107_ == null ? null : net.minecraftforge.client.EntitySpectatorShaderManager.get(p_109107_.getType());
+ if (rl != null)
+ this.setPostEffect(rl);
}
}
@@ -205,7 +_,13 @@
@@ -244,7 +_,13 @@
public void processBlurEffect() {
PostChain postchain = this.minecraft.getShaderManager().getPostChain(BLUR_POST_CHAIN_ID, LevelTargetBundle.MAIN_TARGETS);
if (postchain != null) {
@@ -25,7 +24,7 @@
}
}
@@ -364,7 +_,7 @@
@@ -406,7 +_,7 @@
f *= Mth.lerp(f2, 1.0F, 0.85714287F);
}
@@ -34,22 +33,33 @@
}
}
@@ -512,7 +_,7 @@
@@ -557,7 +_,7 @@
}
} else if (flag && this.minecraft.screen != null) {
try {
- this.minecraft.screen.renderWithTooltip(guigraphics, i, j, p_343467_.getGameTimeDeltaTicks());
- this.minecraft.screen.renderWithTooltipAndSubtitles(guigraphics, i, j, p_343467_.getGameTimeDeltaTicks());
+ net.minecraftforge.client.ForgeHooksClient.drawScreen(this.minecraft.screen, guigraphics, i, j, p_343467_.getRealtimeDeltaTicks());
} catch (Throwable throwable1) {
CrashReport crashreport1 = CrashReport.forThrowable(throwable1, "Rendering screen");
CrashReportCategory crashreportcategory1 = crashreport1.addCategory("Screen render details");
@@ -646,6 +_,9 @@
@@ -672,6 +_,10 @@
BlockInWorld blockinworld = new BlockInWorld(this.minecraft.level, blockpos, false);
Registry<Block> registry = this.minecraft.level.registryAccess().lookupOrThrow(Registries.BLOCK);
flag = !itemstack.isEmpty() && (itemstack.canBreakBlockInAdventureMode(blockinworld) || itemstack.canPlaceOnBlockInAdventureMode(blockinworld));
+ if (!flag && blockstate.hasBlockEntity()) {
+ var blockEntity = this.minecraft.level.getBlockEntity(blockpos);
+ flag = blockEntity != null && blockEntity.hasCustomOutlineRendering();
+ }
}
}
}
@@ -706,6 +_,9 @@
if (this.minecraft.options.bobView().get()) {
this.bobView(posestack, camera.getPartialTickTime());
this.bobView(posestack, this.mainCamera.getPartialTickTime());
}
+
+ var cameraSetup = net.minecraftforge.client.event.ForgeEventFactoryClient.fireComputeCameraAngles(this, camera, f);
+ camera.setRotation(cameraSetup.getYaw(), cameraSetup.getPitch(), cameraSetup.getRoll());
+ var cameraSetup = net.minecraftforge.client.event.ForgeEventFactoryClient.fireComputeCameraAngles(this, this.mainCamera, f);
+ this.mainCamera.setRotation(cameraSetup.getYaw(), cameraSetup.getPitch(), cameraSetup.getRoll());
matrix4f.mul(posestack.last().pose());
float f3 = this.minecraft.options.screenEffectScale().get().floatValue();
@@ -5,12 +5,12 @@
@OnlyIn(Dist.CLIENT)
public class ItemBlockRenderTypes {
+ @Deprecated
private static final Map<Block, ChunkSectionLayer> TYPE_BY_BLOCK = Util.make(Maps.newHashMap(), p_389364_ -> {
private static final Map<Block, ChunkSectionLayer> TYPE_BY_BLOCK = Util.make(Maps.newHashMap(), p_420870_ -> {
ChunkSectionLayer chunksectionlayer = ChunkSectionLayer.TRIPWIRE;
p_389364_.put(Blocks.TRIPWIRE, chunksectionlayer);
@@ -353,12 +_,15 @@
p_389364_.put(Blocks.BUBBLE_COLUMN, chunksectionlayer3);
p_389364_.put(Blocks.TINTED_GLASS, chunksectionlayer3);
p_420870_.put(Blocks.TRIPWIRE, chunksectionlayer);
@@ -357,12 +_,15 @@
p_420870_.put(Blocks.BUBBLE_COLUMN, chunksectionlayer3);
p_420870_.put(Blocks.TINTED_GLASS, chunksectionlayer3);
});
+ @Deprecated
private static final Map<Fluid, ChunkSectionLayer> LAYER_BY_FLUID = Util.make(Maps.newHashMap(), p_404902_ -> {
@@ -24,7 +24,7 @@
public static ChunkSectionLayer getChunkRenderType(BlockState p_109283_) {
Block block = p_109283_.getBlock();
if (block instanceof LeavesBlock) {
@@ -369,6 +_,8 @@
@@ -373,6 +_,8 @@
}
}
@@ -33,7 +33,7 @@
public static RenderType getMovingBlockRenderType(BlockState p_109294_) {
Block block = p_109294_.getBlock();
if (block instanceof LeavesBlock) {
@@ -389,11 +_,14 @@
@@ -393,11 +_,14 @@
}
}
@@ -48,7 +48,7 @@
public static RenderType getRenderType(ItemStack p_363859_) {
if (p_363859_.getItem() instanceof BlockItem blockitem) {
Block block = blockitem.getBlock();
@@ -403,12 +_,71 @@
@@ -407,12 +_,71 @@
}
}
@@ -1,30 +1,30 @@
--- a/net/minecraft/client/renderer/ItemInHandRenderer.java
+++ b/net/minecraft/client/renderer/ItemInHandRenderer.java
@@ -336,12 +_,14 @@
@@ -328,12 +_,14 @@
if (iteminhandrenderer$handrenderselection.renderMainHand) {
float f4 = interactionhand == InteractionHand.MAIN_HAND ? f : 0.0F;
float f5 = 1.0F - Mth.lerp(p_109315_, this.oMainHandHeight, this.mainHandHeight);
+ if (!net.minecraftforge.client.ForgeHooksClient.renderSpecificFirstPersonHand(InteractionHand.MAIN_HAND, p_109316_, p_109317_, p_109319_, p_109315_, f1, f4, f5, this.mainHandItem))
this.renderArmWithItem(p_109318_, p_109315_, f1, InteractionHand.MAIN_HAND, f4, this.mainHandItem, f5, p_109316_, p_109317_, p_109319_);
+ if (!net.minecraftforge.client.ForgeHooksClient.renderSpecificFirstPersonHand(InteractionHand.MAIN_HAND, p_109316_, p_424174_, p_109319_, p_109315_, f1, f4, f5, this.mainHandItem))
this.renderArmWithItem(p_109318_, p_109315_, f1, InteractionHand.MAIN_HAND, f4, this.mainHandItem, f5, p_109316_, p_424174_, p_109319_);
}
if (iteminhandrenderer$handrenderselection.renderOffHand) {
float f6 = interactionhand == InteractionHand.OFF_HAND ? f : 0.0F;
float f7 = 1.0F - Mth.lerp(p_109315_, this.oOffHandHeight, this.offHandHeight);
+ if (!net.minecraftforge.client.ForgeHooksClient.renderSpecificFirstPersonHand(InteractionHand.OFF_HAND, p_109316_, p_109317_, p_109319_, p_109315_, f1, f6, f7, this.offHandItem))
this.renderArmWithItem(p_109318_, p_109315_, f1, InteractionHand.OFF_HAND, f6, this.offHandItem, f7, p_109316_, p_109317_, p_109319_);
+ if (!net.minecraftforge.client.ForgeHooksClient.renderSpecificFirstPersonHand(InteractionHand.OFF_HAND, p_109316_, p_424174_, p_109319_, p_109315_, f1, f6, f7, this.offHandItem))
this.renderArmWithItem(p_109318_, p_109315_, f1, InteractionHand.OFF_HAND, f6, this.offHandItem, f7, p_109316_, p_424174_, p_109319_);
}
@@ -407,7 +_,7 @@
@@ -400,7 +_,7 @@
} else {
this.renderOneHandedMap(p_109379_, p_109380_, p_109381_, p_109378_, humanoidarm, p_109376_, p_109377_);
this.renderOneHandedMap(p_109379_, p_425151_, p_109381_, p_109378_, humanoidarm, p_109376_, p_109377_);
}
- } else if (p_109377_.is(Items.CROSSBOW)) {
+ } else if (p_109377_.getItem() instanceof CrossbowItem) {
boolean flag1 = CrossbowItem.isCharged(p_109377_);
boolean flag2 = humanoidarm == HumanoidArm.RIGHT;
int i = flag2 ? 1 : -1;
@@ -452,6 +_,7 @@
@@ -445,6 +_,7 @@
} else {
boolean flag3 = humanoidarm == HumanoidArm.RIGHT;
int j = flag3 ? 1 : -1;
@@ -32,7 +32,7 @@
if (p_109372_.isUsingItem() && p_109372_.getUseItemRemainingTicks() > 0 && p_109372_.getUsedItemHand() == p_109375_) {
switch (p_109377_.getUseAnimation()) {
case NONE:
@@ -579,8 +_,18 @@
@@ -572,8 +_,18 @@
this.offHandHeight = Mth.clamp(this.offHandHeight - 0.4F, 0.0F, 1.0F);
} else {
float f = localplayer.getAttackStrengthScale(1.0F);
@@ -1,171 +1,95 @@
--- a/net/minecraft/client/renderer/LevelRenderer.java
+++ b/net/minecraft/client/renderer/LevelRenderer.java
@@ -121,7 +_,7 @@
private final SkyRenderer skyRenderer = new SkyRenderer();
private final CloudRenderer cloudRenderer = new CloudRenderer();
private final WorldBorderRenderer worldBorderRenderer = new WorldBorderRenderer();
- private final WeatherEffectRenderer weatherEffectRenderer = new WeatherEffectRenderer();
+ private WeatherEffectRenderer weatherEffectRenderer = new WeatherEffectRenderer();
@Nullable
private ClientLevel level;
private final SectionOcclusionGraph sectionOcclusionGraph = new SectionOcclusionGraph();
@@ -480,7 +_,7 @@
postchain1.addToFrame(framegraphbuilder, i, j, this.targets);
@@ -175,6 +_,7 @@
this.submitNodeStorage = p_427160_.getSubmitNodeStorage();
this.levelRenderState = p_429507_;
this.featureRenderDispatcher = p_427160_;
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onInitLevelRenderer();
}
@Override
@@ -460,9 +_,10 @@
profilerfiller.push("entities");
this.extractVisibleEntities(p_109604_, frustum, p_342180_, this.levelRenderState);
profilerfiller.popPush("blockEntities");
- this.extractVisibleBlockEntities(p_109604_, f, this.levelRenderState);
+ this.extractVisibleBlockEntities(p_109604_, f, this.levelRenderState, frustum);
profilerfiller.popPush("blockOutline");
- this.extractBlockOutline(p_109604_, this.levelRenderState);
+ this.extractBlockOutline(p_109604_, this.levelRenderState, p_109603_);
+ p_109603_ = this.levelRenderState.blockOutlineRenderState != null;
profilerfiller.popPush("blockBreaking");
this.extractBlockDestroyAnimation(p_109604_, this.levelRenderState);
profilerfiller.popPush("weather");
@@ -534,6 +_,7 @@
}
- this.addParticlesPass(framegraphbuilder, p_109604_, f, p_407881_);
+ this.addParticlesPass(framegraphbuilder, p_109604_, f, p_407881_, frustum);
CloudStatus cloudstatus = this.minecraft.options.getCloudsType();
if (cloudstatus != CloudStatus.OFF) {
Optional<Integer> optional = this.level.dimensionType().cloudHeight();
@@ -577,7 +_,7 @@
multibuffersource$buffersource.endLastBatch();
this.checkPoseStack(posestack);
p_369478_.popPush("blockentities");
- this.renderBlockEntities(posestack, multibuffersource$buffersource, multibuffersource$buffersource1, p_364769_, f);
+ var renderOutline = this.renderBlockEntities(posestack, multibuffersource$buffersource, multibuffersource$buffersource1, p_364769_, f, p_363733_) || p_362593_;
multibuffersource$buffersource.endLastBatch();
this.checkPoseStack(posestack);
multibuffersource$buffersource.endBatch(RenderType.solid());
@@ -591,8 +_,8 @@
multibuffersource$buffersource.endBatch(Sheets.hangingSignSheet());
multibuffersource$buffersource.endBatch(Sheets.chestSheet());
this.renderBuffers.outlineBufferSource().endOutlineBatch();
- if (p_362593_) {
- this.renderBlockOutline(p_364769_, multibuffersource$buffersource, posestack, false);
+ if (renderOutline) {
+ this.renderBlockOutline(p_364769_, multibuffersource$buffersource, posestack, false, f);
}
p_369478_.popPush("debug");
@@ -620,8 +_,8 @@
chunksectionstorender.renderGroup(ChunkSectionLayerGroup.TRANSLUCENT);
p_369478_.popPush("string");
chunksectionstorender.renderGroup(ChunkSectionLayerGroup.TRIPWIRE);
- if (p_362593_) {
- this.renderBlockOutline(p_364769_, multibuffersource$buffersource, posestack, true);
+ if (renderOutline) {
+ this.renderBlockOutline(p_364769_, multibuffersource$buffersource, posestack, true, f);
}
multibuffersource$buffersource.endBatch();
@@ -629,7 +_,7 @@
});
}
- private void addParticlesPass(FrameGraphBuilder p_366471_, Camera p_363128_, float p_365755_, GpuBufferSlice p_405857_) {
+ private void addParticlesPass(FrameGraphBuilder p_366471_, Camera p_363128_, float p_365755_, GpuBufferSlice p_405857_, Frustum frustum) {
FramePass framepass = p_366471_.addPass("particles");
if (this.targets.particles != null) {
this.targets.particles = framepass.readsAndWrites(this.targets.particles);
@@ -646,7 +_,7 @@
resourcehandle1.get().copyDepthFrom(resourcehandle.get());
}
- this.minecraft.particleEngine.render(p_363128_, p_365755_, this.renderBuffers.bufferSource());
+ this.minecraft.particleEngine.render(p_363128_, p_365755_, this.renderBuffers.bufferSource(), frustum);
});
}
@@ -716,9 +_,9 @@
|| p_365712_.isDetached()
|| p_365712_.getEntity() instanceof LivingEntity && ((LivingEntity)p_365712_.getEntity()).isSleeping()
)
- && (!(entity instanceof LocalPlayer) || p_365712_.getEntity() == entity)) {
+ && (!(entity instanceof LocalPlayer) || p_365712_.getEntity() == entity || (entity == minecraft.player && !minecraft.player.isSpectator()))) { //FORGE: render local player entity when it is not the renderViewEntity
p_368622_.add(entity);
- if (flag1 && this.minecraft.shouldEntityAppearGlowing(entity)) {
+ if (flag1 && (this.minecraft.shouldEntityAppearGlowing(entity) || entity.hasCustomOutlineRendering(this.minecraft.player))) {
flag = true;
}
}
@@ -758,9 +_,10 @@
this.addLateDebugPass(framegraphbuilder, this.levelRenderState.cameraRenderState.pos, p_407881_, frustum);
+ net.minecraftforge.client.FramePassManager.insertForgePasses(framegraphbuilder, targets); // Forge: Modded passes are inserted here.
profilerfiller.popPush("executeFrameGraph");
framegraphbuilder.execute(p_367325_, new FrameGraphBuilder.Inspector() {
@Override
@@ -801,7 +_,7 @@
}
}
- private void renderBlockEntities(
- PoseStack p_366168_, MultiBufferSource.BufferSource p_362022_, MultiBufferSource.BufferSource p_369016_, Camera p_369847_, float p_367074_
+ private boolean renderBlockEntities(
+ PoseStack p_366168_, MultiBufferSource.BufferSource p_362022_, MultiBufferSource.BufferSource p_369016_, Camera p_369847_, float p_367074_, Frustum frustum
) {
+ boolean customOutline = false;
Vec3 vec3 = p_369847_.getPosition();
- private void extractVisibleBlockEntities(Camera p_427254_, float p_426770_, LevelRenderState p_428920_) {
+ private void extractVisibleBlockEntities(Camera p_427254_, float p_426770_, LevelRenderState p_428920_, Frustum frustum) {
Vec3 vec3 = p_427254_.getPosition();
double d0 = vec3.x();
double d1 = vec3.y();
@@ -770,6 +_,7 @@
@@ -812,6 +_,7 @@
List<BlockEntity> list = sectionrenderdispatcher$rendersection.getSectionMesh().getRenderableBlockEntities();
if (!list.isEmpty()) {
for (BlockEntity blockentity : list) {
+ if (!frustum.isVisible(blockentity.getRenderBoundingBox())) continue;
BlockPos blockpos = blockentity.getBlockPos();
MultiBufferSource multibuffersource = p_362022_;
p_366168_.pushPose();
@@ -789,6 +_,9 @@
}
}
+ if (!customOutline && this.shouldShowEntityOutlines() && blockentity.hasCustomOutlineRendering(this.minecraft.player))
+ customOutline = true;
+
this.blockEntityRenderDispatcher.render(blockentity, p_367074_, p_366168_, multibuffersource);
p_366168_.popPose();
}
@@ -802,13 +_,18 @@
SortedSet<BlockDestructionProgress> sortedset = this.destructionProgress.get(blockpos.asLong());
ModelFeatureRenderer.CrumblingOverlay modelfeaturerenderer$crumblingoverlay;
@@ -839,6 +_,7 @@
if (blockentity1.isRemoved()) {
iterator.remove();
} else {
+ if (!frustum.isVisible(blockentity1.getRenderBoundingBox())) continue;
BlockPos blockpos1 = blockentity1.getBlockPos();
p_366168_.pushPose();
p_366168_.translate(blockpos1.getX() - d0, blockpos1.getY() - d1, blockpos1.getZ() - d2);
+ if (!customOutline && this.shouldShowEntityOutlines() && blockentity1.hasCustomOutlineRendering(this.minecraft.player))
+ customOutline = true;
this.blockEntityRenderDispatcher.render(blockentity1, p_367074_, p_366168_, p_362022_);
p_366168_.popPose();
}
BlockEntityRenderState blockentityrenderstate1 = this.blockEntityRenderDispatcher.tryExtractRenderState(blockentity1, p_426770_, null);
if (blockentityrenderstate1 != null) {
p_428920_.blockEntityRenderStates.add(blockentityrenderstate1);
@@ -895,13 +_,21 @@
VertexConsumer vertexconsumer = new SheetedDecalTextureGenerator(
p_365998_.getBuffer(ModelBakery.DESTROY_TYPES.get(blockbreakingrenderstate.progress)), posestack$pose, 1.0F
);
- this.minecraft.getBlockRenderer().renderBreakingTexture(blockbreakingrenderstate.blockState, blockpos, blockbreakingrenderstate, p_366956_, vertexconsumer);
+ this.minecraft.getBlockRenderer().renderBreakingTexture(blockbreakingrenderstate.blockState, blockpos, blockbreakingrenderstate, p_366956_, vertexconsumer, level.getModelDataManager().getAtOrEmpty(blockpos));
p_366956_.popPose();
}
}
- private void extractBlockOutline(Camera p_428965_, LevelRenderState p_424419_) {
+ private void extractBlockOutline(Camera p_428965_, LevelRenderState p_424419_, boolean shouldRender) {
p_424419_.blockOutlineRenderState = null;
+ var custom = net.minecraftforge.client.ForgeHooksClient.onExtractBlockOutline(this, p_428965_, p_424419_, this.minecraft.hitResult);
+ if (custom != null) {
+ p_424419_.blockOutlineRenderState = new BlockOutlineRenderState(BlockPos.ZERO, false, false, net.minecraft.world.phys.shapes.Shapes.empty(), null, null, null, custom);
+ return;
+ } else if (!shouldRender) {
+ return;
+ }
+
+ return customOutline;
}
private void renderBlockDestroyAnimation(PoseStack p_366956_, Camera p_369324_, MultiBufferSource.BufferSource p_365998_) {
@@ -827,14 +_,14 @@
p_366956_.translate(blockpos.getX() - d0, blockpos.getY() - d1, blockpos.getZ() - d2);
PoseStack.Pose posestack$pose = p_366956_.last();
VertexConsumer vertexconsumer = new SheetedDecalTextureGenerator(p_365998_.getBuffer(ModelBakery.DESTROY_TYPES.get(i)), posestack$pose, 1.0F);
- this.minecraft.getBlockRenderer().renderBreakingTexture(this.level.getBlockState(blockpos), blockpos, this.level, p_366956_, vertexconsumer);
+ this.minecraft.getBlockRenderer().renderBreakingTexture(this.level.getBlockState(blockpos), blockpos, this.level, p_366956_, vertexconsumer, level.getModelDataManager().getAtOrEmpty(blockpos));
p_366956_.popPose();
}
}
}
}
- private void renderBlockOutline(Camera p_367935_, MultiBufferSource.BufferSource p_367206_, PoseStack p_365062_, boolean p_368189_) {
+ private void renderBlockOutline(Camera p_367935_, MultiBufferSource.BufferSource p_367206_, PoseStack p_365062_, boolean p_368189_, float partialTicks) {
if (this.minecraft.hitResult instanceof BlockHitResult blockhitresult) {
if (blockhitresult.getType() != HitResult.Type.MISS) {
BlockPos blockpos = blockhitresult.getBlockPos();
@@ -845,6 +_,9 @@
return;
}
+ if (net.minecraftforge.client.ForgeHooksClient.onDrawHighlight(this, p_367935_, blockhitresult, partialTicks, p_365062_, p_367206_))
+ return;
+
Vec3 vec3 = p_367935_.getPosition();
Boolean obool = this.minecraft.options.highContrastBlockOutline().get();
if (obool) {
@@ -860,6 +_,8 @@
p_367206_.endLastBatch();
}
}
+ } else if (this.minecraft.hitResult instanceof net.minecraft.world.phys.EntityHitResult entity) {
+ net.minecraftforge.client.ForgeHooksClient.onDrawHighlight(this, p_367935_, entity, partialTicks, p_365062_, p_367206_);
}
}
@@ -1344,7 +_,7 @@
@@ -927,6 +_,10 @@
private void renderBlockOutline(MultiBufferSource.BufferSource p_367206_, PoseStack p_365062_, boolean p_368189_, LevelRenderState p_422597_) {
BlockOutlineRenderState blockoutlinerenderstate = p_422597_.blockOutlineRenderState;
if (blockoutlinerenderstate != null) {
+ if (blockoutlinerenderstate.customRenderer() != null) {
+ blockoutlinerenderstate.customRenderer().render(p_367206_, p_365062_, p_368189_, p_422597_);
+ return;
+ }
if (blockoutlinerenderstate.isTranslucent() == p_368189_) {
Vec3 vec3 = p_422597_.cameraRenderState.pos;
if (blockoutlinerenderstate.highContrast()) {
@@ -1356,7 +_,7 @@
} else {
int i = p_398213_.packedBrightness(p_109538_, p_109540_);
int j = LightTexture.block(i);
@@ -174,16 +98,12 @@
if (j < k) {
int l = LightTexture.sky(i);
return LightTexture.pack(k, l);
@@ -1406,6 +_,22 @@
@@ -1418,6 +_,18 @@
public CloudRenderer getCloudRenderer() {
return this.cloudRenderer;
+ }
+
+ public Frustum getFrustum() {
+ return this.capturedFrustum != null ? this.capturedFrustum : this.cullingFrustum;
+ }
+
+ public int getTicks() {
+ return this.ticks;
+ }
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/renderer/LightTexture.java
+++ b/net/minecraft/client/renderer/LightTexture.java
@@ -171,7 +_,7 @@
@@ -189,7 +_,7 @@
}
public static int block(int p_109884_) {
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/renderer/RenderType.java
+++ b/net/minecraft/client/renderer/RenderType.java
@@ -521,6 +_,11 @@
@@ -485,6 +_,11 @@
private final int bufferSize;
private final boolean affectsCrumbling;
private final boolean sortOnUpload;
@@ -12,7 +12,7 @@
public static RenderType solid() {
return SOLID;
@@ -701,7 +_,7 @@
@@ -665,7 +_,7 @@
}
public static RenderType text(ResourceLocation p_110498_) {
@@ -21,7 +21,7 @@
}
public static RenderType textBackground() {
@@ -709,19 +_,19 @@
@@ -673,19 +_,19 @@
}
public static RenderType textIntensity(ResourceLocation p_173238_) {
@@ -45,7 +45,7 @@
}
public static RenderType textBackgroundSeeThrough() {
@@ -729,7 +_,7 @@
@@ -693,7 +_,7 @@
}
public static RenderType textIntensitySeeThrough(ResourceLocation p_173241_) {
Loaded 100 of 570 files, more files were not shown because too many files have changed in this diff. Show more