@Override
  public void renderTileEntityAt(
      TileEntity tileentity, double d0, double d1, double d2, float partialTicks) {
    TileAnimationTablet tile = (TileAnimationTablet) tileentity;

    int meta = tile.getBlockMetadata() & 7;
    if (meta < 2) meta = 2; // Just in case

    int rotation = meta == 2 ? 270 : meta == 3 ? 90 : meta == 4 ? 0 : 180;

    GL11.glPushMatrix();
    GL11.glTranslated(d0, d1, d2);
    renderOverlay(tile, overlayCenter, -1, false, false, 0.65, 0.13F, 0F);
    if (tile.leftClick) renderOverlay(tile, overlayLeft, 1, false, true, 1, 0.13F, 0F);
    else renderOverlay(tile, overlayRight, 1, false, true, 1, 0.131F, 0F);
    renderOverlay(tile, overlayIndent, 0, false, false, 0.5F, 0.13F, rotation + 90F);

    GL11.glRotatef(rotation, 0F, 1F, 0F);
    GL11.glTranslated(0.1, 0.2 + Math.cos(System.currentTimeMillis() / 600D) / 18F, 0.5);
    float[] translations = TRANSLATIONS[meta - 2];
    GL11.glTranslatef(translations[0], translations[1], translations[2]);
    GL11.glScalef(0.8F, 0.8F, 0.8F);
    GL11.glTranslatef(0.5F, 0F, 0.5F);
    GL11.glRotatef(tile.swingProgress, 0F, 0F, 1F);
    GL11.glTranslatef(-0.5F, 0F, -0.5F);
    GL11.glTranslatef(-tile.swingProgress / 250F, tile.swingProgress / 1000F, 0F);
    GL11.glRotatef((float) Math.cos(System.currentTimeMillis() / 400F) * 5F, 1F, 0F, 1F);
    renderItem(tile);
    GL11.glPopMatrix();
  }
 private void renderItem(TileAnimationTablet tablet) {
   ItemStack stack = tablet.getStackInSlot(0);
   Minecraft mc = ClientHelper.minecraft();
   if (stack != null) {
     EntityItem entityitem = new EntityItem(tablet.worldObj, 0.0D, 0.0D, 0.0D, stack);
     entityitem.getEntityItem().stackSize = 1;
     entityitem.hoverStart = 0.0F;
     GL11.glPushMatrix();
     GL11.glTranslatef(0.5F, 0.55F, 0F);
     if (stack.getItem() instanceof ItemBlock) GL11.glScalef(2.5F, 2.5F, 2.5F);
     else GL11.glScalef(1.5F, 1.5F, 1.5F);
     RenderItem.renderInFrame = true;
     RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
     RenderItem.renderInFrame = false;
     GL11.glPopMatrix();
   }
 }