Jump to content

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


Recommended Posts

Posted (edited)

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
Posted
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?^^

Posted
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! :) 

Posted
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...

×   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.