Jump to content

Recommended Posts

Posted (edited)

I made my HUD in RenderGameOverlayEvent.Post. All the renders, but when I take a thing in hand, the name of item appears at the bottom of the screen, and at that moment the HUD does not render. How to fix it?

Edited by Minebot1708
Posted (edited)
12 minutes ago, Earthcomputer said:

Any code to help us answer?

In EventHandler:

    final Minecraft mc = Minecraft.getMinecraft();
    final FontRenderer font = Minecraft.getMinecraft().fontRendererObj;
    final ImplantsHUD implantsHUD = new ImplantsHUD();

	@SubscribeEvent
    public void renderHUD(RenderGameOverlayEvent e){
            GlStateManager.pushMatrix();
            int x = (e.getResolution().getScaledWidth() - 109) / 7;
            int y = (e.getResolution().getScaledHeight() - 290) / 2;
            GlStateManager.translate(x, y, 0);
            implantsHUD.draw(mc, font, 0);
            GlStateManager.popMatrix();
    }

 

HUD class:

public class ImplantsHUD extends Gui{

    public void draw(Minecraft mc, FontRenderer font, int voltage){
        GlStateManager.pushMatrix();
        GlStateManager.enableAlpha();
        GlStateManager.enableBlend();
        GlStateManager.alphaFunc(GL_GREATER, 0.05f);
        GlStateManager.color(1,1,1,0.75f);
        GlStateManager.blendFunc(GL_DST_COLOR, GL_ONE_MINUS_SRC_COLOR);

        mc.getTextureManager().bindTexture(new ResourceLocation("meem:textures/gui/implantshud/energybackground.png"));
        drawModalRectWithCustomSizedTexture(0, 0, 0,0,109,290,109,290);

        font.drawString("Energy", 30, -20, 1606345);
        font.drawString(voltage == 0 ? "Not charging" : voltage + " Volt", 10, 300, voltage == 0 ? 13107200 : 51200);
        GlStateManager.disableBlend();
        GlStateManager.popMatrix();
    }
}

 

Edited by Minebot1708
Posted
18 minutes ago, diesieben07 said:
  • You are not actually using RenderGameOverlayEvent.Post, but you should be.
  • You need to check for one element type, otherwise you render once for every HUD element...

I just tested, so enderGameOverlayEvent.Post is not worth it. But there is no difference, the problem still does not change. I changed the code. Now the HUD does not appear at all

    @SubscribeEvent
    public void renderHUD(RenderGameOverlayEvent.Post e){
        if (e.getType() == RenderGameOverlayEvent.ElementType.HOTBAR) {
            GlStateManager.pushMatrix();
            int x = (e.getResolution().getScaledWidth() - 109) / 7;
            int y = (e.getResolution().getScaledHeight() - 290) / 2;
            GlStateManager.translate(x, y, 0);
            implantsHUD.draw(mc, font, 0, 100, 0);
            GlStateManager.popMatrix();
        }
    }

 

Posted
18 minutes ago, diesieben07 said:

Is the method actually called? Are you sure those coordinates are correct and on-sceen?

The method is called. If the coordinates are considered relative to the upper left edge of the window, then they are correct

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.

Announcements



×
×
  • Create New...

Important Information

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