    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;
    007
    008@SideOnly(Side.CLIENT)
    009public class TextureWaterFX extends FMLTextureFX
    010{
    011    /** red RGB value for water texture */
    012    protected float[] red = new float[256];
    013
    014    /** green RGB value for water texture */
    015    protected float[] green = new float[256];
    016
    017    /** blue RGB value for water texture */
    018    protected float[] blue = new float[256];
    019
    020    /** alpha RGB value for water texture */
    021    protected float[] alpha = new float[256];
    022    private int tickCounter = 0;
    023
    024    public TextureWaterFX()
    025    {
    026        super(Block.waterMoving.blockIndexInTexture);
    027        setup();
    028    }
    029
    030    @Override
    031    public void setup()
    032    {
    033        super.setup();
    034        red = new float[tileSizeSquare];
    035        green = new float[tileSizeSquare];
    036        blue = new float[tileSizeSquare];
    037        alpha = new float[tileSizeSquare];
    038        tickCounter = 0;
    039    }
    040
    041    public void onTick()
    042    {
    043        ++this.tickCounter;
    044        int var1;
    045        int var2;
    046        float var3;
    047        int var5;
    048        int var6;
    049
    050        for (var1 = 0; var1 < tileSizeBase; ++var1)
    051        {
    052            for (var2 = 0; var2 < tileSizeBase; ++var2)
    053            {
    054                var3 = 0.0F;
    055
    056                for (int var4 = var1 - 1; var4 <= var1 + 1; ++var4)
    057                {
    058                    var5 = var4 & tileSizeMask;
    059                    var6 = var2 & tileSizeMask;
    060                    var3 += this.red[var5 + var6 * tileSizeBase];
    061                }
    062
    063                this.green[var1 + var2 * tileSizeBase] = var3 / 3.3F + this.blue[var1 + var2 * tileSizeBase] * 0.8F;
    064            }
    065        }
    066
    067        for (var1 = 0; var1 < tileSizeBase; ++var1)
    068        {
    069            for (var2 = 0; var2 < tileSizeBase; ++var2)
    070            {
    071                this.blue[var1 + var2 * tileSizeBase] += this.alpha[var1 + var2 * tileSizeBase] * 0.05F;
    072
    073                if (this.blue[var1 + var2 * tileSizeBase] < 0.0F)
    074                {
    075                    this.blue[var1 + var2 * tileSizeBase] = 0.0F;
    076                }
    077
    078                this.alpha[var1 + var2 * tileSizeBase] -= 0.1F;
    079
    080                if (Math.random() < 0.05D)
    081                {
    082                    this.alpha[var1 + var2 * tileSizeBase] = 0.5F;
    083                }
    084            }
    085        }
    086
    087        float[] var12 = this.green;
    088        this.green = this.red;
    089        this.red = var12;
    090
    091        for (var2 = 0; var2 < tileSizeSquare; ++var2)
    092        {
    093            var3 = this.red[var2];
    094
    095            if (var3 > 1.0F)
    096            {
    097                var3 = 1.0F;
    098            }
    099
    100            if (var3 < 0.0F)
    101            {
    102                var3 = 0.0F;
    103            }
    104
    105            float var13 = var3 * var3;
    106            var5 = (int)(32.0F + var13 * 32.0F);
    107            var6 = (int)(50.0F + var13 * 64.0F);
    108            int var7 = 255;
    109            int var8 = (int)(146.0F + var13 * 50.0F);
    110
    111            if (this.anaglyphEnabled)
    112            {
    113                int var9 = (var5 * 30 + var6 * 59 + var7 * 11) / 100;
    114                int var10 = (var5 * 30 + var6 * 70) / 100;
    115                int var11 = (var5 * 30 + var7 * 70) / 100;
    116                var5 = var9;
    117                var6 = var10;
    118                var7 = var11;
    119            }
    120
    121            this.imageData[var2 * 4 + 0] = (byte)var5;
    122            this.imageData[var2 * 4 + 1] = (byte)var6;
    123            this.imageData[var2 * 4 + 2] = (byte)var7;
    124            this.imageData[var2 * 4 + 3] = (byte)var8;
    125        }
    126    }
    127}