    001    package net.minecraft.client.renderer.entity;
    002
    003    import cpw.mods.fml.relauncher.Side;
    004    import cpw.mods.fml.relauncher.SideOnly;
    005    import net.minecraft.client.model.ModelBase;
    006    import net.minecraft.entity.EntityLiving;
    007    import net.minecraft.entity.monster.EntitySlime;
    008    import org.lwjgl.opengl.GL11;
    009
    010    @SideOnly(Side.CLIENT)
    011    public class RenderSlime extends RenderLiving
    012    {
    013        private ModelBase scaleAmount;
    014
    015        public RenderSlime(ModelBase par1ModelBase, ModelBase par2ModelBase, float par3)
    016        {
    017            super(par1ModelBase, par3);
    018            this.scaleAmount = par2ModelBase;
    019        }
    020
    021        /**
    022         * Determines whether Slime Render should pass or not.
    023         */
    024        protected int shouldSlimeRenderPass(EntitySlime par1EntitySlime, int par2, float par3)
    025        {
    026            if (par1EntitySlime.getHasActivePotion())
    027            {
    028                return 0;
    029            }
    030            else if (par2 == 0)
    031            {
    032                this.setRenderPassModel(this.scaleAmount);
    033                GL11.glEnable(GL11.GL_NORMALIZE);
    034                GL11.glEnable(GL11.GL_BLEND);
    035                GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    036                return 1;
    037            }
    038            else
    039            {
    040                if (par2 == 1)
    041                {
    042                    GL11.glDisable(GL11.GL_BLEND);
    043                    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    044                }
    045
    046                return -1;
    047            }
    048        }
    049
    050        /**
    051         * sets the scale for the slime based on getSlimeSize in EntitySlime
    052         */
    053        protected void scaleSlime(EntitySlime par1EntitySlime, float par2)
    054        {
    055            float var3 = (float)par1EntitySlime.getSlimeSize();
    056            float var4 = (par1EntitySlime.field_70812_c + (par1EntitySlime.field_70811_b - par1EntitySlime.field_70812_c) * par2) / (var3 * 0.5F + 1.0F);
    057            float var5 = 1.0F / (var4 + 1.0F);
    058            GL11.glScalef(var5 * var3, 1.0F / var5 * var3, var5 * var3);
    059        }
    060
    061        /**
    062         * Allows the render to do any OpenGL state modifications necessary before the model is rendered. Args:
    063         * entityLiving, partialTickTime
    064         */
    065        protected void preRenderCallback(EntityLiving par1EntityLiving, float par2)
    066        {
    067            this.scaleSlime((EntitySlime)par1EntityLiving, par2);
    068        }
    069
    070        /**
    071         * Queries whether should render the specified pass or not.
    072         */
    073        protected int shouldRenderPass(EntityLiving par1EntityLiving, int par2, float par3)
    074        {
    075            return this.shouldSlimeRenderPass((EntitySlime)par1EntityLiving, par2, par3);
    076        }
    077    }