    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 d6 = par2 + (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.05F);
    021        d6 = par4 + (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.05F);
    022        d6 = 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 f6 = ((float)this.particleAge + par2) / (float)this.particleMaxAge;
    033        this.particleScale = this.flameScale * (1.0F - f6 * f6 * 0.5F);
    034        super.renderParticle(par1Tessellator, par2, par3, par4, par5, par6, par7);
    035    }
    036
    037    public int getBrightnessForRender(float par1)
    038    {
    039        float f1 = ((float)this.particleAge + par1) / (float)this.particleMaxAge;
    040
    041        if (f1 < 0.0F)
    042        {
    043            f1 = 0.0F;
    044        }
    045
    046        if (f1 > 1.0F)
    047        {
    048            f1 = 1.0F;
    049        }
    050
    051        int i = super.getBrightnessForRender(par1);
    052        int j = i & 255;
    053        int k = i >> 16 & 255;
    054        j += (int)(f1 * 15.0F * 16.0F);
    055
    056        if (j > 240)
    057        {
    058            j = 240;
    059        }
    060
    061        return j | k << 16;
    062    }
    063
    064    /**
    065     * Gets how bright this entity is.
    066     */
    067    public float getBrightness(float par1)
    068    {
    069        float f1 = ((float)this.particleAge + par1) / (float)this.particleMaxAge;
    070
    071        if (f1 < 0.0F)
    072        {
    073            f1 = 0.0F;
    074        }
    075
    076        if (f1 > 1.0F)
    077        {
    078            f1 = 1.0F;
    079        }
    080
    081        float f2 = super.getBrightness(par1);
    082        return f2 * f1 + (1.0F - f1);
    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}