    001package net.minecraft.client.renderer.texturefx;
    002
    003import cpw.mods.fml.client.FMLTextureFX;
    004import cpw.mods.fml.relauncher.Side;
    005import cpw.mods.fml.relauncher.SideOnly;
    006import net.minecraft.block.Block;
    007import net.minecraft.util.MathHelper;
    008
    009@SideOnly(Side.CLIENT)
    010public class TextureLavaFX extends FMLTextureFX
    011{
    012    protected float[] field_76876_g = new float[256];
    013    protected float[] field_76878_h = new float[256];
    014    protected float[] field_76879_i = new float[256];
    015    protected float[] field_76877_j = new float[256];
    016
    017    public TextureLavaFX()
    018    {
    019        super(Block.lavaMoving.blockIndexInTexture);
    020        setup();
    021    }
    022
    023    @Override
    024    public void setup()
    025    {
    026        super.setup();
    027        field_76876_g = new float[tileSizeSquare];
    028        field_76878_h = new float[tileSizeSquare];
    029        field_76879_i = new float[tileSizeSquare];
    030        field_76877_j = new float[tileSizeSquare];
    031    }
    032
    033    public void onTick()
    034    {
    035        int var2;
    036        float var3;
    037        int var5;
    038        int var6;
    039        int var7;
    040        int var8;
    041        int var9;
    042
    043        for (int var1 = 0; var1 < tileSizeBase; ++var1)
    044        {
    045            for (var2 = 0; var2 < tileSizeBase; ++var2)
    046            {
    047                var3 = 0.0F;
    048                int var4 = (int)(MathHelper.sin((float)var2 * (float)Math.PI * 2.0F / 16.0F) * 1.2F);
    049                var5 = (int)(MathHelper.sin((float)var1 * (float)Math.PI * 2.0F / 16.0F) * 1.2F);
    050
    051                for (var6 = var1 - 1; var6 <= var1 + 1; ++var6)
    052                {
    053                    for (var7 = var2 - 1; var7 <= var2 + 1; ++var7)
    054                    {
    055                        var8 = var6 + var4 & tileSizeMask;
    056                        var9 = var7 + var5 & tileSizeMask;
    057                        var3 += this.field_76876_g[var8 + var9 * tileSizeBase];
    058                    }
    059                }
    060
    061                this.field_76878_h[var1 + var2 * tileSizeBase] = var3 / 10.0F + (this.field_76879_i[(var1 + 0 & tileSizeMask) + (var2 + 0 & tileSizeMask) * tileSizeBase] + this.field_76879_i[(var1 + 1 & tileSizeMask) + (var2 + 0 & tileSizeMask) * tileSizeBase] + this.field_76879_i[(var1 + 1 & tileSizeMask) + (var2 + 1 & tileSizeMask) * tileSizeBase] + this.field_76879_i[(var1 + 0 & tileSizeMask) + (var2 + 1 & tileSizeMask) * tileSizeBase]) / 4.0F * 0.8F;
    062                this.field_76879_i[var1 + var2 * tileSizeBase] += this.field_76877_j[var1 + var2 * tileSizeBase] * 0.01F;
    063
    064                if (this.field_76879_i[var1 + var2 * tileSizeBase] < 0.0F)
    065                {
    066                    this.field_76879_i[var1 + var2 * tileSizeBase] = 0.0F;
    067                }
    068
    069                this.field_76877_j[var1 + var2 * tileSizeBase] -= 0.06F;
    070
    071                if (Math.random() < 0.005D)
    072                {
    073                    this.field_76877_j[var1 + var2 * tileSizeBase] = 1.5F;
    074                }
    075            }
    076        }
    077
    078        float[] var11 = this.field_76878_h;
    079        this.field_76878_h = this.field_76876_g;
    080        this.field_76876_g = var11;
    081
    082        for (var2 = 0; var2 < tileSizeSquare; ++var2)
    083        {
    084            var3 = this.field_76876_g[var2] * 2.0F;
    085
    086            if (var3 > 1.0F)
    087            {
    088                var3 = 1.0F;
    089            }
    090
    091            if (var3 < 0.0F)
    092            {
    093                var3 = 0.0F;
    094            }
    095
    096            var5 = (int)(var3 * 100.0F + 155.0F);
    097            var6 = (int)(var3 * var3 * 255.0F);
    098            var7 = (int)(var3 * var3 * var3 * var3 * 128.0F);
    099
    100            if (this.anaglyphEnabled)
    101            {
    102                var8 = (var5 * 30 + var6 * 59 + var7 * 11) / 100;
    103                var9 = (var5 * 30 + var6 * 70) / 100;
    104                int var10 = (var5 * 30 + var7 * 70) / 100;
    105                var5 = var8;
    106                var6 = var9;
    107                var7 = var10;
    108            }
    109
    110            this.imageData[var2 * 4 + 0] = (byte)var5;
    111            this.imageData[var2 * 4 + 1] = (byte)var6;
    112            this.imageData[var2 * 4 + 2] = (byte)var7;
    113            this.imageData[var2 * 4 + 3] = -1;
    114        }
    115    }
    116}