    001package net.minecraft.client.particle;
    002
    003import cpw.mods.fml.relauncher.Side;
    004import cpw.mods.fml.relauncher.SideOnly;
    005import net.minecraft.block.Block;
    006import net.minecraft.client.renderer.Tessellator;
    007import net.minecraft.world.World;
    008
    009@SideOnly(Side.CLIENT)
    010public class EntityDiggingFX extends EntityFX
    011{
    012    private Block blockInstance;
    013    private int side;
    014
    015    public EntityDiggingFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12, Block par14Block, int par15, int par16)
    016    {
    017        super(par1World, par2, par4, par6, par8, par10, par12);
    018        this.blockInstance = par14Block;
    019        this.setParticleTextureIndex(par14Block.getBlockTextureFromSideAndMetadata(par15, par16));
    020        this.particleGravity = par14Block.blockParticleGravity;
    021        this.particleRed = this.particleGreen = this.particleBlue = 0.6F;
    022        this.particleScale /= 2.0F;
    023        this.side = par15;
    024    }
    025
    026    public EntityDiggingFX func_70596_a(int par1, int par2, int par3)
    027    {
    028        if (this.blockInstance == Block.grass && this.side != 1)
    029        {
    030            return this;
    031        }
    032        else
    033        {
    034            int var4 = this.blockInstance.colorMultiplier(this.worldObj, par1, par2, par3);
    035            this.particleRed *= (float)(var4 >> 16 & 255) / 255.0F;
    036            this.particleGreen *= (float)(var4 >> 8 & 255) / 255.0F;
    037            this.particleBlue *= (float)(var4 & 255) / 255.0F;
    038            return this;
    039        }
    040    }
    041
    042    /**
    043     * Creates a new EntityDiggingFX with the block render color applied to the base particle color
    044     */
    045    public EntityDiggingFX applyRenderColor(int par1)
    046    {
    047        if (this.blockInstance == Block.grass)
    048        {
    049            return this;
    050        }
    051        else
    052        {
    053            int var2 = this.blockInstance.getRenderColor(par1);
    054            this.particleRed *= (float)(var2 >> 16 & 255) / 255.0F;
    055            this.particleGreen *= (float)(var2 >> 8 & 255) / 255.0F;
    056            this.particleBlue *= (float)(var2 & 255) / 255.0F;
    057            return this;
    058        }
    059    }
    060
    061    public int getFXLayer()
    062    {
    063        return 1;
    064    }
    065
    066    public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7)
    067    {
    068        float var8 = ((float)(this.getParticleTextureIndex() % 16) + this.particleTextureJitterX / 4.0F) / 16.0F;
    069        float var9 = var8 + 0.015609375F;
    070        float var10 = ((float)(this.getParticleTextureIndex() / 16) + this.particleTextureJitterY / 4.0F) / 16.0F;
    071        float var11 = var10 + 0.015609375F;
    072        float var12 = 0.1F * this.particleScale;
    073        float var13 = (float)(this.prevPosX + (this.posX - this.prevPosX) * (double)par2 - interpPosX);
    074        float var14 = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)par2 - interpPosY);
    075        float var15 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)par2 - interpPosZ);
    076        float var16 = 1.0F;
    077        par1Tessellator.setColorOpaque_F(var16 * this.particleRed, var16 * this.particleGreen, var16 * this.particleBlue);
    078        par1Tessellator.addVertexWithUV((double)(var13 - par3 * var12 - par6 * var12), (double)(var14 - par4 * var12), (double)(var15 - par5 * var12 - par7 * var12), (double)var8, (double)var11);
    079        par1Tessellator.addVertexWithUV((double)(var13 - par3 * var12 + par6 * var12), (double)(var14 + par4 * var12), (double)(var15 - par5 * var12 + par7 * var12), (double)var8, (double)var10);
    080        par1Tessellator.addVertexWithUV((double)(var13 + par3 * var12 + par6 * var12), (double)(var14 + par4 * var12), (double)(var15 + par5 * var12 + par7 * var12), (double)var9, (double)var10);
    081        par1Tessellator.addVertexWithUV((double)(var13 + par3 * var12 - par6 * var12), (double)(var14 - par4 * var12), (double)(var15 + par5 * var12 - par7 * var12), (double)var9, (double)var11);
    082    }
    083}