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