    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 (par2 == 0)
    024            {
    025                this.setRenderPassModel(this.scaleAmount);
    026                GL11.glEnable(GL11.GL_NORMALIZE);
    027                GL11.glEnable(GL11.GL_BLEND);
    028                GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    029                return 1;
    030            }
    031            else
    032            {
    033                if (par2 == 1)
    034                {
    035                    GL11.glDisable(GL11.GL_BLEND);
    036                    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    037                }
    038
    039                return -1;
    040            }
    041        }
    042
    043        /**
    044         * sets the scale for the slime based on getSlimeSize in EntitySlime
    045         */
    046        protected void scaleSlime(EntitySlime par1EntitySlime, float par2)
    047        {
    048            float var3 = (float)par1EntitySlime.getSlimeSize();
    049            float var4 = (par1EntitySlime.field_70812_c + (par1EntitySlime.field_70811_b - par1EntitySlime.field_70812_c) * par2) / (var3 * 0.5F + 1.0F);
    050            float var5 = 1.0F / (var4 + 1.0F);
    051            GL11.glScalef(var5 * var3, 1.0F / var5 * var3, var5 * var3);
    052        }
    053
    054        /**
    055         * Allows the render to do any OpenGL state modifications necessary before the model is rendered. Args:
    056         * entityLiving, partialTickTime
    057         */
    058        protected void preRenderCallback(EntityLiving par1EntityLiving, float par2)
    059        {
    060            this.scaleSlime((EntitySlime)par1EntityLiving, par2);
    061        }
    062
    063        /**
    064         * Queries whether should render the specified pass or not.
    065         */
    066        protected int shouldRenderPass(EntityLiving par1EntityLiving, int par2, float par3)
    067        {
    068            return this.shouldSlimeRenderPass((EntitySlime)par1EntityLiving, par2, par3);
    069        }
    070    }