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

Part of the tfc:chisel_mode registry and can be created via the default builder in KubeJS’s StartupEvents.registry('tfc:chisel_mode', event => {}) event

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 and cancel the recipe 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 (original.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

Part of the tfc:climate_model registry and can be created via the default builder in KubeJS’s StartupEvents.registry('tfc:climate_model', event => {}) event

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
  • : A TimelessClimateValueFunction, the fog calculation of the model
    • Returned values will be clamped to [0, 1]
  • : A ClimateValueFunction, the fog calculation of the model
    • Returned values will be clamped to [0, 1]
  • : A TimelessClimateValueFunction, the average temperature, in °C, calculation of the model
  • : A TimelessClimateValueFunction, the average rainfall calculation of the model
    • Returned values will be clamped to [0, )
  • : A TimelessClimateValueFunction, the rain variance calculation of the model
    • Returned values will be clamped to [-1, 1]
  • : The calculation for if its currently thundering 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
  • : A ClimateValueFunction, the calculation for the instantaneous temperature of the model
  • :A ClimateValueFunction, the calculation for the instantaneous rainfall of the model
  • : A TimelessClimateValueFunction, the groundwater calculation of the model
    • Returned values will be clamped to [0, )

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 direction = calendarTick / 1000
            return wind.blow(Math.sin(direction), Math.cos(direction)).scale(Math.cos(direction) * 100)
        })
        .thunder((model, calendarTick) => true)
        .rainIntensity((model. calendarTick) => 2)
        .averageTemperature((model, level, pos) => {
            return pos.y > 20 ? 88 : 92
        })
        .instantaneousTemperature((model, level, pos, calendarTick, daysInMonth) => {
            let yearLength = daysInMonth * 12 * TFC.calendar.CALENDAR_TICKS_IN_DAY
            let yearPortion = (calendarTick % yearLength) / yearLength
            // +/- 7 degrees dependent on progress through year
            let currentDeviation = Math.cos(yearPortion * 2 * Math.PI) * 7
            // use the model's average temperate (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

Part of the tfc:food_trait registry and can be created via the default builder in KubeJS’s StartupEvents.registry('tfc:food_trait', event => {}) event

Methods

  • : Sets the decay modifier of the trait
    • A larger value results in a quicker expiry
    • Defaults to 1
  • : Sets the modifier of the trait as a supplier
    • Defaults to () => 1
  • : 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

Part of the tfc:glass_operation registry and can be created via the default builder in KubeJS’s StartupEvents.registry('tfc:glass_operation', event => {}) event

Methods

  • : Marks the operation as being associated with a powder item and sets the texture used in the powder bowl
  • : Sets the minimum temperature, in °C, required to apply the operation
    • Defaults to 480
  • : 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

Part of the tfc:item_stack_modifiers registry and can be created via the default builder in KubeJS’s StartupEvents.registry('tfc:item_stack_modifiers', event => {}) event

Methods

  • : The behavior of the modifier, a callback with the params
    • stack: ItemStack: The original output stack, may 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
  • : The behavior of the modifier, 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
    • return: ItemStack: The modified output item stack
  • : The behavior of the modifier, 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
        })
})

Rock Setting

Rock settings define a collection of blocks that can be used for a rock layer in TFC’s world generation

Part of the tfc:worldgen/rock_settings registry and can be created via the default builder in KubeJS’s ServerEvents.registry('tfc:worldgen/rock_settings', event => {}) event

Methods

  • : The raw block of the setting
    • Must be set
  • : The hardened block of the setting
    • Must be set
  • : The gravel block of the setting
    • Must be set
  • : The cobble block of the setting
    • Must be set
  • : The sand block of the setting
    • Must be set
  • : The sandstone block of the setting
    • Must be set
  • : The spike block of the setting
    • Requires TFC’s spike part block state property
  • : The loose rock block of the setting
    • Requires TFC’s rock count block state property
  • : The mossy loose rock block of the setting
    • Requires TFC’s rock count block state property
  • : Marks the setting as being karst
  • : Marks the setting as being mafic

Example

ServerEvents.registry('tfc:worldgen/rock_settings', event => {
    event.create('vanilla')
        .raw('minecraft:stone')
        .hardened('minecraft:deepslate')
        .gravel('minecraft:gravel')
        .cobble('minecraft:cobblestone')
        .sand('minecraft:sand')
        .sandstone('minecraft:sandstone')
        .mafic()
})

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