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