    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.entity.Entity;
    007import net.minecraft.world.World;
    008
    009@SideOnly(Side.CLIENT)
    010public class EntityCrit2FX extends EntityFX
    011{
    012    /** Entity that had been hit and done the Critical hit on. */
    013    private Entity theEntity;
    014    private int currentLife;
    015    private int maximumLife;
    016    private String particleName;
    017
    018    public EntityCrit2FX(World par1World, Entity par2Entity)
    019    {
    020        this(par1World, par2Entity, "crit");
    021    }
    022
    023    public EntityCrit2FX(World par1World, Entity par2Entity, String par3Str)
    024    {
    025        super(par1World, par2Entity.posX, par2Entity.boundingBox.minY + (double)(par2Entity.height / 2.0F), par2Entity.posZ, par2Entity.motionX, par2Entity.motionY, par2Entity.motionZ);
    026        this.currentLife = 0;
    027        this.maximumLife = 0;
    028        this.theEntity = par2Entity;
    029        this.maximumLife = 3;
    030        this.particleName = par3Str;
    031        this.onUpdate();
    032    }
    033
    034    public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) {}
    035
    036    /**
    037     * Called to update the entity's position/logic.
    038     */
    039    public void onUpdate()
    040    {
    041        for (int var1 = 0; var1 < 16; ++var1)
    042        {
    043            double var2 = (double)(this.rand.nextFloat() * 2.0F - 1.0F);
    044            double var4 = (double)(this.rand.nextFloat() * 2.0F - 1.0F);
    045            double var6 = (double)(this.rand.nextFloat() * 2.0F - 1.0F);
    046
    047            if (var2 * var2 + var4 * var4 + var6 * var6 <= 1.0D)
    048            {
    049                double var8 = this.theEntity.posX + var2 * (double)this.theEntity.width / 4.0D;
    050                double var10 = this.theEntity.boundingBox.minY + (double)(this.theEntity.height / 2.0F) + var4 * (double)this.theEntity.height / 4.0D;
    051                double var12 = this.theEntity.posZ + var6 * (double)this.theEntity.width / 4.0D;
    052                this.worldObj.spawnParticle(this.particleName, var8, var10, var12, var2, var4 + 0.2D, var6);
    053            }
    054        }
    055
    056        ++this.currentLife;
    057
    058        if (this.currentLife >= this.maximumLife)
    059        {
    060            this.setDead();
    061        }
    062    }
    063
    064    public int getFXLayer()
    065    {
    066        return 3;
    067    }
    068}