001 package net.minecraft.src;
002
003 import cpw.mods.fml.common.Side;
004 import cpw.mods.fml.common.asm.SideOnly;
005
006 @SideOnly(Side.CLIENT)
007 public class EntityFlameFX extends EntityFX
008 {
009 /** the scale of the flame FX */
010 private float flameScale;
011
012 public EntityFlameFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12)
013 {
014 super(par1World, par2, par4, par6, par8, par10, par12);
015 this.motionX = this.motionX * 0.009999999776482582D + par8;
016 this.motionY = this.motionY * 0.009999999776482582D + par10;
017 this.motionZ = this.motionZ * 0.009999999776482582D + par12;
018 double var10000 = par2 + (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.05F);
019 var10000 = par4 + (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.05F);
020 var10000 = par6 + (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.05F);
021 this.flameScale = this.particleScale;
022 this.particleRed = this.particleGreen = this.particleBlue = 1.0F;
023 this.particleMaxAge = (int)(8.0D / (Math.random() * 0.8D + 0.2D)) + 4;
024 this.noClip = true;
025 this.setParticleTextureIndex(48);
026 }
027
028 public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7)
029 {
030 float var8 = ((float)this.particleAge + par2) / (float)this.particleMaxAge;
031 this.particleScale = this.flameScale * (1.0F - var8 * var8 * 0.5F);
032 super.renderParticle(par1Tessellator, par2, par3, par4, par5, par6, par7);
033 }
034
035 public int getBrightnessForRender(float par1)
036 {
037 float var2 = ((float)this.particleAge + par1) / (float)this.particleMaxAge;
038
039 if (var2 < 0.0F)
040 {
041 var2 = 0.0F;
042 }
043
044 if (var2 > 1.0F)
045 {
046 var2 = 1.0F;
047 }
048
049 int var3 = super.getBrightnessForRender(par1);
050 int var4 = var3 & 255;
051 int var5 = var3 >> 16 & 255;
052 var4 += (int)(var2 * 15.0F * 16.0F);
053
054 if (var4 > 240)
055 {
056 var4 = 240;
057 }
058
059 return var4 | var5 << 16;
060 }
061
062 /**
063 * Gets how bright this entity is.
064 */
065 public float getBrightness(float par1)
066 {
067 float var2 = ((float)this.particleAge + par1) / (float)this.particleMaxAge;
068
069 if (var2 < 0.0F)
070 {
071 var2 = 0.0F;
072 }
073
074 if (var2 > 1.0F)
075 {
076 var2 = 1.0F;
077 }
078
079 float var3 = super.getBrightness(par1);
080 return var3 * var2 + (1.0F - var2);
081 }
082
083 /**
084 * Called to update the entity's position/logic.
085 */
086 public void onUpdate()
087 {
088 this.prevPosX = this.posX;
089 this.prevPosY = this.posY;
090 this.prevPosZ = this.posZ;
091
092 if (this.particleAge++ >= this.particleMaxAge)
093 {
094 this.setDead();
095 }
096
097 this.moveEntity(this.motionX, this.motionY, this.motionZ);
098 this.motionX *= 0.9599999785423279D;
099 this.motionY *= 0.9599999785423279D;
100 this.motionZ *= 0.9599999785423279D;
101
102 if (this.onGround)
103 {
104 this.motionX *= 0.699999988079071D;
105 this.motionZ *= 0.699999988079071D;
106 }
107 }
108 }