Interface IJavaNativeIntegrationRegistrationHandler


public interface IJavaNativeIntegrationRegistrationHandler
Handles registration of the various components required to integrate ZenCode scripts and Java code.

The various integration components are made up of native classes, zen classes, globals, and preprocessors. Refer to each specific method for more information.

Since:
9.1.0
  • Method Details

    • registerNativeType

      void registerNativeType(String loader, Class<?> clazz, NativeTypeInfo info)
      Registers the specified class as a native type for ZenCode.

      A native type is a pre-existing class that has not been written with ZenCode scripts in mind, but that is being exposed to scripts regardless to allow for easier usage. An example of such a class might be net.minecraft.world.level.block.Block.

      ZenCode sees native types as classes with the members specified by the given NativeTypeInfo and that are automatically expanded by the class specified in the registration. An expansion, even if empty, is required to be able to register a native type to ZenCode. It is thus suggested to use expansion constructs as much as possible instead of specifying a list of methods in the type information to expose methods for ease of usage and discovery.

      Parameters:
      loader - The name of the loader in which the specified native type should be available in.
      clazz - The Class that acts as the expansion necessary to register the native type. This class is not the same class returned by NativeTypeInfo.targetedType().
      info - A NativeTypeInfo record holding all information related to the native type.
      Since:
      9.1.0
    • registerZenClass

      void registerZenClass(String loader, Class<?> clazz, ZenTypeInfo info)
      Registers the specified class as a class for ZenCode.

      A class is simply considered a normal class in ZenCode. Refer to ZenTypeInfo for the different kinds of classes that can be registered.

      Parameters:
      loader - The name of the loader in which the specified class should be available in.
      clazz - The Class that should be registered to ZenCode.
      info - A ZenTypeInfo record holding all information related to the clazz that ZenCode requires to properly register it.
      Since:
      9.1.0
    • registerGlobalsIn

      void registerGlobalsIn(String loader, Class<?> clazz, ZenTypeInfo info)
      Marks a class as having globals that should be registered to ZenCode.

      A global is a name that is globally available and can be referenced anywhere in the script, such as loadedMods or println. The usage of globals is discouraged as a matter of code cleanliness: too many globals could simply lead to global scope pollution.

      Parameters:
      loader - The name of the loader in which the globals should be available in. The class must have already been registered to the same loader prior through registerZenClass(String, Class, ZenTypeInfo).
      clazz - The Class housing the globals that should be registered to ZenCode.
      info - A ZenTypeInfo record holding all information related to the clazz that ZenCode requires to properly register it.
      Since:
      9.1.0
    • registerPreprocessor

      void registerPreprocessor(IPreprocessor preprocessor)
      Registers the given preprocessor to ZenCode.

      Each preprocessor is identified by a unique name. Refer to IPreprocessor for more information.

      Parameters:
      preprocessor - The preprocessor to register.
      Since:
      9.1.0