    001package net.minecraft.client.renderer.tileentity;
    002
    003import cpw.mods.fml.relauncher.Side;
    004import cpw.mods.fml.relauncher.SideOnly;
    005import java.nio.FloatBuffer;
    006import java.util.Random;
    007import net.minecraft.client.Minecraft;
    008import net.minecraft.client.renderer.ActiveRenderInfo;
    009import net.minecraft.client.renderer.GLAllocation;
    010import net.minecraft.client.renderer.Tessellator;
    011import net.minecraft.tileentity.TileEntity;
    012import net.minecraft.tileentity.TileEntityEndPortal;
    013import org.lwjgl.opengl.GL11;
    014
    015@SideOnly(Side.CLIENT)
    016public 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 f1 = (float)this.tileEntityRenderer.playerX;
    026        float f2 = (float)this.tileEntityRenderer.playerY;
    027        float f3 = (float)this.tileEntityRenderer.playerZ;
    028        GL11.glDisable(GL11.GL_LIGHTING);
    029        Random random = new Random(31100L);
    030        float f4 = 0.75F;
    031
    032        for (int i = 0; i < 16; ++i)
    033        {
    034            GL11.glPushMatrix();
    035            float f5 = (float)(16 - i);
    036            float f6 = 0.0625F;
    037            float f7 = 1.0F / (f5 + 1.0F);
    038
    039            if (i == 0)
    040            {
    041                this.bindTextureByName("/misc/tunnel.png");
    042                f7 = 0.1F;
    043                f5 = 65.0F;
    044                f6 = 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 (i == 1)
    050            {
    051                this.bindTextureByName("/misc/particlefield.png");
    052                GL11.glEnable(GL11.GL_BLEND);
    053                GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
    054                f6 = 0.5F;
    055            }
    056
    057            float f8 = (float)(-(par4 + (double)f4));
    058            float f9 = f8 + ActiveRenderInfo.objectY;
    059            float f10 = f8 + f5 + ActiveRenderInfo.objectY;
    060            float f11 = f9 / f10;
    061            f11 += (float)(par4 + (double)f4);
    062            GL11.glTranslatef(f1, f11, f3);
    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(f6, f6, f6);
    081            GL11.glTranslatef(0.5F, 0.5F, 0.0F);
    082            GL11.glRotatef((float)(i * i * 4321 + i * 9) * 2.0F, 0.0F, 0.0F, 1.0F);
    083            GL11.glTranslatef(-0.5F, -0.5F, 0.0F);
    084            GL11.glTranslatef(-f1, -f3, -f2);
    085            f9 = f8 + ActiveRenderInfo.objectY;
    086            GL11.glTranslatef(ActiveRenderInfo.objectX * f5 / f9, ActiveRenderInfo.objectZ * f5 / f9, -f2);
    087            Tessellator tessellator = Tessellator.instance;
    088            tessellator.startDrawingQuads();
    089            f11 = random.nextFloat() * 0.5F + 0.1F;
    090            float f12 = random.nextFloat() * 0.5F + 0.4F;
    091            float f13 = random.nextFloat() * 0.5F + 0.5F;
    092
    093            if (i == 0)
    094            {
    095                f13 = 1.0F;
    096                f12 = 1.0F;
    097                f11 = 1.0F;
    098            }
    099
    100            tessellator.setColorRGBA_F(f11 * f7, f12 * f7, f13 * f7, 1.0F);
    101            tessellator.addVertex(par2, par4 + (double)f4, par6);
    102            tessellator.addVertex(par2, par4 + (double)f4, par6 + 1.0D);
    103            tessellator.addVertex(par2 + 1.0D, par4 + (double)f4, par6 + 1.0D);
    104            tessellator.addVertex(par2 + 1.0D, par4 + (double)f4, par6);
    105            tessellator.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}