Materials - SilentChaos512/Silent-Gear GitHub Wiki

Introduction

Materials are used to craft compound parts. Data packs should prefer to define materials instead of parts. Unlike parts, a single material can be used to craft multiple types of parts. For example, string can be used to make both bindings and bowstrings.

A material is valid for a given part type if its stats object contains the part type. The material does not need to have stats for the part type, an empty object is valid.

See also: Part Types

Examples

An example is worth a thousand words - Some intellectual

Data packs are a vanilla Minecraft feature, so there is plenty of information and tutorials online. These examples should be more than enough to get you started, assuming you already know the basics of data packs from vanilla.

Complete Data Pack

If you need a complete example of a data pack, try the SGear-Just-Gems repo. It tends to be fairly up-to-date, and provides a good example of how the data pack should be structured. The gitignore, license, changelog, and readme, are of course not a required part of the data pack, but the pack.mcmeta, as well as the assets and data folders are.

Built-in Files

Built-in files can be found in these locations:

They are excellent examples, as they make use of most features of the material system.

Material Data and Model

Materials currently require two separate files, one with the bulk of the data, and one with rendering information. This allows for the creation of resource packs using custom textures.

One way to handle this is to pack both the data and model files in one place (folder, zip file). The copy in the data packs folder will load the data files and ignore the model files. Another copy of the pack must be loaded as a resource pack for materials to render correctly. If your materials are all black, this is likely the issue.

File Locations

  • Data: data/my_pack_namespace/silentgear_materials
  • Model: assets/my_pack_namespace/silentgear_materials

Where my_pack_namespace is the namespace of your data pack or the material you are overriding.

Specification

This is an outline of the JSON formats. Many items are described in greater detail below.

Data File

Controls most aspects of the material, except for rendering.

Parent/Child Materials

Materials can optionally have a parent. The child material(s) will inherit stats and traits from their parent. This is useful when creating color variants (ie, different types of wood). The "parent" element should be omitted entirely if the material does not have a parent.

Format

  • parent (string, optional) - The parent material ID, if there is one. See details above. Most materials should not have parents
  • availability (object)
    • tier (int) - The material's tier
    • categories (array) - List of material categories. The built-in categories can be found here, but you can also make your own by just typing in any string (not case sensitive). Categories are relatively new and not used for many things yet. One example is that curio main parts can only be crafted with metals.
    • visible (boolean) - If false, the material will be hidden in some cases
    • gear_blacklist (array) - List of gear types the material is not allowed in (see Gear Types)
  • crafting_items (object)
    • main (object) - Primary ingredient used in crafting. This can be any ingredient (like in recipes), with a simple "tag" or "item" being the most common.
    • subs (object) - Optional "part substitutes". Example: sticks for wood rods.
      • <part type> (object) - Ingredient for part substitute
  • name (object) - Display name, serialized as a text component. Typically, this will simply be "text": "My Name".
  • name_prefix (object, optional) - Display name prefix, serialized as a text component. Most materials should not use prefixes!
  • stats (object) - Stats by part type.
  • traits (object) - Traits by part type.
    • <part type> (array)
      • (object)
        • name (string) - Trait ID
        • level (int) - Trait level (> 0)
        • conditions (array, optional) - Optional trait conditions

Model File

Controls the look of gear items and compound parts made with this material. Most materials just apply colors to a small selection of existing textures, but custom textures can be used for each material.

The model keys are "part_type/gear_type" (eg, "main/all" or "tip/part"). Most often, you will use the "all" gear type. There is also a "part" gear type which can be used to customize the look of the compound part item. This is most useful for tip upgrades, which have multiple layers.

Each model key maps to a list of layers. You can use as many layers as necessary.

Texture Paths

Texture paths consist of a namespace and a suffix. The suffix will be appended to "item/<gear_type>/", where "<gear_type>" is the gear type of the item (or "part" for parts). For example, if the texture path is silentgear:main_gold, then a pickaxe would look for a PNG file at silentgear:item/pickaxe/main_gold (assets/silentgear/textures/item/pickaxe/main_gold.png).

Format

  • <model_key> (array) - List of layers for the given model key (you can add however many model keys you need)
    • (object)
      • texture (string) - Texture path of layer. See details on texture paths above.
      • color (String, optional, defaults to white) - The tint of the texture of this layer. Omit to not tint the texture. Colors are hex codes with optional leading "#", example: "#1E90FF"

Details for data files

Availability

General information, mostly related to crafting and visibility.

Tier has a big impact on synergy with other materials.

