Jump to content

[SOLVED] About ModelBakeEvent, ISmartItemModel and loading JSON models


Recommended Posts

Posted

Hello.

 

My goal is to merge 2 models together using the ModelBakeEvent and ISmartItemModel. The first model is used by an item so it has been registered @ItemModelMesher. The second one however, is not being used by any item (and not registered ofc). I figured out that the code works if I use 2 models that have been registered and are used by an item. So I guess I have to load those unused models as well, however, after deep google'ing I still have no idea how to do it.

Yes, I checked if all strings and file names are correct.

 

Code (might be little bit dirty, since Im still trying to get used to this new system):

 

ModelGun (ISmartItemModel)

 

  Reveal hidden contents

 

 

ModelBakeHandler (ModelBakeEvent)

 

  Reveal hidden contents

 

 

 

Note: I know Im still using the deprecated IBakedModel. Will change that in future ofc. 2 pages that helped me a lot:

https://github.com/TheGreyGhost/MinecraftByExample/tree/master/src/main/java/minecraftbyexample/mbe15_item_smartitemmodel (amazing)

http://www.minecraftforge.net/forum/index.php/topic,32309.0/nowap.html (helped me understanding the basics)

 

thanks

Posted

You may not need to bake them at all if you just want to do combine that model / texture with another one that is already baked:

// in your ISmartItemModel
IBakedModel model = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getModelManager().getModel(new ModelResourceLocation("yourmodid:name_of_the_model_you_want", "inventory"));

// now you can add the model's quads to the current smart item model, e.g.:
this.quads.addAll(model.getGeneralQuads());

I use something similar to combine the front and back of my shield models and only the front one is registered and baked.

 

Actually, that reminds me: I DID add those additional names as variants of my item, even though they are not themselves real items (they don't exist anywhere and can't be had by any means).

 

For one or all of your Attachment item classes, try adding the extra names as variants:

ModelBakery.addVariantName(YourAttachmentItem, real_attachment_name, gun_name_plus_attachment_name_1, etc.);

 

Also, instanceof checks for null, so the following are functionally equivalent:

if (object != null && object instanceof Something)
if (object instanceof Something)

Posted
  On 12/2/2015 at 6:23 AM, coolAlias said:

You may not need to bake them at all if you just want to do combine that model / texture with another one that is already baked:

// in your ISmartItemModel
IBakedModel model = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getModelManager().getModel(new ModelResourceLocation("yourmodid:name_of_the_model_you_want", "inventory"));

// now you can add the model's quads to the current smart item model, e.g.:
this.quads.addAll(model.getGeneralQuads());

I use something similar to combine the front and back of my shield models and only the front one is registered and baked.

 

Actually, that reminds me: I DID add those additional names as variants of my item, even though they are not themselves real items (they don't exist anywhere and can't be had by any means).

 

For one or all of your Attachment item classes, try adding the extra names as variants:

ModelBakery.addVariantName(YourAttachmentItem, real_attachment_name, gun_name_plus_attachment_name_1, etc.);

 

Also, instanceof checks for null, so the following are functionally equivalent:

if (object != null && object instanceof Something)
if (object instanceof Something)

 

Thank you very much. Its working now.

 

For those who want to know: I run the following code right after registering all items to the item model mesher.

 

 

  Reveal hidden contents

 

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.