Custom Registry Objects

KubeJS TFC adds the ability to register some TFC-specific non-item/block types

Chisel Mode

Chisel modes are used when chiseling

The registry for chisel modes is tfc:chisel_mode

Methods

  • : Sets the ‘priority’ of the chisel mode when sorting chisel modes for cycling. Defaults to 300
  • : Sets the texture to use when displayed in the hotbar. Draws the 20 x 20 pixel area at the x and y coordinate
  • : Sets the texture to use when displayed in recipe viewers
  • : Sets the behavior when chiseling is performed. Accepts a callback with the params
    • original: BlockState: The original state being chiseled
    • chiseled: BlockState: The chiseled state specified by the recipe
    • player: Player: The player chiseling
    • hit: BlockHitResult: The hit result of the player
    • return: @Nullable BlockState: The chiseled state to place in-world, may be null to indicate an invalid value Defaults to returning the chiseled state

Example

StartupEvents.registry('tfc:chisel_mode', event => {
    event.create('my_chisel_mode')
        .hotbarIcon('kubejs:block/my_chisel_mode/hotbar', 0, 0)
        .recipeIcon('kubejs:block/my_chisel_mode/recipe', 0, 0, 20, 20)
        .chiselBehavior((original, chiseled, player, hit) => {
            if (orginal.hasBlockEntity()) {
                return null
            } else {
                return chiseled
            }
        })
})

Climate Model Type

Climate models define the temperature, rainfall, and other climatic factors of a world. They are created and added to a level at world-start, but must have a registered type. KubeJS TFC adds the ability to create types and easily create models from them

The registry for climate model types is tfc:climate_model

Methods

  • : Sets the wind calculation of the model, accepts a callback with the params
    • model: ClimateModel: The ClimateModel the wind is being calculated for
    • level: Level: The level wind is being calculated for
    • pos: BlockPos: The position the wind is being calculated for
    • calendarTick: int: The calendar tick at which wind is being calculated at
    • daysInMonth: int: The number of days in a month
    • wind: Function<number, number, Vec2>: A helper function to create a Vec2 without reflection. Use .blow(x: float, z: float) to do so
    • return: Vec2: The calculated horizontal wind vector
  • : Sets the fog calculation of the model, accepts a TimelessClimateValueFunction. The returned value will be clamped to [0, 1]
  • : Sets the fog calculation of the model, accepts a ClimateValueFunction. The returned value will be clamped to [0, 1]
  • : Sets the average temperature calculation of the model. Accepts a TimelessClimateValueFunction which returns the average temperature, in °C, at the position
  • : Sets the average rainfall calculation of the model, accepts a TimelessClimateValueFunction. Returned values will be clamped to [0, Infinity)
  • : Sets the rain variance calculation of the model, accepts a TimelessClimateValueFunction. Returned values will be clamped to [-1, 1]
  • : Sets the calculation for if its currently raining at a calendar tick, given it is raining. Accepts a callback with the params
    • model: ClimateModel: The ClimateModel the calculation is for
    • calendarTick: int: The calendar tick being evaluated at
    • return: boolean: If it is thundering at the tick
  • : Sets the calculation for the rain intensity. Accepts a callback with the parameters
    • model: ClimateModel: The ClimateModel the calculation is for
    • calendarTick: int: The calendar tick being evaluated at
    • return: number: The intensity, typically in the range [0, 1], but may be greater to indicate extreme rain intensity or negative to indicate it is not raining
  • : Sets the calculation for the instantaneous temperature of the model, accepts a ClimateValueFunction
  • : Sets the calculation for the instantaneous rainfall of the model, accepts a ClimateValueFunction
  • : Sets the groundwater calculation of the model, accepts a TimelessClimateValueFunction. Returned values will be clamped to [0, Infinity)

TimelessClimateValueFunction

A callback with the following parameters

  • model: ClimateModel: The ClimateModel the value is being calculated for
  • level: LevelReader: The level the value is being calculated in
  • pos: BlockPos: The position the value is being calculated at
  • return: number: The calculated value

ClimateValueFunction

A callback with the following parameters

  • model: ClimateModel: The ClimateModel the value is being calculated for
  • level: LevelReader: The level the value is being calculated in
  • pos: BlockPos: The position the value is being calculated at
  • calendarTick: int: The calendar tick at which the value is being calculated at
  • daysInMonth: int: The number of days in a month
  • return: number: The calculated value

Example

