package common.ai;

import common.entity.npc.EntityNPC;
import common.inventory.ContainerMerchant;

public class EntityAINagPlayer extends EntityAIBase
{
    private EntityNPC npc;

    public EntityAINagPlayer(EntityNPC npc)
    {
        this.npc = npc;
        this.setMutexBits(5);
    }
    
    public boolean shouldExecute()
    {
        if (!this.npc.isEntityAlive())
        {
            return false;
        }
        else if (this.npc.isInLiquid())
        {
            return false;
        }
        else if (!this.npc.onGround)
        {
            return false;
        }
        else if (this.npc.veloChanged)
        {
            return false;
        }
        else
        {
            EntityNPC entityplayer = this.npc.getTalking();
            return entityplayer == null ? false : (this.npc.getDistanceSqToEntity(entityplayer) > 16.0D ? false : entityplayer.openContainer instanceof ContainerMerchant);
        }
    }
    
    public void startExecuting()
    {
        this.npc.getNavigator().clearPathEntity();
    }
    
    public void resetTask()
    {
        this.npc.setTalking(null);
    }
}
