    001package net.minecraft.client.renderer.entity;
    002
    003import cpw.mods.fml.relauncher.Side;
    004import cpw.mods.fml.relauncher.SideOnly;
    005import net.minecraft.client.model.ModelBook;
    006import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
    007import net.minecraft.entity.Entity;
    008import net.minecraft.tileentity.TileEntity;
    009import net.minecraft.tileentity.TileEntityEnchantmentTable;
    010import net.minecraft.util.MathHelper;
    011import org.lwjgl.opengl.GL11;
    012
    013@SideOnly(Side.CLIENT)
    014public 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 f1 = (float)par1TileEntityEnchantmentTable.tickCount + par8;
    023        GL11.glTranslatef(0.0F, 0.1F + MathHelper.sin(f1 * 0.1F) * 0.01F, 0.0F);
    024        float f2;
    025
    026        for (f2 = par1TileEntityEnchantmentTable.bookRotation2 - par1TileEntityEnchantmentTable.bookRotationPrev; f2 >= (float)Math.PI; f2 -= ((float)Math.PI * 2F))
    027        {
    028            ;
    029        }
    030
    031        while (f2 < -(float)Math.PI)
    032        {
    033            f2 += ((float)Math.PI * 2F);
    034        }
    035
    036        float f3 = par1TileEntityEnchantmentTable.bookRotationPrev + f2 * par8;
    037        GL11.glRotatef(-f3 * 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 f4 = par1TileEntityEnchantmentTable.pageFlipPrev + (par1TileEntityEnchantmentTable.pageFlip - par1TileEntityEnchantmentTable.pageFlipPrev) * par8 + 0.25F;
    041        float f5 = par1TileEntityEnchantmentTable.pageFlipPrev + (par1TileEntityEnchantmentTable.pageFlip - par1TileEntityEnchantmentTable.pageFlipPrev) * par8 + 0.75F;
    042        f4 = (f4 - (float)MathHelper.truncateDoubleToInt((double)f4)) * 1.6F - 0.3F;
    043        f5 = (f5 - (float)MathHelper.truncateDoubleToInt((double)f5)) * 1.6F - 0.3F;
    044
    045        if (f4 < 0.0F)
    046        {
    047            f4 = 0.0F;
    048        }
    049
    050        if (f5 < 0.0F)
    051        {
    052            f5 = 0.0F;
    053        }
    054
    055        if (f4 > 1.0F)
    056        {
    057            f4 = 1.0F;
    058        }
    059
    060        if (f5 > 1.0F)
    061        {
    062            f5 = 1.0F;
    063        }
    064
    065        float f6 = par1TileEntityEnchantmentTable.bookSpreadPrev + (par1TileEntityEnchantmentTable.bookSpread - par1TileEntityEnchantmentTable.bookSpreadPrev) * par8;
    066        GL11.glEnable(GL11.GL_CULL_FACE);
    067        this.enchantmentBook.render((Entity)null, f1, f4, f5, f6, 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}