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.RenderEngine;
007import net.minecraft.client.renderer.Tessellator;
008import net.minecraft.world.World;
009
010@SideOnly(Side.CLIENT)
011public class EntityDiggingFX extends EntityFX
012{
013    private Block blockInstance;
014    private int side;
015
016    public EntityDiggingFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12, Block par14Block, int par15, int par16, RenderEngine par17RenderEngine)
017    {
018        super(par1World, par2, par4, par6, par8, par10, par12);
019        this.blockInstance = par14Block;
020        this.setParticleIcon(par17RenderEngine, par14Block.getIcon(par15, par16));
021        this.particleGravity = par14Block.blockParticleGravity;
022        this.particleRed = this.particleGreen = this.particleBlue = 0.6F;
023        this.particleScale /= 2.0F;
024        this.side = par15;
025    }
026
027    public EntityDiggingFX func_70596_a(int par1, int par2, int par3)
028    {
029        if (this.blockInstance == Block.grass && this.side != 1)
030        {
031            return this;
032        }
033        else
034        {
035            int l = this.blockInstance.colorMultiplier(this.worldObj, par1, par2, par3);
036            this.particleRed *= (float)(l >> 16 & 255) / 255.0F;
037            this.particleGreen *= (float)(l >> 8 & 255) / 255.0F;
038            this.particleBlue *= (float)(l & 255) / 255.0F;
039            return this;
040        }
041    }
042
043    /**
044     * Creates a new EntityDiggingFX with the block render color applied to the base particle color
045     */
046    public EntityDiggingFX applyRenderColor(int par1)
047    {
048        if (this.blockInstance == Block.grass)
049        {
050            return this;
051        }
052        else
053        {
054            int j = this.blockInstance.getRenderColor(par1);
055            this.particleRed *= (float)(j >> 16 & 255) / 255.0F;
056            this.particleGreen *= (float)(j >> 8 & 255) / 255.0F;
057            this.particleBlue *= (float)(j & 255) / 255.0F;
058            return this;
059        }
060    }
061
062    public int getFXLayer()
063    {
064        return 1;
065    }
066
067    public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7)
068    {
069        float f6 = ((float)this.particleTextureIndexX + this.particleTextureJitterX / 4.0F) / 16.0F;
070        float f7 = f6 + 0.015609375F;
071        float f8 = ((float)this.particleTextureIndexY + this.particleTextureJitterY / 4.0F) / 16.0F;
072        float f9 = f8 + 0.015609375F;
073        float f10 = 0.1F * this.particleScale;
074
075        if (this.particleTextureIndex != null)
076        {
077            f6 = this.particleTextureIndex.getInterpolatedU((double)(this.particleTextureJitterX / 4.0F * 16.0F));
078            f7 = this.particleTextureIndex.getInterpolatedU((double)((this.particleTextureJitterX + 1.0F) / 4.0F * 16.0F));
079            f8 = this.particleTextureIndex.getInterpolatedV((double)(this.particleTextureJitterY / 4.0F * 16.0F));
080            f9 = this.particleTextureIndex.getInterpolatedV((double)((this.particleTextureJitterY + 1.0F) / 4.0F * 16.0F));
081        }
082
083        float f11 = (float)(this.prevPosX + (this.posX - this.prevPosX) * (double)par2 - interpPosX);
084        float f12 = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)par2 - interpPosY);
085        float f13 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)par2 - interpPosZ);
086        float f14 = 1.0F;
087        par1Tessellator.setColorOpaque_F(f14 * this.particleRed, f14 * this.particleGreen, f14 * this.particleBlue);
088        par1Tessellator.addVertexWithUV((double)(f11 - par3 * f10 - par6 * f10), (double)(f12 - par4 * f10), (double)(f13 - par5 * f10 - par7 * f10), (double)f6, (double)f9);
089        par1Tessellator.addVertexWithUV((double)(f11 - par3 * f10 + par6 * f10), (double)(f12 + par4 * f10), (double)(f13 - par5 * f10 + par7 * f10), (double)f6, (double)f8);
090        par1Tessellator.addVertexWithUV((double)(f11 + par3 * f10 + par6 * f10), (double)(f12 + par4 * f10), (double)(f13 + par5 * f10 + par7 * f10), (double)f7, (double)f8);
091        par1Tessellator.addVertexWithUV((double)(f11 + par3 * f10 - par6 * f10), (double)(f12 - par4 * f10), (double)(f13 + par5 * f10 - par7 * f10), (double)f7, (double)f9);
092    }
093}