    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    import java.util.Random;
    007
    008    @SideOnly(Side.CLIENT)
    009    public class TexturePortalFX extends FMLTextureFX
    010    {
    011        /** Portal tick counter */
    012        private int portalTickCounter = 0;
    013
    014        /** Portal texture data */
    015        private byte[][] portalTextureData;
    016
    017        public TexturePortalFX()
    018        {
    019            super(Block.portal.blockIndexInTexture);
    020            setup();
    021        }
    022
    023        @Override
    024        public void setup()
    025        {
    026            super.setup();
    027            portalTextureData = new byte[32][tileSizeSquare << 4];
    028            Random var1 = new Random(100L);
    029
    030            for (int var2 = 0; var2 < 32; ++var2)
    031            {
    032                for (int var3 = 0; var3 < tileSizeBase; ++var3)
    033                {
    034                    for (int var4 = 0; var4 < tileSizeBase; ++var4)
    035                    {
    036                        float var5 = 0.0F;
    037                        int var6;
    038
    039                        for (var6 = 0; var6 < 2; ++var6)
    040                        {
    041                            float var7 = (float)(var6 * tileSizeBase) * 0.5F;
    042                            float var8 = (float)(var6 * tileSizeBase) * 0.5F;
    043                            float var9 = ((float)var3 - var7) / (float)tileSizeBase * 2.0F;
    044                            float var10 = ((float)var4 - var8) / (float)tileSizeBase * 2.0F;
    045
    046                            if (var9 < -1.0F)
    047                            {
    048                                var9 += 2.0F;
    049                            }
    050
    051                            if (var9 >= 1.0F)
    052                            {
    053                                var9 -= 2.0F;
    054                            }
    055
    056                            if (var10 < -1.0F)
    057                            {
    058                                var10 += 2.0F;
    059                            }
    060
    061                            if (var10 >= 1.0F)
    062                            {
    063                                var10 -= 2.0F;
    064                            }
    065
    066                            float var11 = var9 * var9 + var10 * var10;
    067                            float var12 = (float)Math.atan2((double)var10, (double)var9) + ((float)var2 / 32.0F * (float)Math.PI * 2.0F - var11 * 10.0F + (float)(var6 * 2)) * (float)(var6 * 2 - 1);
    068                            var12 = (MathHelper.sin(var12) + 1.0F) / 2.0F;
    069                            var12 /= var11 + 1.0F;
    070                            var5 += var12 * 0.5F;
    071                        }
    072
    073                        var5 += var1.nextFloat() * 0.1F;
    074                        var6 = (int)(var5 * 100.0F + 155.0F);
    075                        int var13 = (int)(var5 * var5 * 200.0F + 55.0F);
    076                        int var14 = (int)(var5 * var5 * var5 * var5 * 255.0F);
    077                        int var15 = (int)(var5 * 100.0F + 155.0F);
    078                        int var16 = var4 * tileSizeBase + var3;
    079                        this.portalTextureData[var2][var16 * 4 + 0] = (byte)var13;
    080                        this.portalTextureData[var2][var16 * 4 + 1] = (byte)var14;
    081                        this.portalTextureData[var2][var16 * 4 + 2] = (byte)var6;
    082                        this.portalTextureData[var2][var16 * 4 + 3] = (byte)var15;
    083                    }
    084                }
    085            }
    086        }
    087
    088        public void onTick()
    089        {
    090            ++this.portalTickCounter;
    091            byte[] var1 = this.portalTextureData[this.portalTickCounter & 31];
    092
    093            for (int var2 = 0; var2 < tileSizeSquare; ++var2)
    094            {
    095                int var3 = var1[var2 * 4 + 0] & 255;
    096                int var4 = var1[var2 * 4 + 1] & 255;
    097                int var5 = var1[var2 * 4 + 2] & 255;
    098                int var6 = var1[var2 * 4 + 3] & 255;
    099
    100                if (this.anaglyphEnabled)
    101                {
    102                    int var7 = (var3 * 30 + var4 * 59 + var5 * 11) / 100;
    103                    int var8 = (var3 * 30 + var4 * 70) / 100;
    104                    int var9 = (var3 * 30 + var5 * 70) / 100;
    105                    var3 = var7;
    106                    var4 = var8;
    107                    var5 = var9;
    108                }
    109
    110                this.imageData[var2 * 4 + 0] = (byte)var3;
    111                this.imageData[var2 * 4 + 1] = (byte)var4;
    112                this.imageData[var2 * 4 + 2] = (byte)var5;
    113                this.imageData[var2 * 4 + 3] = (byte)var6;
    114            }
    115        }
    116    }