Guest User

RenderAdvancedFrame

a guest
Jan 22nd, 2015
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 15.65 KB | None | 0 0
  1. @SideOnly(Side.CLIENT)
  2. public class RenderAdvancedFrame extends Render
  3. {
  4.     private static final ResourceLocation mapBackgroundTextures = new ResourceLocation("textures/map/map_background.png");
  5.     private final RenderBlocks field_147916_f = new RenderBlocks();
  6.     private final Minecraft field_147917_g = Minecraft.getMinecraft();
  7.     private IIcon field_94147_f;
  8.     private static final String __OBFID = "CL_00001002";
  9.  
  10.     public void updateIcons(IIconRegister p_94143_1_)
  11.     {
  12.         this.field_94147_f = p_94143_1_.registerIcon("itemframe_background");
  13.     }
  14.  
  15.     /**
  16.      * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
  17.      * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
  18.      * (Render<T extends Entity) and this method has signature public void func_76986_a(T entity, double d, double d1,
  19.      * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
  20.      */
  21.     public void doRender(EntityAdvancedFrame p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_)
  22.     {
  23.         GL11.glPushMatrix();
  24.         double d3 = p_76986_1_.posX - p_76986_2_ - 0.5D;
  25.         double d4 = p_76986_1_.posY - p_76986_4_ - 0.5D;
  26.         double d5 = p_76986_1_.posZ - p_76986_6_ - 0.5D;
  27.         int i = p_76986_1_.field_146063_b + Direction.offsetX[p_76986_1_.hangingDirection];
  28.         int j = p_76986_1_.field_146064_c;
  29.         int k = p_76986_1_.field_146062_d + Direction.offsetZ[p_76986_1_.hangingDirection];
  30.         GL11.glTranslated((double)i - d3, (double)j - d4, (double)k - d5);
  31.  
  32.         if (p_76986_1_.getDisplayedItem() != null && p_76986_1_.getDisplayedItem().getItem() == Items.filled_map)
  33.         {
  34.             this.func_147915_b(p_76986_1_);
  35.         }
  36.         else
  37.         {
  38.             this.renderFrameItemAsBlock(p_76986_1_);
  39.         }
  40.  
  41.         this.func_82402_b(p_76986_1_);
  42.         GL11.glPopMatrix();
  43.         this.func_147914_a(p_76986_1_, p_76986_2_ + (double)((float)Direction.offsetX[p_76986_1_.hangingDirection] * 0.3F), p_76986_4_ - 0.25D, p_76986_6_ + (double)((float)Direction.offsetZ[p_76986_1_.hangingDirection] * 0.3F));
  44.     }
  45.  
  46.     /**
  47.      * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
  48.      */
  49.     protected ResourceLocation getEntityTexture(EntityAdvancedFrame p_110775_1_)
  50.     {
  51.         return null;
  52.     }
  53.  
  54.     private void func_147915_b(EntityItemFrame p_147915_1_)
  55.     {
  56.         GL11.glPushMatrix();
  57.         GL11.glRotatef(p_147915_1_.rotationYaw, 0.0F, 1.0F, 0.0F);
  58.         this.renderManager.renderEngine.bindTexture(TextureMap.locationBlocksTexture);
  59.         Block block = Blocks.planks;
  60.         float f = 0.0625F;
  61.         float f1 = 1.0F;
  62.         float f2 = f1 / 2.0F;
  63.         GL11.glPushMatrix();
  64.         this.field_147916_f.overrideBlockBounds(0.0D, (double)(0.5F - f2 + 0.0625F), (double)(0.5F - f2 + 0.0625F), (double)f, (double)(0.5F + f2 - 0.0625F), (double)(0.5F + f2 - 0.0625F));
  65.         this.field_147916_f.setOverrideBlockTexture(this.field_94147_f);
  66.         this.field_147916_f.renderBlockAsItem(block, 0, 1.0F);
  67.         this.field_147916_f.clearOverrideBlockTexture();
  68.         this.field_147916_f.unlockBlockBounds();
  69.         GL11.glPopMatrix();
  70.         this.field_147916_f.setOverrideBlockTexture(Blocks.planks.getIcon(1, 2));
  71.         GL11.glPushMatrix();
  72.         this.field_147916_f.overrideBlockBounds(0.0D, (double)(0.5F - f2), (double)(0.5F - f2), (double)(f + 1.0E-4F), (double)(f + 0.5F - f2), (double)(0.5F + f2));
  73.         this.field_147916_f.renderBlockAsItem(block, 0, 1.0F);
  74.         GL11.glPopMatrix();
  75.         GL11.glPushMatrix();
  76.         this.field_147916_f.overrideBlockBounds(0.0D, (double)(0.5F + f2 - f), (double)(0.5F - f2), (double)(f + 1.0E-4F), (double)(0.5F + f2), (double)(0.5F + f2));
  77.         this.field_147916_f.renderBlockAsItem(block, 0, 1.0F);
  78.         GL11.glPopMatrix();
  79.         GL11.glPushMatrix();
  80.         this.field_147916_f.overrideBlockBounds(0.0D, (double)(0.5F - f2), (double)(0.5F - f2), (double)f, (double)(0.5F + f2), (double)(f + 0.5F - f2));
  81.         this.field_147916_f.renderBlockAsItem(block, 0, 1.0F);
  82.         GL11.glPopMatrix();
  83.         GL11.glPushMatrix();
  84.         this.field_147916_f.overrideBlockBounds(0.0D, (double)(0.5F - f2), (double)(0.5F + f2 - f), (double)f, (double)(0.5F + f2), (double)(0.5F + f2));
  85.         this.field_147916_f.renderBlockAsItem(block, 0, 1.0F);
  86.         GL11.glPopMatrix();
  87.         this.field_147916_f.unlockBlockBounds();
  88.         this.field_147916_f.clearOverrideBlockTexture();
  89.         GL11.glPopMatrix();
  90.     }
  91.  
  92.     /**
  93.      * Render the item frame's item as a block.
  94.      */
  95.     private void renderFrameItemAsBlock(EntityAdvancedFrame p_82403_1_)
  96.     {
  97.         GL11.glPushMatrix();
  98.         GL11.glRotatef(p_82403_1_.rotationYaw, 0.0F, 1.0F, 0.0F);
  99.         this.renderManager.renderEngine.bindTexture(TextureMap.locationBlocksTexture);
  100.         Block block = Blocks.planks;
  101.         float f = 0.0625F;
  102.         float f1 = 0.75F;
  103.         float f2 = f1 / 2.0F;
  104.         GL11.glPushMatrix();
  105.         this.field_147916_f.overrideBlockBounds(0.0D, (double)(0.5F - f2 + 0.0625F), (double)(0.5F - f2 + 0.0625F), (double)(f * 0.5F), (double)(0.5F + f2 - 0.0625F), (double)(0.5F + f2 - 0.0625F));
  106.         this.field_147916_f.setOverrideBlockTexture(this.field_94147_f);
  107.         this.field_147916_f.renderBlockAsItem(block, 0, 1.0F);
  108.         this.field_147916_f.clearOverrideBlockTexture();
  109.         this.field_147916_f.unlockBlockBounds();
  110.         GL11.glPopMatrix();
  111.         this.field_147916_f.setOverrideBlockTexture(Blocks.planks.getIcon(1, 2));
  112.         GL11.glPushMatrix();
  113.         this.field_147916_f.overrideBlockBounds(0.0D, (double)(0.5F - f2), (double)(0.5F - f2), (double)(f + 1.0E-4F), (double)(f + 0.5F - f2), (double)(0.5F + f2));
  114.         this.field_147916_f.renderBlockAsItem(block, 0, 1.0F);
  115.         GL11.glPopMatrix();
  116.         GL11.glPushMatrix();
  117.         this.field_147916_f.overrideBlockBounds(0.0D, (double)(0.5F + f2 - f), (double)(0.5F - f2), (double)(f + 1.0E-4F), (double)(0.5F + f2), (double)(0.5F + f2));
  118.         this.field_147916_f.renderBlockAsItem(block, 0, 1.0F);
  119.         GL11.glPopMatrix();
  120.         GL11.glPushMatrix();
  121.         this.field_147916_f.overrideBlockBounds(0.0D, (double)(0.5F - f2), (double)(0.5F - f2), (double)f, (double)(0.5F + f2), (double)(f + 0.5F - f2));
  122.         this.field_147916_f.renderBlockAsItem(block, 0, 1.0F);
  123.         GL11.glPopMatrix();
  124.         GL11.glPushMatrix();
  125.         this.field_147916_f.overrideBlockBounds(0.0D, (double)(0.5F - f2), (double)(0.5F + f2 - f), (double)f, (double)(0.5F + f2), (double)(0.5F + f2));
  126.         this.field_147916_f.renderBlockAsItem(block, 0, 1.0F);
  127.         GL11.glPopMatrix();
  128.         this.field_147916_f.unlockBlockBounds();
  129.         this.field_147916_f.clearOverrideBlockTexture();
  130.         GL11.glPopMatrix();
  131.     }
  132.  
  133.     private void func_82402_b(EntityAdvancedFrame p_82402_1_)
  134.     {
  135.         ItemStack itemstack = p_82402_1_.getDisplayedItem();
  136.  
  137.         if (itemstack != null)
  138.         {
  139.             EntityItem entityitem = new EntityItem(p_82402_1_.worldObj, 0.0D, 0.0D, 0.0D, itemstack);
  140.             Item item = entityitem.getEntityItem().getItem();
  141.             entityitem.getEntityItem().stackSize = 1;
  142.             entityitem.hoverStart = 0.0F;
  143.             GL11.glPushMatrix();
  144.             GL11.glTranslatef(-0.453125F * (float)Direction.offsetX[p_82402_1_.hangingDirection], -0.18F, -0.453125F * (float)Direction.offsetZ[p_82402_1_.hangingDirection]);
  145.             GL11.glRotatef(180.0F + p_82402_1_.rotationYaw, 0.0F, 1.0F, 0.0F);
  146.             GL11.glRotatef((float)(-90 * p_82402_1_.getRotation()), 0.0F, 0.0F, 1.0F);
  147.  
  148.             switch (p_82402_1_.getRotation())
  149.             {
  150.                 case 1:
  151.                     GL11.glTranslatef(-0.16F, -0.16F, 0.0F);
  152.                     break;
  153.                 case 2:
  154.                     GL11.glTranslatef(0.0F, -0.32F, 0.0F);
  155.                     break;
  156.                 case 3:
  157.                     GL11.glTranslatef(0.16F, -0.16F, 0.0F);
  158.             }
  159.  
  160. //            net.minecraftforge.client.event.RenderItemInFrameEvent event = new net.minecraftforge.client.event.RenderItemInFrameEvent(p_82402_1_, this);
  161. //            if (!net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event))
  162. //            {
  163.             if (item == Items.filled_map)
  164.             {
  165.                 this.renderManager.renderEngine.bindTexture(mapBackgroundTextures);
  166.                 Tessellator tessellator = Tessellator.instance;
  167.                 GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
  168.                 GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
  169.                 float f = 0.0078125F;
  170.                 GL11.glScalef(f, f, f);
  171.  
  172.                 switch (p_82402_1_.getRotation())
  173.                 {
  174.                     case 0:
  175.                         GL11.glTranslatef(-64.0F, -87.0F, -1.5F);
  176.                         break;
  177.                     case 1:
  178.                         GL11.glTranslatef(-66.5F, -84.5F, -1.5F);
  179.                         break;
  180.                     case 2:
  181.                         GL11.glTranslatef(-64.0F, -82.0F, -1.5F);
  182.                         break;
  183.                     case 3:
  184.                         GL11.glTranslatef(-61.5F, -84.5F, -1.5F);
  185.                 }
  186.  
  187.                 GL11.glNormal3f(0.0F, 0.0F, -1.0F);
  188.                 MapData mapdata = Items.filled_map.getMapData(entityitem.getEntityItem(), p_82402_1_.worldObj);
  189.                 GL11.glTranslatef(0.0F, 0.0F, -1.0F);
  190.  
  191.                 if (mapdata != null)
  192.                 {
  193.                     this.field_147917_g.entityRenderer.getMapItemRenderer().func_148250_a(mapdata, true);
  194.                 }
  195.             }
  196.             else
  197.             {
  198.                 if (item == Items.compass)
  199.                 {
  200.                     TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
  201.                     texturemanager.bindTexture(TextureMap.locationItemsTexture);
  202.                     TextureAtlasSprite textureatlassprite1 = ((TextureMap)texturemanager.getTexture(TextureMap.locationItemsTexture)).getAtlasSprite(Items.compass.getIconIndex(entityitem.getEntityItem()).getIconName());
  203.  
  204.                     if (textureatlassprite1 instanceof TextureCompass)
  205.                     {
  206.                         TextureCompass texturecompass = (TextureCompass)textureatlassprite1;
  207.                         double d0 = texturecompass.currentAngle;
  208.                         double d1 = texturecompass.angleDelta;
  209.                         texturecompass.currentAngle = 0.0D;
  210.                         texturecompass.angleDelta = 0.0D;
  211.                         texturecompass.updateCompass(p_82402_1_.worldObj, p_82402_1_.posX, p_82402_1_.posZ, (double)MathHelper.wrapAngleTo180_float((float)(180 + p_82402_1_.hangingDirection * 90)), false, true);
  212.                         texturecompass.currentAngle = d0;
  213.                         texturecompass.angleDelta = d1;
  214.                     }
  215.                 }
  216.  
  217.                 RenderItem.renderInFrame = true;
  218.                 RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
  219.                 RenderItem.renderInFrame = false;
  220.  
  221.                 if (item == Items.compass)
  222.                 {
  223.                     TextureAtlasSprite textureatlassprite = ((TextureMap)Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationItemsTexture)).getAtlasSprite(Items.compass.getIconIndex(entityitem.getEntityItem()).getIconName());
  224.  
  225.                     if (textureatlassprite.getFrameCount() > 0)
  226.                     {
  227.                         textureatlassprite.updateAnimation();
  228.                     }
  229.                 }
  230.             }
  231.             }
  232.  
  233.             GL11.glPopMatrix();
  234.         }
  235. //    }
  236.  
  237.     protected void func_147914_a(EntityAdvancedFrame p_147914_1_, double p_147914_2_, double p_147914_4_, double p_147914_6_)
  238.     {
  239.         if (Minecraft.isGuiEnabled() && p_147914_1_.getDisplayedItem() != null && p_147914_1_.getDisplayedItem().hasDisplayName() && this.renderManager.field_147941_i == p_147914_1_)
  240.         {
  241.             float f = 1.6F;
  242.             float f1 = 0.016666668F * f;
  243.             double d3 = p_147914_1_.getDistanceSqToEntity(this.renderManager.livingPlayer);
  244.             float f2 = p_147914_1_.isSneaking() ? 32.0F : 64.0F;
  245.  
  246.             if (d3 < (double)(f2 * f2))
  247.             {
  248.                 String s = p_147914_1_.getDisplayedItem().getDisplayName();
  249.  
  250.                 if (p_147914_1_.isSneaking())
  251.                 {
  252.                     FontRenderer fontrenderer = this.getFontRendererFromRenderManager();
  253.                     GL11.glPushMatrix();
  254.                     GL11.glTranslatef((float)p_147914_2_ + 0.0F, (float)p_147914_4_ + p_147914_1_.height + 0.5F, (float)p_147914_6_);
  255.                     GL11.glNormal3f(0.0F, 1.0F, 0.0F);
  256.                     GL11.glRotatef(-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
  257.                     GL11.glRotatef(this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
  258.                     GL11.glScalef(-f1, -f1, f1);
  259.                     GL11.glDisable(GL11.GL_LIGHTING);
  260.                     GL11.glTranslatef(0.0F, 0.25F / f1, 0.0F);
  261.                     GL11.glDepthMask(false);
  262.                     GL11.glEnable(GL11.GL_BLEND);
  263.                     GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
  264.                     Tessellator tessellator = Tessellator.instance;
  265.                     GL11.glDisable(GL11.GL_TEXTURE_2D);
  266.                     tessellator.startDrawingQuads();
  267.                     int i = fontrenderer.getStringWidth(s) / 2;
  268.                     tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F);
  269.                     tessellator.addVertex((double)(-i - 1), -1.0D, 0.0D);
  270.                     tessellator.addVertex((double)(-i - 1), 8.0D, 0.0D);
  271.                     tessellator.addVertex((double)(i + 1), 8.0D, 0.0D);
  272.                     tessellator.addVertex((double)(i + 1), -1.0D, 0.0D);
  273.                     tessellator.draw();
  274.                     GL11.glEnable(GL11.GL_TEXTURE_2D);
  275.                     GL11.glDepthMask(true);
  276.                     fontrenderer.drawString(s, -fontrenderer.getStringWidth(s) / 2, 0, 553648127);
  277.                     GL11.glEnable(GL11.GL_LIGHTING);
  278.                     GL11.glDisable(GL11.GL_BLEND);
  279.                     GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
  280.                     GL11.glPopMatrix();
  281.                 }
  282.                 else
  283.                 {
  284.                     this.func_147906_a(p_147914_1_, s, p_147914_2_, p_147914_4_, p_147914_6_, 64);
  285.                 }
  286.             }
  287.         }
  288.     }
  289.  
  290.     /**
  291.      * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
  292.      */
  293.     protected ResourceLocation getEntityTexture(Entity p_110775_1_)
  294.     {
  295.         return this.getEntityTexture((EntityAdvancedFrame)p_110775_1_);
  296.     }
  297.  
  298.     /**
  299.      * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
  300.      * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
  301.      * (Render<T extends Entity) and this method has signature public void func_76986_a(T entity, double d, double d1,
  302.      * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
  303.      */
  304.     public void doRender(Entity p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_)
  305.     {
  306.         this.doRender((EntityAdvancedFrame)p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_);
  307.     }
  308. }
Advertisement
Add Comment
Please, Sign In to add comment