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