Annotation Interface ZenRegister


@Documented @Retention(RUNTIME) @Target(TYPE) public @interface ZenRegister
Marks a class as requiring registration to ZenCode.

Classes with this annotation will be automatically discovered by CraftTweaker and their lifecycle managed accordingly. It is thus not required for a mod to use a plugin's IJavaNativeIntegrationRegistrationHandler to register the classes.

Classes will be automatically registered to the loaders specified in loaders(). It is also possible to prevent discovery of this class through the modDeps() annotation parameter.

It might be required to combine this annotation with other annotations, such as ZenCodeType.Name or NativeTypeRegistration depending on the circumstances. Refer to the other annotations documentation for more information.

Since:
9.1.0
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Returns a list of loaders to which this class should be registered.
    Specifies a list of mods that must be present for discovery of the class to occur.
  • Element Details

    • modDeps

      String[] modDeps
      Specifies a list of mods that must be present for discovery of the class to occur.

      In other words, if any of the mods specified in the array is not available in the current environment, the class will not be registered to ZenCode. This allows for soft-dependencies to be correctly handled by mods.

      If no dependency is specified (i.e. the array is left empty), the class will always be loaded.

      Returns:
      The mod IDs that need to be available for this class to be discovered.
      Since:
      9.1.0
      Default:
      {}
    • loaders

      String[] loaders
      Returns a list of loaders to which this class should be registered.

      Any loader that is not specified in this array will not be able to reference this class in ZenCode scripts, effectively allowing for isolation of multiple loaders.

      By default, all classes will be registered to the default loader, whose name is identified by CraftTweakerConstants.DEFAULT_LOADER_NAME.

      Although discouraged, it is possible to indicate that a class should be registered to all available loaders by using the global marker. Note that this should be used sporadically to prevent pollution of the global namespace and unwanted side effects.

      Returns:
      The loaders to which this class should be available.
      Since:
      9.1.0
      Default:
      {"crafttweaker"}