Jump to content

[1.10] Item texture questions


Melonslise

Recommended Posts

1. How do I overlay text and a texture over an item texture every second? I'm trying to make a cooldown type of overlay over my item.

2. Can I add variation (different textures) to my item's texture every time it's created? How do I combine multiple textures into one model?

Edited by Melonslise
Link to comment
Share on other sites

To overlay things on your model, you'll need to create your own IModel/IBakedModel/ICustomModelLoader implementations. Forge has several examples of these. The SimpleModelFontRenderer class added to Forge in 1.11.2 allows you to render text on models.

 

If there are a fixed number of variations, you can register them all with ModelBakery.registerItemVariants and then register an ItemMeshDefinition that selects the model based on some aspect of the ItemStack (e.g. metadata, NBT, capabilities). If the variants are dynamically-generated, you'll need your own model implementation.

 

I can't really help you with the specifics of your model implementation, you'll need to look for examples in Forge or open-source mods.

  • Like 2

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.

Link to comment
Share on other sites

4 hours ago, Choonster said:

To overlay things on your model, you'll need to create your own IModel/IBakedModel/ICustomModelLoader implementations. Forge has several examples of these. The SimpleModelFontRenderer class added to Forge in 1.11.2 allows you to render text on models.

 

If there are a fixed number of variations, you can register them all with ModelBakery.registerItemVariants and then register an ItemMeshDefinition that selects the model based on some aspect of the ItemStack (e.g. metadata, NBT, capabilities). If the variants are dynamically-generated, you'll need your own model implementation.

 

I can't really help you with the specifics of your model implementation, you'll need to look for examples in Forge or open-source mods.

Thanks for the answer!

What's the difference between IModel / IBakedModel / ICustomModelLoader? Are there any examples of these in forge?

Link to comment
Share on other sites

1 minute ago, Melonslise said:

What's the difference between IModel / IBakedModel / ICustomModelLoader? Are there any examples of these in forge?

 

IModel is the model in its raw form, which can be baked into an IBakedModel. IBakedModel is the model in a form optimised for being uploaded to the GPU.

 

ICustomModelLoader is responsible for loading the IModel.

  • Like 2

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.

Link to comment
Share on other sites

21 hours ago, Choonster said:

 

IModel is the model in its raw form, which can be baked into an IBakedModel. IBakedModel is the model in a form optimised for being uploaded to the GPU.

 

ICustomModelLoader is responsible for loading the IModel.

What about MeshDefinition? I've found some mods that use MeshDefinition to apply different textures to items.

Link to comment
Share on other sites

1 minute ago, Melonslise said:

What about MeshDefinition? I've found some mods that use MeshDefinition to apply different textures to items.

 

ItemMeshDefinition is used to select a ModelResourceLocation based on any aspect of the ItemStack.

  • Like 1

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.

Link to comment
Share on other sites

34 minutes ago, Melonslise said:

Oh, I see. So the model cannot be changed real-time if I use ItemMeshDefinition.

 

ItemMeshDefinition#getModelLocation is called every time the Item's model is rendered, but the ModelResourceLocations returned by it must be registered with ModelBakery.registerItemVariants at startup; so it can't load new models on-demand.

  • Like 1

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.

Link to comment
Share on other sites

On 8/1/2017 at 9:44 AM, Choonster said:

To overlay things on your model, you'll need to create your own IModel/IBakedModel/ICustomModelLoader implementations. Forge has several examples of these. The SimpleModelFontRenderer class added to Forge in 1.11.2 allows you to render text on models.

 

If there are a fixed number of variations, you can register them all with ModelBakery.registerItemVariants and then register an ItemMeshDefinition that selects the model based on some aspect of the ItemStack (e.g. metadata, NBT, capabilities). If the variants are dynamically-generated, you'll need your own model implementation.

 

I can't really help you with the specifics of your model implementation, you'll need to look for examples in Forge or open-source mods.

Alright, what if I want to combine multiple textures into one and use it as a variant? Do I use ItemMeshDefinition? If so, then how?

Link to comment
Share on other sites

19 minutes ago, Melonslise said:

Alright, what if I want to combine multiple textures into one and use it as a variant? Do I use ItemMeshDefinition? If so, then how?

 

An ItemMeshDefinition simply selects a model for an ItemStack, it doesn't combine or generate models itself. This needs to be done by the model.

 

Look at ModelDynBucket or ItemLayerModel to see how they combine multiple textures into a model. I can't really help you with specifics, I can only point you to examples.

  • Like 2

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.

Link to comment
Share on other sites

8 hours ago, Choonster said:

 

An ItemMeshDefinition simply selects a model for an ItemStack, it doesn't combine or generate models itself. This needs to be done by the model.

 

Look at ModelDynBucket or ItemLayerModel to see how they combine multiple textures into a model. I can't really help you with specifics, I can only point you to examples.

Alright, thanks. Do you know what happened to IItemRenderer and if there's any replacement for it?

Link to comment
Share on other sites

What would be the best way to create a layered model? Can I just instantiate ItemLayerModel with a list of all the textures I'd like to combine or is that not how it works?

If it does work then how do I assign the instance to an item from an ItemMeshDefinition? Looks like it only returns ModelResourceLocations and not models.

