Jump to content

[1.16] Quick question about rendering a small HUD sprite


Tavi007

Recommended Posts

Hello. I want to render a small texture for a HUD. I currently have this for testing prupose:

	@SubscribeEvent
	public static void displayData(RenderGameOverlayEvent.Post event) {
		if(event.getType().equals(RenderGameOverlayEvent.ElementType.ALL)) {
			Minecraft mc = Minecraft.getInstance();
			MatrixStack matrixStack = event.getMatrixStack();

			mc.getTextureManager().bindTexture(new ResourceLocation("elementalcombat", "textures/icons/fire.png"));

			matrixStack.push();
			matrixStack.scale(0.1F, 0.1F, 0.1F);
			mc.ingameGUI.blit(matrixStack, 0, 0, 0, 0, 256, 256);     
	        matrixStack.pop();
			
	        mc.getTextureManager().bindTexture(AbstractGui.GUI_ICONS_LOCATION);	 
		}
	}

 

The image gets rendered, but I have few issues.
1. If I don't scale the matrixstack, the image is gigantic and takes up the full left side of the screen.
2. If I don't set the uWidth or vHeight to 256, only parts of the texture gets rendered.

This is weird, cause the sprite has the size of 7x7 px. Why is the sprite ingame so gigantic and also exceed the 7x7 size? If I change my ResourceLocation to GUI_ICONS_LOCATION and disable the scaling, the rendered sprite has the normal size, that I would expect from it.

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.