Skip to content

Machine Upgrade Items

Frinn38 edited this page Jul 30, 2021 · 2 revisions

Machine upgrades are items that can be used to change the behaviours of a custom machine recipe while it's processing.

You can change the properties of almost every requirements, for example make a machine consume 2x more FE but also half the processing time.

You can define any item registered in the game as machine upgrade.

The defined item will works as a machine upgrade only if placed in an item component slot with variant property set to upgrade. See Item Component Variant for more infos.

The machine upgrade must be defined in a json file placed in a datapack, such as machines and recipes json.

The path of the machine upgrade json file must be : [datapack_name]/data/[namespace]/upgrades/my_upgrade.json You can use whatever you want as [datapack_name], [namespace] and json file name but it MUST be under the upgrades folder. Subfolders are allowed.

Inside the upgrade json file you have to define 3 properties to make the upgrade works and there is also 2 optional properties.

item (Mandatory)

Description : The item you want to use as upgrade, you can define only one item per upgrade json file (but you can make as many file as you want). The item can be any vanilla or modded item.

Example : "item": "minecraft:diamond" The upgrade will be a vanilla diamond.

machines (Mandatory list)

Description : A list of custom machines where this upgrade is allowed.

Example : "machines": ["custommachinery:magic_spawner", "custommachinery:power_crusher"]

Note : The [] are required, even if there is only 1 machine in the list.

modifiers (Mandatory list)

Description : A list of requirements modifiers. These are used to define how the upgrade will influence the recipe processing.

Example :

"modifiers": [
    {
        "requirement": "custommachinery:energy",
	"mode": "input",
	"operation": "multiplication",
	"modifier": 0.5
    }
]

This modifier will half the energy input required to process the recipe. See more about requirement modifiers in the following section.

max (Optional)

Description : Not implemented yet

tooltip (Optional)

Description : The tooltop that will render when a player hover any machine upgrade item in a gui.
This is a json object with a mandatory text property which define the text to render and some formating properties.
The text property can be a lang key.

Default :

{
    "text": "custommachinery.upgrade.tooltip",
    "color": "aqua"
}

Example that show all the possible text formatting options:

"tooltip": {
    "text": "Here goes some tooltip !",
    "bold": true,
    "italic": true,
    "underlined": true,
    "strikethrough": true,
    "obfuscated": true,
    "color": "#164561",
    "font": "minecraft:default"
}

Requirement Modifier

Requirement modifiers are used to tweak some properties of a recipe requirement.

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

To define a requirement modifiers, you must specify 4 mandatory properties and 2 optional property.

requirement (Mandatory)

Description : The type of the requirement you want to apply the modifier to. This is the same type as the one you specify in the type property when defining the requirement in th recipe json.

Example : "requirement": "custommachinery:energy" This modifier will be applied to the energy requirement.

Note : The recipe processing speed can also be modified with this system. Use custommachinery:speed to target it.

mode (Mandatory)

Description : The mode of the requirement you want to apply the modifier to. It can be either input or output but not both.

Example : "mode": "input" This modifier will be applied only on input energy requirements.

operation (Mandatory)

Description : The mathematical operation that will be applied to the targetted requirement property by the modifier. The available operations are :

  • addition : The resulting value will be the sum of the base requirement value and the modifier value.
  • multiplication : The resulting value will be the multiplication of the base requirement value and the modifier value.

Example : "operation": "multiplication"

modifier (Mandatory)

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

Example : "modifier": 0.5

target (Optional)

Description : Some requirement have more than one value that can be modified. In that case the target property can be used to define which one of the requirement property you want to modify. For example some requirement have a chance property that can be modified by the upgrade, simply use "target": "chance" to target the chance property instead of the default one.

Default : empty The modifier will be applied to the default property of the defined requirement.

Example : In case of the Entity Requirement the default property is amount so if you want to modify the radius property you can do : "target": "radius"

chance (Optional)

Description : The chance the modifier will be applied to the requirement, this have nothing to do with the chance property some requirement have and will be applied independantly. This value must be between 0 and 1 where 0 is 0% chance to be applied and 1 is 100% chance.

Default : 1 The modifier have 100% chance to be applied on the requirement.

Example : "chance": 0.4 The modifier have 40% chance to be applied on the requirement.

Example

The machine upgrade json below make a vanilla diamond item half the recipe duration in the Custom Machinery Power Crusher included in the test datapack.

{
    "item": "minecraft:diamond",
    "machines": ["custommachinery:power_crusher"],
    "modifiers": [
        {
	    "requirement": "custommachinery:speed",
	    "mode": "input",
	    "operation": "multiplication",
	    "modifier": 0.5
	}
    ]
}
Clone this wiki locally