So, here's the code I have to show the health bar currently without replacing it. How would I go about replacing the default health bar?
public class HealthRenderer extends Gui{
public static HealthRenderer instance = new HealthRenderer();
private final ResourceLocation bar = new ResourceLocation(Reference.MODID, "textures/gui/hpbar.png");
private final int tex_width = 102, tex_height = 8, bar_width = 100, bar_height = 6;
@SubscribeEvent
public void renderOverlay(RenderGameOverlayEvent e) {
Minecraft mc = Minecraft.getMinecraft();
EntityPlayer entity = mc.thePlayer;
FontRenderer fontObj = mc.fontRendererObj;
if (e.type == RenderGameOverlayEvent.ElementType.TEXT) {
mc.renderEngine.bindTexture(bar);
float oneUnit = (float)bar_width / entity.getMaxHealth();
int currentWidth = (int)(oneUnit * entity.getHealth());
float health = entity.getHealth();
//String pHealth = String.format("%.1f", health);
//drawString(fontObj, pHealth, 30, 5, -1);
drawTexturedModalRect(0, 0, 0, 0, tex_width, tex_height);
drawTexturedModalRect(1, 0, 1, tex_height, currentWidth, tex_height);
}
}
}
Also, here's the image I'm using