    001package net.minecraft.client.particle;
    002
    003import cpw.mods.fml.relauncher.Side;
    004import cpw.mods.fml.relauncher.SideOnly;
    005import net.minecraft.world.World;
    006
    007@SideOnly(Side.CLIENT)
    008public class EntityEnchantmentTableParticleFX extends EntityFX
    009{
    010    private float field_70565_a;
    011    private double field_70568_aq;
    012    private double field_70567_ar;
    013    private double field_70566_as;
    014
    015    public EntityEnchantmentTableParticleFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12)
    016    {
    017        super(par1World, par2, par4, par6, par8, par10, par12);
    018        this.motionX = par8;
    019        this.motionY = par10;
    020        this.motionZ = par12;
    021        this.field_70568_aq = this.posX = par2;
    022        this.field_70567_ar = this.posY = par4;
    023        this.field_70566_as = this.posZ = par6;
    024        float f = this.rand.nextFloat() * 0.6F + 0.4F;
    025        this.field_70565_a = this.particleScale = this.rand.nextFloat() * 0.5F + 0.2F;
    026        this.particleRed = this.particleGreen = this.particleBlue = 1.0F * f;
    027        this.particleGreen *= 0.9F;
    028        this.particleRed *= 0.9F;
    029        this.particleMaxAge = (int)(Math.random() * 10.0D) + 30;
    030        this.noClip = true;
    031        this.setParticleTextureIndex((int)(Math.random() * 26.0D + 1.0D + 224.0D));
    032    }
    033
    034    public int getBrightnessForRender(float par1)
    035    {
    036        int i = super.getBrightnessForRender(par1);
    037        float f1 = (float)this.particleAge / (float)this.particleMaxAge;
    038        f1 *= f1;
    039        f1 *= f1;
    040        int j = i & 255;
    041        int k = i >> 16 & 255;
    042        k += (int)(f1 * 15.0F * 16.0F);
    043
    044        if (k > 240)
    045        {
    046            k = 240;
    047        }
    048
    049        return j | k << 16;
    050    }
    051
    052    /**
    053     * Gets how bright this entity is.
    054     */
    055    public float getBrightness(float par1)
    056    {
    057        float f1 = super.getBrightness(par1);
    058        float f2 = (float)this.particleAge / (float)this.particleMaxAge;
    059        f2 *= f2;
    060        f2 *= f2;
    061        return f1 * (1.0F - f2) + f2;
    062    }
    063
    064    /**
    065     * Called to update the entity's position/logic.
    066     */
    067    public void onUpdate()
    068    {
    069        this.prevPosX = this.posX;
    070        this.prevPosY = this.posY;
    071        this.prevPosZ = this.posZ;
    072        float f = (float)this.particleAge / (float)this.particleMaxAge;
    073        f = 1.0F - f;
    074        float f1 = 1.0F - f;
    075        f1 *= f1;
    076        f1 *= f1;
    077        this.posX = this.field_70568_aq + this.motionX * (double)f;
    078        this.posY = this.field_70567_ar + this.motionY * (double)f - (double)(f1 * 1.2F);
    079        this.posZ = this.field_70566_as + this.motionZ * (double)f;
    080
    081        if (this.particleAge++ >= this.particleMaxAge)
    082        {
    083            this.setDead();
    084        }
    085    }
    086}