Jump to content

[1.9.4] Rendering Overlay Turns Things Black


Recommended Posts

Whenever I render my overlay, the background when opening the inventory or going to the menu is pitch black.


Render Code:

package tlhpoe.scalae.handler;

import org.lwjgl.opengl.*;

import net.minecraft.client.*;
import net.minecraft.client.gui.*;
import net.minecraft.client.renderer.*;
import net.minecraft.util.*;
import net.minecraftforge.client.event.*;
import net.minecraftforge.client.event.RenderGameOverlayEvent.*;
import net.minecraftforge.fml.common.eventhandler.*;
import net.minecraftforge.fml.common.gameevent.*;
import net.minecraftforge.fml.common.gameevent.TickEvent.*;
import net.minecraftforge.fml.relauncher.*;
import tlhpoe.scalae.*;
import tlhpoe.scalae.capabilities.*;

public class ScalaeClientEvents extends Gui {
private static final ResourceLocation TEXTURE = new ResourceLocation(Scalae.MODID, "textures/gui/xp_bar.png");

private Minecraft mc;

public ScalaeClientEvents() {
	this.mc = Minecraft.getMinecraft();

public void drawXPBarPost(RenderGameOverlayEvent.Pre e) {
	if(e.getType() == ElementType.EXPERIENCE) {

		ScaledResolution sRes = new ScaledResolution(mc);

		int xPos = (sRes.getScaledWidth() - 182) / 2, yPos = sRes.getScaledHeight() - 32 + 3;


		GlStateManager.color(1F, 1F, 1F);


		drawTexturedModalRect(xPos, yPos, 0, 0, 182, 5);

		int width = (int) (182 * ((float) ClientProxy.PLAYER_XP / (float) ScalaeCapabilities.getXPRequired(ClientProxy.PLAYER_LEVEL)));

		drawTexturedModalRect(xPos, yPos, 0, 5, width, 5);

		String s = "" + ClientProxy.PLAYER_LEVEL;

		xPos = (sRes.getScaledWidth() - mc.fontRendererObj.getStringWidth(s)) / 2;
		yPos -= 6;

		mc.fontRendererObj.drawString(s, xPos + 1, yPos, 0);
		mc.fontRendererObj.drawString(s, xPos - 1, yPos, 0);
		mc.fontRendererObj.drawString(s, xPos, yPos + 1, 0);
		mc.fontRendererObj.drawString(s, xPos, yPos - 1, 0);
		mc.fontRendererObj.drawString(s, xPos, yPos, 0xFFF600);





I restarted the game and now the chat is black, but not the backgrounds.



When the event isn't canceled, everything renders fine.


Link to comment
Share on other sites

You have to revert GL states to original (pre-event). Also - just because you are not directly changing states doesn't mean they are not different than they are supposed to (I am talking about cancelling event). Analyze place where particular Type of event is fired and make sure you have GL states correctly set. I wouldn't really trust push/pop Attribs.


Also: event.getScaledResolution() ;p (or something like that).

1.7.10 is no longer supported by forge, you are on your own.

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.

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.