Jump to content




[SOLVED] Adding peripheral to CC's creative tab


  • You cannot reply to this topic
3 replies to this topic

#1 Niverton

  • Members
  • 6 posts

Posted 25 June 2014 - 03: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 by Niverton, 25 June 2014 - 05:02 PM.


#2 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 25 June 2014 - 04: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 by theoriginalbit, 25 June 2014 - 04:30 PM.


#3 Niverton

  • Members
  • 6 posts

Posted 25 June 2014 - 05:02 PM

Thanks ! Never thought the tab list was accessible x)

#4 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 26 June 2014 - 01: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





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users