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 i = 0; i < 16; ++i)
042        {
043            double d0 = (double)(this.rand.nextFloat() * 2.0F - 1.0F);
044            double d1 = (double)(this.rand.nextFloat() * 2.0F - 1.0F);
045            double d2 = (double)(this.rand.nextFloat() * 2.0F - 1.0F);
046
047            if (d0 * d0 + d1 * d1 + d2 * d2 <= 1.0D)
048            {
049                double d3 = this.theEntity.posX + d0 * (double)this.theEntity.width / 4.0D;
050                double d4 = this.theEntity.boundingBox.minY + (double)(this.theEntity.height / 2.0F) + d1 * (double)this.theEntity.height / 4.0D;
051                double d5 = this.theEntity.posZ + d2 * (double)this.theEntity.width / 4.0D;
052                this.worldObj.spawnParticle(this.particleName, d3, d4, d5, d0, d1 + 0.2D, d2);
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}