Home Commands Examples Getting Started With Scripts Global Keywords

IFluidStack

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 crafttweaker.api.fluid.IFluidStack;

Implemented Interfaces

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

Static Methods

Gets the empty IFluidStack

Returns: The empty IFluidStack
Return Type: IFluidStack

script.zs
// IFluidStack.empty() as IFluidStack
IFluidStack.empty();

Casters

Result TypeIs Implicit
Result Type
Fluid
Is Implicit
true
Result Type
FluidIngredient
Is Implicit
true
Result Type
IData
Is Implicit
true

Methods

Return Type: IData

script.zs
// IFluidStack.asIData() as IData
myIFluidStack.asIData();

Return Type: IFluidStack

script.zs
// IFluidStack.asImmutable() as IFluidStack
myIFluidStack.asImmutable();

Makes this stack mutable

Returns: A new Stack, that is mutable.
Return Type: IFluidStack

script.zs
// IFluidStack.asMutable() as IFluidStack
myIFluidStack.asMutable();

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

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

script.zs
// IFluidStack.copy() as IFluidStack
myIFluidStack.copy();

Returns the NBT tag attached to this FluidStack.

Returns: MapData of the FluidStack’s NBT Tag, null if it doesn’t exist.
Return Type: IData

script.zs
// IFluidStack.getTag() as IData
myIFluidStack.getTag();

Return Type: boolean

script.zs
// IFluidStack.isImmutable() as boolean
myIFluidStack.isImmutable();

Checks if this IFluidStack, matches the given IFluidStack by checking if the fluids are the same, and if this fluid’s amount is bigger than the given fluid’s amount

Returns: true if this fluid contains the other fluid
Return Type: boolean

script.zs
IFluidStack.matches(other as IFluidStack) as boolean
ParameterTypeDescription
Parameter
other
Type
IFluidStack
Description
other IFluidStack to compare against

Sets the fluid amount in MilliBuckets (mB)

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

script.zs
// IFluidStack.setAmount(amount as int) as IFluidStack
myIFluidStack.setAmount(1000);
ParameterTypeDescription
Parameter
amount
Type
int
Description
The amount to multiply this stack

Sets the tag for the FluidStack.

Returns: This FluidStack if it is mutable, a new one with the changed property otherwise
Return Type: IFluidStack

script.zs
// IFluidStack.withTag(tag as IData?) as IFluidStack
myIFluidStack.withTag({Display: {lore: ["Hello"]}});
ParameterTypeDescription
Parameter
tag
Type
IData?
Description
The tag to set.

Operators

Checks if this IFluidStack, matches the given IFluidStack by checking if the fluids are the same, and if this fluid’s amount is bigger than the given fluid’s amount

script.zs
other as IFluidStack in myIFluidStack

Sets the fluid amount in MilliBuckets (mB)

script.zs
myIFluidStack * amount as int
myIFluidStack * 1000
script.zs
myIFluidStack | other as FluidIngredient

Properties

NameTypeHas GetterHas SetterDescription
Name
amount
Type
long
Has Getter
true
Has Setter
false
Description
Gets the fluid amount in MilliBuckets (mB).
Name
empty
Type
boolean
Has Getter
true
Has Setter
false
Description
Gets whether this fluid stack is empty.
Name
fluid
Type
Fluid
Has Getter
true
Has Setter
false
Description
Retrieves this fluid stack’s fluid.
Name
hasTag
Type
boolean
Has Getter
true
Has Setter
false
Description
Returns true if this FluidStack has a Tag
Name
isImmutable
Type
boolean
Has Getter
true
Has Setter
false
Description
Name
registryName
Type
ResourceLocation
Has Getter
true
Has Setter
false
Description
Gets the registry name for the fluid this stack is representing.
Name
tag
Type
IData
Has Getter
true
Has Setter
false
Description
Returns the NBT tag attached to this FluidStack.