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