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

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

Qpagq9T.png

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 :)

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

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.