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