Posted June 18, 20178 yr Currently I have my own overlays or added overlays, I'm slowly replacing the existing HEALTH and FOOD overlays with my own Health and Stamina models and then adding Mana later on. But in my works I've noticed the XP bar has vanished however the XP counter (1, 2, 3 etc) that number still appears if you collect enough xp but the progress bar is not visible package htd.rot.events.client; import htd.rot.Rot; import htd.rot.capability.playerextra.CapPlayerExtra; import htd.rot.capability.playerextra.CapPlayerExtraData; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.MathHelper; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class EventPlayerOverlayGui extends Gui { // Registered in ClientProxy private Minecraft mc; private static final ResourceLocation staminaTexture = new ResourceLocation(Rot.MODID + ":textures/gui/stam_bar.png"); private int barW = 81, barH = 9; private int innerBarW = barW - 2; public EventPlayerOverlayGui(Minecraft mc) { super(); this.mc = mc; } @SubscribeEvent(priority = EventPriority.NORMAL) public void onRenderExperienceBar(RenderGameOverlayEvent event) { if (event.getType() == ElementType.FOOD) { event.setCanceled(true); return; } if (event.getType() != ElementType.EXPERIENCE) { return; } ScaledResolution res = event.getResolution(); int bottomScreen = res.getScaledHeight(), halfHeight = bottomScreen / 2; int rightScreen = res.getScaledWidth(), halfWidth = rightScreen / 2; CapPlayerExtraData capPlayerExtra = Minecraft.getMinecraft().thePlayer.getCapability(CapPlayerExtra.CAPABILITY, null); int currentbarwidth = 0; int xPos = halfWidth + 10; int yPos = bottomScreen - 22 - ((this.barH * 2) - 1); // Draw Stam Bar this.mc.getTextureManager().bindTexture(staminaTexture); float currentStam = capPlayerExtra.getCurrentStam(); float maxStam = capPlayerExtra.MAX_STAM; currentbarwidth = MathHelper.clamp_int((int) ((currentStam / maxStam) * this.innerBarW), 0, this.innerBarW); drawTexturedModalRect(xPos, yPos, 0, 0, this.barW, this.barH); drawTexturedModalRect(xPos + 1, yPos, 0, this.barH, currentbarwidth, this.barH); } } Is the issue that I'm extending Gui? I'm doing that so I can use the "drawTexturedModalRect()" method for drawing. And "ScaledResolution" for positioning. EDIT: in the attached image LEFT is my modded version, RIGHT is vanilla Edited June 18, 20178 yr by hugo_the_dwarf Changing Title to indicate SOLVED Currently updating my Mod to 1.10.2 https://bitbucket.org/hugo_the_dwarf/riseoftristram2016/src?at=master
June 18, 20178 yr 6 minutes ago, hugo_the_dwarf said: this.mc.getTextureManager().bindTexture(staminaTexture); After you are done rendering your stuff you need to rebind the texture that was previously used. Forge won't rebind the texture after each even it posts in GuiIngameForge, it leaves it to modders(and that is the way it should be). The numbers are still drawn as FontRenderer binds the font texture every time it needs to draw anything.
June 18, 20178 yr Author Thank you, I had not known that. I added: this.mc.getTextureManager().bindTexture(ICONS); at the end of my render code and fixed it. Currently updating my Mod to 1.10.2 https://bitbucket.org/hugo_the_dwarf/riseoftristram2016/src?at=master
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.