    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 EntityPortalFX extends EntityFX
    010    {
    011        private float portalParticleScale;
    012        private double portalPosX;
    013        private double portalPosY;
    014        private double portalPosZ;
    015
    016        public EntityPortalFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12)
    017        {
    018            super(par1World, par2, par4, par6, par8, par10, par12);
    019            this.motionX = par8;
    020            this.motionY = par10;
    021            this.motionZ = par12;
    022            this.portalPosX = this.posX = par2;
    023            this.portalPosY = this.posY = par4;
    024            this.portalPosZ = this.posZ = par6;
    025            float var14 = this.rand.nextFloat() * 0.6F + 0.4F;
    026            this.portalParticleScale = this.particleScale = this.rand.nextFloat() * 0.2F + 0.5F;
    027            this.particleRed = this.particleGreen = this.particleBlue = 1.0F * var14;
    028            this.particleGreen *= 0.3F;
    029            this.particleRed *= 0.9F;
    030            this.particleMaxAge = (int)(Math.random() * 10.0D) + 40;
    031            this.noClip = true;
    032            this.setParticleTextureIndex((int)(Math.random() * 8.0D));
    033        }
    034
    035        public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7)
    036        {
    037            float var8 = ((float)this.particleAge + par2) / (float)this.particleMaxAge;
    038            var8 = 1.0F - var8;
    039            var8 *= var8;
    040            var8 = 1.0F - var8;
    041            this.particleScale = this.portalParticleScale * var8;
    042            super.renderParticle(par1Tessellator, par2, par3, par4, par5, par6, par7);
    043        }
    044
    045        public int getBrightnessForRender(float par1)
    046        {
    047            int var2 = super.getBrightnessForRender(par1);
    048            float var3 = (float)this.particleAge / (float)this.particleMaxAge;
    049            var3 *= var3;
    050            var3 *= var3;
    051            int var4 = var2 & 255;
    052            int var5 = var2 >> 16 & 255;
    053            var5 += (int)(var3 * 15.0F * 16.0F);
    054
    055            if (var5 > 240)
    056            {
    057                var5 = 240;
    058            }
    059
    060            return var4 | var5 << 16;
    061        }
    062
    063        /**
    064         * Gets how bright this entity is.
    065         */
    066        public float getBrightness(float par1)
    067        {
    068            float var2 = super.getBrightness(par1);
    069            float var3 = (float)this.particleAge / (float)this.particleMaxAge;
    070            var3 = var3 * var3 * var3 * var3;
    071            return var2 * (1.0F - var3) + var3;
    072        }
    073
    074        /**
    075         * Called to update the entity's position/logic.
    076         */
    077        public void onUpdate()
    078        {
    079            this.prevPosX = this.posX;
    080            this.prevPosY = this.posY;
    081            this.prevPosZ = this.posZ;
    082            float var1 = (float)this.particleAge / (float)this.particleMaxAge;
    083            float var2 = var1;
    084            var1 = -var1 + var1 * var1 * 2.0F;
    085            var1 = 1.0F - var1;
    086            this.posX = this.portalPosX + this.motionX * (double)var1;
    087            this.posY = this.portalPosY + this.motionY * (double)var1 + (double)(1.0F - var2);
    088            this.posZ = this.portalPosZ + this.motionZ * (double)var1;
    089
    090            if (this.particleAge++ >= this.particleMaxAge)
    091            {
    092                this.setDead();
    093            }
    094        }
    095    }