Jump to content

Recommended Posts

Posted

Greetings! 

I wish to create an overlay, similar to the vanilla hotbar, which will display images inside it's slots. The user will be able to scroll trough the hotbar.

I would like to know where I may learn about the GUI system, how to use it, and ultimately, how to implement the overlay. 

Any help would be greatly appreciated.

Posted
4 minutes ago, diesieben07 said:

Look at OverlayRegistry to register your own HUD element. See ForgeIngameGui for how the existing ones are implemented.

Hello! 

I believe that class is under a different name (I am unable to find it). I am using forge 1.16.5 with the official mappings.

Posted
2 minutes ago, diesieben07 said:

Since you did not specify the Minecraft or Forge version I assumed you are using the most up to date, so 1.17.1.

In 1.16.5 use RenderGameOverlay.Post with ElementType.ALL to add stuff to the HUD.

@SubscribeEvent
public void renderGameOverlay(RenderGameOverlayEvent.Post event) {
    if(event.getType() != RenderGameOverlayEvent.ElementType.ALL) {
        return;
    }

    LOGGER.info("render!");
}

This seems to work. Thank you!

Posted
22 hours ago, diesieben07 said:

Since you did not specify the Minecraft or Forge version I assumed you are using the most up to date, so 1.17.1.

In 1.16.5 use RenderGameOverlay.Post with ElementType.ALL to add stuff to the HUD.

Do you know of any document explaining the parameters and what the methods do? I am very new to graphics programming, and understanding the code with obfuscated names is quite hard. I have been successful in copying and modifying vanilla code, but using it whilst not understanding it is unacceptable for me.

Posted

Without an even rudimentary understanding of the code, I cannot figure out why this does not work.

textureManager.bind(new ResourceLocation("mod:textures/overlay/bar.png"));
// ??
RenderSystem.enableBlend();
// extract image from bound texture (from x 0, y 0 with width 128, height 10) and draw it to screen starting from x 100, y 100
mc.gui.blit(matrix, 100, 100, 0, 0, 128, 10);
// ??
RenderSystem.disableBlend();

goPyiaf.png

ICeWEVc.png

Posted
7 hours ago, diesieben07 said:

Firstly, blit is a static method. Why are you calling it like an instance method? Your IDE should be warning you about this.

The version of blit you are using assumes a 256x256 texture. Is your texture that size?

I was not. It now works. But that still does not solve the fundamental issue. 

 

23 hours ago, matthew123 said:

Do you know of any document explaining the parameters and what the methods do? I am very new to graphics programming, and understanding the code with obfuscated names is quite hard. I have been successful in copying and modifying vanilla code, but using it whilst not understanding it is unacceptable for me.

Knowing the cause of the issue and fixing it myself will always be superior to getting help fixing it.

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.