001    package net.minecraft.client.particle;
002    
003    import cpw.mods.fml.relauncher.Side;
004    import cpw.mods.fml.relauncher.SideOnly;
005    import net.minecraft.client.renderer.Tessellator;
006    import net.minecraft.world.World;
007    
008    @SideOnly(Side.CLIENT)
009    public class EntitySpellParticleFX extends EntityFX
010    {
011        /** Base spell texture index */
012        private int baseSpellTextureIndex = 128;
013    
014        public EntitySpellParticleFX(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.motionY *= 0.20000000298023224D;
018    
019            if (par8 == 0.0D && par12 == 0.0D)
020            {
021                this.motionX *= 0.10000000149011612D;
022                this.motionZ *= 0.10000000149011612D;
023            }
024    
025            this.particleScale *= 0.75F;
026            this.particleMaxAge = (int)(8.0D / (Math.random() * 0.8D + 0.2D));
027            this.noClip = false;
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 * 32.0F;
033    
034            if (var8 < 0.0F)
035            {
036                var8 = 0.0F;
037            }
038    
039            if (var8 > 1.0F)
040            {
041                var8 = 1.0F;
042            }
043    
044            super.renderParticle(par1Tessellator, par2, par3, par4, par5, par6, par7);
045        }
046    
047        /**
048         * Called to update the entity's position/logic.
049         */
050        public void onUpdate()
051        {
052            this.prevPosX = this.posX;
053            this.prevPosY = this.posY;
054            this.prevPosZ = this.posZ;
055    
056            if (this.particleAge++ >= this.particleMaxAge)
057            {
058                this.setDead();
059            }
060    
061            this.setParticleTextureIndex(this.baseSpellTextureIndex + (7 - this.particleAge * 8 / this.particleMaxAge));
062            this.motionY += 0.004D;
063            this.moveEntity(this.motionX, this.motionY, this.motionZ);
064    
065            if (this.posY == this.prevPosY)
066            {
067                this.motionX *= 1.1D;
068                this.motionZ *= 1.1D;
069            }
070    
071            this.motionX *= 0.9599999785423279D;
072            this.motionY *= 0.9599999785423279D;
073            this.motionZ *= 0.9599999785423279D;
074    
075            if (this.onGround)
076            {
077                this.motionX *= 0.699999988079071D;
078                this.motionZ *= 0.699999988079071D;
079            }
080        }
081    
082        /**
083         * Sets the base spell texture index
084         */
085        public void setBaseSpellTextureIndex(int par1)
086        {
087            this.baseSpellTextureIndex = par1;
088        }
089    }