    001    package net.minecraft.client.renderer.tileentity;
    002
    003    import cpw.mods.fml.relauncher.Side;
    004    import cpw.mods.fml.relauncher.SideOnly;
    005    import net.minecraft.block.Block;
    006    import net.minecraft.client.gui.FontRenderer;
    007    import net.minecraft.client.model.ModelSign;
    008    import net.minecraft.tileentity.TileEntity;
    009    import net.minecraft.tileentity.TileEntitySign;
    010    import org.lwjgl.opengl.GL11;
    011
    012    @SideOnly(Side.CLIENT)
    013    public 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 var9 = par1TileEntitySign.getBlockType();
    021            GL11.glPushMatrix();
    022            float var10 = 0.6666667F;
    023            float var12;
    024
    025            if (var9 == Block.signPost)
    026            {
    027                GL11.glTranslatef((float)par2 + 0.5F, (float)par4 + 0.75F * var10, (float)par6 + 0.5F);
    028                float var11 = (float)(par1TileEntitySign.getBlockMetadata() * 360) / 16.0F;
    029                GL11.glRotatef(-var11, 0.0F, 1.0F, 0.0F);
    030                this.modelSign.signStick.showModel = true;
    031            }
    032            else
    033            {
    034                int var16 = par1TileEntitySign.getBlockMetadata();
    035                var12 = 0.0F;
    036
    037                if (var16 == 2)
    038                {
    039                    var12 = 180.0F;
    040                }
    041
    042                if (var16 == 4)
    043                {
    044                    var12 = 90.0F;
    045                }
    046
    047                if (var16 == 5)
    048                {
    049                    var12 = -90.0F;
    050                }
    051
    052                GL11.glTranslatef((float)par2 + 0.5F, (float)par4 + 0.75F * var10, (float)par6 + 0.5F);
    053                GL11.glRotatef(-var12, 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(var10, -var10, -var10);
    061            this.modelSign.renderSign();
    062            GL11.glPopMatrix();
    063            FontRenderer var17 = this.getFontRenderer();
    064            var12 = 0.016666668F * var10;
    065            GL11.glTranslatef(0.0F, 0.5F * var10, 0.07F * var10);
    066            GL11.glScalef(var12, -var12, var12);
    067            GL11.glNormal3f(0.0F, 0.0F, -1.0F * var12);
    068            GL11.glDepthMask(false);
    069            byte var13 = 0;
    070
    071            for (int var14 = 0; var14 < par1TileEntitySign.signText.length; ++var14)
    072            {
    073                String var15 = par1TileEntitySign.signText[var14];
    074
    075                if (var14 == par1TileEntitySign.lineBeingEdited)
    076                {
    077                    var15 = "> " + var15 + " <";
    078                    var17.drawString(var15, -var17.getStringWidth(var15) / 2, var14 * 10 - par1TileEntitySign.signText.length * 5, var13);
    079                }
    080                else
    081                {
    082                    var17.drawString(var15, -var17.getStringWidth(var15) / 2, var14 * 10 - par1TileEntitySign.signText.length * 5, var13);
    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    }