Component modifiers

Make a machine upgrade able to alter a machine component.

Component modifiers are used to tweak some properties of a machine component.

They are defined in json inside of the components property of the machine upgrade item json.

List of properties that can be modified

Component
Needs id
Target
Modified property

No

"radius"

radius

No

"capacity"

capacity

No

"max_input"

maxInput

No

"min_input"

minInput

No

"max_output"

maxOutput

No

"min_output""

minOutput

No

"capacity"

capacity

Yes

"capacity"

capacity

Yes

"max_input"

maxInput

Yes

"min_input"

minInput

Yes

"max_output"

maxOutput

Yes

"min_output"

minOutput

Yes

"capacity"

capacity

Yes

"max_input"

maxInput

Yes

"max_output"

maxOutput

Properties

The component modifier has 4 mandatory properties and 4 optional property.

Mandatory properties

Component

Name : component

Description :

The type of the componentyou want to apply the modifier to. This is the same type as the one you specify in the type property when defining the component in the machine json.

Example :

"component": "custommachinery:energy"

This modifier will be applied to the energy component.

Target

Name : target

Description :

The target property can be used to define which one of the component property you want to modify.

Example :

Modify the capacity property of the component :

"target": "capacity"
Operation

Name : operation

Description :

The mathematical operation that will be applied to the targeted component property by the modifier. The available operations are :

  • addition : The resulting value will be the sum of the base component value and the modifier value multiplied by the amount of upgrades. final_value = base_value + upgrade_modifier * upgrade_amount

  • multiplication : The resulting value will be the multiplication of the base component value and the modifier value multiplied by the amount of upgrades. final_value = base_value * upgrade_modifier * upgrade_amount

  • exponential : The resulting value will be the multiplication of the base component value and the modifier value powered to the amount of upgrades. final_value = base_value * upgrade_modifier ^ upgrade_amount

Example :

"operation": "multiplication"

The base component value (defined in the machine json) will be multiplicated by the value defined in this modifier.

Modifier

Name : modifier

Description :

The value (double) to add or multiply to the base component value. It can be positive or negative and support decimal numbers.

Example :

"modifier": 0.5

Optional properties

Id

Name : id

Description :

Some components (fluids and items in CM, more in addons) have an id property that must be specified in the modifier so it know which specific component to modify.

If a component is single (energy, experience, chunkload in CM) the id can be omitted.

Default : empty

The modifier will be applied to the single component of the specified type.

Example :

The modifier will be applied to a component with id "input1" :

"id": "input1"
Max

Name : max

Description :

A positive integer that define the maximum value obtained after applying this upgrade.

Default : POSITIVE_INFINITY

Example :

"max": 42

Whatever the modifier does, the resulting value won't be greater than 42.

Min

Name : min

Description :

A positive integer that define the minimum value obtained after applying this upgrade.

Default : NEGATIVE_INFINITY

Example :

"min": 42

Whatever the modifier does, the resulting value won't be lower than 42.

Tooltip

Name : tooltip

Description :

The tooltip that will render when a player hover any machine upgrade item in a gui while holding shift. This is a text component.

Default :

A short string that describe what the modifier does like : -50% Energy capacity

Example :

"tooltip": {
    "text": "Overclock: Double energy capacity",
    "color": "orange"
}

The tooltip will be "Overclock: Double energy capacity" in orange.

Example

A modifier that double energy capacity :

{
    "component": "custommachinery:energy",
    "target": "capacity",
    "operation": "multiplication",
    "modifier": 2
}

A modifier that add 50mB of max input in a fluid component with id "input1" :

{
    "component": "custommachinery:fluid",
    "id": "input1",
    "target": "max_input",
    "operation": "addition",
    "modifier": 50
}

Last updated