Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

  • Author
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

  • Author
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();
        }
    }

 

  • Author
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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.