Jump to content

Recommended Posts

Posted

I'm trying to create a custom entity, known as an Oompah Loompah. I've created three classes:

 

RenderOompah (points to the texture, etc)

 

  Reveal hidden contents

 

EntityOompah (creates the entity, ai, etc)

 

  Reveal hidden contents

 

ModelOompah(creates the entity's model using a java model)

 

  Reveal hidden contents

 

How do I register and initialize the entity? It has changed since 1.8, and I can't get it to work.

Posted

Call

EntityRegistry#registerModEntity

in preInit to register your entity. Use the overload with the two additional

int

arguments to add a spawn egg for the entity.

 

Call

RenderingRegistry#registerEntityRenderingHandler(Class<T>, IRenderFactory<? super T>)

in preInit from your client proxy to register your entity's renderer. I suggest using an anonymous class (Java 6/7) or lambda/method reference (Java 8) to implement

IRenderFactory

.

 

Edit: Removed smiley.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

I tried this by adding these to my client proxy preInit, but no spawn egg or entity is registered. Did I do anything wrong, there aren't any errors in the code.

EntityRegistry.registerModEntity(EntityOompah.class, "oompah", 0, Main.instance, 80, 3, false, 6750105, 7859797);

	RenderingRegistry.registerEntityRenderingHandler(EntityOompah.class, new IRenderFactory<Entity>()
	{
		@Override
		public Render<? super Entity> createRenderFor(RenderManager manager)
		{
			return new RenderOompah(manager, null, 0);
		}
	});

Posted

Are you sure the method is actually being called? Set a breakpoint and run Minecraft in debug mode.

 

EntityRegistry.registerModEntity

needs to be called on both sides, so don't put it in your client proxy.

 

Passing

null

as the

ModelBase

argument of the

RenderOompah

constructor will almost certainly cause issues,

RenderLivingBase

doesn't expect the model to be

null

.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
  On 6/20/2016 at 8:01 PM, Choonster said:

Passing

null

as the

ModelBase

argument of the

RenderOompah

constructor will almost certainly cause issues,

RenderLivingBase

doesn't expect the model to be

null

.

 

What else could go in there besides null? My model is based off of modelbase, but using

return new RenderOompah(manager, ModelBase.class, 0);

returns "The constructor RenderOompah(RenderManager, Class<ModelBase>, int) is undefined"

Posted
  On 6/20/2016 at 8:49 PM, Bright_Steel said:

  Quote

Passing

null

as the

ModelBase

argument of the

RenderOompah

constructor will almost certainly cause issues,

RenderLivingBase

doesn't expect the model to be

null

.

 

What else could go in there besides null? My model is based off of modelbase, but using

return new RenderOompah(manager, ModelBase.class, 0);

returns "The constructor RenderOompah(RenderManager, Class<ModelBase>, int) is undefined"

 

Pass an instance of

ModelBase

or a class that extends it (like

ModelOompah

). Don't pass the class itself.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

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.