Hey guys after some help I cannot get my block variants to render within the Creative tab/hotbar, when placed in the world as a block they render just fine with each with it's own texture.
My ModBlocks Class
public static final Block blockStained = new BlockStained();
public static void registerBlocks()
{
GameRegistry.register(blockStained);
Register blockStainedVarients();
}
public static void blockStainedVarients()
{
String colors[] = {"white","orange","magenta","light_blue","yellow","lime","pink","gray","silver","cyan","purple","blue","brown","green","red","black"};
for (int i=0; i < colors.length; i++)
{
ModelBakery.registerItemVariants(Item.getItemFromBlock(blockStained), new ModelResourceLocation(blockStained.getRegistryName() + "_" + colors[i], "inventory"));
}
}
My ModItems Class
public static void registerItems()
{
GameRegistry.register(new [glow=red,2,300]ItemBlockMeta[/glow](ModBlocks.blockStained), ModBlocks.blockStained.getRegistryName());
}
My Custom ItemBlockMeta Class
public class ItemBlockMeta extends ItemBlock {
public ItemBlockMeta(Block block) {
super(block);
if (!(block instanceof IMetaBlockName)) {
throw new IllegalArgumentException(String.format("The given Block %s is not an instance of ISpecialBlockName!", block.getUnlocalizedName()));
}
this.setMaxDamage(0);
this.setHasSubtypes(true);
}
public int getMetadata(int damage)
{
return damage;
}
@Override
public String getUnlocalizedName(ItemStack stack) {
return super.getUnlocalizedName(stack) + "." + ((IMetaBlockName)this.block).getSpecialName(stack); //This is a custom Interface class with String getSpecialName(ItemStack stack);
}
}
My assets\modname\blockstates\blockstained.json with all 16 varients meta states
{
"variants": {
"color=white": { "model":"justsolars:blockstained_white" },
"color=orange": { "model":"justsolars:blockstained_orange" },
"color=magenta": { "model":"justsolars:blockstained_magenta" },
"color=light_blue": { "model":"justsolars:blockstained_light_blue" },
"color=yellow": { "model":"justsolars:blockstained_yellow" },
"color=lime": { "model":"justsolars:blockstained_lime" },
"color=pink": { "model":"justsolars:blockstained_pink" },
"color=gray": { "model":"justsolars:blockstained_gray" },
"color=silver": { "model":"justsolars:blockstained_silver" },
"color=cyan": { "model":"justsolars:blockstained_cyan" },
"color=purple": { "model":"justsolars:blockstained_purple" },
"color=blue": { "model":"justsolars:blockstained_blue" },
"color=brown": { "model":"justsolars:blockstained_brown" },
"color=green": { "model":"justsolars:blockstained_green" },
"color=red": { "model":"justsolars:blockstained_red" },
"color=black": { "model":"justsolars:blockstained_black" }
}
}
I have 16 model\block Json's, 16 model\item Json's and 16 textures/
I have attached a couple of screenshot to help understand.
Any help appreciated.
Regards
Jolt