    001    package net.minecraft.client.renderer.tileentity;
    002
    003    import cpw.mods.fml.common.Side;
    004    import cpw.mods.fml.common.asm.SideOnly;
    005    import java.nio.FloatBuffer;
    006    import java.util.Random;
    007    import net.minecraft.client.Minecraft;
    008    import net.minecraft.client.renderer.ActiveRenderInfo;
    009    import net.minecraft.client.renderer.GLAllocation;
    010    import net.minecraft.client.renderer.Tessellator;
    011    import net.minecraft.tileentity.TileEntity;
    012    import net.minecraft.tileentity.TileEntityEndPortal;
    013    import org.lwjgl.opengl.GL11;
    014
    015    @SideOnly(Side.CLIENT)
    016    public class RenderEndPortal extends TileEntitySpecialRenderer
    017    {
    018        FloatBuffer field_76908_a = GLAllocation.createDirectFloatBuffer(16);
    019
    020        /**
    021         * Renders the End Portal.
    022         */
    023        public void renderEndPortalTileEntity(TileEntityEndPortal par1TileEntityEndPortal, double par2, double par4, double par6, float par8)
    024        {
    025            float var9 = (float)this.tileEntityRenderer.playerX;
    026            float var10 = (float)this.tileEntityRenderer.playerY;
    027            float var11 = (float)this.tileEntityRenderer.playerZ;
    028            GL11.glDisable(GL11.GL_LIGHTING);
    029            Random var12 = new Random(31100L);
    030            float var13 = 0.75F;
    031
    032            for (int var14 = 0; var14 < 16; ++var14)
    033            {
    034                GL11.glPushMatrix();
    035                float var15 = (float)(16 - var14);
    036                float var16 = 0.0625F;
    037                float var17 = 1.0F / (var15 + 1.0F);
    038
    039                if (var14 == 0)
    040                {
    041                    this.bindTextureByName("/misc/tunnel.png");
    042                    var17 = 0.1F;
    043                    var15 = 65.0F;
    044                    var16 = 0.125F;
    045                    GL11.glEnable(GL11.GL_BLEND);
    046                    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    047                }
    048
    049                if (var14 == 1)
    050                {
    051                    this.bindTextureByName("/misc/particlefield.png");
    052                    GL11.glEnable(GL11.GL_BLEND);
    053                    GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
    054                    var16 = 0.5F;
    055                }
    056
    057                float var18 = (float)(-(par4 + (double)var13));
    058                float var19 = var18 + ActiveRenderInfo.objectY;
    059                float var20 = var18 + var15 + ActiveRenderInfo.objectY;
    060                float var21 = var19 / var20;
    061                var21 += (float)(par4 + (double)var13);
    062                GL11.glTranslatef(var9, var21, var11);
    063                GL11.glTexGeni(GL11.GL_S, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR);
    064                GL11.glTexGeni(GL11.GL_T, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR);
    065                GL11.glTexGeni(GL11.GL_R, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR);
    066                GL11.glTexGeni(GL11.GL_Q, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_EYE_LINEAR);
    067                GL11.glTexGen(GL11.GL_S, GL11.GL_OBJECT_PLANE, this.func_76907_a(1.0F, 0.0F, 0.0F, 0.0F));
    068                GL11.glTexGen(GL11.GL_T, GL11.GL_OBJECT_PLANE, this.func_76907_a(0.0F, 0.0F, 1.0F, 0.0F));
    069                GL11.glTexGen(GL11.GL_R, GL11.GL_OBJECT_PLANE, this.func_76907_a(0.0F, 0.0F, 0.0F, 1.0F));
    070                GL11.glTexGen(GL11.GL_Q, GL11.GL_EYE_PLANE, this.func_76907_a(0.0F, 1.0F, 0.0F, 0.0F));
    071                GL11.glEnable(GL11.GL_TEXTURE_GEN_S);
    072                GL11.glEnable(GL11.GL_TEXTURE_GEN_T);
    073                GL11.glEnable(GL11.GL_TEXTURE_GEN_R);
    074                GL11.glEnable(GL11.GL_TEXTURE_GEN_Q);
    075                GL11.glPopMatrix();
    076                GL11.glMatrixMode(GL11.GL_TEXTURE);
    077                GL11.glPushMatrix();
    078                GL11.glLoadIdentity();
    079                GL11.glTranslatef(0.0F, (float)(Minecraft.getSystemTime() % 700000L) / 700000.0F, 0.0F);
    080                GL11.glScalef(var16, var16, var16);
    081                GL11.glTranslatef(0.5F, 0.5F, 0.0F);
    082                GL11.glRotatef((float)(var14 * var14 * 4321 + var14 * 9) * 2.0F, 0.0F, 0.0F, 1.0F);
    083                GL11.glTranslatef(-0.5F, -0.5F, 0.0F);
    084                GL11.glTranslatef(-var9, -var11, -var10);
    085                var19 = var18 + ActiveRenderInfo.objectY;
    086                GL11.glTranslatef(ActiveRenderInfo.objectX * var15 / var19, ActiveRenderInfo.objectZ * var15 / var19, -var10);
    087                Tessellator var24 = Tessellator.instance;
    088                var24.startDrawingQuads();
    089                var21 = var12.nextFloat() * 0.5F + 0.1F;
    090                float var22 = var12.nextFloat() * 0.5F + 0.4F;
    091                float var23 = var12.nextFloat() * 0.5F + 0.5F;
    092
    093                if (var14 == 0)
    094                {
    095                    var23 = 1.0F;
    096                    var22 = 1.0F;
    097                    var21 = 1.0F;
    098                }
    099
    100                var24.setColorRGBA_F(var21 * var17, var22 * var17, var23 * var17, 1.0F);
    101                var24.addVertex(par2, par4 + (double)var13, par6);
    102                var24.addVertex(par2, par4 + (double)var13, par6 + 1.0D);
    103                var24.addVertex(par2 + 1.0D, par4 + (double)var13, par6 + 1.0D);
    104                var24.addVertex(par2 + 1.0D, par4 + (double)var13, par6);
    105                var24.draw();
    106                GL11.glPopMatrix();
    107                GL11.glMatrixMode(GL11.GL_MODELVIEW);
    108            }
    109
    110            GL11.glDisable(GL11.GL_BLEND);
    111            GL11.glDisable(GL11.GL_TEXTURE_GEN_S);
    112            GL11.glDisable(GL11.GL_TEXTURE_GEN_T);
    113            GL11.glDisable(GL11.GL_TEXTURE_GEN_R);
    114            GL11.glDisable(GL11.GL_TEXTURE_GEN_Q);
    115            GL11.glEnable(GL11.GL_LIGHTING);
    116        }
    117
    118        private FloatBuffer func_76907_a(float par1, float par2, float par3, float par4)
    119        {
    120            this.field_76908_a.clear();
    121            this.field_76908_a.put(par1).put(par2).put(par3).put(par4);
    122            this.field_76908_a.flip();
    123            return this.field_76908_a;
    124        }
    125
    126        public void renderTileEntityAt(TileEntity par1TileEntity, double par2, double par4, double par6, float par8)
    127        {
    128            this.renderEndPortalTileEntity((TileEntityEndPortal)par1TileEntity, par2, par4, par6, par8);
    129        }
    130    }