From 1b20c3fcb06beada6cbc95c011c7a3ab256d128f Mon Sep 17 00:00:00 2001 From: Gig Date: Sun, 14 Jun 2015 19:34:14 +0100 Subject: [PATCH] Hud color changes depending on current charge --- .../java/techreborn/client/hud/ChargeHud.java | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/main/java/techreborn/client/hud/ChargeHud.java b/src/main/java/techreborn/client/hud/ChargeHud.java index c54a9ded1..745a48f69 100644 --- a/src/main/java/techreborn/client/hud/ChargeHud.java +++ b/src/main/java/techreborn/client/hud/ChargeHud.java @@ -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); } } }