package common.entity.animal;

import common.ai.EntityAIAttackOnCollide;
import common.ai.EntityAIHurtByTarget;
import common.ai.EntityAILeapAtTarget;
import common.ai.EntityAILookIdle;
import common.ai.EntityAIMate;
import common.ai.EntityAINearestAttackableTarget;
import common.ai.EntityAISwimming;
import common.ai.EntityAIWander;
import common.ai.EntityAIWatchClosest;
import common.entity.DamageSource;
import common.entity.Entity;
import common.entity.npc.Alignment;
import common.entity.types.EntityAnimal;
import common.entity.types.EntityLiving;
import common.init.Items;
import common.init.SoundEvent;
import common.item.Item;
import common.item.ItemStack;
import common.pathfinding.PathNavigateGround;
import common.vars.Vars;
import common.world.World;

public class EntityFox extends EntityAnimal
{
    public EntityFox(World worldIn)
    {
        super(worldIn);
        this.setSize(0.6F, 0.8F);
        ((PathNavigateGround)this.getNavigator()).setAvoidsWater(true);
        this.tasks.addTask(1, new EntityAISwimming(this));
        this.tasks.addTask(3, new EntityAILeapAtTarget(this, 0.4F));
        this.tasks.addTask(4, new EntityAIAttackOnCollide(this, 1.0D, true));
        this.tasks.addTask(6, new EntityAIMate(this, 1.0D));
        this.tasks.addTask(7, new EntityAIWander(this, 1.0D));
        this.tasks.addTask(9, new EntityAIWatchClosest(this, null, 8.0F));
        this.tasks.addTask(9, new EntityAILookIdle(this));
        this.targets.addTask(3, new EntityAIHurtByTarget(this, true));
        this.targets.addTask(5, new EntityAINearestAttackableTarget(this, EntityChicken.class, true));
    }

    protected void applyEntityAttributes()
    {
        super.applyEntityAttributes();
        this.setSpeedBase(0.35f);
        this.setMaxHealth(6);
    }

    protected SoundEvent getHurtSound()
    {
        return SoundEvent.FOX_HURT;
    }

    protected SoundEvent getDeathSound()
    {
        return SoundEvent.FOX_DEATH;
    }

    protected float getSoundVolume()
    {
        return 0.4F;
    }

    protected Item getDropItem()
    {
        return null;
    }

    public float getEyeHeight()
    {
        return this.height * 0.8F;
    }

    public boolean attackEntityAsMob(Entity entityIn)
    {
    	if(!this.worldObj.client && !Vars.damageMobs)
    		return false;
        boolean flag = entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), 2);

        if (flag)
        {
            this.applyEnchantments(this, entityIn);
        }

        return flag;
    }

    public boolean isBreedingItem(ItemStack stack)
    {
        return stack != null && stack.getItem() == Items.apple;
    }

    public int getMaxChunkSpawns()
    {
        return 6;
    }

    public EntityFox createChild(EntityLiving ageable)
    {
        return new EntityFox(this.worldObj);
    }
    
	public int getColor() {
		return 0xc35d00;
	}
	
	public Alignment getAlignment() {
		return Alignment.CHAOTIC;
	}
}
