Jump to content

[1.15.2] Issue Rendering Item Overlay in GUI


Haydenman2

Recommended Posts

Howdy y'all,

 

I'm trying to use GL scaling to render small versions of text on a custom-rendered ItemStack, however, this is not working nearly how I want it to. It's very close, however, the text is appearing behind the stack. Any idea why?

@Override
		protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
			super.drawGuiContainerForegroundLayer(mouseX, mouseY);
			
			if(tsfm.storedItem == null) {
				this.font.drawString("Empty", 52, 13, 0xffffff);
			}else {
				this.font.drawString(tsfm.storedItem.getName().getFormattedText(), 52, 13, 0xffffff);
				if(tsfm.internalStored < 10_000_000) {
					this.font.drawString("Stored: " + Formatting.GENERAL_FORMAT.format(tsfm.internalStored), 52, 25, 0xd4d4d4);
				}else {
					this.font.drawString("Stored: " + SCINOT.format(tsfm.internalStored), 52, 25, 0xd4d4d4);
				}
				
				RenderSystem.pushMatrix();
				
				RenderSystem.scalef(0.5f, 0.5f, 0.5f);
				this.itemRenderer.renderItemOverlayIntoGUI(this.font, tsfm.storedItem.getDefaultInstance(), (25)*2, (68)*2, "Hello!");
				
				RenderSystem.popMatrix();
				
			}
			
			
			
		}
		
		@Override
		protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
			super.drawGuiContainerBackgroundLayer(partialTicks, mouseX, mouseY);
			
			int x = (this.width - this.xSize) / 2;
			int y = (this.height - this.ySize) / 2;
			if(tsfm.storedItem != null) {
				
				
				this.itemRenderer.renderItemIntoGUI(tsfm.storedItem.getDefaultInstance(), (x+17), (y+60));
			}
			
		}

 

I have tested it, and rendering ItemOverlayIntoGUI works correctly and places on top of the item as proper when scaling is not involved.

 

EDIT: I actually got it all worked out. Thank you.

Capture.PNG

Edited by Haydenman2

...

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.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.