materials - mickelus/tetra GitHub Wiki

screenshot of material detail UI

Some properties can now be defined per material and then references from modules and schematics.

Material data is organized in folders based on the type of the material (e.g. wood, metal or skin) with one file/resource per material. Modules and schematics can then reference a specific material (e.g. wood/spruce or misc/bone) or all materials of a type (e.g. wood or metal) and defined how the properties of those materials should be applied for the module.

Example data

Here's the material definition for oak:

{
    "key": "oak",
    "category": "wood",
    "primary": "3",
    "secondary": "4",
    "tertiary": "6",
    "durability": "5.2",
    "integrityCost": "1",
    "integrityGain": "4",
    "magicCapacity": "90",
    "toolLevel": "1",
    "toolEfficiency": "2",
    "tints": {
        "glyph": "oak_glyph",
        "texture": "oak"
    },
    "textures": ["crude", "default"],
    "material" : {
        "tag": "minecraft:planks"
    },
    "requiredTools": {
        "axe": 1
    }
}

And here's diamond:

{
    "key": "diamond",
    "category": "gem",
    "primary": "6",
    "secondary": "7",
    "tertiary": "0",
    "durability": "156.1",
    "integrityCost": "2",
    "integrityGain": "2",
    "magicCapacity": 60,
    "toolLevel": "4",
    "toolEfficiency": "8",
    "tints": {
        "glyph": "diamond_glyph",
        "texture": "diamond"
    },
    "textures": ["shiny", "crude", "default"],
    "material" : {
        "item": "minecraft:diamond"
    },
    "improvements": {
        "arrested": 0
    },
    "requiredTools": {
        "hammer": 3
    }
}

Data format

Each material json file contain a single json object with the following fields:

key

Identifier for the material, will be used as suffix for module variants from this material

category optional

Applied to all module variants from this material, default: "misc"

primary

Multiplier for primary attributes & effects. Should represent hardness, sharpness or the ability to shape this material into something with a hard/sharp edge

secondary

Multiplier for secondary attributes & effects. Should represent material density, rigidity or weight, how much kinetic energy does this carry as it's swung

tertiary

Multiplier for tertiary attributes & effects. Should represent flexibility or tensile strength(?), how fast does this material spring back when bent

durability

Durability base, modules use this to determine flat or multiplier durability bonuses

integrityGain

Multiplier for modules that provide integrity

integrityCost

Multiplier for modules that consume integrity

magicCapacity

The magic capacity of major modules variants made from this material

toolLevel

Modules that provide tools that vary based on material use this to determine the level of the tools

toolEfficiency

Modules that provide tools that vary based on material use this to determine the efficiency of the tools

attributes optional

All modules made from this material will provide these attributes, e.g. mystical world amethyst items always provide luck

effects optional

All modules made from this material will provide these effects, e.g. mana steel should always provide mana repair

improvements optional

All major modules made from this material will have these improvements, e.g. major diamond should always have the arrested improvement

tints

  • texture: Hexadecimal string for tinting of textures, can reference item colors
  • glyph: Hexadecimal string for tinting glyphs in the workbench UI, can reference item colors

textures

An array of texture suffixes that this material would prefer to use, the first one matching a texture provided by the module will be used

textureOverride

Force all modules variants of this material to use the first texture regardless if it matches one provided by the module (not sure about this, it would break when tetra updates and for pack<->pack compat)

material

Defines which items are required as materials for crafting module variants of this material, either tag or item is required

  • tag: Reference to an item tag
  • item: Reference to an item
  • count: (optional) Multiplier for the number of items required, default: 1

requiredTools

Defines the tools (and which levels) that are required to craft module variants of this material, schematics may add additional tools and multiply/offset the levels provided here

For determining the properties I've used:

  • sword/pickaxe durability to determine durability
  • enchantability multiplied by 6 for magic capacity (multiplier fit well with cost of enchantments)
  • vanilla harvest level values +1 for tool levels (note that tool level is subtracted by 1 before passed back to vanilla as harvest level)
  • vanilla harvest efficiency for tool efficiency
  • sword damage -1 for the primary multiplier

The remaining properties are based on research on the material and some balancing, and just feeling ¯\_(ツ)_/¯

Structure

Vanilla materials are grouped/structured like this:

├── fabric
│   └── wool.json
├── fibre
│   ├── phantom_membrane.json
│   ├── string.json
│   ├── twisting_vine.json
│   ├── vine.json
│   └── weeping_vine.json
├── gem
│   ├── diamond.json
│   └── emerald.json
├── metal
│   ├── gold.json
│   ├── iron.json
│   └── netherite.json
├── misc
│   ├── blaze_rod.json
│   ├── bone.json
│   └── end_rod.json
├── scale
│   └── turtle_scute.json
├── skin
│   ├── hide.json
│   └── leather.json
├── stone
│   ├── andesite.json
│   ├── blackstone.json
│   ├── diorite.json
│   ├── flint.json
│   ├── granite.json
│   ├── obsidian.json
│   └── stone.json
└── wood
    ├── acacia.json
    ├── birch.json
    ├── crimson.json
    ├── dark_oak.json
    ├── oak.json
    ├── spruce.json
    └── warped.json

Module material variant entry

Module variants that contain a materials field are treated as material entries. Multiple material variant entries may be provided per module, useful for when different types of materials should have their properties applied slightly different (e.g. axes). Material variant entries contain the following fields:

materials

A list of resource locations referencing specific materials or types of materials

key

Combined with the material key to yield the key for each variant

attributes optional

Static attributes, used to offset attributes or to provide flat modifiers, e.g. attack speed for basic blades or pickaxes

