    001    package net.minecraft.client.renderer.entity;
    002
    003    import cpw.mods.fml.relauncher.Side;
    004    import cpw.mods.fml.relauncher.SideOnly;
    005    import net.minecraft.client.model.ModelBook;
    006    import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
    007    import net.minecraft.entity.Entity;
    008    import net.minecraft.tileentity.TileEntity;
    009    import net.minecraft.tileentity.TileEntityEnchantmentTable;
    010    import net.minecraft.util.MathHelper;
    011    import org.lwjgl.opengl.GL11;
    012
    013    @SideOnly(Side.CLIENT)
    014    public class RenderEnchantmentTable extends TileEntitySpecialRenderer
    015    {
    016        private ModelBook enchantmentBook = new ModelBook();
    017
    018        public void renderTileEntityEnchantmentTableAt(TileEntityEnchantmentTable par1TileEntityEnchantmentTable, double par2, double par4, double par6, float par8)
    019        {
    020            GL11.glPushMatrix();
    021            GL11.glTranslatef((float)par2 + 0.5F, (float)par4 + 0.75F, (float)par6 + 0.5F);
    022            float var9 = (float)par1TileEntityEnchantmentTable.tickCount + par8;
    023            GL11.glTranslatef(0.0F, 0.1F + MathHelper.sin(var9 * 0.1F) * 0.01F, 0.0F);
    024            float var10;
    025
    026            for (var10 = par1TileEntityEnchantmentTable.bookRotation2 - par1TileEntityEnchantmentTable.bookRotationPrev; var10 >= (float)Math.PI; var10 -= ((float)Math.PI * 2F))
    027            {
    028                ;
    029            }
    030
    031            while (var10 < -(float)Math.PI)
    032            {
    033                var10 += ((float)Math.PI * 2F);
    034            }
    035
    036            float var11 = par1TileEntityEnchantmentTable.bookRotationPrev + var10 * par8;
    037            GL11.glRotatef(-var11 * 180.0F / (float)Math.PI, 0.0F, 1.0F, 0.0F);
    038            GL11.glRotatef(80.0F, 0.0F, 0.0F, 1.0F);
    039            this.bindTextureByName("/item/book.png");
    040            float var12 = par1TileEntityEnchantmentTable.pageFlipPrev + (par1TileEntityEnchantmentTable.pageFlip - par1TileEntityEnchantmentTable.pageFlipPrev) * par8 + 0.25F;
    041            float var13 = par1TileEntityEnchantmentTable.pageFlipPrev + (par1TileEntityEnchantmentTable.pageFlip - par1TileEntityEnchantmentTable.pageFlipPrev) * par8 + 0.75F;
    042            var12 = (var12 - (float)MathHelper.truncateDoubleToInt((double)var12)) * 1.6F - 0.3F;
    043            var13 = (var13 - (float)MathHelper.truncateDoubleToInt((double)var13)) * 1.6F - 0.3F;
    044
    045            if (var12 < 0.0F)
    046            {
    047                var12 = 0.0F;
    048            }
    049
    050            if (var13 < 0.0F)
    051            {
    052                var13 = 0.0F;
    053            }
    054
    055            if (var12 > 1.0F)
    056            {
    057                var12 = 1.0F;
    058            }
    059
    060            if (var13 > 1.0F)
    061            {
    062                var13 = 1.0F;
    063            }
    064
    065            float var14 = par1TileEntityEnchantmentTable.bookSpreadPrev + (par1TileEntityEnchantmentTable.bookSpread - par1TileEntityEnchantmentTable.bookSpreadPrev) * par8;
    066            GL11.glEnable(GL11.GL_CULL_FACE);
    067            this.enchantmentBook.render((Entity)null, var9, var12, var13, var14, 0.0F, 0.0625F);
    068            GL11.glPopMatrix();
    069        }
    070
    071        public void renderTileEntityAt(TileEntity par1TileEntity, double par2, double par4, double par6, float par8)
    072        {
    073            this.renderTileEntityEnchantmentTableAt((TileEntityEnchantmentTable)par1TileEntity, par2, par4, par6, par8);
    074        }
    075    }