StartupEvents.registry('tfc:climate_model', event => {
    event.create('hell')
        .wind((model, level, pos, calendarTick, daysInMonth, wind) => {
            let dir = calendarTick / 1000
            return wind.blow(Math.sin(dir), Math.cos(dir)).scaled(Math.cos(dir) * 100)
        })
        .thunder((model, calendarTick) => true)
        .rainIntensity((model, calendarTick) => 2)
        .averageTemperature((model, level, pos) => {
            return pos.y > 20 ? 88 : 92
        })
        .instantaneousTemperature((model, level, pos, calendarTicks, daysInMonth) => {
            let yearlength = daysInMonth * 12 * 24000
            let yearPortion = (calendarTicks % yearLength) / yearLength
            // +/- 7 degrees dependent on progress through year
            let currentDeviation = Math.cos(yearPortion * 2 * Math.PI) * 7
            // Use the model's average temperature (as calculated above) as a base
            return model.getAverageTemperature(level, pos) + currentDeviation
        })
})

Food Trait

Food traits can be applied to food items to modify how long it takes them to expire

The registry for food traits is tfc:food_trait

Methods

  • : Sets the decay modifier of the trait. A larger value results in a quicker expiry
  • : Sets the modifier of the trait as a supplier
  • : Gives the food trait a tooltip with the specified translation key
  • : Gives the food trait a tooltip with the given text, autogenerating a lang key if not already specified

Example

StartupEvents.registry('tfc:food-trait', event => {
    event.create('my_trait')
        .decayModifier(0.5)
        .tooltipText('Well preserved')
})

Glass Operation

Glass operations are used in glassworking recipes and are performed by specific items and tools

The registry for glass operations is tfc:glass_operation

Methods

  • : Marks the operation as being associated with a powder item and sets the texture used in the powder bowl
  • : Sets the minimum temperature required to apply the operation
  • : Sets the sound1 to use when the operation is applied
  • .items(items...: Holder<Item>[]): Sets the items associated with the operation, used for recipe viewers and, if a powder, powder bowls

Example

StartupEvents.registry('tfc:glass_operation', event => {
    event.create('my_operation')
        .powder('minecraft:block/cobblestone')
        .items('kubejs:stone_dust', 'kubejs:pulverized_mineral_sample')
})

Item Stack Modifier

Item stack modifiers are used by ItemStackProviders to modify a stack, typically at the completion of a recipe

The registry for item stack modifiers is tfc:item_stack_modifiers

Methods

  • : Sets the behavior of the modifier, accepts a callback with the params
    • stack: ItemStack: The original output stack, my be freely modified
    • context: StackModifierContext: The context under which the modifier is being applied, may be either default or no_random_chance
    • return: ItemStack: The modified output item stack
  • : Sets the behavior of the modifier, accepts a callback with the params
    • stack: ItemStack: The original output stack, may be freely modified
    • input: ItemStack: The input stack, should not be modified in any way
    • context: StackModifierContext: The context under which the modifier is being applies, may be either default or no_random_chance
    • return: ItemStack: The modified output item stack
  • : Sets the behavior of the modifier, accepts a callback with the params
    • stack: ItemStack: The original output stack, may be freely modified
    • input: ItemStack: The input stack, should not be modified in any way
    • context: StackModifierContext: The context under which the modifier is being applied, may be either default or no_random_chance
    • inventory: Iterable<ItemStack>: An iterable view of the inventory’s items
    • return: ItemStack: The modified output item stack

Example

StartupEvents.registry('tfc:item_stack_modifiers', event => {
    event.create('copy_cheese')
        .applicatorWithInput((stack, input, ctx) => {
            if (input.has('cheese_mod:cheese')) {
                stack.patch({
                    'cheese_mod:cheese': input.get('cheese_mod:cheese')
                })
            }
            return stack
        })
})

Spring Water

A fluid registry type

Type: tfc:spring

Creates a fluid which emits steam and bubble particles and heals the player when inside it

Inherits all the methods of the base fluid builder

Extra Methods

  • : Set the bubble particle options of the fluid via the id of a particle type or null to indicate the fluid has no bubble particles
  • : Set the bubble particle options of the fluid
  • : Set the steam particle options of the fluid via the id of a particle type of null to indicate the fluid has no steam particles
  • : Set the steam particle options of the fluid
  • : Set the health the fluid restores while a living entity is in it, defaults to 0.08

Example

StartupEvents.registry('fluid', event => {
    event.create('spring', 'tfc:spring')
        .bubbleParticle(null)
        .healingAmount(5)
})
  1. A full list of sounds can be obtained by running the command /kubejs dump_registry minecraft:sound_event in-game