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