Hud color changes depending on current charge

This commit is contained in:
Gig 2015-06-14 19:34:14 +01:00
parent 22d018efb3
commit 1b20c3fcb0

View file

@ -2,7 +2,9 @@ package techreborn.client.hud;
import org.lwjgl.opengl.GL11;
import codechicken.lib.colour.ColourARGB;
import techreborn.config.ConfigTechReborn;
import techreborn.util.Color;
import ic2.api.item.ElectricItem;
import ic2.api.item.IElectricItem;
import ic2.api.item.IElectricItemManager;
@ -14,6 +16,7 @@ import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@ -39,18 +42,38 @@ public class ChargeHud
public void drawChargeHud(ScaledResolution res)
{
EntityPlayer player = mc.thePlayer;
ItemStack stack = player.getCurrentArmor(2);;
ItemStack stack = player.getCurrentArmor(2);
if(stack != null)
{
if((stack.getItem() instanceof IElectricItem) && ConfigTechReborn.ShowChargeHud)
{
double MaxCharge = ((IElectricItem) stack.getItem()).getMaxCharge(stack);
double CurrentCharge = ElectricItem.manager.getCharge(stack);
Color color = Color.GREEN;
double quarter = MaxCharge / 4;
double half = MaxCharge / 2;
double threeQuarters = MaxCharge / 4 * 3;
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glEnable(32826);
RenderHelper.enableStandardItemLighting();
RenderHelper.enableGUIStandardItemLighting();
mc.fontRenderer.drawString(Double.toString(CurrentCharge) + "/" + Double.toString(MaxCharge), 0, 0, 0);
//Render the stack
RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, stack, 0, 0);
RenderItem.getInstance().renderItemOverlayIntoGUI(mc.fontRenderer, mc.renderEngine, stack, 0, 0);
//Render Overlay
if(CurrentCharge <= threeQuarters)
{
color = Color.YELLOW;
}
if(CurrentCharge <= half)
{
color = Color.RED;
}
if(CurrentCharge <= quarter)
{
color = Color.DARK_RED;
}
mc.fontRenderer.drawString(color + Double.toString(CurrentCharge) + "/" + Double.toString(MaxCharge), 20, 5, 0);
}
}
}