    001    package net.minecraft.src;
    002
    003    public class EntityChicken extends EntityAnimal
    004    {
    005        public boolean field_70885_d = false;
    006        public float field_70886_e = 0.0F;
    007        public float destPos = 0.0F;
    008        public float field_70884_g;
    009        public float field_70888_h;
    010        public float field_70889_i = 1.0F;
    011
    012        /** The time until the next egg is spawned. */
    013        public int timeUntilNextEgg;
    014
    015        public EntityChicken(World par1World)
    016        {
    017            super(par1World);
    018            this.texture = "/mob/chicken.png";
    019            this.setSize(0.3F, 0.7F);
    020            this.timeUntilNextEgg = this.rand.nextInt(6000) + 6000;
    021            float var2 = 0.25F;
    022            this.tasks.addTask(0, new EntityAISwimming(this));
    023            this.tasks.addTask(1, new EntityAIPanic(this, 0.38F));
    024            this.tasks.addTask(2, new EntityAIMate(this, var2));
    025            this.tasks.addTask(3, new EntityAITempt(this, 0.25F, Item.wheat.shiftedIndex, false));
    026            this.tasks.addTask(4, new EntityAIFollowParent(this, 0.28F));
    027            this.tasks.addTask(5, new EntityAIWander(this, var2));
    028            this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
    029            this.tasks.addTask(7, new EntityAILookIdle(this));
    030        }
    031
    032        /**
    033         * Returns true if the newer Entity AI code should be run
    034         */
    035        public boolean isAIEnabled()
    036        {
    037            return true;
    038        }
    039
    040        public int getMaxHealth()
    041        {
    042            return 4;
    043        }
    044
    045        /**
    046         * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
    047         * use this to react to sunlight and start to burn.
    048         */
    049        public void onLivingUpdate()
    050        {
    051            super.onLivingUpdate();
    052            this.field_70888_h = this.field_70886_e;
    053            this.field_70884_g = this.destPos;
    054            this.destPos = (float)((double)this.destPos + (double)(this.onGround ? -1 : 4) * 0.3D);
    055
    056            if (this.destPos < 0.0F)
    057            {
    058                this.destPos = 0.0F;
    059            }
    060
    061            if (this.destPos > 1.0F)
    062            {
    063                this.destPos = 1.0F;
    064            }
    065
    066            if (!this.onGround && this.field_70889_i < 1.0F)
    067            {
    068                this.field_70889_i = 1.0F;
    069            }
    070
    071            this.field_70889_i = (float)((double)this.field_70889_i * 0.9D);
    072
    073            if (!this.onGround && this.motionY < 0.0D)
    074            {
    075                this.motionY *= 0.6D;
    076            }
    077
    078            this.field_70886_e += this.field_70889_i * 2.0F;
    079
    080            if (!this.isChild() && !this.worldObj.isRemote && --this.timeUntilNextEgg <= 0)
    081            {
    082                this.worldObj.playSoundAtEntity(this, "mob.chickenplop", 1.0F, (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);
    083                this.dropItem(Item.egg.shiftedIndex, 1);
    084                this.timeUntilNextEgg = this.rand.nextInt(6000) + 6000;
    085            }
    086        }
    087
    088        /**
    089         * Called when the mob is falling. Calculates and applies fall damage.
    090         */
    091        protected void fall(float par1) {}
    092
    093        /**
    094         * Returns the sound this mob makes while it's alive.
    095         */
    096        protected String getLivingSound()
    097        {
    098            return "mob.chicken";
    099        }
    100
    101        /**
    102         * Returns the sound this mob makes when it is hurt.
    103         */
    104        protected String getHurtSound()
    105        {
    106            return "mob.chickenhurt";
    107        }
    108
    109        /**
    110         * Returns the sound this mob makes on death.
    111         */
    112        protected String getDeathSound()
    113        {
    114            return "mob.chickenhurt";
    115        }
    116
    117        /**
    118         * Returns the item ID for the item the mob drops on death.
    119         */
    120        protected int getDropItemId()
    121        {
    122            return Item.feather.shiftedIndex;
    123        }
    124
    125        /**
    126         * Drop 0-2 items of this living's type
    127         */
    128        protected void dropFewItems(boolean par1, int par2)
    129        {
    130            int var3 = this.rand.nextInt(3) + this.rand.nextInt(1 + par2);
    131
    132            for (int var4 = 0; var4 < var3; ++var4)
    133            {
    134                this.dropItem(Item.feather.shiftedIndex, 1);
    135            }
    136
    137            if (this.isBurning())
    138            {
    139                this.dropItem(Item.chickenCooked.shiftedIndex, 1);
    140            }
    141            else
    142            {
    143                this.dropItem(Item.chickenRaw.shiftedIndex, 1);
    144            }
    145        }
    146
    147        /**
    148         * This function is used when two same-species animals in 'love mode' breed to generate the new baby animal.
    149         */
    150        public EntityAnimal spawnBabyAnimal(EntityAnimal par1EntityAnimal)
    151        {
    152            return new EntityChicken(this.worldObj);
    153        }
    154    }