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

[1.12.2] Display texture over screen


Nick82285
 Share

Recommended Posts

My goal is to display a texture on the screen with transparency and at a certain position. This has been a challenge because the default function Minecraft.ingameGUI.drawTexturedModalRect only shows part of the texture. What's wrong and is there any way to mitigate this?

 

@SubscribeEvent
	public void doTheOtherThing(RenderTickEvent event) {

		Minecraft mc = Minecraft.getMinecraft();
		ScaledResolution scaledRes = new ScaledResolution(mc);

		mc.getTextureManager().bindTexture(new ResourceLocation("xpsystem:textures/gui/xp_bar.png"));

		mc.ingameGUI.drawTexturedModalRect(scaledRes.getScaledWidth() / 2, scaledRes.getScaledHeight() / 2, 0, 0, 59,
				8);
	}

 

Here's what I've got so far... https://imgur.com/a/9GAZVt7 (I can't upload images on here except for imgur for some reason).

 

Sidenote: when I use anything but the RenderGameOverlayEvent and I bind the texture it, it binds the texture to the hearts and the hunger bar removing them and turning them into a red bar like the texture.

 

The Texture:

xp_bar.png.42a84ad805781a0ecc337661e9a279ec.png

 

Edited by Nick82285
Link to comment
Share on other sites

2 minutes ago, Nick82285 said:

Minecraft.ingameGUI.drawTexturedModalRect only shows part of the texture.

what do you mean by this?

3 minutes ago, Nick82285 said:

Sidenote: when I use anything but the RenderGameOverlayEvent and I bind the texture it, it binds the texture to the hearts and the hunger bar removing them and turning them into a red bar like the texture.

You have to bind it back to the one the minecraft renderer expects it to be (from memory its GuiIngameForge.ICONS)

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

7 minutes ago, Nick82285 said:

It seems to only display the top left pixel of the texture, I would like to display the entire texture.

14 minutes ago, Nick82285 said:

mc.ingameGUI.drawTexturedModalRect(scaledRes.getScaledWidth() / 2, scaledRes.getScaledHeight() / 2, 0, 0, 59, 8);

It's drawing at the middle of the screen from 0,0 to 59,8. Do you want it to draw something else?

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

1 minute ago, Nick82285 said:

The 0,0 is the place in the texture where I want to start and 59, 8 is the position that I want to stop.

Look at the parameters of the method, they are (xCoord, yCoord, minU, minV, maxU, maxV).

You probably want something like drawTexturedModalRectWithCustomSize(x, y, u, v, width, height, textureWidth, textureHeight)

Edited by Cadiboo

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

17 minutes ago, Cadiboo said:

Look at the parameters

 

mc.ingameGUI.drawTexturedModalRect(x, y, textureX, textureY, width, height);
mc.ingameGUI.drawTexturedModalRect(scaledRes.getScaledWidth() / 2, scaledRes.getScaledHeight() / 2, 0, 0, 59, 8);

 

The width is 59, the height is 8, and it starts analyzing the texture at (0, 0)

The position is centered on the screen.

 

It just seems to stretch 1 pixel in a 59x8 rectangle, not scale the texture. 

Edited by Nick82285
Link to comment
Share on other sites

1 minute ago, Nick82285 said:

drawTexturedModalRect

expects the texture to be 256x256

17 minutes ago, Cadiboo said:

You probably want something like drawTexturedModalRectWithCustomSize(x, y, u, v, width, height, textureWidth, textureHeight)

 

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

12 hours ago, Nick82285 said:

Sidenote: when I use anything but the RenderGameOverlayEvent and I bind the texture it, it binds the texture to the hearts and the hunger bar removing them and turning them into a red bar like the texture.

You should use RenderGameOverlayEvent, it is the correct event to draw HUD elements. You have to bind the Gui.ICONS texture if you change it during this event. Also make sure to use the event correctly.

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.