Jump to content

Can't render EntityThrowable


Romejanic

Recommended Posts

Hey there!

 

I am updating one of my 1.5.2 mods to 1.6.4. I ran ion problems so I re-wrote the entire mod. But I have a little problem...

 

I am adding a projectile entity which extends EntityThrowable. I copied the old 1.5 code because it worked. What it does is render the chicken model because that is what I want it to render. But in the game, it does nothing. I even tried to make it render with RenderSnowball but even that does not work. Here's the render class:

 

package assets.exchicken.client.renderer;

import org.lwjgl.opengl.GL11;

import assets.exchicken.common.entity.EntityChickenFired;
import assets.exchicken.common.entity.EntityExplosiveChicken;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelChicken;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.passive.EntityChicken;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Vec3;

@SideOnly(Side.CLIENT)
public class RenderFiredChicken extends Render
{
protected ModelBase modelChicken;

    public RenderFiredChicken()
    {
        super();
        this.modelChicken = new ModelChicken();
    }

    public void renderChicken(EntityChickenFired par1EntityChicken, double par2, double par4, double par6, float par8, float par9)
    {
    	GL11.glPushMatrix();
        long i = (long)par1EntityChicken.entityId * 493286711L;
        i = i * i * 4392167121L + i * 98761L;
        float f2 = (((float)(i >> 16 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F;
        float f3 = (((float)(i >> 20 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F;
        float f4 = (((float)(i >> 24 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F;
        GL11.glTranslatef(f2, f3, f4);
        double d3 = par1EntityChicken.lastTickPosX + (par1EntityChicken.posX - par1EntityChicken.lastTickPosX) * (double)par9;
        double d4 = par1EntityChicken.lastTickPosY + (par1EntityChicken.posY - par1EntityChicken.lastTickPosY) * (double)par9;
        double d5 = par1EntityChicken.lastTickPosZ + (par1EntityChicken.posZ - par1EntityChicken.lastTickPosZ) * (double)par9;
        double d6 = 0.30000001192092896D;
        float f5 = par1EntityChicken.prevRotationPitch + (par1EntityChicken.rotationPitch - par1EntityChicken.prevRotationPitch) * par9;

        GL11.glTranslatef((float)par2, (float)par4, (float)par6);
        GL11.glRotatef(180.0F - par8, 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(-f5, 0.0F, 0.0F, 1.0F);

        GL11.glScalef(-1.0F, -1.0F, 1.0F);
        this.modelChicken.render(par1EntityChicken, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
        GL11.glPopMatrix();
    }

    protected float getWingRotation(EntityExplosiveChicken par1EntityChicken, float par2)
    {
        float f1 = par1EntityChicken.field_70888_h + (par1EntityChicken.field_70886_e - par1EntityChicken.field_70888_h) * par2;
        float f2 = par1EntityChicken.field_70884_g + (par1EntityChicken.destPos - par1EntityChicken.field_70884_g) * par2;
        return (MathHelper.sin(f1) + 1.0F) * f2;
    }

    /**
     * Defines what float the third param in setRotationAngles of ModelBase is
     */
    protected float handleRotationFloat(EntityLiving par1EntityLiving, float par2)
    {
        return this.getWingRotation((EntityExplosiveChicken)par1EntityLiving, par2);
    }

    public void doRenderLiving(Entity par1EntityLiving, double par2, double par4, double par6, float par8, float par9)
    {
        this.renderChicken((EntityChickenFired)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.
     */
    public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
    {
        this.renderChicken((EntityChickenFired)par1Entity, par2, par4, par6, par8, par9);
    }

@Override
protected ResourceLocation getEntityTexture(Entity entity) {

	return new ResourceLocation("textures/entity/chicken.png");

}

}

 

And here's my ClientProxy:

 

package assets.exchicken.client.core;

import net.minecraft.client.model.ModelChicken;
import net.minecraft.client.renderer.entity.RenderSnowball;
import net.minecraft.item.Item;
import cpw.mods.fml.client.registry.RenderingRegistry;
import assets.exchicken.client.renderer.RenderChickenMob;
import assets.exchicken.client.renderer.RenderFiredChicken;
import assets.exchicken.common.core.CommonProxy;
import assets.exchicken.common.entity.EntityChickenFired;
import assets.exchicken.common.entity.EntityExplosiveChicken;

public class ClientProxy extends CommonProxy {

@Override
public void registerRenderers() {

	RenderingRegistry.registerEntityRenderingHandler(EntityExplosiveChicken.class, new RenderChickenMob(new ModelChicken(), 0.0f));
	RenderingRegistry.registerEntityRenderingHandler(EntityChickenFired.class, new RenderFiredChicken());

}

}

 

Any ideas? Any help would be much appreciated!

 

Thanks,

Romejanic

Romejanic

 

Creator of Witch Hats, Explosive Chickens and Battlefield!

Link to comment
Share on other sites

Hi

 

Do you know if your renderer is being called at all?  (your .doRender)

 

If not, I'd suggest you go to RenderGlobal.renderEntities, modify this small section of code and put a breakpoint in it.  Then trace into renderEntity and see why your renderer isn't being called.

If the breakpoint never triggers even when you're looking at your entity, then maybe your entity isn't being spawned at all.

 

                if (flag && (entity != this.mc.renderViewEntity || this.mc.gameSettings.thirdPersonView != 0 || this.mc.renderViewEntity.isPlayerSleeping()) && this.theWorld.blockExists(MathHelper.floor_double(entity.posX), 0, MathHelper.floor_double(entity.posZ)))
                {
                    ++this.countEntitiesRendered;
if (entity instanceof EntityChickenFired) {
  int dummy = 1;  // put breakpoint here
}
                    RenderManager.instance.renderEntity(entity, par3);
                }

 

-TGG

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.