From b8e0333020d731756f2115a7b81d63d3cb1a4fa4 Mon Sep 17 00:00:00 2001 From: FiniteReality Date: Mon, 9 Dec 2024 09:33:56 +0000 Subject: [PATCH] Remove no-op method for enabling depth, pass desired width/height --- .../blaze3d/pipeline/MainTarget.java.patch | 10 ++++--- .../neoforge/client/ClientHooks.java | 4 +-- .../event/ConfigureMainRenderTargetEvent.java | 30 ++++++++++++++----- 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/patches/com/mojang/blaze3d/pipeline/MainTarget.java.patch b/patches/com/mojang/blaze3d/pipeline/MainTarget.java.patch index 7e4a944801..4bc19bd147 100644 --- a/patches/com/mojang/blaze3d/pipeline/MainTarget.java.patch +++ b/patches/com/mojang/blaze3d/pipeline/MainTarget.java.patch @@ -1,18 +1,20 @@ --- a/com/mojang/blaze3d/pipeline/MainTarget.java +++ b/com/mojang/blaze3d/pipeline/MainTarget.java -@@ -16,7 +_,11 @@ +@@ -16,8 +_,12 @@ static final MainTarget.Dimension DEFAULT_DIMENSIONS = new MainTarget.Dimension(854, 480); public MainTarget(int p_166137_, int p_166138_) { - super(true); -+ this(net.neoforged.neoforge.client.ClientHooks.configureMainRenderTarget(), p_166137_, p_166138_); +- this.createFrameBuffer(p_166137_, p_166138_); ++ this(net.neoforged.neoforge.client.ClientHooks.configureMainRenderTarget(true, p_166137_, p_166138_)); + } + -+ private MainTarget(net.neoforged.neoforge.client.event.ConfigureMainRenderTargetEvent e, int p_166137_, int p_166138_) { ++ private MainTarget(net.neoforged.neoforge.client.event.ConfigureMainRenderTargetEvent e) { + super(e.useDepth(), e.useStencil()); - this.createFrameBuffer(p_166137_, p_166138_); ++ this.createFrameBuffer(e.width(), e.height()); } + private void createFrameBuffer(int p_166142_, int p_166143_) { @@ -30,13 +_,24 @@ GlStateManager._texParameter(3553, 10242, 33071); GlStateManager._texParameter(3553, 10243, 33071); diff --git a/src/main/java/net/neoforged/neoforge/client/ClientHooks.java b/src/main/java/net/neoforged/neoforge/client/ClientHooks.java index d5ba4239b3..b773fcae05 100644 --- a/src/main/java/net/neoforged/neoforge/client/ClientHooks.java +++ b/src/main/java/net/neoforged/neoforge/client/ClientHooks.java @@ -1102,8 +1102,8 @@ public static Map gatherMaterialAtlases(Map< return Map.copyOf(vanillaAtlases); } - public static ConfigureMainRenderTargetEvent configureMainRenderTarget() { - var e = new ConfigureMainRenderTargetEvent(); + public static ConfigureMainRenderTargetEvent configureMainRenderTarget(boolean useDepth, int width, int height) { + var e = new ConfigureMainRenderTargetEvent(useDepth, width, height); ModLoader.postEvent(e); return e; } diff --git a/src/main/java/net/neoforged/neoforge/client/event/ConfigureMainRenderTargetEvent.java b/src/main/java/net/neoforged/neoforge/client/event/ConfigureMainRenderTargetEvent.java index c4bc57ad89..805092c02e 100644 --- a/src/main/java/net/neoforged/neoforge/client/event/ConfigureMainRenderTargetEvent.java +++ b/src/main/java/net/neoforged/neoforge/client/event/ConfigureMainRenderTargetEvent.java @@ -23,13 +23,19 @@ * This event is fired on the mod-speciffic event bus, only on the {@linkplain LogicalSide#CLIENT logical client}. */ public class ConfigureMainRenderTargetEvent extends Event implements IModBusEvent { - private boolean useDepth; + private final boolean useDepth; private boolean useStencil; + private final int width; + private final int height; + @ApiStatus.Internal - public ConfigureMainRenderTargetEvent() { - this.useDepth = true; + public ConfigureMainRenderTargetEvent(boolean useDepth, int width, int height) { + this.useDepth = useDepth; this.useStencil = false; + + this.width = width; + this.height = height; } /** @@ -51,13 +57,21 @@ public boolean useStencil() { } /** - * Enable the depth buffer for the main render target. + * Returns the preferred width of the framebuffer. * - * @return this, for method chaining. + * @return The width, in pixels, to attempt to use for the framebuffer. */ - public ConfigureMainRenderTargetEvent enableDepth() { - this.useDepth = true; - return this; + public int width() { + return this.width; + } + + /** + * Returns the preferred height of the framebuffer. + * + * @return The height, in pixels, to attempt to use for the framebuffer. + */ + public int height() { + return this.height; } /**