2016-07-10 12:46:03 -04:00
|
|
|
package WayofTime.bloodmagic.client.hud;
|
|
|
|
|
2016-07-27 07:54:32 -04:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
2016-07-10 12:46:03 -04:00
|
|
|
|
|
|
|
import net.minecraft.client.Minecraft;
|
|
|
|
import net.minecraft.client.gui.ScaledResolution;
|
|
|
|
import net.minecraft.client.renderer.GlStateManager;
|
|
|
|
import net.minecraft.client.renderer.Tessellator;
|
|
|
|
import net.minecraft.client.renderer.VertexBuffer;
|
2016-07-10 15:27:26 -04:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2016-07-10 12:46:03 -04:00
|
|
|
import net.minecraft.util.ResourceLocation;
|
|
|
|
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
|
|
|
import WayofTime.bloodmagic.api.Constants;
|
|
|
|
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
2016-07-10 15:27:26 -04:00
|
|
|
import WayofTime.bloodmagic.proxy.ClientProxy;
|
2016-07-10 21:51:17 -04:00
|
|
|
import WayofTime.bloodmagic.util.Utils;
|
2016-07-10 12:46:03 -04:00
|
|
|
|
|
|
|
public class HUDElementDemonWillAura extends HUDElement
|
|
|
|
{
|
2016-07-27 07:54:32 -04:00
|
|
|
protected List<EnumDemonWillType> barOrder = new ArrayList<EnumDemonWillType>();
|
2016-07-10 12:46:03 -04:00
|
|
|
|
|
|
|
public HUDElementDemonWillAura()
|
|
|
|
{
|
|
|
|
super(5, 5, RenderGameOverlayEvent.ElementType.HOTBAR);
|
2016-07-27 08:28:33 -04:00
|
|
|
|
2016-07-27 07:54:32 -04:00
|
|
|
barOrder.add(EnumDemonWillType.DEFAULT);
|
|
|
|
barOrder.add(EnumDemonWillType.CORROSIVE);
|
|
|
|
barOrder.add(EnumDemonWillType.STEADFAST);
|
|
|
|
barOrder.add(EnumDemonWillType.DESTRUCTIVE);
|
|
|
|
barOrder.add(EnumDemonWillType.VENGEFUL);
|
2016-07-10 12:46:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void render(Minecraft minecraft, ScaledResolution resolution, float partialTicks)
|
|
|
|
{
|
2017-01-02 00:10:28 -08:00
|
|
|
EntityPlayer player = minecraft.player;
|
2016-07-10 12:46:03 -04:00
|
|
|
|
2016-07-10 21:51:17 -04:00
|
|
|
if (!Utils.canPlayerSeeDemonWill(player))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-07-27 07:54:32 -04:00
|
|
|
minecraft.getTextureManager().bindTexture(new ResourceLocation(Constants.Mod.MODID, "textures/hud/bars.png"));
|
2016-07-10 12:46:03 -04:00
|
|
|
GlStateManager.color(1.0F, 1.0F, 1.0F);
|
2016-07-27 07:54:32 -04:00
|
|
|
this.drawTexturedModalRect(getXOffset(), getYOffset(), 0, 105 * 2, 80, 46);
|
2016-07-10 12:46:03 -04:00
|
|
|
|
2016-07-10 21:51:17 -04:00
|
|
|
double maxAmount = Utils.getDemonWillResolution(player);
|
2016-07-10 12:46:03 -04:00
|
|
|
|
2016-07-27 08:28:33 -04:00
|
|
|
int i = 0;
|
2016-07-27 07:54:32 -04:00
|
|
|
for (EnumDemonWillType type : barOrder)
|
2016-07-10 12:46:03 -04:00
|
|
|
{
|
2016-07-27 08:28:33 -04:00
|
|
|
i++;
|
2016-07-10 15:27:26 -04:00
|
|
|
GlStateManager.color(1.0F, 1.0F, 1.0F);
|
2016-07-27 08:28:33 -04:00
|
|
|
minecraft.getTextureManager().bindTexture(new ResourceLocation(Constants.Mod.MODID, "textures/hud/bars.png"));
|
|
|
|
int textureXOffset = (i > 3) ? (i - 3) : (3 - i);
|
|
|
|
int maxBarSize = 30 - 2 * textureXOffset;
|
2016-07-10 12:46:03 -04:00
|
|
|
|
2016-07-10 15:27:26 -04:00
|
|
|
double amount = ClientProxy.currentAura == null ? 0 : ClientProxy.currentAura.getWill(type);
|
2016-07-10 12:46:03 -04:00
|
|
|
double ratio = Math.max(Math.min(amount / maxAmount, 1), 0);
|
|
|
|
|
2016-07-27 08:28:33 -04:00
|
|
|
double width = maxBarSize * ratio * 2;
|
|
|
|
double height = 2;
|
|
|
|
double x = getXOffset() + 2 * textureXOffset + 10;
|
|
|
|
double y = getYOffset() + 4 * i + 10;
|
|
|
|
|
|
|
|
double textureX = 2 * textureXOffset + 2 * 42;
|
|
|
|
double textureY = 4 * i + 220;
|
|
|
|
|
|
|
|
this.drawTexturedModalRect(x, y, textureX, textureY, width, height);
|
|
|
|
|
|
|
|
if (player.isSneaking())
|
|
|
|
{
|
|
|
|
GlStateManager.pushMatrix();
|
|
|
|
String value = "" + (int) amount;
|
|
|
|
GlStateManager.translate(x - 2 * textureXOffset - value.length() * 0 + 70, (y - 1), 0);
|
|
|
|
GlStateManager.scale(0.5, 0.5, 1);
|
|
|
|
minecraft.fontRendererObj.drawStringWithShadow("" + (int) amount, 0, 2, 0xffffff);
|
|
|
|
GlStateManager.popMatrix();
|
|
|
|
}
|
2016-07-10 12:46:03 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean shouldRender(Minecraft minecraft)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|