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