Posted September 26, 201510 yr So i'm implementing the Buff Status Bar from the Minecraft Forge Wiki, the bar itself works fine but i've tried adding under the icon the duration of the effect. Duration works as well, is displayed correctly, but the icon for the effects are wrong So here is the status bar class package blaze.events; import java.util.Collection; import java.util.Iterator; import org.lwjgl.opengl.GL11; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.Gui; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.ResourceLocation; 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 GUIBuffBar extends Gui { private Minecraft mc; FontRenderer fontRender; public GUIBuffBar(Minecraft mc) { super(); this.mc = mc; } private static final int BUFF_ICON_SIZE = 18; private static final int BUFF_ICON_SPACING = BUFF_ICON_SIZE + 5; // 2 pixels between buff icons private static final int BUFF_ICON_BASE_U_OFFSET = 0; private static final int BUFF_ICON_BASE_V_OFFSET = 198; private static final int BUFF_ICONS_PER_ROW = 8; @SubscribeEvent(priority = EventPriority.NORMAL) public void onRenderExperienceBar(RenderGameOverlayEvent event) { if(event.isCancelable() || event.type != ElementType.EXPERIENCE) { return; } int xPos = 2; int yPos = 2; fontRender = mc.fontRendererObj; Collection collection = this.mc.thePlayer.getActivePotionEffects(); if (!collection.isEmpty()) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_LIGHTING); this.mc.renderEngine.bindTexture(new ResourceLocation("textures/gui/container/inventory.png")); for (Iterator iterator = this.mc.thePlayer.getActivePotionEffects().iterator(); iterator.hasNext(); xPos += BUFF_ICON_SPACING) { PotionEffect potioneffect = (PotionEffect) iterator.next(); Potion potion = Potion.potionTypes[potioneffect.getPotionID()]; if (potion.hasStatusIcon()) { int iconIndex = potion.getStatusIconIndex(); this.drawTexturedModalRect( xPos, yPos, BUFF_ICON_BASE_U_OFFSET + iconIndex % BUFF_ICONS_PER_ROW * BUFF_ICON_SIZE, BUFF_ICON_BASE_V_OFFSET + iconIndex / BUFF_ICONS_PER_ROW * BUFF_ICON_SIZE, BUFF_ICON_SIZE, BUFF_ICON_SIZE); fontRender.drawStringWithShadow(potion.getDurationString(potioneffect), xPos, yPos + 20, 0xFFFFFF); } } } } } And this is what it looks like when multiple effects are active Thanks in advance for all who will help me Don't blame me if i always ask for your help. I just want to learn to be better
September 26, 201510 yr Author Thanks for your help Drawing all the texts after solve the problem Don't blame me if i always ask for your help. I just want to learn to be better
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.