Jump to content

[1.12.2] Custom minecart entity loads up properly but doesn't replace default minecart model


nocot

Recommended Posts

Hi,

I've finally got to work my custom minecart entity called EntityTramc which extends EntityMinecart and for testing purposes, it has ride ability turned off and does nothing besides that. And it got to work. To replace a model of minecart into a testing box (which will become a tram soon), I created a class called RenderTramc:

 

@SideOnly(Side.CLIENT)
public class RenderTramc extends RenderMinecart<EntityTramc>
{
    public RenderTramc(RenderManager renderManagerIn)
    {
        super(renderManagerIn);
        this.modelMinecart = new ModelTramc();
        System.out.println("RenderTramc loaded");
    }
  ...

and ModelTramc() is a function in a ModelTramc.class which is auto-generated model class (made by some model creator).

 

To register RenderTramc I created a render handler:

public class RenderHandler {
	public static void registerEntityRenders()
	{
		RenderingRegistry.registerEntityRenderingHandler(EntityTramc.class, new IRenderFactory<EntityTramc>()
		{
			@Override
			public Render<? super EntityTramc> createRenderFor(RenderManager manager)
			{
				return new RenderTramc(manager);
		});
	}
}

and called it in a registry handler by subscribe event:

@SubscribeEvent
	public static void onItemRegister(RegistryEvent.Register<Item> event)
	{
		event.getRegistry().registerAll(ModItems.ITEMS.toArray(new Item[0]));
		event.getRegistry().registerAll(ModItems.ITEMS.toArray(new Item[1]));
		RenderHandler.registerEntityRenders();
	}
...

I know it's very ugly to call it in that way but I just want to get it work, optimization will come next.

A RenderTramc() function is being called at the very beginning of the game (I got the System.out message) but it doesn't change a minecart model at all. I know I've messed up with something but I don't really see where is it. So, any help will be appreciated.

Link to comment
Share on other sites

30 minutes ago, nocot said:

Hi,

I've finally got to work my custom minecart entity called EntityTramc which extends EntityMinecart and for testing purposes, it has ride ability turned off and does nothing besides that. And it got to work. To replace a model of minecart into a testing box (which will become a tram soon), I created a class called RenderTramc:

 


@SideOnly(Side.CLIENT)
public class RenderTramc extends RenderMinecart<EntityTramc>
{
    public RenderTramc(RenderManager renderManagerIn)
    {
        super(renderManagerIn);
        this.modelMinecart = new ModelTramc();
        System.out.println("RenderTramc loaded");
    }
  ...

and ModelTramc() is a function in a ModelTramc.class which is auto-generated model class (made by some model creator).

 

To register RenderTramc I created a render handler:


public class RenderHandler {
	public static void registerEntityRenders()
	{
		RenderingRegistry.registerEntityRenderingHandler(EntityTramc.class, new IRenderFactory<EntityTramc>()
		{
			@Override
			public Render<? super EntityTramc> createRenderFor(RenderManager manager)
			{
				return new RenderTramc(manager);
		});
	}
}

and called it in a registry handler by subscribe event:


@SubscribeEvent
	public static void onItemRegister(RegistryEvent.Register<Item> event)
	{
		event.getRegistry().registerAll(ModItems.ITEMS.toArray(new Item[0]));
		event.getRegistry().registerAll(ModItems.ITEMS.toArray(new Item[1]));
		RenderHandler.registerEntityRenders();
	}
...

I know it's very ugly to call it in that way but I just want to get it work, optimization will come next.

A RenderTramc() function is being called at the very beginning of the game (I got the System.out message) but it doesn't change a minecart model at all. I know I've messed up with something but I don't really see where is it. So, any help will be appreciated.

Your rendering registry code should probably be in the client side modelLoad event. Also can you show it?

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

Hello again; so I'm back into Minecraft modding. I analyzed my code a bit and it seems like an overriding function for rendering function is never being called. And why I think it is so - it's because when I create my own minecart entity, it spawns a regular modelled minecart, without null pointer exception or any graphical issues - and a default minecart model in my entity is never replaced by my mod (I don't mean replace original minecart model, but my modded entity model - default is minecart).

 

So, am I thinking right? Also, I tried to register entity renders in model loader with no luck:

@SubscribeEvent
	public static void modelRegister(ModelLoader event)
	{
		if(Minecraft.getMinecraft().world.isRemote)
		{
			RenderHandler.registerEntityRenders();
		}
	}
...

But I think that it just couldn't work. Can anyone help?

Edited by nocot
Link to comment
Share on other sites

20 minutes ago, nocot said:

RenderHandler.registerEntityRenders();

Cool! What's this do?

 

Also:

Quote

ModelLoader event

Seriously?

1) You don't use it

2) Where did you get it

3) Any method you might want is static

Edited by Draco18s

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

As I wrote in my first post, this is my RenderHandler class:

public class RenderHandler {
	public static void registerEntityRenders()
	{
		RenderingRegistry.registerEntityRenderingHandler(EntityTramc.class, new IRenderFactory<EntityTramc>()
		{
			@Override
			public Render<? super EntityTramc> createRenderFor(RenderManager manager)
			{
				return new RenderTramc(manager);
		});
	}
}

And RenderTramc() :

@SideOnly(Side.CLIENT)
public class RenderTramc extends RenderMinecart<EntityTramc>
{
    public RenderTramc(RenderManager renderManagerIn)
    {
        super(renderManagerIn);
        this.modelMinecart = new ModelTramc();
        System.out.println("RenderTramc loaded");
    }
  ...

I know I messed up with something but I still don't get the point. Entities are still quite puzzling to me.

 

EDIT:

Note that RenderTramc class is not fully pasted but it's (I think) not needed for help purposes.

Edited by nocot
Link to comment
Share on other sites

1 hour ago, nocot said:

As I wrote in my first post, this is my RenderHandler class:


public class RenderHandler {
	public static void registerEntityRenders()
	{
		RenderingRegistry.registerEntityRenderingHandler(EntityTramc.class, new IRenderFactory<EntityTramc>()
		{
			@Override
			public Render<? super EntityTramc> createRenderFor(RenderManager manager)
			{
				return new RenderTramc(manager);
		});
	}
}

And RenderTramc() :


@SideOnly(Side.CLIENT)
public class RenderTramc extends RenderMinecart<EntityTramc>
{
    public RenderTramc(RenderManager renderManagerIn)
    {
        super(renderManagerIn);
        this.modelMinecart = new ModelTramc();
        System.out.println("RenderTramc loaded");
    }
  ...

I know I messed up with something but I still don't get the point. Entities are still quite puzzling to me.

 

EDIT:

Note that RenderTramc class is not fully pasted but it's (I think) not needed for help purposes.

Give us a GitHub

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

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.