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 EntityReddustFX extends EntityFX
010{
011    float reddustParticleScale;
012
013    public EntityReddustFX(World par1World, double par2, double par4, double par6, float par8, float par9, float par10)
014    {
015        this(par1World, par2, par4, par6, 1.0F, par8, par9, par10);
016    }
017
018    public EntityReddustFX(World par1World, double par2, double par4, double par6, float par8, float par9, float par10, float par11)
019    {
020        super(par1World, par2, par4, par6, 0.0D, 0.0D, 0.0D);
021        this.motionX *= 0.10000000149011612D;
022        this.motionY *= 0.10000000149011612D;
023        this.motionZ *= 0.10000000149011612D;
024
025        if (par9 == 0.0F)
026        {
027            par9 = 1.0F;
028        }
029
030        float var12 = (float)Math.random() * 0.4F + 0.6F;
031        this.particleRed = ((float)(Math.random() * 0.20000000298023224D) + 0.8F) * par9 * var12;
032        this.particleGreen = ((float)(Math.random() * 0.20000000298023224D) + 0.8F) * par10 * var12;
033        this.particleBlue = ((float)(Math.random() * 0.20000000298023224D) + 0.8F) * par11 * var12;
034        this.particleScale *= 0.75F;
035        this.particleScale *= par8;
036        this.reddustParticleScale = this.particleScale;
037        this.particleMaxAge = (int)(8.0D / (Math.random() * 0.8D + 0.2D));
038        this.particleMaxAge = (int)((float)this.particleMaxAge * par8);
039        this.noClip = false;
040    }
041
042    public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7)
043    {
044        float var8 = ((float)this.particleAge + par2) / (float)this.particleMaxAge * 32.0F;
045
046        if (var8 < 0.0F)
047        {
048            var8 = 0.0F;
049        }
050
051        if (var8 > 1.0F)
052        {
053            var8 = 1.0F;
054        }
055
056        this.particleScale = this.reddustParticleScale * var8;
057        super.renderParticle(par1Tessellator, par2, par3, par4, par5, par6, par7);
058    }
059
060    /**
061     * Called to update the entity's position/logic.
062     */
063    public void onUpdate()
064    {
065        this.prevPosX = this.posX;
066        this.prevPosY = this.posY;
067        this.prevPosZ = this.posZ;
068
069        if (this.particleAge++ >= this.particleMaxAge)
070        {
071            this.setDead();
072        }
073
074        this.setParticleTextureIndex(7 - this.particleAge * 8 / this.particleMaxAge);
075        this.moveEntity(this.motionX, this.motionY, this.motionZ);
076
077        if (this.posY == this.prevPosY)
078        {
079            this.motionX *= 1.1D;
080            this.motionZ *= 1.1D;
081        }
082
083        this.motionX *= 0.9599999785423279D;
084        this.motionY *= 0.9599999785423279D;
085        this.motionZ *= 0.9599999785423279D;
086
087        if (this.onGround)
088        {
089            this.motionX *= 0.699999988079071D;
090            this.motionZ *= 0.699999988079071D;
091        }
092    }
093}