    001package net.minecraft.client.renderer.tileentity;
    002
    003import cpw.mods.fml.relauncher.Side;
    004import cpw.mods.fml.relauncher.SideOnly;
    005import net.minecraft.block.Block;
    006import net.minecraft.client.gui.FontRenderer;
    007import net.minecraft.client.model.ModelSign;
    008import net.minecraft.tileentity.TileEntity;
    009import net.minecraft.tileentity.TileEntitySign;
    010import org.lwjgl.opengl.GL11;
    011
    012@SideOnly(Side.CLIENT)
    013public class TileEntitySignRenderer extends TileEntitySpecialRenderer
    014{
    015    /** The ModelSign instance used by the TileEntitySignRenderer */
    016    private ModelSign modelSign = new ModelSign();
    017
    018    public void renderTileEntitySignAt(TileEntitySign par1TileEntitySign, double par2, double par4, double par6, float par8)
    019    {
    020        Block block = par1TileEntitySign.getBlockType();
    021        GL11.glPushMatrix();
    022        float f1 = 0.6666667F;
    023        float f2;
    024
    025        if (block == Block.signPost)
    026        {
    027            GL11.glTranslatef((float)par2 + 0.5F, (float)par4 + 0.75F * f1, (float)par6 + 0.5F);
    028            float f3 = (float)(par1TileEntitySign.getBlockMetadata() * 360) / 16.0F;
    029            GL11.glRotatef(-f3, 0.0F, 1.0F, 0.0F);
    030            this.modelSign.signStick.showModel = true;
    031        }
    032        else
    033        {
    034            int i = par1TileEntitySign.getBlockMetadata();
    035            f2 = 0.0F;
    036
    037            if (i == 2)
    038            {
    039                f2 = 180.0F;
    040            }
    041
    042            if (i == 4)
    043            {
    044                f2 = 90.0F;
    045            }
    046
    047            if (i == 5)
    048            {
    049                f2 = -90.0F;
    050            }
    051
    052            GL11.glTranslatef((float)par2 + 0.5F, (float)par4 + 0.75F * f1, (float)par6 + 0.5F);
    053            GL11.glRotatef(-f2, 0.0F, 1.0F, 0.0F);
    054            GL11.glTranslatef(0.0F, -0.3125F, -0.4375F);
    055            this.modelSign.signStick.showModel = false;
    056        }
    057
    058        this.bindTextureByName("/item/sign.png");
    059        GL11.glPushMatrix();
    060        GL11.glScalef(f1, -f1, -f1);
    061        this.modelSign.renderSign();
    062        GL11.glPopMatrix();
    063        FontRenderer fontrenderer = this.getFontRenderer();
    064        f2 = 0.016666668F * f1;
    065        GL11.glTranslatef(0.0F, 0.5F * f1, 0.07F * f1);
    066        GL11.glScalef(f2, -f2, f2);
    067        GL11.glNormal3f(0.0F, 0.0F, -1.0F * f2);
    068        GL11.glDepthMask(false);
    069        byte b0 = 0;
    070
    071        for (int j = 0; j < par1TileEntitySign.signText.length; ++j)
    072        {
    073            String s = par1TileEntitySign.signText[j];
    074
    075            if (j == par1TileEntitySign.lineBeingEdited)
    076            {
    077                s = "> " + s + " <";
    078                fontrenderer.drawString(s, -fontrenderer.getStringWidth(s) / 2, j * 10 - par1TileEntitySign.signText.length * 5, b0);
    079            }
    080            else
    081            {
    082                fontrenderer.drawString(s, -fontrenderer.getStringWidth(s) / 2, j * 10 - par1TileEntitySign.signText.length * 5, b0);
    083            }
    084        }
    085
    086        GL11.glDepthMask(true);
    087        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    088        GL11.glPopMatrix();
    089    }
    090
    091    public void renderTileEntityAt(TileEntity par1TileEntity, double par2, double par4, double par6, float par8)
    092    {
    093        this.renderTileEntitySignAt((TileEntitySign)par1TileEntity, par2, par4, par6, par8);
    094    }
    095}