Jump to content

[1.8] Metadata Block item render: Am I doing this correctly?


Recommended Posts

Trying to figure out the new texture/model system, and I have a metadata block with a different model for each metadata. Block rendering is working just fine, got the variants (one file) and block model definition json files (one for each metadata) set up. But I had some trouble getting the item models to work, since the item json can only use one block json as its parent. I fiddled around for a while and managed to get it working with this code:

Item itemBlock = Item.getItemFromBlock(blockMulti);
for(int i = 0; i<5; i++) {
    ModelBakery.addVariantName(itemBlock, Constants.MOD_ID + ":" + BlockMulti.NAME + i);
for(int i = 0; i<5; i++) {
    mesher.register(itemBlock, i, new ModelResourceLocation(Constants.MOD_ID + ":" + BlockMulti.NAME + i, "inventory"));

So basically adding variants of name modid:blockname<metadata value> and then registering each metadata with ModelResourceLocation's of the same name. So in my case I have blockMulti0.json-blockMulti5.json in my models/item folder, each using a respective block json as its parent. And this worked, but I'm not quite sure if this is the correct way. The log also shows that it still tries to search for a blockMulti.json file, even though I'm not registering that.

Link to comment
Share on other sites

Was thinking about why it still searches for an item json file with the same name as the block name, and thought maybe somewhere along the init process it was adding a default variant if no other variants were specified. So I tried moving the add variant for loop to preinit instead of init, and that seems to have stopped it looking for that json. Anything else odd or that could be done differently?

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.

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.