    001    package net.minecraft.src;
    002
    003    import cpw.mods.fml.common.Side;
    004    import cpw.mods.fml.common.asm.SideOnly;
    005    import org.lwjgl.opengl.GL11;
    006
    007    @SideOnly(Side.CLIENT)
    008    public class RenderItemFrame extends Render
    009    {
    010        private final RenderBlocks field_82405_a = new RenderBlocks();
    011
    012        public void func_82404_a(EntityItemFrame par1EntityItemFrame, double par2, double par4, double par6, float par8, float par9)
    013        {
    014            GL11.glPushMatrix();
    015            float var10 = (float)(par1EntityItemFrame.posX - par2) - 0.5F;
    016            float var11 = (float)(par1EntityItemFrame.posY - par4) - 0.5F;
    017            float var12 = (float)(par1EntityItemFrame.posZ - par6) - 0.5F;
    018            int var13 = par1EntityItemFrame.xPosition + Direction.offsetX[par1EntityItemFrame.field_82332_a];
    019            int var14 = par1EntityItemFrame.yPosition;
    020            int var15 = par1EntityItemFrame.zPosition + Direction.offsetZ[par1EntityItemFrame.field_82332_a];
    021            GL11.glTranslatef((float)var13 - var10, (float)var14 - var11, (float)var15 - var12);
    022            this.renderFrameItemAsBlock(par1EntityItemFrame);
    023            this.func_82402_b(par1EntityItemFrame);
    024            GL11.glPopMatrix();
    025        }
    026
    027        /**
    028         * Render the item frame's item as a block.
    029         */
    030        private void renderFrameItemAsBlock(EntityItemFrame par1EntityItemFrame)
    031        {
    032            GL11.glPushMatrix();
    033            GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.renderManager.renderEngine.getTexture("/terrain.png"));
    034            GL11.glRotatef(par1EntityItemFrame.rotationYaw, 0.0F, 1.0F, 0.0F);
    035            Block var2 = Block.planks;
    036            float var3 = 0.0625F;
    037            float var4 = 0.75F;
    038            float var5 = var4 / 2.0F;
    039            GL11.glPushMatrix();
    040            this.field_82405_a.func_83019_b(0.0D, (double)(0.5F - var5 + 0.0625F), (double)(0.5F - var5 + 0.0625F), (double)(var3 * 0.5F), (double)(0.5F + var5 - 0.0625F), (double)(0.5F + var5 - 0.0625F));
    041            this.field_82405_a.func_82774_a(185);
    042            this.field_82405_a.renderBlockAsItem(var2, 0, 1.0F);
    043            this.field_82405_a.clearOverrideBlockTexture();
    044            this.field_82405_a.func_83017_b();
    045            GL11.glPopMatrix();
    046            this.field_82405_a.func_82774_a(214);
    047            GL11.glPushMatrix();
    048            this.field_82405_a.func_83019_b(0.0D, (double)(0.5F - var5), (double)(0.5F - var5), (double)(var3 + 1.0E-4F), (double)(var3 + 0.5F - var5), (double)(0.5F + var5));
    049            this.field_82405_a.renderBlockAsItem(var2, 0, 1.0F);
    050            GL11.glPopMatrix();
    051            GL11.glPushMatrix();
    052            this.field_82405_a.func_83019_b(0.0D, (double)(0.5F + var5 - var3), (double)(0.5F - var5), (double)(var3 + 1.0E-4F), (double)(0.5F + var5), (double)(0.5F + var5));
    053            this.field_82405_a.renderBlockAsItem(var2, 0, 1.0F);
    054            GL11.glPopMatrix();
    055            GL11.glPushMatrix();
    056            this.field_82405_a.func_83019_b(0.0D, (double)(0.5F - var5), (double)(0.5F - var5), (double)var3, (double)(0.5F + var5), (double)(var3 + 0.5F - var5));
    057            this.field_82405_a.renderBlockAsItem(var2, 0, 1.0F);
    058            GL11.glPopMatrix();
    059            GL11.glPushMatrix();
    060            this.field_82405_a.func_83019_b(0.0D, (double)(0.5F - var5), (double)(0.5F + var5 - var3), (double)var3, (double)(0.5F + var5), (double)(0.5F + var5));
    061            this.field_82405_a.renderBlockAsItem(var2, 0, 1.0F);
    062            GL11.glPopMatrix();
    063            this.field_82405_a.func_83017_b();
    064            this.field_82405_a.clearOverrideBlockTexture();
    065            GL11.glPopMatrix();
    066        }
    067
    068        private void func_82402_b(EntityItemFrame par1EntityItemFrame)
    069        {
    070            ItemStack var2 = par1EntityItemFrame.func_82335_i();
    071
    072            if (var2 != null)
    073            {
    074                EntityItem var3 = new EntityItem(par1EntityItemFrame.worldObj, 0.0D, 0.0D, 0.0D, var2);
    075                var3.item.stackSize = 1;
    076                var3.hoverStart = 0.0F;
    077                GL11.glPushMatrix();
    078                GL11.glTranslatef(-0.453125F * (float)Direction.offsetX[par1EntityItemFrame.field_82332_a], -0.18F, -0.453125F * (float)Direction.offsetZ[par1EntityItemFrame.field_82332_a]);
    079                GL11.glRotatef(180.0F + par1EntityItemFrame.rotationYaw, 0.0F, 1.0F, 0.0F);
    080                GL11.glRotatef((float)(-90 * par1EntityItemFrame.getRotation()), 0.0F, 0.0F, 1.0F);
    081
    082                switch (par1EntityItemFrame.getRotation())
    083                {
    084                    case 1:
    085                        GL11.glTranslatef(-0.16F, -0.16F, 0.0F);
    086                        break;
    087                    case 2:
    088                        GL11.glTranslatef(0.0F, -0.32F, 0.0F);
    089                        break;
    090                    case 3:
    091                        GL11.glTranslatef(0.16F, -0.16F, 0.0F);
    092                }
    093
    094                if (var3.item.getItem() == Item.map)
    095                {
    096                    this.renderManager.renderEngine.bindTexture(this.renderManager.renderEngine.getTexture("/misc/mapbg.png"));
    097                    Tessellator var4 = Tessellator.instance;
    098                    GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
    099                    GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
    100                    GL11.glScalef(0.00390625F, 0.00390625F, 0.00390625F);
    101                    GL11.glTranslatef(-65.0F, -107.0F, -1.0F);
    102                    GL11.glNormal3f(0.0F, 0.0F, -1.0F);
    103                    var4.startDrawingQuads();
    104                    byte var5 = 7;
    105                    var4.addVertexWithUV((double)(0 - var5), (double)(128 + var5), 0.0D, 0.0D, 1.0D);
    106                    var4.addVertexWithUV((double)(128 + var5), (double)(128 + var5), 0.0D, 1.0D, 1.0D);
    107                    var4.addVertexWithUV((double)(128 + var5), (double)(0 - var5), 0.0D, 1.0D, 0.0D);
    108                    var4.addVertexWithUV((double)(0 - var5), (double)(0 - var5), 0.0D, 0.0D, 0.0D);
    109                    var4.draw();
    110                    MapData var6 = Item.map.getMapData(var3.item, par1EntityItemFrame.worldObj);
    111
    112                    if (var6 != null)
    113                    {
    114                        this.renderManager.itemRenderer.mapItemRenderer.renderMap((EntityPlayer)null, this.renderManager.renderEngine, var6);
    115                    }
    116                }
    117                else
    118                {
    119                    if (var3.item.getItem() == Item.compass)
    120                    {
    121                        double var8 = TextureCompassFX.field_82391_c.field_76868_i;
    122                        double var10 = TextureCompassFX.field_82391_c.field_76866_j;
    123                        TextureCompassFX.field_82391_c.field_76868_i = 0.0D;
    124                        TextureCompassFX.field_82391_c.field_76866_j = 0.0D;
    125                        TextureCompassFX.func_82390_a(par1EntityItemFrame.posX, par1EntityItemFrame.posZ, (double)MathHelper.wrapAngleTo180_float((float)(180 + par1EntityItemFrame.field_82332_a * 90)), false, true);
    126                        TextureCompassFX.field_82391_c.field_76868_i = var8;
    127                        TextureCompassFX.field_82391_c.field_76866_j = var10;
    128                        this.renderManager.renderEngine.func_82772_a(TextureCompassFX.field_82391_c, -1);
    129                    }
    130
    131                    float var9 = this.renderManager.playerViewY;
    132                    this.renderManager.playerViewY = 180.0F;
    133                    RenderItem.field_82407_g = true;
    134                    RenderManager.instance.renderEntityWithPosYaw(var3, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
    135                    RenderItem.field_82407_g = false;
    136                    this.renderManager.playerViewY = var9;
    137                    GL11.glEnable(GL11.GL_LIGHTING);
    138
    139                    if (var3.item.getItem() == Item.compass)
    140                    {
    141                        TextureCompassFX.field_82391_c.onTick();
    142                        this.renderManager.renderEngine.func_82772_a(TextureCompassFX.field_82391_c, -1);
    143                    }
    144                }
    145
    146                GL11.glPopMatrix();
    147            }
    148        }
    149
    150        /**
    151         * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
    152         * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
    153         * (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1,
    154         * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
    155         */
    156        public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
    157        {
    158            this.func_82404_a((EntityItemFrame)par1Entity, par2, par4, par6, par8, par9);
    159        }
    160    }