Jump to content

How to set up an item model .json file for a meta block?


winnetrie

Recommended Posts

I have created a block wich comes in 16 types (the 16 colors).

All is working fine, they have the right texture but the item does not.

 

this is the blockstate for BlockBricks.json:

{
    "variants": {
        "type=white": { "model":"tem:bricks_white" },
        "type=orange": { "model":"tem:bricks_orange" },
        "type=magenta": { "model":"tem:bricks_magenta" },
        "type=light_blue": { "model":"tem:bricks_light_blue" },
        "type=yellow": { "model":"tem:bricks_yellow" },
        "type=lime": { "model":"tem:bricks_lime" },
        "type=pink": { "model":"tem:bricks_pink" },
        "type=gray": { "model":"tem:bricks_gray" },
        "type=silver": { "model":"tem:bricks_silver" },
        "type=cyan": { "model":"tem:bricks_cyan" },
        "type=purple": { "model":"tem:bricks_purple" },
        "type=blue": { "model":"tem:bricks_blue" },
        "type=brown": { "model":"tem:bricks_brown" },
        "type=green": { "model":"tem:bricks_green" },
        "type=red": { "model":"tem:bricks_red" },
        "type=black": { "model":"tem:bricks_black" }
    }
}

 

this is 1 of the 16 block models (bricks_black.json):

{
    "parent":"block/cube_all",
    "textures": {
        "all": "tem:blocks/bricks_black"
    }
}

the other 15 looks the same, only other color name.

 

this is my item model for BlockBricks.json:

{
   "parent": "block/cube_all",
   "textures": {
      "all": "tem:blocks/bricks_black"
   }
}

ofc this only set the first of all 16 items.

So ingame i have 1 item with a texture and the other 15 not.

Since the item model json has to be the same name as the registryname, i have no clue

 

 

Link to comment
Share on other sites

Since the item model json has to be the same name as the registryname, i have no clue

 

This isn't the case. You can register any model for your items, the registry name is simply the default.

 

You need to call

ModelLoader.setCustomModelResourceLocation

for each metadata value of the

Item

. The

ModelResourceLocation

can either point to an item model or a variant of a blockstates file. I have an explanation of the model loading process and how

ModelResourceLocation

s are mapped to models here.

 

Consider using Forge's blockstates format, it eliminates the need to create a model file for every variant of your block.

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

oh yes i got it working now:

public static void registerRenders(){
	registerRender(cheese);

	registerMetaRender(bricks,0,"bricks_white");
	registerMetaRender(bricks,1,"bricks_orange");
	registerMetaRender(bricks,2,"bricks_magenta");
	registerMetaRender(bricks,3,"bricks_light_blue");

}
private static void registerMetaRender(Block block, int meta, String file){
	ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), meta, new ModelResourceLocation(References.MOD_ID + ":" + file,"inventory"));
	//Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(item.getRegistryName(),"inventory"));
}

I will check on the Forge blockstates format

Link to comment
Share on other sites

the forge blockstates format looks a bit diffecult to understand.

If i would use 1 model file how would i pass all the 16 types from my blockstate json to the model json?

That's something i don't understand.

Now for every type i have a model file. Can you help me explain this better.

I read the example on the page there, but i don't understand it

 

Edit:

I tried this

{
    "forge_marker": 1,
    "defaults": {
        "textures": {
            "texture": "tem:blocks/bricks_white",
        },
        "model": "block/cube_all",
        "uvlock": true
    },
    "variants": {
        "type": {
            "white":{
                "textures": {
                    "texture": "tem:blocks/bricks_white"
                }
            }
        }
        
    }
}

that doesn't work

 

Link to comment
Share on other sites

the forge blockstates format looks a bit diffecult to understand.

If i would use 1 model file how would i pass all the 16 types from my blockstate json to the model json?

That's something i don't understand.

Now for every type i have a model file. Can you help me explain this better.

I read the example on the page there, but i don't understand it

 

In the

defaults

section, you set the model to the base model, e.g.

