package com.zivilon.cinder_loe.entity.npc.good_human;

import lotr.common.LOTRMod;
import lotr.common.LOTRShields;
import lotr.common.entity.ai.LOTREntityAIAttackOnCollide;
import lotr.common.entity.npc.LOTREntityDaleSoldier;
import lotr.common.entity.npc.LOTREntityTauredain;
import net.minecraft.entity.IEntityLivingData;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

public class TauredainTrueBlood extends LOTREntityTauredain {
    public TauredainTrueBlood(World world) {
        super(world);
        this.npcShield = LOTRShields.ALIGNMENT_TAUREDAIN;
    }
    @Override
    public EntityAIBase createHaradrimAttackAI() {
        return new LOTREntityAIAttackOnCollide(this, 1.7, false);
    }
    @Override
    protected void applyEntityAttributes() {
        super.applyEntityAttributes();
        this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(26.0);
        this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(24.0);
        this.getEntityAttribute(npcAttackDamageExtra).setBaseValue(2.0);
    }

    private static ItemStack[] weapons = new ItemStack[]{new ItemStack(LOTRMod.swordTauredain), new ItemStack(LOTRMod.battleaxeTauredain), new ItemStack(LOTRMod.hammerTauredain), new ItemStack(LOTRMod.spearTauredain), new ItemStack(LOTRMod.pikeTauredain)};
    private static ItemStack[] helmets = new ItemStack[]{new ItemStack(LOTRMod.helmetTauredainChieftain), new ItemStack(LOTRMod.helmetTauredainChieftain), new ItemStack(LOTRMod.helmetTauredainGold, 0)};
    private static ItemStack[] bodies = new ItemStack[]{new ItemStack(LOTRMod.bodyTauredain), new ItemStack(LOTRMod.bodyTauredain), new ItemStack(LOTRMod.bodyTauredainGold, 0)};
    private static ItemStack[] legs = new ItemStack[]{new ItemStack(LOTRMod.legsTauredain), new ItemStack(LOTRMod.legsTauredain), new ItemStack(LOTRMod.legsTauredainGold, 0)};
    private static ItemStack[] boots = new ItemStack[]{new ItemStack(LOTRMod.bootsTauredain), new ItemStack(LOTRMod.bootsTauredain), new ItemStack(LOTRMod.bootsTauredainGold, 0)};
    @Override
    public IEntityLivingData onSpawnWithEgg(IEntityLivingData data) {
        data = super.onSpawnWithEgg(data);
        int i = this.rand.nextInt(weapons.length);
        this.npcItemsInv.setMeleeWeapon(weapons[i].copy());
        this.npcItemsInv.setIdleItem(this.npcItemsInv.getMeleeWeapon());
        i = this.rand.nextInt(boots.length);
        this.setCurrentItemOrArmor(1, boots[i].copy());
        i = this.rand.nextInt(legs.length);
        this.setCurrentItemOrArmor(2, legs[i].copy());
        i = this.rand.nextInt(bodies.length);
        this.setCurrentItemOrArmor(3, bodies[i].copy());
        if (this.rand.nextInt(5) != 0) {
            i = this.rand.nextInt(helmets.length);
            this.setCurrentItemOrArmor(4, helmets[i].copy());
        }
        return data;
    }
}
