Skip to content

Texture Generators (Data Packs)

KnightMiner edited this page Jan 19, 2022 · 2 revisions

Texture generators are a feature in Tinkers' Construct for mass-producing textures from a given set of base textures. While they may not end up as high quality as artist made textures, they are much easier for modders and artists alike.

They are two ways to run the texture generators:

  • Datagen: can be set up similar to data generators for tags or recipes. This method is ideal for modders to use. See Texture Generators (Modders) for more info.
  • Command: this method is much less ideal in an addon, designed mainly for datapacks and resource packs. This page covers the specifics.

Basics

The command when run will take a bit of time based on the number of textures required to generate. It will automatically generate a resource pack containing textures for all registered parts in all registered materials. For players, you can simply use this resource pack right after generating, though it may be desirable to create a zip file resource pack if you plan to distribute it.

Syntax

/tconstruct generate_part_textures <filter> [<mod_id>|<material>]

Arguments:

  • <filter>: can be either all or missing:
    • all: Causes the command to generate textures for every material and part combination. This will generate duplicates to many already generated textures from Tinkers' Construct and addons, so the main use is for the sake of resource packs that remake the base textures for each tool.
    • missing: Causes the command to only generate textures that are not currently included. This is ideal to fill in the gaps with material textures when new tools are added, or vice versa.
  • <mod_id>: If specified, will only generate textures for materials under the given domain.
  • <material>: If specified, will only generate textures for the given material.

By default, the command runs using settings generated by Tinkers' Construct and addons. There are two parts to these settings: material render info, and generator part textures, which can both be configured using resource packs (as described in the following sections)

Generator Part Textures

This file controls which textures will be generated. It is located at assets/<mod_id>/models/tconstruct_generator_part_textures.json, which up to 1 file for each mod ID. You can typically expect any addons adding tools to define a copy of this file under their own domain.

Keys:

  • replace: If true, will ignore copies of this file for this domain in lower resource packs. If false, will merge with them. Note if you intend to disable all textures set by mods, you will need to set this to true for each mod ID providing a copy of the file.
  • parts: Array of part textures
    • A JSON object
      • path: Path to the texture.
      • baseFolder: If true, textures are relative to assets/<mod_id>/textures/, false makes them relative to assets/<mod_id>/textures/item/tool/ (default). Upcoming in next 1.16 build.
      • statType: Stat type for the texture. If the material render info does not support this stat type, this pairing will be skipped.

Material Render Info

Material render info, located in assets/<mod_id>/models/tool_materials/, contain information about how a material should render. Several keys are notable to the command:

  • texture: If defined, materials will be generated using this as the texture ID. If unset, the material ID is used, as determined by the path.
  • fallbacks: The first fallback texture in this list will be used as a base for the generator. If no fallback texture is found or the list is empty, the base texture will be used.
  • generator: JSON object containing data only used by the generator command
    • supportedStats: Array of stat type resource locations supported. If a part's stat type is not in this array, that combination will not be generated.
    • ignoreMaterialStats: By default, the stat type array is expanded with all stat types the material has from datapacks. If this behavior is not desired, set this boolean to true.
    • transformer: Object containing information on which texture transformer to use
      • type: Resource location with the transformer ID, see #Transformers
      • Other keys used by the transformer

Transformers

Tinkers' Construct provides two transformers by default. Addons can provide additional transformers which should be documented by the addon.

tconstruct:recolor_sprite

This transformer will recolor a sprite pixel by pixel using a color mapping.

Keys:

  • type: Always "tconstruct:recolor_sprite"
  • color_mapping: JSON Object containing information on the color mapping
    • type: Resource location with the color mapping ID, see #Color Mappings
    • Other keys used by the color mapping

tconstruct:grey_to_sprite

This transformer will recolor a sprite pixel by pixel, mapping from grey to either a solid color or a sprite. When mapping to a sprite, the color in the sprite will be copied into the tool texture for a given X, Y location. #tconstruct:grey_to_color has more information on the grey values.

Keys:

  • type: Always "tconstruct:grey_to_sprite"
  • palette: Array of mappings from grey to colors or sprites
    • A JSON object
      • grey: Grey value to replace from the original sprite. Must be larger than the grey value of the previous element.
      • path: Path to the sprite, relative to assets/<mod_id>/textures. If unset, will use a solid color.
      • color: Color to replace the grey value, in AARRGGBB format. If path is defined, acts as a tint for the sprite. If undefined, defaults to "FFFFFFFF", meaning white and fully opaque.

Color Mappings

Tinkers' Construct provides one color mapping by default. Addons can provide additional color mappings which should be documented by the addon.

tconstruct:grey_to_color

This color palette will map colors from a grey value to a color. By default, most textures include grey values of 63, 102, 140, 178, 216, and 255, meaning most color mappings should provide those 6 values (plus 0 so black is mapped to the proper color). Note that if a grey value is seen in the sprite that is missing from the palette, nearby grey values will be be used, blending their color values (interpolation).

Keys:

  • type: Always "tconstruct:grey_to_sprite"
  • palette: Array of mappings from grey to colors or sprites
    • A JSON object
      • grey: Grey value to replace from the original sprite. Must be larger than the grey value of the previous element.
      • color: Color to replace the grey value, in AARRGGBB format.
Clone this wiki locally