Events
KubeJS TFC adds several JS events for use in your scripts
- Rock Settings
- Limiting Containers
- Register Climate Model
- Select Climate Model
- Start Fire
- Prospect
- Logging
- Animal Product
- Collapse
- Douse Fire
- Custom Food Traits
- Custom Item Stack Modifiers
- Representative Blocks
- Birthdays
- Register Interactions
- Modifying Worldgen Defaults
- Register Fauna Definitions
Rock Settings
- Type:
startup_scripts
Defines a new layer or overrides an existing layer which can be referenced from a world preset json
Method Signature
event.defineRock(
id: string,
raw: Block,
hardened: Block,
gravel: Block,
cobble: Block,
sand: Block,
sandstone: Block,
spike: @Nullable Block,
loose: @Nullable Block,
mossyLoose: @Nullable Block
)
- 1st argument: A block, the registry name of the rock
- 2nd argument: A block, to be used as the raw stone block of the rock
- 3rd argument: A block, to be used as the hardened stone block of the rock
- 4th argument: A block, to be used as the gravel block of the rock
- 5th argument: A block, to be used as the cobble block of the rock
- 6th argument: A block, to be used as the sand block of the rock
- 7th argument: A block, to be used as the sandstone block of the rock
- 8th argument: A block, to be used as the spike block of the rock, may be null
- 9th argument: A block, to be used as the loose rock block of the rock, may be null
- 10th argument: A block, to be used as the mossy loose rock block of the rock, may be null
Example
TFCEvents.rockSettings(event => {
event.defineRock('kubejs:vanilla_layer', 'minecraft:stone', 'minecraft:deepslate', 'minecraft:gravel', 'minecraft:cobblestone', 'minecraft:sand', 'minecraft:sandstone', null, null, null)
})
Limiting Containers
- Type:
server_scripts
TFC has an item size feature which it uses to limit which items can go into its containers. KubeJS TFC allows you to somewhat replicate this behavior with other mods’ containers, with some limitations
- It will only be able to apply to a container which registers a
MenuType
- It only applies to player interactions
- It only applies upon closing a menu
The basic functionality and idea is based off of a 1.12 addon that did much the same. It is licensed under the BSD License
Upon a player closing a container limited through this event, any items that are 1) in the limited slots and are not within the size limits will be removed from the container and spawned in world around the player
Method Signatures
declare class ContainerLimiterEventJS {
limit(size: Size, allowsEqual?: boolean): void
limit(size: Size, min: number, max: number, allowsEqual?: boolean): void
lowerLimit(size: Size, allowsEqual?: boolean): void
lowerLimit(size: SIze, min: number, max: number, allowsEqual?: boolean): void
}
.limit(size: Size, allowsEqual?: boolean)
: Limits the entire container to the specified size, requiring any items in it to be smaller than the provided size.allowsEqual
determines if a size ofsmall
will accept items with a size ofsmall
, defaults totrue
.limit(size: Size, min: number, max: number, allowsEqual?: boolean)
: Limits the specified slot index range to the specified size, requiring any items in it to be smaller than the provided size.allowsEqual
determines if a size ofsmall
will accept items with a size ofsmall
, defaults totrue
.lowerLimit(size: Size, allowsEqual?: boolean)
: Limits the entire container to the specified size, requiring any items in it to be larger than the provided size.allowsEqual
determines if a size ofsmall
will accept items with a size ofsmall
, defaults totrue
.lowerLimit(size: Size, min: number, max: number, allowsEqual?: boolean)
: Limits the specified slot index range to the specified size, requiring any items in it to be larger than the provided size.allowsEqual
determines if a size ofsmall
will accept items with a size ofsmall
, defaults totrue
Allows size values: tiny
, very_small
, small
, normal
, large
, very_large
, huge
Additionally, every event listener requires the name of a menu type1 in its declaration
Examples
TFCEvents.limitContainer('minecraft:generic_3x3', event => {
event.limit('large', 0, 4)
event.limit('small')
event.lowerLimit('normal', 0, 2)
})
Register Climate Model
- Type:
startup_scripts
TFC implements a system for local temperature, rainfall, fog, wind, and more. This is done through a ClimateModel
Method Signatures
declare class RegisterClimateModelEventJS {
registerClimateModel(name: string, model: Consumer<KubeJSClimateModel>): void
registerAdvancedClimateModel(name: string, model: Consumer<AdvancedKubeJSClimateModel>): void
newVec2(x: number, y: number): Vec2
getDefaultCurrentTemperatureCallback(): (LevelReader, BlockPos, long, int) => number
getDefaultAverageTemperatureCallback(): (LevelReader, BlockPos) => number
getDefaultAverageRainfallCallback(): (LevelReader, BlockPos) => number
getDefaultAirFogCallback(): (LevelReader, BlockPos, long) => number
getDefaultWaterFogCallback(): (LevelReader, BlockPos, long) => number
getDefaultWindVectorCallback(): (BlockContainerJS, long) => Vec2
}
The two register methods have the following arguments:
- 1st argument: A string, the registry name of the model
- 2nd argument: A consumer with several methods:
setCurrentTemperatureCalculation(callback)
: Sets the model’s calculation for the current temperature at a position. The callback provides aLevelReader
,BlockPos
,long
, andint
and expects a number to be returnedLevelReader
: The level readerBlockPos
: The positionlong
: The calendar tickint
: The number of days in a month
setAverageTemperatureCalculation(callback)
: Sets the model’s calculation for the average yearly temperature at a position. The callback provides aLevelReader
andBlockPos
and expects a number to be returnedLevelReader
: The level readerBlockPos
: The position
setAverageRainfallCalculation(callback)
: Sets the model’s calculation for the average yearly rainfall at a position. The callback provides aLevelReader
andBlockPos
and expects a number to be returnedLevelReader
: The level readerBlockPos
: The position
.setAirFog(callback)
: Sets the model’s calculation for fogginess at a position and time. The callback provides aLevelReader
,BlockPos
, andlong
and expects a number, in the range [0, 1], to be returnedLevelReader
: The level readerBlockPos
: The positionlong
: The calendar tick
.setWaterFog(callback)
: Sets the model’s calculation for water fogginess at a position and time. The callback provides aLevelReader
,BlockPos
, andlong
and expects a number, in the range [0, 1], to be returnedLevelReader
: The level readerBlockPos
: The positionlong
: The calendar tick
.setWindVector(callback)
: Sets the model’s calculation for the wind vector at a position and time. The callback provides aBlockContainerJS
and along
and expects aVec2
to be returnedBlockContainerJS
: The level and positionlong
: The calendar tick
.setOnWorldLoad(Consumer<ServerLevel>)
: Sets the model’s actions when the world loads. Only available for advanced models.setOnChunkLoad(callback)
: Sets the model’s actions when a chunk loads. The callback provides aWorldGenLevel
,ChunkAccess
, andChunkData
. TFC uses this to update blocks on load with climate specific modifications. Only available for advanced models
The newVec2
method creates a Vec2
for use in the wind vector callback and has the following arguments:
- 1st argument: A number, the x component of the
Vec2
- 2nd argument: A number, the z component of the
Vec2
Internally, the components of a Vec2
are labeled x
and y
, but TFC uses the y
component for the z
direction
The getDefault
methods return a callback equivalent to that used by TFC’s overworld model
Examples
TFCEvents.registerClimateModel(event => {
event.registerClimateModel('kubejs:hell', model => {
model.setCurrentTemperatureCalculation((level, pos, calendarTicks, daysInMonth) => {
return 100
})
model.setAverageTemperatureCalculation((level, pos) => {
return 100
})
model.setAverageRainfallCalculation((level, pos) => {
return 0
})
model.setAirFog((level, pos, calendarTicks) => {
return 0.25
})
model.setWaterFog((level, pos, calendarTicks) => {
return 0.25
})
model.setWindVector((block, calendarTicks) => {
return event.newVec2(1, 1)
})
})
})
Select Climate Model
- Type:
server_scripts
This event is fired when a world is loading and selecting the climate model to use
Method Signatures
declare class SelectClimateModelEventJS {
getLevel(): Level
getModel(): ClimateModel
getModelName(): ResourceLocation
setModel(model: ClimateModel): void
}
.getLevel()
: Returns the event’s level.getModel()
: Returns the events current model, defaults to a biome based model, TFC sets the overworld to use its own overworld model.getModelName()
: Returns the registry name of the event’s current modelsetModel(model: ClimateModel)
: Sets the events climate model
Example
TFCEvents.selectClimateModel(event => {
if (event.level.dimensionKey.location() == 'minecraft:nether') {
event.setModel('kubejs:hell')
}
})
Start Fire
- Type:
server_scripts
TFC uses this event for lighting fires or optionally light-able blocks. This event should be cancelled if it was handled here. If you want your items to act like Flint and Steel or Torches, add them to either the tfc:starts_fires_with_items
tag or the tfc:starts_fires_with_durability
tags.
Method Signatures
declare class StartFireEventJS {
getLevel(): Level
getBlock(): BlockContainerJS
getTargetedFace(): Direction
getEntity(): @Nullable Player
getItem(): ItemStack
isString(): boolean
}
.getLevel()
: Returns the level of the event.getBlock()
: Returns theBlockContainerJS
of the eventgetTargetedFace()
: Returns the direction of the clicked face.getEntity()
: Returns the player of the event, may be null.getItem()
: Returns the item stack used to start the fire.isStrong()
: Returns true if the event is strong
Example
// Enables the player to light a charcoal forge underneath a Create fluid tank
const CharcoalForgeBlock = Java.loadClass("net.dries007.tfc.common.blocks.devices.CharcoalForgeBlock")
const CharcoalForge = Java.loadClass("net.dries007.tfc.common.blockentities.CharcoalForgeBlockEntity")
TFCEvents.startFire(event =>{
if (event.block.id == 'create:fluid_tank' && CharcoalForgeBlock.isValid(event.level, event.block.down.pos) && event.isStrong()) {
let be = event.block.down.entity
if (be instanceof CharcoalForge && be.light(event.block.down.blockState)) {
event.cancel()
}
}
})
Prospect
- Type:
server_scripts
Whenever a prospector’s pick is used, this event is fired. It is purely informational and cannot change anything
Method Signature
declare class ProspectEventJS {
getEntity(): Player
getBlock(): Block
getProspectResult(): ProspectResult
}
.getEntity()
: Returns the player that prospected.getBlock()
: Returns the found block, or if the prospect result isnothing
, the clicked block.getProspectResult()
: Results the prospect result, can benothing
,traces
,small
,medium
,large
,very_large
, andfound
Example
TFCEvents.prospect(event => {
if (event.prospectResult == 'found') {
event.entity.give('kubejs:gift_box')
}
})
Logging
- Type:
server_scripts
This event is fired when a tree is about to be felled by an axe. Cancelling it will cause the block to be broken normally
Method Signature
declare class LoggingEventJS {
getLevel(): Level
getAxe(): ItemStack
getBlock(): BlockContainerJS
}
.getLevel()
: Returns the level.getAxe()
: Returns the item stack of the axe used.getBlock()
: Returns theBlockContainerJS
of the event
Example
TFCEvents.log(event => {
if (event.axe.hasTag('kubejs:logging_deny_list')) {
event.cancel()
}
})
Animal Product
- Type:
server_scripts
This event is fired whenever a sheep is sheared, a cow is milked, or similar action happens. Cancelling it will prevent the default behavior, which is controlled by each entity’s implementation. This event does not control if an entity can give products, it is for the sole purpose of modifying/blocking what happens when products are made
This event has a product, it may wither be an ItemStack
or a FluidStackJS
, not both. Only the non-empty type will retain modifications, attempting to change the type will void the original product
Method Signature
declare class AnimalProductEventJS {
getPlayer(): @Nullable Player
getAnimal(): Entity
getLevel(): Level
getBlock(): BlockContainerJS
getAnimalProperties(): TFCAnimalProperties
getTool(): ItemStack
getItemProduct(): ItemStack
getFluidProduct(): FluidStackJS
isItemProduct(): boolean
setItemProduct(item: ItemStack): void
setFluidProduct(fluid: FluidStackJS): void
getUses(): number
setUses(uses: number): void
}
.getPlayer()
: Returns the player that used the tool, may be null.getAnimal()
: Returns the animal the product comes from.getLevel()
: Returns the level of the event.getBlock()
: Returns theBlockContainerJS
of the event.getAnimalProperties()
: Returns the TFCAnimalProperties of the animal.getTool()
: Returns the tool used.getItemProduct()
: Returns anItemStack
, the item product, may be empty.getFluidProduct()
: Returns aFluidStackJS
, the fluid product, may be empty.isItemProduct()
: Returns true if the item product is not empty.setItemProduct(item: ItemStack)
: Sets the item product to the given item stack.setFluidProduct(fluid: FluidStackJS)
: Sets the fluid product to the given fluid.getUses()
: Returns how much wear the animal will take from this event.setUses(uses: number)
: Sets the number of uses the animal will take from this event
Example
TFCEvents.animalProduct(event => {
if (event.animalProperties.geneticSize < 10) {
event.cancel()
}
})
Collapse
- Type:
server_scripts
This event is fired whenever a collapse happens, including fake collapses
Method Signature
declare class CollapseEventJS {
getCenterBlock(): BlockContainerJS
getLevel(): Level
getRadiusSquared(): number
getSecondaryPositions(): List<BlockPos>
isFake(): boolean
}
.getCenterBlock()
: Returns theBlockContainerJS
of the center block of the collapse.getLevel()
: Returns the level of the collapse.getRadiusSquared()
: Returns the squared radius of the collapse, will be0
if the collapse is fake.getSecondaryPositions()
: Returns a list ofBlockPos
es which are the positions that will collapse.isFake()
: Returns true if the collapse is fake
Example
TFCEvents.collapse(event => {
event.secondaryPositions.forEach(pos => {
event.level.playSound(null, pos, 'minecraft:block.wood.break', 'blocks', 1.0, 1.0)
})
})
Douse Fire
- Type:
server_scripts
This event fires when a fire-dousing item is used on a block or a water potion lands
Method Signature
declare class DouseFireEventJS {
getLevel(): Level
getBlock(): BlockContainerJS
getBounds(): AABB
getPlayer(): @Nullable Player
}
.getLevel()
: Returns the event’s level.getBlock()
: Returns the event’sBlockContainerJS
.getBounds()
: Returns anAABB
representing the total effected area.getPlayer()
: Returns the player that doused the fire, may be null
Example
// replicates TFC's behavior with regular fire blocks
TFCEvents.douseFire(event => {
if (event.block.id == 'kubejs:my_burning_block') {
level.removeBlock(event.block.pos, false)
event.cancel();
}
})
Custom Food Traits
- Type:
startup_scripts
Food traits are applied to food items while in a container or after completion of a recipe and are used to effect how fast an item rots
Method Signature
declare class RegisterFoodTraitEventJS {
registerTrait(decayModifier: number, id: string): void
registerTraitWithTooltip(decayModifier: number, id: string): void
}
.registerTrait(decayModifier: number, id: string)
: Registers a food trait under the given id with the provided decay modifierregisterTraitWithTooltip(decayModifier: number, id: string)
: Registers a food trait under the given id with the provided decay modifier, this trait will have a tooltip on the item with a translation key of<id namespace>.tooltip.foodtrait.<id path>
Note: A higher decayModifier
means the food rots faster
Examples
TFCEvents.registerFoodTrait(event => {
event.registerTrait(2.0, 'kubejs:trash')
event.registerTraitWithTooltip(1.2, 'kubejs:stinky')
})
Custom Item Stack Modifiers
- Type:
startup_scripts
TFC uses item stack modifiers to, as one might imagine, modify item stacks created by recipes that support item stack providers. This event allows you to register custom modifiers with new functionality
Method Signatures
declare class RegisterItemStackModifierEventJS {
simple(id: string, applicator: Function<ItemStack, ItemStack>): void
withInput(id: string, applicator: BiFunction<ItemStack, ItemStack, ItemStack>): void
withInventory(id: string, applicator: TriFunction<ItemStack, ItemStack, Iterable<ItemStack>, ItemStack>): void
}
simple(id: string, applicator: Function<ItemStack, ItemStack>)
: Registers a modifier that is not input dependent- Id: A string, the registry id to register the modifier as
- Applicator: A function that receives and returns an
ItemStack
, the output stack. Performs the modifications to the output stack
withInput(id: string, applicator: BiFunction<ItemStack, ItemStack, ItemStack>)
: Registers a modifier that is input dependent- Id: A string, the registry id to register the modifier as
- Applicator: A bi-function that receives two
ItemStack
s, the output stack and the input stack2, and returns anItemStack
, the modified output stack. Performs the modifications to the output stack
withInventory(id: string, applicator: TriFunction<ItemStack, ItemStack, Iterable<ItemStack>, ItemStack>)
: Registers a modifier that is input dependent and has access to an iterable view of the input inventory- Id: A string, the registry id to register the modifier as
- Applicator: A tri-function that receives two
ItemStack
s, the output stack and the input stack2, and anIterable<ItemStack>
, an iterable view of the input inventory, and returns anItemStack
, the modified output stack. Performs the modifications to the output stack
Examples
TFCEvents.registerItemStackModifier(event => {
// Doubles the stack size of the output
event.simple('kubejs:double', stack => {
stack.grow(stack.count);
return stack;
})
// Copies the input stack's nbt data to the output if present
event.withInput('kubejs:copy_nbt', (output, input) => {
let { nbt } = input
if (nbt) {
output.orCreateTag.merge(nbt)
}
return output
})
// Copies all of the input stacks' nbt into the output stack
event.withInventory('kubejs_copy_all_nbt', (output, input, inventory) => {
inventory.forEach(stack => {
let { nbt } = stack;
if (nbt) {
output.orCreateTag.merge(nbt)
}
})
return nbt
})
})
Register Representative Blocks
- Type:
startup_scripts
In 1.20, TFC added a representative blocks system for prospecting, essentially allowing ores of the same type but different grades to be viewed as the same when the prospector’s pick counts the blocks nearby, this event allows you to register new representatives
Method Signature
event.register(representative: Block, blocks: Block[]): void
- 1st argument: The block to represent the other blocks
- 22nd argument: An array of blocks, to be represented by the first argument when prospecting
Example
TFCEvents.prospectRepresentative(event => {
event.register('minecraft:clay', ['tfc:clay/loam', 'tfc:clay/silt', 'tfc:clay/sandy_loam', 'tfc:clay/silty_loam'])
})
Modify Birthdays
- Type:
startup_scripts
TFC has an easter egg in its calendar screen where on certain dates it will show someone’s birthday, this event allows you to add and remove names from the list of birthdays
Method Signatures
declare class BirthdayEventsJS {
add(month: Month, day: number, name: string): void
remove(month: Month, day: number): void
removeAll(): void
}
.add(month: Month, day: number, name: string)
: Adds a birthday to the given month and day.remove(month: Month, day: number)
: Removes the birthday on the given month and day if there is one.removeAll()
: Removes all birthdays
Example
TFCEvents.birthdays(event => {
event.add('august', 4, 'Barack Obama')
})
Register interactions
- Type:
startup_scripts
TFC has a custom system for performing certain interactions with items, most notably knapping, this event exposes the ability to create your own interactions
Method Signatures
declare class RegisterInteractionsEventJS {
interaction(ingredient: Ingredient, targetBlocks: boolean, targetAir: boolean, action: OnItemUseAction): void
interaction(ingredient: Ingredient, targetAir: boolean, action: OnItemUseAction): void
interaction(ingredient: Ingredient, action: OnItemUseAction): void
blockItemPlacement(item: Item, block: Block): void
}
.interaction(ingredient: Ingredient, targetBlocks: boolean, targetAir: boolean, action: OnItemUseAction)
: Registers the given ingredient for the provided action, the boolean params determine if blocks and air should be valid targets.interaction(ingredient: Ingredient, targetAir: boolean, action: OnItemUseAction)
: Registers the given ingredient for the provided action, the boolean param determines if air is a valid target, blocks default to being a valid target.interaction(ingredient: Ingredient, action: OnItemUseAction)
: Registers the given ingredient for the provided action, defaulting to blocks being valid targets and air not.blockItemPlacement(item: Item, block: Block)
: Registers a block placement for the given item, placing the given block
Example
TFCEvents.registerInteractions(event => {
event.interaction('minecraft:diamond', (stack, ctx) => {
// Do what ever you want when a diamond is right clicked
return 'pass'
})
})
OnItemUseAction
The basis of an interaction, a callback that takes a ItemStack
, the item in the hand, and a UseOnContext
, the context of the event, and returns an InteractionResult
. It has the following method signature:
apply(stack: ItemStack, context: UseOnContext): InteractionResult
Modifying Worldgen defaults
Type: startup_scripts
Allows for editing the default settings of TFC chunk generator at world creation, including editing the rock layers
Method Signatures
declare class ModifyDefaultWorldgenSettingsEventJS {
flatBedrock(flat?: boolean): void
setSpawnDistance(i: number): void
setSpawnCenterX(i: number): void
setSpawnCenterZ(i: number): void
setTemperatureScale(i: number): void
setTemperatureConstant(f: number): void
setRainfallScale(i: number): void
setRainfallConstant(f: number): void
setContinentalness(f: number): void
setGrassDensity(f: number): void
addRock(rock: RockSettings, name: string, bottom: boolean): void
addRockFromId(id: string, name: string, bottom: boolean): void
getRock(name: string): RockSettings
getRockNames(): Set<string>
removeRock(name: string): void
addToBottom(name: string): void
removeFromBottom(name: string): void
defineLayer(id: string, rockMap: Map<string, string>): void
removeLayer(layerId: string): void
getLayerIds(): List<string>
cleanSlate(): void
addOceanFloorLayer(name: string): void
removeOceanFloorLayer(name: string): void
getOceanFloorLayers(): List<string>
addLandLayer(name: string): void
removeLandLayer(name: string): void
getLandLayers(): List<string>
addVolcanicLayer(name: string): void
removeVolcanicLayer(name: string): void
getVolcanicLayers(): List<string>
addUpliftLayer(name: string): void
removeUpliftLayer(name: string): void
getUpliftLayers(): List<string>
}
Climate Modifiers
flatBedrock(flat?: boolean)
: Sets if the world should have flat bedrock, defaults tofalse
, calling without any arguments sets it totrue
setSpawnDistance(i: number)
: Sets the distance from the spawn center that players may spawn, defaults to 4000setSpawnCenterX(i: number)
: Sets the spawn center on the x-coordinate, defaults to 0setSpawnCenterZ(i: number)
: Sets the spawn center on the z-coordinate, defaults to 0setTemperatureScale(i: number)
: Sets the temperature scale of the world, the distance from pole-to-pole, defaults to 20000setTemperatureConstant(f: number)
: Sets the relative constant temperature of the world, defaults to 0setRainfallScale(i: number)
: Sets the rainfall scale of the world, the distance from peak to peak, defaults to 20000setRainfallConstant(f: number)
: Sets the relative constant temperature of the world, defaults to 0setContinentalness(f: number)
: Sets the proportion of the world that is land instead of water, defaults to 0.5. A value of 0 translates to -100% on the world creation screen and 1 translates to +100%setGrassDensity(f: number)
: Sets the grass density of the world, defaults to 0.5. A value of 0 translates to -100% on the world creation screen and 1 translates to +100%
Rock Layer Settings Modifiers
TFC’s worldgen is primarily based around rocks, layers, and layer types3. There are 5 layer types, bottom
, ocean_floor
, land
, volcanic
, and uplift
, the bottom
layer type is unique in that it only possesses rocks, the rest only possess layers. Layer types determine which geologic environment a rock/layer will generate. Every layer type must have at least one entry. Layers and rocks are user defined and are referenced by name. Rocks define which blocks are placed where, see registering them for more about that. Layers are a list of rock-layer pairs, associating a rock with the layer that should generate underneath it
addRock(rock: RockSettings, name: string, bottom: boolean)
: Adds the given rock to the generator’s pool of available rocks- Rock: the
RockSettings
to add - Name: The name which the rock can be referenced by
- Bottom: If the rock should be added to the ‘bottom’ layer of the world
- Rock: the
addRockFromId(id: string, name: string, bottom: boolean)
: Adds the given rock to the generator’s pool of available rocks- Id: the registered id of the
RockSettings
to add - Name: The name which the rock can be referenced by
- Bottom: If the rock should be added the the ‘bottom’ layer of the world
- Id: the registered id of the
getRock(name: string)
: Returns theRockSettings
with the given namegetRockNames()
: Returns a set of the names of all the rocks currently in the generator’s pool of rocksremoveRock(name: string)
: Removes the provided rock from the generator’s pool of available rocks and any references to itaddToBottom(name: string)
: Adds the given rock to the ‘bottom’ layerremoveFromBottom(name: string)
: Removes the given rock from the ‘bottom’ layerdefineLayer(id: string, rockMap: Map<string, string>)
: Defines a new layer- Id: the name of the layer to add
- RockMap: A map of rock names to layer names, associates a rock with the layer that will generate underneath it
removeLayer(layerId: string)
: removes the given layer from the generatorgetLayerIds()
: returns a list of the names of all layers currently in the generator’s pool of layerscleanSlate()
: Removes all rocks and layers from the generatoraddOceanFloorLayer(name: string)
: Adds the given layer to the ‘ocean_floor’ layer typeremoveOceanFloorLayer(name: string)
: removes the given layer from the ‘ocean_floor’ layer typegetOceanFloorLayers()
: Gets the layers currently in the ‘ocean_floor’ layer typeaddLandLayer(name: string)
: Adds the given layer to the ‘land’ layer typeremoveLandLayer(name: string)
: removes the given layer from the ‘land’ layer typegetLandLayers()
: Gets the layers currently in the ‘land’ layer typeaddVolcanicLayer(name: string)
: Adds the given layer to the ‘volcanic’ layer typeremoveVolcanicLayer(name: string)
: Removes the given layer from the ‘volcanic’ layer typegetVolcanicLayers()
: Gets the layers currently in the ‘volcanic’ layer typeaddUpliftLayer(name: string)
: Adds the given layer to the ‘uplift’ layer typeremoveUpliftLayer(name: string)
: Removes the given layer from the ‘uplift’ layer typegetUpliftLayers()
: Gets the layers that are currently in the ‘uplift’ layer type
Example
TFCEvents.defaultWorldSettings(event => {
event.rainfallScale = 4000
event.continentalness = -3.5
event.defineLayer('my_cool_layer', {
granite: 'my_cool_layer',
dolomite: 'my_cool_layer',
diorite: 'felsic'
})
event.addLandLayer('my_cool_layer')
})
Register Fauna Definitions
Type: startup_scripts
Allows for registering a fauna definition for any entity type
Method Signatures
event.replace(entityType: EntityType<?>, suffix?: String, placementType: SpawnPlacements$Type, heightmap: Heightmap$Types): void
event.and(entityType: EntityType<?>, suffix?: String, placementType: SpawnPlacement$Type, heightmap: Heightmap$Types): void
event.or(entityType: EntityType<?>, suffix?: String, placementType: SpawnPlacement$Type, heightmap: Heightmap$Types): void
.replace(entityType: EntityType<?>, suffix?: String, placementType: SpawnPlacements$Type, heightmap: Heightmap$Types)
: Registers a new fauna definition for the entity type and overwrites any spawn conditions it may have had before- EntityType: The entity type to register the fauna for
- Suffix: See below
- PlacementType: See below
- Heightmap: See below
.and(entityType: EntityType<?>, suffix?: String, placementType: SpawnPlacement$Type, heightmap: Heightmap$Types)
: Registers a new fauna definition for the entity type and ANDs any pre-existing spawn conditions it may have had before with the fauna’s rules- EntityType: The entity type to register the fauna for
- Suffix: See below
- PlacementType: See below
- Heightmap: See below
.or(entityType: EntityType<?>, suffix?: String, placementType: SpawnPlacement$Type, heightmap: Heightmap$Types)
: Registers a new fauna definition for the entity type and ORs any pre-existing spawn conditions it may have had before with the fauna’s conditions, including other fauna definitions- EntityType: The entity type to register the fauna for
- Suffix: See below
- PlacementType: See below
- Heightmap: See below
suffix
: An optional suffix to the autogenerated fauna id, by default just the entity type’s id. Suffixed to the end of the id with a/
. May be null or simply not presentplacementType
may be any of'on_ground'
,'in_water'
,'no_restrictions'
, or'in_lava
’ and determines where the entity may be placedheightmap
may be any of'world_surface_wg'
,'world_surface'
,'ocean_floor_wg'
,'ocean_floor'
,'motion_blocking'
, or'motion_blocking_no_leaves'
. See the Minecraft Wiki for an explanation for what each of these mean
Example
TFCEvents.registerFaunas(event => {
event.register('minecraft:pig', 'on_ground', 'world_surface_wg')
})