Creative Tab
Link to creative-tab
This allows you to add Creative Tabs to the game!
Creating the ICreativeTab object
Link to creating-the-icreativetab-object
Before you can add the tab, you need to create a representation which will allow you to set the properties of the tab you want to add.
This is where the VanillaFactory comes in:
ZenScript Copymods.contenttweaker.VanillaFactory.createCreativeTab(String unlocalizedName, IItemStack iItemStack);
mods.contenttweaker.VanillaFactory.createCreativeTab(String unlocalizedName, ItemRepresentation iItem);
mods.contenttweaker.VanillaFactory.createCreativeTab(String unlocalizedName, BlockRepresentation iBlock);
mods.contenttweaker.VanillaFactory.createCreativeTab(String unlocalizedName, IItemStackSupplier supplier);
The String is in each of the three methods the same: It's the unlocalized name the Tab will later have.
The second parameter is the symbol your tab will carry later on (e.g. a lava bucket for "misc").
You can decide wheter you want to use an itemRepresentation, an itemStack, a blockrepresentation or an itemStackSupplier function.
Calling an existing ICreativeTab object
Link to calling-an-existing-icreativetab-object
You can also call an existing creative tab, though you cannot change any of it's properties.
Why would you need this, you ask?
You will need this if you want to add a newly created block or item to an existing tab!
You can call and set all these properties using the normal ZenGetters and ZenSetters
tab.unlocalizedName = "hh";
Note that you will probably hardly ever need the Setters as these Properties are already initialized to your wanted values when you create the ICreativeTab object.
Also, you can neither set nor get properties from an existing ICreativeTab(one that you retrieved using the Bracket handler)!
Property Name | 类型 | Required | 默认值 | Description/Notes |
---|---|---|---|---|
Property Name unlocalizedName | 类型 string | Required YES | 默认值 | Description/Notes The Creative Tab's name |
Property Name iconStack | 类型 IItemstack | Required YES/NO | 默认值 | Description/Notes The Creative Tab's icon |
Property Name iconStackSupplier | 类型 IItemStackSupplier | Required NO/YES | 默认值 null | Description/Notes Determines something? |
Registering the creative tab
Link to registering-the-creative-tab
You need to call this method to register the creative Tab in the game!
Otherwise nothing will happen!
After you have called this function, you cannot un-register the tab or change any of it's properties!
ZenScript Copytab.register();
示例脚本
Link to 示例脚本
ZenScript Copy#loader contenttweaker
import mods.contenttweaker.CreativeTab;
import mods.contenttweaker.VanillaFactory;
val zsTab = VanillaFactory.createCreativeTab("contenttweaker", <item:minecraft:dragon_egg>);
zsTab.register();