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.

[ solved ] - HUD images (exp bar, health, hunger, etc.) glitching out.

Featured Replies

Posted

Hello,

 

For some reason whenever I activate my HUD for my mod in survival and adventure mode, the text displays fine, but the HUD ( exp bar, health, hunger, etc. ) displays in glitched out white boxes. I'm not sure what's causing this, because I'm not using / editing any textures. I'm just drawing strings on the screen. Do you know what the issue is? ( There is no error in the console either, if you were wondering. )

 

4fVb8.png

 

package ws.mods.wsessentials.overlay;

import java.awt.FontMetrics;
import java.awt.Graphics;

import org.lwjgl.input.Keyboard;

import ws.mods.wsessentials.keybinds.HideHUD;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.event.EventPriority;
import net.minecraftforge.event.ForgeSubscribe;

public class PositionOverlay extends Gui{

private final Minecraft mc;

public PositionOverlay(Minecraft mc){
	super();
	this.mc = mc;
}

@ForgeSubscribe(priority = EventPriority.NORMAL)
public void onRenderPosition(RenderGameOverlayEvent e){
	ScaledResolution res = new ScaledResolution(mc.gameSettings,
			mc.displayWidth, mc.displayHeight);
	FontRenderer fontRender = mc.fontRenderer;
	int width = res.getScaledWidth();
	int height = res.getScaledHeight();
	EntityPlayer p = mc.getMinecraft().thePlayer;
	double xPos = p.posX;
	double yPos = p.posY - 1;
	double zPos = p.posZ;
	mc.entityRenderer.setupOverlayRendering();

	String versionNumber = "Minecraft 1.6.2";
	String x = "" + xPos;
	int xIndex = x.indexOf(".");
	if (xIndex != -1){
		x = x.substring(0, xIndex);
	}
	String y = "" + yPos;
	int yIndex = y.indexOf(".");
	if (yIndex != -1){
		y = y.substring(0, yIndex);
	}
	String z = "" + zPos;
	int zIndex = z.indexOf(".");
	if (zIndex != -1){
		z = z.substring(0, zIndex);
	}
	String xPOS = "x " + x;
	String yPOS = "y " + y;
	String zPOS = "z " + z;
	String entities = mc.getEntityDebug().replace("E:", "e");
	int entIndex = entities.indexOf(".");
	if (entIndex != -1){
		entities = entities.substring(0, entIndex);
	}
	String fps = mc.debug;
	int fpsIndex = fps.indexOf(",");
	if (fpsIndex != -1){
		fps = fps.substring(0, fpsIndex);
	}
	String f3Mode = "HUD disabled due to debug menu.";
	int xVN = 2;
	int xE = res.getScaledWidth() - fontRender.getStringWidth(fps) - 2;
	int xE2 = res.getScaledWidth() - fontRender.getStringWidth(entities) - 2;
	int xDis = res.getScaledWidth() - fontRender.getStringWidth(f3Mode) - 10;
	int yVN = 2;
	int yP1 = 12;
	int yP2 = 22;
	int yP3 = 32;
	int yP4 = 82;
	int colour = 0xFFFFFF;
	if (this.mc.gameSettings.showDebugInfo && HideHUD.hasOpenedGUI == false){
		// Yay, empty line! Woo! *enthusiasm explosion*
	} else if (this.mc.gameSettings.showDebugInfo){
		fontRender.drawStringWithShadow(f3Mode, xDis, yP4, colour);
	} else if(HideHUD.hasOpenedGUI == false){
		// Empty lines are for re re's. Oh wait...
	} else {
		fontRender.drawStringWithShadow(versionNumber, xVN, yVN, colour);
		fontRender.drawStringWithShadow(xPOS, xVN, yP1, colour);
		fontRender.drawStringWithShadow(yPOS, xVN, yP2, colour);
		fontRender.drawStringWithShadow(zPOS, xVN, yP3, colour);
		fontRender.drawStringWithShadow(fps, xE, yVN, colour);
		fontRender.drawStringWithShadow(entities, xE2, yP1, colour);
	}
}

}

If you are only drawing strings, use RenderGameOverlayEvent.Text.

And add your strings to the lists.

  • 6 years later...
  • Guest locked this topic
Guest
This topic is now closed to further replies.

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.