ZenExpansion
Link to zenexpansion
A ZenExpansion is, like @ZenClass
, used to annotate a Class that should be accessible from within ZS.
Unlike ZenClasses however, ZenExpansions are used to expand the functionality of already existing ZenClasses.
Example
Link to example
java Copy@ZenExpansion("crafttweaker.item.IItemStack")
@ZenRegister
public class Expansion {
@ZenMethod
public static void print(IItemStack stack) {
CraftTweakerAPI.logInfo("STACKKKKK: " + stack.getDisplayName());
}
}
This would allow people to do
ZenScript Copy<minecraft:iron_ingot>.print();
Since this is an expansion the first parameter is the class' instance!
This parameter will not be available in ZS.
What classes can be annotated || Additional Info
Link to what-classes-can-be-annotated--additional-info
- All Methods need to begin with a parameter that represents the expanded class' instance. Also, all Methods inside the expansion must be static (... and public).
- You can annotate all Java Classes
- You must give the annotation a String value (e.g.
crafttweaker.item.IItemStack
). This String value must represent an already existing ZenClass' name. - After declaring a class a ZenExpansion, you still need to register it. It is recommended that you use
@ZenRegister
for that.