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.

[SOLVED][1.16.x] RenderGameOverlayEvent - Missing vanilla texture coordinates

Featured Replies

Posted

Hello everybody,

 

i need your help. I render a custom screen in Minecraft with the RenderGameOverlayEvent, but the Armor Bar and Food Bar lose their texture coordinates.

Is that a bug or am I doing something wrong?

 

Event-Handler:

@Mod.EventBusSubscriber
public class GuiEvents
{
    @SubscribeEvent
    public static void renderGUI(RenderGameOverlayEvent.Post event)
    {
        new PlayerDataScreen(Minecraft.getInstance(), event.getMatrixStack());
    }
}

 

Screen:

public class PlayerDataScreen extends IngameGui
{
    public PlayerDataScreen(Minecraft mcIn, MatrixStack matrixStack)
    {
       	super(mcIn);
        StringTextComponent textComponent = new StringTextComponent("");
        textComponent.func_240699_a_(TextFormatting.GOLD);
        textComponent.func_230529_a_(new StringTextComponent(",").func_240699_a_(TextFormatting.WHITE));
        textComponent.func_230529_a_(new StringTextComponent("").func_240699_a_(TextFormatting.DARK_GRAY));
        textComponent.func_230529_a_(new StringTextComponent(",").func_240699_a_(TextFormatting.WHITE));
        textComponent.func_230529_a_(new StringTextComponent("").func_240699_a_(TextFormatting.DARK_RED));

        this.getFontRenderer().func_243246_a(matrixStack, textComponent, 15,15, 16);
    }
}

 

Result:

 

0.PNG

Edited by DestroyedAdventure

  • Author
17 minutes ago, diesieben07 said:

You must check the element type when subscribing to RenderGameOverlayEvent (RenderGameOverlayEvent#getType), otherwise your code will run many times every frame - for every part of the HUD that is being drawn. For simply adding to the HUD, use ElementType.ALL.

 

Why on earth are you extending IngameGui? This makes no sense.

I changed this in the Event-Handler and the PlayerDataScreen extending now from the AbstractGui Class (Is this the right class? Or should I choose the ForgeIngame class?). But it works perfectly :)

 

49 minutes ago, diesieben07 said:

Why are you drawing stuff inside a constructor? This makes no sense.

I cant find any methode to override for drawing content :/ Im stupid :D and it's really hard with obfuscated names :/

 

21 minutes ago, diesieben07 said:

The last two points I think I have seen before. Are you following a tutorial?

Nope, i'm studying alone :D 

i have a question @diesieben07, can you speak german?^^

  • Author
1 hour ago, diesieben07 said:

Make your own? Please learn basic Java.

 

Yes.

War der Meinung, dass es in einer älteren Version von Forge/Minecraft eine Methode zum rendern von Elementen gab, die überschrieben wurde. Hätte ja sein können, dass es die noch gibt oder ich verwechsle da was🤔. Das letzte mal habe ich mich mit Minecraft Forge Modding 2013 beschäftigt :D . Hab jetzt eine eigene Methode geschrieben, die aufgerufen wird. Danke für die Hilfe! Funktioniert! :) 

  • Author
3 hours ago, diesieben07 said:

Please keep this forum in English.

Sorry, but my text is irrelevant to others.

 

It contains neither solutions or problems and was addressed to you. I thought it wouldn't be a problem if it was written in German.

 

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.