Jump to content

Recommended Posts

Posted (edited)

If I had a block would there be a way of putting the block's texture into the GUI. For example putting the diamond block texture onto the top left corner of the screen. I know I can use RenderGameOverlayEvent.Post to render text but I could not work out how to render images?

Edit: I am using 1.17.1

Edited by Nicknotname
  • Nicknotname changed the title to [1.17.1] Render a block texture on screen
  • 2 weeks later...
Posted

Here is code and an explanation of how to draw to a screen.

PoseStack matrices = event.getMatrixStack();                                   // Just get a matrix stack
int x1 = 0, y1 = 0, x2 = 100, y2 = 100;                                        // Cooordinates to draw the texture at
ResourceLocation texture = new ResourceLocation("mod", "path/to/texture.png"); // Texture
RenderSystem.setShaderTexture(0, texture);                                     // Bind texture
Gui.blit(matrices, x1, y1, x1, y1, x2, y2, x2, y2);                            // Render texture

Hope this helps :)

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.