    001    package net.minecraft.src;
    002
    003    import cpw.mods.fml.common.Side;
    004    import cpw.mods.fml.common.asm.SideOnly;
    005    import org.lwjgl.opengl.GL11;
    006    import org.lwjgl.opengl.GL12;
    007
    008    @SideOnly(Side.CLIENT)
    009    public class TileEntitySkullRenderer extends TileEntitySpecialRenderer
    010    {
    011        public static TileEntitySkullRenderer field_82397_a;
    012        private ModelSkeletonHead field_82396_c = new ModelSkeletonHead(0, 0, 64, 32);
    013        private ModelSkeletonHead field_82395_d = new ModelSkeletonHead(0, 0, 64, 64);
    014
    015        public void func_82394_a(TileEntitySkull par1TileEntitySkull, double par2, double par4, double par6, float par8)
    016        {
    017            this.func_82393_a((float)par2, (float)par4, (float)par6, par1TileEntitySkull.getBlockMetadata() & 7, (float)(par1TileEntitySkull.func_82119_b() * 360) / 16.0F, par1TileEntitySkull.func_82117_a(), par1TileEntitySkull.func_82120_c());
    018        }
    019
    020        /**
    021         * Associate a TileEntityRenderer with this TileEntitySpecialRenderer
    022         */
    023        public void setTileEntityRenderer(TileEntityRenderer par1TileEntityRenderer)
    024        {
    025            super.setTileEntityRenderer(par1TileEntityRenderer);
    026            field_82397_a = this;
    027        }
    028
    029        public void func_82393_a(float par1, float par2, float par3, int par4, float par5, int par6, String par7Str)
    030        {
    031            ModelSkeletonHead var8 = this.field_82396_c;
    032
    033            switch (par6)
    034            {
    035                case 0:
    036                default:
    037                    this.bindTextureByName("/mob/skeleton.png");
    038                    break;
    039                case 1:
    040                    this.bindTextureByName("/mob/skeleton_wither.png");
    041                    break;
    042                case 2:
    043                    this.bindTextureByName("/mob/zombie.png");
    044                    var8 = this.field_82395_d;
    045                    break;
    046                case 3:
    047                    if (par7Str != null && par7Str.length() > 0)
    048                    {
    049                        String var9 = "http://skins.minecraft.net/MinecraftSkins/" + StringUtils.stripControlCodes(par7Str) + ".png";
    050
    051                        if (!field_82397_a.tileEntityRenderer.renderEngine.func_82773_c(var9))
    052                        {
    053                            field_82397_a.tileEntityRenderer.renderEngine.obtainImageData(var9, new ImageBufferDownload());
    054                        }
    055
    056                        this.func_82392_a(var9, "/mob/char.png");
    057                    }
    058                    else
    059                    {
    060                        this.bindTextureByName("/mob/char.png");
    061                    }
    062
    063                    break;
    064                case 4:
    065                    this.bindTextureByName("/mob/creeper.png");
    066            }
    067
    068            GL11.glPushMatrix();
    069            GL11.glDisable(GL11.GL_CULL_FACE);
    070
    071            if (par4 != 1)
    072            {
    073                switch (par4)
    074                {
    075                    case 2:
    076                        GL11.glTranslatef(par1 + 0.5F, par2 + 0.25F, par3 + 0.74F);
    077                        break;
    078                    case 3:
    079                        GL11.glTranslatef(par1 + 0.5F, par2 + 0.25F, par3 + 0.26F);
    080                        par5 = 180.0F;
    081                        break;
    082                    case 4:
    083                        GL11.glTranslatef(par1 + 0.74F, par2 + 0.25F, par3 + 0.5F);
    084                        par5 = 270.0F;
    085                        break;
    086                    case 5:
    087                    default:
    088                        GL11.glTranslatef(par1 + 0.26F, par2 + 0.25F, par3 + 0.5F);
    089                        par5 = 90.0F;
    090                }
    091            }
    092            else
    093            {
    094                GL11.glTranslatef(par1 + 0.5F, par2, par3 + 0.5F);
    095            }
    096
    097            float var10 = 0.0625F;
    098            GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    099            GL11.glScalef(-1.0F, -1.0F, 1.0F);
    100            GL11.glEnable(GL11.GL_ALPHA_TEST);
    101            var8.render((Entity)null, 0.0F, 0.0F, 0.0F, par5, 0.0F, var10);
    102            GL11.glPopMatrix();
    103        }
    104
    105        public void renderTileEntityAt(TileEntity par1TileEntity, double par2, double par4, double par6, float par8)
    106        {
    107            this.func_82394_a((TileEntitySkull)par1TileEntity, par2, par4, par6, par8);
    108        }
    109    }