Jump to content

[1.12.2] Second entity model not loading


jonesto95

Recommended Posts

I've recently successfully gotten a race car entity to load in my mod, and I'm trying to get a second entity (a trophy) to work as well. I figure the best way to get the that trophy model to work, is to copy the appropriate files from the racecar model and adjust the class names. The item used to spawn this object spawns in an entity (the hitbox loads), but the model does not show up. Here's all of the code I believe is relevant: 


ModEntities

Spoiler

public class ModEntities {	
	
	public static void registerEntities()
	{
		registerEntity("racecar", EntityRaceCar2.class, 120, 50);
		registerEntity("trophy", EntityTrophy.class, 121, 50);
	}
	
	
	private static void registerEntity(String name, Class<? extends Entity> entity, int id, int range)
	{
		ResourceLocation rl = new ResourceLocation(Reference.MODID + ":" + name);
		EntityRegistry.registerModEntity(rl, entity, name, id, RaceCarMod.instance, range, 1, true, 555, 555);
	}
	
}

 


RenderHandler

Spoiler

public class RenderHandler {

	public static void registerEntityRenders()
	{
		RenderingRegistry.registerEntityRenderingHandler(EntityRaceCar2.class, new IRenderFactory<EntityRaceCar2>()
		{
			@Override public Render<? super EntityRaceCar2> createRenderFor(RenderManager manager)
			{
				return new RenderRaceCar2(manager);
			}
		});
		
		
		RenderingRegistry.registerEntityRenderingHandler(EntityTrophy.class, new IRenderFactory<EntityTrophy>()
		{
			@Override public Render<? super EntityTrophy> createRenderFor(RenderManager manager)
			{
				return new RenderTrophy(manager);
			}
		});
	}
}

 


RenderTrophy class

Spoiler

package tnsoft.racecarmod.entity.render;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.item.EntityBoat;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.MathHelper;
import tnsoft.racecarmod.entity.EntityTrophy;
import tnsoft.racecarmod.entity.model.ModelTrophy;
import tnsoft.racecarmod.util.Reference;

public class RenderTrophy extends Render<EntityTrophy> {

	protected ModelBase modelTrophy;
	
	public RenderTrophy(RenderManager renderManager) {
		super(renderManager);
		modelTrophy = new ModelTrophy();
		// TODO Auto-generated constructor stub
	}

	@Override
	protected ResourceLocation getEntityTexture(EntityTrophy entity) {
		String path = ":textures/entity/trophy.png";
		return new ResourceLocation(Reference.MODID + path);
	}
	
	
	@Override
	public void doRender(EntityTrophy entity, double x, double y, double z, float entityYaw, float partialTicks)
    {
        GlStateManager.pushMatrix();
        this.setupTranslation(x, y, z);
        this.setupRotation(entity, entityYaw, partialTicks);
        this.bindEntityTexture(entity);

        if (this.renderOutlines)
        {
            GlStateManager.enableColorMaterial();
            GlStateManager.enableOutlineMode(this.getTeamColor(entity));
        }

        modelTrophy.render(entity, partialTicks, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);

        if (this.renderOutlines)
        {
            GlStateManager.disableOutlineMode();
            GlStateManager.disableColorMaterial();
        }

        GlStateManager.popMatrix();
        super.doRender(entity, x, y, z, entityYaw, partialTicks);
    }
	
	
	public void setupRotation(EntityTrophy p_188311_1_, float p_188311_2_, float p_188311_3_)
    {
        GlStateManager.rotate(180.0F - p_188311_2_, 0.0F, 1.0F, 0.0F);
        float f = (float)p_188311_1_.getTimeSinceHit() - p_188311_3_;
        float f1 = p_188311_1_.getDamageTaken() - p_188311_3_;

        if (f1 < 0.0F)
        {
            f1 = 0.0F;
        }

        if (f > 0.0F)
        {
            GlStateManager.rotate(MathHelper.sin(f) * f * f1 / 10.0F * (float)p_188311_1_.getForwardDirection(), 1.0F, 0.0F, 0.0F);
        }

        GlStateManager.scale(-1.0F, -1.0F, 1.0F);
    }

    public void setupTranslation(double p_188309_1_, double p_188309_3_, double p_188309_5_)
    {
        GlStateManager.translate((float)p_188309_1_, (float)p_188309_3_ + 0.375F, (float)p_188309_5_);
    }
}

 


I feel like the error is somewhere in the RenderHandler class, I feel like I should merge those two RenderingRegistry statements, but I'm not sure how to do so.

Edited by jonesto95
Link to comment
Share on other sites

This seems correct, you can try to use RenderRaceCar2 also for the trophy, if this works the error is inside the RenderProphy. You could then try to render the model from your car instead of the trohpy model, if this works without other changes then your model class is faulty.

catch(Exception e)

{

 

}

Yay, Pokémon exception handling, gotta catch 'em all (and then do nothing with 'em).

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.

Announcements



×
×
  • Create New...

Important Information

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