Jump to content

[1.11] Metadata Blockstates Won't show up in Creative Tab


Saegusa

Recommended Posts

Hello,

 

I've been struggling with this for a while. Basically all the blocks I make with metadata variants register into the game, I can acquire them all with the /give command. But only the defaultState (metadata = 0) appears in the creative tab they're registered to. And I did set the creative tab in the block's constructor.

 

Have anyone else encountered something like this? I know doing this is possible because vanilla has it with wool and wood blocks.

 

Thanks

Link to comment
Share on other sites

You need to override getSubBlocks in your block class and add those block states as ItemStacks to the List parameter yourself:

 

(Pseudocode)

getSubBlocks(itemIn, tab, list) {
    list.add(new ItemStack(myBlock, 1, metadata));
}

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

I already have it overriden in my Block class:

@SideOnly(Side.CLIENT)
@Override
    public void getSubBlocks(Item item, CreativeTabs creativeTab, List<ItemStack> itemStacks) {
        for (Ores ore : Ores.VARIANTS) {
            itemStacks.add(new ItemStack(BlockUtils.getItemBlockFor(this), 1, ore.getMeta()));
        }
    }

 

and this is the getItemBlockFor() function:

 

 

public static ItemBlock getItemBlockFor(Block block) {
        return block instanceof BlockEthMeta ? new ItemBlockMeta(block) : new ItemBlock(block);
    }

 

ItemBlockMeta is just an extension of ItemBlock that I do my custom unlocalized namings and setHasSubtypes(true)

 

Edit: NVM I solved it thanks for helping, it turns out BlockEthMeta didn't have the getSubBlocks method to be overriden from BlockEthMetaOre. Thanks

 

I'll leave the code up for reference if anyone needs but you can lock the thread.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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