Jump to content

How to render textures in screen guis?


Soulvenom

Recommended Posts

The docs on this are quite badly explained, so I hope someone will answer me here. I basically have a gui, which should look like a book, so I want to draw a background that looks like one. The docs tell me to use the blit function but not really more and it doesn't seem to be self explanatory at all (After all I had the choice between a 7 year old video explaining the now severely outdated syntax and a 1 year old video titled "Minecraft 1.16.5 : #6 รับเควสจากทางบ้าน สอนเขียน GuiScreen" in which the creator tries to create a "p**n book" but severely and utterly fails doing so over the next 53 minutes).

I have set up the code for my screen and put following four lines into the render method: 

renderBackground(pPoseStack);
Minecraft.getInstance().getTextureManager().bindForSetup(new ResourceLocation("mcaquests", "textures/gui/questbookgui.png"));
blit(pPoseStack, this.width / 2 - (420 / 2), this.height / 2 - (256 / 2), 0, 0, 420, 256, 420, 256);
super.render(pPoseStack, pMouseX, pMouseY, pPartialTick);

My texture is located at exactly 

Quote

src/main/resources/assets/mcaquests/textures/gui/questbookgui.png

It is exactly 420px wide and 256px high and I have done nothing code-wise to implement the texture besides the code I've shown here. Do I have to register the texture somewhere?

 

Upon opening the gui, which in theory works fine, I'm greeted with every vanilla minecraft hud overlay texture spread across my screen multiple times. (And upon the third time opening the gui my game crashes with the following exeption:)

Quote

Caused by: java.lang.NullPointerException: Cannot read field "level" because "this.minecraft" is null

Link to comment
Share on other sites

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.