Jump to content

[1.19 - 1.20] User defined HUD element is being drawn over the top of vanilla elements


Capricocious

Recommended Posts

I have a custom IGuiOverly defined to show the players hydration levels. Preferably, I would like it to appear between the hunger level tracker and the air bubble tracker. Currently I have manually positioned it above hunger with the RenderSystem and the GuiGraphics.blit method and it is just being drawn on top of the air tracker if a player submerges themselves.

    public static final IGuiOverlay HUD_THIRST = ((gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
        int x = screenWidth / 2;
        int y = screenHeight;

        RenderSystem.setShader(GameRenderer::getPositionTexShader);
        RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
        RenderSystem.setShaderTexture(0, EMPTY_THIRST);

        for(int i = 0; i < 10; i++) {
            guiGraphics.blit(EMPTY_THIRST, x + 8 + (i * 8), y -51, 0, 0, 13, 12,
                    13, 12);
        }

        RenderSystem.setShaderTexture(0, FILLED_THIRST);

        for(int i = 0; i < 10; i++) {
            if(ClientThirstData.get() > i) {
                guiGraphics.blit(FILLED_THIRST, x + 8 + (i * 8), y -51, 0, 0, 13, 12,
                        13, 12);
            } else {
                break;
            }
        }
    });

Is there a way to bump the air bubble tracker up a few few pixels or make my GUI overlay known to the vanilla classes to prevent overlapping?

I'm the CEO of breaking things 

Link to comment
Share on other sites

Notes for self and anyone else it might help:

the main forge event bus has several screen-related events, the vanilla Minecraft code also has an event for 'RenderGuiOverlayEvent' (Pre and Post), may be able to insert status bar as the vanilla gui is rendered and potentially manipulate gui elements from there.

Edited by Capricocious
typo

I'm the CEO of breaking things 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.