    001    package net.minecraft.src;
    002
    003    public class EntitySnowman extends EntityGolem implements IRangedAttackMob
    004    {
    005        public EntitySnowman(World par1World)
    006        {
    007            super(par1World);
    008            this.texture = "/mob/snowman.png";
    009            this.setSize(0.4F, 1.8F);
    010            this.getNavigator().setAvoidsWater(true);
    011            this.tasks.addTask(1, new EntityAIArrowAttack(this, 0.25F, 20, 10.0F));
    012            this.tasks.addTask(2, new EntityAIWander(this, 0.2F));
    013            this.tasks.addTask(3, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
    014            this.tasks.addTask(4, new EntityAILookIdle(this));
    015            this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityLiving.class, 16.0F, 0, true, false, IMob.field_82192_a));
    016        }
    017
    018        /**
    019         * Returns true if the newer Entity AI code should be run
    020         */
    021        public boolean isAIEnabled()
    022        {
    023            return true;
    024        }
    025
    026        public int getMaxHealth()
    027        {
    028            return 4;
    029        }
    030
    031        /**
    032         * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
    033         * use this to react to sunlight and start to burn.
    034         */
    035        public void onLivingUpdate()
    036        {
    037            super.onLivingUpdate();
    038
    039            if (this.isWet())
    040            {
    041                this.attackEntityFrom(DamageSource.drown, 1);
    042            }
    043
    044            int var1 = MathHelper.floor_double(this.posX);
    045            int var2 = MathHelper.floor_double(this.posZ);
    046
    047            if (this.worldObj.getBiomeGenForCoords(var1, var2).getFloatTemperature() > 1.0F)
    048            {
    049                this.attackEntityFrom(DamageSource.onFire, 1);
    050            }
    051
    052            for (var1 = 0; var1 < 4; ++var1)
    053            {
    054                var2 = MathHelper.floor_double(this.posX + (double)((float)(var1 % 2 * 2 - 1) * 0.25F));
    055                int var3 = MathHelper.floor_double(this.posY);
    056                int var4 = MathHelper.floor_double(this.posZ + (double)((float)(var1 / 2 % 2 * 2 - 1) * 0.25F));
    057
    058                if (this.worldObj.getBlockId(var2, var3, var4) == 0 && this.worldObj.getBiomeGenForCoords(var2, var4).getFloatTemperature() < 0.8F && Block.snow.canPlaceBlockAt(this.worldObj, var2, var3, var4))
    059                {
    060                    this.worldObj.setBlockWithNotify(var2, var3, var4, Block.snow.blockID);
    061                }
    062            }
    063        }
    064
    065        /**
    066         * Returns the item ID for the item the mob drops on death.
    067         */
    068        protected int getDropItemId()
    069        {
    070            return Item.snowball.shiftedIndex;
    071        }
    072
    073        /**
    074         * Drop 0-2 items of this living's type
    075         */
    076        protected void dropFewItems(boolean par1, int par2)
    077        {
    078            int var3 = this.rand.nextInt(16);
    079
    080            for (int var4 = 0; var4 < var3; ++var4)
    081            {
    082                this.dropItem(Item.snowball.shiftedIndex, 1);
    083            }
    084        }
    085
    086        public void func_82196_d(EntityLiving par1EntityLiving)
    087        {
    088            EntitySnowball var2 = new EntitySnowball(this.worldObj, this);
    089            double var3 = par1EntityLiving.posX - this.posX;
    090            double var5 = par1EntityLiving.posY + (double)par1EntityLiving.getEyeHeight() - 1.100000023841858D - var2.posY;
    091            double var7 = par1EntityLiving.posZ - this.posZ;
    092            float var9 = MathHelper.sqrt_double(var3 * var3 + var7 * var7) * 0.2F;
    093            var2.setThrowableHeading(var3, var5 + (double)var9, var7, 1.6F, 12.0F);
    094            this.worldObj.playSoundAtEntity(this, "random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
    095            this.worldObj.spawnEntityInWorld(var2);
    096        }
    097    }