package client.renderer.entity;

import org.lwjgl.opengl.GL11;

import client.Client;
import client.renderer.GlState;
import common.entity.item.EntityTntCart;
import common.init.Blocks;
import common.util.ExtMath;
import common.world.State;

public class RenderTntMinecart extends RenderMinecart<EntityTntCart>
{
    public RenderTntMinecart(RenderManager renderManagerIn)
    {
        super(renderManagerIn);
    }

    protected void func_180560_a(EntityTntCart minecart, float partialTicks, State state)
    {
        int i = minecart.getFuseTicks();

        if (i > -1 && (float)i - partialTicks + 1.0F < 10.0F)
        {
            float f = 1.0F - ((float)i - partialTicks + 1.0F) / 10.0F;
            f = ExtMath.clampf(f, 0.0F, 1.0F);
            f = f * f;
            f = f * f;
            float f1 = 1.0F + f * 0.3F;
            GL11.glScalef(f1, f1, f1);
        }

        super.func_180560_a(minecart, partialTicks, state);

        if (i > -1 && i / 5 % 2 == 0)
        {
            GlState.disableTexture2D();
            GlState.disableLighting();
            GlState.enableBlend();
            GlState.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_DST_ALPHA);
            GlState.color(1.0F, 1.0F, 1.0F, (1.0F - ((float)i - partialTicks + 1.0F) / 100.0F) * 0.8F);
            GL11.glPushMatrix();
            Client.CLIENT.renderer.renderBlockEntity(Blocks.tnt.getState(), 1.0F);
            GL11.glPopMatrix();
            GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
            GlState.disableBlend();
            GlState.enableLighting();
            GlState.enableTexture2D();
        }
    }
}
