Posted July 10, 20169 yr 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.*; @SideOnly(Side.CLIENT) 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(); } @SubscribeEvent public void drawXPBarPost(RenderGameOverlayEvent.Pre e) { if(e.getType() == ElementType.EXPERIENCE) { e.setCanceled(true); ScaledResolution sRes = new ScaledResolution(mc); int xPos = (sRes.getScaledWidth() - 182) / 2, yPos = sRes.getScaledHeight() - 32 + 3; mc.getTextureManager().bindTexture(TEXTURE); GlStateManager.pushAttrib(); GlStateManager.color(1F, 1F, 1F); GlStateManager.enableAlpha(); GlStateManager.enableBlend(); 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); GlStateManager.popAttrib(); } } } I restarted the game and now the chat is black, but not the backgrounds. When the event isn't canceled, everything renders fine. Kain
July 10, 20169 yr 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.
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.