2012-11-06 16:44:14 +01:00
|
|
|
package mekanism.api;
|
|
|
|
|
|
|
|
import net.minecraft.src.*;
|
|
|
|
|
2012-11-07 21:01:46 +01:00
|
|
|
/**
|
|
|
|
* Class used to add items or blocks to the Mekanism creative tab.
|
|
|
|
* @author AidanBrady
|
|
|
|
*
|
|
|
|
*/
|
2012-11-06 16:44:14 +01:00
|
|
|
public final class TabProxy
|
|
|
|
{
|
2012-11-07 21:01:46 +01:00
|
|
|
/** The 'Mekanism' class where the tab instance is stored. */
|
2012-11-06 16:44:14 +01:00
|
|
|
public static Class Mekanism;
|
|
|
|
|
2012-11-07 21:01:46 +01:00
|
|
|
/**
|
|
|
|
* Attempts to get the Mekanism creative tab instance from the 'Mekanism' class. Will return
|
|
|
|
* the tab if the mod is loaded, but otherwise will return null. Be sure you check it isn't
|
|
|
|
* null before you use it!
|
|
|
|
* @return mekanism creative tab if can, otherwise null
|
|
|
|
*/
|
2012-11-15 21:04:12 +01:00
|
|
|
public static CreativeTabs tabMekanism(CreativeTabs preferred)
|
2012-11-06 16:44:14 +01:00
|
|
|
{
|
|
|
|
try {
|
|
|
|
if(Mekanism == null)
|
|
|
|
{
|
|
|
|
Mekanism = Class.forName("mekanism.common.Mekanism");
|
|
|
|
}
|
|
|
|
|
|
|
|
Object ret = Mekanism.getField("tabMekanism").get(null);
|
|
|
|
|
|
|
|
if(ret instanceof CreativeTabs)
|
|
|
|
{
|
|
|
|
return (CreativeTabs)ret;
|
|
|
|
}
|
|
|
|
else {
|
2012-11-15 21:04:12 +01:00
|
|
|
return preferred;
|
2012-11-06 16:44:14 +01:00
|
|
|
}
|
|
|
|
} catch(Exception e) {
|
|
|
|
System.err.println("[Mekanism] Error retrieving Mekanism creative tab.");
|
2012-11-15 21:04:12 +01:00
|
|
|
return preferred;
|
2012-11-06 16:44:14 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|