com.hamcybo.sa.render.Render_Hare.java Source code

Java tutorial

Introduction

Here is the source code for com.hamcybo.sa.render.Render_Hare.java

Source

    package com.hamcybo.sa.render;

    import org.lwjgl.opengl.GL11;

    import TFC.API.Entities.IAnimal;

    import com.hamcybo.sa.entites.mobs.Entity_Hare;
    import com.hamcybo.sa.lib.Reference;

    import net.minecraft.client.model.ModelBase;
    import net.minecraft.client.renderer.entity.RenderLiving;
    import net.minecraft.entity.Entity;
    import net.minecraft.entity.EntityLiving;
    import net.minecraft.entity.EntityLivingBase;
    import net.minecraft.util.ResourceLocation;

    /**
     * Second Age
     * 
     * SA
     * 
     * @author Hamcybo
     * @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
     * 
     */

    public class Render_Hare extends RenderLiving;
{
        private static final ResourceLocation MaleHare = ResourceLocation(Reference.MOD_ID, "mob/MaleHare.png");
        //private static final ResourceLocation FemaleHare = ResourceLocation(Reference.MOD_ID, "mob/FemaleHare.png");
        private float scale = 1.0f;
        private com.hamcybo.sa.render.models.Model_Hare Model_Hare;

        public Render_Hare(ModelBase par1ModelBase, float par2) {
            super(par1ModelBase, par2);
            Model_Hare = (Model_Hare) par1ModelBase;
        }

        public Render_Hare(Entity_Hare par1Entity_Hare, double par2, double par4, double par6, float par8, float par9) {
            super.doRenderLiving(par1Entity_Hare, par2, par4, par6, par8, par9);
            scale = par1Entity_Hare.size_mod;
        }

        protected void func_25006_b(Entity_Hare entity_Hare, float f) {
        }

        /**
         * Allows the render to do any OpenGL state modifications necessary before the model is rendered. Args:
         * entityLiving, partialTickTime
         */
        @Override
        protected void preRenderCallback(EntityLivingBase par1EntityLiving, float par2) {
            preRenderScale((Entity_Hare) par1EntityLiving, par2);
            func_25006_b((Entity_Hare) par1EntityLiving, par2);
        }

        protected void preRenderScale(Entity_Hare par1Entity_Hare, float par2) {
            GL11.glScalef(par1Entity_Hare.size_mod - 0.3f, par1Entity_Hare.size_mod - 0.3f,
                    par1Entity_Hare.size_mod - 0.3f);
        }

        /**
         * Defines what float the third param in setRotationAngles of ModelBase is
         */
        @Override
        protected float handleRotationFloat(EntityLivingBase par1EntityLiving, float par2) {
            return 1.0f;
        }

        @Override
        public void doRenderLiving(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8,
                float par9) {
            Render_Hare((Entity_Hare) par1EntityLiving, par2, par4, par6, par8, par9);
        }

        /**
         * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
         * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
         * (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1,
         * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
         */
        @Override
        public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) {
            Render_Hare((Entity_Hare) par1Entity, par2, par4, par6, par8, par9);
        }

        protected ResourceLocation getTexture(IAnimal entity) {
            if (!entity.isAdult()) {
                //return MaleHareTexture;
            } else {
                //return FemaleHareTexture;
            }
        }

        @Override
        protected ResourceLocation getEntityTexture(Entity entity) {
            // TODO Auto-generated method stub
            return getTexture((IAnimal) entity);
        }
    }