    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 TextureFlamesFX extends FMLTextureFX
    009    {
    010        protected float[] field_76869_g = new float[320];
    011        protected float[] field_76870_h = new float[320];
    012        private int fireTileSize = 20;
    013        private int fireGridSize = 320;
    014
    015        public TextureFlamesFX(int par1)
    016        {
    017            super(Block.fire.blockIndexInTexture + par1 * 16);
    018            setup();
    019        }
    020
    021        @Override
    022        public void setup()
    023        {
    024            super.setup();
    025            fireTileSize = tileSizeBase + (tileSizeBase >> 2);
    026            fireGridSize = fireTileSize * tileSizeBase;
    027            field_76869_g = new float[fireGridSize];
    028            field_76870_h = new float[fireGridSize];
    029        }
    030
    031        public void onTick()
    032        {
    033            int var3;
    034            float var4;
    035            int var6;
    036
    037            float fireFactor1 = 3.0F + (float)(tileSizeBase >> 4);
    038
    039            float fireFactor2 = 1.01F + (0.8F / tileSizeBase);
    040
    041            for (int var1 = 0; var1 < tileSizeBase; ++var1)
    042            {
    043                for (int var2 = 0; var2 < fireTileSize; ++var2)
    044                {
    045                    var3 = fireTileSize - (tileSizeBase >> 3);
    046
    047                    var4 = this.field_76869_g[var1 + (var2 + 1) % fireTileSize * tileSizeBase] * (float)var3;
    048
    049                    for (int var5 = var1 - 1; var5 <= var1 + 1; ++var5)
    050                    {
    051                        for (var6 = var2; var6 <= var2 + 1; ++var6)
    052                        {
    053                            if (var5 >= 0 && var6 >= 0 && var5 < tileSizeBase && var6 < fireTileSize)
    054                            {
    055                                var4 += this.field_76869_g[var5 + var6 * tileSizeBase];
    056                            }
    057
    058                            ++var3;
    059                        }
    060                    }
    061
    062                    this.field_76870_h[var1 + var2 * tileSizeBase] = var4 / ((float)var3 * fireFactor2);
    063
    064                    if (var2 >= fireTileSize - (tileSizeBase >> 4))
    065                    {
    066                        this.field_76870_h[var1 + var2 * tileSizeBase] = (float)(Math.random() * Math.random() * Math.random() * fireFactor1 + Math.random() * 0.1F + 0.2F);
    067                    }
    068                }
    069            }
    070
    071            float[] var13 = this.field_76870_h;
    072            this.field_76870_h = this.field_76869_g;
    073            this.field_76869_g = var13;
    074
    075            for (var3 = 0; var3 < tileSizeSquare; ++var3)
    076            {
    077                var4 = this.field_76869_g[var3] * 1.8F;
    078
    079                if (var4 > 1.0F)
    080                {
    081                    var4 = 1.0F;
    082                }
    083
    084                if (var4 < 0.0F)
    085                {
    086                    var4 = 0.0F;
    087                }
    088
    089                var6 = (int)(var4 * 155.0F + 100.0F);
    090                int var7 = (int)(var4 * var4 * 255.0F);
    091                int var8 = (int)(var4 * var4 * var4 * var4 * var4 * var4 * var4 * var4 * var4 * var4 * 255.0F);
    092                short var9 = 255;
    093
    094                if (var4 < 0.5F)
    095                {
    096                    var9 = 0;
    097                }
    098
    099                float var14 = (var4 - 0.5F) * 2.0F;
    100
    101                if (this.anaglyphEnabled)
    102                {
    103                    int var10 = (var6 * 30 + var7 * 59 + var8 * 11) / 100;
    104                    int var11 = (var6 * 30 + var7 * 70) / 100;
    105                    int var12 = (var6 * 30 + var8 * 70) / 100;
    106                    var6 = var10;
    107                    var7 = var11;
    108                    var8 = var12;
    109                }
    110
    111                this.imageData[var3 * 4 + 0] = (byte)var6;
    112                this.imageData[var3 * 4 + 1] = (byte)var7;
    113                this.imageData[var3 * 4 + 2] = (byte)var8;
    114                this.imageData[var3 * 4 + 3] = (byte)var9;
    115            }
    116        }
    117    }