Item Stack Provider Bindings
Item stack providers are an item stack with attached data, known as item stack modifiers. There are several methods for creating them
These are available from the TFC.itemStackProvider
and TFC.isp
fields
Method Signatures
TFC.itemStackProvider.of(itemStack: ItemStack, modifiers?: (String | JsonArray | JsonObject | List<(String | JsonObject)>)): ItemStackProvider
TFC.isp.empty(modifiers?: (String | JsonArray | JsonObject | List<(String | JsonObject)>)): ItemStackProvider
TFC.itemStackProvider.copyInput(modifiers?: (String | JsonArray | JsonObject | List<(String | JsonObject)>)): ItemStackProvider
: Returns an item stack provider with the given item and modifiers.of(itemStack: ItemStack, modifiers?: (String | JsonArray | JsonObject | List<(String | JsonObject)>))
- 1st argument: An item stack, the item stack of the ISP
- Optional 2nd argument: A string, json array, json object, of list of strings and/or json objects, the modifiers to add. If not provided, no modifiers will be applied to the ISP
: Returns an item stack modifier with an empty item stack and the provided modifiers.empty(modifiers?: (String | JsonArray | JsonObject | List<(String | JsonObject)>))
- Optional 1st argument: A string, json array, json object, of list of strings and/or json objects, the modifiers to add. If not provided, no modifiers will be applied to the ISP
: Returns an empty ISP with the.copyInput(modifiers?: (String | JsonArray | JsonObject | List<(String | JsonObject)>))
tfc:copy_input
modifier and the provided modifiers- Optional 1st argument: A string, json array, json object, of list of strings and/or json objects, the modifiers to add. If not provided, only the copy input modifier will be applied to the ISP
These methods return an ItemStackProviderJS
object which has several helper methods and is described below
Examples
TFC.itemStackProvider.of('3x minecraft:dirt', ['tfc:add_glass', {type: 'tfc:add_trait', trait: 'kubejs:my_cool_trait'}])
TFC.isp.of('5x minecraft:stone')
TFC.itemStackProvider.empty('tfc:add_powder')
TFC.isp.copyInput()
TFC.itemStackProvider.copyInput('tfc:copy_heat')
In json:
{
"stack": {
"item": "minecraft:dirt",
"count": 3
},
"modifiers": [
{
"type": "tfc:add_glass"
},
{
"type": "tfc:add_trait",
"trait": "kubejs:my_cool_trait"
}
]
}
{
"item": "minecraft:stone",
"count": 5
}
{
"modifiers": [
{
"type": "tfc:add_powder"
}
]
}
{
"modifiers": [
{
"type": "tfc:copy_input"
}
]
}
{
"modifiers": [
{
"type": "tfc:copy_input"
},
{
"type": "tfc:copy_heat"
}
]
}
ItemStackProviderJS
An ItemStackProviderJS
is an object which is meant to mirror an actual ItemStackProvider
but be friendly to modify from JS and can be serialized into json.
Method Signatures
isp.stack(): ItemStack
isp.modifiers(): JsonArray
isp.isEmpty(): boolean
isp.isSimple(): boolean
isp.withCount(i: number): ItemStackProviderJS
isp.getCount(): number
isp.getJsonStack(): JsonObject
isp.getModifiersOfType(type: String): List<JsonObject>
isp.toJson(): JsonObject
isp.asCanonClass(): ItemStackProvider
isp.dependsOnInput(): boolean
isp.copy(): ItemStackProviderJS
isp.getTag(): @Nullable CompoundTag
isp.setTag(tag: CompoundTag): ItemStackProviderJS
isp.mergeTag(tag: CompoundTag): ItemStackProviderJS
isp.simpleModifier(type: String): ItemStackProviderJS
isp.jsonModifier(modifier: JsonObject): ItemStackProviderJS
isp.dyeLeather(color: DyeColor): ItemStackProviderJS
isp.addHeat(temperature: number): ItemStackProviderJS
isp.addPowder(): ItemStackProviderJS
isp.addTrait(trait: String): ItemStackProviderJS
isp.removeTrait(trait: String): ItemStackProviderJS
isp.addGlass(): ItemStackProviderJS
isp.copyFood(): ItemStackProviderJS
isp.copyForgingBonus(): ItemStackProviderJS
isp.copyHeat(): ItemStackProviderJS
isp.copyInput(): ItemStackProviderJS
isp.emptyBowl(): ItemStackProviderJS
isp.resetFood(): ItemStackProviderJS
isp.copyOldestFood(): ItemStackProviderJS
isp.addBait(): ItemStackProviderJS
isp.meal(food: Consumer<BuildFoodItemData>, portions?: Consumer<BuildPortionData>[]): ItemStackProviderJS
// The following are available if FirmaLife is installed
isp.firmaLifeAddPiePan(): ItemStackProviderJS
isp.firmaLifeCopyDynamicFood(): ItemStackProviderJS
isp.firmaLifeEmptyPan(): ItemStackProviderJS
: Returns the.stack()
ItemStack
of the ISP
: Returns a json array of all of the applied modifiers.modifiers()
: Returns true if the stack and modifier list is empty.isEmpty()
: Sets the stacks count to the provided value.withCount(i: number)
: Returns the stack’s count.getCount()
: Returns a json object representing the item stack.getJsonStack()
: Returns a list of json objects which represent the applied modifiers with the given type.getModifiersOfType(type: String)
: Returns the json representation of the ISP.toJson()
: Returns the ISP as an.asCanonClass()
ItemStackProvider
object, TFC’s canonical class for this data
: Returns true if any of the applied modifiers is dependent on the recipe’s input.dependsOnInput()
: Returns a copy of the ISP.copy()
: Returns the item stack’s.getTag()
CompoundTag
, may be null
: Sets the item stack’s.setTag(tag: CompoundTag)
CompoundTag
: Merges the provided.mergeTag(tag: CompoundTag)
CompoundTag
into the item stack’s
: Adds a modifier of the provided type.simpleModifier(type: String)
: Adds the provided json modifier.jsonModifier(modifier: JsonObject)
: Adds a.dyeLeather(color: DyeColor)
tfc:dye_leather
modifier with the provided color
: Adds a.addHeat(temperature: number)
tfc:add_heat
with the provided temperature, allows negative values
: Adds a.addPowder()
tfc:add_powder
modifier
: Adds a.addTrait(trait: String)
tfc:add_trait
modifier with the provided trait value
: Adds a.removeTrait(trait: String)
tfc:remove_trait
modifier with the provided trait value
: Adds a.addGlass()
tfc:add_glass
modifier
: Adds a.copyFood()
tfc:copy_food
modifier
: Adds a.copyForgingBonus()
tfc:copy_forging_bonus
modifier
: Adds a.copyHeat()
tfc:copy_heat
modifier
: Adds a.copyInput()
tfc:copy_input
modifier
: Adds a.emptyBowl()
tfc:empty_bowl
modifier
: Adds a.resetFood()
tfc:reset_food
modifier
: Adds a.copyOldestFood()
tfc:copy_oldest_food
modifier
: Adds a.addBait()
tfc:add_bait_to_rod
modifier
: Adds a.meal(food: Consumer<BuildFoodItemData>, portions?: Consumer<BuildPortionData>[])
tfc:meal
modifier- 1st argument: A consumer with the same methods as the 2nd argument of a food definition
- Optional 2nd argument: An array of consumers specifying the portions of a meal
.ingredient(ingredient: Ingredient)
: Sets the portion’s ingredient.nutrientModifier(modifier: number)
: Multiplies the nutrition from the ingredient, defaults to 1.waterModifier(modifier: number)
: Multiplies the water from the ingredient, defaults to 1.saturationModifier(modifier: number)
: Multiplies the saturation from the ingredient, defaults to 1
If FirmaLife is installed the following methods are available:
: Adds a.firmaLifeAddPiePan()
firmalife:add_pie_pan
modifier
: Adds a.firmaLifeCopyDynamicFood()
firmalife:copy_dynamic_food
modifier
: Adds a.firmaLifeEmptyPan()
firmalife:empty_pan
modifier
Examples
TFC.itemStackProvider.copyInput().copyHeat().copyOldestFood()
TFC.itemStackProvider.of('5x minecraft:glass').addHeat(500)
In json:
{
"modifiers": [
{
"type": "tfc:copy_input"
},
{
"type": "tfc:copy_heat"
},
{
"type": "tfc:copy_oldest_food"
}
]
}
{
"stack": {
"item": "minecraft:glass",
"count": 5
},
"modifiers": [
{
"type": "tfc:add_heat",
"temperature": 500
}
]
}