001 package net.minecraft.src;
002
003 public class EntitySnowman extends EntityGolem
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, 2, 20));
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, EntityMob.class, 16.0F, 0, true));
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 }