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