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
    • 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
    • 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 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 ItemStack of the ISP
  • : Returns a json array of all of the applied modifiers
  • : Returns true if the stack and modifier list is empty
  • : Sets the stacks count to the provided value
  • : Returns the stack’s count
  • : Returns a json object representing the item stack
  • : Returns a list of json objects which represent the applied modifiers with the given type
  • : Returns the json representation of the ISP
  • : Returns the ISP as an ItemStackProvider object, TFC’s canonical class for this data
  • : Returns true if any of the applied modifiers is dependent on the recipe’s input
  • : Returns a copy of the ISP
  • : Returns the item stack’s CompoundTag, may be null
  • : Sets the item stack’s CompoundTag
  • : Merges the provided CompoundTag into the item stack’s
  • : Adds a modifier of the provided type
  • : Adds the provided json modifier
  • : Adds a tfc:dye_leather modifier with the provided color
  • : Adds a tfc:add_heat with the provided temperature, allows negative values
  • : Adds a tfc:add_powder modifier
  • : Adds a tfc:add_trait modifier with the provided trait value
  • : Adds a tfc:remove_trait modifier with the provided trait value
  • : Adds a tfc:add_glass modifier
  • : Adds a tfc:copy_food modifier
  • : Adds a tfc:copy_forging_bonus modifier
  • : Adds a tfc:copy_heat modifier
  • : Adds a tfc:copy_input modifier
  • : Adds a tfc:empty_bowl modifier
  • : Adds a tfc:reset_food modifier
  • : Adds a tfc:copy_oldest_food modifier
  • : Adds a tfc:add_bait_to_rod modifier
  • : Adds a 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 firmalife:add_pie_pan modifier
  • : Adds a firmalife:copy_dynamic_food modifier
  • : Adds a 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
        }
    ]
}