    001    package net.minecraft.src;
    002
    003    import cpw.mods.fml.common.Side;
    004    import cpw.mods.fml.common.asm.SideOnly;
    005    import java.util.Random;
    006    import org.lwjgl.opengl.GL11;
    007    import org.lwjgl.opengl.GL12;
    008
    009    @SideOnly(Side.CLIENT)
    010    public class RenderEnderman extends RenderLiving
    011    {
    012        /** The model of the enderman */
    013        private ModelEnderman endermanModel;
    014        private Random rnd = new Random();
    015
    016        public RenderEnderman()
    017        {
    018            super(new ModelEnderman(), 0.5F);
    019            this.endermanModel = (ModelEnderman)super.mainModel;
    020            this.setRenderPassModel(this.endermanModel);
    021        }
    022
    023        /**
    024         * Renders the enderman
    025         */
    026        public void renderEnderman(EntityEnderman par1EntityEnderman, double par2, double par4, double par6, float par8, float par9)
    027        {
    028            this.endermanModel.isCarrying = par1EntityEnderman.getCarried() > 0;
    029            this.endermanModel.isAttacking = par1EntityEnderman.func_70823_r();
    030
    031            if (par1EntityEnderman.func_70823_r())
    032            {
    033                double var10 = 0.02D;
    034                par2 += this.rnd.nextGaussian() * var10;
    035                par6 += this.rnd.nextGaussian() * var10;
    036            }
    037
    038            super.doRenderLiving(par1EntityEnderman, par2, par4, par6, par8, par9);
    039        }
    040
    041        /**
    042         * Render the block an enderman is carrying
    043         */
    044        protected void renderCarrying(EntityEnderman par1EntityEnderman, float par2)
    045        {
    046            super.renderEquippedItems(par1EntityEnderman, par2);
    047
    048            if (par1EntityEnderman.getCarried() > 0)
    049            {
    050                GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    051                GL11.glPushMatrix();
    052                float var3 = 0.5F;
    053                GL11.glTranslatef(0.0F, 0.6875F, -0.75F);
    054                var3 *= 1.0F;
    055                GL11.glRotatef(20.0F, 1.0F, 0.0F, 0.0F);
    056                GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
    057                GL11.glScalef(var3, -var3, var3);
    058                int var4 = par1EntityEnderman.getBrightnessForRender(par2);
    059                int var5 = var4 % 65536;
    060                int var6 = var4 / 65536;
    061                OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)var5 / 1.0F, (float)var6 / 1.0F);
    062                GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    063                GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    064                this.loadTexture("/terrain.png");
    065                this.renderBlocks.renderBlockAsItem(Block.blocksList[par1EntityEnderman.getCarried()], par1EntityEnderman.getCarryingData(), 1.0F);
    066                GL11.glPopMatrix();
    067                GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    068            }
    069        }
    070
    071        /**
    072         * Render the endermans eyes
    073         */
    074        protected int renderEyes(EntityEnderman par1EntityEnderman, int par2, float par3)
    075        {
    076            if (par2 != 0)
    077            {
    078                return -1;
    079            }
    080            else
    081            {
    082                this.loadTexture("/mob/enderman_eyes.png");
    083                float var4 = 1.0F;
    084                GL11.glEnable(GL11.GL_BLEND);
    085                GL11.glDisable(GL11.GL_ALPHA_TEST);
    086                GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
    087                GL11.glDisable(GL11.GL_LIGHTING);
    088
    089                if (par1EntityEnderman.func_82150_aj())
    090                {
    091                    GL11.glDepthMask(false);
    092                }
    093                else
    094                {
    095                    GL11.glDepthMask(true);
    096                }
    097
    098                char var5 = 61680;
    099                int var6 = var5 % 65536;
    100                int var7 = var5 / 65536;
    101                OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)var6 / 1.0F, (float)var7 / 1.0F);
    102                GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    103                GL11.glEnable(GL11.GL_LIGHTING);
    104                GL11.glColor4f(1.0F, 1.0F, 1.0F, var4);
    105                return 1;
    106            }
    107        }
    108
    109        /**
    110         * Queries whether should render the specified pass or not.
    111         */
    112        protected int shouldRenderPass(EntityLiving par1EntityLiving, int par2, float par3)
    113        {
    114            return this.renderEyes((EntityEnderman)par1EntityLiving, par2, par3);
    115        }
    116
    117        protected void renderEquippedItems(EntityLiving par1EntityLiving, float par2)
    118        {
    119            this.renderCarrying((EntityEnderman)par1EntityLiving, par2);
    120        }
    121
    122        public void doRenderLiving(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9)
    123        {
    124            this.renderEnderman((EntityEnderman)par1EntityLiving, par2, par4, par6, par8, par9);
    125        }
    126
    127        /**
    128         * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
    129         * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
    130         * (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1,
    131         * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
    132         */
    133        public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
    134        {
    135            this.renderEnderman((EntityEnderman)par1Entity, par2, par4, par6, par8, par9);
    136        }
    137    }