Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

Posted

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.

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)

  • Author

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

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.

  • Author

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

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)

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.