Upgrades

Create machine upgrades using KubeJS

Custom Machine upgrades can be made with KubeJS script.

Create a .js file in the kubejs\server_scripts folder (ex: custom_machine_upgrades.js) and look at the example below to see all the available methods to create a Custom Machine upgrade with KubeJS.

If you're not familiar about custom machine upgrades see the wiki page.

Creating custom machine upgrade with KubeJS

Find all requirement types and targets that can be modified here.

//Use the 'cm_upgrades' event to register custom machine upgrades.
onEvent('cm_upgrades', event => {

//Create an upgrade from the item you want, ex: vanilla diamond.
//You must also specify the max amount of this upgrade the machine can accept, ex: 64.
//Syntax: event.create(Item.of("item_id"), maxAmount)
event.create(Item.of('minecraft:diamond'), 64)

//Add a machine that can accept this upgrade, you can use this method several times to add differents machines.
//You MUST specify at least one machine or the upgrade will not be created and an error will be thrown.
//Syntax: .machine("machine_id")
.machine("custommachinery:power_crusher")

//You can add a custom tooltip to the machine upgrade item.
.tooltip('Ultra booster MK3')

//Add various requirement modifiers using the methods below.

//Add an addition modifier for all input requirements of type: "requirement_id".
//"target" is for specifying  a specific property of the requirement, ex: "chance" to modify the "chance" property of requirements that have this property.
//chance is a value between 0.0 and 1.0 that define the chance of the modifier to be applied.
.addInput("requirement_id", value)
.addInput("requirement_id", value, "target")
.addInput("requirement_id", value, chance)
.addInput("requirement_id", value, "target", chance)

//Add a multiplication modifier for all input requirements of type: "requirement_id".
//"target" is for specifying  a specific property of the requirement, ex: "chance" to modify the "chance" property of requirements that have this property.
//chance is a value between 0.0 and 1.0 that define the chance of the modifier to be applied.
.mulInput("requirement_id", value)
.mulInput("requirement_id", value, "target")
.mulInput("requirement_id", value, chance)
.mulInput("requirement_id", value, "target", chance)

//Add an addition modifier for all output requirements of type: "requirement_id".
//"target" is for specifying  a specific property of the requirement, ex: "chance" to modify the "chance" property of requirements that have this property.
//chance is a value between 0.0 and 1.0 that define the chance of the modifier to be applied.
.addOutput("requirement_id", value)
.addOutput("requirement_id", value, "target")
.addOutput("requirement_id", value, chance)
.addOutput("requirement_id", value, "target", chance)

//Add a multiplication modifier for all output requirements of type: "requirement_id".
//"target" is for specifying  a specific property of the requirement, ex: "chance" to modify the "chance" property of requirements that have this property.
//chance is a value between 0.0 and 1.0 that define the chance of the modifier to be applied.
.mulOutput("requirement_id", value)
.mulOutput("requirement_id", value, "target")
.mulOutput("requirement_id", value, chance)
.mulOutput("requirement_id", value, "target", chance)
})

Examples

A gold ingot put inside the Power Crusher will double it's energy consumption but also half it's duration time.

onEvent('cm_upgrades', event => {
    event.create(Item.of('minecraft:gold_ingot'), 64)
    .machine("custommachinery:power_crusher")
    .mulInput('custommachinery:energy', 2)
    .mulInput('custommachinery:speed', 1.5)
})

Last updated