    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 skullRenderer;
    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        /**
    016         * Render a skull tile entity.
    017         */
    018        public void renderTileEntitySkullAt(TileEntitySkull par1TileEntitySkull, double par2, double par4, double par6, float par8)
    019        {
    020            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());
    021        }
    022
    023        /**
    024         * Associate a TileEntityRenderer with this TileEntitySpecialRenderer
    025         */
    026        public void setTileEntityRenderer(TileEntityRenderer par1TileEntityRenderer)
    027        {
    028            super.setTileEntityRenderer(par1TileEntityRenderer);
    029            skullRenderer = this;
    030        }
    031
    032        public void func_82393_a(float par1, float par2, float par3, int par4, float par5, int par6, String par7Str)
    033        {
    034            ModelSkeletonHead var8 = this.field_82396_c;
    035
    036            switch (par6)
    037            {
    038                case 0:
    039                default:
    040                    this.bindTextureByName("/mob/skeleton.png");
    041                    break;
    042                case 1:
    043                    this.bindTextureByName("/mob/skeleton_wither.png");
    044                    break;
    045                case 2:
    046                    this.bindTextureByName("/mob/zombie.png");
    047                    var8 = this.field_82395_d;
    048                    break;
    049                case 3:
    050                    if (par7Str != null && par7Str.length() > 0)
    051                    {
    052                        String var9 = "http://skins.minecraft.net/MinecraftSkins/" + StringUtils.stripControlCodes(par7Str) + ".png";
    053
    054                        if (!skullRenderer.tileEntityRenderer.renderEngine.func_82773_c(var9))
    055                        {
    056                            skullRenderer.tileEntityRenderer.renderEngine.obtainImageData(var9, new ImageBufferDownload());
    057                        }
    058
    059                        this.func_82392_a(var9, "/mob/char.png");
    060                    }
    061                    else
    062                    {
    063                        this.bindTextureByName("/mob/char.png");
    064                    }
    065
    066                    break;
    067                case 4:
    068                    this.bindTextureByName("/mob/creeper.png");
    069            }
    070
    071            GL11.glPushMatrix();
    072            GL11.glDisable(GL11.GL_CULL_FACE);
    073
    074            if (par4 != 1)
    075            {
    076                switch (par4)
    077                {
    078                    case 2:
    079                        GL11.glTranslatef(par1 + 0.5F, par2 + 0.25F, par3 + 0.74F);
    080                        break;
    081                    case 3:
    082                        GL11.glTranslatef(par1 + 0.5F, par2 + 0.25F, par3 + 0.26F);
    083                        par5 = 180.0F;
    084                        break;
    085                    case 4:
    086                        GL11.glTranslatef(par1 + 0.74F, par2 + 0.25F, par3 + 0.5F);
    087                        par5 = 270.0F;
    088                        break;
    089                    case 5:
    090                    default:
    091                        GL11.glTranslatef(par1 + 0.26F, par2 + 0.25F, par3 + 0.5F);
    092                        par5 = 90.0F;
    093                }
    094            }
    095            else
    096            {
    097                GL11.glTranslatef(par1 + 0.5F, par2, par3 + 0.5F);
    098            }
    099
    100            float var10 = 0.0625F;
    101            GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    102            GL11.glScalef(-1.0F, -1.0F, 1.0F);
    103            GL11.glEnable(GL11.GL_ALPHA_TEST);
    104            var8.render((Entity)null, 0.0F, 0.0F, 0.0F, par5, 0.0F, var10);
    105            GL11.glPopMatrix();
    106        }
    107
    108        public void renderTileEntityAt(TileEntity par1TileEntity, double par2, double par4, double par6, float par8)
    109        {
    110            this.renderTileEntitySkullAt((TileEntitySkull)par1TileEntity, par2, par4, par6, par8);
    111        }
    112    }