Importing the class

Link to 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.

ZenScript
Copy
import crafttweaker.api.villager.ItemCost;

Extending Record

Link to extending-record

ItemCost extends Record. That means all methods available in Record are also available in ItemCost

Name: of

Return Type: ItemCost

ZenScript
Copy
ItemCost.of(stack as IItemStack) as ItemCost
ParameterType
Parameter
stack
Type
IItemStack

Name: of

Return Type: ItemCost

ZenScript
Copy
ItemCost.of(stack as IItemStack, predicate as DataComponentPredicate) as ItemCost
ParameterType
Parameter
stack
Type
IItemStack
Parameter
predicate
Type
DataComponentPredicate

Name: components

Return Type: DataComponentPredicate

ZenScript
Copy
// ItemCost.components() as DataComponentPredicate

myItemCost.components();

Name: test

Return Type: boolean

ZenScript
Copy
ItemCost.test(stack as IItemStack) as boolean
ParameterType
Parameter
stack
Type
IItemStack

Name: withComponents

Return Type: ItemCost

ZenScript
Copy
ItemCost.withComponents(operator as UnaryOperator<DataComponentPredicateBuilder>) as ItemCost
ParameterType
Parameter
operator
Type
UnaryOperator<DataComponentPredicateBuilder>
NameTypeHas GetterHas Setter
Name
count
Type
int
Has Getter
true
Has Setter
false
Name
item
Type
ItemDefinition
Has Getter
true
Has Setter
false
Name
itemStack
Type
IItemStack
Has Getter
true
Has Setter
false