Jump to content

[1.19.2] Dynamic change of texture and model, item JSON


Recommended Posts

Posted (edited)

 

I would like to add a sight to the weapon, a silencer, as a layer (If possible) and change item texture.

As far as I understand, I need BakedModel. But it looks like I'm doing something wrong. ( I don't go to methods. )

  Reveal hidden contents

Maybe I still need ItemOverrides

But, my json looks different (Blockbench), I don't have "model". I have vertices and groups of them in JSON
 

  Reveal hidden contents

 

Edited by Luckydel
Posted
  On 10/29/2022 at 3:19 PM, Luckydel said:

As far as I understand, I need BakedModel. But it looks like I'm doing something wrong. ( I don't go to methods. )

  Reveal hidden contents
 
Expand  

The baked model is necessary as it represents the model, but it doesn't do anything if you don't register an associated ModelLoader to read the JSONs as that format. This process is not well documented and has recently gotten a massive overhaul, so the best thing to do is look at other model loaders already present and mimic them. Also, if everything is null, things will crash.

  On 10/29/2022 at 3:19 PM, Luckydel said:

Maybe I still need ItemOverrides

Expand  

Yes, they are for the context of an ItemStack, getQuads is typically in the context of the world (so, blocks).

  On 10/29/2022 at 3:19 PM, Luckydel said:

But, my json looks different (Blockbench), I don't have "model". I have vertices and groups of them in JSON

Expand  

You can have those, though whether they'll be read depends on if the vanilla model accepts them (don't think they do for some of the group fields).

Posted
  On 10/31/2022 at 12:48 PM, ChampionAsh5357 said:
 

The baked model is necessary as it represents the model, but it doesn't do anything if you don't register an associated ModelLoader to read the JSONs as that format. This process is not well documented and has recently gotten a massive overhaul, so the best thing to do is look at other model loaders already present and mimic them. Also, if everything is null, things will crash.

Yes, they are for the context of an ItemStack, getQuads is typically in the context of the world (so, blocks).

You can have those, though whether they'll be read depends on if the vanilla model accepts them (don't think they do for some of the group fields).

Expand  

Then, for regular json, do I need to use UnbakedModel? Something does not work.

Posted
  On 11/2/2022 at 6:20 PM, Luckydel said:

Then, for regular json, do I need to use UnbakedModel? Something does not work.

Expand  

That's not what I said? You can bake the models in using the normal procedure and just have your custom model loader consume the baked models and render them all at specific offsets. Once again, take a look at existing custom model loaders (the composite model loader comes to mind here).

Posted
  On 11/3/2022 at 12:56 PM, ChampionAsh5357 said:

That's not what I said? You can bake the models in using the normal procedure and just have your custom model loader consume the baked models and render them all at specific offsets. Once again, take a look at existing custom model loaders (the composite model loader comes to mind here).

Expand  

Thank you for your patience.
Okay, I've created a custom model loader, how do I tell the item to use it?

Posted (edited)

I am reluctant to get involved in this thread since I know virtually nothing about custom model loaders. 🙂

I just want to suggest you look at what ForgeClientMod ClientForgeMod does.

This is just another mod, the only thing special about it, is that it is preinstalled with forge.

e.g. it creates the composite loader mentioned above, along with others.

 

You might also want to look at: https://docs.minecraftforge.net/en/1.19.x/rendering/modelloaders/#custom-model-loaders

Edited by warjort

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Posted
  On 11/3/2022 at 8:24 PM, Luckydel said:

Okay, I've created a custom model loader, how do I tell the item to use it?

Expand  

You'll need to register it with `ModelEvent$RegisterGeometryLoaders` if you haven't already, which will register your loader with the name `modid:name`. Then you supply that within the main model of your item with the `loader` key.

Posted (edited)
  On 11/3/2022 at 10:53 PM, ChampionAsh5357 said:

You'll need to register it with `ModelEvent$RegisterGeometryLoaders` if you haven't already, which will register your loader with the name `modid:name`. Then you supply that within the main model of your item with the `loader` key.

Expand  

It looks like I misunderstood something

Custom model loader is CompositeModelBuilder or CompositeModel$Loader ?
EDIT:

Can you give more details about the `loader` key, or a link to the documentation

Edited by Luckydel
Posted
  On 11/4/2022 at 12:00 PM, Luckydel said:

Custom model loader is CompositeModelBuilder or CompositeModel$Loader ?

Expand  

`CompositeModel$Loader`, the builder is used to make the baked model from quads, which can be obtained from other baked models.

  On 11/4/2022 at 12:00 PM, Luckydel said:

Can you give more details about the `loader` key, or a link to the documentation

Expand  

It's just a key that points to the name you registered the loader under. There is currently no actual documentation on this yet.

{
  "loader": "modid:loader_name",
  // ... Rest of the model json
}
Posted
  On 11/4/2022 at 2:32 PM, ChampionAsh5357 said:

`CompositeModel$Loader`, the builder is used to make the baked model from quads, which can be obtained from other baked models.

It's just a key that points to the name you registered the loader under. There is currently no actual documentation on this yet.

{
  "loader": "modid:loader_name",
  // ... Rest of the model json
}
Expand  

I'm doing something wrong. Doesn't go to registration event.
 

  Reveal hidden contents

Model loader class, as a basis I used ElementsModel.

  Reveal hidden contents

 

 

I have another question, after I register it and set "loader". I will be able to interact with the model via IUnbakedGeometry#bake in item  class or am I misunderstanding something?

Posted

ModelEvent$RegisterGeometryLoaders is on the mod event bus as the event says on its javadocs.

Do not copy-paste the raw loader. The reason why I mentioned using the composite loader is because it does something similar to what you want but requires you to thing about what to implement.

  On 11/4/2022 at 6:11 PM, Luckydel said:

I have another question, after I register it and set "loader". I will be able to interact with the model via IUnbakedGeometry#bake in item  class or am I misunderstanding something?

Expand  

You read it into an unbaked geometry and then bake it into a model after everything has been loaded. You should not be able to access the geometry from the item class. If you want to provide overrides depending on the stack, you need to provide your own custom ItemOverrides to and specifying that for this stack use this model.

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.