Home Migration Guide Getting Started With Scripts Commands Examples
Generic JSON Recipes

ModuleHelper

This class was added by a mod with mod-id mekanism. So you need to have this mod installed if you want to use this feature.

Importing the class

It might be required for you to import the package if you encounter any issues (like casting an Array), so better be safe than sorry and add the import at the very top of the file.

script.zs
import mods.mekanism.api.gear.ModuleHelper;

Static Methods

Gets all the module types a given item support.

Returns: Set of supported module types.
Return Type: Set<ModuleData>

script.zs
ModuleHelper.getSupported(container as ItemStack) as Set<ModuleData>
ParameterTypeDescription
Parameter
container
Type
ItemStack
Description
Module container, for example a Meka-Tool or MekaSuit piece.

Helper to get the various items that support a given module type.

Returns: Set of items that support the given module type.
Return Type: Set<MCItemDefinition>

script.zs
ModuleHelper.getSupported(type as ModuleData) as Set<MCItemDefinition>
ParameterTypeDescription
Parameter
type
Type
ModuleData
Description
Module type.

Helper method to check if an item has a module installed and the module is enabled.

Returns: true if the item has the module installed and enabled.
Return Type: boolean

script.zs
ModuleHelper.isEnabled(container as ItemStack, type as ModuleData) as boolean
ParameterTypeDescription
Parameter
container
Type
ItemStack
Description
Module container, for example a Meka-Tool or MekaSuit piece.
Parameter
type
Type
ModuleData
Description
Module type.

Helper method to try and load a module from an item.

Returns: Module, or null if no module of the given type is installed.
Return Type: Module<MODULE>?

script.zs
ModuleHelper.load<MODULE>(container as ItemStack, type as ModuleData<MODULE>) as Module<MODULE>?
ParameterTypeDescription
Parameter
container
Type
ItemStack
Description
Module container, for example a Meka-Tool or MekaSuit piece.
Parameter
type
Type
ModuleData<MODULE>
Description
Module type.
Parameter
MODULE
Type
Description
No Description Provided

Gets a list of all modules on an item stack.

Returns: List of modules on an item, or an empty list if the item doesn’t support modules.
Return Type: stdlib.List<Module>

script.zs
ModuleHelper.loadAll(container as ItemStack) as stdlib.List<Module>
ParameterTypeDescription
Parameter
container
Type
ItemStack
Description
Module container, for example a Meka-Tool or MekaSuit piece.

Gets all the module types on an item stack.

Returns: Module types on an item.
Return Type: Collection<ModuleData>

script.zs
ModuleHelper.loadAllTypes(container as ItemStack) as Collection<ModuleData>
ParameterTypeDescription
Parameter
container
Type
ItemStack
Description
Module container, for example a Meka-Tool or MekaSuit piece.