neoforged / NeoForge

Neo Modding API for Minecraft, based on Forge
https://projects.neoforged.net/neoforged/neoforge
Other
1.21k stars 177 forks source link

[1.21] Registering too many GUI layers causes some to be invisible #1400

Closed embeddedt closed 2 months ago

embeddedt commented 3 months ago

Minecraft Version: 1.21

NeoForge Version: 21.0.112-beta

Description of issue:

Presumably due to the LayeredDraw system using a fixed Z separation of 200 units between layers, adding enough layers causes the top ones to become invisible.

To reproduce, add a loop like below to any mod that renders a custom GUI layer and run it standalone. The modded layer will be invisible.

private void onRegisterGuiLayers(RegisterGuiLayersEvent event) {
    // Register some placeholder layers
    for(int i = 0; i < 50; i++) {
        event.registerAboveAll(ResourceLocation.fromNamespaceAndPath(MOD_ID, "fake_" + i), new LayeredDraw.Layer() {
            @Override
        public void render(GuiGraphics guiGraphics, DeltaTracker deltaTracker) {

        }
        });
    }
    // Register the real layer
    event.registerAboveAll(ResourceLocation.fromNamespaceAndPath(MOD_ID, "hud"), new ModdedHUDRenderLayer());
}
KyBeeS commented 2 months ago

Issue is occurring again in current release of all the mods 10. We're having issues reproducing it with other mod combinations and it's seemingly random. Seems it may be a neoforge issue but we're not sure

XFactHD commented 2 months ago

I can reproduce the issue in both ATM10 and a dev environment. I have opened a separate issue for it, see #1504 for more details