Jump to content

[1.11] Why is my gui texture randomly being replaced by the alphabet...?


Eria8

Recommended Posts

This is the weirdest problem I've ever had  when modding.

I'm trying to make a gui that renders text over a texture in the corner of the screen.

There are four parts of the texture that I'm rendering separately, since if the player doesn't have something I don't want that part to render.

It all works perfectly, except the third and fourth parts SOMEHOW are losing my texture and instead it's rendering what looks like the default Minecraft font texture at more than double resolution?


Pictures:

Spoiler

This is what it looks like:

j0w5kj.jpg

 

This is what it's SUPPOSED to look like (texture from gimp; not to scale, with added background so you can see it):

11cgojb.jpg

 

And this is the code:

	@SubscribeEvent
	public void onRenderGui(RenderGameOverlayEvent.Post event)
	{
		if (event.getType() != ElementType.EXPERIENCE)
		{
			return;
		}
		IEchoesCapability echoes = mc.thePlayer.getCapability(EchoesManager.ECHOES, null);

		if (echoes == null)
		{
			return;
		}

		this.mc.getTextureManager().bindTexture(hud);

		int y = 0;
		int y1 = 4;

		if (echoes.getEchoes() > 0) // The rune-like symbol. Works.
		{
			this.drawTexturedModalRect(1, y, 0, 0, 136, 29);
			drawString(mc.fontRendererObj, TextFormatting.WHITE + "" + echoes.getEchoes(), 16, y1, colour);

			y += 30;
			y1 += 15;
		}
		if (echoes.getInsight() > 0) // The eye symbol. Works.
		{
			this.drawTexturedModalRect(1, y, 0, 29, 136, 29);
			drawString(mc.fontRendererObj, TextFormatting.WHITE + "" + echoes.getInsight(), 16, y1, colour);

			y += 30;
			y1 += 15;
		}

		int bullets = 0;

		for (ItemStack stack : mc.thePlayer.inventory.mainInventory)
		{
			if (stack.getItem() == Registry.quickSilverBullet)
			{
				bullets += stack.func_190916_E();
			}
		}

		if (bullets > 0) // The bullet symbol. Does NOT work, renders alphabet instead.
		{
			this.drawTexturedModalRect(1, y, 0, 58, 91, 29);
			// TODO draw amount

			y += 30;
			y1 += 15;
		}

		if (echoes.getCords() > 0) // The spiral-like symbol. Does NOT work, renders alphabet instead.
		{
			this.drawTexturedModalRect(1, y, 0, 87, 91, 29);
			if (echoes.getCords() >= 3)
			{
				// TODO alternate cords icon
			}
			// TODO draw amount

			y += 30;
			y1 += 15;
		}

		if (echoes.hasAsh())
		{
			// TODO alternate bullet icon
		}
	}

 

How on earth does this happen and how do I fix it?

 

And for the record, I tried adding:

		this.mc.getTextureManager().bindTexture(hud);

pretty much anywhere before it starts displaying the alphabet to try to fix it, but the result is that what ever drawTexturedModalRect() came next just doesn't get called at all.

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.