This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Niverton's profile picture

[SOLVED] Adding peripheral to CC's creative tab

Started by Niverton, 25 June 2014 - 02:23 PM
Niverton #1
Posted 25 June 2014 - 04:23 PM
Hey,
The title says it all, I'm working on a peripheral, and as my mod only adds one block, I'd like to be able to add it to CC's creative tab. I searched for a few hours now, can't find a way to get the CreativeTab from another mod. Any help here please ?
Thanks
Edited on 25 June 2014 - 04:02 PM
theoriginalbit #2
Posted 25 June 2014 - 05:29 PM
you could use reflection to get it from out of ComputerCraft, that's a little more complicated than needed however, because Minecraft doesn't make the array of CreativeTabs private, and ComputerCraft's tab isn't translated, so we can just search for it that way :)/>


public CreativeTabs findCCTab() {
  for (CreativeTabs tab : CreativeTabs.creativeTabArray) {
	if (tab.getTabLabel().equals("ComputerCraft")) {
	  return tab;
	}
  }
  throw new IllegalStateException("ComputerCraft creative tab couldn't be found. Where is it?");
}
Edited on 25 June 2014 - 03:30 PM
Niverton #3
Posted 25 June 2014 - 06:02 PM
Thanks ! Never thought the tab list was accessible x)
theoriginalbit #4
Posted 26 June 2014 - 02:52 AM
neither did I. so I looked in the source and it was public. its amazing what can be learnt by looking into source :P/>