Jump to content

XP bar rendering


Recommended Posts

I have written the following code to replace the Experience bar with a new XP/Magic bar for my mod however, all it renders is a black rectangle.


public class GuiXPMagicBar extends Gui 
private Minecraft mc = Minecraft.getMinecraft();

public void onRenderExperienceBar(RenderGameOverlayEvent event)
	if (event.type == ElementType.EXPERIENCE && !mc.thePlayer.isRidingHorse())

		if (this.mc.playerController.gameIsSurvivalOrAdventure())
			ScaledResolution scaledresolution = new ScaledResolution(this.mc, this.mc.displayWidth, this.mc.displayHeight);
	        int w = scaledresolution.getScaledWidth();
	        int h = scaledresolution.getScaledHeight();
            this.mc.getTextureManager().bindTexture(new ResourceLocation("immersion:textures/gui/magicbar.png"));
            int cap = this.mc.thePlayer.xpBarCap();

            if (cap > 0)
                int expl = (int)(this.mc.thePlayer.experience * (float)(183));
                int x = w / 2 - 92;
                int y = h - 32 + 3;
                this.drawTexturedModalRect(x, y, 0, 0, 182, ;

                if (expl > 0)
                    this.drawTexturedModalRect(x, y, 0, 9, expl, ;


Any help would be appreciated.

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.