package com.zivilon.cinder_loe.entity.npc;

import com.zivilon.cinder_loe.CinderLoE;

import lotr.common.LOTRMod;
import lotr.common.LOTRShields;
import lotr.common.entity.npc.LOTREntityDwarfWarrior;
import net.minecraft.entity.IEntityLivingData;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;

public class DwarfLevy extends LOTREntityDwarfWarrior {

    private static ItemStack[] levyWeapons = new ItemStack[]{new ItemStack(LOTRMod.daggerDwarven), new ItemStack(LOTRMod.daggerDwarvenPoisoned), new ItemStack(LOTRMod.swordDwarven), new ItemStack(LOTRMod.axeDwarven), new ItemStack(LOTRMod.battleaxeDwarven), new ItemStack(LOTRMod.hammerDwarven), new ItemStack(Items.iron_axe), new ItemStack(LOTRMod.battleaxeIron), new ItemStack(LOTRMod.spearDwarven), new ItemStack(LOTRMod.spearIron)};
    private static ItemStack[] levySpears = new ItemStack[]{new ItemStack(LOTRMod.spearDwarven), new ItemStack(LOTRMod.spearIron)};
    private static ItemStack[] levyBodies = new ItemStack[]{new ItemStack(Items.leather_chestplate), new ItemStack(LOTRMod.bodyDaleGambeson)};
    private static ItemStack[] levyLegs = new ItemStack[]{new ItemStack(Items.leather_leggings), new ItemStack(Items.iron_leggings)};
    private static ItemStack[] levyBoots = new ItemStack[]{new ItemStack(Items.leather_boots), new ItemStack(LOTRMod.bootsBronze), null};
    private static final int[] colors = new int[]{14823729, 5512477, 14196753, 11374145, 7366222};

    public DwarfLevy(World world) {
        super(world);
        this.npcShield = null;
    }

    public IEntityLivingData onSpawnWithEgg(IEntityLivingData data) {
        data = super.onSpawnWithEgg(data);
        int i = (this).rand.nextInt(levyWeapons.length);
        this.npcItemsInv.setMeleeWeapon(levyWeapons[i].copy());
        this.npcItemsInv.setIdleItem(this.npcItemsInv.getMeleeWeapon());
        if ((this).rand.nextInt(5) == 0) {
            this.npcItemsInv.setSpearBackup(this.npcItemsInv.getMeleeWeapon());
            i = (this).rand.nextInt(levySpears.length);
            this.npcItemsInv.setMeleeWeapon(levySpears[i].copy());
        }
        i = (this).rand.nextInt(levyBoots.length);
        this.setCurrentItemOrArmor(1, levyBoots[i].copy());
        i = (this).rand.nextInt(levyLegs.length);
        this.setCurrentItemOrArmor(2, levyLegs[i].copy());
        i = (this).rand.nextInt(levyBodies.length);
        this.setCurrentItemOrArmor(3, levyBodies[i].copy());
        this.setCurrentItemOrArmor(4, null);
        return data;
    }
    @Override
    public ItemStack getPickedResult(MovingObjectPosition target) {
        return new ItemStack(CinderLoE.spawnEgg, 1, 24);
    }
}
