package net.cmr.jurassicrevived.screen.renderer;

import net.cmr.jurassicrevived.block.entity.energy.ModEnergyStorage;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.network.chat.Component;

import java.util.List;

/*
 *  BluSunrize
 *  Copyright (c) 2021
 *
 *  This code is licensed under "Blu's License of Common Sense"
 *  https://github.com/BluSunrize/ImmersiveEngineering/blob/1.19.2/LICENSE
 *
 *  Slightly Modified Version by: Kaupenjoe
 */
public class EnergyDisplayTooltipAreaDouble {
	private final int xPos;
	private final int yPos;
	private final int width;
	private final int height;
	private final ModEnergyStorage energy;

	public EnergyDisplayTooltipAreaDouble(int xMin, int yMin, ModEnergyStorage energy)  {
		this(xMin, yMin, energy, 16, 64);
	}

	public EnergyDisplayTooltipAreaDouble(int xMin, int yMin, ModEnergyStorage energy, int width, int height)  {
		xPos = xMin;
		yPos = yMin;
		this.width = width;
		this.height = height;
		this.energy = energy;
	}

	public List<Component> getTooltips() {
		return List.of(Component.literal(energy.getEnergyStored() + " / " + energy.getMaxEnergyStored() + " FE"));
	}

	public void render(GuiGraphics guiGraphics) {
		int stored = (int)(height * (energy.getEnergyStored() / (float)energy.getMaxEnergyStored()));
		guiGraphics.fillGradient(xPos, yPos + (height - stored), xPos + width,
			yPos + height, 0xffb51500, 0xff600b00);
	}
}