package net.minecraft.src;

import net.lax1dude.eaglercraft.TextureLocation;
import net.lax1dude.eaglercraft.EaglerAdapter;

public class RenderSpider extends RenderLiving
{
    private static final TextureLocation spiderEyesTextures = new TextureLocation("textures/entity/spider_eyes.png");
    private static final TextureLocation spiderTextures = new TextureLocation("textures/entity/spider/spider.png");

    public RenderSpider()
    {
        super(new ModelSpider(), 1.0F);
        this.setRenderPassModel(new ModelSpider());
    }

    protected float setSpiderDeathMaxRotation(EntitySpider par1EntitySpider)
    {
        return 180.0F;
    }

    /**
     * Sets the spider's glowing eyes
     */
    protected int setSpiderEyeBrightness(EntitySpider par1EntitySpider, int par2, float par3)
    {
        if (par2 != 0)
        {
            return -1;
        }
        else
        {
            this.bindTexture(spiderEyesTextures);
            float var4 = 1.0F;
            EaglerAdapter.glEnable(EaglerAdapter.GL_BLEND);
            EaglerAdapter.glDisable(EaglerAdapter.GL_ALPHA_TEST);
            EaglerAdapter.glBlendFunc(EaglerAdapter.GL_ONE, EaglerAdapter.GL_ONE);

            if (par1EntitySpider.isInvisible())
            {
                EaglerAdapter.glDepthMask(false);
            }
            else
            {
                EaglerAdapter.glDepthMask(true);
            }

            char var5 = 61680;
            int var6 = var5 % 65536;
            int var7 = var5 / 65536;
            OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)var6 / 1.0F, (float)var7 / 1.0F);
            EaglerAdapter.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
            EaglerAdapter.glColor4f(1.0F, 1.0F, 1.0F, var4);
            return 1;
        }
    }

    protected TextureLocation getSpiderTextures(EntitySpider par1EntitySpider)
    {
        return spiderTextures;
    }

    protected float getDeathMaxRotation(EntityLivingBase par1EntityLivingBase)
    {
        return this.setSpiderDeathMaxRotation((EntitySpider)par1EntityLivingBase);
    }

    @Override
    protected void bindTexture(EntityLivingBase par1EntityLiving) {
        spiderTextures.bindTexture();
    }

    /**
     * Queries whether should render the specified pass or not.
     */
    protected int shouldRenderPass(EntityLivingBase par1EntityLivingBase, int par2, float par3)
    {
        return this.setSpiderEyeBrightness((EntitySpider)par1EntityLivingBase, par2, par3);
    }

    /**
     * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
     */
    protected TextureLocation getEntityTexture(Entity par1Entity)
    {
        return this.getSpiderTextures((EntitySpider)par1Entity);
    }
}
