Search in sources :

Example 1 with Color

use of org.lwjgl.util.Color in project SilentGems by SilentChaos512.

the class GuiChaosBar method onRenderGameOverlay.

@SubscribeEvent
public void onRenderGameOverlay(RenderGameOverlayEvent.Pre event) {
    if (event.getType() != ElementType.AIR) {
        return;
    }
    Minecraft mc = Minecraft.getMinecraft();
    EntityPlayer player = mc.player;
    currentTime = ClientTickHandler.ticksInGame;
    if (player.capabilities.isCreativeMode || (!GemsConfig.CHAOS_BAR_SHOW_ALWAYS && currentTime > lastUpdateTime + POPUP_TIME)) {
        return;
    }
    int width = event.getResolution().getScaledWidth();
    int height = event.getResolution().getScaledHeight();
    PlayerData data = PlayerDataHandler.get(player);
    int chaos = data.getCurrentChaos();
    int maxChaos = data.getMaxChaos();
    int chaosHalves = (int) (20f * chaos / maxChaos);
    int rowHeight = 10;
    int left = width / 2 + 10;
    int top = height - GuiIngameForge.right_height;
    GuiIngameForge.right_height += rowHeight;
    final int textureX = 0;
    final int textureY = 23;
    final int textureWidth = 9;
    final int textureHeight = 9;
    GlStateManager.pushMatrix();
    GlStateManager.enableBlend();
    mc.renderEngine.bindTexture(TEXTURE);
    for (int i = 9; i >= 0; --i) {
        int row = MathHelper.ceil((i + 1) / 10f) - 1;
        int x = left + i % 10 * 8;
        int y = top - row * rowHeight;
        GlStateManager.color(1f, 1f, 1f, 1f);
        drawTexturedModalRect(x, y, textureX + 2 * textureWidth, textureY, textureWidth, textureHeight);
        Color color = new Color();
        float hue = ((currentTime + COLOR_CHANGE_STEP * i) % COLOR_CHANGE_DELAY) / COLOR_CHANGE_DELAY;
        color.fromHSB(hue, 0.6f, 1f);
        GlStateManager.color(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, 1f);
        if (i * 2 + 1 < chaosHalves) {
            drawTexturedModalRect(x, y, textureX, textureY, textureWidth, textureHeight);
        } else if (i * 2 + 1 == chaosHalves) {
            drawTexturedModalRect(x, y, textureX + textureWidth, textureY, textureWidth, textureHeight);
        }
    }
    GlStateManager.color(1f, 1f, 1f, 1f);
    mc.renderEngine.bindTexture(Gui.ICONS);
    GlStateManager.disableBlend();
    GlStateManager.popMatrix();
}
Also used : Color(org.lwjgl.util.Color) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Minecraft(net.minecraft.client.Minecraft) PlayerData(net.silentchaos512.gems.handler.PlayerDataHandler.PlayerData) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

Minecraft (net.minecraft.client.Minecraft)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1 PlayerData (net.silentchaos512.gems.handler.PlayerDataHandler.PlayerData)1 Color (org.lwjgl.util.Color)1