Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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();
	}
}
}

 

1bf23d32e5504f83a47e1e404e5f7a80.png

 

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

21fda40ce3544e30b210f83e6a79bf3e.png

 

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

Kain

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.