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

import com.zivilon.cinder_loe.CinderLoE;

import lotr.common.LOTRMod;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IEntityLivingData;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import lotr.common.entity.npc.LOTREntityDwarfCommander;
import lotr.common.entity.npc.LOTRUnitTradeable;
import lotr.common.entity.npc.LOTRUnitTradeEntries;
import net.minecraft.util.MovingObjectPosition;


public class RedDwarfCommander extends LOTREntityDwarfCommander implements LOTRUnitTradeable {
    public RedDwarfCommander(World world) {
        super(world);
        addTargetTasks(false);
    }

    public LOTRUnitTradeEntries getUnits() {
        return CinderLoE.RED_DWARF_COMMANDER;
    }

    public IEntityLivingData onSpawnWithEgg(IEntityLivingData data) {
        data = super.onSpawnWithEgg(data);
        int i = rand.nextInt(5);
        if (i == 0) {
            this.npcItemsInv.setMeleeWeapon(new ItemStack(CinderLoE.swordRedDwarf));
        } else if (i == 1 || i == 2) {
            this.npcItemsInv.setMeleeWeapon(new ItemStack(CinderLoE.battleaxeRedDwarf));
        } else if (i == 3 || i == 4) {
            this.npcItemsInv.setMeleeWeapon(new ItemStack(CinderLoE.spearRedDwarf));
        }
        if (rand.nextInt(6) == 0) {
            this.npcItemsInv.setSpearBackup(this.npcItemsInv.getMeleeWeapon());
            this.npcItemsInv.setMeleeWeapon(new ItemStack(CinderLoE.spearRedDwarf));
        }
        this.npcItemsInv.setIdleItem(this.npcItemsInv.getMeleeWeapon());
        setCurrentItemOrArmor(1, new ItemStack(CinderLoE.bootsRedDwarf));
        setCurrentItemOrArmor(2, new ItemStack(CinderLoE.legsRedDwarf));
        setCurrentItemOrArmor(3, new ItemStack(CinderLoE.bodyRedDwarf));
        setCurrentItemOrArmor(4, null);
        if (rand.nextInt(10) != 0)
            setCurrentItemOrArmor(4, new ItemStack(CinderLoE.helmetRedDwarf));
        return data;
    }
    @Override
    public ItemStack getPickedResult(MovingObjectPosition target) {
        return new ItemStack(CinderLoE.spawnEgg, 1, 13);
    }

    @Override
    public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_) {
    }
}