I'm sorry if these questions are quite simple, but I'm really struggling to understand how the whole model system in Minecraft works.

Edited by Melonslise
Link to comment
Share on other sites

Alright, so how does the ICustomModelLoader detect if the model (json?) is able to be loaded? What happens if there are no ICustomModelLoaders that can load the model? I thought blockstates were related to blocks only. How do I create a single blockstate json for all my texture combinations?

I actually want to use the vanilla ItemLayerModel class for my model, it already has an ICustomModelLoader implementation.

Edited by Melonslise
Link to comment
Share on other sites

How do I see what data the ItemLayerModel supports? As in what type it takes in the constructor? How do I customize the blockstate json? From what I've seen the blockstate json only supports blockstate properties.

Edited by Melonslise
Link to comment
Share on other sites

I have read the documentation, but it clearly stated that 

Quote

Blockstate JSONs tell the game which model it should use depending on the values of the block’s blockstate properties.

And the forge json page said nothing about blockstate properties or items at all.

 

 

Alright, it seems easy enough, but I still don't understand how I can layer certain textures out of a pool depending on an item's nbt? I was guessing I need to use ItemMeshDefinition above, but I'm not sure how to select certain layers out of a single json model.

Edited by Melonslise
Link to comment
Share on other sites

What I'm trying to do is combine a random base texture out of different variants of the base texture with a certain overlay texture depending on the item's nbt.

I don't think I'll have too many models, but I wanted to create an easier system for implementing new variants so that I didn't have to create ((number of base textures) * (new overlay texture)) every time I added a new overlay texture.

Link to comment
Share on other sites

5 minutes ago, diesieben07 said:

It sounds like you will need a runtime model to combine them then.

So how do I do that? Do I need to make my own implementations of IModel, IBakedModel and ICustomModelLoader like Choonster said? Even if I did, how would I go about selecting certain textures out of a pool?

Link to comment
Share on other sites

4 minutes ago, diesieben07 said:

You probably will only need ICustomModelLoader and IModel, when baking the model you can delegate to ItemLayerModel to do the heavy lifting.

As for how to select textures you can encode which textures to use in the resource location and then extract that information in the model loader. Keep in mind that you will still need to register all possible combinations at startup using ModelBakery.registerItemVariants to be able to use them from ItemMeshDefinition.

Wow that still seems awfully complicated and tedious, even more so than creating a separate json for every item. I might just stick to creating separate jsons.

Link to comment
Share on other sites

2 hours ago, diesieben07 said:

You probably will only need ICustomModelLoader and IModel, when baking the model you can delegate to ItemLayerModel to do the heavy lifting.

As for how to select textures you can encode which textures to use in the resource location and then extract that information in the model loader. Keep in mind that you will still need to register all possible combinations at startup using ModelBakery.registerItemVariants to be able to use them from ItemMeshDefinition.

Is there any way to change item models in-game?

EDIT: When a model is loaded by it's ICustomModelLoader class and then processed by it's IModel implementation, does the baked model stay during the session or are new baked models made in real-time?

EDIT: I'm asking because I thought I could make a base json model containing all my base textures and multiple overlay json models which extend the base json model. I thought I could assign one of the overlay json models to an item (since these are affected by item's nbt) and then have the IModel select a random base texture from the base json model (since the overlay json models extends it) and then apply the overlay on top of it. And I was wondering if the base texture of the model would change with every created item of that type or it would stay the same for all of them?

Edited by Melonslise
Link to comment
Share on other sites

For reference, here's an example of using ItemMeshDefinition:

 

https://github.com/Draco18s/ReasonableRealism/blob/master/src/main/java/com/draco18s/industry/item/ItemCastingMold.java#L80

 

The item selects between different "states" based on a template item: it gets that template item's name, strips off some unnessessary bits (it uses them elsewhere, so they're still saved), and then looks for an item model based on that name. Those different models then supply a different texture.

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.

Link to comment
Share on other sites

33 minutes ago, Draco18s said:

For reference, here's an example of using ItemMeshDefinition:

 

https://github.com/Draco18s/ReasonableRealism/blob/master/src/main/java/com/draco18s/industry/item/ItemCastingMold.java#L80

 

The item selects between different "states" based on a template item: it gets that template item's name, strips off some unnessessary bits (it uses them elsewhere, so they're still saved), and then looks for an item model based on that name. Those different models then supply a different texture.

Yeah, I already got that. It's just that I don't want to create a crap load of models for all my combinations.

Link to comment
Share on other sites

32 minutes ago, Melonslise said:

Yeah, I already got that. It's just that I don't want to create a crap load of models for all my combinations.

Sure, I get that. I haven't done anything with dynamic text, so I can't offer any insights.

 

For me and what I was trying to do, I actually wanted all of those models so that more could be supplied outside my own mod.  One of my companion mods does this:

https://github.com/Draco18s/ReasonableRealism/blob/master/src/main/resources/assets/harderfarming/models/item/mold_butcherknife.json

Different mod (albeit using the same base library), that has a model and texture for that item without needing to do anything other than supply the recipe for that particular combination.

 

The IRecipe is supplied by the library, but because it's just NBT data, it would be possible for another mod to create the item without using my library.

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.

Link to comment
Share on other sites

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.



×
×
  • Create New...

Important Information

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