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