package client.renderer.layers;

import client.renderer.GlState;
import client.renderer.entity.RenderSheep;
import client.renderer.model.ModelSheep1;
import common.entity.animal.EntitySheep;


public class LayerSheepWool implements LayerRenderer<EntitySheep>
{
    private static final String TEXTURE = "textures/creature/sheep_fur.png";
    private final RenderSheep sheepRenderer;
    private final ModelSheep1 sheepModel = new ModelSheep1();

    public LayerSheepWool(RenderSheep sheepRendererIn)
    {
        this.sheepRenderer = sheepRendererIn;
    }

    public void doRenderLayer(EntitySheep entitylivingbaseIn, float p_177141_2_, float p_177141_3_, float partialTicks, float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale)
    {
        if (!entitylivingbaseIn.getSheared()) // && !entitylivingbaseIn.isInvisible())
        {
            this.sheepRenderer.bindTexture(TEXTURE);

            if (entitylivingbaseIn.hasCustomName() && ("Grell".equalsIgnoreCase(entitylivingbaseIn.getCustomNameTag())
            		|| "Grelle".equalsIgnoreCase(entitylivingbaseIn.getCustomNameTag())))
            {
//                int i1 = 25;
//                int i = entitylivingbaseIn.ticksExisted / 25 + entitylivingbaseIn.getId();
//                int j = EnumDyeColor.values().length;
//                int k = i % j;
//                int l = (i + 1) % j;
//                float f = ((float)(entitylivingbaseIn.ticksExisted % 25) + partialTicks) / 25.0F;
//                float[] afloat1 = EntitySheep.getDyeRgb(EnumDyeColor.byMetadata(k));
//                float[] afloat2 = EntitySheep.getDyeRgb(EnumDyeColor.byMetadata(l));
                GlState.color(1.0f, 0.0f, 0.0f, 1.0F);
            }
            else
            {
                GlState.color(entitylivingbaseIn.getFleeceColor().getColor() | 0xff000000);
            }

            this.sheepModel.setModelAttributes(this.sheepRenderer.getMainModel());
            this.sheepModel.setLivingAnimations(entitylivingbaseIn, p_177141_2_, p_177141_3_, partialTicks);
            this.sheepModel.render(entitylivingbaseIn, p_177141_2_, p_177141_3_, p_177141_5_, p_177141_6_, p_177141_7_, scale);
        }
    }

    public boolean shouldCombineTextures()
    {
        return true;
    }
}
