Jump to content

Recommended Posts

Posted

I recently started working on a new mod, and right now I'm stuck with trying to get an entity to register. I've watched and read some tutorials to try and help me through, but I haven't been able to fully figure out how to get my entity in game, especially with a lack of 1.8.9 tutorials on mobs. As I've said, I've used tutorials from different people, so I apologize if my coding looks jumbled up and mismatched. Any help with this would be greatly appreciated

 

EntityImp.java

 

  Reveal hidden contents

 

 

ModelImp.java

 

  Reveal hidden contents

 

 

RenderImp.java

 

  Reveal hidden contents

 

 

ClientProxy.java

 

  Reveal hidden contents

 

 

DaemonologyMod.java (My main mod file)

 

  Reveal hidden contents

 

"War doesn't determine who is right. Only who is left." -Bertrand Russell

Posted

Pretty sure EntityRegistry#registerModEntity still requires an instance of your mod, even in 1.8.9:

int entity_id = 0;
int tracking_range = 80; // used by most mobs and animals; most projectiles use 64
int update_frequency = 3; // used by most mobs and animals; most projectiles use 10, except arrows
EntityRegistry.registerModEntity(YourEntity.class, "registry_name", entity_id++, YourMod.instance, tracking_range, update_frequency, true, egg_color_1, egg_color_2);

Take a look at the vanilla EntityList class for the tracking range and update frequencies used for vanilla entities - that will help you decide what to use for each of your particular entities.

Posted
  On 3/28/2016 at 2:11 PM, coolAlias said:

Pretty sure EntityRegistry#registerModEntity still requires an instance of your mod, even in 1.8.9:

int entity_id = 0;
int tracking_range = 80; // used by most mobs and animals; most projectiles use 64
int update_frequency = 3; // used by most mobs and animals; most projectiles use 10, except arrows
EntityRegistry.registerModEntity(YourEntity.class, "registry_name", entity_id++, YourMod.instance, tracking_range, update_frequency, true, egg_color_1, egg_color_2);

Take a look at the vanilla EntityList class for the tracking range and update frequencies used for vanilla entities - that will help you decide what to use for each of your particular entities.

 

I do have that under my DaemonologyMod.java file.

EntityRegistry.registerModEntity(EntityImp.class, "Imp", 1, 1, 80, 3, true, 0, 0);

 

Leaving my code the way it is, when I run the client, it crashes. I looked in the console and the only code that it mentioned form my mod was this exact line.

 

EDIT: I looked at the code again and then another video and saw that I was missing the instance. I hadn't seen it in use before so I didn't know that I needed it. Thank you very  much. I ran the client and my entity showed up. Except for the fact that it's now a white box. Do you have any idea what I did wrong this time?

"War doesn't determine who is right. Only who is left." -Bertrand Russell

Posted

You're passing the

Integer

1 as the

mod

argument of

EntityRegistry.registerModEntity

. This compiles because every reference type extends

Object

and every primitive type can be boxed to a reference type. This fails at runtime because 1 isn't a

String

mod ID or an instance of a mod class, it's just an integer.

 

When asking for help with a crash, always post the FML log or crash report.

 

In future, please use Gist or Pastebin to post logs/crash reports (if applicable) and code with syntax highlighting. To get syntax highlighting on Gist, give each file the appropriate extension (.java for Java code). To get syntax highlighting on Pastebin, select the language from the dropdown at the bottom of the page.

 

It's much easier to read code with proper formatting and syntax highlighting.

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 3/28/2016 at 2:41 PM, Choonster said:

You're passing the

Integer

1 as the

mod

argument of

EntityRegistry.registerModEntity

. This compiles because every reference type extends

Object

and every primitive type can be boxed to a reference type. This fails at runtime because 1 isn't a

String

mod ID or an instance of a mod class, it's just an integer.

 

When asking for help with a crash, always post the FML log or crash report.

 

In future, please use Gist or Pastebin to post logs/crash reports (if applicable) and code with syntax highlighting. To get syntax highlighting on Gist, give each file the appropriate extension (.java for Java code). To get syntax highlighting on Pastebin, select the language from the dropdown at the bottom of the page.

 

It's much easier to read code with proper formatting and syntax highlighting.

 

Okay, I will do that in the future. I ended up fixing that piece of code, and my entity registers in game now. But when I see it in game, it's just a white box. Do you have any idea what I did wrong to make this happen?

 

"War doesn't determine who is right. Only who is left." -Bertrand Russell

Posted

It looks like you're never calling the

ClientProxy#preInit

method. Add a method with the same signature (name + arguments) to

CommonProxy

, add the

@Override

annotation to the

ClientProxy

method and then call this method from

DaemonologyMod#preInit

.

 

The overload of

RenderingRegistry.registerEntityRenderingHandler

you're using is deprecated and will be removed at some point in the future. Use the overload with an

IRenderFactory

argument instead.

 

To implement

IRenderFactory

, either use an anonymous class (if you're targeting Java 6/7) or a constructor method reference (if you're targeting Java 8).

 

As the documentation of this method says, it should be called in the preInit phase.

 

Edit: The


smiley is really annoying when talking about Java 8 or Minecraft 1.8.

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 did end up getting it. Now I'm just finishing up on the rotation angles as a couple body parts weren't rotated how I want them.

"War doesn't determine who is right. Only who is left." -Bertrand Russell

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.