    001    package net.minecraft.src;
    002
    003    public class EntityZombie extends EntityMob
    004    {
    005        public EntityZombie(World par1World)
    006        {
    007            super(par1World);
    008            this.texture = "/mob/zombie.png";
    009            this.moveSpeed = 0.23F;
    010            this.attackStrength = 4;
    011            this.getNavigator().setBreakDoors(true);
    012            this.tasks.addTask(0, new EntityAISwimming(this));
    013            this.tasks.addTask(1, new EntityAIBreakDoor(this));
    014            this.tasks.addTask(2, new EntityAIAttackOnCollide(this, EntityPlayer.class, this.moveSpeed, false));
    015            this.tasks.addTask(3, new EntityAIAttackOnCollide(this, EntityVillager.class, this.moveSpeed, true));
    016            this.tasks.addTask(4, new EntityAIMoveTwardsRestriction(this, this.moveSpeed));
    017            this.tasks.addTask(5, new EntityAIMoveThroughVillage(this, this.moveSpeed, false));
    018            this.tasks.addTask(6, new EntityAIWander(this, this.moveSpeed));
    019            this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
    020            this.tasks.addTask(7, new EntityAILookIdle(this));
    021            this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
    022            this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 16.0F, 0, true));
    023            this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityVillager.class, 16.0F, 0, false));
    024        }
    025
    026        public int getMaxHealth()
    027        {
    028            return 20;
    029        }
    030
    031        /**
    032         * Returns the current armor value as determined by a call to InventoryPlayer.getTotalArmorValue
    033         */
    034        public int getTotalArmorValue()
    035        {
    036            return 2;
    037        }
    038
    039        /**
    040         * Returns true if the newer Entity AI code should be run
    041         */
    042        protected boolean isAIEnabled()
    043        {
    044            return true;
    045        }
    046
    047        /**
    048         * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
    049         * use this to react to sunlight and start to burn.
    050         */
    051        public void onLivingUpdate()
    052        {
    053            if (this.worldObj.isDaytime() && !this.worldObj.isRemote)
    054            {
    055                float var1 = this.getBrightness(1.0F);
    056
    057                if (var1 > 0.5F && this.worldObj.canBlockSeeTheSky(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)) && this.rand.nextFloat() * 30.0F < (var1 - 0.4F) * 2.0F)
    058                {
    059                    this.setFire(8);
    060                }
    061            }
    062
    063            super.onLivingUpdate();
    064        }
    065
    066        /**
    067         * Returns the sound this mob makes while it's alive.
    068         */
    069        protected String getLivingSound()
    070        {
    071            return "mob.zombie";
    072        }
    073
    074        /**
    075         * Returns the sound this mob makes when it is hurt.
    076         */
    077        protected String getHurtSound()
    078        {
    079            return "mob.zombiehurt";
    080        }
    081
    082        /**
    083         * Returns the sound this mob makes on death.
    084         */
    085        protected String getDeathSound()
    086        {
    087            return "mob.zombiedeath";
    088        }
    089
    090        /**
    091         * Returns the item ID for the item the mob drops on death.
    092         */
    093        protected int getDropItemId()
    094        {
    095            return Item.rottenFlesh.shiftedIndex;
    096        }
    097
    098        /**
    099         * Get this Entity's EnumCreatureAttribute
    100         */
    101        public EnumCreatureAttribute getCreatureAttribute()
    102        {
    103            return EnumCreatureAttribute.UNDEAD;
    104        }
    105
    106        protected void dropRareDrop(int par1)
    107        {
    108            switch (this.rand.nextInt(4))
    109            {
    110                case 0:
    111                    this.dropItem(Item.swordSteel.shiftedIndex, 1);
    112                    break;
    113                case 1:
    114                    this.dropItem(Item.helmetSteel.shiftedIndex, 1);
    115                    break;
    116                case 2:
    117                    this.dropItem(Item.ingotIron.shiftedIndex, 1);
    118                    break;
    119                case 3:
    120                    this.dropItem(Item.shovelSteel.shiftedIndex, 1);
    121            }
    122        }
    123    }