durability optional

Static durability, used to offset the durability extracted from the material

durabilityMultiplier optional

Static durability multiplier, used to offset the durability extracted from the material

integrity optional

Static integrity, used to offset the integrity extracted from the material

tools optional

Static tools that should not base the level/efficiency on the material, e.g. cut for basic blades

effects optional

Static effects that should not base the level/efficiency on the material, e.g. sweeping for basic blades

models optional

Static models that should not be suffixed or tinted based on material

magicCapacity optional

Static magic capacity, can be used to offset to the magic capacity provided by the material

extract

An object with fields that defines which (and how) properties should be extracted from the material

primaryAttributes optional

Attributes that will be multiplied by the material's primary multiplier

secondaryAttributes optional

Attributes that will be multiplied by the material's secondary multiplier

tertiaryAttributes optional

Attributes that will be multiplied by the material's tertiary multiplier

primaryEffects optional

Effects that will be multiplied (both level and efficiency) by the material's primary multiplier

secondaryEffects optional

Effects that will be multiplied (both level and efficiency) by the material's secondary multiplier

tertiaryEffects optional

Effects that will be multiplied (both level and efficiency) by the material's tertiary multiplier

durability optional

Defines durability that should be based on the material's durability factor

durabilityMultiplier optional

Defines a durability multiplier that should be based on the material's durability factor, skipped if not provided

integrity optional

Defines integrity gain/cost that should be based on the material's integrity factor. Decimal value are allowed, the result will be rounded off to the nearest integer

magicCapacity optional

Defines how much of the material's magic capacity that should apply for this module. Typically a value of 1 should be used for modules that are enchantable, otherwise omitted

tools optional

Tools that should be based the level/efficiency on the material, e.g. pickaxe for pickaxes

glyph

The glyph for the module, the tint from the material will be used

models optional

Module models that should be tinted and suffixed based on the material

availableTextures optional

Texture suffixes available for model textures, the first material texture that matches one of the available textures will be used, if none matches the first of the available textures will be used

The extracted durability multiplier is currently a bit broken, the durability of diamond is 30 times the durability of wood. Without a flat modifier a module/improvement that is balanced so that wood provides a 5% durability increase would then have the diamond variant provide a 150% durability increase.

Example json

Below is the material variant entry for the basic pickaxe:

{
    /* ... */
    "variants": [
        {
            "materials": ["tetra:metal/", "tetra:stone/", "tetra:wood/", "tetra:gem/", "tetra:misc/bone"],
            "key": "basic_pickaxe/",
            "attributes": {
                "generic.attack_damage": -2,
                "generic.attack_speed": -0.2
            },
            "tools": {
                "pickaxe": -1
            },
            "durability": -10,
            "extract": {
                "primaryAttributes": {
                    "generic.attack_damage": 1
                },
                "tools": {
                    "pickaxe": [1, 0.8333]
                },
                "durability": 0.5,
                "integrity": -1,
                "magicCapacity": 1,
                "glyph": {
                    "textureX": 176
                },
                "availableTextures": ["metal", "crude"],
                "models": [{ "location": "tetra:items/module/double/head/basic_pickaxe/" }]
            }
        },
        /* ... */
    ]
}

Double pickaxe heads gain 1 harvest level from a synergy bonus so there's a flat reduction of -1 pickaxe level for all variants and a 1x pickaxe level multiplier based on the material.

Here's the material variant entry for the heavy blade. Its damage is based on both the primary and the secondary attribute.

{
    /* ... */
    "variants": [
        {
            "materials": ["tetra:metal/", "tetra:stone/", "tetra:wood/"],
            "key": "heavy_blade/",
            "attributes": {
                "generic.attack_speed": -1.2
            },
            "durability": -20,
            "integrity": -1,
            "extract": {
                "primaryAttributes": {
                    "generic.attack_damage": 0.8
                },
                "secondaryAttributes": {
                    "generic.attack_damage": 0.4,
                    "generic.attack_speed": -0.2
                },
                "tools": {
                    "cut": [1, 2]
                },
                "durability": 1,
                "integrity": -1,
                "magicCapacity": 1,
                "glyph": {
                    "textureX": 48
                },
                "availableTextures": ["metal", "shiny", "grainy", "crude"],
                "models": [{ "location": "tetra:items/module/sword/blade/heavy/" }]
            }
        },
        /* ... */
    ]
}

Schematic material outcome entry

Schematic outcomes that contain a materials field are treated as material entries, they contain the following fields:

materials

A list of resource locations referencing specific materials or types of materials

moduleKey

Reference to the module that should be crafted

moduleVariant

Combined with the material key to yield the key for each variant

countOffset optional

Offsets the number of required materials

countFactor optional

Multiplies the number of required materials. Decimal values allowed, the result is rounded to the nearest integer

toolOffset optional

Offsets the level for required tools defined by the material

toolFactor optional

Multiplies the level for required tools defined by the material. Decimal values allowed, the result is rounded to the nearest integer

requiredTools optional

Adds additional tool requirements in addition to those required by the material

Example json

This is the outcomes array for the basic blade:

{
    /* ... */
    "outcomes": [
        {
            "materials": ["tetra:wood/", "tetra:stone/", "tetra:metal/", "tetra:gem/", "tetra:misc/bone"],
            "moduleKey": "sword/basic_blade",
            "moduleVariant": "basic_blade/"
        }
    ]
}

It's possible to mix material entries with the old approach when defining module variants and schematic outcomes.

This should reduce the need for repetition when creating content, make it possible for datapacks/mod compat to work together and make material stats more consistent between modules.