    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.seeds.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.func_85030_a("mob.chicken.plop", 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.say";
    099        }
    100
    101        /**
    102         * Returns the sound this mob makes when it is hurt.
    103         */
    104        protected String getHurtSound()
    105        {
    106            return "mob.chicken.hurt";
    107        }
    108
    109        /**
    110         * Returns the sound this mob makes on death.
    111         */
    112        protected String getDeathSound()
    113        {
    114            return "mob.chicken.hurt";
    115        }
    116
    117        /**
    118         * Plays step sound at given x, y, z for the entity
    119         */
    120        protected void playStepSound(int par1, int par2, int par3, int par4)
    121        {
    122            this.func_85030_a("mob.chicken.step", 0.15F, 1.0F);
    123        }
    124
    125        /**
    126         * Returns the item ID for the item the mob drops on death.
    127         */
    128        protected int getDropItemId()
    129        {
    130            return Item.feather.shiftedIndex;
    131        }
    132
    133        /**
    134         * Drop 0-2 items of this living's type
    135         */
    136        protected void dropFewItems(boolean par1, int par2)
    137        {
    138            int var3 = this.rand.nextInt(3) + this.rand.nextInt(1 + par2);
    139
    140            for (int var4 = 0; var4 < var3; ++var4)
    141            {
    142                this.dropItem(Item.feather.shiftedIndex, 1);
    143            }
    144
    145            if (this.isBurning())
    146            {
    147                this.dropItem(Item.chickenCooked.shiftedIndex, 1);
    148            }
    149            else
    150            {
    151                this.dropItem(Item.chickenRaw.shiftedIndex, 1);
    152            }
    153        }
    154
    155        /**
    156         * This function is used when two same-species animals in 'love mode' breed to generate the new baby animal.
    157         */
    158        public EntityChicken spawnBabyAnimal(EntityAgeable par1EntityAgeable)
    159        {
    160            return new EntityChicken(this.worldObj);
    161        }
    162
    163        /**
    164         * Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on
    165         * the animal type)
    166         */
    167        public boolean isBreedingItem(ItemStack par1ItemStack)
    168        {
    169            return par1ItemStack != null && par1ItemStack.getItem() instanceof ItemSeeds;
    170        }
    171
    172        public EntityAgeable func_90011_a(EntityAgeable par1EntityAgeable)
    173        {
    174            return this.spawnBabyAnimal(par1EntityAgeable);
    175        }
    176    }