001    package net.minecraft.entity.ai;
002    
003    import java.util.ArrayList;
004    import java.util.List;
005    import net.minecraft.entity.Entity;
006    import net.minecraft.entity.EntityLiving;
007    
008    public class EntitySenses
009    {
010        EntityLiving entityObj;
011    
012        /** Cache of entities which we can see */
013        List seenEntities = new ArrayList();
014    
015        /** Cache of entities which we cannot see */
016        List unseenEntities = new ArrayList();
017    
018        public EntitySenses(EntityLiving par1EntityLiving)
019        {
020            this.entityObj = par1EntityLiving;
021        }
022    
023        /**
024         * Clears canSeeCachePositive and canSeeCacheNegative.
025         */
026        public void clearSensingCache()
027        {
028            this.seenEntities.clear();
029            this.unseenEntities.clear();
030        }
031    
032        /**
033         * Checks, whether 'our' entity can see the entity given as argument (true) or not (false), caching the result.
034         */
035        public boolean canSee(Entity par1Entity)
036        {
037            if (this.seenEntities.contains(par1Entity))
038            {
039                return true;
040            }
041            else if (this.unseenEntities.contains(par1Entity))
042            {
043                return false;
044            }
045            else
046            {
047                this.entityObj.worldObj.theProfiler.startSection("canSee");
048                boolean var2 = this.entityObj.canEntityBeSeen(par1Entity);
049                this.entityObj.worldObj.theProfiler.endSection();
050    
051                if (var2)
052                {
053                    this.seenEntities.add(par1Entity);
054                }
055                else
056                {
057                    this.unseenEntities.add(par1Entity);
058                }
059    
060                return var2;
061            }
062        }
063    }