Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RenderGuiLayerEvent.Pre#isGoingToRender(), allowing to determine whenever layer is actually going to render on screen #1505

Open
wants to merge 3 commits into
base: 1.21.x
Choose a base branch
from

Conversation

DBotThePony
Copy link
Contributor

@DBotThePony DBotThePony commented Aug 31, 2024

Additionally, adds new RegisterGuiLayersEvent API methods, allowing to specify own "rendering condition" which is visible to other mods in isGoingToRender()

Introduces no breaking changes, everything that is declared as public API is binary compatible.

From #neoforge-github:

what's the usecase of having this isGoingToRender parameter?

Not duplicating logic regarding whenever hud element is actually rendered
Currently, all hud elements are firing this event
Even if they render nothing
E.g. Hunger layer event is still fired if player is in creative, so mod makers have to duplicate vanilla logic in their event listener to check separately if they actually need to draw their hunger bar replacement or similar
This check differ a little from version to version, which also creates error prone situations during mod porting
And as well it all being not very intuitive at first that layer events are called even if player have pressed F1

This PR creates middle ground, events continue to get called, so mods depending on this behavior don't get broken, while also addressing issue regarding checking if layer has actually rendered anything without duplicating logic
I have no idea why this havent been merged yet

…whenever layer is actually going to render on screen

Additionally, adds new RegisterGuiLayersEvent API methods, allowing to specify own "rendering condition" which is visible to other mods in isGoingToRender()
@CLAassistant
Copy link

CLAassistant commented Aug 31, 2024

CLA assistant check
All committers have signed the CLA.

@neoforged-pr-publishing
Copy link

  • Publish PR to GitHub Packages

@sciwhiz12 sciwhiz12 added enhancement New (or improvement to existing) feature or request 1.21.1 Targeted at Minecraft 1.21.1 labels Aug 31, 2024
@neoforged-compatibility-checks
Copy link

neoforged-compatibility-checks bot commented Aug 31, 2024

@DBotThePony, this PR introduces breaking changes.
Fortunately, this project is currently accepting breaking changes, but if they are not intentional, please revert them.
Last checked commit: 5810b19b239990c18f982b7ea97a3cd074bd6533.

neoforge (:neoforge)

  • net/neoforged/neoforge/client/event/RenderGuiLayerEvent$Pre
    • <init>(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/client/DeltaTracker;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/client/gui/LayeredDraw$Layer;)V: ⚠ Method was lowered in visibility
  • net/neoforged/neoforge/client/event/RenderGuiLayerEvent$Post
    • <init>(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/client/DeltaTracker;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/client/gui/LayeredDraw$Layer;)V: ⚠ Method was lowered in visibility
  • net/neoforged/neoforge/client/gui/GuiLayerManager$NamedLayer
    • <init>(Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/client/gui/LayeredDraw$Layer;)V: ❗ API method was removed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.21.1 Targeted at Minecraft 1.21.1 enhancement New (or improvement to existing) feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants