Compare commits

...
1 Commits
Author SHA1 Message Date
LexManos 3da1b644d0 26.2 2026-06-17 19:35:27 -07:00
697 changed files with 5412 additions and 5635 deletions

No files matched your search

+1 -1
View File
@@ -2,7 +2,7 @@ name: Publish
on: on:
push: push:
branches: [ '26.1.2' ] branches: [ '26.2' ]
permissions: permissions:
contents: read contents: read
+1 -1
View File
@@ -21,7 +21,7 @@ ext {
} }
changelog { changelog {
from '64.0' from '65.0'
} }
tasks.register('setup') { tasks.register('setup') {
+2 -2
View File
@@ -2,8 +2,8 @@
MinecraftForge MinecraftForge
============= =============
[![Stable Release](https://img.shields.io/badge/dynamic/json?url=https://files.minecraftforge.net/net/minecraftforge/forge/promotions_slim.json&label=Stable&prefix=1.21.11-&query=$.promos["1.21.11-recommended"]&color=brightgreen&logo=data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyBjbGFzcz0ic3ZnLWlubGluZS0tZmEgZmEtc3RhciBmYS13LTE4IiBhcmlhLWhpZGRlbj0idHJ1ZSIgZGF0YS1pY29uPSJzdGFyIiBkYXRhLXByZWZpeD0iZmFzIiBmb2N1c2FibGU9ImZhbHNlIiByb2xlPSJpbWciIHZpZXdCb3g9IjAgMCA1NzYgNTEyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBkPSJNMjU5LjMgMTcuOEwxOTQgMTUwLjIgNDcuOSAxNzEuNWMtMjYuMiAzLjgtMzYuNyAzNi4xLTE3LjcgNTQuNmwxMDUuNyAxMDMtMjUgMTQ1LjVjLTQuNSAyNi4zIDIzLjIgNDYgNDYuNCAzMy43TDI4OCA0MzkuNmwxMzAuNyA2OC43YzIzLjIgMTIuMiA1MC45LTcuNCA0Ni40LTMzLjdsLTI1LTE0NS41IDEwNS43LTEwM2MxOS0xOC41IDguNS01MC44LTE3LjctNTQuNkwzODIgMTUwLjIgMzE2LjcgMTcuOGMtMTEuNy0yMy42LTQ1LjYtMjMuOS01Ny40IDB6IiBmaWxsPSJ3aGl0ZSIvPgo8L3N2Zz4K)][Download] [![Stable Release](https://img.shields.io/badge/dynamic/json?url=https://files.minecraftforge.net/net/minecraftforge/forge/promotions_slim.json&label=Stable&prefix=26.1.2-&query=$.promos["26.1.2-latest"]&color=brightgreen&logo=data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyBjbGFzcz0ic3ZnLWlubGluZS0tZmEgZmEtc3RhciBmYS13LTE4IiBhcmlhLWhpZGRlbj0idHJ1ZSIgZGF0YS1pY29uPSJzdGFyIiBkYXRhLXByZWZpeD0iZmFzIiBmb2N1c2FibGU9ImZhbHNlIiByb2xlPSJpbWciIHZpZXdCb3g9IjAgMCA1NzYgNTEyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBkPSJNMjU5LjMgMTcuOEwxOTQgMTUwLjIgNDcuOSAxNzEuNWMtMjYuMiAzLjgtMzYuNyAzNi4xLTE3LjcgNTQuNmwxMDUuNyAxMDMtMjUgMTQ1LjVjLTQuNSAyNi4zIDIzLjIgNDYgNDYuNCAzMy43TDI4OCA0MzkuNmwxMzAuNyA2OC43YzIzLjIgMTIuMiA1MC45LTcuNCA0Ni40LTMzLjdsLTI1LTE0NS41IDEwNS43LTEwM2MxOS0xOC41IDguNS01MC44LTE3LjctNTQuNkwzODIgMTUwLjIgMzE2LjcgMTcuOGMtMTEuNy0yMy42LTQ1LjYtMjMuOS01Ny40IDB6IiBmaWxsPSJ3aGl0ZSIvPgo8L3N2Zz4K)][Download]
[![Latest Release](https://img.shields.io/badge/dynamic/json?url=https://files.minecraftforge.net/net/minecraftforge/forge/promotions_slim.json&label=Latest&prefix=26.1.2-&query=$.promos["26.1.2-latest"]&color=blue&logo=data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyBjbGFzcz0ic3ZnLWlubGluZS0tZmEgZmEtYnVnIGZhLXctMTYiIGFyaWEtaGlkZGVuPSJ0cnVlIiBkYXRhLWljb249ImJ1ZyIgZGF0YS1wcmVmaXg9ImZhcyIgZm9jdXNhYmxlPSJmYWxzZSIgcm9sZT0iaW1nIiB2aWV3Qm94PSIwIDAgNTEyIDUxMiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTUxMS45ODggMjg4LjljLS40NzggMTcuNDMtMTUuMjE3IDMxLjEtMzIuNjUzIDMxLjFINDI0djE2YzAgMjEuODY0LTQuODgyIDQyLjU4NC0xMy42IDYxLjE0NWw2MC4yMjggNjAuMjI4YzEyLjQ5NiAxMi40OTcgMTIuNDk2IDMyLjc1OCAwIDQ1LjI1NS0xMi40OTggMTIuNDk3LTMyLjc1OSAxMi40OTYtNDUuMjU2IDBsLTU0LjczNi01NC43MzZDMzQ1Ljg4NiA0NjcuOTY1IDMxNC4zNTEgNDgwIDI4MCA0ODBWMjM2YzAtNi42MjctNS4zNzMtMTItMTItMTJoLTI0Yy02LjYyNyAwLTEyIDUuMzczLTEyIDEydjI0NGMtMzQuMzUxIDAtNjUuODg2LTEyLjAzNS05MC42MzYtMzIuMTA4bC01NC43MzYgNTQuNzM2Yy0xMi40OTggMTIuNDk3LTMyLjc1OSAxMi40OTYtNDUuMjU2IDAtMTIuNDk2LTEyLjQ5Ny0xMi40OTYtMzIuNzU4IDAtNDUuMjU1bDYwLjIyOC02MC4yMjhDOTIuODgyIDM3OC41ODQgODggMzU3Ljg2NCA4OCAzMzZ2LTE2SDMyLjY2NkMxNS4yMyAzMjAgLjQ5MSAzMDYuMzMuMDEzIDI4OC45LS40ODQgMjcwLjgxNiAxNC4wMjggMjU2IDMyIDI1Nmg1NnYtNTguNzQ1bC00Ni42MjgtNDYuNjI4Yy0xMi40OTYtMTIuNDk3LTEyLjQ5Ni0zMi43NTggMC00NS4yNTUgMTIuNDk4LTEyLjQ5NyAzMi43NTgtMTIuNDk3IDQ1LjI1NiAwTDE0MS4yNTUgMTYwaDIyOS40ODlsNTQuNjI3LTU0LjYyN2MxMi40OTgtMTIuNDk3IDMyLjc1OC0xMi40OTcgNDUuMjU2IDAgMTIuNDk2IDEyLjQ5NyAxMi40OTYgMzIuNzU4IDAgNDUuMjU1TDQyNCAxOTcuMjU1VjI1Nmg1NmMxNy45NzIgMCAzMi40ODQgMTQuODE2IDMxLjk4OCAzMi45ek0yNTcgMGMtNjEuODU2IDAtMTEyIDUwLjE0NC0xMTIgMTEyaDIyNEMzNjkgNTAuMTQ0IDMxOC44NTYgMCAyNTcgMHoiIGZpbGw9IndoaXRlIi8+Cjwvc3ZnPgo= [![Latest Release](https://img.shields.io/badge/dynamic/json?url=https://files.minecraftforge.net/net/minecraftforge/forge/promotions_slim.json&label=Latest&prefix=26.2-&query=$.promos["26.2-latest"]&color=blue&logo=data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyBjbGFzcz0ic3ZnLWlubGluZS0tZmEgZmEtYnVnIGZhLXctMTYiIGFyaWEtaGlkZGVuPSJ0cnVlIiBkYXRhLWljb249ImJ1ZyIgZGF0YS1wcmVmaXg9ImZhcyIgZm9jdXNhYmxlPSJmYWxzZSIgcm9sZT0iaW1nIiB2aWV3Qm94PSIwIDAgNTEyIDUxMiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTUxMS45ODggMjg4LjljLS40NzggMTcuNDMtMTUuMjE3IDMxLjEtMzIuNjUzIDMxLjFINDI0djE2YzAgMjEuODY0LTQuODgyIDQyLjU4NC0xMy42IDYxLjE0NWw2MC4yMjggNjAuMjI4YzEyLjQ5NiAxMi40OTcgMTIuNDk2IDMyLjc1OCAwIDQ1LjI1NS0xMi40OTggMTIuNDk3LTMyLjc1OSAxMi40OTYtNDUuMjU2IDBsLTU0LjczNi01NC43MzZDMzQ1Ljg4NiA0NjcuOTY1IDMxNC4zNTEgNDgwIDI4MCA0ODBWMjM2YzAtNi42MjctNS4zNzMtMTItMTItMTJoLTI0Yy02LjYyNyAwLTEyIDUuMzczLTEyIDEydjI0NGMtMzQuMzUxIDAtNjUuODg2LTEyLjAzNS05MC42MzYtMzIuMTA4bC01NC43MzYgNTQuNzM2Yy0xMi40OTggMTIuNDk3LTMyLjc1OSAxMi40OTYtNDUuMjU2IDAtMTIuNDk2LTEyLjQ5Ny0xMi40OTYtMzIuNzU4IDAtNDUuMjU1bDYwLjIyOC02MC4yMjhDOTIuODgyIDM3OC41ODQgODggMzU3Ljg2NCA4OCAzMzZ2LTE2SDMyLjY2NkMxNS4yMyAzMjAgLjQ5MSAzMDYuMzMuMDEzIDI4OC45LS40ODQgMjcwLjgxNiAxNC4wMjggMjU2IDMyIDI1Nmg1NnYtNTguNzQ1bC00Ni42MjgtNDYuNjI4Yy0xMi40OTYtMTIuNDk3LTEyLjQ5Ni0zMi43NTggMC00NS4yNTUgMTIuNDk4LTEyLjQ5NyAzMi43NTgtMTIuNDk3IDQ1LjI1NiAwTDE0MS4yNTUgMTYwaDIyOS40ODlsNTQuNjI3LTU0LjYyN2MxMi40OTgtMTIuNDk3IDMyLjc1OC0xMi40OTcgNDUuMjU2IDAgMTIuNDk2IDEyLjQ5NyAxMi40OTYgMzIuNzU4IDAgNDUuMjU1TDQyNCAxOTcuMjU1VjI1Nmg1NmMxNy45NzIgMCAzMi40ODQgMTQuODE2IDMxLjk4OCAzMi45ek0yNTcgMGMtNjEuODU2IDAtMTEyIDUwLjE0NC0xMTIgMTEyaDIyNEMzNjkgNTAuMTQ0IDMxOC44NTYgMCAyNTcgMHoiIGZpbGw9IndoaXRlIi8+Cjwvc3ZnPgo=
)][Download] [![Discord](https://img.shields.io/discord/313125603924639766.svg?color=%237289da&label=Discord&logo=discord&logoColor=%237289da)][Discord] [![Support](https://img.shields.io/badge/Patreon-Support-orange.svg?logo=Patreon)][Patreon] )][Download] [![Discord](https://img.shields.io/discord/313125603924639766.svg?color=%237289da&label=Discord&logo=discord&logoColor=%237289da)][Discord] [![Support](https://img.shields.io/badge/Patreon-Support-orange.svg?logo=Patreon)][Patreon]
Forge is a free, open-source modding API all of your favourite mods use! Forge is a free, open-source modding API all of your favourite mods use!
@@ -14,16 +14,14 @@ import java.util.List;
import java.util.function.BooleanSupplier; import java.util.function.BooleanSupplier;
import java.util.function.Supplier; import java.util.function.Supplier;
public class CrashReportCallables public class CrashReportCallables {
{
private static final Logger LOGGER = LogUtils.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
private static final List<ISystemReportExtender> crashCallables = Collections.synchronizedList(new ArrayList<>()); private static final List<ISystemReportExtender> crashCallables = Collections.synchronizedList(new ArrayList<>());
/** /**
* Register a custom {@link ISystemReportExtender} * Register a custom {@link ISystemReportExtender}
*/ */
public static void registerCrashCallable(ISystemReportExtender callable) public static void registerCrashCallable(ISystemReportExtender callable) {
{
crashCallables.add(callable); crashCallables.add(callable);
} }
@@ -33,19 +31,15 @@ public class CrashReportCallables
* @param headerName The name of the system report entry * @param headerName The name of the system report entry
* @param reportGenerator The report generator to be called when a crash report is built * @param reportGenerator The report generator to be called when a crash report is built
*/ */
public static void registerCrashCallable(String headerName, Supplier<String> reportGenerator) public static void registerCrashCallable(String headerName, Supplier<String> reportGenerator) {
{ registerCrashCallable(new ISystemReportExtender() {
registerCrashCallable(new ISystemReportExtender()
{
@Override @Override
public String getLabel() public String getLabel() {
{
return headerName; return headerName;
} }
@Override @Override
public String get() public String get() {
{
return reportGenerator.get(); return reportGenerator.get();
} }
}); });
@@ -58,31 +52,23 @@ public class CrashReportCallables
* @param reportGenerator The report generator to be called when a crash report is built * @param reportGenerator The report generator to be called when a crash report is built
* @param active The supplier of the flag to be checked when a crash report is built * @param active The supplier of the flag to be checked when a crash report is built
*/ */
public static void registerCrashCallable(String headerName, Supplier<String> reportGenerator, BooleanSupplier active) public static void registerCrashCallable(String headerName, Supplier<String> reportGenerator, BooleanSupplier active) {
{ registerCrashCallable(new ISystemReportExtender() {
registerCrashCallable(new ISystemReportExtender()
{
@Override @Override
public String getLabel() public String getLabel() {
{
return headerName; return headerName;
} }
@Override @Override
public String get() public String get() {
{
return reportGenerator.get(); return reportGenerator.get();
} }
@Override @Override
public boolean isActive() public boolean isActive() {
{ try {
try
{
return active.getAsBoolean(); return active.getAsBoolean();
} } catch (Throwable t) {
catch (Throwable t)
{
LOGGER.warn("CrashCallable '{}' threw an exception while checking the active flag, disabling", headerName, t); LOGGER.warn("CrashCallable '{}' threw an exception while checking the active flag, disabling", headerName, t);
return false; return false;
} }
@@ -90,8 +76,7 @@ public class CrashReportCallables
}); });
} }
public static List<ISystemReportExtender> allCrashCallables() public static List<ISystemReportExtender> allCrashCallables() {
{
return List.copyOf(crashCallables); return List.copyOf(crashCallables);
} }
} }
@@ -7,12 +7,10 @@ package net.minecraftforge.fml;
import java.util.function.Supplier; import java.util.function.Supplier;
public interface ISystemReportExtender extends Supplier<String> public interface ISystemReportExtender extends Supplier<String> {
{
String getLabel(); String getLabel();
default boolean isActive() default boolean isActive() {
{
return true; return true;
} }
} }
@@ -53,7 +53,7 @@ public abstract class ModContainer {
Supplier<IExtensionPoint.DisplayTest> displayTestSupplier = switch (displayTestString) { Supplier<IExtensionPoint.DisplayTest> displayTestSupplier = switch (displayTestString) {
case "MATCH_VERSION" -> // default displaytest checks for version string match case "MATCH_VERSION" -> // default displaytest checks for version string match
() -> new IExtensionPoint.DisplayTest(() -> this.modInfo.getVersion().toString(), () -> new IExtensionPoint.DisplayTest(() -> this.modInfo.getVersion().toString(),
(incoming, isNetwork) -> Objects.equals(incoming, this.modInfo.getVersion().toString())); (incoming, _) -> Objects.equals(incoming, this.modInfo.getVersion().toString()));
case "IGNORE_SERVER_VERSION" -> // Ignores any version information coming from the server - use for server only mods case "IGNORE_SERVER_VERSION" -> // Ignores any version information coming from the server - use for server only mods
IExtensionPoint.DisplayTest.IGNORE_SERVER_VERSION; IExtensionPoint.DisplayTest.IGNORE_SERVER_VERSION;
case "IGNORE_ALL_VERSION" -> // Ignores all information and provides no information case "IGNORE_ALL_VERSION" -> // Ignores all information and provides no information
@@ -379,8 +379,8 @@ public final class ModLoader {
@SuppressWarnings("removal") @SuppressWarnings("removal")
public static <T extends IModBusEvent> void postEventWrapContainerInModOrder(T event) { public static <T extends IModBusEvent> void postEventWrapContainerInModOrder(T event) {
postEventWithWrapInModOrder(event, postEventWithWrapInModOrder(event,
(mc, e) -> ModLoadingContext.get().setActiveContainer(mc), (mc, _) -> ModLoadingContext.get().setActiveContainer(mc),
(mc, e) -> ModLoadingContext.get().setActiveContainer(null) (_, _) -> ModLoadingContext.get().setActiveContainer(null)
); );
} }
@@ -9,7 +9,6 @@ import net.minecraftforge.fml.loading.progress.ProgressMeter;
import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable; import org.jspecify.annotations.Nullable;
import java.util.Objects;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import java.util.function.Function; import java.util.function.Function;
@@ -99,7 +99,7 @@ final class ModStateTransitionHelper {
results[i] = raw.whenComplete((result, exception) -> list.set(i, new FutureResult<>(result, exception))); results[i] = raw.whenComplete((result, exception) -> list.set(i, new FutureResult<>(result, exception)));
} }
return CompletableFuture.allOf(results).handle((r, th)->null).thenApply(res -> list); return CompletableFuture.allOf(results).handle((_, _)->null).thenApply(_ -> list);
} }
private static <T extends IModBusEvent> CompletableFuture<Void> addCompletableFutureTaskForModDispatch( private static <T extends IModBusEvent> CompletableFuture<Void> addCompletableFutureTaskForModDispatch(
@@ -135,7 +135,7 @@ final class ModStateTransitionHelper {
handler.run(); handler.run();
mod.acceptEvent(eventGenerator.apply(mod)); mod.acceptEvent(eventGenerator.apply(mod));
}, executor) }, executor)
.whenComplete((mc, exception) -> { .whenComplete((_, exception) -> {
mod.modLoadingStage = nextState.apply(mod.modLoadingStage, exception); mod.modLoadingStage = nextState.apply(mod.modLoadingStage, exception);
progressBar.increment(); progressBar.increment();
ModLoadingContext.get().setActiveContainer(null); ModLoadingContext.get().setActiveContainer(null);
@@ -9,8 +9,8 @@ import java.util.concurrent.Executor;
import java.util.function.BinaryOperator; import java.util.function.BinaryOperator;
public enum ThreadSelector implements BinaryOperator<Executor> { public enum ThreadSelector implements BinaryOperator<Executor> {
SYNC((sync, parallel) -> sync), SYNC((sync, _) -> sync),
PARALLEL((sync, parallel) -> parallel); PARALLEL((_, parallel) -> parallel);
private final BinaryOperator<Executor> selector; private final BinaryOperator<Executor> selector;
@@ -13,8 +13,6 @@ import net.minecraftforge.fml.loading.StringUtils;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.Locale;
import java.util.concurrent.Callable;
public class ModConfig public class ModConfig
{ {
@@ -116,7 +116,7 @@ public class RenderElement {
} }
public static RenderElement forgeVersionOverlay(SimpleFont font, String version) { public static RenderElement forgeVersionOverlay(SimpleFont font, String version) {
return new RenderElement(RenderElement.initializeText(font, (bb, fnt, ctx)-> return new RenderElement(RenderElement.initializeText(font, (bb, _, ctx)->
font.generateVerticesForTexts(ctx.scaledWidth() - font.stringWidth(version) - 10, font.generateVerticesForTexts(ctx.scaledWidth() - font.stringWidth(version) - 10,
ctx.scaledHeight() - font.lineSpacing() + font.descent() - 10, bb, ctx.scaledHeight() - font.lineSpacing() + font.descent() - 10, bb,
new SimpleFont.DisplayText(version, ctx.colourScheme.foreground().packedint(RenderElement.globalAlpha))))); new SimpleFont.DisplayText(version, ctx.colourScheme.foreground().packedint(RenderElement.globalAlpha)))));
@@ -178,11 +178,11 @@ public class RenderElement {
var colour = (alpha << 24) | 0xFFFFFF; var colour = (alpha << 24) | 0xFFFFFF;
Renderer bar; Renderer bar;
if (pm.steps() == 0) { if (pm.steps() == 0) {
bar = progressBar(ctx->new int[] {(ctx.scaledWidth() - BAR_WIDTH * ctx.scale()) / 2, y + font.lineSpacing() - font.descent(), BAR_WIDTH * ctx.scale()}, f->colour, frame -> indeterminateBar(frame, cnt == 0)); bar = progressBar(ctx->new int[] {(ctx.scaledWidth() - BAR_WIDTH * ctx.scale()) / 2, y + font.lineSpacing() - font.descent(), BAR_WIDTH * ctx.scale()}, _->colour, frame -> indeterminateBar(frame, cnt == 0));
} else { } else {
bar = progressBar(ctx -> new int[]{(ctx.scaledWidth() - BAR_WIDTH * ctx.scale()) / 2, y + font.lineSpacing() - font.descent(), BAR_WIDTH * ctx.scale()}, f -> colour, f -> new float[]{0f, pm.progress()}); bar = progressBar(ctx -> new int[]{(ctx.scaledWidth() - BAR_WIDTH * ctx.scale()) / 2, y + font.lineSpacing() - font.descent(), BAR_WIDTH * ctx.scale()}, _ -> colour, _ -> new float[]{0f, pm.progress()});
} }
Renderer label = (bb, ctx, frame) -> renderText(font, text((ctx.scaledWidth() - BAR_WIDTH * ctx.scale()) / 2, y, pm.label().getText(), colour), bb, ctx); Renderer label = (bb, ctx, _) -> renderText(font, text((ctx.scaledWidth() - BAR_WIDTH * ctx.scale()) / 2, y, pm.label().getText(), colour), bb, ctx);
return bar.then(label); return bar.then(label);
} }
private static float[] indeterminateBar(int frame, boolean isActive) { private static float[] indeterminateBar(int frame, boolean isActive) {
@@ -198,9 +198,9 @@ public class RenderElement {
var y = 10 * context.scale(); var y = 10 * context.scale();
PerformanceInfo pi = context.performance(); PerformanceInfo pi = context.performance();
final int colour = hsvToRGB((1.0f - (float)Math.pow(pi.memory(), 1.5f)) / 3f, 1.0f, 0.5f); final int colour = hsvToRGB((1.0f - (float)Math.pow(pi.memory(), 1.5f)) / 3f, 1.0f, 0.5f);
var bar = progressBar(ctx -> new int[]{(ctx.scaledWidth() - BAR_WIDTH * ctx.scale()) / 2, y, BAR_WIDTH * ctx.scale()}, f -> colour, f -> new float[]{0f, pi.memory()}); var bar = progressBar(ctx -> new int[]{(ctx.scaledWidth() - BAR_WIDTH * ctx.scale()) / 2, y, BAR_WIDTH * ctx.scale()}, _ -> colour, _ -> new float[]{0f, pi.memory()});
var width = font.stringWidth(pi.text()); var width = font.stringWidth(pi.text());
Renderer label = (bb, ctx, frame) -> renderText(font, text(ctx.scaledWidth() / 2 - width / 2, y + 18, pi.text(), context.colourScheme.foreground().packedint(globalAlpha)), bb, ctx); Renderer label = (bb, ctx, _) -> renderText(font, text(ctx.scaledWidth() / 2 - width / 2, y + 18, pi.text(), context.colourScheme.foreground().packedint(globalAlpha)), bb, ctx);
bar.then(label).accept(buffer, context, frameNumber); bar.then(label).accept(buffer, context, frameNumber);
} }
@@ -250,7 +250,7 @@ public class RenderElement {
} }
private static Renderer initializeText(SimpleFont font, TextGenerator textGenerator) { private static Renderer initializeText(SimpleFont font, TextGenerator textGenerator) {
return (bb, context, frame) -> renderText(font, textGenerator, bb, context); return (bb, context, _) -> renderText(font, textGenerator, bb, context);
} }
private static void renderText(final SimpleFont font, final TextGenerator textGenerator, final SimpleBufferBuilder bb, final DisplayContext context) { private static void renderText(final SimpleFont font, final TextGenerator textGenerator, final SimpleBufferBuilder bb, final DisplayContext context) {
@@ -262,7 +262,7 @@ public class RenderElement {
} }
private static TextGenerator text(int x, int y, String text, int colour) { private static TextGenerator text(int x, int y, String text, int colour) {
return (bb, font, context) -> font.generateVerticesForTexts(x, y, bb, new SimpleFont.DisplayText(text, colour)); return (bb, font, _) -> font.generateVerticesForTexts(x, y, bb, new SimpleFont.DisplayText(text, colour));
} }
private static Renderer initializeTexture(final String textureFileName, int size, int textureNumber, TextureRenderer positionAndColour) { private static Renderer initializeTexture(final String textureFileName, int size, int textureNumber, TextureRenderer positionAndColour) {
@@ -109,7 +109,7 @@ public class FMLConfig
} }
if (!configSpec.isCorrect(configData)) { if (!configSpec.isCorrect(configData)) {
LOGGER.warn(CORE, "Configuration file {} is not correct. Correcting", configFile); LOGGER.warn(CORE, "Configuration file {} is not correct. Correcting", configFile);
configSpec.correct(configData, (action, path, incorrectValue, correctedValue) -> configSpec.correct(configData, (_, path, incorrectValue, correctedValue) ->
LOGGER.info(CORE, "Incorrect key {} was corrected from {} to {}", path, incorrectValue, correctedValue)); LOGGER.info(CORE, "Incorrect key {} was corrected from {} to {}", path, incorrectValue, correctedValue));
} }
configData.putAllComments(configComments); configData.putAllComments(configComments);
@@ -20,8 +20,8 @@ public class FMLEnvironment
public static final boolean secureJarsEnabled = FMLLoader.isSecureJarEnabled(); public static final boolean secureJarsEnabled = FMLLoader.isSecureJarEnabled();
static void setupInteropEnvironment(IEnvironment environment) { static void setupInteropEnvironment(IEnvironment environment) {
environment.computePropertyIfAbsent(IEnvironment.Keys.NAMING.get(), v->naming); environment.computePropertyIfAbsent(IEnvironment.Keys.NAMING.get(), _->naming);
environment.computePropertyIfAbsent(Environment.Keys.DIST.get(), v->dist); environment.computePropertyIfAbsent(Environment.Keys.DIST.get(), _->dist);
} }
public static class Keys { public static class Keys {
@@ -12,7 +12,6 @@ import net.minecraftforge.forgespi.Environment;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
@@ -42,7 +41,7 @@ public class FMLServiceProvider implements ITransformationService {
LOGGER.debug(CORE, "Loading configuration"); LOGGER.debug(CORE, "Loading configuration");
FMLConfig.load(); FMLConfig.load();
LOGGER.debug(CORE, "Preparing ModFile"); LOGGER.debug(CORE, "Preparing ModFile");
environment.computePropertyIfAbsent(Environment.Keys.MODFILEFACTORY.get(), k->ModFile::new); environment.computePropertyIfAbsent(Environment.Keys.MODFILEFACTORY.get(), _->ModFile::new);
LOGGER.debug(CORE, "Preparing launch handler"); LOGGER.debug(CORE, "Preparing launch handler");
FMLLoader.setupLaunchHandler(environment, arguments); FMLLoader.setupLaunchHandler(environment, arguments);
FMLEnvironment.setupInteropEnvironment(environment); FMLEnvironment.setupInteropEnvironment(environment);
@@ -7,7 +7,6 @@ package net.minecraftforge.fml.loading;
import com.mojang.logging.LogUtils; import com.mojang.logging.LogUtils;
import cpw.mods.modlauncher.api.INameMappingService; import cpw.mods.modlauncher.api.INameMappingService;
import org.apache.commons.lang3.tuple.Pair;
import org.slf4j.Logger; import org.slf4j.Logger;
import java.io.BufferedReader; import java.io.BufferedReader;
@@ -6,7 +6,6 @@
package net.minecraftforge.fml.loading; package net.minecraftforge.fml.loading;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths;
/** /**
* Convert a maven coordinate into a Path. * Convert a maven coordinate into a Path.
@@ -26,6 +26,7 @@ public class StringUtils {
return java.util.stream.Stream.of(endings).anyMatch(lowerSearch::endsWith); return java.util.stream.Stream.of(endings).anyMatch(lowerSearch::endsWith);
} }
@SuppressWarnings("deprecation")
public static URL toURL(final String string) { public static URL toURL(final String string) {
if (string == null || string.trim().isEmpty() || string.contains("myurl.me") || string.contains("example.invalid")) if (string == null || string.trim().isEmpty() || string.contains("myurl.me") || string.contains("example.invalid"))
return null; return null;
@@ -13,7 +13,6 @@ import org.jetbrains.annotations.ApiStatus;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.function.BiPredicate;
@ApiStatus.Internal // since 1.21.1, will be made non-public in a later MC version @ApiStatus.Internal // since 1.21.1, will be made non-public in a later MC version
public class VersionSupportMatrix { public class VersionSupportMatrix {
@@ -7,7 +7,6 @@ package net.minecraftforge.fml.loading.moddiscovery;
import com.mojang.logging.LogUtils; import com.mojang.logging.LogUtils;
import net.minecraftforge.fml.loading.ImmediateWindowHandler; import net.minecraftforge.fml.loading.ImmediateWindowHandler;
import net.minecraftforge.fml.loading.LoadingModList;
import net.minecraftforge.fml.loading.LogMarkers; import net.minecraftforge.fml.loading.LogMarkers;
import net.minecraftforge.forgespi.language.ModFileScanData; import net.minecraftforge.forgespi.language.ModFileScanData;
import org.slf4j.Logger; import org.slf4j.Logger;
@@ -56,7 +55,7 @@ public final class BackgroundScanHandler {
ImmediateWindowHandler.updateProgress("Scanning mod candidates"); ImmediateWindowHandler.updateProgress("Scanning mod candidates");
CompletableFuture<ModFileScanData> future = CompletableFuture.supplyAsync(file::compileContent, modContentScanner) CompletableFuture<ModFileScanData> future = CompletableFuture.supplyAsync(file::compileContent, modContentScanner)
.whenComplete(file::setScanResult); .whenComplete(file::setScanResult);
if (DEBUG) future = future.whenComplete((r, t) -> addCompletedFile(file, t)); if (DEBUG) future = future.whenComplete((_, t) -> addCompletedFile(file, t));
file.setFutureScanResult(future); file.setFutureScanResult(future);
} }
@@ -24,7 +24,7 @@ public enum InvalidModIdentifier {
LITELOADER(filePresent("litemod.json")), LITELOADER(filePresent("litemod.json")),
OPTIFINE(filePresent("optifine/Installer.class")), OPTIFINE(filePresent("optifine/Installer.class")),
BUKKIT(filePresent("plugin.yml")), BUKKIT(filePresent("plugin.yml")),
INVALIDZIP((f,zf) -> zf.isEmpty()); // note: only this one INVALIDZIP check is ran until the todo on this class is fixed INVALIDZIP((_,zf) -> zf.isEmpty()); // note: only this one INVALIDZIP check is ran until the todo on this class is fixed
private final BiPredicate<Path, Optional<ZipFile>> ident; private final BiPredicate<Path, Optional<ZipFile>> ident;
@@ -51,7 +51,7 @@ public enum InvalidModIdentifier {
private static BiPredicate<Path, Optional<ZipFile>> filePresent(String filename) private static BiPredicate<Path, Optional<ZipFile>> filePresent(String filename)
{ {
return (f, zfo) -> zfo.map(zf -> zf.getEntry(filename) != null).orElse(false); return (_, zfo) -> zfo.map(zf -> zf.getEntry(filename) != null).orElse(false);
} }
private static <T> Optional<T> optionalFromException(Supplier_WithExceptions<T, ? extends Exception> supp) private static <T> Optional<T> optionalFromException(Supplier_WithExceptions<T, ? extends Exception> supp)
@@ -145,7 +145,7 @@ public class JarInJarDependencyLocator extends AbstractModProvider implements ID
var ids = new TreeMap<String, List<Entry>>(); var ids = new TreeMap<String, List<Entry>>();
for (var entry : selector.entries.values()) { for (var entry : selector.entries.values()) {
if (entry != FAILED && entry.coord != null) if (entry != FAILED && entry.coord != null)
ids.computeIfAbsent(entry.coord, id -> new ArrayList<>()).add(entry); ids.computeIfAbsent(entry.coord, _ -> new ArrayList<>()).add(entry);
} }
for (var entry : ids.entrySet()) { for (var entry : ids.entrySet()) {
@@ -27,7 +27,7 @@ public final class MinecraftLocator extends AbstractModProvider implements IModL
// Minecraft itself. // Minecraft itself.
var meta = new ModJarMetadata(); var meta = new ModJarMetadata();
var mcjar = SecureJar.from(jar -> meta, paths); var mcjar = SecureJar.from(_ -> meta, paths);
var mc = ModFileFactory.FACTORY.build(mcjar, this, MinecraftLocator::buildMinecraftTOML); var mc = ModFileFactory.FACTORY.build(mcjar, this, MinecraftLocator::buildMinecraftTOML);
meta.setModFile(mc); meta.setModFile(mc);
@@ -8,7 +8,6 @@ package net.minecraftforge.fml.loading.moddiscovery;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.mojang.logging.LogUtils; import com.mojang.logging.LogUtils;
import cpw.mods.jarhandling.SecureJar; import cpw.mods.jarhandling.SecureJar;
import net.minecraftforge.fml.loading.FMLLoader;
import net.minecraftforge.fml.loading.LanguageLoadingProvider; import net.minecraftforge.fml.loading.LanguageLoadingProvider;
import net.minecraftforge.fml.loading.LogMarkers; import net.minecraftforge.fml.loading.LogMarkers;
import net.minecraftforge.forgespi.language.IModFileInfo; import net.minecraftforge.forgespi.language.IModFileInfo;
@@ -26,7 +25,6 @@ import java.nio.file.FileSystems;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
@@ -56,7 +56,7 @@ public class StartupNotificationManager {
private synchronized static void addMessage(Message.MessageType type, String message, int maxSize) private synchronized static void addMessage(Message.MessageType type, String message, int maxSize)
{ {
EnumMap<Message.MessageType, List<Message>> newMessages = new EnumMap<>(messages); EnumMap<Message.MessageType, List<Message>> newMessages = new EnumMap<>(messages);
newMessages.compute(type, (key, existingList) -> { newMessages.compute(type, (_, existingList) -> {
List<Message> newList = new ArrayList<>(); List<Message> newList = new ArrayList<>();
if (existingList != null) if (existingList != null)
{ {
@@ -141,7 +141,7 @@ abstract class CommonDevLaunchHandler extends CommonLaunchHandler {
protected static Path getForgeOnly(Path forge) { protected static Path getForgeOnly(Path forge) {
var packages = getPackages(); // Pulled out so it is passed to the lambda as value var packages = getPackages(); // Pulled out so it is passed to the lambda as value
// We need to separate out our resources/code so that we can show up as a different data pack. // We need to separate out our resources/code so that we can show up as a different data pack.
var modJar = SecureJar.from((path, base) -> { var modJar = SecureJar.from((path, _) -> {
if (!path.endsWith(".class")) return true; if (!path.endsWith(".class")) return true;
for (var pkg : packages) for (var pkg : packages)
if (path.startsWith(pkg)) return true; if (path.startsWith(pkg)) return true;
@@ -112,7 +112,7 @@ public final class ForgeDevLocator extends AbstractModProvider implements IModLo
// We want just the class files from the root of the input paths. So make a new union with a filter. // We want just the class files from the root of the input paths. So make a new union with a filter.
var classes = UnionHelper.newFileSystem( var classes = UnionHelper.newFileSystem(
(name, base) -> { (name, _) -> {
if (name.endsWith("/")) { if (name.endsWith("/")) {
if (name.startsWith("/")) if (name.startsWith("/"))
name = name.substring(1); name = name.substring(1);
@@ -164,7 +164,7 @@ public final class ForgeDevLocator extends AbstractModProvider implements IModLo
if ("value".equals(key)) { if ("value".equals(key)) {
int idx = clsName.lastIndexOf('/'); int idx = clsName.lastIndexOf('/');
var pkg = clsName.substring(0, idx); var pkg = clsName.substring(0, idx);
mods.computeIfAbsent(pkg, k -> new HashSet<>()).add((String)value); mods.computeIfAbsent(pkg, _ -> new HashSet<>()).add((String)value);
idx = pkg.lastIndexOf('/'); idx = pkg.lastIndexOf('/');
while (idx != -1) { while (idx != -1) {
@@ -126,7 +126,7 @@ record FieldToMethodTransformer(String className, Map<String, String> fields) im
throw new IllegalStateException("No field with name " + fieldName + " found"); throw new IllegalStateException("No field with name " + fieldName + " found");
if (!Modifier.isPrivate(foundField.access) || Modifier.isStatic(foundField.access)) if (!Modifier.isPrivate(foundField.access) || Modifier.isStatic(foundField.access))
throw new IllegalStateException("Field " + fieldName + " is not private and an instance field"); throw new IllegalStateException("Field " + classNode.name + '.' + fieldName + " is not private and an instance field");
var methodSignature = "()" + foundField.desc; var methodSignature = "()" + foundField.desc;
var foundMethod = findMethod(classNode, methodName, methodSignature); var foundMethod = findMethod(classNode, methodName, methodSignature);
@@ -41,7 +41,7 @@ record MethodRedirector() implements ITransformer<ClassNode> {
"finalizeSpawn", "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;", "(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), GSON.fromJson(new InputStreamReader(sneak(() -> MethodRedirector.class.getModule().getResourceAsStream("coremods/finalize_spawn_targets.json"))), Target[].class),
insn -> new MethodInsnNode( _ -> new MethodInsnNode(
Opcodes.INVOKESTATIC, Opcodes.INVOKESTATIC,
"net/minecraftforge/event/ForgeEventFactory", "net/minecraftforge/event/ForgeEventFactory",
"onFinalizeSpawn", "onFinalizeSpawn",
@@ -1,8 +1,8 @@
[ [
{ {
"class": "net/minecraft/gametest/framework/GameTestHelper", "class": "net/minecraft/gametest/framework/GameTestEntityBuilder",
"methods": [ "methods": [
"spawn(Lnet/minecraft/world/entity/EntityType;Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/entity/EntitySpawnReason;)Lnet/minecraft/world/entity/Entity;" "spawn()Lnet/minecraft/world/entity/Entity;"
] ]
}, },
{ {
@@ -20,7 +20,7 @@
{ {
"class": "net/minecraft/world/entity/EntityType", "class": "net/minecraft/world/entity/EntityType",
"methods": [ "methods": [
"create(Lnet/minecraft/server/level/ServerLevel;Ljava/util/function/Consumer;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/entity/EntitySpawnReason;ZZ)Lnet/minecraft/world/entity/Entity;" "create(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/entity/PostSpawnProcessor;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/entity/EntitySpawnReason;ZZ)Lnet/minecraft/world/entity/Entity;"
] ]
}, },
{ {
+4 -4
View File
@@ -5,11 +5,11 @@ org.gradle.daemon=false
org.gradle.parallel=true org.gradle.parallel=true
JAVA_VERSION=25 JAVA_VERSION=25
MC_VERSION=26.1.2 MC_VERSION=26.2
MC_NEXT_VERSION=26.2 MC_NEXT_VERSION=26.3
MCP_VERSION=20260409.101008 MCP_VERSION=20260616.103818
MAPPING_CHANNEL=official MAPPING_CHANNEL=official
MAPPING_VERSION=26.1.2 MAPPING_VERSION=26.2
# Set to true before the first build of a new MC version, so we don't do compatibility checks # Set to true before the first build of a new MC version, so we don't do compatibility checks
CHECK_COMPATIBILITY=false CHECK_COMPATIBILITY=false
@@ -81,7 +81,7 @@ public class FMLJavaModLanguageProvider implements IModLanguageProvider
.filter(ad -> ad.annotationType().equals(MODANNOTATION)) .filter(ad -> ad.annotationType().equals(MODANNOTATION))
.peek(ad -> LOGGER.debug(SCAN, "Found @Mod class {} with id {}", ad.clazz().getClassName(), ad.annotationData().get("value"))) .peek(ad -> LOGGER.debug(SCAN, "Found @Mod class {} with id {}", ad.clazz().getClassName(), ad.annotationData().get("value")))
.map(ad -> new FMLModTarget(ad.clazz().getClassName(), (String)ad.annotationData().get("value"))) .map(ad -> new FMLModTarget(ad.clazz().getClassName(), (String)ad.annotationData().get("value")))
.collect(Collectors.toMap(FMLModTarget::modId, Function.identity(), (a,b)->a)); .collect(Collectors.toMap(FMLModTarget::modId, Function.identity(), (a, _) -> a));
scanResult.addLanguageLoader(modTargetMap); scanResult.addLanguageLoader(modTargetMap);
}; };
} }
@@ -74,7 +74,7 @@ public class LowCodeModLanguageProvider implements IModLanguageProvider
.flatMap(fi->fi.getMods().stream()) .flatMap(fi->fi.getMods().stream())
.map(IModInfo::getModId) .map(IModInfo::getModId)
.map(LowCodeModTarget::new) .map(LowCodeModTarget::new)
.collect(Collectors.toMap(LowCodeModTarget::modId, Function.identity(), (a, b)->a)); .collect(Collectors.toMap(LowCodeModTarget::modId, Function.identity(), (a, _)->a));
scanResult.addLanguageLoader(modTargetMap); scanResult.addLanguageLoader(modTargetMap);
}; };
} }
@@ -1,6 +1,6 @@
--- a/com/mojang/blaze3d/opengl/GlCommandEncoder.java --- a/com/mojang/blaze3d/opengl/GlCommandEncoder.java
+++ b/com/mojang/blaze3d/opengl/GlCommandEncoder.java +++ b/com/mojang/blaze3d/opengl/GlCommandEncoder.java
@@ -111,6 +_,9 @@ @@ -201,6 +_,9 @@
GlStateManager._colorMask(15); GlStateManager._colorMask(15);
GlStateManager._clear(16384); GlStateManager._clear(16384);
GlStateManager._glFramebufferTexture2D(36160, 36064, 3553, 0, 0); GlStateManager._glFramebufferTexture2D(36160, 36064, 3553, 0, 0);
@@ -1,35 +1,35 @@
--- a/com/mojang/blaze3d/opengl/GlConst.java --- a/com/mojang/blaze3d/opengl/GlConst.java
+++ b/com/mojang/blaze3d/opengl/GlConst.java +++ b/com/mojang/blaze3d/opengl/GlConst.java
@@ -249,6 +_,10 @@ @@ -239,6 +_,10 @@
} }
public static int toGlInternalId(final TextureFormat textureFormat) { public static int toGlInternalId(final GpuFormat gpuFormat) {
+ return toGlInternalId(textureFormat, false); + return toGlInternalId(gpuFormat, false);
+ } + }
+ public static int toGlInternalId(final TextureFormat textureFormat, final boolean stencil) { + public static int toGlInternalId(final GpuFormat gpuFormat, final boolean stencil) {
+ if (stencil && textureFormat.hasDepthAspect()) return org.lwjgl.opengl.GL30.GL_DEPTH32F_STENCIL8; + if (stencil && gpuFormat.hasDepthAspect()) return org.lwjgl.opengl.GL30.GL_DEPTH32F_STENCIL8;
return switch (textureFormat) { return switch (gpuFormat) {
case RGBA8 -> 32856; case R8_UNORM -> 33321;
case RED8 -> 33321; case R8_SNORM -> 36756;
@@ -258,6 +_,10 @@ @@ -291,6 +_,10 @@
} }
public static int toGlExternalId(final TextureFormat textureFormat) { public static int toGlExternalId(final GpuFormat gpuFormat) {
+ return toGlExternalId(textureFormat, false); + return toGlExternalId(gpuFormat, false);
+ } + }
+ public static int toGlExternalId(final TextureFormat textureFormat, final boolean stencil) { + public static int toGlExternalId(final GpuFormat gpuFormat, final boolean stencil) {
+ if (stencil && textureFormat.hasDepthAspect()) return org.lwjgl.opengl.GL30.GL_DEPTH_STENCIL; + if (stencil && gpuFormat.hasDepthAspect()) return org.lwjgl.opengl.GL30.GL_DEPTH_STENCIL;
return switch (textureFormat) { return switch (gpuFormat) {
case RGBA8 -> 6408; case R8_UNORM, R8_SNORM, R16_UNORM, R16_SNORM, R16_FLOAT, R32_FLOAT -> 6403;
case RED8 -> 6403; case RG8_UNORM, RG8_SNORM, RG16_UNORM, RG16_SNORM, RG16_FLOAT, RG32_FLOAT -> 33319;
@@ -267,6 +_,10 @@ @@ -308,6 +_,10 @@
} }
public static int toGlType(final TextureFormat textureFormat) { public static int toGlType(final GpuFormat gpuFormat) {
+ return toGlType(textureFormat, false); + return toGlType(gpuFormat, false);
+ } + }
+ public static int toGlType(final TextureFormat textureFormat, boolean stencil) { + public static int toGlType(final GpuFormat gpuFormat, boolean stencil) {
+ if (stencil && textureFormat.hasDepthAspect()) return org.lwjgl.opengl.GL30.GL_FLOAT_32_UNSIGNED_INT_24_8_REV; + if (stencil && gpuFormat.hasDepthAspect()) return org.lwjgl.opengl.GL30.GL_FLOAT_32_UNSIGNED_INT_24_8_REV;
return switch (textureFormat) { return switch (gpuFormat) {
case RGBA8 -> 5121; case R8_UNORM, RG8_UNORM, RGB8_UNORM, RGBA8_UNORM, R8_UINT, RG8_UINT, RGBA8_UINT, S8_UINT, RGB8_UINT -> 5121;
case RED8 -> 5121; case R8_SNORM, RG8_SNORM, RGB8_SNORM, RGBA8_SNORM, R8_SINT, RG8_SINT, RGBA8_SINT, RGB8_SINT -> 5120;
@@ -15,7 +15,7 @@
private static final Logger LOGGER = LogUtils.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
private static final int CIRCULAR_LOG_SIZE = 10; private static final int CIRCULAR_LOG_SIZE = 10;
private final Queue<GlDebug.LogEntry> MESSAGE_BUFFER = EvictingQueue.create(10); private final Queue<GlDebug.LogEntry> MESSAGE_BUFFER = EvictingQueue.create(10);
@@ -103,6 +_,8 @@ @@ -83,6 +_,8 @@
} }
LOGGER.info("OpenGL debug message: {}", entry); LOGGER.info("OpenGL debug message: {}", entry);
@@ -24,21 +24,21 @@
} }
public List<String> getLastOpenGlDebugMessages() { public List<String> getLastOpenGlDebugMessages() {
@@ -126,7 +_,7 @@ @@ -107,7 +_,7 @@
GlDebug debug = new GlDebug(); GlDebug debug = new GlDebug();
enabledExtensions.add("GL_KHR_debug"); enabledExtensions.add("GL_KHR_debug");
GL11.glEnable(37600); GL33C.glEnable(37600);
- if (debugSynchronousGlLogs) { - if (debugSynchronousGlLogs) {
+ if (debugSynchronousGlLogs | PRINT_STACKTRACE_ON_ERROR) { + if (debugSynchronousGlLogs | PRINT_STACKTRACE_ON_ERROR) {
GL11.glEnable(33346); GL33C.glEnable(33346);
} }
@@ -140,7 +_,7 @@ @@ -121,7 +_,7 @@
} else if (caps.GL_ARB_debug_output && GlDevice.USE_GL_ARB_debug_output) { } else if (caps.GL_ARB_debug_output && GlDevice.USE_GL_ARB_debug_output) {
GlDebug debug = new GlDebug(); GlDebug debug = new GlDebug();
enabledExtensions.add("GL_ARB_debug_output"); enabledExtensions.add("GL_ARB_debug_output");
- if (debugSynchronousGlLogs) { - if (debugSynchronousGlLogs) {
+ if (debugSynchronousGlLogs | PRINT_STACKTRACE_ON_ERROR) { + if (debugSynchronousGlLogs | PRINT_STACKTRACE_ON_ERROR) {
GL11.glEnable(33346); GL33C.glEnable(33346);
} }
@@ -1,6 +1,6 @@
--- a/com/mojang/blaze3d/opengl/GlDevice.java --- a/com/mojang/blaze3d/opengl/GlDevice.java
+++ b/com/mojang/blaze3d/opengl/GlDevice.java +++ b/com/mojang/blaze3d/opengl/GlDevice.java
@@ -129,7 +_,12 @@ @@ -150,7 +_,12 @@
final int depthOrLayers, final int depthOrLayers,
final int mipLevels final int mipLevels
) { ) {
@@ -9,12 +9,12 @@
+ } + }
+ +
+ @Override + @Override
+ public GpuTexture createTexture(final @Nullable Supplier<String> label, @GpuTexture.Usage final int usage, final TextureFormat format, final int width, final int height, final int depthOrLayers, final int mipLevels, final boolean stencil ) { + public GpuTexture createTexture(final @Nullable Supplier<String> label, @GpuTexture.Usage final int usage, final GpuFormat format, final int width, final int height, final int depthOrLayers, final int mipLevels, final boolean stencil) {
+ return this.createTexture(this.debugLabels.exists() && label != null ? label.get() : null, usage, format, width, height, depthOrLayers, mipLevels, stencil); + return this.createTexture(this.debugLabels.exists() && label != null ? label.get() : null, usage, format, width, height, depthOrLayers, mipLevels, stencil);
} }
@Override @Override
@@ -142,6 +_,11 @@ @@ -163,6 +_,11 @@
final int depthOrLayers, final int depthOrLayers,
final int mipLevels final int mipLevels
) { ) {
@@ -22,41 +22,29 @@
+ } + }
+ +
+ @Override + @Override
+ public GpuTexture createTexture(@Nullable String label, @GpuTexture.Usage final int usage, final TextureFormat format, final int width, final int height, final int depthOrLayers, final int mipLevels, boolean stencil) { + public GpuTexture createTexture(@Nullable String label, @GpuTexture.Usage final int usage, final GpuFormat format, final int width, final int height, final int depthOrLayers, final int mipLevels, boolean stencil) {
GlStateManager.clearGlErrors(); GlStateManager.clearGlErrors();
int id = GlStateManager._genTexture(); int id = GlStateManager._genTexture();
if (label == null) { if (label == null) {
@@ -171,12 +_,12 @@ @@ -186,9 +_,9 @@
GlStateManager._texImage2D( GlStateManager._texParameter(target, 34892, 0);
cubeTarget,
i,
- GlConst.toGlInternalId(format),
+ GlConst.toGlInternalId(format, stencil),
width >> i,
height >> i,
0,
- GlConst.toGlExternalId(format),
- GlConst.toGlType(format),
+ GlConst.toGlExternalId(format, stencil),
+ GlConst.toGlType(format, stencil),
null
);
}
@@ -184,7 +_,7 @@
} else {
for (int i = 0; i < mipLevels; i++) {
GlStateManager._texImage2D(
- target, i, GlConst.toGlInternalId(format), width >> i, height >> i, 0, GlConst.toGlExternalId(format), GlConst.toGlType(format), null
+ target, i, GlConst.toGlInternalId(format, stencil), width >> i, height >> i, 0, GlConst.toGlExternalId(format, stencil), GlConst.toGlType(format, stencil), null
);
}
} }
@@ -195,7 +_,7 @@
} else if (error != 0) { - int glInternalID = GlConst.toGlInternalId(format);
throw new IllegalStateException("OpenGL error " + error); - int glExternalID = GlConst.toGlExternalId(format);
} else { - int glType = GlConst.toGlType(format);
- GlTexture texture = new GlTexture(usage, label, format, width, height, depthOrLayers, mipLevels, id); + int glInternalID = GlConst.toGlInternalId(format, stencil);
+ GlTexture texture = new GlTexture(usage, label, format, width, height, depthOrLayers, mipLevels, id, stencil); + int glExternalID = GlConst.toGlExternalId(format, stencil);
+ int glType = GlConst.toGlType(format, stencil);
if (glInternalID != 0 && glExternalID != 0 && glType != 0) {
if (isCubemap) {
for (int cubeTarget : GlConst.CUBEMAP_TARGETS) {
@@ -211,7 +_,7 @@
throw new IllegalStateException("OpenGL error " + error);
}
- GlTexture texture = new GlTexture(usage, label, format, width, height, depthOrLayers, mipLevels, id, this.frameBufferCache);
+ GlTexture texture = new GlTexture(usage, label, format, width, height, depthOrLayers, mipLevels, id, this.frameBufferCache, stencil);
this.debugLabels.applyLabel(texture); this.debugLabels.applyLabel(texture);
return texture; return texture;
} } else {
@@ -1,18 +1,18 @@
--- a/com/mojang/blaze3d/opengl/GlStateManager.java --- a/com/mojang/blaze3d/opengl/GlStateManager.java
+++ b/com/mojang/blaze3d/opengl/GlStateManager.java +++ b/com/mojang/blaze3d/opengl/GlStateManager.java
@@ -86,6 +_,11 @@ @@ -80,6 +_,11 @@
} }
} }
+ public static boolean _isBlendEnabled() { + public static boolean _isBlendEnabled(int index) {
+ RenderSystem.assertOnRenderThread(); + RenderSystem.assertOnRenderThread();
+ return BLEND.mode.enabled; + return BLEND[index].mode.enabled;
+ } + }
+ +
public static void _disableBlend() { public static void _disableBlend(int index) {
RenderSystem.assertOnRenderThread(); RenderSystem.assertOnRenderThread();
BLEND.mode.disable(); BLEND[index].mode.disable();
@@ -380,9 +_,17 @@ @@ -390,9 +_,17 @@
} }
} }
@@ -22,8 +22,8 @@
+ +
public static void _texParameter(final int target, final int name, final int value) { public static void _texParameter(final int target, final int name, final int value) {
RenderSystem.assertOnRenderThread(); RenderSystem.assertOnRenderThread();
GL11.glTexParameteri(target, name, value); GL33C.glTexParameteri(target, name, value);
+ if (target == GL13.GL_TEXTURE1) { + if (target == GL33C.GL_TEXTURE1) {
+ lastBrightnessX = name; + lastBrightnessX = name;
+ lastBrightnessY = value; + lastBrightnessY = value;
+ } + }
@@ -1,20 +1,21 @@
--- a/com/mojang/blaze3d/opengl/GlTexture.java --- a/com/mojang/blaze3d/opengl/GlTexture.java
+++ b/com/mojang/blaze3d/opengl/GlTexture.java +++ b/com/mojang/blaze3d/opengl/GlTexture.java
@@ -28,8 +_,13 @@ @@ -27,9 +_,14 @@
final int mipLevels, final int id,
final int id final FrameBufferCache frameBufferCache
) { ) {
+ this(usage, label, format, width, height, depthOrLayers, mipLevels, id, false); + this(usage, label, format, width, height, depthOrLayers, mipLevels, id, frameBufferCache, false);
+ } + }
+ +
+ protected GlTexture(int usage, String label, TextureFormat format, int width, int height, int depthOrLayers, int mipLevels, int id, boolean stencil) { + protected GlTexture(@GpuTexture.Usage int usage, String label, GpuFormat format, int width, int height, int depthOrLayers, int mipLevels, int id, FrameBufferCache frameBufferCache, boolean stencil) {
super(usage, label, format, width, height, depthOrLayers, mipLevels); super(usage, label, format, width, height, depthOrLayers, mipLevels);
this.id = id; this.id = id;
this.frameBufferCache = frameBufferCache;
+ this.stencilEnabled = stencil; + this.stencilEnabled = stencil;
} }
@Override @Override
@@ -96,5 +_,12 @@ @@ -84,5 +_,12 @@
if (this.closed && this.views == 0) { if (this.closed && this.views == 0) {
this.destroyImmediately(); this.destroyImmediately();
} }
@@ -1,15 +1,15 @@
--- a/com/mojang/blaze3d/pipeline/RenderTarget.java --- a/com/mojang/blaze3d/pipeline/RenderTarget.java
+++ b/com/mojang/blaze3d/pipeline/RenderTarget.java +++ b/com/mojang/blaze3d/pipeline/RenderTarget.java
@@ -80,7 +_,7 @@ @@ -83,7 +_,7 @@
this.width = width; this.width = width;
this.height = height; this.height = height;
if (this.useDepth) { if (this.useDepth) {
- this.depthTexture = device.createTexture(() -> this.label + " / Depth", 15, TextureFormat.DEPTH32, width, height, 1, 1); - this.depthTexture = device.createTexture(() -> this.label + " / Depth", 15, GpuFormat.D32_FLOAT, width, height, 1, 1);
+ this.depthTexture = device.createTexture(() -> this.label + " / Depth", 15, TextureFormat.DEPTH32, width, height, 1, 1, this.stencilEnabled); + this.depthTexture = device.createTexture(() -> this.label + " / Depth", 15, GpuFormat.D32_FLOAT, width, height, 1, 1, this.stencilEnabled);
this.depthTextureView = device.createTextureView(this.depthTexture); this.depthTextureView = device.createTextureView(this.depthTexture);
} }
@@ -124,5 +_,26 @@ @@ -121,5 +_,26 @@
public @Nullable GpuTextureView getDepthTextureView() { public @Nullable GpuTextureView getDepthTextureView() {
return this.depthTextureView; return this.depthTextureView;
@@ -1,17 +1,17 @@
--- a/com/mojang/blaze3d/platform/Window.java --- a/com/mojang/blaze3d/platform/Window.java
+++ b/com/mojang/blaze3d/platform/Window.java +++ b/com/mojang/blaze3d/platform/Window.java
@@ -97,8 +_,9 @@ @@ -101,8 +_,9 @@
Monitor initialMonitor = this.screenManager.getMonitor(GLFW.glfwGetPrimaryMonitor()); Monitor initialMonitor = monitorManager.getMonitor(GLFW.glfwGetPrimaryMonitor());
this.windowedWidth = this.width = allowedWindowMinSize(displayData.width()); this.windowedWidth = this.width = allowedWindowMinSize(displayData.width());
this.windowedHeight = this.height = allowedWindowMinSize(displayData.height()); this.windowedHeight = this.height = allowedWindowMinSize(displayData.height());
- this.handle = this.createWindow(backend, this.width, this.height, title, this.fullscreen && initialMonitor != null ? initialMonitor.getMonitor() : 0L); - this.handle = this.createWindow(backend, this.width, this.height, title, this.fullscreen && initialMonitor != null ? initialMonitor.monitor() : 0L);
+ this.handle = net.minecraftforge.fml.loading.ImmediateWindowHandler.setupMinecraftWindow(this.width, this.height, title, this.fullscreen && initialMonitor != null ? initialMonitor.getMonitor() : 0L, () -> backend); + this.handle = net.minecraftforge.fml.loading.ImmediateWindowHandler.setupMinecraftWindow(this.width, this.height, title, this.fullscreen && initialMonitor != null ? initialMonitor.monitor() : 0L, () -> backend);
this.backend = backend; this.backend = backend;
+ if (!net.minecraftforge.fml.loading.ImmediateWindowHandler.positionWindow(Optional.ofNullable(initialMonitor), w->this.width = this.windowedWidth = w, h->this.height = this.windowedHeight = h, x->this.x = this.windowedX = x, y->this.y = this.windowedY = y)) { + if (!net.minecraftforge.fml.loading.ImmediateWindowHandler.positionWindow(Optional.ofNullable(initialMonitor), w->this.width = this.windowedWidth = w, h->this.height = this.windowedHeight = h, x->this.x = this.windowedX = x, y->this.y = this.windowedY = y)) {
if (initialMonitor != null) { if (initialMonitor != null) {
VideoMode mode = initialMonitor.getPreferredVidMode(this.fullscreen ? this.preferredFullscreenVideoMode : Optional.empty()); VideoMode mode = initialMonitor.getPreferredVidMode(this.fullscreen ? this.preferredFullscreenVideoMode : Optional.empty());
this.windowedX = this.x = initialMonitor.getX() + mode.getWidth() / 2 - this.width / 2; this.windowedX = this.x = initialMonitor.x() + mode.getWidth() / 2 - this.width / 2;
@@ -110,6 +_,7 @@ @@ -114,6 +_,7 @@
this.windowedX = this.x = actualX[0]; this.windowedX = this.x = actualX[0];
this.windowedY = this.y = actualY[0]; this.windowedY = this.y = actualY[0];
} }
@@ -19,8 +19,8 @@
this.setMode(); this.setMode();
this.refreshFramebufferSize(); this.refreshFramebufferSize();
@@ -300,6 +_,9 @@ @@ -306,6 +_,9 @@
GLFW.glfwGetFramebufferSize(this.handle, outWidth, outHeight); outHeight[0] = this.isSoftScreen() ? outHeight[0] - 1 : outHeight[0];
this.framebufferWidth = outWidth[0] > 0 ? outWidth[0] : 1; this.framebufferWidth = outWidth[0] > 0 ? outWidth[0] : 1;
this.framebufferHeight = outHeight[0] > 0 ? outHeight[0] : 1; this.framebufferHeight = outHeight[0] > 0 ? outHeight[0] : 1;
+ if (this.framebufferHeight == 0 || this.framebufferWidth == 0) { + if (this.framebufferHeight == 0 || this.framebufferWidth == 0) {
@@ -1,14 +1,14 @@
--- a/com/mojang/blaze3d/systems/GpuDevice.java --- a/com/mojang/blaze3d/systems/GpuDevice.java
+++ b/com/mojang/blaze3d/systems/GpuDevice.java +++ b/com/mojang/blaze3d/systems/GpuDevice.java
@@ -61,6 +_,21 @@ @@ -73,6 +_,21 @@
return this.backend.createTexture(label, usage, format, width, height, depthOrLayers, mipLevels); return this.backend.createTexture(label, usage, format, width, height, depthOrLayers, mipLevels);
} }
+ /** Forge: same as {@link #createTexture(Supplier, int, TextureFormat, int, int, int)} but with stencil support */ + /** Forge: same as {@link #createTexture(Supplier, int, GpuFormat, int, int, int)} but with stencil support */
+ public GpuTexture createTexture( + public GpuTexture createTexture(
+ final @Nullable Supplier<String> label, + final @Nullable Supplier<String> label,
+ @GpuTexture.Usage final int usage, + @GpuTexture.Usage final int usage,
+ final TextureFormat format, + final GpuFormat format,
+ final int width, + final int width,
+ final int height, + final int height,
+ final int depthOrLayers, + final int depthOrLayers,
@@ -21,18 +21,18 @@
+ +
public GpuTexture createTexture( public GpuTexture createTexture(
final @Nullable String label, final @Nullable String label,
@GpuTexture.Usage final int usage, final @GpuTexture.Usage int usage,
@@ -72,6 +_,21 @@ @@ -84,6 +_,21 @@
) { ) {
this.verifyTextureCreationArgs(usage, width, height, depthOrLayers, mipLevels); this.verifyTextureCreationArgs(usage, width, height, depthOrLayers, mipLevels);
return this.backend.createTexture(label, usage, format, width, height, depthOrLayers, mipLevels); return this.backend.createTexture(label, usage, format, width, height, depthOrLayers, mipLevels);
+ } + }
+ +
+ /** Forge: same as {@link #createTexture(Supplier, int, TextureFormat, int, int, int)} but with stencil support */ + /** Forge: same as {@link #createTexture(Supplier, int, GpuFormat, int, int, int)} but with stencil support */
+ public GpuTexture createTexture( + public GpuTexture createTexture(
+ final @Nullable String label, + final @Nullable String label,
+ @GpuTexture.Usage final int usage, + @GpuTexture.Usage final int usage,
+ final TextureFormat format, + final GpuFormat format,
+ final int width, + final int width,
+ final int height, + final int height,
+ final int depthOrLayers, + final int depthOrLayers,
@@ -43,4 +43,4 @@
+ return this.backend.createTexture(label, usage, format, width, height, depthOrLayers, mipLevels, stencil); + return this.backend.createTexture(label, usage, format, width, height, depthOrLayers, mipLevels, stencil);
} }
private void verifyTextureCreationArgs(@GpuTexture.Usage final int usage, final int width, final int height, final int depthOrLayers, final int mipLevels) { private void verifyTextureCreationArgs(final @GpuTexture.Usage int usage, final int width, final int height, final int depthOrLayers, final int mipLevels) {
@@ -1,20 +1,18 @@
--- a/com/mojang/blaze3d/systems/GpuDeviceBackend.java --- a/com/mojang/blaze3d/systems/GpuDeviceBackend.java
+++ b/com/mojang/blaze3d/systems/GpuDeviceBackend.java +++ b/com/mojang/blaze3d/systems/GpuDeviceBackend.java
@@ -30,9 +_,19 @@ @@ -32,7 +_,17 @@
@Nullable Supplier<String> label, @GpuTexture.Usage final int usage, TextureFormat format, int width, int height, int depthOrLayers, int mipLevels @Nullable Supplier<String> label, @GpuTexture.Usage int usage, GpuFormat format, int width, int height, int depthOrLayers, int mipLevels
); );
+ /** Forge: same as {@link #createTexture(Supplier<String>, int, TextureFormat, int, int, int)} but with stencil support */ + /** Forge: same as {@link #createTexture(Supplier<String>, int, GpuFormat, int, int, int)} but with stencil support */
+ default GpuTexture createTexture(@Nullable Supplier<String> label, @GpuTexture.Usage final int usage, TextureFormat format, int width, int height, int depthOrLayers, int mipLevels, boolean stencil) { + default GpuTexture createTexture(@Nullable Supplier<String> label, @GpuTexture.Usage final int usage, GpuFormat format, int width, int height, int depthOrLayers, int mipLevels, boolean stencil) {
+ return createTexture(label, usage, format, width, height, depthOrLayers, mipLevels); + return createTexture(label, usage, format, width, height, depthOrLayers, mipLevels);
+ } + }
+ +
GpuTexture createTexture( GpuTexture createTexture(@Nullable String label, @GpuTexture.Usage int usage, GpuFormat format, int width, int height, int depthOrLayers, int mipLevels);
@Nullable String label, @GpuTexture.Usage final int usage, TextureFormat format, int width, int height, int depthOrLayers, int mipLevels
);
+ +
+ /** Forge: same as {@link #createTexture(String, int, TextureFormat, int, int, int)} but with stencil support */ + /** Forge: same as {@link #createTexture(String, int, GpuFormat, int, int, int)} but with stencil support */
+ default GpuTexture createTexture(@Nullable String label, @GpuTexture.Usage final int usage, TextureFormat format, int width, int height, int depthOrLayers, int mipLevels, boolean stencil) { + default GpuTexture createTexture(@Nullable String label, @GpuTexture.Usage final int usage, GpuFormat format, int width, int height, int depthOrLayers, int mipLevels, boolean stencil) {
+ return createTexture(label, usage, format, width, height, depthOrLayers, mipLevels); + return createTexture(label, usage, format, width, height, depthOrLayers, mipLevels);
+ } + }
@@ -1,6 +1,6 @@
--- a/com/mojang/blaze3d/textures/GpuTexture.java --- a/com/mojang/blaze3d/textures/GpuTexture.java
+++ b/com/mojang/blaze3d/textures/GpuTexture.java +++ b/com/mojang/blaze3d/textures/GpuTexture.java
@@ -8,7 +_,7 @@ @@ -9,7 +_,7 @@
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
@@ -1,32 +1,31 @@
--- a/com/mojang/blaze3d/vertex/VertexFormat.java --- a/com/mojang/blaze3d/vertex/VertexFormat.java
+++ b/com/mojang/blaze3d/vertex/VertexFormat.java +++ b/com/mojang/blaze3d/vertex/VertexFormat.java
@@ -29,6 +_,7 @@ @@ -19,6 +_,7 @@
private final int[] offsetsByElement = new int[32]; private final int vertexSize;
private @Nullable GpuBuffer immediateDrawVertexBuffer; private final int stepRate;
private @Nullable GpuBuffer immediateDrawIndexBuffer; private final List<VertexFormatElement> elementValues;
+ private final com.google.common.collect.ImmutableMap<String, VertexFormatElement> elementMapping; + private final com.google.common.collect.ImmutableMap<String, VertexFormatElement> elementMapping;
private VertexFormat(final List<VertexFormatElement> elements, final List<String> names, final IntList offsets, final int vertexSize) { private VertexFormat(final List<VertexFormatElement> elements, final int vertexSize, final int stepRate) {
this.elements = elements; this.vertexSize = vertexSize;
@@ -41,6 +_,11 @@ @@ -29,6 +_,11 @@
int index = element != null ? elements.indexOf(element) : -1;
this.offsetsByElement[id] = index != -1 ? offsets.getInt(index) : -1;
} }
this.elementValues = elements;
+ +
+ ImmutableMap.Builder<String, VertexFormatElement> elementMapping = ImmutableMap.builder(); + var elementMapping = com.google.common.collect.ImmutableMap.<String, VertexFormatElement>builder();
+ for (int i = 0; i < elements.size(); i++) + for (var element : elements)
+ elementMapping.put(names.get(i), elements.get(i)); + elementMapping.put(element.name(), element);
+ this.elementMapping = elementMapping.buildOrThrow(); + this.elementMapping = elementMapping.buildOrThrow();
} }
public static VertexFormat.Builder builder() { public static VertexFormat.Builder builder(final int stepRate) {
@@ -139,6 +_,9 @@ @@ -69,6 +_,8 @@
this.immediateDrawIndexBuffer = uploadToBuffer(this.immediateDrawIndexBuffer, buffer, 72, () -> "Immediate index buffer for " + this); public int hashCode() {
return this.immediateDrawIndexBuffer; return this.elementValues.hashCode();
} }
+ +
+ public ImmutableMap<String, VertexFormatElement> getElementMapping() { return elementMapping; } + public com.google.common.collect.ImmutableMap<String, VertexFormatElement> getElementMapping() { return elementMapping; }
+ public int getOffset(int index) { return offsetsByElement[index]; }
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public static class Builder { public static class Builder {
@@ -1,6 +1,6 @@
--- a/com/mojang/math/Transformation.java --- a/com/mojang/math/Transformation.java
+++ b/com/mojang/math/Transformation.java +++ b/com/mojang/math/Transformation.java
@@ -16,7 +_,7 @@ @@ -14,7 +_,7 @@
import org.joml.Vector3fc; import org.joml.Vector3fc;
import org.jspecify.annotations.Nullable; import org.jspecify.annotations.Nullable;
@@ -9,21 +9,21 @@
private static final Vector3fc ZERO_TRANSLATION = new Vector3f(); private static final Vector3fc ZERO_TRANSLATION = new Vector3f();
private static final Vector3fc UNIT_SCALE = new Vector3f(1.0F, 1.0F, 1.0F); private static final Vector3fc UNIT_SCALE = new Vector3f(1.0F, 1.0F, 1.0F);
private static final Quaternionfc ZERO_ROTATION = new Quaternionf(); private static final Quaternionfc ZERO_ROTATION = new Quaternionf();
@@ -171,6 +_,20 @@ @@ -172,6 +_,20 @@
this.scale().lerp(that.scale(), progress, new Vector3f()), this.scale().lerp(that.scale(), progress, new Vector3f()),
this.rightRotation().slerp(that.rightRotation(), progress, new Quaternionf()) this.rightRotation().slerp(that.rightRotation(), progress, new Quaternionf())
); );
+ } + }
+ +
+ private Matrix3f normalTransform = null; + private org.joml.Matrix3f normalTransform = null;
+ public Matrix3f getNormalMatrix() { + public org.joml.Matrix3f getNormalMatrix() {
+ checkNormalTransform(); + checkNormalTransform();
+ return normalTransform; + return normalTransform;
+ } + }
+ +
+ private void checkNormalTransform() { + private void checkNormalTransform() {
+ if (normalTransform == null) { + if (normalTransform == null) {
+ normalTransform = new Matrix3f(matrix); + normalTransform = new org.joml.Matrix3f(matrix);
+ normalTransform.invert(); + normalTransform.invert();
+ normalTransform.transpose(); + normalTransform.transpose();
+ } + }
@@ -6,7 +6,7 @@
@Override @Override
+ public boolean keyPressed(net.minecraft.client.input.KeyEvent event) { + public boolean keyPressed(net.minecraft.client.input.KeyEvent event) {
+ if (event.key() == org.lwjgl.glfw.GLFW.GLFW_KEY_ESCAPE) { + if (event.key() == org.lwjgl.glfw.GLFW.GLFW_KEY_ESCAPE) {
+ minecraft.setScreen(this.nextScreen); + minecraft.gui.setScreen(this.nextScreen);
+ return true; + return true;
+ } + }
+ return super.keyPressed(event); + return super.keyPressed(event);
@@ -1,6 +1,6 @@
--- a/com/mojang/realmsclient/gui/screens/RealmsResetWorldScreen.java --- a/com/mojang/realmsclient/gui/screens/RealmsResetWorldScreen.java
+++ b/com/mojang/realmsclient/gui/screens/RealmsResetWorldScreen.java +++ b/com/mojang/realmsclient/gui/screens/RealmsResetWorldScreen.java
@@ -302,7 +_,7 @@ @@ -300,7 +_,7 @@
int y = this.getY(); int y = this.getY();
graphics.blit(RenderPipelines.GUI_TEXTURED, this.image, x + 2, y + 2, 0.0F, 0.0F, 56, 56, 56, 56, 56, 56, color); graphics.blit(RenderPipelines.GUI_TEXTURED, this.image, x + 2, y + 2, 0.0F, 0.0F, 56, 56, 56, 56, 56, 56, color);
graphics.blitSprite(RenderPipelines.GUI_TEXTURED, SLOT_FRAME_SPRITE, x, y, 60, 60, color); graphics.blitSprite(RenderPipelines.GUI_TEXTURED, SLOT_FRAME_SPRITE, x, y, 60, 60, color);
@@ -1,7 +1,7 @@
--- a/net/minecraft/CrashReport.java --- a/net/minecraft/CrashReport.java
+++ b/net/minecraft/CrashReport.java +++ b/net/minecraft/CrashReport.java
@@ -58,14 +_,9 @@ @@ -58,14 +_,9 @@
if (this.uncategorizedStackTrace != null && this.uncategorizedStackTrace.length > 0) { if (this.uncategorizedStackTrace.length > 0) {
builder.append("-- Head --\n"); builder.append("-- Head --\n");
builder.append("Thread: ").append(Thread.currentThread().getName()).append("\n"); builder.append("Thread: ").append(Thread.currentThread().getName()).append("\n");
- builder.append("Stacktrace:\n"); - builder.append("Stacktrace:\n");
@@ -26,23 +26,20 @@
this.systemReport.appendToCrashReportString(builder); this.systemReport.appendToCrashReportString(builder);
} }
@@ -92,18 +_,7 @@ @@ -84,15 +_,7 @@
exception.setStackTrace(this.exception.getStackTrace()); exception = replaceMessage(exception, this.title);
} }
- String var4;
- try { - try {
- writer = new StringWriter(); - writer = new StringWriter();
- printWriter = new PrintWriter(writer); - printWriter = new PrintWriter(writer);
- exception.printStackTrace(printWriter); - exception.printStackTrace(printWriter);
- var4 = writer.toString(); - return writer.toString();
- } finally { - } finally {
- IOUtils.closeQuietly((Writer)writer); - IOUtils.closeQuietly(writer);
- IOUtils.closeQuietly((Writer)printWriter); - IOUtils.closeQuietly(printWriter);
- } - }
-
- return var4;
+ return net.minecraftforge.logging.CrashReportExtender.generateEnhancedStackTrace(exception); + return net.minecraftforge.logging.CrashReportExtender.generateEnhancedStackTrace(exception);
} }
public String getFriendlyReport(final ReportType reportType, final List<String> extraComments) { private static Throwable copyProperties(final Throwable original, final Throwable copy) {
@@ -1,21 +1,21 @@
--- a/net/minecraft/CrashReportCategory.java --- a/net/minecraft/CrashReportCategory.java
+++ b/net/minecraft/CrashReportCategory.java +++ b/net/minecraft/CrashReportCategory.java
@@ -140,8 +_,10 @@ @@ -138,8 +_,10 @@
if (full.length <= 0) {
return 0; return 0;
} else {
- this.stackTrace = new StackTraceElement[full.length - 3 - nestedOffset];
- System.arraycopy(full, 3 + nestedOffset, this.stackTrace, 0, this.stackTrace.length);
+ int len = full.length - 3 - nestedOffset;
+ if (len <= 0) len = full.length;
+ this.stackTrace = new StackTraceElement[len];
+ System.arraycopy(full, full.length - len, this.stackTrace, 0, this.stackTrace.length);
return this.stackTrace.length;
} }
}
@@ -188,16 +_,16 @@
if (this.stackTrace != null && this.stackTrace.length > 0) { - this.stackTrace = new StackTraceElement[full.length - 3 - nestedOffset];
- System.arraycopy(full, 3 + nestedOffset, this.stackTrace, 0, this.stackTrace.length);
+ int len = full.length - 3 - nestedOffset;
+ if (len <= 0) len = full.length;
+ this.stackTrace = new StackTraceElement[len];
+ System.arraycopy(full, full.length - len, this.stackTrace, 0, this.stackTrace.length);
return this.stackTrace.length;
}
@@ -181,16 +_,16 @@
if (this.stackTrace.length > 0) {
builder.append("\nStacktrace:"); builder.append("\nStacktrace:");
- -
- for (StackTraceElement element : this.stackTrace) { - for (StackTraceElement element : this.stackTrace) {
@@ -1,6 +1,6 @@
--- a/net/minecraft/SharedConstants.java --- a/net/minecraft/SharedConstants.java
+++ b/net/minecraft/SharedConstants.java +++ b/net/minecraft/SharedConstants.java
@@ -216,6 +_,7 @@ @@ -218,6 +_,7 @@
} }
static { static {
@@ -1,6 +1,6 @@
--- a/net/minecraft/advancements/Advancement.java --- a/net/minecraft/advancements/Advancement.java
+++ b/net/minecraft/advancements/Advancement.java +++ b/net/minecraft/advancements/Advancement.java
@@ -219,7 +_,11 @@ @@ -220,7 +_,11 @@
} }
public AdvancementHolder save(final Consumer<AdvancementHolder> output, final String name) { public AdvancementHolder save(final Consumer<AdvancementHolder> output, final String name) {
@@ -1,13 +1,12 @@
--- a/net/minecraft/client/Camera.java --- a/net/minecraft/client/Camera.java
+++ b/net/minecraft/client/Camera.java +++ b/net/minecraft/client/Camera.java
@@ -217,12 +_,14 @@ @@ -224,11 +_,13 @@
return 90.0F;
} else {
float fov = this.minecraft.options.fov().get().intValue() * Mth.lerp(partialTicks, this.oldFovModifier, this.fovModifier);
- return this.modifyFovBasedOnDeathOrFluid(partialTicks, fov);
+ var ret = this.modifyFovBasedOnDeathOrFluid(partialTicks, fov);
+ return net.minecraftforge.client.event.ForgeEventFactoryClient.fireComputeFov(this.minecraft.gameRenderer, this, partialTicks, ret, true).getFOV();
} }
float fov = this.minecraft.options.fov().get().intValue() * Mth.lerp(partialTicks, this.oldFovModifier, this.fovModifier);
- return this.modifyFovBasedOnDeathOrFluid(partialTicks, fov);
+ var ret = this.modifyFovBasedOnDeathOrFluid(partialTicks, fov);
+ return net.minecraftforge.client.event.ForgeEventFactoryClient.fireComputeFov(this.minecraft.gameRenderer, this, partialTicks, ret, true).getFOV();
} }
private float calculateHudFov(final float partialTicks) { private float calculateHudFov(final float partialTicks) {
@@ -17,7 +16,7 @@
} }
private float modifyFovBasedOnDeathOrFluid(final float partialTicks, float fov) { private float modifyFovBasedOnDeathOrFluid(final float partialTicks, float fov) {
@@ -331,9 +_,13 @@ @@ -337,9 +_,13 @@
} }
protected void setRotation(final float yRot, final float xRot) { protected void setRotation(final float yRot, final float xRot) {
@@ -32,7 +31,7 @@
FORWARDS.rotate(this.rotation, this.forwards); FORWARDS.rotate(this.rotation, this.forwards);
UP.rotate(this.rotation, this.up); UP.rotate(this.rotation, this.up);
LEFT.rotate(this.rotation, this.left); LEFT.rotate(this.rotation, this.left);
@@ -364,6 +_,13 @@ @@ -370,6 +_,13 @@
public float yRot() { public float yRot() {
return this.yRot; return this.yRot;
@@ -70,7 +70,7 @@
return this.key.equals(that.key); return this.key.equals(that.key);
} }
@@ -175,11 +_,13 @@ @@ -179,11 +_,13 @@
} }
public Component getTranslatedKeyMessage() { public Component getTranslatedKeyMessage() {
@@ -85,7 +85,7 @@
} }
public String saveString() { public String saveString() {
@@ -191,11 +_,94 @@ @@ -195,11 +_,94 @@
} }
private void registerMapping(final InputConstants.Key key) { private void registerMapping(final InputConstants.Key key) {
@@ -1,24 +1,24 @@
--- a/net/minecraft/client/KeyboardHandler.java --- a/net/minecraft/client/KeyboardHandler.java
+++ b/net/minecraft/client/KeyboardHandler.java +++ b/net/minecraft/client/KeyboardHandler.java
@@ -514,7 +_,7 @@ @@ -478,7 +_,7 @@
if (screen != null) { if (screen != null) {
try { try {
if (action != 1 && action != 2) { if (action != 1 && action != 2) {
- if (action == 0 && screen.keyReleased(event)) { - if (action == 0 && screen.keyReleased(event)) {
+ if (action == 0 && net.minecraftforge.client.ForgeHooksClient.onScreenKeyReleased(screen, event)) { + if (action == 0 && net.minecraftforge.client.ForgeHooksClient.onScreenKeyReleased(screen, event)) {
if (options.keyDebugModifier.matches(event)) { if (options.keyDebugModifier.matches(event)) {
this.usedDebugKeyAsModifier = false; this.usedDebugKeyAsModifier = false;
}
@@ -487,7 +_,7 @@
} }
@@ -523,7 +_,7 @@ } else {
} screen.afterKeyboardAction();
} else { - if (screen.keyPressed(event)) {
screen.afterKeyboardAction(); + if (net.minecraftforge.client.ForgeHooksClient.onScreenKeyPressed(screen, event)) {
- if (screen.keyPressed(event)) { if (this.minecraft.gui.screen() == null) {
+ if (net.minecraftforge.client.ForgeHooksClient.onScreenKeyPressed(screen, event)) { InputConstants.Key key = InputConstants.getKey(event);
if (this.minecraft.screen == null) { KeyMapping.set(key, false);
InputConstants.Key key = InputConstants.getKey(event); @@ -562,6 +_,7 @@
KeyMapping.set(key, false);
@@ -595,6 +_,7 @@
} }
} }
} }
@@ -26,12 +26,12 @@
} }
} }
@@ -603,7 +_,7 @@ @@ -570,7 +_,7 @@
Screen screen = this.minecraft.screen; Screen screen = this.minecraft.gui.screen();
if (screen != null && this.minecraft.getOverlay() == null) { if (screen != null && this.minecraft.gui.overlay() == null) {
try { try {
- screen.charTyped(event); - screen.charTyped(event);
+ net.minecraftforge.client.ForgeHooksClient.onScreenCharTyped(screen, event); + net.minecraftforge.client.ForgeHooksClient.onScreenCharTyped(screen, event);
} catch (Throwable var8) { } catch (Throwable t) {
CrashReport report = CrashReport.forThrowable(var8, "charTyped event handler"); CrashReport report = CrashReport.forThrowable(t, "charTyped event handler");
screen.fillCrashDetails(report); screen.fillCrashDetails(report);
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/Minecraft.java --- a/net/minecraft/client/Minecraft.java
+++ b/net/minecraft/client/Minecraft.java +++ b/net/minecraft/client/Minecraft.java
@@ -268,7 +_,7 @@ @@ -258,7 +_,7 @@
import org.slf4j.Logger; import org.slf4j.Logger;
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
@@ -9,7 +9,7 @@
private static Minecraft instance; private static Minecraft instance;
private static final Logger LOGGER = LogUtils.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
private static final int MAX_TICKS_PER_UPDATE = 10; private static final int MAX_TICKS_PER_UPDATE = 10;
@@ -432,7 +_,6 @@ @@ -410,7 +_,6 @@
} }
}, Util.nonCriticalIoPool()); }, Util.nonCriticalIoPool());
LOGGER.info("Setting user: {}", this.user.getName()); LOGGER.info("Setting user: {}", this.user.getName());
@@ -17,68 +17,74 @@
this.demo = gameConfig.game.demo; this.demo = gameConfig.game.demo;
this.allowsMultiplayer = !gameConfig.game.disableMultiplayer; this.allowsMultiplayer = !gameConfig.game.disableMultiplayer;
this.allowsChat = !gameConfig.game.disableChat; this.allowsChat = !gameConfig.game.disableChat;
@@ -518,14 +_,14 @@ @@ -547,12 +_,12 @@
LOGGER.error("Couldn't set icon", (Throwable)var23); LOGGER.error("Couldn't set icon", e);
}
+ // FORGE: Move mouse and keyboard handler setup further below
this.mouseHandler = new MouseHandler(this);
- this.mouseHandler.setup(this.window);
this.keyboardHandler = new KeyboardHandler(this);
- this.keyboardHandler.setup(this.window);
this.options.applyGraphicsPreset(this.options.graphicsPreset().get());
this.resourceManager = new ReloadableResourceManager(PackType.CLIENT_RESOURCES);
+ net.minecraftforge.client.loading.ClientModLoader.begin(this, this.resourcePackRepository, this.resourceManager);
this.resourcePackRepository.reload();
this.options.loadSelectedResourcePacks(this.resourcePackRepository);
this.languageManager = new LanguageManager(this.options.languageCode, var1 -> {
@@ -630,6 +_,7 @@
ParticleResources particleResources = new ParticleResources();
this.resourceManager.registerReloadListener(particleResources);
this.particleEngine = new ParticleEngine(this.level, particleResources);
+ net.minecraftforge.client.ForgeHooksClient.onRegisterParticleProviders(particleResources);
particleResources.onReload(this.particleEngine::clearParticles);
this.gameRenderer = new GameRenderer(this, this.entityRenderDispatcher.getItemInHandRenderer(), this.modelManager);
WindowRenderState windowRenderState = this.gameRenderer.gameRenderState().windowRenderState;
@@ -647,6 +_,7 @@
this.window.getHeight()
);
this.levelExtractor = new LevelExtractor(this, this.gameRenderer.gameRenderState().levelRenderState, this.levelRenderer);
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onInitLevelRenderer();
this.resourceManager.registerReloadListener(this.levelExtractor);
this.resourceManager.registerReloadListener(this.levelRenderer.cloudRenderer());
this.gpuWarnlistManager = new GpuWarnlistManager();
@@ -654,6 +_,9 @@
this.resourceManager.registerReloadListener(this.regionalCompliancies);
this.gui = new Gui(this, new Hud(this), this.gameRenderer.gameRenderState().guiRenderState);
this.gui.registerReloadListeners(this.resourceManager);
+ // FORGE: Moved keyboard and mouse handler setup below ingame gui creation to prevent NPEs in them.
+ this.mouseHandler.setup(this.window);
+ this.keyboardHandler.setup(this.window);
RealmsClient realmsClient = RealmsClient.getOrCreate(this);
this.realmsDataFetcher = new RealmsDataFetcher(realmsClient);
RenderSystem.setErrorCallback(this::onFullscreenError);
@@ -686,6 +_,7 @@
}
}
+ net.minecraftforge.client.ForgeHooksClient.initClientHooks(this, this.resourceManager);
this.window.updateRawMouseInput(this.options.rawMouseInput().get());
this.window.setAllowCursorChanges(this.options.allowCursorChanges().get());
this.window.setDefaultErrorCallback();
@@ -710,14 +_,15 @@
.createReload(Util.backgroundExecutor().forName("resourceLoad"), this, RESOURCE_RELOAD_INITIAL_TASK, packs);
GameLoadTimesEvent.INSTANCE.beginStep(TelemetryProperty.LOAD_TIME_LOADING_OVERLAY_MS);
GameLoadCookie loadCookie = new GameLoadCookie(realmsClient, gameConfig.quickPlay);
- this.gui.setOverlay(new LoadingOverlay(this, reloadInstance, maybeT -> Util.ifElse(maybeT, t -> this.rollbackResourcePacks(t, loadCookie), () -> {
+ this.gui.setOverlay(net.minecraftforge.fml.loading.ImmediateWindowHandler.<LoadingOverlay>loadingOverlay(() -> this, () ->reloadInstance, maybeT -> Util.ifElse(maybeT, t -> this.rollbackResourcePacks(t, loadCookie), () -> {
if (SharedConstants.IS_RUNNING_IN_IDE) {
this.selfTest();
} }
+ // FORGE: Move mouse and keyboard handler setup further below this.reloadStateTracker.finishReload();
this.mouseHandler = new MouseHandler(this); this.onResourceLoadFinished(loadCookie);
- this.mouseHandler.setup(this.window); - }), false));
this.keyboardHandler = new KeyboardHandler(this); + net.minecraftforge.client.loading.ClientModLoader.completeModLoading();
- this.keyboardHandler.setup(this.window); + }), false).get());
this.options.applyGraphicsPreset(this.options.graphicsPreset().get()); this.quickPlayLog = QuickPlayLog.of(gameConfig.quickPlay.logPath());
LOGGER.info("Using optional rendering extensions: {}", String.join(", ", RenderSystem.getDevice().getEnabledExtensions())); this.framerateLimitTracker = new FramerateLimitTracker(this.options, this);
this.mainRenderTarget = new MainTarget(this.window.getWidth(), this.window.getHeight()); this.fpsPieProfiler = new ContinuousProfiler(Util.timeSource(), () -> this.fpsPieRenderTicks, this.framerateLimitTracker::isHeavilyThrottled);
this.resourceManager = new ReloadableResourceManager(PackType.CLIENT_RESOURCES); @@ -801,6 +_,7 @@
+ net.minecraftforge.client.loading.ClientModLoader.begin(this, this.resourcePackRepository, this.resourceManager);
this.resourcePackRepository.reload();
this.options.loadSelectedResourcePacks(this.resourcePackRepository);
this.languageManager = new LanguageManager(this.options.languageCode, languageData -> {
@@ -613,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);
@@ -634,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);
+ this.keyboardHandler.setup(this.window);
RealmsClient realmsClient = RealmsClient.getOrCreate(this);
this.realmsDataFetcher = new RealmsDataFetcher(realmsClient);
RenderSystem.setErrorCallback(this::onFullscreenError);
@@ -665,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.setAllowCursorChanges(this.options.allowCursorChanges().get());
@@ -690,14 +_,15 @@
.createReload(Util.backgroundExecutor().forName("resourceLoad"), this, RESOURCE_RELOAD_INITIAL_TASK, packs);
GameLoadTimesEvent.INSTANCE.beginStep(TelemetryProperty.LOAD_TIME_LOADING_OVERLAY_MS);
Minecraft.GameLoadCookie loadCookie = new Minecraft.GameLoadCookie(realmsClient, gameConfig.quickPlay);
- this.setOverlay(new LoadingOverlay(this, reloadInstance, maybeT -> Util.ifElse(maybeT, t -> this.rollbackResourcePacks(t, loadCookie), () -> {
+ this.setOverlay(net.minecraftforge.fml.loading.ImmediateWindowHandler.<LoadingOverlay>loadingOverlay(() -> this, () ->reloadInstance, maybeT -> Util.ifElse(maybeT, t -> this.rollbackResourcePacks(t, loadCookie), () -> {
if (SharedConstants.IS_RUNNING_IN_IDE) {
this.selfTest();
}
this.reloadStateTracker.finishReload();
this.onResourceLoadFinished(loadCookie);
- }), false));
+ net.minecraftforge.client.loading.ClientModLoader.completeModLoading();
+ }), false).get());
this.quickPlayLog = QuickPlayLog.of(gameConfig.quickPlay.logPath());
this.framerateLimitTracker = new FramerateLimitTracker(this.options, this);
this.fpsPieProfiler = new ContinuousProfiler(Util.timeSource, () -> this.fpsPieRenderTicks, this.framerateLimitTracker::isHeavilyThrottled);
@@ -816,6 +_,7 @@
StringBuilder builder = new StringBuilder("Minecraft"); StringBuilder builder = new StringBuilder("Minecraft");
if (checkModStatus().shouldReportAsModified()) { if (checkModStatus().shouldReportAsModified()) {
builder.append("*"); builder.append("*");
@@ -86,88 +92,51 @@
} }
builder.append(" "); builder.append(" ");
@@ -839,6 +_,8 @@ @@ -824,6 +_,8 @@
} }
private UserApiService createUserApiService(final YggdrasilAuthenticationService authService, final GameConfig config) { private static UserApiService createUserApiService(final YggdrasilAuthenticationService authService, final GameConfig config) {
+ if ("0".equals(config.user.user.getAccessToken())) // Forge: We use "0" in dev. Short circuit to stop exception spam. + if ("0".equals(config.user.user.getAccessToken())) // Forge: We use "0" in dev. Short circuit to stop exception spam.
+ return UserApiService.OFFLINE; + return UserApiService.OFFLINE;
return config.game.offlineDeveloperMode ? UserApiService.OFFLINE : authService.createUserApiService(config.user.user.getAccessToken()); return config.game.offlineDeveloperMode ? UserApiService.OFFLINE : authService.createUserApiService(config.user.user.getAccessToken());
} }
@@ -851,7 +_,7 @@ @@ -840,7 +_,7 @@
} }
private void rollbackResourcePacks(final Throwable t, final Minecraft.@Nullable GameLoadCookie loadCookie) { private void rollbackResourcePacks(final Throwable t, final @Nullable GameLoadCookie loadCookie) {
- if (this.resourcePackRepository.getSelectedIds().size() > 1) { - if (this.resourcePackRepository.getSelectedIds().size() > 1) {
+ if (this.resourcePackRepository.getSelectedPacks().stream().anyMatch(e -> !e.isRequired())) { //Forge: This caused infinite loop if any resource packs are forced. Such as mod resources. So check if we can disable any. + if (this.resourcePackRepository.getSelectedPacks().stream().anyMatch(e -> !e.isRequired())) { //Forge: This caused infinite loop if any resource packs are forced. Such as mod resources. So check if we can disable any.
this.clearResourcePacksOnError(t, null, loadCookie); this.clearResourcePacksOnError(t, null, loadCookie);
} else { } else {
Util.throwAsRuntime(t); Util.throwAsRuntime(t);
@@ -1128,12 +_,6 @@ @@ -1141,6 +_,7 @@
LOGGER.error("setScreen called from non-game thread");
}
- if (this.screen != null) {
- this.screen.removed();
- } else {
- this.setLastInputType(InputType.NONE);
- }
-
if (screen == null) {
if (this.clientLevelTeardownInProgress) {
throw new IllegalStateException("Trying to return to in-game GUI during disconnection");
@@ -1152,6 +_,23 @@
}
}
+ net.minecraftforge.client.ForgeHooksClient.clearGuiLayers(this);
+ Screen old = this.screen;
+ if (screen != null) {
+ var event = net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenOpening(old, screen);
+ if (event == null) return;
+ screen = event;
+ }
+
+ if (screen != old) {
+ if (old != null) {
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenClose(old);
+ old.removed();
+ } else {
+ this.setLastInputType(InputType.NONE);
+ }
+ }
+
this.screen = screen;
if (this.screen != null) {
this.screen.added();
@@ -1235,6 +_,7 @@
Util.shutdownExecutors(); Util.shutdownExecutors();
RenderSystem.getSamplerCache().close(); this.windowSurface.close();
RenderSystem.getDevice().close(); RenderSystem.shutdownRenderer();
+ net.minecraftforge.fml.config.ConfigTracker.forceUnload(); + net.minecraftforge.fml.config.ConfigTracker.forceUnload();
} catch (Throwable var5) { } catch (Throwable t) {
LOGGER.error("Shutdown failure!", var5); LOGGER.error("Shutdown failure!", t);
throw var5; throw t;
@@ -1346,7 +_,9 @@ @@ -1301,7 +_,9 @@
profiler.popPush("gpuAsync"); profiler.popPush("gpuAsync");
RenderSystem.executePendingTasks(); RenderSystem.executePendingTasks();
profiler.pop(); profiler.pop();
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderTickStart(this.deltaTracker); + net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderTickStart(this.deltaTracker);
this.gameRenderer.render(this.deltaTracker, advanceGameTime); this.gameRenderer.render(this.deltaTracker, advanceGameTime);
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderTickEnd(this.deltaTracker); + net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderTickEnd(this.deltaTracker);
profiler.push("present"); }
if (!this.gameRenderer.getGameRenderState().windowRenderState.isMinimized) {
this.mainRenderTarget.blitToScreen(); profiler.push("present");
@@ -1450,6 +_,7 @@ @@ -1425,6 +_,7 @@
this.window.setGuiScale(guiScale); this.window.setGuiScale(guiScale);
if (this.screen != null) { if (this.gui.screen() != null) {
this.screen.resize(this.window.getGuiScaledWidth(), this.window.getGuiScaledHeight()); this.gui.screen().resize(this.window.getGuiScaledWidth(), this.window.getGuiScaledHeight());
+ net.minecraftforge.client.ForgeHooksClient.resizeGuiLayers(this, this.window.getGuiScaledWidth(), this.window.getGuiScaledHeight()); + this.gui.resizeLayers(this.window.getGuiScaledWidth(), this.window.getGuiScaledHeight());
} }
this.mouseHandler.setIgnoreFirstMove(); this.mouseHandler.setIgnoreFirstMove();
@@ -1601,6 +_,7 @@ @@ -1576,6 +_,7 @@
} }
public void stop() { public void stop() {
@@ -175,7 +144,7 @@
this.running = false; this.running = false;
} }
@@ -1630,10 +_,18 @@ @@ -1599,10 +_,18 @@
if (down && this.hitResult != null && this.hitResult.getType() == HitResult.Type.BLOCK) { if (down && this.hitResult != null && this.hitResult.getType() == HitResult.Type.BLOCK) {
BlockHitResult blockHit = (BlockHitResult)this.hitResult; BlockHitResult blockHit = (BlockHitResult)this.hitResult;
BlockPos pos = blockHit.getBlockPos(); BlockPos pos = blockHit.getBlockPos();
@@ -197,36 +166,36 @@
this.player.swing(InteractionHand.MAIN_HAND); this.player.swing(InteractionHand.MAIN_HAND);
} }
} }
@@ -1676,6 +_,8 @@ @@ -1656,6 +_,8 @@
this.player.swing(InteractionHand.MAIN_HAND);
return true; return true;
} else {
+ 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))
switch (this.hitResult.getType()) {
case ENTITY:
AttackRange customItemRange = heldItem.get(DataComponents.ATTACK_RANGE);
@@ -1686,7 +_,7 @@
case BLOCK:
BlockHitResult blockHit = (BlockHitResult)this.hitResult;
BlockPos pos = blockHit.getBlockPos();
- if (!this.level.getBlockState(pos).isAir()) {
+ if (!this.level.isEmptyBlock(pos)) {
this.gameMode.startDestroyBlock(pos, blockHit.getDirection());
if (this.level.getBlockState(pos).isAir()) {
endAttack = true;
@@ -1699,8 +_,10 @@
}
this.player.resetAttackStrengthTicker();
+ net.minecraftforge.event.ForgeEventFactory.onLeftClickEmpty(this.player);
}
+ if (inputEvent.shouldSwingHand())
this.player.swing(InteractionHand.MAIN_HAND);
return endAttack;
} }
@@ -1717,6 +_,12 @@
+ 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))
switch (this.hitResult.getType()) {
case ENTITY:
AttackRange customItemRange = heldItem.get(DataComponents.ATTACK_RANGE);
@@ -1666,7 +_,7 @@
case BLOCK:
BlockHitResult blockHit = (BlockHitResult)this.hitResult;
BlockPos pos = blockHit.getBlockPos();
- if (!this.level.getBlockState(pos).isAir()) {
+ if (!this.level.isEmptyBlock(pos)) {
this.gameMode.startDestroyBlock(pos, blockHit.getDirection());
if (this.level.getBlockState(pos).isAir()) {
endAttack = true;
@@ -1679,8 +_,10 @@
}
this.player.resetAttackStrengthTicker();
+ net.minecraftforge.event.ForgeEventFactory.onLeftClickEmpty(this.player);
}
+ if (inputEvent.shouldSwingHand())
this.player.swing(InteractionHand.MAIN_HAND);
return endAttack;
}
@@ -1696,6 +_,12 @@
} }
for (InteractionHand hand : InteractionHand.values()) { for (InteractionHand hand : InteractionHand.values()) {
@@ -239,7 +208,7 @@
ItemStack heldItem = this.player.getItemInHand(hand); ItemStack heldItem = this.player.getItemInHand(hand);
if (!heldItem.isItemEnabled(this.level.enabledFeatures())) { if (!heldItem.isItemEnabled(this.level.enabledFeatures())) {
return; return;
@@ -1733,7 +_,7 @@ @@ -1712,7 +_,7 @@
if (this.player.isWithinEntityInteractionRange(entity, 0.0) if (this.player.isWithinEntityInteractionRange(entity, 0.0)
&& this.gameMode.interact(this.player, entity, entityHit, hand) instanceof InteractionResult.Success success) { && this.gameMode.interact(this.player, entity, entityHit, hand) instanceof InteractionResult.Success success) {
@@ -248,7 +217,7 @@
this.player.swing(hand); this.player.swing(hand);
} }
@@ -1745,7 +_,7 @@ @@ -1724,7 +_,7 @@
int oldCount = heldItem.getCount(); int oldCount = heldItem.getCount();
InteractionResult useResult = this.gameMode.useItemOn(this.player, hand, blockHit); InteractionResult useResult = this.gameMode.useItemOn(this.player, hand, blockHit);
if (useResult instanceof InteractionResult.Success success) { if (useResult instanceof InteractionResult.Success success) {
@@ -257,7 +226,7 @@
this.player.swing(hand); this.player.swing(hand);
if (!heldItem.isEmpty() && (heldItem.getCount() != oldCount || this.player.hasInfiniteMaterials())) { if (!heldItem.isEmpty() && (heldItem.getCount() != oldCount || this.player.hasInfiniteMaterials())) {
this.gameRenderer.itemInHandRenderer.itemUsed(hand); this.gameRenderer.itemInHandRenderer.itemUsed(hand);
@@ -1761,6 +_,9 @@ @@ -1740,6 +_,9 @@
} }
} }
@@ -267,24 +236,24 @@
if (!heldItem.isEmpty() && this.gameMode.useItem(this.player, hand) instanceof InteractionResult.Success success) { if (!heldItem.isEmpty() && this.gameMode.useItem(this.player, hand) instanceof InteractionResult.Success success) {
if (success.swingSource() == InteractionResult.SwingSource.CLIENT) { if (success.swingSource() == InteractionResult.SwingSource.CLIENT) {
this.player.swing(hand); this.player.swing(hand);
@@ -1789,6 +_,8 @@ @@ -1768,6 +_,8 @@
} }
ProfilerFiller profiler = Profiler.get(); ProfilerFiller profiler = Profiler.get();
+ net.minecraftforge.event.ForgeEventFactory.onPreClientTick(); + net.minecraftforge.event.ForgeEventFactory.onPreClientTick();
+ +
profiler.push("gui"); profiler.push("gameMode");
this.textInputManager.tick(); if (!this.pause && this.level != null) {
this.chatListener.tick(); this.gameMode.tick();
@@ -1871,6 +_,7 @@ @@ -1817,6 +_,7 @@
this.tutorial.tick(); this.tutorial.tick();
+ net.minecraftforge.event.ForgeEventFactory.onPreLevelTick(this.level, () -> true); + net.minecraftforge.event.ForgeEventFactory.onPreLevelTick(this.level, () -> true);
try { try {
this.level.tick(() -> true); this.level.tick(() -> true);
} catch (Throwable var6) { } catch (Throwable t) {
@@ -1884,6 +_,7 @@ @@ -1830,6 +_,7 @@
throw new ReportedException(report); throw new ReportedException(report);
} }
@@ -292,7 +261,7 @@
} }
profiler.popPush("animateTick"); profiler.popPush("animateTick");
@@ -1908,6 +_,7 @@ @@ -1854,6 +_,7 @@
profiler.popPush("keyboard"); profiler.popPush("keyboard");
this.keyboardHandler.tick(); this.keyboardHandler.tick();
profiler.pop(); profiler.pop();
@@ -300,7 +269,7 @@
} }
private boolean isLevelRunningNormally() { private boolean isLevelRunningNormally() {
@@ -2138,6 +_,7 @@ @@ -2059,6 +_,7 @@
} }
public void setLevel(final ClientLevel level) { public void setLevel(final ClientLevel level) {
@@ -308,23 +277,23 @@
this.level = level; this.level = level;
this.updateLevelInEngines(level); this.updateLevelInEngines(level);
} }
@@ -2199,6 +_,7 @@ @@ -2120,6 +_,7 @@
IntegratedServer server = this.singleplayerServer; IntegratedServer server = this.singleplayerServer;
this.singleplayerServer = null; this.singleplayerServer = null;
this.gameRenderer.resetData(); this.gameRenderer.resetData();
+ net.minecraftforge.client.event.ForgeEventFactoryClient.firePlayerLogout(this.gameMode, this.player); + net.minecraftforge.client.event.ForgeEventFactoryClient.firePlayerLogout(this.gameMode, this.player);
this.gameMode = null; this.gameMode = null;
this.narrator.clear(); this.narrator.clear();
this.clientLevelTeardownInProgress = true; this.gui.setClientLevelTeardownInProgress(true);
@@ -2206,6 +_,7 @@ @@ -2127,6 +_,7 @@
try { try {
if (this.level != null) { if (this.level != null) {
this.gui.onDisconnected(); this.gui.hud.onDisconnected();
+ net.minecraftforge.event.ForgeEventFactory.onLevelUnload(this.level); + net.minecraftforge.event.ForgeEventFactory.onLevelUnload(this.level);
} }
this.level = null; this.level = null;
@@ -2220,6 +_,7 @@ @@ -2141,6 +_,7 @@
} }
profiler.pop(); profiler.pop();
@@ -332,7 +301,7 @@
} }
this.setScreenAndShow(screen); this.setScreenAndShow(screen);
@@ -2372,6 +_,7 @@ @@ -2354,6 +_,7 @@
private void pickBlockOrEntity() { private void pickBlockOrEntity() {
if (this.hitResult != null && this.hitResult.getType() != HitResult.Type.MISS) { if (this.hitResult != null && this.hitResult.getType() != HitResult.Type.MISS) {
@@ -1,14 +1,14 @@
--- a/net/minecraft/client/MouseHandler.java --- a/net/minecraft/client/MouseHandler.java
+++ b/net/minecraft/client/MouseHandler.java +++ b/net/minecraft/client/MouseHandler.java
@@ -87,6 +_,7 @@ @@ -77,6 +_,7 @@
this.activeButton = null; this.activeButton = null;
} }
+ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onMouseButtonPre(buttonInfo, action)) return; + if (net.minecraftforge.client.event.ForgeEventFactoryClient.onMouseButtonPre(buttonInfo, action)) return;
if (this.minecraft.getOverlay() == null) { if (this.minecraft.gui.overlay() == null) {
if (this.minecraft.screen == null) { if (pressed
if (!this.mouseGrabbed && pressed) { && this.minecraft.handleGlobalKeyPress(InputConstants.Type.MOUSE.getOrCreate(buttonInfo.button()), buttonInfo.hasControlDownWithQuirk())) {
@@ -106,7 +_,7 @@ @@ -101,7 +_,7 @@
&& currentTime - this.lastClick.time() < 250L && currentTime - this.lastClick.time() < 250L
&& this.lastClick.screen() == screen && this.lastClick.screen() == screen
&& this.lastClickButton == event.button(); && this.lastClickButton == event.button();
@@ -17,7 +17,7 @@
this.lastClick = new MouseHandler.LastClick(currentTime, screen); this.lastClick = new MouseHandler.LastClick(currentTime, screen);
this.lastClickButton = buttonInfo.button(); this.lastClickButton = buttonInfo.button();
return; return;
@@ -121,7 +_,7 @@ @@ -116,7 +_,7 @@
} }
} else { } else {
try { try {
@@ -25,8 +25,8 @@
+ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenMouseReleased(screen, xm, ym, event)) { + if (net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenMouseReleased(screen, xm, ym, event)) {
return; return;
} }
} catch (Throwable var17) { } catch (Throwable t) {
@@ -151,6 +_,7 @@ @@ -146,6 +_,7 @@
KeyMapping.click(mouseKey); KeyMapping.click(mouseKey);
} }
} }
@@ -34,35 +34,35 @@
} }
} }
@@ -202,7 +_,9 @@ @@ -197,7 +_,9 @@
if (this.minecraft.screen != null) { if (this.minecraft.gui.screen() != null) {
double xm = this.getScaledXPos(this.minecraft.getWindow()); double xm = this.getScaledXPos(this.minecraft.getWindow());
double ym = this.getScaledYPos(this.minecraft.getWindow()); double ym = this.getScaledYPos(this.minecraft.getWindow());
- this.minecraft.screen.mouseScrolled(xm, ym, scaledXOffset, scaledYOffset); - this.minecraft.gui.screen().mouseScrolled(xm, ym, scaledXOffset, scaledYOffset);
+ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenMouseScrollPre(this.minecraft.screen, xm, ym, scaledXOffset, scaledYOffset)) return; + if (net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenMouseScrollPre(this.minecraft.gui.screen(), xm, ym, scaledXOffset, scaledYOffset)) return;
+ if (this.minecraft.screen.mouseScrolled(xm, ym, scaledXOffset, scaledYOffset)) return; + if (this.minecraft.gui.screen().mouseScrolled(xm, ym, scaledXOffset, scaledYOffset)) return;
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenMouseScrollPost(this.minecraft.screen, xm, ym, scaledXOffset, scaledYOffset); + net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenMouseScrollPost(this.minecraft.gui.screen(), xm, ym, scaledXOffset, scaledYOffset);
this.minecraft.screen.afterMouseAction(); this.minecraft.gui.screen().afterMouseAction();
} else if (this.minecraft.player != null) { } else if (this.minecraft.player != null) {
Vector2i wheelXY = this.scrollWheelHandler.onMouseScroll(scaledXOffset, scaledYOffset); Vector2i wheelXY = this.scrollWheelHandler.onMouseScroll(scaledXOffset, scaledYOffset);
@@ -211,6 +_,7 @@ @@ -206,6 +_,7 @@
} }
int wheel = wheelXY.y == 0 ? -wheelXY.x : wheelXY.y; int wheel = wheelXY.y == 0 ? -wheelXY.x : wheelXY.y;
+ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onMouseScroll(this, scaledXOffset, scaledYOffset)) return; + if (net.minecraftforge.client.event.ForgeEventFactoryClient.onMouseScroll(this, scaledXOffset, scaledYOffset)) return;
if (this.minecraft.player.isSpectator()) { if (this.minecraft.player.isSpectator()) {
if (this.minecraft.gui.getSpectatorGui().isMenuActive()) { if (this.minecraft.gui.hud.getSpectatorGui().isMenuActive()) {
this.minecraft.gui.getSpectatorGui().onMouseScrolled(-wheel); this.minecraft.gui.hud.getSpectatorGui().onMouseScrolled(-wheel);
@@ -317,7 +_,7 @@ @@ -312,7 +_,7 @@
double dy = getScaledYPos(window, this.accumulatedDY); double dy = getScaledYPos(window, this.accumulatedDY);
try { try {
- screen.mouseDragged(new MouseButtonEvent(xm, ym, this.activeButton), dx, dy); - screen.mouseDragged(new MouseButtonEvent(xm, ym, this.activeButton), dx, dy);
+ net.minecraftforge.client.ForgeHooksClient.onScreenMouseDrag(screen, new MouseButtonEvent(xm, ym, this.activeButton), dx, dy); + net.minecraftforge.client.ForgeHooksClient.onScreenMouseDrag(screen, new MouseButtonEvent(xm, ym, this.activeButton), dx, dy);
} catch (Throwable var19) { } catch (Throwable t) {
CrashReport report = CrashReport.forThrowable(var19, "mouseDragged event handler"); CrashReport report = CrashReport.forThrowable(t, "mouseDragged event handler");
screen.fillCrashDetails(report); screen.fillCrashDetails(report);
@@ -402,6 +_,14 @@ @@ -397,6 +_,14 @@
public double ypos() { public double ypos() {
return this.ypos; return this.ypos;
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/Options.java --- a/net/minecraft/client/Options.java
+++ b/net/minecraft/client/Options.java +++ b/net/minecraft/client/Options.java
@@ -929,6 +_,7 @@ @@ -986,6 +_,7 @@
); );
public boolean syncWrites; public boolean syncWrites;
public boolean startedCleanly = true; public boolean startedCleanly = true;
@@ -8,7 +8,7 @@
public static boolean isSoundDeviceDefault(final String deviceName) { public static boolean isSoundDeviceDefault(final String deviceName) {
return deviceName.equals(""); return deviceName.equals("");
@@ -1404,6 +_,7 @@ @@ -1474,6 +_,7 @@
} }
public Options(final Minecraft minecraft, final File workingDirectory) { public Options(final Minecraft minecraft, final File workingDirectory) {
@@ -16,7 +16,7 @@
this.minecraft = minecraft; this.minecraft = minecraft;
this.optionsFile = new File(workingDirectory, "options.txt"); this.optionsFile = new File(workingDirectory, "options.txt");
boolean largeDistances = Runtime.getRuntime().maxMemory() >= 1000000000L; boolean largeDistances = Runtime.getRuntime().maxMemory() >= 1000000000L;
@@ -1556,15 +_,28 @@ @@ -1624,15 +_,28 @@
this.startedCleanly = access.process("startedCleanly", this.startedCleanly); this.startedCleanly = access.process("startedCleanly", this.startedCleanly);
access.process("musicToast", this.musicToast); access.process("musicToast", this.musicToast);
access.process("musicFrequency", this.musicFrequency); access.process("musicFrequency", this.musicFrequency);
@@ -46,7 +46,7 @@
for (SoundSource source : SoundSource.values()) { for (SoundSource source : SoundSource.values()) {
access.process("soundCategory_" + source.getName(), this.soundSourceVolumes.get(source)); access.process("soundCategory_" + source.getName(), this.soundSourceVolumes.get(source));
} }
@@ -1579,6 +_,10 @@ @@ -1647,6 +_,10 @@
} }
public void load() { public void load() {
@@ -57,7 +57,7 @@
try { try {
if (!this.optionsFile.exists()) { if (!this.optionsFile.exists()) {
return; return;
@@ -1598,7 +_,8 @@ @@ -1666,7 +_,8 @@
} }
final CompoundTag options = this.dataFix(rawOptions); final CompoundTag options = this.dataFix(rawOptions);
@@ -65,9 +65,9 @@
+ java.util.function.Consumer<FieldAccess> processor = limited ? this::processOptionsKeysOnly : this::processOptions; + java.util.function.Consumer<FieldAccess> processor = limited ? this::processOptionsKeysOnly : this::processOptions;
+ processor.accept( + processor.accept(
new Options.FieldAccess() { new Options.FieldAccess() {
{ private @Nullable String getValue(final String name) {
Objects.requireNonNull(Options.this); Tag tag = options.get(name);
@@ -1680,6 +_,17 @@ @@ -1748,6 +_,17 @@
); );
options.getString("fullscreenResolution").ifPresent(fullscreenResolution -> this.fullscreenVideoModeString = fullscreenResolution); options.getString("fullscreenResolution").ifPresent(fullscreenResolution -> this.fullscreenVideoModeString = fullscreenResolution);
KeyMapping.resetMapping(); KeyMapping.resetMapping();
@@ -82,26 +82,22 @@
+ } + }
+ } + }
+ +
} catch (Exception var7) { } catch (Exception e) {
LOGGER.error("Failed to load options", (Throwable)var7); LOGGER.error("Failed to load options", e);
} }
@@ -1707,6 +_,7 @@ @@ -1778,9 +_,11 @@
public void save() { public void save() {
try (final PrintWriter writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(this.optionsFile), StandardCharsets.UTF_8))) { try (final PrintWriter writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(this.optionsFile), StandardCharsets.UTF_8))) {
writer.println("version:" + SharedConstants.getCurrentVersion().dataVersion().version()); writer.println("version:" + SharedConstants.getCurrentVersion().dataVersion().version());
+ var seen = new java.util.HashSet<String>(); + var seen = new java.util.HashSet<String>();
this.processOptions( this.processOptions(
new Options.FieldAccess() { new Options.FieldAccess() {
{
@@ -1714,6 +_,7 @@
}
public void writePrefix(final String name) { public void writePrefix(final String name) {
+ seen.add(name); + seen.add(name);
writer.print(name); writer.print(name);
writer.print(':'); writer.print(':');
} }
@@ -1769,6 +_,12 @@ @@ -1836,6 +_,12 @@
if (fullscreenVideoModeString != null) { if (fullscreenVideoModeString != null) {
writer.println("fullscreenResolution:" + fullscreenVideoModeString); writer.println("fullscreenResolution:" + fullscreenVideoModeString);
} }
@@ -111,10 +107,10 @@
+ writer.println(entry.getKey() + ":" + entry.getValue()); + writer.println(entry.getKey() + ":" + entry.getValue());
+ } + }
+ +
} catch (Exception var6) { } catch (Exception e) {
LOGGER.error("Failed to save options", (Throwable)var6); LOGGER.error("Failed to save options", e);
} }
@@ -1806,6 +_,7 @@ @@ -1873,6 +_,7 @@
} }
public void broadcastOptions() { public void broadcastOptions() {
@@ -122,7 +118,7 @@
if (this.minecraft.player != null) { if (this.minecraft.player != null) {
this.minecraft.player.connection.broadcastClientInformation(this.buildPlayerInformation()); this.minecraft.player.connection.broadcastClientInformation(this.buildPlayerInformation());
} }
@@ -1923,6 +_,23 @@ @@ -1986,6 +_,23 @@
public static Component genericValueLabel(final Component caption, final int value) { public static Component genericValueLabel(final Component caption, final int value) {
return genericValueLabel(caption, Component.literal(Integer.toString(value))); return genericValueLabel(caption, Component.literal(Integer.toString(value)));
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/Screenshot.java --- a/net/minecraft/client/Screenshot.java
+++ b/net/minecraft/client/Screenshot.java +++ b/net/minecraft/client/Screenshot.java
@@ -44,6 +_,13 @@ @@ -53,14 +_,24 @@
file = new File(picDir, forceName); file = new File(picDir, forceName);
} }
@@ -14,19 +14,17 @@
Util.ioPool() Util.ioPool()
.execute( .execute(
() -> { () -> {
@@ -51,10 +_,13 @@ try (image) {
NativeImage twrVar0$ = image; - image.writeToFile(file);
- Component component = Component.literal(file.getName())
try { + image.writeToFile(outputFile);
- image.writeToFile(file); + Component component = Component.literal(outputFile.getName())
- Component component = Component.literal(file.getName()) .withStyle(ChatFormatting.UNDERLINE)
+ image.writeToFile(outputFile); - .withStyle(s -> s.withClickEvent(new ClickEvent.OpenFile(file.getAbsoluteFile())));
+ Component component = Component.literal(outputFile.getName()) + .withStyle(s -> s.withClickEvent(new ClickEvent.OpenFile(outputFile.getAbsoluteFile())));
.withStyle(ChatFormatting.UNDERLINE) + if (event.getResultMessage() != null)
.withStyle(s -> s.withClickEvent(new ClickEvent.OpenFile(file.getAbsoluteFile()))); + callback.accept(event.getResultMessage());
+ if (event.getResultMessage() != null) + else
+ callback.accept(event.getResultMessage()); callback.accept(Component.translatable("screenshot.success", component));
+ else } catch (Exception e) {
callback.accept(Component.translatable("screenshot.success", component)); LOGGER.warn("Couldn't save screenshot", e);
} catch (Throwable var7) {
if (image != null) {
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/data/models/ItemModelGenerators.java --- a/net/minecraft/client/data/models/ItemModelGenerators.java
+++ b/net/minecraft/client/data/models/ItemModelGenerators.java +++ b/net/minecraft/client/data/models/ItemModelGenerators.java
@@ -909,6 +_,9 @@ @@ -868,6 +_,9 @@
this.declareCustomModelItem(Items.COD); this.declareCustomModelItem(Items.COD);
this.declareCustomModelItem(Items.FEATHER); this.declareCustomModelItem(Items.FEATHER);
this.declareCustomModelItem(Items.LEAD); this.declareCustomModelItem(Items.LEAD);
@@ -100,8 +100,8 @@
ClientItem donorInfo = this.itemInfos.get(donor); ClientItem donorInfo = this.itemInfos.get(donor);
if (donorInfo == null) { if (donorInfo == null) {
@@ -131,8 +_,8 @@ @@ -131,8 +_,8 @@
this.register(acceptor, donorInfo);
} this.register(acceptor, donorInfo);
}); });
- List<Identifier> missingDefinitions = BuiltInRegistries.ITEM - List<Identifier> missingDefinitions = BuiltInRegistries.ITEM
- .listElements() - .listElements()
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/Font.java --- a/net/minecraft/client/gui/Font.java
+++ b/net/minecraft/client/gui/Font.java +++ b/net/minecraft/client/gui/Font.java
@@ -33,7 +_,7 @@ @@ -28,7 +_,7 @@
import org.jspecify.annotations.Nullable; import org.jspecify.annotations.Nullable;
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
@@ -1,116 +1,75 @@
--- a/net/minecraft/client/gui/Gui.java --- a/net/minecraft/client/gui/Gui.java
+++ b/net/minecraft/client/gui/Gui.java +++ b/net/minecraft/client/gui/Gui.java
@@ -150,7 +_,7 @@ @@ -64,7 +_,7 @@
public float vignetteBrightness = 1.0F; import org.slf4j.Logger;
private int toolHighlightTimer;
private ItemStack lastToolHighlight = ItemStack.EMPTY;
- private final DebugScreenOverlay debugOverlay;
+ protected DebugScreenOverlay debugOverlay;
private final SubtitleOverlay subtitleOverlay;
private final SpectatorGui spectatorGui;
private final PlayerTabOverlay tabList;
@@ -192,6 +_,7 @@
() -> new JumpableVehicleBarRenderer(minecraft)
);
this.resetTitleTimes();
+ net.minecraftforge.client.gui.overlay.ForgeLayeredDraw.init(this, minecraft);
}
public void resetTitleTimes() { @OnlyIn(Dist.CLIENT)
@@ -202,6 +_,10 @@ -public class Gui {
+public class Gui extends net.minecraftforge.client.gui.overlay.ForgeLayerInstance {
private static final Logger LOGGER = LogUtils.getLogger();
private static final Component SOCIAL_INTERACTIONS_NOT_AVAILABLE = Component.translatable("multiplayer.socialInteractions.not_available");
public static final Component SAVING_LEVEL = Component.translatable("menu.savingLevel");
@@ -80,6 +_,7 @@
private @Nullable TutorialToast socialInteractionsToast;
public void extractRenderState(final GuiGraphicsExtractor graphics, final DeltaTracker deltaTracker) { public Gui(final Minecraft minecraft, final Hud hud, final GuiRenderState guiRenderState) {
if (!(this.minecraft.screen instanceof LevelLoadingScreen)) { + super(minecraft);
+ if (Boolean.valueOf(true)) { this.minecraft = minecraft;
+ net.minecraftforge.client.gui.overlay.ForgeLayeredDraw.extractRenderState(graphics, deltaTracker); this.hud = hud;
+ return; this.splashManager = new SplashManager(minecraft.getUser());
+ } @@ -175,7 +_,7 @@
if (!this.minecraft.options.hideGui) { profiler.push("screen");
this.extractCameraOverlays(graphics, deltaTracker);
this.extractCrosshair(graphics, deltaTracker); try {
@@ -385,7 +_,7 @@ - this.screen.extractRenderStateWithTooltipAndSubtitles(graphics, xMouse, yMouse, deltaTracker.getGameTimeDeltaTicks());
int mouseX = Mth.floor(this.minecraft.mouseHandler.getScaledXPos(window)); + drawScreen(graphics, xMouse, yMouse, deltaTracker.getRealtimeDeltaTicks());
int mouseY = Mth.floor(this.minecraft.mouseHandler.getScaledYPos(window)); } catch (Throwable t) {
graphics.nextStratum(); CrashReport report = CrashReport.forThrowable(t, "Rendering screen");
- this.chat.extractRenderState(graphics, this.getFont(), this.tickCount, mouseX, mouseY, ChatComponent.DisplayMode.BACKGROUND, false); CrashReportCategory category = report.addCategory("Screen render details");
+ net.minecraftforge.client.ForgeHooksClient.onCustomizeChatEvent(graphics, this.chat, window, mouseX, mouseY, this.tickCount, this.getFont()); @@ -224,12 +_,6 @@
LOGGER.error("setScreen called from non-game thread");
} }
}
@@ -478,6 +_,8 @@ - if (this.screen != null) {
- this.screen.removed();
for (MobEffectInstance instance : Ordering.natural().reverse().sortedCopy(activeEffects)) { - } else {
Holder<MobEffect> effect = instance.getEffect(); - this.minecraft.setLastInputType(InputType.NONE);
+ var renderer = net.minecraftforge.client.extensions.common.IClientMobEffectExtensions.of(instance); - }
+ if (!renderer.isVisibleInGui(instance)) continue; -
if (instance.showIcon()) { if (screen == null) {
int x = graphics.guiWidth(); if (this.clientLevelTeardownInProgress) {
int y = 1; throw new IllegalStateException("Trying to return to in-game GUI during disconnection");
@@ -508,6 +_,7 @@ @@ -248,6 +_,22 @@
}
}
+ if (renderer.extractGuiIcon(instance, this, graphics, x, y, 0, alpha)) continue;
graphics.blitSprite(RenderPipelines.GUI_TEXTURED, getMobEffectSprite(effect), x + 3, y + 3, 18, 18, ARGB.white(alpha));
}
} }
@@ -610,15 +_,37 @@ }
}
public void extractSelectedItemName(final GuiGraphicsExtractor graphics) { + clearLayers();
+ renderSelectedItemName(graphics, 0); + Screen old = this.screen;
+ } + if (screen != null) {
+ + var event = net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenOpening(old, screen);
+ // Forge: Maintain vanilla parity during FLD#BACKGROUND + if (event == null) return;
+ public final void updateContextualInfo(final GuiGraphicsExtractor graphics, DeltaTracker deltaTracker) { + screen = event;
+ Gui.ContextualInfo nextContextualInfo = this.nextContextualInfoState();
+ if (nextContextualInfo != this.contextualInfoBar.getKey()) {
+ this.contextualInfoBar = Pair.of(nextContextualInfo, this.contextualInfoBarRenderers.get(nextContextualInfo).get());
+ } + }
+ +
+ this.contextualInfoBar.getValue().extractBackground(graphics, deltaTracker); + if (screen != old) {
+ } + if (old != null) {
+ // Forge: Same as above but for FLD#CONTEXTUAL_INFO + net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenClose(old);
+ public final void extractContextualInfoState(final GuiGraphicsExtractor graphics, DeltaTracker deltaTracker) { + old.removed();
+ this.contextualInfoBar.getValue().extractRenderState(graphics, deltaTracker); + } else {
+ this.minecraft.setLastInputType(InputType.NONE);
+ }
+ }
this.screen = screen;
if (this.screen != null) {
this.screen.added();
@@ -465,5 +_,10 @@
}
)
);
+ } + }
+ +
+ public void renderSelectedItemName(final GuiGraphicsExtractor graphics, int yShift) { + @Override
if (this.toolHighlightTimer > 0 && !this.lastToolHighlight.isEmpty()) { + protected void setScreenInternal(Screen value) {
MutableComponent str = Component.empty().append(this.lastToolHighlight.getHoverName()).withStyle(this.lastToolHighlight.getRarity().color()); + this.screen = value;
if (this.lastToolHighlight.has(DataComponents.CUSTOM_NAME)) {
str.withStyle(ChatFormatting.ITALIC);
}
- int strWidth = this.getFont().width(str);
+ Component highlightTip = this.lastToolHighlight.getHighlightTip(str);
+ Font font = net.minecraftforge.client.extensions.common.IClientItemExtensions.of(lastToolHighlight).getFont(lastToolHighlight, net.minecraftforge.client.extensions.common.IClientItemExtensions.FontContext.SELECTED_ITEM_NAME);
+ if (font == null)
+ font = this.getFont();
+ int strWidth = font.width(highlightTip);
int x = (graphics.guiWidth() - strWidth) / 2;
- int y = graphics.guiHeight() - 59;
+ int y = graphics.guiHeight() - Math.max(yShift, 59);
if (!this.minecraft.gameMode.canHurtPlayer()) {
y += 14;
}
@@ -629,7 +_,7 @@
}
if (alpha > 0) {
- graphics.textWithBackdrop(this.getFont(), str, x, y, strWidth, ARGB.white(alpha));
+ graphics.textWithBackdrop(font, highlightTip, x, y, strWidth, ARGB.white(alpha));
}
}
} }
@@ -1195,7 +_,9 @@ }
this.toolHighlightTimer = 0;
} else if (this.lastToolHighlight.isEmpty()
|| !selected.is(this.lastToolHighlight.getItem())
- || !selected.getHoverName().equals(this.lastToolHighlight.getHoverName())) {
+ || !selected.getHoverName().equals(this.lastToolHighlight.getHoverName())
+ || !selected.getHighlightTip(selected.getHoverName()).equals(lastToolHighlight.getHighlightTip(lastToolHighlight.getHoverName()))
+ ) {
this.toolHighlightTimer = (int)(40.0 * this.minecraft.options.notificationDisplayTime().get());
} else if (this.toolHighlightTimer > 0) {
this.toolHighlightTimer--;
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/GuiGraphicsExtractor.java --- a/net/minecraft/client/gui/GuiGraphicsExtractor.java
+++ b/net/minecraft/client/gui/GuiGraphicsExtractor.java +++ b/net/minecraft/client/gui/GuiGraphicsExtractor.java
@@ -88,7 +_,7 @@ @@ -85,7 +_,7 @@
import org.jspecify.annotations.Nullable; import org.jspecify.annotations.Nullable;
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
@@ -9,15 +9,15 @@
private static final int EXTRA_SPACE_AFTER_FIRST_TOOLTIP_LINE = 2; private static final int EXTRA_SPACE_AFTER_FIRST_TOOLTIP_LINE = 2;
private final Minecraft minecraft; private final Minecraft minecraft;
private final Matrix3x2fStack pose; private final Matrix3x2fStack pose;
@@ -914,6 +_,7 @@ @@ -912,6 +_,7 @@
CrashReport report = CrashReport.forThrowable(var11, "Rendering item"); CrashReport report = CrashReport.forThrowable(t, "Rendering item");
CrashReportCategory category = report.addCategory("Item being rendered"); CrashReportCategory category = report.addCategory("Item being rendered");
category.setDetail("Item Type", () -> String.valueOf(itemStack.getItem())); category.setDetail("Item Type", () -> String.valueOf(itemStack.getItem()));
+ category.setDetail("Registry Name", () -> String.valueOf(net.minecraftforge.registries.ForgeRegistries.ITEMS.getKey(itemStack.getItem()))); + category.setDetail("Registry Name", () -> String.valueOf(net.minecraftforge.registries.ForgeRegistries.ITEMS.getKey(itemStack.getItem())));
category.setDetail("Item Components", () -> String.valueOf(itemStack.getComponents())); category.setDetail("Item Components", () -> String.valueOf(itemStack.getComponents()));
category.setDetail("Item Foil", () -> String.valueOf(itemStack.hasFoil())); category.setDetail("Item Foil", () -> String.valueOf(itemStack.hasFoil()));
throw new ReportedException(report); throw new ReportedException(report);
@@ -940,6 +_,7 @@ @@ -938,6 +_,7 @@
this.itemCooldown(itemStack, x, y); this.itemCooldown(itemStack, x, y);
this.itemCount(font, itemStack, x, y, countText); this.itemCount(font, itemStack, x, y, countText);
this.pose.popMatrix(); this.pose.popMatrix();
@@ -25,7 +25,7 @@
} }
} }
@@ -1112,16 +_,25 @@ @@ -1106,16 +_,25 @@
this.setTooltipForNextFrame(this.minecraft.font, formattedCharSequences, DefaultTooltipPositioner.INSTANCE, x, y, false); this.setTooltipForNextFrame(this.minecraft.font, formattedCharSequences, DefaultTooltipPositioner.INSTANCE, x, y, false);
} }
@@ -51,7 +51,7 @@
public void setTooltipForNextFrame( public void setTooltipForNextFrame(
final Font font, final Font font,
final List<Component> texts, final List<Component> texts,
@@ -1130,11 +_,7 @@ @@ -1124,11 +_,7 @@
final int yo, final int yo,
final @Nullable Identifier style final @Nullable Identifier style
) { ) {
@@ -64,7 +64,7 @@
this.setTooltipForNextFrameInternal(font, components, xo, yo, DefaultTooltipPositioner.INSTANCE, style, false); this.setTooltipForNextFrameInternal(font, components, xo, yo, DefaultTooltipPositioner.INSTANCE, style, false);
} }
@@ -1162,7 +_,22 @@ @@ -1156,7 +_,22 @@
} }
public void setComponentTooltipForNextFrame(final Font font, final List<Component> lines, final int xo, final int yo) { public void setComponentTooltipForNextFrame(final Font font, final List<Component> lines, final int xo, final int yo) {
@@ -88,7 +88,7 @@
} }
public void setComponentTooltipForNextFrame(final Font font, final List<Component> lines, final int xo, final int yo, final @Nullable Identifier style) { public void setComponentTooltipForNextFrame(final Font font, final List<Component> lines, final int xo, final int yo, final @Nullable Identifier style) {
@@ -1213,10 +_,16 @@ @@ -1207,10 +_,16 @@
) { ) {
if (!lines.isEmpty()) { if (!lines.isEmpty()) {
if (this.deferredTooltip == null || replaceExisting) { if (this.deferredTooltip == null || replaceExisting) {
@@ -106,7 +106,7 @@
public void tooltip( public void tooltip(
final Font font, final Font font,
@@ -1224,13 +_,16 @@ @@ -1218,13 +_,16 @@
final int xo, final int xo,
final int yo, final int yo,
final ClientTooltipPositioner positioner, final ClientTooltipPositioner positioner,
@@ -125,17 +125,17 @@
if (lineWidth > textWidth) { if (lineWidth > textWidth) {
textWidth = lineWidth; textWidth = lineWidth;
} }
@@ -1240,25 +_,25 @@ @@ -1234,25 +_,25 @@
int w = textWidth; int w = textWidth;
int h = tempHeight; int h = tempHeight;
- Vector2ic positionedTooltip = positioner.positionTooltip(this.guiWidth(), this.guiHeight(), xo, yo, textWidth, tempHeight); - Vector2ic positionedTooltip = positioner.positionTooltip(this.guiWidth(), this.guiHeight(), xo, yo, w, h);
+ Vector2ic positionedTooltip = positioner.positionTooltip(this.guiWidth(), this.guiHeight(), preEvent.getX(), preEvent.getY(), textWidth, tempHeight); + Vector2ic positionedTooltip = positioner.positionTooltip(this.guiWidth(), this.guiHeight(), preEvent.getX(), preEvent.getY(), w, h);
int x = positionedTooltip.x(); int x = positionedTooltip.x();
int y = positionedTooltip.y(); int y = positionedTooltip.y();
this.pose.pushMatrix(); this.pose.pushMatrix();
- TooltipRenderUtil.extractTooltipBackground(this, x, y, textWidth, tempHeight, style); - TooltipRenderUtil.extractTooltipBackground(this, x, y, w, h, style);
+ TooltipRenderUtil.extractTooltipBackground(this, x, y, textWidth, tempHeight, preEvent.getBackground()); + TooltipRenderUtil.extractTooltipBackground(this, x, y, w, h, preEvent.getBackground());
int localY = y; int localY = y;
for (int i = 0; i < lines.size(); i++) { for (int i = 0; i < lines.size(); i++) {
@@ -157,7 +157,7 @@
} }
this.pose.popMatrix(); this.pose.popMatrix();
@@ -1333,6 +_,14 @@ @@ -1326,6 +_,14 @@
private ActiveTextCollector.Parameters createDefaultTextParameters(final float opacity) { private ActiveTextCollector.Parameters createDefaultTextParameters(final float opacity) {
return new ActiveTextCollector.Parameters(new Matrix3x2f(this.pose), opacity, this.scissorStack.peek()); return new ActiveTextCollector.Parameters(new Matrix3x2f(this.pose), opacity, this.scissorStack.peek());
@@ -0,0 +1,116 @@
--- a/net/minecraft/client/gui/Hud.java
+++ b/net/minecraft/client/gui/Hud.java
@@ -156,7 +_,7 @@
public float vignetteBrightness = 1.0F;
private int toolHighlightTimer;
private ItemStack lastToolHighlight = ItemStack.EMPTY;
- private final DebugScreenOverlay debugOverlay;
+ protected DebugScreenOverlay debugOverlay;
private final SubtitleOverlay subtitleOverlay;
private final SpectatorGui spectatorGui;
private final PlayerTabOverlay tabList;
@@ -198,6 +_,7 @@
() -> new JumpableVehicleBar(minecraft)
);
this.resetTitleTimes();
+ net.minecraftforge.client.gui.overlay.ForgeLayeredDraw.init(this, minecraft);
}
public void registerReloadListeners(final ReloadableResourceManager resourceManager) {
@@ -221,6 +_,10 @@
public void extractRenderState(final GuiGraphicsExtractor graphics, final DeltaTracker deltaTracker) {
this.minecraft.gameRenderer.gameRenderState().guiRenderState.isHudHidden = this.isHidden;
if (!(this.minecraft.gui.screen() instanceof LevelLoadingScreen)) {
+ if (Boolean.valueOf(true)) {
+ net.minecraftforge.client.gui.overlay.ForgeLayeredDraw.extractRenderState(graphics, deltaTracker);
+ return;
+ }
if (!this.isHidden) {
this.extractCameraOverlays(graphics, deltaTracker);
this.extractCrosshair(graphics, deltaTracker);
@@ -404,7 +_,7 @@
int mouseX = Mth.floor(this.minecraft.mouseHandler.getScaledXPos(window));
int mouseY = Mth.floor(this.minecraft.mouseHandler.getScaledYPos(window));
graphics.nextStratum();
- this.chat.extractRenderState(graphics, this.getFont(), this.tickCount, mouseX, mouseY, ChatComponent.DisplayMode.BACKGROUND, false);
+ net.minecraftforge.client.ForgeHooksClient.onCustomizeChatEvent(graphics, this.chat, window, mouseX, mouseY, this.tickCount, this.getFont());
}
}
@@ -497,6 +_,8 @@
for (MobEffectInstance instance : Ordering.natural().reverse().sortedCopy(activeEffects)) {
Holder<MobEffect> effect = instance.getEffect();
+ var renderer = net.minecraftforge.client.extensions.common.IClientMobEffectExtensions.of(instance);
+ if (!renderer.isVisibleInGui(instance)) continue;
if (instance.showIcon()) {
int x = graphics.guiWidth();
int y = 1;
@@ -527,6 +_,7 @@
}
}
+ if (renderer.extractGuiIcon(instance, this, graphics, x, y, 0, alpha)) continue;
graphics.blitSprite(RenderPipelines.GUI_TEXTURED, getMobEffectSprite(effect), x + 3, y + 3, 18, 18, ARGB.white(alpha));
}
}
@@ -629,15 +_,37 @@
}
public void extractSelectedItemName(final GuiGraphicsExtractor graphics) {
+ renderSelectedItemName(graphics, 0);
+ }
+
+ // Forge: Maintain vanilla parity during FLD#BACKGROUND
+ public final void updateContextualInfo(final GuiGraphicsExtractor graphics, DeltaTracker deltaTracker) {
+ var nextContextualInfo = this.nextContextualInfoState();
+ if (nextContextualInfo != this.contextualInfoBar.getFirst()) {
+ this.contextualInfoBar = Pair.of(nextContextualInfo, this.contextualInfoBars.get(nextContextualInfo).get());
+ }
+
+ this.contextualInfoBar.getSecond().extractBackground(graphics, deltaTracker);
+ }
+ // Forge: Same as above but for FLD#CONTEXTUAL_INFO
+ public final void extractContextualInfoState(final GuiGraphicsExtractor graphics, DeltaTracker deltaTracker) {
+ this.contextualInfoBar.getSecond().extractRenderState(graphics, deltaTracker);
+ }
+
+ public void renderSelectedItemName(final GuiGraphicsExtractor graphics, int yShift) {
if (this.toolHighlightTimer > 0 && !this.lastToolHighlight.isEmpty()) {
MutableComponent str = Component.empty().append(this.lastToolHighlight.getHoverName()).withStyle(this.lastToolHighlight.getRarity().color());
if (this.lastToolHighlight.has(DataComponents.CUSTOM_NAME)) {
str.withStyle(ChatFormatting.ITALIC);
}
- int strWidth = this.getFont().width(str);
+ Component highlightTip = this.lastToolHighlight.getHighlightTip(str);
+ Font font = net.minecraftforge.client.extensions.common.IClientItemExtensions.of(lastToolHighlight).getFont(lastToolHighlight, net.minecraftforge.client.extensions.common.IClientItemExtensions.FontContext.SELECTED_ITEM_NAME);
+ if (font == null)
+ font = this.getFont();
+ int strWidth = font.width(highlightTip);
int x = (graphics.guiWidth() - strWidth) / 2;
- int y = graphics.guiHeight() - 59;
+ int y = graphics.guiHeight() - Math.max(yShift, 59);
if (!this.minecraft.gameMode.canHurtPlayer()) {
y += 14;
}
@@ -648,7 +_,7 @@
}
if (alpha > 0) {
- graphics.textWithBackdrop(this.getFont(), str, x, y, strWidth, ARGB.white(alpha));
+ graphics.textWithBackdrop(font, highlightTip, x, y, strWidth, ARGB.white(alpha));
}
}
}
@@ -1216,7 +_,9 @@
this.toolHighlightTimer = 0;
} else if (this.lastToolHighlight.isEmpty()
|| !selected.is(this.lastToolHighlight.getItem())
- || !selected.getHoverName().equals(this.lastToolHighlight.getHoverName())) {
+ || !selected.getHoverName().equals(this.lastToolHighlight.getHoverName())
+ || !selected.getHighlightTip(selected.getHoverName()).equals(lastToolHighlight.getHighlightTip(lastToolHighlight.getHoverName()))
+ ) {
this.toolHighlightTimer = (int)(40.0 * this.minecraft.options.notificationDisplayTime().get());
} else if (this.toolHighlightTimer > 0) {
this.toolHighlightTimer--;
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/components/AbstractWidget.java --- a/net/minecraft/client/gui/components/AbstractWidget.java
+++ b/net/minecraft/client/gui/components/AbstractWidget.java +++ b/net/minecraft/client/gui/components/AbstractWidget.java
@@ -221,6 +_,23 @@ @@ -225,6 +_,23 @@
this.focused = focused; this.focused = focused;
} }
@@ -1,16 +1,16 @@
--- a/net/minecraft/client/gui/components/BossHealthOverlay.java --- a/net/minecraft/client/gui/components/BossHealthOverlay.java
+++ b/net/minecraft/client/gui/components/BossHealthOverlay.java +++ b/net/minecraft/client/gui/components/BossHealthOverlay.java
@@ -68,13 +_,16 @@ @@ -68,13 +_,16 @@
for (LerpingBossEvent event : this.events.values()) { for (LerpingBossEvent event : this.events.values()) {
int xLeft = screenWidth / 2 - 91; int xLeft = screenWidth / 2 - 91;
int yo = yOffset;
+ var progressEvent = net.minecraftforge.client.ForgeHooksClient.onCustomizeBossEventProgress(graphics, this.minecraft.getWindow(), event, xLeft, yOffset, 10 + this.minecraft.font.lineHeight); + var progressEvent = net.minecraftforge.client.ForgeHooksClient.onCustomizeBossEventProgress(graphics, this.minecraft.getWindow(), event, xLeft, yOffset, 10 + this.minecraft.font.lineHeight);
+ if (progressEvent != null) { + if (progressEvent != null) {
this.extractBar(graphics, xLeft, yOffset, event); this.extractBar(graphics, xLeft, yo, event);
Component msg = event.getName(); Component msg = event.getName();
int width = this.minecraft.font.width(msg); int width = this.minecraft.font.width(msg);
int x = screenWidth / 2 - width / 2; int x = screenWidth / 2 - width / 2;
int y = yOffset - 9; int y = yo - 9;
graphics.text(this.minecraft.font, msg, x, y, -1); graphics.text(this.minecraft.font, msg, x, y, -1);
- yOffset += 10 + 9; - yOffset += 10 + 9;
+ } + }
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/components/toasts/ToastManager.java --- a/net/minecraft/client/gui/components/toasts/ToastManager.java
+++ b/net/minecraft/client/gui/components/toasts/ToastManager.java +++ b/net/minecraft/client/gui/components/toasts/ToastManager.java
@@ -143,6 +_,7 @@ @@ -142,6 +_,7 @@
} }
public void addToast(final Toast toast) { public void addToast(final Toast toast) {
@@ -1,10 +1,10 @@
--- a/net/minecraft/client/gui/render/GuiRenderer.java --- a/net/minecraft/client/gui/render/GuiRenderer.java
+++ b/net/minecraft/client/gui/render/GuiRenderer.java +++ b/net/minecraft/client/gui/render/GuiRenderer.java
@@ -130,6 +_,7 @@ @@ -110,6 +_,7 @@
builder.put((Class<? extends PictureInPictureRenderState>)pictureInPictureRenderer.getRenderStateClass(), pictureInPictureRenderer); builder.put((Class<? extends PictureInPictureRenderState>)pictureInPictureRenderer.getRenderStateClass(), pictureInPictureRenderer);
} }
+ net.minecraftforge.client.ForgeHooksClient.onRegisterPictureInPictureRenderers(pictureInPictureRenderers, bufferSource, builder); + net.minecraftforge.client.ForgeHooksClient.onRegisterPictureInPictureRenderers(pictureInPictureRenderers, builder);
this.pictureInPictureRenderers = builder.buildOrThrow(); this.pictureInPictureRenderers = builder.buildOrThrow();
} }
@@ -1,10 +1,10 @@
--- a/net/minecraft/client/gui/screens/ChatScreen.java --- a/net/minecraft/client/gui/screens/ChatScreen.java
+++ b/net/minecraft/client/gui/screens/ChatScreen.java +++ b/net/minecraft/client/gui/screens/ChatScreen.java
@@ -139,6 +_,7 @@ @@ -141,6 +_,7 @@
this.handleChatInput(this.input.getValue(), true); this.handleChatInput(this.input.getValue(), true);
if (this.closeOnSubmit) { if (this.closeOnSubmit) {
this.exitReason = ChatScreen.ExitReason.DONE; this.exitReason = ChatScreen.ExitReason.DONE;
+ if (this.minecraft.screen == this) // FORGE: Prevent closing the screen if another screen has been opened. + if (this.minecraft.gui.screen() == this) // FORGE: Prevent closing the screen if another screen has been opened.
this.minecraft.setScreen(null); this.minecraft.gui.setScreen(null);
} else { } else {
this.input.setValue(""); this.input.setValue("");
@@ -1,11 +1,11 @@
--- a/net/minecraft/client/gui/screens/ConnectScreen.java --- a/net/minecraft/client/gui/screens/ConnectScreen.java
+++ b/net/minecraft/client/gui/screens/ConnectScreen.java +++ b/net/minecraft/client/gui/screens/ConnectScreen.java
@@ -114,6 +_,8 @@ @@ -109,6 +_,8 @@
} }
if (resolvedAddress.isEmpty()) { if (resolvedAddress.isEmpty()) {
+ ConnectScreen.LOGGER.error("Couldn't connect to server: Unknown host \"{}\"", hostAndPort.getHost()); + ConnectScreen.LOGGER.error("Couldn't connect to server: Unknown host \"{}\"", hostAndPort.getHost());
+ net.minecraftforge.network.DualStackUtils.logInitialPreferences(); + net.minecraftforge.network.DualStackUtils.logInitialPreferences();
minecraft.execute( minecraft.execute(
() -> minecraft.setScreen( () -> minecraft.gui
new DisconnectedScreen(ConnectScreen.this.parent, ConnectScreen.this.connectFailedTitle, ConnectScreen.UNKNOWN_HOST_MESSAGE) .setScreen(
@@ -16,7 +16,7 @@
+ if (extractContentRenderState(graphics, logoAlpha)) { + if (extractContentRenderState(graphics, logoAlpha)) {
int contentX = (int)(graphics.guiWidth() * 0.5); int contentX = (int)(graphics.guiWidth() * 0.5);
int logoY = (int)(graphics.guiHeight() * 0.5); int logoY = (int)(graphics.guiHeight() * 0.5);
double logoHeight = Math.min(graphics.guiWidth() * 0.75, (double)graphics.guiHeight()) * 0.25; double logoHeight = Math.min(graphics.guiWidth() * 0.75, graphics.guiHeight()) * 0.25;
@@ -148,6 +_,7 @@ @@ -148,6 +_,7 @@
graphics, width / 2 - logoWidthHalf, barY - 5, width / 2 + logoWidthHalf, barY + 5, 1.0F - Mth.clamp(fadeOutAnim, 0.0F, 1.0F) graphics, width / 2 - logoWidthHalf, barY - 5, width / 2 + logoWidthHalf, barY + 5, 1.0F - Mth.clamp(fadeOutAnim, 0.0F, 1.0F)
); );
@@ -24,7 +24,7 @@
+ } + }
if (fadeOutAnim >= 2.0F) { if (fadeOutAnim >= 2.0F) {
this.minecraft.setOverlay(null); this.minecraft.gui.setOverlay(null);
@@ -157,6 +_,7 @@ @@ -157,6 +_,7 @@
@Override @Override
public void tick() { public void tick() {
@@ -34,10 +34,10 @@
this.reload.checkExceptions(); this.reload.checkExceptions();
this.onFinish.accept(Optional.empty()); this.onFinish.accept(Optional.empty());
@@ -164,7 +_,6 @@ @@ -164,7 +_,6 @@
this.onFinish.accept(Optional.of(var2)); this.onFinish.accept(Optional.of(t));
} }
- this.fadeOutStart = Util.getMillis(); - this.fadeOutStart = Util.getMillis();
if (this.minecraft.screen != null) { if (this.minecraft.gui.screen() != null) {
Window window = this.minecraft.getWindow(); Window window = this.minecraft.getWindow();
this.minecraft.screen.init(window.getGuiScaledWidth(), window.getGuiScaledHeight()); this.minecraft.gui.screen().init(window.getGuiScaledWidth(), window.getGuiScaledHeight());
@@ -1,10 +1,10 @@
--- a/net/minecraft/client/gui/screens/PauseScreen.java --- a/net/minecraft/client/gui/screens/PauseScreen.java
+++ b/net/minecraft/client/gui/screens/PauseScreen.java +++ b/net/minecraft/client/gui/screens/PauseScreen.java
@@ -102,6 +_,7 @@ @@ -165,6 +_,7 @@
} else { Button.builder(OPTIONS, var1x -> this.minecraft.gui.setScreen(new OptionsScreen(this, this.minecraft.options, true))).width(204).build(), 2
helper.addChild(this.openScreenButton(PLAYER_REPORTING, () -> new SocialInteractionsScreen(this))); );
} }
+ helper.addChild(Button.builder(Component.translatable("fml.menu.mods"), button -> this.minecraft.setScreen(new net.minecraftforge.client.gui.ModListScreen(this))).width(BUTTON_WIDTH_FULL).build(), 2); + helper.addChild(Button.builder(Component.translatable("fml.menu.mods"), button -> this.minecraft.gui.setScreen(new net.minecraftforge.client.gui.ModListScreen(this))).width(BUTTON_WIDTH_FULL).build(), 2);
this.disconnectButton = helper.addChild( this.disconnectButton = helper.addChild(
Button.builder( Button.builder(
@@ -1,15 +1,15 @@
--- a/net/minecraft/client/gui/screens/Screen.java --- a/net/minecraft/client/gui/screens/Screen.java
+++ b/net/minecraft/client/gui/screens/Screen.java +++ b/net/minecraft/client/gui/screens/Screen.java
@@ -194,7 +_,7 @@ @@ -196,7 +_,7 @@
} }
public void onClose() { public void onClose() {
- this.minecraft.setScreen(null); - this.minecraft.gui.setScreen(null);
+ this.minecraft.popGuiLayer(); + this.minecraft.gui.popLayer();
} }
protected <T extends GuiEventListener & Renderable & NarratableEntry> T addRenderableWidget(final T widget) { protected <T extends GuiEventListener & Renderable & NarratableEntry> T addRenderableWidget(final T widget) {
@@ -326,8 +_,10 @@ @@ -327,8 +_,10 @@
this.width = width; this.width = width;
this.height = height; this.height = height;
if (!this.initialized) { if (!this.initialized) {
@@ -20,7 +20,7 @@
} else { } else {
this.repositionElements(); this.repositionElements();
} }
@@ -344,8 +_,10 @@ @@ -345,8 +_,10 @@
protected void rebuildWidgets() { protected void rebuildWidgets() {
this.clearWidgets(); this.clearWidgets();
this.clearFocus(); this.clearFocus();
@@ -31,16 +31,16 @@
} }
protected void fadeWidgets(final float widgetFade) { protected void fadeWidgets(final float widgetFade) {
@@ -385,6 +_,8 @@ @@ -386,6 +_,8 @@
this.extractMenuBackground(graphics); this.extractMenuBackground(graphics);
} }
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderScreenBackground(this, graphics); + net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderScreenBackground(this, graphics);
+ +
this.minecraft.gui.extractDeferredSubtitles(); this.minecraft.gui.hud.extractDeferredSubtitles();
} }
@@ -474,6 +_,19 @@ @@ -471,6 +_,19 @@
} }
public void onFilesDrop(final List<Path> files) { public void onFilesDrop(final List<Path> files) {
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/TitleScreen.java --- a/net/minecraft/client/gui/screens/TitleScreen.java
+++ b/net/minecraft/client/gui/screens/TitleScreen.java +++ b/net/minecraft/client/gui/screens/TitleScreen.java
@@ -53,6 +_,7 @@ @@ -57,6 +_,7 @@
private boolean fading; private boolean fading;
private long fadeInStart; private long fadeInStart;
private final LogoRenderer logoRenderer; private final LogoRenderer logoRenderer;
@@ -8,7 +8,7 @@
public TitleScreen() { public TitleScreen() {
this(false); this(false);
@@ -105,11 +_,15 @@ @@ -114,11 +_,15 @@
int copyrightX = this.width - copyrightWidth - 2; int copyrightX = this.width - copyrightWidth - 2;
int spacing = 24; int spacing = 24;
int topPos = this.height / 4 + 48; int topPos = this.height / 4 + 48;
@@ -17,23 +17,23 @@
topPos = this.createDemoMenuOptions(topPos, 24); topPos = this.createDemoMenuOptions(topPos, 24);
} else { } else {
topPos = this.createNormalMenuOptions(topPos, 24); topPos = this.createNormalMenuOptions(topPos, 24);
+ modButton = this.addRenderableWidget(Button.builder(Component.translatable("fml.menu.mods"), button -> this.minecraft.setScreen(new net.minecraftforge.client.gui.ModListScreen(this))) + modButton = this.addRenderableWidget(Button.builder(Component.translatable("fml.menu.mods"), button -> this.minecraft.gui.setScreen(new net.minecraftforge.client.gui.ModListScreen(this)))
+ .pos(this.width / 2 - 100, topPos).size(98, 20).build()); + .pos(this.width / 2 - 100, topPos).size(98, 20).build());
} }
+ modUpdateNotification = net.minecraftforge.client.gui.TitleScreenModUpdateIndicator.init(this, modButton); + modUpdateNotification = net.minecraftforge.client.gui.TitleScreenModUpdateIndicator.init(this, modButton);
topPos = this.createTestWorldButton(topPos, 24); int numberOfButtons = 3;
SpriteIconButton language = this.addRenderableWidget( int currentButton = 0;
@@ -182,7 +_,7 @@ @@ -199,7 +_,7 @@
}).bounds(this.width / 2 - 100, var6 = topPos + spacing, 200, 20).tooltip(tooltip).build()).active = multiplayerAllowed; }).bounds(this.width / 2 - 100, var7 = topPos + spacing, 200, 20).tooltip(tooltip).build()).active = multiplayerAllowed;
this.addRenderableWidget( this.addRenderableWidget(
Button.builder(Component.translatable("menu.online"), button -> this.minecraft.setScreen(new RealmsMainScreen(this))) Button.builder(Component.translatable("menu.online"), var1 -> this.minecraft.gui.setScreen(new RealmsMainScreen(this)))
- .bounds(this.width / 2 - 100, topPos = var6 + spacing, 200, 20) - .bounds(this.width / 2 - 100, topPos = var7 + spacing, 200, 20)
+ .bounds(this.width / 2 + 2, topPos = var6 + spacing, 98, 20) + .bounds(this.width / 2 + 2, topPos = var7 + spacing, 98, 20)
.tooltip(tooltip) .tooltip(tooltip)
.build() .build()
) )
@@ -310,9 +_,18 @@ @@ -323,9 +_,18 @@
versionString = versionString + I18n.get("menu.modded"); versionString = versionString + I18n.get("menu.modded");
} }
@@ -1,14 +1,14 @@
--- a/net/minecraft/client/gui/screens/advancements/AdvancementTab.java --- a/net/minecraft/client/gui/screens/advancements/AdvancementTab.java
+++ b/net/minecraft/client/gui/screens/advancements/AdvancementTab.java +++ b/net/minecraft/client/gui/screens/advancements/AdvancementTab.java
@@ -40,6 +_,7 @@ @@ -41,6 +_,7 @@
private int maxY = Integer.MIN_VALUE;
private float fade; private float fade;
private boolean centered; private boolean centered;
private @Nullable AdvancementWidget hovered;
+ private int page; + private int page;
public AdvancementTab( public AdvancementTab(
final Minecraft minecraft, final Minecraft minecraft,
@@ -61,6 +_,15 @@ @@ -62,6 +_,15 @@
this.addWidget(this.root, rootNode.holder()); this.addWidget(this.root, rootNode.holder());
} }
@@ -24,14 +24,14 @@
public AdvancementTabType getType() { public AdvancementTabType getType() {
return this.type; return this.type;
} }
@@ -155,8 +_,8 @@ @@ -169,8 +_,8 @@
return null; }
} else {
for (AdvancementTabType type : AdvancementTabType.values()) {
- if (index < type.getMax()) {
- return new AdvancementTab(minecraft, screen, type, index, root, display.get());
+ if ((index % AdvancementTabType.MAX_TABS) < type.getMax()) {
+ return new AdvancementTab(minecraft, screen, type, index % AdvancementTabType.MAX_TABS, index / AdvancementTabType.MAX_TABS, root, display.get());
}
index -= type.getMax(); for (AdvancementTabType type : AdvancementTabType.values()) {
- if (index < type.getMax()) {
- return new AdvancementTab(minecraft, screen, type, index, root, display.get());
+ if ((index % AdvancementTabType.MAX_TABS) < type.getMax()) {
+ return new AdvancementTab(minecraft, screen, type, index % AdvancementTabType.MAX_TABS, index / AdvancementTabType.MAX_TABS, root, display.get());
}
index -= type.getMax();
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java --- a/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java
+++ b/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java +++ b/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java
@@ -50,6 +_,7 @@ @@ -52,6 +_,7 @@
private final Map<AdvancementHolder, AdvancementTab> tabs = Maps.newLinkedHashMap(); private final Map<AdvancementHolder, AdvancementTab> tabs = Maps.newLinkedHashMap();
private @Nullable AdvancementTab selectedTab; private @Nullable AdvancementTab selectedTab;
private boolean isScrolling; private boolean isScrolling;
@@ -8,7 +8,7 @@
public AdvancementsScreen(final ClientAdvancements advancements) { public AdvancementsScreen(final ClientAdvancements advancements) {
this(advancements, null); this(advancements, null);
@@ -63,6 +_,19 @@ @@ -65,6 +_,19 @@
@Override @Override
protected void init() { protected void init() {
@@ -28,7 +28,7 @@
this.layout.addTitleHeader(TITLE, this.font); this.layout.addTitleHeader(TITLE, this.font);
this.tabs.clear(); this.tabs.clear();
this.selectedTab = null; this.selectedTab = null;
@@ -105,7 +_,7 @@ @@ -119,7 +_,7 @@
int yo = (this.height - 140) / 2; int yo = (this.height - 140) / 2;
for (AdvancementTab tab : this.tabs.values()) { for (AdvancementTab tab : this.tabs.values()) {
@@ -37,24 +37,24 @@
this.advancements.setSelectedTab(tab.getRootNode().holder(), true); this.advancements.setSelectedTab(tab.getRootNode().holder(), true);
break; break;
} }
@@ -196,10 +_,12 @@ @@ -208,10 +_,12 @@
graphics.blit(RenderPipelines.GUI_TEXTURED, WINDOW_LOCATION, xo, yo, 0.0F, 0.0F, 252, 140, 256, 256); graphics.blit(RenderPipelines.GUI_TEXTURED, WINDOW_LOCATION, this.leftPos, this.topPos, 0.0F, 0.0F, 252, 140, 256, 256);
if (this.tabs.size() > 1) { if (this.tabs.size() > 1) {
for (AdvancementTab tab : this.tabs.values()) { for (AdvancementTab tab : this.tabs.values()) {
+ if (tab.getPage() == tabPage) + if (tab.getPage() == tabPage)
tab.extractTab(graphics, xo, yo, mouseX, mouseY, tab == this.selectedTab); tab.extractTab(graphics, this.leftPos, this.topPos, mouseX, mouseY, tab == this.selectedTab);
} }
for (AdvancementTab tab : this.tabs.values()) { for (AdvancementTab tab : this.tabs.values()) {
+ if (tab.getPage() == tabPage) + if (tab.getPage() == tabPage)
tab.extractIcon(graphics, xo, yo); tab.extractIcon(graphics, this.leftPos, this.topPos);
} }
} }
@@ -218,6 +_,7 @@ @@ -230,6 +_,7 @@
if (this.tabs.size() > 1) { if (this.tabs.size() > 1) {
for (AdvancementTab tab : this.tabs.values()) { for (AdvancementTab tab : this.tabs.values()) {
+ if (tab.getPage() == tabPage) + if (tab.getPage() == tabPage)
if (tab.isMouseOver(xo, yo, mouseX, mouseY)) { if (tab.isMouseOver(this.leftPos, this.topPos, mouseX, mouseY)) {
graphics.setTooltipForNextFrame(this.font, tab.getTitle(), mouseX, mouseY); graphics.setTooltipForNextFrame(this.font, tab.getTitle(), mouseX, mouseY);
} }
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java --- a/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java
+++ b/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java +++ b/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java
@@ -111,6 +_,7 @@ @@ -98,6 +_,7 @@
int xo = this.leftPos; int xo = this.leftPos;
int yo = this.topPos; int yo = this.topPos;
super.extractRenderState(graphics, mouseX, mouseY, a); super.extractRenderState(graphics, mouseX, mouseY, a);
@@ -8,7 +8,7 @@
graphics.pose().pushMatrix(); graphics.pose().pushMatrix();
graphics.pose().translate(xo, yo); graphics.pose().translate(xo, yo);
this.extractLabels(graphics, mouseX, mouseY); this.extractLabels(graphics, mouseX, mouseY);
@@ -122,6 +_,7 @@ @@ -109,6 +_,7 @@
if (previouslyHoveredSlot != null && previouslyHoveredSlot != this.hoveredSlot) { if (previouslyHoveredSlot != null && previouslyHoveredSlot != this.hoveredSlot) {
this.onStopHovering(previouslyHoveredSlot); this.onStopHovering(previouslyHoveredSlot);
} }
@@ -16,7 +16,7 @@
graphics.pose().popMatrix(); graphics.pose().popMatrix();
} }
@@ -200,7 +_,7 @@ @@ -170,7 +_,7 @@
ItemStack item = this.hoveredSlot.getItem(); ItemStack item = this.hoveredSlot.getItem();
if (this.menu.getCarried().isEmpty() || this.showTooltipWithItemInHand(item)) { if (this.menu.getCarried().isEmpty() || this.showTooltipWithItemInHand(item)) {
graphics.setTooltipForNextFrame( graphics.setTooltipForNextFrame(
@@ -25,53 +25,53 @@
); );
} }
} }
@@ -216,7 +_,8 @@ @@ -186,7 +_,8 @@
private void extractFloatingItem(final GuiGraphicsExtractor graphics, final ItemStack carried, final int x, final int y, final @Nullable String itemCount) { private void extractFloatingItem(final GuiGraphicsExtractor graphics, final ItemStack carried, final int x, final int y, final @Nullable String itemCount) {
graphics.item(carried, x, y); graphics.item(carried, x, y);
- graphics.itemDecorations(this.font, carried, x, y - (this.draggingItem.isEmpty() ? 0 : 8), itemCount); - graphics.itemDecorations(this.font, carried, x, y, itemCount);
+ var font = net.minecraftforge.client.extensions.common.IClientItemExtensions.of(carried).getFont(carried, net.minecraftforge.client.extensions.common.IClientItemExtensions.FontContext.ITEM_COUNT); + var font = net.minecraftforge.client.extensions.common.IClientItemExtensions.of(carried).getFont(carried, net.minecraftforge.client.extensions.common.IClientItemExtensions.FontContext.ITEM_COUNT);
+ graphics.itemDecorations(font == null ? this.font : font, carried, x, y - (this.draggingItem.isEmpty() ? 0 : 8), itemCount); + graphics.itemDecorations(font == null ? this.font : font, carried, x, y, itemCount);
} }
protected void extractLabels(final GuiGraphicsExtractor graphics, final int xm, final int ym) { protected void extractLabels(final GuiGraphicsExtractor graphics, final int xm, final int ym) {
@@ -316,7 +_,8 @@ @@ -285,7 +_,8 @@
if (super.mouseClicked(event, doubleClick)) {
return true; return true;
} else { }
- boolean cloning = this.minecraft.options.keyPickItem.matchesMouse(event) && this.minecraft.player.hasInfiniteMaterials();
+ var mouseKey = com.mojang.blaze3d.platform.InputConstants.Type.MOUSE.getOrCreate(event.button()); - boolean cloning = this.minecraft.options.keyPickItem.matchesMouse(event) && this.minecraft.player.hasInfiniteMaterials();
+ boolean cloning = this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey) && this.minecraft.player.hasInfiniteMaterials(); + var mouseKey = com.mojang.blaze3d.platform.InputConstants.Type.MOUSE.getOrCreate(event.button());
Slot slot = this.getHoveredSlot(event.x(), event.y()); + boolean cloning = this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey) && this.minecraft.player.hasInfiniteMaterials();
this.doubleclick = this.lastClickSlot == slot && doubleClick; Slot slot = this.getHoveredSlot(event.x(), event.y());
this.skipNextRelease = false; this.doubleclick = this.lastClickSlot == slot && doubleClick;
@@ -326,6 +_,7 @@ this.skipNextRelease = false;
int xo = this.leftPos; @@ -295,6 +_,7 @@
int yo = this.topPos; int xo = this.leftPos;
boolean clickedOutside = this.hasClickedOutside(event.x(), event.y(), xo, yo); int yo = this.topPos;
+ if (slot != null) clickedOutside = false; // Forge, prevent dropping of items through slots outside of GUI boundaries boolean clickedOutside = this.hasClickedOutside(event.x(), event.y(), xo, yo);
int slotId = -1; + if (slot != null) clickedOutside = false; // Forge, prevent dropping of items through slots outside of GUI boundaries
if (slot != null) { int slotId = -1;
slotId = slot.index; if (slot != null) {
@@ -351,7 +_,7 @@ slotId = slot.index;
} @@ -306,7 +_,7 @@
} else if (!this.isQuickCrafting) {
if (this.menu.getCarried().isEmpty()) { if (slotId != -1 && !this.isQuickCrafting) {
- if (cloning) { if (this.menu.getCarried().isEmpty()) {
+ if (this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey)) { - if (cloning) {
this.slotClicked(slot, slotId, event.button(), ContainerInput.CLONE); + if (this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey)) {
} else { this.slotClicked(slot, slotId, event.button(), ContainerInput.CLONE);
boolean quickKey = slotId != -999 && event.hasShiftDown(); } else {
@@ -375,7 +_,7 @@ boolean quickKey = slotId != -999 && event.hasShiftDown();
this.quickCraftingType = 0; @@ -330,7 +_,7 @@
} else if (event.button() == 1) { this.quickCraftingType = 0;
this.quickCraftingType = 1; } else if (event.button() == 1) {
- } else if (cloning) { this.quickCraftingType = 1;
+ } else if (this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey)) { - } else if (cloning) {
this.quickCraftingType = 2; + } else if (this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey)) {
} this.quickCraftingType = 2;
} }
@@ -445,10 +_,13 @@ }
@@ -374,10 +_,13 @@
@Override @Override
public boolean mouseReleased(final MouseButtonEvent event) { public boolean mouseReleased(final MouseButtonEvent event) {
@@ -85,7 +85,7 @@
int slotId = -1; int slotId = -1;
if (slot != null) { if (slot != null) {
slotId = slot.index; slotId = slot.index;
@@ -465,7 +_,7 @@ @@ -394,7 +_,7 @@
if (target != null if (target != null
&& target.mayPickup(this.minecraft.player) && target.mayPickup(this.minecraft.player)
&& target.hasItem() && target.hasItem()
@@ -94,8 +94,8 @@
&& AbstractContainerMenu.canItemQuickReplace(target, this.lastQuickMoved, true)) { && AbstractContainerMenu.canItemQuickReplace(target, this.lastQuickMoved, true)) {
this.slotClicked(target, target.index, event.button(), ContainerInput.QUICK_MOVE); this.slotClicked(target, target.index, event.button(), ContainerInput.QUICK_MOVE);
} }
@@ -524,7 +_,7 @@ @@ -421,7 +_,7 @@
} else if (this.isQuickCrafting && !this.quickCraftSlots.isEmpty()) { if (this.isQuickCrafting && !this.quickCraftSlots.isEmpty()) {
this.quickCraftToSlots(); this.quickCraftToSlots();
} else if (!this.menu.getCarried().isEmpty()) { } else if (!this.menu.getCarried().isEmpty()) {
- if (this.minecraft.options.keyPickItem.matchesMouse(event)) { - if (this.minecraft.options.keyPickItem.matchesMouse(event)) {
@@ -103,16 +103,16 @@
this.slotClicked(slot, slotId, event.button(), ContainerInput.CLONE); this.slotClicked(slot, slotId, event.button(), ContainerInput.CLONE);
} else { } else {
boolean quickKey = slotId != -999 && event.hasShiftDown(); boolean quickKey = slotId != -999 && event.hasShiftDown();
@@ -595,7 +_,7 @@ @@ -489,7 +_,7 @@
public boolean keyPressed(final KeyEvent event) {
if (super.keyPressed(event)) {
return true; return true;
- } else if (this.minecraft.options.keyInventory.matches(event)) { }
+ } else if (this.minecraft.options.keyInventory.isActiveAndMatches(com.mojang.blaze3d.platform.InputConstants.getKey(event))) {
- if (this.minecraft.options.keyInventory.matches(event)) {
+ if (this.minecraft.options.keyInventory.isActiveAndMatches(com.mojang.blaze3d.platform.InputConstants.getKey(event))) {
this.onClose(); this.onClose();
return true; return true;
} else { }
@@ -693,6 +_,13 @@ @@ -587,4 +_,11 @@
super.onClose(); super.onClose();
} }
@@ -123,6 +123,4 @@
+ public int getGuiTop() { return topPos; } + public int getGuiTop() { return topPos; }
+ public int getXSize() { return imageWidth; } + public int getXSize() { return imageWidth; }
+ public int getYSize() { return imageHeight; } + public int getYSize() { return imageHeight; }
}
@OnlyIn(Dist.CLIENT)
private record SnapbackData(ItemStack item, Vector2i start, Vector2i end, long time) {
@@ -55,16 +55,16 @@
this.searchBox = new EditBox(this.font, this.leftPos + 82, this.topPos + 6, 80, 9, Component.translatable("itemGroup.search")); this.searchBox = new EditBox(this.font, this.leftPos + 82, this.topPos + 6, 80, 9, Component.translatable("itemGroup.search"));
this.searchBox.setMaxLength(50); this.searchBox.setMaxLength(50);
this.searchBox.setBordered(false); this.searchBox.setBordered(false);
@@ -377,7 +_,7 @@ @@ -379,7 +_,7 @@
public boolean charTyped(final CharacterEvent event) {
if (this.ignoreTextInput) {
return false; return false;
- } else if (selectedTab.getType() != CreativeModeTab.Type.SEARCH) { }
+ } else if (!selectedTab.hasSearchBar()) {
- if (selectedTab.getType() != CreativeModeTab.Type.SEARCH) {
+ if (!selectedTab.hasSearchBar()) {
return false; return false;
} else { }
String oldContents = this.searchBox.getValue();
@@ -405,7 +_,7 @@ @@ -407,7 +_,7 @@
@Override @Override
public boolean keyPressed(final KeyEvent event) { public boolean keyPressed(final KeyEvent event) {
this.ignoreTextInput = false; this.ignoreTextInput = false;
@@ -73,7 +73,7 @@
if (this.minecraft.options.keyChat.matches(event)) { if (this.minecraft.options.keyChat.matches(event)) {
this.ignoreTextInput = true; this.ignoreTextInput = true;
this.selectTab(CreativeModeTabs.searchTab()); this.selectTab(CreativeModeTabs.searchTab());
@@ -441,6 +_,7 @@ @@ -443,6 +_,7 @@
} }
private void refreshSearchResults() { private void refreshSearchResults() {
@@ -81,7 +81,7 @@
this.menu.items.clear(); this.menu.items.clear();
this.visibleTags.clear(); this.visibleTags.clear();
String searchTerm = this.searchBox.getValue(); String searchTerm = this.searchBox.getValue();
@@ -453,10 +_,10 @@ @@ -455,10 +_,10 @@
SearchTree<ItemStack> tree; SearchTree<ItemStack> tree;
if (searchTerm.startsWith("#")) { if (searchTerm.startsWith("#")) {
searchTerm = searchTerm.substring(1); searchTerm = searchTerm.substring(1);
@@ -94,7 +94,7 @@
} }
this.menu.items.addAll(tree.search(searchTerm.toLowerCase(Locale.ROOT))); this.menu.items.addAll(tree.search(searchTerm.toLowerCase(Locale.ROOT)));
@@ -484,7 +_,7 @@ @@ -486,7 +_,7 @@
@Override @Override
protected void extractLabels(final GuiGraphicsExtractor graphics, final int xm, final int ym) { protected void extractLabels(final GuiGraphicsExtractor graphics, final int xm, final int ym) {
if (selectedTab.showTitle()) { if (selectedTab.showTitle()) {
@@ -103,7 +103,7 @@
} }
} }
@@ -494,7 +_,7 @@ @@ -496,7 +_,7 @@
double xm = event.x() - this.leftPos; double xm = event.x() - this.leftPos;
double ym = event.y() - this.topPos; double ym = event.y() - this.topPos;
@@ -112,7 +112,7 @@
if (this.checkTabClicked(tab, xm, ym)) { if (this.checkTabClicked(tab, xm, ym)) {
return true; return true;
} }
@@ -516,7 +_,7 @@ @@ -518,7 +_,7 @@
double ym = event.y() - this.topPos; double ym = event.y() - this.topPos;
this.scrolling = false; this.scrolling = false;
@@ -121,7 +121,7 @@
if (this.checkTabClicked(tab, xm, ym)) { if (this.checkTabClicked(tab, xm, ym)) {
this.selectTab(tab); this.selectTab(tab);
return true; return true;
@@ -610,13 +_,15 @@ @@ -611,13 +_,15 @@
this.originalSlots = null; this.originalSlots = null;
} }
@@ -138,7 +138,7 @@
this.refreshSearchResults(); this.refreshSearchResults();
} else { } else {
@@ -679,7 +_,14 @@ @@ -682,7 +_,14 @@
this.effects.extractRenderState(graphics, mouseX, mouseY); this.effects.extractRenderState(graphics, mouseX, mouseY);
super.extractRenderState(graphics, mouseX, mouseY, a); super.extractRenderState(graphics, mouseX, mouseY, a);
@@ -154,7 +154,7 @@
if (this.checkTabHovering(graphics, tab, mouseX, mouseY)) { if (this.checkTabHovering(graphics, tab, mouseX, mouseY)) {
break; break;
} }
@@ -701,7 +_,7 @@ @@ -704,7 +_,7 @@
public List<Component> getTooltipFromContainerItem(final ItemStack itemStack) { public List<Component> getTooltipFromContainerItem(final ItemStack itemStack) {
boolean isCreativeSlot = this.hoveredSlot != null && this.hoveredSlot instanceof CreativeModeInventoryScreen.CustomCreativeSlot; boolean isCreativeSlot = this.hoveredSlot != null && this.hoveredSlot instanceof CreativeModeInventoryScreen.CustomCreativeSlot;
boolean isSingleCategoryTab = selectedTab.getType() == CreativeModeTab.Type.CATEGORY; boolean isSingleCategoryTab = selectedTab.getType() == CreativeModeTab.Type.CATEGORY;
@@ -163,16 +163,16 @@
TooltipFlag.Default originalTooltipStyle = this.minecraft.options.advancedItemTooltips ? TooltipFlag.Default.ADVANCED : TooltipFlag.Default.NORMAL; TooltipFlag.Default originalTooltipStyle = this.minecraft.options.advancedItemTooltips ? TooltipFlag.Default.ADVANCED : TooltipFlag.Default.NORMAL;
TooltipFlag tooltipStyle = isCreativeSlot ? originalTooltipStyle.asCreative() : originalTooltipStyle; TooltipFlag tooltipStyle = isCreativeSlot ? originalTooltipStyle.asCreative() : originalTooltipStyle;
List<Component> originalLines = itemStack.getTooltipLines(Item.TooltipContext.of(this.minecraft.level), this.minecraft.player, tooltipStyle); List<Component> originalLines = itemStack.getTooltipLines(Item.TooltipContext.of(this.minecraft.level), this.minecraft.player, tooltipStyle);
@@ -722,7 +_,7 @@ @@ -728,7 +_,7 @@
int i = 1; int i = 1;
for (CreativeModeTab tab : CreativeModeTabs.tabs()) { for (CreativeModeTab tab : CreativeModeTabs.tabs()) {
- if (tab.getType() != CreativeModeTab.Type.SEARCH && tab.contains(itemStack)) { - if (tab.getType() != CreativeModeTab.Type.SEARCH && tab.contains(itemStack)) {
+ if (!tab.hasSearchBar() && tab.contains(itemStack)) { + if (!tab.hasSearchBar() && tab.contains(itemStack)) {
linesToDisplay.add(i++, tab.getDisplayName().copy().withStyle(ChatFormatting.BLUE)); linesToDisplay.add(i++, tab.getDisplayName().copy().withStyle(ChatFormatting.BLUE));
}
} }
@@ -735,7 +_,7 @@ }
@@ -740,7 +_,7 @@
public void extractBackground(final GuiGraphicsExtractor graphics, final int mouseX, final int mouseY, final float a) { public void extractBackground(final GuiGraphicsExtractor graphics, final int mouseX, final int mouseY, final float a) {
super.extractBackground(graphics, mouseX, mouseY, a); super.extractBackground(graphics, mouseX, mouseY, a);
@@ -181,7 +181,7 @@
if (tab != selectedTab) { if (tab != selectedTab) {
this.extractTabButton(graphics, mouseX, mouseY, tab); this.extractTabButton(graphics, mouseX, mouseY, tab);
} }
@@ -770,6 +_,7 @@ @@ -775,6 +_,7 @@
graphics.blitSprite(RenderPipelines.GUI_TEXTURED, sprite, xscr, yscr + (int)((yscr2 - yscr - 17) * this.scrollOffs), 12, 15); graphics.blitSprite(RenderPipelines.GUI_TEXTURED, sprite, xscr, yscr + (int)((yscr2 - yscr - 17) * this.scrollOffs), 12, 15);
} }
@@ -189,7 +189,7 @@
this.extractTabButton(graphics, mouseX, mouseY, selectedTab); this.extractTabButton(graphics, mouseX, mouseY, selectedTab);
if (selectedTab.getType() == CreativeModeTab.Type.INVENTORY) { if (selectedTab.getType() == CreativeModeTab.Type.INVENTORY) {
InventoryScreen.extractEntityInInventoryFollowsMouse( InventoryScreen.extractEntityInInventoryFollowsMouse(
@@ -779,7 +_,7 @@ @@ -784,7 +_,7 @@
} }
private int getTabX(final CreativeModeTab tab) { private int getTabX(final CreativeModeTab tab) {
@@ -198,7 +198,7 @@
int spacing = 27; int spacing = 27;
int x = 27 * pos; int x = 27 * pos;
if (tab.isAlignedRight()) { if (tab.isAlignedRight()) {
@@ -791,7 +_,7 @@ @@ -796,7 +_,7 @@
private int getTabY(final CreativeModeTab tab) { private int getTabY(final CreativeModeTab tab) {
int y = 0; int y = 0;
@@ -207,7 +207,7 @@
y -= 32; y -= 32;
} else { } else {
y += this.imageHeight; y += this.imageHeight;
@@ -819,8 +_,8 @@ @@ -824,8 +_,8 @@
protected void extractTabButton(final GuiGraphicsExtractor graphics, final int mouseX, final int mouseY, final CreativeModeTab tab) { protected void extractTabButton(final GuiGraphicsExtractor graphics, final int mouseX, final int mouseY, final CreativeModeTab tab) {
boolean selected = tab == selectedTab; boolean selected = tab == selectedTab;
@@ -218,15 +218,7 @@
int x = this.leftPos + this.getTabX(tab); int x = this.leftPos + this.getTabX(tab);
int y = this.topPos - (isTop ? 28 : -(this.imageHeight - 4)); int y = this.topPos - (isTop ? 28 : -(this.imageHeight - 4));
Identifier[] sprites; Identifier[] sprites;
@@ -834,6 +_,7 @@ @@ -875,6 +_,14 @@
graphics.requestCursor(CursorTypes.POINTING_HAND);
}
+ com.mojang.blaze3d.opengl.GlStateManager._enableBlend(); //Forge: Make sure blend is enabled else tabs show a white border.
graphics.blitSprite(RenderPipelines.GUI_TEXTURED, sprites[Mth.clamp(pos, 0, sprites.length)], x, y, 26, 32);
int iconX = x + 13 - 8;
int iconY = y + 16 - 8 + (isTop ? 1 : -1);
@@ -870,6 +_,14 @@
} }
} }
@@ -241,7 +233,7 @@
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
private static class CustomCreativeSlot extends Slot { private static class CustomCreativeSlot extends Slot {
public CustomCreativeSlot(final Container container, final int slot, final int x, final int y) { public CustomCreativeSlot(final Container container, final int slot, final int x, final int y) {
@@ -1050,6 +_,22 @@ @@ -1055,6 +_,22 @@
@Override @Override
public boolean mayPickup(final Player player) { public boolean mayPickup(final Player player) {
return this.target.mayPickup(player); return this.target.mayPickup(player);
@@ -1,7 +1,7 @@
--- a/net/minecraft/client/gui/screens/inventory/HangingSignEditScreen.java --- a/net/minecraft/client/gui/screens/inventory/HangingSignEditScreen.java
+++ b/net/minecraft/client/gui/screens/inventory/HangingSignEditScreen.java +++ b/net/minecraft/client/gui/screens/inventory/HangingSignEditScreen.java
@@ -15,7 +_,7 @@ @@ -16,7 +_,7 @@
private static final Vector3f TEXT_SCALE = new Vector3f(1.0F, 1.0F, 1.0F); private static final Vector3fc TEXT_SCALE = new Vector3f(1.0F, 1.0F, 1.0F);
private static final int TEXTURE_WIDTH = 16; private static final int TEXTURE_WIDTH = 16;
private static final int TEXTURE_HEIGHT = 16; private static final int TEXTURE_HEIGHT = 16;
- private final Identifier texture = Identifier.withDefaultNamespace("textures/gui/hanging_signs/" + this.woodType.name() + ".png"); - private final Identifier texture = Identifier.withDefaultNamespace("textures/gui/hanging_signs/" + this.woodType.name() + ".png");
@@ -1,11 +1,11 @@
--- a/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java --- a/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java
+++ b/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java +++ b/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java
@@ -18,7 +_,7 @@ @@ -18,7 +_,7 @@
return (ClientTooltipComponent)(switch (component) { return switch (component) {
case BundleTooltip bundleTooltip -> new ClientBundleTooltip(bundleTooltip.contents()); case BundleTooltip bundleTooltip -> new ClientBundleTooltip(bundleTooltip.contents());
case ClientActivePlayersTooltip.ActivePlayersTooltip activePlayersTooltip -> new ClientActivePlayersTooltip(activePlayersTooltip); case ClientActivePlayersTooltip.ActivePlayersTooltip activePlayersTooltip -> new ClientActivePlayersTooltip(activePlayersTooltip);
- default -> throw new IllegalArgumentException("Unknown TooltipComponent"); - default -> throw new IllegalArgumentException("Unknown TooltipComponent");
+ default -> net.minecraftforge.client.gui.ClientTooltipComponentManager.createClientTooltipComponent(component); + default -> net.minecraftforge.client.gui.ClientTooltipComponentManager.createClientTooltipComponent(component);
}); };
} }
@@ -1,11 +1,11 @@
--- a/net/minecraft/client/gui/screens/multiplayer/ServerSelectionList.java --- a/net/minecraft/client/gui/screens/multiplayer/ServerSelectionList.java
+++ b/net/minecraft/client/gui/screens/multiplayer/ServerSelectionList.java +++ b/net/minecraft/client/gui/screens/multiplayer/ServerSelectionList.java
@@ -372,6 +_,8 @@ @@ -369,6 +_,8 @@
graphics.setTooltipForNextFrame(Lists.transform(this.onlinePlayersTooltip, Component::getVisualOrderText), mouseX, mouseY); graphics.setTooltipForNextFrame(Lists.transform(this.onlinePlayersTooltip, Component::getVisualOrderText), mouseX, mouseY);
} }
+ net.minecraftforge.client.ForgeHooksClient.drawForgePingInfo(this.screen, serverData, graphics, this.getContentX(), this.getContentY(), this.getContentWidth(), mouseX - this.getContentX(), mouseY - this.getContentY()); + net.minecraftforge.client.ForgeHooksClient.drawForgePingInfo(this.screen, serverData, graphics, this.getContentX(), this.getContentY(), this.getContentWidth(), mouseX - this.getContentX(), mouseY - this.getContentY());
+ +
if (this.minecraft.options.touchscreen().get() || hovered) { if (hovered) {
graphics.fill(this.getContentX(), this.getContentY(), this.getContentX() + 32, this.getContentY() + 32, -1601138544); graphics.fill(this.getContentX(), this.getContentY(), this.getContentX() + 32, this.getContentY() + 32, -1601138544);
int relX = mouseX - this.getContentX(); int relX = mouseX - this.getContentX();
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/options/controls/KeyBindsList.java --- a/net/minecraft/client/gui/screens/options/controls/KeyBindsList.java
+++ b/net/minecraft/client/gui/screens/options/controls/KeyBindsList.java +++ b/net/minecraft/client/gui/screens/options/controls/KeyBindsList.java
@@ -122,9 +_,10 @@ @@ -116,9 +_,10 @@
this.name = name; this.name = name;
this.changeButton = Button.builder(name, button -> { this.changeButton = Button.builder(name, button -> {
KeyBindsList.this.keyBindsScreen.selectedKey = key; KeyBindsList.this.keyBindsScreen.selectedKey = key;
@@ -12,7 +12,7 @@
.createNarration( .createNarration(
defaultNarrationSupplier -> key.isUnbound() defaultNarrationSupplier -> key.isUnbound()
? Component.translatable("narrator.controls.unbound", name) ? Component.translatable("narrator.controls.unbound", name)
@@ -132,7 +_,7 @@ @@ -126,7 +_,7 @@
) )
.build(); .build();
this.resetButton = Button.builder(RESET_BUTTON_TITLE, button -> { this.resetButton = Button.builder(RESET_BUTTON_TITLE, button -> {
@@ -21,7 +21,7 @@
KeyBindsList.this.resetMappingAndUpdateButtons(); KeyBindsList.this.resetMappingAndUpdateButtons();
}).bounds(0, 0, 50, 20).createNarration(defaultNarrationSupplier -> Component.translatable("narrator.controls.reset", name)).build(); }).bounds(0, 0, 50, 20).createNarration(defaultNarrationSupplier -> Component.translatable("narrator.controls.reset", name)).build();
this.refreshEntry(); this.refreshEntry();
@@ -173,7 +_,8 @@ @@ -167,7 +_,8 @@
MutableComponent tooltip = Component.empty(); MutableComponent tooltip = Component.empty();
if (!this.key.isUnbound()) { if (!this.key.isUnbound()) {
for (KeyMapping otherKey : KeyBindsList.this.minecraft.options.keyMappings) { for (KeyMapping otherKey : KeyBindsList.this.minecraft.options.keyMappings) {
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/packs/PackSelectionModel.java --- a/net/minecraft/client/gui/screens/packs/PackSelectionModel.java
+++ b/net/minecraft/client/gui/screens/packs/PackSelectionModel.java +++ b/net/minecraft/client/gui/screens/packs/PackSelectionModel.java
@@ -112,6 +_,10 @@ @@ -111,6 +_,10 @@
boolean canMoveUp(); boolean canMoveUp();
boolean canMoveDown(); boolean canMoveDown();
@@ -11,7 +11,7 @@
} }
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
@@ -213,6 +_,11 @@ @@ -210,6 +_,11 @@
@Override @Override
public void moveDown() { public void moveDown() {
this.move(1); this.move(1);
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/packs/TransferableSelectionList.java --- a/net/minecraft/client/gui/screens/packs/TransferableSelectionList.java
+++ b/net/minecraft/client/gui/screens/packs/TransferableSelectionList.java +++ b/net/minecraft/client/gui/screens/packs/TransferableSelectionList.java
@@ -66,7 +_,7 @@ @@ -65,7 +_,7 @@
Component header = Component.empty().append(this.title).withStyle(ChatFormatting.UNDERLINE, ChatFormatting.BOLD); Component header = Component.empty().append(this.title).withStyle(ChatFormatting.UNDERLINE, ChatFormatting.BOLD);
this.addEntry(new TransferableSelectionList.HeaderEntry(this.minecraft.font, header), (int)(9.0F * 1.5F)); this.addEntry(new TransferableSelectionList.HeaderEntry(this.minecraft.font, header), (int)(9.0F * 1.5F));
this.setSelected(null); this.setSelected(null);
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java --- a/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java
+++ b/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java +++ b/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java
@@ -174,6 +_,7 @@ @@ -172,6 +_,7 @@
WorldDataConfiguration dataConfig = SharedConstants.IS_RUNNING_IN_IDE WorldDataConfiguration dataConfig = SharedConstants.IS_RUNNING_IN_IDE
? new WorldDataConfiguration(new DataPackConfig(List.of("vanilla", "tests"), List.of()), FeatureFlags.DEFAULT_FLAGS) ? new WorldDataConfiguration(new DataPackConfig(List.of("vanilla", "tests"), List.of()), FeatureFlags.DEFAULT_FLAGS)
: WorldDataConfiguration.DEFAULT; : WorldDataConfiguration.DEFAULT;
@@ -8,7 +8,7 @@
WorldLoader.InitConfig loadConfig = createDefaultLoadConfig(vanillaOnlyPackRepository, dataConfig); WorldLoader.InitConfig loadConfig = createDefaultLoadConfig(vanillaOnlyPackRepository, dataConfig);
CompletableFuture<WorldCreationContext> loadResult = WorldLoader.load( CompletableFuture<WorldCreationContext> loadResult = WorldLoader.load(
loadConfig, loadConfig,
@@ -509,7 +_,7 @@ @@ -512,7 +_,7 @@
if (retry) { if (retry) {
onAbort.accept(this.uiState.getSettings().dataConfiguration()); onAbort.accept(this.uiState.getSettings().dataConfiguration());
} else { } else {
@@ -17,7 +17,7 @@
} }
}, },
Component.translatable("dataPack.validation.failed"), Component.translatable("dataPack.validation.failed"),
@@ -623,6 +_,7 @@ @@ -621,6 +_,7 @@
if (dataPackDir != null) { if (dataPackDir != null) {
if (this.tempDataPackRepository == null) { if (this.tempDataPackRepository == null) {
this.tempDataPackRepository = ServerPacksSource.createPackRepository(dataPackDir, this.packValidator); this.tempDataPackRepository = ServerPacksSource.createPackRepository(dataPackDir, this.packValidator);
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/worldselection/WorldCreationUiState.java --- a/net/minecraft/client/gui/screens/worldselection/WorldCreationUiState.java
+++ b/net/minecraft/client/gui/screens/worldselection/WorldCreationUiState.java +++ b/net/minecraft/client/gui/screens/worldselection/WorldCreationUiState.java
@@ -229,7 +_,7 @@ @@ -239,7 +_,7 @@
public @Nullable PresetEditor getPresetEditor() { public @Nullable PresetEditor getPresetEditor() {
Holder<WorldPreset> preset = this.getWorldType().preset(); Holder<WorldPreset> preset = this.getWorldType().preset();
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java --- a/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java
+++ b/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java +++ b/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java
@@ -489,6 +_,8 @@ @@ -495,6 +_,8 @@
this.minecraft.setScreenAndShow(new GenericMessageScreen(Component.translatable("selectWorld.resource_load"))); this.minecraft.setScreenAndShow(new GenericMessageScreen(Component.translatable("selectWorld.resource_load")));
PackRepository packRepository = ServerPacksSource.createPackRepository(worldAccess); PackRepository packRepository = ServerPacksSource.createPackRepository(worldAccess);
@@ -9,7 +9,7 @@
WorldStem worldStem; WorldStem worldStem;
try { try {
worldStem = this.loadWorldStem(worldAccess, levelDataTag, safeMode, packRepository); worldStem = this.loadWorldStem(worldAccess, levelDataTag, safeMode, packRepository);
@@ -530,6 +_,8 @@ @@ -537,6 +_,8 @@
WorldData data = worldDataAndGenSettings.data(); WorldData data = worldDataAndGenSettings.data();
boolean oldCustomized = worldDataAndGenSettings.genSettings().options().isOldCustomizedWorld(); boolean oldCustomized = worldDataAndGenSettings.genSettings().options().isOldCustomizedWorld();
boolean unstable = data.worldGenSettingsLifecycle() != Lifecycle.stable(); boolean unstable = data.worldGenSettingsLifecycle() != Lifecycle.stable();
@@ -18,7 +18,7 @@
if (!oldCustomized && !unstable) { if (!oldCustomized && !unstable) {
this.openWorldLoadBundledResourcePack(worldAccess, worldStem, packRepository, onCancel); this.openWorldLoadBundledResourcePack(worldAccess, worldStem, packRepository, onCancel);
} else { } else {
@@ -546,6 +_,8 @@ @@ -553,6 +_,8 @@
private void openWorldLoadBundledResourcePack( private void openWorldLoadBundledResourcePack(
final LevelStorageSource.LevelStorageAccess worldAccess, final WorldStem worldStem, final PackRepository packRepository, final Runnable onCancel final LevelStorageSource.LevelStorageAccess worldAccess, final WorldStem worldStem, final PackRepository packRepository, final Runnable onCancel
) { ) {
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/worldselection/WorldSelectionList.java --- a/net/minecraft/client/gui/screens/worldselection/WorldSelectionList.java
+++ b/net/minecraft/client/gui/screens/worldselection/WorldSelectionList.java +++ b/net/minecraft/client/gui/screens/worldselection/WorldSelectionList.java
@@ -84,6 +_,7 @@ @@ -83,6 +_,7 @@
private static final Identifier JOIN_HIGHLIGHTED_SPRITE = Identifier.withDefaultNamespace("world_list/join_highlighted"); private static final Identifier JOIN_HIGHLIGHTED_SPRITE = Identifier.withDefaultNamespace("world_list/join_highlighted");
private static final Identifier JOIN_SPRITE = Identifier.withDefaultNamespace("world_list/join"); private static final Identifier JOIN_SPRITE = Identifier.withDefaultNamespace("world_list/join");
private static final Logger LOGGER = LogUtils.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
@@ -8,7 +8,7 @@
private static final Component FROM_NEWER_TOOLTIP_1 = Component.translatable("selectWorld.tooltip.fromNewerVersion1").withStyle(ChatFormatting.RED); private static final Component FROM_NEWER_TOOLTIP_1 = Component.translatable("selectWorld.tooltip.fromNewerVersion1").withStyle(ChatFormatting.RED);
private static final Component FROM_NEWER_TOOLTIP_2 = Component.translatable("selectWorld.tooltip.fromNewerVersion2").withStyle(ChatFormatting.RED); private static final Component FROM_NEWER_TOOLTIP_2 = Component.translatable("selectWorld.tooltip.fromNewerVersion2").withStyle(ChatFormatting.RED);
private static final Component SNAPSHOT_TOOLTIP_1 = Component.translatable("selectWorld.tooltip.snapshot1").withStyle(ChatFormatting.GOLD); private static final Component SNAPSHOT_TOOLTIP_1 = Component.translatable("selectWorld.tooltip.snapshot1").withStyle(ChatFormatting.GOLD);
@@ -486,6 +_,19 @@ @@ -483,6 +_,19 @@
} }
} }
@@ -28,11 +28,11 @@
@Override @Override
public Component getNarration() { public Component getNarration() {
Component entryNarration = Component.translatable( Component entryNarration = Component.translatable(
@@ -515,6 +_,7 @@ @@ -512,6 +_,7 @@
this.infoText.setPosition(textX, this.getContentY() + 9 + 9 + 3); this.infoText.setPosition(textX, this.getContentY() + 9 + 9 + 3);
this.infoText.extractRenderState(graphics, mouseX, mouseY, a); this.infoText.extractRenderState(graphics, mouseX, mouseY, a);
graphics.blit(RenderPipelines.GUI_TEXTURED, this.icon.textureLocation(), this.getContentX(), this.getContentY(), 0.0F, 0.0F, 32, 32, 32, 32); graphics.blit(RenderPipelines.GUI_TEXTURED, this.icon.textureLocation(), this.getContentX(), this.getContentY(), 0.0F, 0.0F, 32, 32, 32, 32);
+ renderExperimentalWarning(graphics, mouseX, mouseY, this.getContentY(), this.getContentX()); + renderExperimentalWarning(graphics, mouseX, mouseY, this.getContentY(), this.getContentX());
if (this.list.entryType == WorldSelectionList.EntryType.SINGLEPLAYER && (this.minecraft.options.touchscreen().get() || hovered)) { if (this.list.entryType == WorldSelectionList.EntryType.SINGLEPLAYER && hovered) {
graphics.fill(this.getContentX(), this.getContentY(), this.getContentX() + 32, this.getContentY() + 32, -1601138544); graphics.fill(this.getContentX(), this.getContentY(), this.getContentX() + 32, this.getContentY() + 32, -1601138544);
int relX = mouseX - this.getContentX(); int relX = mouseX - this.getContentX();
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/main/Main.java --- a/net/minecraft/client/main/Main.java
+++ b/net/minecraft/client/main/Main.java +++ b/net/minecraft/client/main/Main.java
@@ -114,8 +_,8 @@ @@ -159,8 +_,8 @@
CrashReport.preload(); CrashReport.preload();
logger = LogUtils.getLogger(); logger = LogUtils.getLogger();
stage = "Bootstrap"; stage = "Bootstrap";
@@ -22,13 +22,13 @@
} }
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
- public static enum ArmPose { - public enum ArmPose {
+ public static enum ArmPose implements net.minecraftforge.common.IExtensibleEnum { + public enum ArmPose implements net.minecraftforge.common.IExtensibleEnum {
EMPTY(false, false), EMPTY(false, false),
ITEM(false, false), ITEM(false, false),
BLOCK(false, false), BLOCK(false, false),
@@ -523,10 +_,29 @@ @@ -523,10 +_,29 @@
private ArmPose(final boolean twoHanded, final boolean affectsOffhandPose) { ArmPose(final boolean twoHanded, final boolean affectsOffhandPose) {
this.twoHanded = twoHanded; this.twoHanded = twoHanded;
this.affectsOffhandPose = affectsOffhandPose; this.affectsOffhandPose = affectsOffhandPose;
+ this.forgeArmPose = null; + this.forgeArmPose = null;
@@ -1,9 +1,9 @@
--- a/net/minecraft/client/model/geom/LayerDefinitions.java --- a/net/minecraft/client/model/geom/LayerDefinitions.java
+++ b/net/minecraft/client/model/geom/LayerDefinitions.java +++ b/net/minecraft/client/model/geom/LayerDefinitions.java
@@ -569,6 +_,7 @@ @@ -557,6 +_,7 @@
result.put(ModelLayers.createHangingSignModelName(woodType, attachmentType), hangingSignModel); result.put(ModelLayers.PALE_OAK_CHEST_BOAT, chestBoatModel);
} result.put(ModelLayers.MANGROVE_BOAT, boatModel);
}); result.put(ModelLayers.MANGROVE_CHEST_BOAT, chestBoatModel);
+ net.minecraftforge.client.ForgeHooksClient.loadLayerDefinitions(result); + net.minecraftforge.client.ForgeHooksClient.loadLayerDefinitions(result);
ImmutableMap<ModelLayerLocation, LayerDefinition> definitions = result.build(); ImmutableMap<ModelLayerLocation, LayerDefinition> definitions = result.build();
List<ModelLayerLocation> missingDefinitions = ModelLayers.getKnownLocations().filter(l -> !definitions.containsKey(l)).toList(); List<ModelLayerLocation> missingDefinitions = ModelLayers.getKnownLocations().filter(l -> !definitions.containsKey(l)).toList();
@@ -3,9 +3,9 @@
@@ -75,6 +_,8 @@ @@ -75,6 +_,8 @@
this.writeProfileKeyPair(fetchedKeyPair); this.writeProfileKeyPair(fetchedKeyPair);
return Optional.ofNullable(fetchedKeyPair); return Optional.ofNullable(fetchedKeyPair);
} catch (CryptException | MinecraftClientException | IOException var3) { } catch (IOException | CryptException | MinecraftClientException e) {
+ // Forge: The offline user api service always returns a null profile key pair, so let's hide this useless exception if in dev + // Forge: The offline user api service always returns a null profile key pair, so let's hide this useless exception if in dev
+ if (net.minecraftforge.fml.loading.FMLLoader.isProduction() || this.userApiService != UserApiService.OFFLINE) + if (net.minecraftforge.fml.loading.FMLLoader.isProduction() || this.userApiService != UserApiService.OFFLINE)
LOGGER.error("Failed to retrieve profile key pair", (Throwable)var3); LOGGER.error("Failed to retrieve profile key pair", e);
this.writeProfileKeyPair(null); this.writeProfileKeyPair(null);
return cachedKeyPair; return cachedKeyPair;
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/multiplayer/ClientChunkCache.java --- a/net/minecraft/client/multiplayer/ClientChunkCache.java
+++ b/net/minecraft/client/multiplayer/ClientChunkCache.java +++ b/net/minecraft/client/multiplayer/ClientChunkCache.java
@@ -65,6 +_,7 @@ @@ -64,6 +_,7 @@
int index = this.storage.getIndex(pos.x(), pos.z()); int index = this.storage.getIndex(pos.x(), pos.z());
LevelChunk currentChunk = this.storage.getChunk(index); LevelChunk currentChunk = this.storage.getChunk(index);
if (isValidChunk(currentChunk, pos.x(), pos.z())) { if (isValidChunk(currentChunk, pos.x(), pos.z())) {
@@ -9,10 +9,10 @@
} }
} }
@@ -124,6 +_,7 @@ @@ -124,6 +_,7 @@
}
this.level.onChunkLoaded(pos);
+ net.minecraftforge.event.level.ChunkEvent.Load.BUS.post(new net.minecraftforge.event.level.ChunkEvent.Load(chunk, false));
return chunk;
} }
this.level.onChunkLoaded(pos);
+ net.minecraftforge.event.level.ChunkEvent.Load.BUS.post(new net.minecraftforge.event.level.ChunkEvent.Load(chunk, false));
return chunk;
} }
@@ -1,8 +1,8 @@
--- a/net/minecraft/client/multiplayer/ClientConfigurationPacketListenerImpl.java --- a/net/minecraft/client/multiplayer/ClientConfigurationPacketListenerImpl.java
+++ b/net/minecraft/client/multiplayer/ClientConfigurationPacketListenerImpl.java +++ b/net/minecraft/client/multiplayer/ClientConfigurationPacketListenerImpl.java
@@ -148,6 +_,7 @@ @@ -144,6 +_,7 @@
})); }
} }));
} }
+ net.minecraftforge.common.ForgeHooks.handleClientConfigurationComplete(this.connection); + net.minecraftforge.common.ForgeHooks.handleClientConfigurationComplete(this.connection);
} }
@@ -1,14 +1,14 @@
--- a/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java --- a/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java
+++ b/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java +++ b/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java
@@ -209,6 +_,7 @@ @@ -211,6 +_,7 @@
Component title = this.wasTransferredTo ? CommonComponents.TRANSFER_CONNECT_FAILED : CommonComponents.CONNECT_FAILED; Component title = this.wasTransferredTo ? CommonComponents.TRANSFER_CONNECT_FAILED : CommonComponents.CONNECT_FAILED;
if (this.serverData != null && this.serverData.isRealm()) { if (this.serverData != null && this.serverData.isRealm()) {
this.minecraft.setScreen(new DisconnectedScreen(this.parent, title, details.reason(), CommonComponents.GUI_BACK)); this.minecraft.gui.setScreen(new DisconnectedScreen(this.parent, title, details.reason(), CommonComponents.GUI_BACK));
+ } else if (net.minecraftforge.client.ForgeHooksClient.onClientDisconnect(this.connection, this.minecraft, this.parent, details.reason())) { + } else if (net.minecraftforge.client.ForgeHooksClient.onClientDisconnect(this.connection, this.minecraft, this.parent, details.reason())) {
} else { } else {
this.minecraft.setScreen(new DisconnectedScreen(this.parent, title, details)); this.minecraft.gui.setScreen(new DisconnectedScreen(this.parent, title, details));
} }
@@ -233,6 +_,7 @@ @@ -235,6 +_,7 @@
@Override @Override
public void handleCustomQuery(final ClientboundCustomQueryPacket packet) { public void handleCustomQuery(final ClientboundCustomQueryPacket packet) {
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/multiplayer/ClientLevel.java --- a/net/minecraft/client/multiplayer/ClientLevel.java
+++ b/net/minecraft/client/multiplayer/ClientLevel.java +++ b/net/minecraft/client/multiplayer/ClientLevel.java
@@ -150,6 +_,7 @@ @@ -165,6 +_,7 @@
cache.put(BiomeColors.FOLIAGE_COLOR_RESOLVER, new BlockTintCache(pos -> this.calculateBlockTint(pos, BiomeColors.FOLIAGE_COLOR_RESOLVER))); cache.put(BiomeColors.FOLIAGE_COLOR_RESOLVER, new BlockTintCache(pos -> this.calculateBlockTint(pos, BiomeColors.FOLIAGE_COLOR_RESOLVER)));
cache.put(BiomeColors.DRY_FOLIAGE_COLOR_RESOLVER, new BlockTintCache(pos -> this.calculateBlockTint(pos, BiomeColors.DRY_FOLIAGE_COLOR_RESOLVER))); cache.put(BiomeColors.DRY_FOLIAGE_COLOR_RESOLVER, new BlockTintCache(pos -> this.calculateBlockTint(pos, BiomeColors.DRY_FOLIAGE_COLOR_RESOLVER)));
cache.put(BiomeColors.WATER_COLOR_RESOLVER, new BlockTintCache(pos -> this.calculateBlockTint(pos, BiomeColors.WATER_COLOR_RESOLVER))); cache.put(BiomeColors.WATER_COLOR_RESOLVER, new BlockTintCache(pos -> this.calculateBlockTint(pos, BiomeColors.WATER_COLOR_RESOLVER)));
@@ -8,8 +8,8 @@
}); });
private final ClientChunkCache chunkSource; private final ClientChunkCache chunkSource;
private final Deque<Runnable> lightUpdateQueue = Queues.newArrayDeque(); private final Deque<Runnable> lightUpdateQueue = Queues.newArrayDeque();
@@ -161,6 +_,8 @@ @@ -178,6 +_,8 @@
private final EnvironmentAttributeSystem environmentAttributes; private final Long2ObjectMap<SortedSet<BlockDestructionProgress>> destructionProgress = new Long2ObjectOpenHashMap<>();
private final int seaLevel; private final int seaLevel;
private static final Set<Item> MARKER_PARTICLE_ITEMS = Set.of(Items.BARRIER, Items.LIGHT); private static final Set<Item> MARKER_PARTICLE_ITEMS = Set.of(Items.BARRIER, Items.LIGHT);
+ private final it.unimi.dsi.fastutil.ints.Int2ObjectMap<net.minecraftforge.entity.PartEntity<?>> partEntities = new it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap<>(); + private final it.unimi.dsi.fastutil.ints.Int2ObjectMap<net.minecraftforge.entity.PartEntity<?>> partEntities = new it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap<>();
@@ -17,7 +17,7 @@
public void handleBlockChangedAck(final int sequence) { public void handleBlockChangedAck(final int sequence) {
if (SharedConstants.DEBUG_BLOCK_BREAK) { if (SharedConstants.DEBUG_BLOCK_BREAK) {
@@ -243,6 +_,8 @@ @@ -260,6 +_,8 @@
this.serverSimulationDistance = serverSimulationDistance; this.serverSimulationDistance = serverSimulationDistance;
this.environmentAttributes = this.addEnvironmentAttributeLayers(EnvironmentAttributeSystem.builder()).build(); this.environmentAttributes = this.addEnvironmentAttributeLayers(EnvironmentAttributeSystem.builder()).build();
this.updateSkyBrightness(); this.updateSkyBrightness();
@@ -26,7 +26,7 @@
} }
private EnvironmentAttributeSystem.Builder addEnvironmentAttributeLayers(final EnvironmentAttributeSystem.Builder environmentAttributes) { private EnvironmentAttributeSystem.Builder addEnvironmentAttributeLayers(final EnvironmentAttributeSystem.Builder environmentAttributes) {
@@ -352,6 +_,7 @@ @@ -471,6 +_,7 @@
entity.setOldPosAndRot(); entity.setOldPosAndRot();
entity.tickCount++; entity.tickCount++;
Profiler.get().push(entity.typeHolder()::getRegisteredName); Profiler.get().push(entity.typeHolder()::getRegisteredName);
@@ -34,7 +34,7 @@
entity.tick(); entity.tick();
Profiler.get().pop(); Profiler.get().pop();
@@ -412,8 +_,10 @@ @@ -527,8 +_,10 @@
} }
public void addEntity(final Entity entity) { public void addEntity(final Entity entity) {
@@ -45,7 +45,7 @@
} }
public void removeEntity(final int id, final Entity.RemovalReason reason) { public void removeEntity(final int id, final Entity.RemovalReason reason) {
@@ -576,8 +_,10 @@ @@ -692,8 +_,10 @@
final float pitch, final float pitch,
final long seed final long seed
) { ) {
@@ -57,7 +57,7 @@
} }
} }
@@ -591,8 +_,10 @@ @@ -707,8 +_,10 @@
final float pitch, final float pitch,
final long seed final long seed
) { ) {
@@ -69,7 +69,7 @@
} }
} }
@@ -946,7 +_,7 @@ @@ -1081,7 +_,7 @@
@Override @Override
public void addDestroyBlockEffect(final BlockPos pos, final BlockState blockState) { public void addDestroyBlockEffect(final BlockPos pos, final BlockState blockState) {
@@ -78,7 +78,7 @@
VoxelShape shape = blockState.getShape(this, pos); VoxelShape shape = blockState.getShape(this, pos);
double density = 0.25; double density = 0.25;
shape.forAllBoxes( shape.forAllBoxes(
@@ -973,6 +_,7 @@ @@ -1108,6 +_,7 @@
new TerrainParticle( new TerrainParticle(
this, pos.getX() + x, pos.getY() + y, pos.getZ() + z, relX - 0.5, relY - 0.5, relZ - 0.5, blockState, pos this, pos.getX() + x, pos.getY() + y, pos.getZ() + z, relX - 0.5, relY - 0.5, relZ - 0.5, blockState, pos
) )
@@ -86,7 +86,7 @@
); );
} }
} }
@@ -982,6 +_,13 @@ @@ -1117,6 +_,13 @@
} }
} }
@@ -100,7 +100,7 @@
public void addBreakingBlockEffect(final BlockPos pos, final Direction direction) { public void addBreakingBlockEffect(final BlockPos pos, final Direction direction) {
BlockState blockState = this.getBlockState(pos); BlockState blockState = this.getBlockState(pos);
if (blockState.getRenderShape() != RenderShape.INVISIBLE && blockState.shouldSpawnTerrainParticles()) { if (blockState.getRenderShape() != RenderShape.INVISIBLE && blockState.shouldSpawnTerrainParticles()) {
@@ -1017,7 +_,7 @@ @@ -1152,7 +_,7 @@
xp = x + shape.maxX + 0.1F; xp = x + shape.maxX + 0.1F;
} }
@@ -109,7 +109,7 @@
} }
} }
@@ -1083,6 +_,16 @@ @@ -1218,6 +_,16 @@
this.explosionTracker.track(center, radius, blockCount, blockParticles); this.explosionTracker.track(center, radius, blockCount, blockParticles);
} }
@@ -126,7 +126,7 @@
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public static class ClientLevelData implements WritableLevelData { public static class ClientLevelData implements WritableLevelData {
private final boolean hardcore; private final boolean hardcore;
@@ -1138,6 +_,7 @@ @@ -1273,6 +_,7 @@
} }
public void setDifficulty(final Difficulty difficulty) { public void setDifficulty(final Difficulty difficulty) {
@@ -134,7 +134,7 @@
this.difficulty = difficulty; this.difficulty = difficulty;
} }
@@ -1185,6 +_,12 @@ @@ -1315,6 +_,12 @@
break; break;
default: default:
} }
@@ -147,7 +147,7 @@
} }
public void onTrackingEnd(final Entity entity) { public void onTrackingEnd(final Entity entity) {
@@ -1197,6 +_,15 @@ @@ -1327,6 +_,15 @@
ClientLevel.this.dragonParts.removeAll(Arrays.asList(dragon.getSubEntities())); ClientLevel.this.dragonParts.removeAll(Arrays.asList(dragon.getSubEntities()));
break; break;
default: default:
@@ -2,13 +2,13 @@
+++ b/net/minecraft/client/multiplayer/ClientPacketListener.java +++ b/net/minecraft/client/multiplayer/ClientPacketListener.java
@@ -531,6 +_,7 @@ @@ -531,6 +_,7 @@
this.debugSubscriber.clear(); this.debugSubscriber.clear();
this.minecraft.levelRenderer.debugRenderer.refreshRendererList(); this.minecraft.levelExtractor.debugRenderer.refreshRendererList();
this.minecraft.player.resetPos(); this.minecraft.player.resetPos();
+ net.minecraftforge.client.event.ForgeEventFactoryClient.firePlayerLogin(this.minecraft.gameMode, this.minecraft.player, this.minecraft.getConnection().connection); + net.minecraftforge.client.event.ForgeEventFactoryClient.firePlayerLogin(this.minecraft.gameMode, this.minecraft.player, this.minecraft.getConnection().connection);
this.minecraft.player.setId(packet.playerId()); this.minecraft.player.setId(packet.playerId());
this.level.addEntity(this.minecraft.player); this.level.addEntity(this.minecraft.player);
this.minecraft.player.input = new KeyboardInput(this.minecraft.options); this.minecraft.player.input = new KeyboardInput(this.minecraft.options);
@@ -1325,6 +_,8 @@ @@ -1323,6 +_,8 @@
newPlayer.getAttributes().assignBaseValues(oldPlayer.getAttributes()); newPlayer.getAttributes().assignBaseValues(oldPlayer.getAttributes());
} }
@@ -17,16 +17,16 @@
this.level.addEntity(newPlayer); this.level.addEntity(newPlayer);
newPlayer.input = new KeyboardInput(this.minecraft.options); newPlayer.input = new KeyboardInput(this.minecraft.options);
this.minecraft.gameMode.adjustPlayer(newPlayer); this.minecraft.gameMode.adjustPlayer(newPlayer);
@@ -1480,7 +_,7 @@ @@ -1478,7 +_,7 @@
ProblemReporter.ScopedCollector reporter = new ProblemReporter.ScopedCollector(blockEntity.problemPath(), LOGGER); ProblemReporter.ScopedCollector reporter = new ProblemReporter.ScopedCollector(blockEntity.problemPath(), LOGGER);
try { try {
- blockEntity.loadWithComponents(TagValueInput.create(reporter, this.registryAccess, packet.getTag())); - blockEntity.loadWithComponents(TagValueInput.create(reporter, this.registryAccess, packet.getTag()));
+ blockEntity.onDataPacket(connection, TagValueInput.create(reporter, this.registryAccess, packet.getTag()), this.registryAccess); + blockEntity.onDataPacket(connection, TagValueInput.create(reporter, this.registryAccess, packet.getTag()), this.registryAccess);
} catch (Throwable var7) { } catch (Throwable t$) {
try { try {
reporter.close(); reporter.close();
@@ -1687,7 +_,9 @@ @@ -1686,7 +_,9 @@
@Override @Override
public void handleCommands(final ClientboundCommandsPacket packet) { public void handleCommands(final ClientboundCommandsPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.minecraft.packetProcessor()); PacketUtils.ensureRunningOnSameThread(packet, this, this.minecraft.packetProcessor());
@@ -37,15 +37,15 @@
} }
@Override @Override
@@ -1788,6 +_,7 @@ @@ -1787,6 +_,7 @@
if (this.minecraft.screen instanceof RecipeUpdateListener updateListener) { if (this.minecraft.gui.screen() instanceof RecipeUpdateListener updateListener) {
updateListener.recipesUpdated(); updateListener.recipesUpdated();
} }
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onRecipesUpdated(recipeBook); + net.minecraftforge.client.event.ForgeEventFactoryClient.onRecipesUpdated(recipeBook);
} }
@Override @Override
@@ -1832,6 +_,8 @@ @@ -1830,6 +_,8 @@
this.fuelValues = FuelValues.vanillaBurnTimes(this.registryAccess, this.enabledFeatures); this.fuelValues = FuelValues.vanillaBurnTimes(this.registryAccess, this.enabledFeatures);
List<ItemStack> searchItems = List.copyOf(CreativeModeTabs.searchTab().getDisplayItems()); List<ItemStack> searchItems = List.copyOf(CreativeModeTabs.searchTab().getDisplayItems());
this.searchTrees.updateCreativeTags(searchItems); this.searchTrees.updateCreativeTags(searchItems);
@@ -54,7 +54,7 @@
} }
@Override @Override
@@ -2650,7 +_,9 @@ @@ -2652,7 +_,9 @@
} }
} }
@@ -65,7 +65,7 @@
Instant timeStamp = Instant.now(); Instant timeStamp = Instant.now();
long salt = Crypt.SaltSupplier.getLong(); long salt = Crypt.SaltSupplier.getLong();
LastSeenMessagesTracker.Update lastSeenUpdate = this.lastSeenMessages.generateAndApplyUpdate(); LastSeenMessagesTracker.Update lastSeenUpdate = this.lastSeenMessages.generateAndApplyUpdate();
@@ -2659,6 +_,7 @@ @@ -2661,6 +_,7 @@
} }
public void sendCommand(final String command) { public void sendCommand(final String command) {
@@ -73,7 +73,7 @@
SignableCommand<ClientSuggestionProvider> signableCommand = SignableCommand.of(this.commands.parse(command, this.suggestionsProvider)); SignableCommand<ClientSuggestionProvider> signableCommand = SignableCommand.of(this.commands.parse(command, this.suggestionsProvider));
if (signableCommand.arguments().isEmpty()) { if (signableCommand.arguments().isEmpty()) {
this.send(new ServerboundChatCommandPacket(command)); this.send(new ServerboundChatCommandPacket(command));
@@ -2675,6 +_,7 @@ @@ -2677,6 +_,7 @@
} }
public void sendUnattendedCommand(final String command, final @Nullable Screen screenAfterCommand) { public void sendUnattendedCommand(final String command, final @Nullable Screen screenAfterCommand) {
@@ -1,61 +1,25 @@
--- a/net/minecraft/client/multiplayer/MultiPlayerGameMode.java --- a/net/minecraft/client/multiplayer/MultiPlayerGameMode.java
+++ b/net/minecraft/client/multiplayer/MultiPlayerGameMode.java +++ b/net/minecraft/client/multiplayer/MultiPlayerGameMode.java
@@ -114,6 +_,7 @@ @@ -115,6 +_,7 @@
} }
public boolean destroyBlock(final BlockPos pos) { public boolean destroyBlock(final BlockPos pos) {
+ if (minecraft.player.getMainHandItem().onBlockStartBreak(pos, minecraft.player)) return false; + if (minecraft.player.getMainHandItem().onBlockStartBreak(pos, minecraft.player)) return false;
if (this.minecraft.player.blockActionRestricted(this.minecraft.level, pos, this.localPlayerMode)) { if (this.minecraft.player.blockActionRestricted(this.minecraft.level, pos, this.localPlayerMode)) {
return false; return false;
} else { }
@@ -128,9 +_,8 @@ @@ -134,9 +_,8 @@
} else if (oldState.isAir()) { return false;
return false; }
} else {
- oldBlock.playerWillDestroy(level, pos, oldState, this.minecraft.player);
FluidState fluidState = level.getFluidState(pos);
- boolean changed = level.setBlock(pos, fluidState.createLegacyBlock(), 11);
+ boolean changed = oldState.onDestroyedByPlayer(level, pos, minecraft.player, false, fluidState);
if (changed) {
oldBlock.destroy(level, pos, oldState);
}
@@ -159,6 +_,7 @@
}
this.startPrediction(this.minecraft.level, sequence -> { - oldBlock.playerWillDestroy(level, pos, oldState, this.minecraft.player);
+ if (!net.minecraftforge.event.ForgeEventFactory.isLeftClickBlockCancelled(this.minecraft.player, pos, direction, ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK)) FluidState fluidState = level.getFluidState(pos);
this.destroyBlock(pos); - boolean changed = level.setBlock(pos, fluidState.createLegacyBlock(), 11);
return new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, pos, direction, sequence); + boolean changed = oldState.onDestroyedByPlayer(level, pos, minecraft.player, false, fluidState);
}); if (changed) {
@@ -172,6 +_,7 @@ oldBlock.destroy(level, pos, oldState);
this.connection }
.send(new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK, this.destroyBlockPos, direction)); @@ -165,6 +_,7 @@
}
+ var event = net.minecraftforge.event.ForgeEventFactory.onLeftClickBlock(this.minecraft.player, pos, direction, ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK);
BlockState state = this.minecraft.level.getBlockState(pos);
this.minecraft.getTutorial().onDestroyBlock(this.minecraft.level, pos, state, 0.0F);
@@ -182,9 +_,11 @@
this.startPrediction(this.minecraft.level, sequence -> {
boolean notAir = !state.isAir();
if (notAir && this.destroyProgress == 0.0F) {
+ if (event != null && !event.getUseBlock().isDenied())
state.attack(this.minecraft.level, pos, this.minecraft.player);
}
+ if (event != null && !event.getUseItem().isDenied()) {
if (notAir && state.getDestroyProgress(this.minecraft.player, this.minecraft.player.level(), pos) >= 1.0F) {
this.destroyBlock(pos);
} else {
@@ -195,6 +_,7 @@
this.destroyTicks = 0.0F;
this.minecraft.level.destroyBlockProgress(this.minecraft.player.getId(), this.destroyBlockPos, this.getDestroyStage());
}
+ }
return new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, pos, direction, sequence);
});
@@ -235,6 +_,7 @@
} }
this.startPrediction(this.minecraft.level, sequence -> { this.startPrediction(this.minecraft.level, sequence -> {
@@ -63,24 +27,68 @@
this.destroyBlock(pos); this.destroyBlock(pos);
return new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, pos, direction, sequence); return new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, pos, direction, sequence);
}); });
@@ -247,7 +_,7 @@ @@ -178,6 +_,7 @@
} else { this.connection
this.destroyProgress = this.destroyProgress + state.getDestroyProgress(this.minecraft.player, this.minecraft.player.level(), pos); .send(new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK, this.destroyBlockPos, direction));
if (this.destroyTicks % 4.0F == 0.0F) { }
- SoundType soundType = state.getSoundType(); + var event = net.minecraftforge.event.ForgeEventFactory.onLeftClickBlock(this.minecraft.player, pos, direction, ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK);
+ SoundType soundType = state.getSoundType(this.minecraft.level, pos, this.minecraft.player);
this.minecraft
.getSoundManager()
.play(
@@ -264,6 +_,7 @@
this.destroyTicks++; BlockState state = this.minecraft.level.getBlockState(pos);
this.minecraft.getTutorial().onDestroyBlock(this.minecraft.level, pos, state, Mth.clamp(this.destroyProgress, 0.0F, 1.0F)); this.minecraft.getTutorial().onDestroyBlock(this.minecraft.level, pos, state, 0.0F);
@@ -188,9 +_,11 @@
this.startPrediction(this.minecraft.level, sequence -> {
boolean notAir = !state.isAir();
if (notAir && this.destroyProgress == 0.0F) {
+ if (event != null && !event.getUseBlock().isDenied())
state.attack(this.minecraft.level, pos, this.minecraft.player);
}
+ if (event != null && !event.getUseItem().isDenied()) {
if (notAir && state.getDestroyProgress(this.minecraft.player, this.minecraft.player.level(), pos) >= 1.0F) {
this.destroyBlock(pos);
} else {
@@ -201,6 +_,7 @@
this.destroyTicks = 0.0F;
this.minecraft.level.destroyBlockProgress(this.minecraft.player.getId(), this.destroyBlockPos, this.getDestroyStage());
}
+ }
return new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, pos, direction, sequence);
});
@@ -242,6 +_,7 @@
}
this.startPrediction(this.minecraft.level, sequence -> {
+ if (!net.minecraftforge.event.ForgeEventFactory.isLeftClickBlockCancelled(this.minecraft.player, pos, direction, ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK))
this.destroyBlock(pos);
return new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, pos, direction, sequence);
});
@@ -255,7 +_,7 @@
this.destroyProgress = this.destroyProgress + state.getDestroyProgress(this.minecraft.player, this.minecraft.player.level(), pos);
if (this.destroyTicks % 4.0F == 0.0F) {
- SoundType soundType = state.getSoundType();
+ SoundType soundType = state.getSoundType(this.minecraft.level, pos, this.minecraft.player);
this.minecraft
.getSoundManager()
.play(
@@ -272,6 +_,7 @@
this.destroyTicks++;
this.minecraft.getTutorial().onDestroyBlock(this.minecraft.level, pos, state, Mth.clamp(this.destroyProgress, 0.0F, 1.0F));
+ if (net.minecraftforge.event.ForgeEventFactory.onLeftClickBlockHold(this.minecraft.player, pos, direction).getUseItem().isDenied()) return true; + if (net.minecraftforge.event.ForgeEventFactory.onLeftClickBlockHold(this.minecraft.player, pos, direction).getUseItem().isDenied()) return true;
if (this.destroyProgress >= 1.0F) { if (this.destroyProgress >= 1.0F) {
this.isDestroying = false; this.isDestroying = false;
if (SharedConstants.DEBUG_BLOCK_BREAK) { if (SharedConstants.DEBUG_BLOCK_BREAK) {
@@ -306,7 +_,7 @@ @@ -279,6 +_,7 @@
}
this.startPrediction(this.minecraft.level, sequence -> {
+ if (!net.minecraftforge.event.ForgeEventFactory.isLeftClickBlockCancelled(this.minecraft.player, pos, direction, ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK))
this.destroyBlock(pos);
return new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.STOP_DESTROY_BLOCK, pos, direction, sequence);
});
@@ -313,7 +_,7 @@
private boolean sameDestroyTarget(final BlockPos pos) { private boolean sameDestroyTarget(final BlockPos pos) {
ItemStack selected = this.minecraft.player.getMainHandItem(); ItemStack selected = this.minecraft.player.getMainHandItem();
@@ -89,7 +97,7 @@
} }
private void ensureHasSentCarriedItem() { private void ensureHasSentCarriedItem() {
@@ -334,12 +_,23 @@ @@ -341,13 +_,24 @@
private InteractionResult performUseItemOn(final LocalPlayer player, final InteractionHand hand, final BlockHitResult blockHit) { private InteractionResult performUseItemOn(final LocalPlayer player, final InteractionHand hand, final BlockHitResult blockHit) {
BlockPos pos = blockHit.getBlockPos(); BlockPos pos = blockHit.getBlockPos();
ItemStack itemStack = player.getItemInHand(hand); ItemStack itemStack = player.getItemInHand(hand);
@@ -99,58 +107,60 @@
+ } + }
if (this.localPlayerMode == GameType.SPECTATOR) { if (this.localPlayerMode == GameType.SPECTATOR) {
return InteractionResult.CONSUME; return InteractionResult.CONSUME;
} else { }
- boolean haveSomethingInOurHands = !player.getMainHandItem().isEmpty() || !player.getOffhandItem().isEmpty();
+ UseOnContext context = new UseOnContext(player, hand, blockHit); - boolean haveSomethingInOurHands = !player.getMainHandItem().isEmpty() || !player.getOffhandItem().isEmpty();
+ if (!event.getUseItem().isDenied()) { + UseOnContext context = new UseOnContext(player, hand, blockHit);
+ InteractionResult result = itemStack.onItemUseFirst(context); + if (!event.getUseItem().isDenied()) {
+ if (result != InteractionResult.PASS) { + InteractionResult result = itemStack.onItemUseFirst(context);
+ return result; + if (result != InteractionResult.PASS) {
+ } + return result;
+ } + }
+ boolean haveSomethingInOurHands = !player.getMainHandItem().doesSneakBypassUse(player.level(), pos, player) || !player.getOffhandItem().doesSneakBypassUse(player.level(), pos, player); + }
boolean suppressUsingBlock = player.isSecondaryUseActive() && haveSomethingInOurHands; + boolean haveSomethingInOurHands = !player.getMainHandItem().doesSneakBypassUse(player.level(), pos, player) || !player.getOffhandItem().doesSneakBypassUse(player.level(), pos, player);
- if (!suppressUsingBlock) { boolean suppressUsingBlock = player.isSecondaryUseActive() && haveSomethingInOurHands;
+ if (event.getUseBlock().isAllowed() || (!event.getUseBlock().isDenied() && !suppressUsingBlock)) { - if (!suppressUsingBlock) {
BlockState blockState = this.minecraft.level.getBlockState(pos); + if (event.getUseBlock().isAllowed() || (!event.getUseBlock().isDenied() && !suppressUsingBlock)) {
if (!this.connection.isFeatureEnabled(blockState.getBlock().requiredFeatures())) { BlockState blockState = this.minecraft.level.getBlockState(pos);
return InteractionResult.FAIL; if (!this.connection.isFeatureEnabled(blockState.getBlock().requiredFeatures())) {
@@ -358,8 +_,10 @@ return InteractionResult.FAIL;
} @@ -366,8 +_,10 @@
}
}
- if (!itemStack.isEmpty() && !player.getCooldowns().isOnCooldown(itemStack)) {
- UseOnContext context = new UseOnContext(player, hand, blockHit);
+ if (event.getUseItem().isDenied()) {
+ return InteractionResult.PASS;
+ }
+ if (event.getUseItem().isAllowed() || (!itemStack.isEmpty() && !player.getCooldowns().isOnCooldown(itemStack))) {
InteractionResult success;
if (player.hasInfiniteMaterials()) {
int count = itemStack.getCount();
@@ -398,6 +_,12 @@
return packet;
} }
- if (!itemStack.isEmpty() && !player.getCooldowns().isOnCooldown(itemStack)) { + var event = new net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickItem(player, hand);
- UseOnContext context = new UseOnContext(player, hand, blockHit); + if (net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickItem.BUS.post(event)) {
+ if (event.getUseItem().isDenied()) { + interactionResult.setValue(event.getCancellationResult());
+ return InteractionResult.PASS; + return packet;
+ } + }
+ if (event.getUseItem().isAllowed() || (!itemStack.isEmpty() && !player.getCooldowns().isOnCooldown(itemStack))) { +
InteractionResult success; InteractionResult resultHolder = itemStack.use(this.minecraft.level, player, hand);
if (player.hasInfiniteMaterials()) { ItemStack result;
int count = itemStack.getCount(); if (resultHolder instanceof InteractionResult.Success success) {
@@ -389,6 +_,11 @@ @@ -408,6 +_,9 @@
interactionResult.setValue(InteractionResult.PASS);
return packet;
} else {
+ var event = new net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickItem(player, hand);
+ if (net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickItem.BUS.post(event)) {
+ interactionResult.setValue(event.getCancellationResult());
+ return packet;
+ }
InteractionResult resultHolder = itemStack.use(this.minecraft.level, player, hand);
ItemStack result;
if (resultHolder instanceof InteractionResult.Success success) {
@@ -399,6 +_,9 @@
if (result != itemStack) { if (result != itemStack) {
player.setItemInHand(hand, result); player.setItemInHand(hand, result);
+ if (result.isEmpty()) { + if (result.isEmpty()) {
+ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(player, itemStack, hand); + net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(player, itemStack, hand);
+ } + }
} }
interactionResult.setValue(resultHolder); interactionResult.setValue(resultHolder);
@@ -434,6 +_,10 @@ @@ -445,6 +_,10 @@
this.ensureHasSentCarriedItem(); this.ensureHasSentCarriedItem();
Vec3 location = hitResult.getLocation().subtract(entity.getX(), entity.getY(), entity.getZ()); Vec3 location = hitResult.getLocation().subtract(entity.getX(), entity.getY(), entity.getZ());
this.connection.send(new ServerboundInteractPacket(entity.getId(), hand, location, player.isShiftKeyDown())); this.connection.send(new ServerboundInteractPacket(entity.getId(), hand, location, player.isShiftKeyDown()));
@@ -158,6 +168,6 @@
+ var event = new net.minecraftforge.event.entity.player.PlayerInteractEvent.EntityInteractSpecific(player, hand, entity, location); + var event = new net.minecraftforge.event.entity.player.PlayerInteractEvent.EntityInteractSpecific(player, hand, entity, location);
+ if (net.minecraftforge.event.entity.player.PlayerInteractEvent.EntityInteractSpecific.BUS.post(event)) return event.getCancellationResult(); + if (net.minecraftforge.event.entity.player.PlayerInteractEvent.EntityInteractSpecific.BUS.post(event)) return event.getCancellationResult();
+ } + }
return (InteractionResult)(this.localPlayerMode == GameType.SPECTATOR ? InteractionResult.PASS : player.interactOn(entity, hand, location)); return this.localPlayerMode == GameType.SPECTATOR ? InteractionResult.PASS : player.interactOn(entity, hand, location);
} }
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/multiplayer/ServerStatusPinger.java --- a/net/minecraft/client/multiplayer/ServerStatusPinger.java
+++ b/net/minecraft/client/multiplayer/ServerStatusPinger.java +++ b/net/minecraft/client/multiplayer/ServerStatusPinger.java
@@ -123,6 +_,7 @@ @@ -118,6 +_,7 @@
onPersistentDataChange.run(); onPersistentDataChange.run();
} }
}); });
@@ -8,12 +8,12 @@
this.pingStart = Util.getMillis(); this.pingStart = Util.getMillis();
connection.send(new ServerboundPingRequestPacket(this.pingStart)); connection.send(new ServerboundPingRequestPacket(this.pingStart));
this.success = true; this.success = true;
@@ -179,7 +_,7 @@ @@ -174,7 +_,7 @@
private void pingLegacyServer( private void pingLegacyServer(
final InetSocketAddress resolvedAddress, final ServerAddress rawAddress, final ServerData data, final EventLoopGroupHolder eventLoopGroupHolder final InetSocketAddress resolvedAddress, final ServerAddress rawAddress, final ServerData data, final EventLoopGroupHolder eventLoopGroupHolder
) { ) {
- new Bootstrap().group(eventLoopGroupHolder.eventLoopGroup()).handler(new ChannelInitializer<Channel>() { - new Bootstrap().group(eventLoopGroupHolder.eventLoopGroup()).handler(new ChannelInitializer<Channel>() {
+ new Bootstrap().group(eventLoopGroupHolder.eventLoopGroup(true)).handler(new ChannelInitializer<Channel>() { + new Bootstrap().group(eventLoopGroupHolder.eventLoopGroup(true)).handler(new ChannelInitializer<Channel>() {
{ @Override
Objects.requireNonNull(ServerStatusPinger.this); protected void initChannel(final Channel channel) {
} try {
Loaded 100 of 697 files, more files were not shown because too many files have changed in this diff. Show more