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

ChemicalStack

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.chemical.ChemicalStack;

A ChemicalStack is the concrete representation of a Chemical, with defined characteristics, such as the amount, the type, and other data.

Implemented Interfaces

ChemicalStack implements the following interfaces. That means all methods defined in these interfaces are also available in ChemicalStack

Casters

Result typeIs Implicit
Result type
CHEMICAL
Is Implicit
true
Result type
ChemicalStackIngredient
Is Implicit
true

Methods

Makes this stack immutable

Returns: An immutable Stack. This is either a new stack if the current stack is mutable, or the same stack if it is already immutable.

Return Type: CRT_STACK

script.zs
// ChemicalStack.asImmutable() as CRT_STACK
myChemicalStack.asImmutable();

Makes this stack mutable

Returns: A new Stack, that is mutable.

Return Type: CRT_STACK

script.zs
// ChemicalStack.asMutable() as CRT_STACK
myChemicalStack.asMutable();

Checks if this chemical stack, contains the given chemical stack by checking if the chemicals are the same, and if this stack’s amount is bigger than the given stack’s amount

Returns: true if this stack contains the other stack

Return Type: boolean

script.zs
ChemicalStack.containsOther(stack as CRT_STACK) as boolean
ParameterTypeDescription
Parameter
stack
Type
CRT_STACK
Description
Chemical stack to compare against

Copies the stack. Only needed when mutable stacks are involved.

Returns: A new stack, that contains the same info as this one

Return Type: CRT_STACK

script.zs
// ChemicalStack.copy() as CRT_STACK
myChemicalStack.copy();

Gets the size of this chemical stack.

Returns: The size of this chemical stack or zero if it is empty

Return Type: long

script.zs
// ChemicalStack.getAmount() as long
myChemicalStack.getAmount();

Gets the registry name for the chemical this stack is representing.

Returns: A MCResourceLocation representing the registry name.

Return Type: MCResourceLocation

script.zs
// ChemicalStack.getRegistryName() as MCResourceLocation
myChemicalStack.getRegistryName();

Retrieves this fluid stack’s fluid.

Returns: The fluid.

Return Type: CHEMICAL

script.zs
// ChemicalStack.getType() as CHEMICAL
myChemicalStack.getType();

Grows the stack’s amount by the given amount in MilliBuckets (MB)

Returns: A new stack, or this stack, depending on if this stack is mutable
Return Type: CRT_STACK

script.zs
ChemicalStack.grow(amount as long) as CRT_STACK
ParameterTypeDescription
Parameter
amount
Type
long
Description
The amount to grow the stack by.

Whether this chemical stack is empty.

Returns: true if this stack is empty, false otherwise.

Return Type: boolean

script.zs
// ChemicalStack.isEmpty() as boolean
myChemicalStack.isEmpty();

Checks if this chemical stack is equal another chemical stack.

Returns: true if the chemicals stacks are equal, false otherwise.

Return Type: boolean

script.zs
ChemicalStack.isEqual(other as CRT_STACK) as boolean
ParameterTypeDescription
Parameter
other
Type
CRT_STACK
Description
Chemical stack to check against.

Whether this ChemicalStack’s chemical type is equal to the other defined ChemicalStack.

Returns: if the ChemicalStacks contain the same chemical type

Return Type: boolean

script.zs
ChemicalStack.isTypeEqual(stack as CRT_STACK) as boolean
ParameterTypeDescription
Parameter
stack
Type
CRT_STACK
Description
- ChemicalStack to check

Sets the chemical’s amount in MilliBuckets (MB)

Returns: A new stack, or this stack, depending on if this stack is mutable

Return Type: CRT_STACK

script.zs
ChemicalStack.setAmount(amount as long) as CRT_STACK
ParameterTypeDescription
Parameter
amount
Type
long
Description
The amount to set the stack’s amount to.

Shrinks the stack’s amount by the given amount in MilliBuckets (MB)

Returns: A new stack, or this stack, depending on if this stack is mutable

Return Type: CRT_STACK

script.zs
ChemicalStack.shrink(amount as long) as CRT_STACK
ParameterTypeDescription
Parameter
amount
Type
long
Description
The amount to shrink the stack by.

Operators

Checks if this chemical stack, contains the given chemical stack by checking if the chemicals are the same, and if this stack’s amount is bigger than the given
stack’s amount

script.zs
stack as CRT_STACK in myChemicalStack

Checks if this chemical stack is equal another chemical stack.

script.zs
myChemicalStack == other as CRT_STACK

Multiplies the stack’s amount by the given amount in MilliBuckets (MB)

script.zs
myChemicalStack * amount as long

Properties

NameTypeHas GetterHas SetterDescription
Name
amount
Type
long
Has Getter
true
Has Setter
false
Description
Gets the size of this chemical stack.
Name
commandString
Type
string
Has Getter
true
Has Setter
false
Description
No Description Provided
Name
empty
Type
boolean
Has Getter
true
Has Setter
false
Description
Whether this chemical stack is empty.
Name
registryName
Type
MCResourceLocation
Has Getter
true
Has Setter
false
Description
Gets the registry name for the chemical this stack is representing.
Name
type
Type
CHEMICAL
Has Getter
true
Has Setter
false
Description
Retrieves this chemical stack’s chemical.

Small note

It is worth nothing that for each Chemical type, there’s a ChemicalStack:

script.zs
GasStack
InfusionStack
PigmentStack
SlurryStack

exist and are something you can interact with.