Jump to content

Recommended Posts

Posted

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

 

 

Posted

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.

Posted

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

Posted

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

 

Posted

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.

Posted

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?

Posted

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.

Posted

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:

Posted

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.

Posted

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"));
}

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.