Jump to content

[1.10.2] Registering Block with varients - Help


JoltEffect

Recommended Posts

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.

tFyjjAj.png

9jSDESg.png

 

Any help appreciated.

 

Regards

 

Jolt

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



×
×
  • Create New...

Important Information

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