Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.17.1] Render a block texture on screen


Nicknotname
 Share

Recommended Posts

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
Link to comment
Share on other sites

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

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

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.

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

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.