The gear blacklist can be used for greater control over crafting. One thing to note: any material with zero armor durability is automatically banned from armor, and any material with zero durability is automatically banned from tools. Example: leather.

Crafting Items

Main

As stated above this can be any recipe ingredient. In vanilla, this is typically either an item tag or an item, which is fine for most cases:

"main": {
  "tag": "forge:ingots/iron"
}

or

"main": {
  "item": "minecraft:iron_ingot"
}

Tags should be preferred in most cases for maximum compatibility with other mods.

Silent Gear also provides several ingredient types. The "exclusion ingredient" (moving to Silent Lib in the near future, with type silentlib:exclusion) is sometimes useful when working when child materials:

"main": {
  "type": "silentgear:exclusion",
  "value": {
    "tag": "minecraft:planks"
  },
  "exclusions": [
    "minecraft:acacia_planks",
    "minecraft:birch_planks",
    "minecraft:dark_oak_planks",
    "minecraft:jungle_planks",
    "minecraft:oak_planks",
    "minecraft:spruce_planks",
    "silentgear:netherwood_planks",
    "minecraft:crimson_planks",
    "minecraft:warped_planks"
  ]
}

Part Substitutes

Sometimes you just want to throw something together right? Like use that random stick in your inventory instead of crafting a rod? Part substitutes allow that. You can add part subs for any part type. Same as with the main crafting item, you can use any ingredient, including exclusion ingredients.

"subs": {
  "rod": {
    "tag": "forge:rods/iron"
  }
}

Name and Name Prefix

Display name of the material and optional prefix. Prefixes should be used sparingly! These are both serialized as text components, so you can build whatever you want with them. See this page for details: https://minecraft.gamepedia.com/Raw_JSON_text_format

The most common use cases are to either use a raw string (for data packs) or to translate text from the lang file (for mods or mod packs).

Raw text:

"name": {
  "text": "My Material's Name"
}

To translate from a lang file (be sure to add the key to your lang file...):

"name": {
  "translate": "material.my_mod_id.my_material_id"
}

Stats

The stats object should contain a key for all part types the material can be used in, even if the object is empty (no stats).

Materials provide "stat modifiers" to the parts they are used to craft. A modifier consists of a value and an operation.

List of stats: https://github.com/SilentChaos512/Silent-Gear/wiki/Stats

Operations

List of operations, in the order they are executed

  • AVG (average) - Part creates a "weighted average" of all the AVG modifiers from its materials
  • MAX (maximum) - Raises the value to this if the value is lower (mainly used by harvest level stat)
  • MUL1 (multiply base) - Multiplies the value computed from AVG and MAX (ignores other MUL1 operations)
  • MUL2 (multiply total) - Multiplies the total value (includes other MUL2 operations)
  • ADD (add/subtract) - Value is added to stat. This is done after all other operations. Tip for those not mathematically-inclined: adding a negative number is the same as subtracting.

JSON

Stats are serialized in a sort of shorthand notation. The key is the stat ID (and sometimes a gear type) and the value is the modifier. If the modifier is simply a number, then the default operation for that stat is used (usually AVG, or MAX for harvest level). If the value is an object, then it should contain a single key-value pair. The key is the operation (case insensitive) and the value is the modifier value (float).

Simple shorthand. This produces an AVG modifier with a value of 250 for the durability stat.

"durability": 250

This creates a MUL2 modifier with a value of 0.1 for melee damage. Multipliers are zero-based, so 0.1 multiples by 1.1. This modifier would be displayed as "x1.1". A value of -0.2 would multiply by 0.8 and be shown as "x0.8"

"melee_damage": {
  "mul2": 0.1
}

The keys for every stat modifier can also include a gear type in newer versions. These are entered as the stat ID and the gear type separated by a slash (attack_speed/axe, enchantability/ranged_weapon, etc.) If the gear type is omitted, the type is "all" (matches everything).

This feature can be useful if you want to allow only certain types of armor to be crafted with a material, or to fine-tune stat values for particular gear types. Just note that every modifier is displayed in the tooltip right now, so adding too many would create a huge tooltip window.

"armor_durability/helmet": 25.0
"armor/helmet": 2.0

Traits

Traits, like stats, are also specified per part type. A material does not need to have traits for any part type in order to be craftable. Traits can optionally have conditions attached to them.

Related pages:

"main": [
  {
    "name": "silentgear:malleable",
    "level": 3
  },
  {
    "name": "silentgear:magnetic",
    "level": 1,
    "conditions": [
      {
        "type": "silentgear:material_ratio",
        "ratio": 0.66
      }
    ]
  }
]
⚠️ **GitHub.com Fallback** ⚠️