modules - mickelus/tetra GitHub Wiki

screenshot of modules in UI

Work in progress

Modular items have a set of slots which can hold modules. There are major and minor module slots, the item defines which are which. Major modules are denoted by the larger diamond shaped borders, major modules can hold improvements.

Modules have multiple variants (often based on different materials), it's the variants that provide stats and effects.

Most modules can only go in a single slot, but the modules used for the heads of double headed tools or the slots for the belt can fit into several. Data-wise those are considered as a single module but under the hood those are duplicated into different modules for each slot.

Module data is placed in the modules folder and is typically structured like this: tetra/modules/<item>/<module>, e.g. tetra/modules/sword/basic_blade.json for basic blades.

Example data

tetra/modules/sword/example_blade.json

{
    "replace": false,
    "slots": ["sword/blade"],
    "type": "tetra:basic_major_module",
    "improvements": [
        "tetra:enchantment/sharpness",
        "tetra:sword/blade/shared",
        "tetra:shared/"
    ],
    "variants": [
        {
            "key": "example_blade/iron",
            "attributes": {
                "generic.attack_speed": -1.9,
                "generic.attack_damage": 5
            },
            "effects": {
                "sweeping": 1
            },
            "tools": {
                "cut": [1, 2]
            },
            "durability": 200,
            "glyph": {
                "textureX": 46,
                "textureY": 16,
                "tint": "ffffff"
            },
            "models": [{ "location": "tetra:items/module/sword/blade/example/metal" }]
        },
        {
            "key": "example_blade/oak",
            "attributes": {
                "generic.attack_speed": -1.3,
                "generic.attack_damage": 3
            },
            "effects": {
                "sweeping": 1
            },
            "tools": {
                "cut": [1, 1.2]
            },
            "durability": 120,
            "glyph": {
                "textureX": 46,
                "textureY": 16,
                "tint": "9d804e"
            },
            "models": [{
                "tint": "bf934b",
                "location": "tetra:items/module/sword/blade/example/crude"
            }]
        }
    ]
}

Module data format

replace

If set to true this resource will replace others with the same location, rather than them being merged.

slots required

An array of slots that this module can go into, has to contain at least one value.

slotSuffixes

Used when modules should have different keys depending on slot (e.g. pickaxe head keys end with "_left" or "_right" so that different textures can be used depending on the slot. If there's more than one slot then this has to have the same number of entries as the slots field.

type

Defines the type of the module, see Module types

renderLayer

Defines the layer that this module's textures should render on, possible values: LOWEST, LOWER, LOW, BASE, HIGH, HIGHER, HIGHEST, default: BASE

tweakKey

Reference to a tweak resource, use if this module should have variants or improvements that should have tweakable stats

improvements

An array of references to improvement resources that this module should be able to hold, only applicable for major modules

variants required

An array of module variants, a module that can only be crafted in a single way (like a scanner or the stonecutter) would have a single variant. Variants have the following fields:

key required

Identifier for the variant, should be unique

category

The category is used when grouping variants in the holosphere

Default value: "misc"

durability

The durability that the module provides, called item damage in vanilla minecraft. A higher value makes the item last longer before it needs repairs. Swords lose one point of durability when hitting entities and two points when destroying blocks, for tools it's the opposite.

Default value: 0

durabilityMultiplier

Multiplies the durability of the item.

Default value: 1

integrity

Integrity is tetras way of balancing items. Some modules provide integrity while some have an integrity cost, if an upgrade would cause the cost to exceed the available integrity the upgrade would not be possible. A negative value represents an integrity cost while positive values cause the module to provide integrity.

Default value: 0

magicCapacity

The magic capacity determines how many enchantments a module can hold before it starts to suffer from destabilization effects. A higher value is better. Only relevant for major modules since those are the only ones that can hold enchantments :)

Default value: 0

attributes

A map of attributes, used to add damage, armor, toughness, attack speed or reach/range to an item.

The iron blade variant in this example would add 5 damage and reduce attack speed by 0.2

{
    "key": "basic_blade/iron",
    "attributes": {
        "generic.attack_damage": 5,
        "generic.attack_speed": -0.2
    }
}

Attributes prefixed with ** or * will act as multipliers, it works like this:

  • ** multiplies the attribute for the wielding entity (attributes gained from the item plus attributes gained from other sources such as armor or potions), stacks multiplicatively
  • *multiplies the attribute for the module (module, improvements and tweaks), stacks additively This is the multiply_base and multiply behaviour for attributes in vanilla minecraft (read more here), but tetra captures all modifiers with the multiply_base operation to multiply add modifiers internally before passing them on to the wielding entity.

The improvement in this example would increase the damage of the module it's added to by 10% and reduce the attack speed of the wielder by 20%

{
    "key": "blade/jagged",
    "level": 1,
    "attributes": {
        "*generic.attack_damage": 0.1,
        "**generic.attack_speed": -0.2
    }
}

Tetra passes on all attributes for handheld items (swords, double headed, single headed and shields) to the wielding entity when the item is held in the mainhand or the offhand, except for generic.attack_damage which is only passed from the mainhand item.

tools

Adds tool capabilities for the item. Efficiency is optional, a single number can be passed instead of an array when omitting the efficiency.

This example would add level 1 hammering capabilities and level 1 cutting capabilities with an efficiency of 20.

{
    "key": "precision_axe/iron",
    "tools": {
        "hammer": 1,
        "cut": [1, 20]
    }
}

effects

Adds item effects for the item. Efficiency is optional, a single number can be passed instead of an array when omitting the efficiency. Check this list for available effects.

This example would give a 20% chance to stun for 1.5 seconds when attacking with the item.

{
    "key": "precision_axe/iron",
    "effects": {
        "stun": [20, 1.5]
    }
}

glyph

A map that defines which glyph is used to represent this module in the workbench gui, and how it's to be tinted. Has four fields:

  • textureX: x coordinate within the texture sheet, default: 0
  • textureY: y coordinate within the texture sheet, default: 0
  • textureLocation: a resource location pointing to the texture sheet that the glyph is to be taken from, has to include .png in the end since it's a gui texture :o, default: "tetra:textures/gui/glyphs.png"
  • tint**: A hexadecimal string used to tint the glyph, default: ffffff (white/untinted)

Some example data reference hardcoded tint values (e.g. "iron_glyph"), those will be removed so use hex values instead.

This example would use the glyph at x:224, y:32 in the texture "tetra:textures/gui/my_custom_glyphs.png" with a red tint.

{
    "glyph": {
        "textureX": 224,
        "textureY": 32,
        "textureLocation": "tetra:textures/gui/my_custom_glyphs.png",
        "tint": "ff0000"
    }
}

models

Material variants

It's possible to dynamically add module variants based on material data, how that works is described in more detail on the materials page.

Module types

  • tetra:basic_module: Used by most minor modules, e.g. sword guards or bow risers
  • tetra:multi_module: Used by most major modules, e.g. sword blades or bowstrings
  • tetra:basic_major_module: Used for minor modules that can go in multiple slots, no current uses
  • tetra:multi_major_module: Used for major modules that can go in multiple slots, e.g. double headed tool heads
  • tetra:toolbelt_module: Used for belt attachment modules
⚠️ **GitHub.com Fallback** ⚠️