001package net.minecraft.client.renderer.entity;
002
003import cpw.mods.fml.relauncher.Side;
004import cpw.mods.fml.relauncher.SideOnly;
005import net.minecraft.client.renderer.OpenGlHelper;
006import net.minecraft.client.renderer.Tessellator;
007import net.minecraft.entity.Entity;
008import net.minecraft.entity.item.EntityXPOrb;
009import net.minecraft.util.MathHelper;
010import org.lwjgl.opengl.GL11;
011import org.lwjgl.opengl.GL12;
012
013@SideOnly(Side.CLIENT)
014public class RenderXPOrb extends Render
015{
016    public RenderXPOrb()
017    {
018        this.shadowSize = 0.15F;
019        this.shadowOpaque = 0.75F;
020    }
021
022    /**
023     * Renders the XP Orb.
024     */
025    public void renderTheXPOrb(EntityXPOrb par1EntityXPOrb, double par2, double par4, double par6, float par8, float par9)
026    {
027        GL11.glPushMatrix();
028        GL11.glTranslatef((float)par2, (float)par4, (float)par6);
029        int i = par1EntityXPOrb.getTextureByXP();
030        this.loadTexture("/item/xporb.png");
031        Tessellator tessellator = Tessellator.instance;
032        float f2 = (float)(i % 4 * 16 + 0) / 64.0F;
033        float f3 = (float)(i % 4 * 16 + 16) / 64.0F;
034        float f4 = (float)(i / 4 * 16 + 0) / 64.0F;
035        float f5 = (float)(i / 4 * 16 + 16) / 64.0F;
036        float f6 = 1.0F;
037        float f7 = 0.5F;
038        float f8 = 0.25F;
039        int j = par1EntityXPOrb.getBrightnessForRender(par9);
040        int k = j % 65536;
041        int l = j / 65536;
042        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)k / 1.0F, (float)l / 1.0F);
043        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
044        float f9 = 255.0F;
045        float f10 = ((float)par1EntityXPOrb.xpColor + par9) / 2.0F;
046        l = (int)((MathHelper.sin(f10 + 0.0F) + 1.0F) * 0.5F * f9);
047        int i1 = (int)f9;
048        int j1 = (int)((MathHelper.sin(f10 + 4.1887903F) + 1.0F) * 0.1F * f9);
049        int k1 = l << 16 | i1 << 8 | j1;
050        GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
051        GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
052        float f11 = 0.3F;
053        GL11.glScalef(f11, f11, f11);
054        tessellator.startDrawingQuads();
055        tessellator.setColorRGBA_I(k1, 128);
056        tessellator.setNormal(0.0F, 1.0F, 0.0F);
057        tessellator.addVertexWithUV((double)(0.0F - f7), (double)(0.0F - f8), 0.0D, (double)f2, (double)f5);
058        tessellator.addVertexWithUV((double)(f6 - f7), (double)(0.0F - f8), 0.0D, (double)f3, (double)f5);
059        tessellator.addVertexWithUV((double)(f6 - f7), (double)(1.0F - f8), 0.0D, (double)f3, (double)f4);
060        tessellator.addVertexWithUV((double)(0.0F - f7), (double)(1.0F - f8), 0.0D, (double)f2, (double)f4);
061        tessellator.draw();
062        GL11.glDisable(GL11.GL_BLEND);
063        GL11.glDisable(GL12.GL_RESCALE_NORMAL);
064        GL11.glPopMatrix();
065    }
066
067    /**
068     * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
069     * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
070     * (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1,
071     * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
072     */
073    public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
074    {
075        this.renderTheXPOrb((EntityXPOrb)par1Entity, par2, par4, par6, par8, par9);
076    }
077}