001 package net.minecraft.src; 002 003 import cpw.mods.fml.common.Side; 004 import cpw.mods.fml.common.asm.SideOnly; 005 006 public class EntityBlaze extends EntityMob 007 { 008 /** Random offset used in floating behaviour */ 009 private float heightOffset = 0.5F; 010 011 /** ticks until heightOffset is randomized */ 012 private int heightOffsetUpdateTime; 013 private int field_70846_g; 014 015 public EntityBlaze(World par1World) 016 { 017 super(par1World); 018 this.texture = "/mob/fire.png"; 019 this.isImmuneToFire = true; 020 this.experienceValue = 10; 021 } 022 023 public int getMaxHealth() 024 { 025 return 20; 026 } 027 028 protected void entityInit() 029 { 030 super.entityInit(); 031 this.dataWatcher.addObject(16, new Byte((byte)0)); 032 } 033 034 /** 035 * Returns the sound this mob makes while it's alive. 036 */ 037 protected String getLivingSound() 038 { 039 return "mob.blaze.breathe"; 040 } 041 042 /** 043 * Returns the sound this mob makes when it is hurt. 044 */ 045 protected String getHurtSound() 046 { 047 return "mob.blaze.hit"; 048 } 049 050 /** 051 * Returns the sound this mob makes on death. 052 */ 053 protected String getDeathSound() 054 { 055 return "mob.blaze.death"; 056 } 057 058 @SideOnly(Side.CLIENT) 059 public int getBrightnessForRender(float par1) 060 { 061 return 15728880; 062 } 063 064 /** 065 * Gets how bright this entity is. 066 */ 067 public float getBrightness(float par1) 068 { 069 return 1.0F; 070 } 071 072 /** 073 * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons 074 * use this to react to sunlight and start to burn. 075 */ 076 public void onLivingUpdate() 077 { 078 if (!this.worldObj.isRemote) 079 { 080 if (this.isWet()) 081 { 082 this.attackEntityFrom(DamageSource.drown, 1); 083 } 084 085 --this.heightOffsetUpdateTime; 086 087 if (this.heightOffsetUpdateTime <= 0) 088 { 089 this.heightOffsetUpdateTime = 100; 090 this.heightOffset = 0.5F + (float)this.rand.nextGaussian() * 3.0F; 091 } 092 093 if (this.getEntityToAttack() != null && this.getEntityToAttack().posY + (double)this.getEntityToAttack().getEyeHeight() > this.posY + (double)this.getEyeHeight() + (double)this.heightOffset) 094 { 095 this.motionY += (0.30000001192092896D - this.motionY) * 0.30000001192092896D; 096 } 097 } 098 099 if (this.rand.nextInt(24) == 0) 100 { 101 this.worldObj.playSoundEffect(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D, "fire.fire", 1.0F + this.rand.nextFloat(), this.rand.nextFloat() * 0.7F + 0.3F); 102 } 103 104 if (!this.onGround && this.motionY < 0.0D) 105 { 106 this.motionY *= 0.6D; 107 } 108 109 for (int var1 = 0; var1 < 2; ++var1) 110 { 111 this.worldObj.spawnParticle("largesmoke", this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, this.posY + this.rand.nextDouble() * (double)this.height, this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, 0.0D, 0.0D, 0.0D); 112 } 113 114 super.onLivingUpdate(); 115 } 116 117 /** 118 * Basic mob attack. Default to touch of death in EntityCreature. Overridden by each mob to define their attack. 119 */ 120 protected void attackEntity(Entity par1Entity, float par2) 121 { 122 if (this.attackTime <= 0 && par2 < 2.0F && par1Entity.boundingBox.maxY > this.boundingBox.minY && par1Entity.boundingBox.minY < this.boundingBox.maxY) 123 { 124 this.attackTime = 20; 125 this.attackEntityAsMob(par1Entity); 126 } 127 else if (par2 < 30.0F) 128 { 129 double var3 = par1Entity.posX - this.posX; 130 double var5 = par1Entity.boundingBox.minY + (double)(par1Entity.height / 2.0F) - (this.posY + (double)(this.height / 2.0F)); 131 double var7 = par1Entity.posZ - this.posZ; 132 133 if (this.attackTime == 0) 134 { 135 ++this.field_70846_g; 136 137 if (this.field_70846_g == 1) 138 { 139 this.attackTime = 60; 140 this.func_70844_e(true); 141 } 142 else if (this.field_70846_g <= 4) 143 { 144 this.attackTime = 6; 145 } 146 else 147 { 148 this.attackTime = 100; 149 this.field_70846_g = 0; 150 this.func_70844_e(false); 151 } 152 153 if (this.field_70846_g > 1) 154 { 155 float var9 = MathHelper.sqrt_float(par2) * 0.5F; 156 this.worldObj.playAuxSFXAtEntity((EntityPlayer)null, 1009, (int)this.posX, (int)this.posY, (int)this.posZ, 0); 157 158 for (int var10 = 0; var10 < 1; ++var10) 159 { 160 EntitySmallFireball var11 = new EntitySmallFireball(this.worldObj, this, var3 + this.rand.nextGaussian() * (double)var9, var5, var7 + this.rand.nextGaussian() * (double)var9); 161 var11.posY = this.posY + (double)(this.height / 2.0F) + 0.5D; 162 this.worldObj.spawnEntityInWorld(var11); 163 } 164 } 165 } 166 167 this.rotationYaw = (float)(Math.atan2(var7, var3) * 180.0D / Math.PI) - 90.0F; 168 this.hasAttacked = true; 169 } 170 } 171 172 /** 173 * Called when the mob is falling. Calculates and applies fall damage. 174 */ 175 protected void fall(float par1) {} 176 177 /** 178 * Returns the item ID for the item the mob drops on death. 179 */ 180 protected int getDropItemId() 181 { 182 return Item.blazeRod.shiftedIndex; 183 } 184 185 /** 186 * Returns true if the entity is on fire. Used by render to add the fire effect on rendering. 187 */ 188 public boolean isBurning() 189 { 190 return this.func_70845_n(); 191 } 192 193 /** 194 * Drop 0-2 items of this living's type 195 */ 196 protected void dropFewItems(boolean par1, int par2) 197 { 198 if (par1) 199 { 200 int var3 = this.rand.nextInt(2 + par2); 201 202 for (int var4 = 0; var4 < var3; ++var4) 203 { 204 this.dropItem(Item.blazeRod.shiftedIndex, 1); 205 } 206 } 207 } 208 209 public boolean func_70845_n() 210 { 211 return (this.dataWatcher.getWatchableObjectByte(16) & 1) != 0; 212 } 213 214 public void func_70844_e(boolean par1) 215 { 216 byte var2 = this.dataWatcher.getWatchableObjectByte(16); 217 218 if (par1) 219 { 220 var2 = (byte)(var2 | 1); 221 } 222 else 223 { 224 var2 &= -2; 225 } 226 227 this.dataWatcher.updateObject(16, Byte.valueOf(var2)); 228 } 229 230 /** 231 * Checks to make sure the light is not too bright where the mob is spawning 232 */ 233 protected boolean isValidLightLevel() 234 { 235 return true; 236 } 237 238 /** 239 * Returns the amount of damage a mob should deal. 240 */ 241 public int getAttackStrength(Entity par1Entity) 242 { 243 return 6; 244 } 245 }