minecraft:cube_all

. For each variant, you set the

all

texture to the appropriate texture for that variant.

 

I have a basic example here and a more complex example here.

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

i have this and it works :

 

 

{
    "forge_marker": 1,
    "defaults": {
        "model": "minecraft:cube_all"
    },
    "variants": {
        "type": {
            "white": {
                "textures": {
                    "all": "tem:blocks/bricks_white"
                }
            },
            "orange": {
                "textures": {
                    "all": "tem:blocks/bricks_orange"
                }
            },
            "magenta": {
                "textures": {
                    "all": "tem:blocks/bricks_magenta"
                }
            },
            "light_blue": {
                "textures": {
                    "all": "tem:blocks/bricks_light_blue"
                }
            },
            "yellow": {
                "textures": {
                    "all": "tem:blocks/bricks_yellow"
                }
            },
            "lime": {
                "textures": {
                    "all": "tem:blocks/bricks_lime"
                }
            },
            "pink": {
                "textures": {
                    "all": "tem:blocks/bricks_pink"
                }
            },
            "gray": {
                "textures": {
                    "all": "tem:blocks/bricks_gray"
                }
            },
            "silver": {
                "textures": {
                    "all": "tem:blocks/bricks_silver"
                }
            },
            "cyan": {
                "textures": {
                    "all": "tem:blocks/bricks_cyan"
                }
            },
            "purple": {
                "textures": {
                    "all": "tem:blocks/bricks_purple"
                }
            },
            "blue": {
                "textures": {
                    "all": "tem:blocks/bricks_blue"
                }
            },
            "brown": {
                "textures": {
                    "all": "tem:blocks/bricks_brown"
                }
            },
            "green": {
                "textures": {
                    "all": "tem:blocks/bricks_green"
                }
            },
            "red": {
                "textures": {
                    "all": "tem:blocks/bricks_red"
                }
            },
            "black": {
                "textures": {
                    "all": "tem:blocks/bricks_black"
                }
            }
        }
    }
}

 

 

Do i have to do the same for the item model?

Link to comment
Share on other sites

Do i have to do the same for the item model?

 

No, you can tell Minecraft to use the variants from your blockstates file as the models for your item. Use the name of the blockstates file as the domain and path of the

ModelResourceLocation

and the variant as the variant.

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

What do i need to change here?

the "inventory"?

 

private static void registerMetaRender(Block block, int meta){
	ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), meta, new ModelResourceLocation(block.getRegistryName(),"inventory"));

}

Link to comment
Share on other sites

I think you can replace it with "property=variant", but don't quote me on that.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

I think i still don't understand how this works.

 

I see an error in the console:

Caused by: java.io.FileNotFoundException: tem:models/item/BlockBricks.json

 

I'm confused now , i thought i didn't need to make a model for it.

 

Edit:

i have also this:

[12:40:17] [Client thread/ERROR] [FML]: Exception loading model for variant tem:blockstates/BlockBrick#variants for item "tem:BlockBricks", blockstate location exception:

Link to comment
Share on other sites

I think i still don't understand how this works.

 

I see an error in the console:

Caused by: java.io.FileNotFoundException: tem:models/item/BlockBricks.json

 

I'm confused now , i thought i didn't need to make a model for it.

 

Edit:

i have also this:

[12:40:17] [Client thread/ERROR] [FML]: Exception loading model for variant tem:blockstates/BlockBrick#variants for item "tem:BlockBricks", blockstate location exception:

 

Forge always tries to load the item model first and falls back to the blockstates file if that fails. If both fail, it logs both exceptions.

 

Your blockstates file doesn't have a variant called

variants

, so an exception is thrown when Forge tries to load the model for that variant.

 

The variants specified by your blockstates file are

type=white

,

type=orange

, etc.

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

Nice thank you very much. I have it working now:

