    001    package net.minecraft.src;
    002
    003    public abstract class EntityWaterMob extends EntityCreature implements IAnimals
    004    {
    005        public EntityWaterMob(World par1World)
    006        {
    007            super(par1World);
    008        }
    009
    010        public boolean canBreatheUnderwater()
    011        {
    012            return true;
    013        }
    014
    015        /**
    016         * Checks if the entity's current position is a valid location to spawn this entity.
    017         */
    018        public boolean getCanSpawnHere()
    019        {
    020            return this.worldObj.checkIfAABBIsClear(this.boundingBox);
    021        }
    022
    023        /**
    024         * Get number of ticks, at least during which the living entity will be silent.
    025         */
    026        public int getTalkInterval()
    027        {
    028            return 120;
    029        }
    030
    031        /**
    032         * Determines if an entity can be despawned, used on idle far away entities
    033         */
    034        protected boolean canDespawn()
    035        {
    036            return true;
    037        }
    038
    039        /**
    040         * Get the experience points the entity currently has.
    041         */
    042        protected int getExperiencePoints(EntityPlayer par1EntityPlayer)
    043        {
    044            return 1 + this.worldObj.rand.nextInt(3);
    045        }
    046
    047        /**
    048         * Gets called every tick from main Entity class
    049         */
    050        public void onEntityUpdate()
    051        {
    052            int var1 = this.getAir();
    053            super.onEntityUpdate();
    054
    055            if (this.isEntityAlive() && !this.isInsideOfMaterial(Material.water))
    056            {
    057                --var1;
    058                this.setAir(var1);
    059
    060                if (this.getAir() == -20)
    061                {
    062                    this.setAir(0);
    063                    this.attackEntityFrom(DamageSource.drown, 2);
    064                }
    065            }
    066            else
    067            {
    068                this.setAir(300);
    069            }
    070        }
    071    }