package com.zivilon.cinder_loe.client.render;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.util.ResourceLocation;

import com.zivilon.cinder_loe.entity.Renegade;

import lotr.client.model.LOTRModelHuman;
import lotr.client.render.entity.LOTRRandomSkins;
import lotr.client.render.entity.LOTRRenderBiped;
import lotr.common.entity.LOTRRandomSkinEntity;
import lotr.common.entity.npc.LOTREntityNPC;

public class RenderRenegade extends LOTRRenderBiped {

    private static LOTRRandomSkins skinsMale;

    private static LOTRRandomSkins skinsFemale;

    private static LOTRRandomSkins headwearFemale;

    protected ModelBiped outfitModel = (ModelBiped) new LOTRModelHuman(0.6F, false);

    public RenderRenegade() {
        super((ModelBiped) new LOTRModelHuman(), 0.5F);
        skinsMale = LOTRRandomSkins.loadSkinsList("cinder_loe:mob/renegade/renegade_male");
        skinsFemale = LOTRRandomSkins.loadSkinsList("cinder_loe:mob/renegade/renegade_female");
        headwearFemale = LOTRRandomSkins.loadSkinsList("cinder_loe:mob/renegade/headwear_female");
    }

    public ResourceLocation getEntityTexture(Entity entity) {
        Renegade man = (Renegade) entity;
        if (((LOTREntityNPC) man).familyInfo.isMale()) return skinsMale.getRandomSkin((LOTRRandomSkinEntity) man);
        return skinsFemale.getRandomSkin((LOTRRandomSkinEntity) man);
    }

    public int shouldRenderPass(EntityLiving entity, int pass, float f) {
        Renegade man = (Renegade) entity;
        if (pass == 0 && man.getEquipmentInSlot(4) == null) if (!((LOTREntityNPC) man).familyInfo.isMale()
            && LOTRRandomSkins.nextInt((LOTRRandomSkinEntity) man, 4) == 0) {
                setRenderPassModel((ModelBase) this.outfitModel);
                bindTexture(headwearFemale.getRandomSkin((LOTRRandomSkinEntity) man));
                return 1;
            }
        return super.shouldRenderPass((EntityLiving) man, pass, f);
    }
}
