Jump to content

Recommended Posts

Posted

Hello, I'm relatively new to modding but not java, and i was trying to add new items and blocks. Everything is working so far, except the creativetab part. I can get my items with /give, but they are just not showing in my creative tab. I am creating the creativetab like so:

modTab = new ModTab("testmod", wrench);

, and my ModTabs constructor is:

public ModTab(String label, Item i) {
	super(label);
	tabIcon = i;
}

.

I register my items with a method called 'register', and inside that it registers them to gameregistry and sets the creativetab:

private void register(Item item){
	GameRegistry.registerItem(item, item.getUnlocalizedName());
	item.setCreativeTab(modTab);
}

. I also have one for blocks, the same but with registerBlock. Any help would be appreciated!

 

P.S. Sorry for formatting issues, new to forum

Posted

Also don't use register item, change it to:

public static void registerItem(Item item) {

String name = item.getUnlocalizedName().substring(5);

if (item.getRegistryName() == null && Strings.isNullOrEmpty(name))

throw new IllegalArgumentException("Attempted to register a item with no name: " + item);

if (item.getRegistryName() != null && !item.getRegistryName().toString().equals(name))

throw new IllegalArgumentException("Attempted to register a item with conflicting names. Old: "

+ item.getRegistryName() + " New: " + name);

GameRegistry.register(item.getRegistryName() == null ? item.setRegistryName(name) : item);

item.setCreativetab(modTab);

}

Posted

override

Item.getSubItems(Item, CreativeTabs, List<ItemStack>)

if you don't already, you return the list after adding all the sub-items of the item you are making so it can be shown in the creative tab

Posted

I got this fixed, thanks for all the help! Turns out it was because i was setting the tabs in preInit(or not?), but once i moved the tab setting into Init it worked fine. Thanks for the help again!

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.