Interface IJavaNativeIntegrationRegistrationHandler
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 Summary
Modifier and TypeMethodDescriptionvoidregisterGlobalsIn(String loader, Class<?> clazz, ZenTypeInfo info) Marks a class as having globals that should be registered to ZenCode.voidregisterNativeType(String loader, Class<?> clazz, NativeTypeInfo info) Registers the specified class as a native type for ZenCode.voidregisterPreprocessor(IPreprocessor preprocessor) Registers the given preprocessor to ZenCode.voidregisterZenClass(String loader, Class<?> clazz, ZenTypeInfo info) Registers the specified class as a class for ZenCode.
-
Method Details
-
registerNativeType
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
NativeTypeInfoand 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- TheClassthat acts as the expansion necessary to register the native type. This class is not the same class returned byNativeTypeInfo.targetedType().info- ANativeTypeInforecord holding all information related to the native type.- Since:
- 9.1.0
-
registerZenClass
Registers the specified class as a class for ZenCode.A class is simply considered a normal class in ZenCode. Refer to
ZenTypeInfofor 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- TheClassthat should be registered to ZenCode.info- AZenTypeInforecord holding all information related to theclazzthat ZenCode requires to properly register it.- Since:
- 9.1.0
-
registerGlobalsIn
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
loadedModsorprintln. 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 throughregisterZenClass(String, Class, ZenTypeInfo).clazz- TheClasshousing the globals that should be registered to ZenCode.info- AZenTypeInforecord holding all information related to theclazzthat ZenCode requires to properly register it.- Since:
- 9.1.0
-
registerPreprocessor
Registers the given preprocessor to ZenCode.Each preprocessor is identified by a unique name. Refer to
IPreprocessorfor more information.- Parameters:
preprocessor- The preprocessor to register.- Since:
- 9.1.0
-