public static void registerRenders(){
	registerRender(cheese);

	registerMetaRender(bricks,0,"type=white");
	registerMetaRender(bricks,1,"type=orange");
	registerMetaRender(bricks,2,"type=magenta");
	registerMetaRender(bricks,3,"type=light_blue");
	registerMetaRender(bricks,4,"type=yellow");
	registerMetaRender(bricks,5,"type=lime");
	registerMetaRender(bricks,6,"type=pink");
	registerMetaRender(bricks,7,"type=gray");
	registerMetaRender(bricks,8,"type=silver");
	registerMetaRender(bricks,9,"type=cyan");
	registerMetaRender(bricks,10,"type=purple");
	registerMetaRender(bricks,11,"type=blue");
	registerMetaRender(bricks,12,"type=brown");
	registerMetaRender(bricks,13,"type=green");
	registerMetaRender(bricks,14,"type=red");
	registerMetaRender(bricks,15,"type=black");


}
private static void registerMetaRender(Block block, int meta, String variant){
	ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), meta, new ModelResourceLocation(block.getRegistryName(),variant));

}

private static void registerRender(Block block){
	ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(),"inventory"));
	//Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(item.getRegistryName(),"inventory"));
}

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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I was just trying to play my modded world when i randomly got this crash for no reason. I sorted through like every mod and eventually I realized it was LLibrary but I can't seem to find a solution to fix the crashing. I can't lose the world that I have that uses this mod please help me. Here's the report: https://pastebin.com/0D00B79i If anyone has a solution please let me know.  
    • 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑   Daftar Slot Ligawin88 adalah bocoran slot rekomendasi gacor dari Ligawin88 yang bisa anda temukan di SLOT Ligawin88. Situs SLOT Ligawin88 hari ini yang kami bagikan di sini adalah yang terbaik dan bersiaplah untuk mengalami sensasi tak terlupakan dalam permainan slot online. Temukan game SLOT Ligawin88 terbaik dengan 100 pilihan provider ternama yang dipercaya akan memberikan kepuasan dan kemenangan hari ini untuk meraih x500. RTP SLOT Ligawin88 merupakan SLOT Ligawin88 hari ini yang telah menjadi pilihan utama bagi pemain judi online di seluruh Indonesia. Setiap harinya jutaan pemain memasuki dunia maya untuk memperoleh hiburan seru dan kemenangan besar dalam bermain slot dengan adanya bocoran RTP SLOT Ligawin88. Tidak ada yang lebih menyenangkan daripada mengungguli mesin slot dan meraih jackpot x500 yang menggiurkan di situs SLOT Ligawin88 hari ini yang telah disediakan SLOT Ligawin88. Menangkan jackpot besar x500 rajanya maxwin dari segala slot dan raih kemenangan spektakuler di situs Ligawin88 terbaik 2024 adalah tempat yang menyediakan mesin slot dengan peluang kemenangan lebih tinggi daripada situs slot lainnya. Bagi anda yang mencari pengalaman judi slot paling seru dan mendebarkan, situs bo SLOT Ligawin88 terbaik 2024 adalah pilihan yang tepat. Jelajahi dunia slot online melalui situs SLOT Ligawin88 di link SLOT Ligawin88.
    • 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑   Daftar Slot Asusslot adalah bocoran slot rekomendasi gacor dari Asusslot yang bisa anda temukan di SLOT Asusslot. Situs SLOT Asusslot hari ini yang kami bagikan di sini adalah yang terbaik dan bersiaplah untuk mengalami sensasi tak terlupakan dalam permainan slot online. Temukan game SLOT Asusslot terbaik dengan 100 pilihan provider ternama yang dipercaya akan memberikan kepuasan dan kemenangan hari ini untuk meraih x500. RTP SLOT Asusslot merupakan SLOT Asusslot hari ini yang telah menjadi pilihan utama bagi pemain judi online di seluruh Indonesia. Setiap harinya jutaan pemain memasuki dunia maya untuk memperoleh hiburan seru dan kemenangan besar dalam bermain slot dengan adanya bocoran RTP SLOT Asusslot. Tidak ada yang lebih menyenangkan daripada mengungguli mesin slot dan meraih jackpot x500 yang menggiurkan di situs SLOT Asusslot hari ini yang telah disediakan SLOT Asusslot. Menangkan jackpot besar x500 rajanya maxwin dari segala slot dan raih kemenangan spektakuler di situs Asusslot terbaik 2024 adalah tempat yang menyediakan mesin slot dengan peluang kemenangan lebih tinggi daripada situs slot lainnya. Bagi anda yang mencari pengalaman judi slot paling seru dan mendebarkan, situs bo SLOT Asusslot terbaik 2024 adalah pilihan yang tepat. Jelajahi dunia slot online melalui situs SLOT Asusslot di link SLOT Asusslot.
    • 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 Daftar Slot Galeri555 adalah bocoran slot rekomendasi gacor dari Galeri555 yang bisa anda temukan di SLOT Galeri555. Situs SLOT Galeri555 hari ini yang kami bagikan di sini adalah yang terbaik dan bersiaplah untuk mengalami sensasi tak terlupakan dalam permainan slot online. Temukan game SLOT Galeri555 terbaik dengan 100 pilihan provider ternama yang dipercaya akan memberikan kepuasan dan kemenangan hari ini untuk meraih x500. RTP SLOT Galeri555 merupakan SLOT Galeri555 hari ini yang telah menjadi pilihan utama bagi pemain judi online di seluruh Indonesia. Setiap harinya jutaan pemain memasuki dunia maya untuk memperoleh hiburan seru dan kemenangan besar dalam bermain slot dengan adanya bocoran RTP SLOT Galeri555. Tidak ada yang lebih menyenangkan daripada mengungguli mesin slot dan meraih jackpot x500 yang menggiurkan di situs SLOT Galeri555 hari ini yang telah disediakan SLOT Galeri555. Menangkan jackpot besar x500 rajanya maxwin dari segala slot dan raih kemenangan spektakuler di situs Galeri555 terbaik 2024 adalah tempat yang menyediakan mesin slot dengan peluang kemenangan lebih tinggi daripada situs slot lainnya. Bagi anda yang mencari pengalaman judi slot paling seru dan mendebarkan, situs bo SLOT Galeri555 terbaik 2024 adalah pilihan yang tepat. Jelajahi dunia slot online melalui situs SLOT Galeri555 di link SLOT Galeri555.
    • 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 Daftar Slot Kocok303 adalah bocoran slot rekomendasi gacor dari Kocok303 yang bisa anda temukan di SLOT Kocok303. Situs SLOT Kocok303 hari ini yang kami bagikan di sini adalah yang terbaik dan bersiaplah untuk mengalami sensasi tak terlupakan dalam permainan slot online. Temukan game SLOT Kocok303 terbaik dengan 100 pilihan provider ternama yang dipercaya akan memberikan kepuasan dan kemenangan hari ini untuk meraih x500. RTP SLOT Kocok303 merupakan SLOT Kocok303 hari ini yang telah menjadi pilihan utama bagi pemain judi online di seluruh Indonesia. Setiap harinya jutaan pemain memasuki dunia maya untuk memperoleh hiburan seru dan kemenangan besar dalam bermain slot dengan adanya bocoran RTP SLOT Kocok303. Tidak ada yang lebih menyenangkan daripada mengungguli mesin slot dan meraih jackpot x500 yang menggiurkan di situs SLOT Kocok303 hari ini yang telah disediakan SLOT Kocok303. Menangkan jackpot besar x500 rajanya maxwin dari segala slot dan raih kemenangan spektakuler di situs Kocok303 terbaik 2024 adalah tempat yang menyediakan mesin slot dengan peluang kemenangan lebih tinggi daripada situs slot lainnya. Bagi anda yang mencari pengalaman judi slot paling seru dan mendebarkan, situs bo SLOT Kocok303 terbaik 2024 adalah pilihan yang tepat. Jelajahi dunia slot online melalui situs SLOT Kocok303 di link SLOT Kocok303.
  • Topics

×
×
  • Create New...

Important Information

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