public void renderAModelAt(TileEntitySkywoodChest tile, double x, double y, double z, float f) {
    int rotation = 0;
    if (tile.worldObj != null) {
      rotation = tile.getBlockMetadata();
    }

    if (tile.adjacentChestZNeg == null && tile.adjacentChestXNeg == null) {
      ModelChest modelchest;

      if (tile.adjacentChestXPos == null && tile.adjacentChestZPosition == null) {
        modelchest = this.chestModel;

        this.bindTexture(TileEntityResourceLocation.skywood_singleChest);

      } else {
        modelchest = this.largeChestModel;

        this.bindTexture(TileEntityResourceLocation.skywood_doubleChest);
      }
      GL11.glPushMatrix();
      GL11.glEnable(GL12.GL_RESCALE_NORMAL);
      GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
      GL11.glTranslatef((float) x, (float) y + 1.0F, (float) z + 1.0F);
      GL11.glScalef(1.0F, -1.0F, -1.0F);
      GL11.glTranslatef(0.5F, 0.5F, 0.5F);
      short short1 = 0;

      if (rotation == 2) {
        short1 = 180;
      }

      if (rotation == 3) {
        short1 = 0;
      }

      if (rotation == 4) {
        short1 = 90;
      }

      if (rotation == 5) {
        short1 = -90;
      }

      if (rotation == 2 && tile.adjacentChestXPos != null) {
        GL11.glTranslatef(1.0F, 0.0F, 0.0F);
      }

      if (rotation == 5 && tile.adjacentChestZPosition != null) {
        GL11.glTranslatef(0.0F, 0.0F, -1.0F);
      }

      GL11.glRotatef((float) short1, 0.0F, 1.0F, 0.0F);
      GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
      float f1 = tile.prevLidAngle + (tile.lidAngle - tile.prevLidAngle) * f;
      float f2;

      if (tile.adjacentChestZNeg != null) {
        f2 =
            tile.adjacentChestZNeg.prevLidAngle
                + (tile.adjacentChestZNeg.lidAngle - tile.adjacentChestZNeg.prevLidAngle) * f;

        if (f2 > f1) {
          f1 = f2;
        }
      }

      if (tile.adjacentChestXNeg != null) {
        f2 =
            tile.adjacentChestXNeg.prevLidAngle
                + (tile.adjacentChestXNeg.lidAngle - tile.adjacentChestXNeg.prevLidAngle) * f;

        if (f2 > f1) {
          f1 = f2;
        }
      }

      f1 = 1.0F - f1;
      f1 = 1.0F - f1 * f1 * f1;
      modelchest.chestLid.rotateAngleX = -(f1 * (float) Math.PI / 2.0F);
      modelchest.renderAll();
      GL11.glDisable(GL12.GL_RESCALE_NORMAL);
      GL11.glPopMatrix();
      GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    }
  }
  public void renderItem(ItemStack item, float x, float y, float z, int pass) {
    String wood = WoodTypes.DEFAULT_WOOD_ID;
    int wool = 0;
    EInventoryMaterial mat = EInventoryMaterial.values()[item.getItemDamage()];

    if (item.hasTagCompound()) {
      if (item.getTagCompound().hasKey("woodType"))
        wood = item.getTagCompound().getString("woodType");
      wool = item.getTagCompound().getInteger("wool");
    }

    int i = 5;
    GL11.glPushMatrix();
    // GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    switch (pass) {
      case 0:
        mc.renderEngine.bindTexture(WoodTypes.getWoodType(wood).getTexture(2));
        GL11.glColor4f(1f, 1f, 1f, 1f);
        break;
      case 1:
        Color c = ColorHelper.WOOL_COLORS[wool];
        GL11.glColor4f(c.getRed() / 255f, c.getGreen() / 255f, c.getBlue() / 255f, 1f);
        mc.renderEngine.bindTexture(singleChestWool);
        break;
      case 2:
        if (mat.hasTexture()) {
          GL11.glColor4f(1f, 1f, 1f, 1f);
          mc.renderEngine.bindTexture(mat.getTexture(0));
        } else {
          GL11.glColor4f(mat.r(), mat.g(), mat.b(), 1f);
          mc.renderEngine.bindTexture(singleChestFrame);
        }
        break;
      case 3:
        GL11.glColor4f(1f, 1f, 1f, 1f);
        mc.renderEngine.bindTexture(singleRefinedLocation);
        break;
    }
    GL11.glTranslatef((float) x, (float) y + 1.0F, (float) z + 1.0F);
    GL11.glScalef(1.0F, -1.0F, -1.0F);
    GL11.glTranslatef(0.5F, 0.5F, 0.5F);
    short short1 = 0;

    if (i == 2) {
      short1 = 180;
    }

    if (i == 3) {
      short1 = 0;
    }

    if (i == 4) {
      short1 = 90;
    }

    if (i == 5) {
      short1 = -90;
    }

    GL11.glRotatef((float) short1, 0.0F, 1.0F, 0.0F);
    GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
    // float f1 = chest.prevLidAngle + (chest.lidAngle - chest.prevLidAngle) * f;
    // float f2;
    // f1 = 1.0F - f1;
    // f1 = 1.0F - f1 * f1 * f1;
    // modelchest.chestLid.rotateAngleX = -(f1 * (float)Math.PI / 2.0F);
    modelChest.renderAll();
    // GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    GL11.glPopMatrix();
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
  }
  /** Renders the TileEntity for the chest at a position. */
  public void renderTileEntityChestAt(
      TileEntityTutorialChest par1TileEntityChest,
      double par2,
      double par4,
      double par6,
      float par8) {
    int i;

    if (!par1TileEntityChest.hasWorldObj()) {
      i = 0;
    } else {
      Block block = par1TileEntityChest.getBlockType();
      i = par1TileEntityChest.getBlockMetadata();

      if (block instanceof TutorialChest && i == 0) {
        try {
          ((TutorialChest) block)
              .unifyAdjacentChests(
                  par1TileEntityChest.getWorldObj(),
                  par1TileEntityChest.xCoord,
                  par1TileEntityChest.yCoord,
                  par1TileEntityChest.zCoord);
        } catch (ClassCastException e) {
          FMLLog.severe(
              "Attempted to render a chest at %d,  %d, %d that was not a chest",
              par1TileEntityChest.xCoord, par1TileEntityChest.yCoord, par1TileEntityChest.zCoord);
        }
        i = par1TileEntityChest.getBlockMetadata();
      }

      par1TileEntityChest.checkForAdjacentChests();
    }

    if (par1TileEntityChest.adjacentChestZNeg == null
        && par1TileEntityChest.adjacentChestXNeg == null) {
      ModelChest modelchest;

      if (par1TileEntityChest.adjacentChestXPos == null
          && par1TileEntityChest.adjacentChestZPosition == null) {
        modelchest = this.chestModel;

        if (par1TileEntityChest.func_98041_l() == 1) {
        } else {
          this.bindTexture(resourcelgchest);
        }
      } else {
        modelchest = this.largeChestModel;

        if (par1TileEntityChest.func_98041_l() == 1) {
        } else {
          this.bindTexture(resourcechest);
        }
      }

      GL11.glPushMatrix();
      GL11.glEnable(GL12.GL_RESCALE_NORMAL);
      GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
      GL11.glTranslatef((float) par2, (float) par4 + 1.0F, (float) par6 + 1.0F);
      GL11.glScalef(1.0F, -1.0F, -1.0F);
      GL11.glTranslatef(0.5F, 0.5F, 0.5F);
      short short1 = 0;

      if (i == 2) {
        short1 = 180;
      }

      if (i == 3) {
        short1 = 0;
      }

      if (i == 4) {
        short1 = 90;
      }

      if (i == 5) {
        short1 = -90;
      }

      if (i == 2 && par1TileEntityChest.adjacentChestXPos != null) {
        GL11.glTranslatef(1.0F, 0.0F, 0.0F);
      }

      if (i == 5 && par1TileEntityChest.adjacentChestZPosition != null) {
        GL11.glTranslatef(0.0F, 0.0F, -1.0F);
      }

      GL11.glRotatef((float) short1, 0.0F, 1.0F, 0.0F);
      GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
      float f1 =
          par1TileEntityChest.prevLidAngle
              + (par1TileEntityChest.lidAngle - par1TileEntityChest.prevLidAngle) * par8;
      float f2;

      if (par1TileEntityChest.adjacentChestZNeg != null) {
        f2 =
            par1TileEntityChest.adjacentChestZNeg.prevLidAngle
                + (par1TileEntityChest.adjacentChestZNeg.lidAngle
                        - par1TileEntityChest.adjacentChestZNeg.prevLidAngle)
                    * par8;

        if (f2 > f1) {
          f1 = f2;
        }
      }

      if (par1TileEntityChest.adjacentChestXNeg != null) {
        f2 =
            par1TileEntityChest.adjacentChestXNeg.prevLidAngle
                + (par1TileEntityChest.adjacentChestXNeg.lidAngle
                        - par1TileEntityChest.adjacentChestXNeg.prevLidAngle)
                    * par8;

        if (f2 > f1) {
          f1 = f2;
        }
      }

      f1 = 1.0F - f1;
      f1 = 1.0F - f1 * f1 * f1;
      modelchest.chestLid.rotateAngleX = -(f1 * (float) Math.PI / 2.0F);
      modelchest.renderAll();
      GL11.glDisable(GL12.GL_RESCALE_NORMAL);
      GL11.glPopMatrix();
      GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    }
  }