Tinkers' Construct Documentation

repository·1.20.1·Indexed 23 days ago

https://github.com/slimeknights/tinkersconstruct

A Minecraft mod focused on metal melting and tool customization. This documentation covers workspace setup and compilation from source, as well as technical details for implementing custom commands using arguments for materials, modifiers, tool statistics, and slot types. It also includes references for administrative subcommands such as durability modification and automated recipe/tag generation.

Tokens
4.9K
Snippets
5
Records
33
Agent score
78%

What's inside Tinkers' Construct

  1. Report an issue with Tinkers' Construct

    1.20.1

    When reporting an issue, please provide the following information to ensure it can be addressed:

    • Minecraft version
    • Tinkers' Construct version
    • Forge version/build
    • Versions of any mods potentially related to the issue
    • Relevant screenshots

    For crashes, you must also include:

    • Steps to reproduce the crash
    • The latest.log (FML log) located in the root folder of your client
  2. Set up a workspace and compile Tinkers' Construct from source

    1.20.1

    To develop on or compile Tinkers' Construct, ensure Git is installed and available in your system path. Follow these steps:

    1. Setup: Import the Tinkers' Construct repository as a Gradle project into IntelliJ IDEA and allow it to run the initial setup.
    2. Generate Runs: Run the command gradlew genIntellijRuns within IntelliJ IDEA to configure execution environments.
    3. Build: Run gradlew build to compile the project.

    If you encounter obscure Gradle issues, attempt to clear the state by running:

    • gradlew clean
    • gradlew cleanCache
  3. Configure melting recipe generation

    1.20.1

    The generation process is controlled by a JSON configuration file located at command/generate_melting_recipes.json within your datapacks. This file allows you to define which items are eligible to be melted, which items can serve as inputs, and which items should be ignored or which recipes should be skipped.

    Supported configuration keys:

    • melt: An IJsonPredicate<Item> defining which items are eligible to receive a melting recipe (the result of the crafting recipe).
    • inputs: An IJsonPredicate<Item> defining which items are valid ingredients for the melting process.
    • ignore: An IJsonPredicate<Item> defining items that can be present in a recipe but do not contribute to the fluid output (effectively ignored).
    • skip_recipes: A list of ResourceLocations representing specific crafting recipes to skip during the generation process.
  4. Use SlotTypeArgument in commands

    1.20.1

    When developing custom commands for Tinkers' Construct, you can use SlotTypeArgument to allow users to select a specific modifier slot type. This argument supports providing a valid SlotType name or, if configured, a special slotless keyword.

    Argument Behavior

    • Valid Slot Types: Users can input the name of an existing SlotType (e.g., upgrades, abilities).
    • Slotless Option: If the argument is initialized with allowSlotless = true, users can input slotless to represent a null/empty slot type.
    • Suggestions: The command will automatically provide suggestions based on all available SlotType names, plus slotless if enabled.

    Retrieving Values from Command Context

    Depending on whether you want to allow a null value or require a specific type, use the following methods:

    1. getOptional(context, name): Returns an OptionalSlotType record. Use this if you want to handle the case where the user selects slotless (which results in a null slot type inside the record).
    2. getSlotType(context, name): Returns a non-null SlotType. This method will throw a CommandSyntaxException if the user provides slotless or an invalid type.
  5. Use ModifierTagSource for command arguments

    1.20.1

    In Tinkers' Construct command development, ModifierTagSource is used to provide a source for Minecraft command arguments that need to select Modifier objects via tags or resource locations. It integrates with the ModifierManager to resolve tags and individual modifier entries.

    When implementing custom commands that require selecting modifiers, use this source to allow users to input either a specific modifier ID (as a ResourceLocation) or a tag containing modifiers.

  6. Use MaterialStatsArgument in commands

    1.20.1

    The MaterialStatsArgument is a custom Brigadier argument type used in Tinkers' Construct commands to select specific material statistics (e.g., tconstruct:head or tconstruct:limb).

    When implementing or using commands that require a material stat type, this argument parses a resource location ID and returns the corresponding MaterialStatType<?>. If the provided ID does not match a registered stat type, it throws a material_stat.not_found error.

    Usage in Command Implementation: To retrieve the parsed stat type from a command context, use the getStat helper method, providing the context and the name of the argument as defined in your command tree.

  7. Use ToolStatArgument in commands

    1.20.1

    When developing custom commands for Tinkers' Construct, you can use ToolStatArgument to allow users to select a specific tool statistic (e.g., mining speed or durability) via the CLI.

    • The argument expects a resource identifier in the format namespace:path (e.g., tconstruct:mining_speed).
    • You can provide a filter class to restrict the available statistics to a specific subtype of IToolStat.
    • To retrieve the parsed statistic from a command context, use the getStat helper method.

    Examples of valid input:

    • tconstruct:mining_speed
    • tconstruct:durability
  8. Use the Material argument in commands

    1.20.1

    When interacting with Tinkers' Construct commands via the Minecraft CLI, you can specify materials using a resource identifier format. The argument accepts valid IMaterial identifiers registered within the mod.

    Format: modid:material_name (e.g., tconstruct:iron)

    Examples:

    • tconstruct:wood
    • tconstruct:iron
    tconstruct:wood
    tconstruct:iron
  9. Use MaterialTagSource for command arguments

    1.20.1

    In Tinkers' Construct command development, MaterialTagSource is used to allow users to select materials or material tags via CLI arguments. It bridges the MaterialManager with the TagSource interface, enabling commands to resolve IMaterial objects from Minecraft tags or specific ResourceLocation identifiers.

    When implementing a command that requires material selection, using this source allows the command to:

    • Validate if a provided tag exists in the MaterialManager.
    • Resolve a ResourceLocation (e.g., tconstruct:cobalt) into an IMaterial instance.
    • List all available material tags and individual material keys for tab completion.
  10. Use the modifier hook argument in commands

    1.20.1

    When developing or using commands within Tinkers' Construct, you can use the ModifierHookArgument to allow users to select a specific ModuleHook<?>. This argument expects a ResourceLocation (namespaced ID) that corresponds to a registered modifier hook.

    Usage Details:

    • Input Format: A namespaced string (e.g., tconstruct:tool_stats).
    • Validation: The argument validates that the provided ID exists within the ModifierHooks registry. If the ID is not found, it throws a modifier_hook.not_found error.
    • Suggestions: The command interface will provide autocomplete suggestions based on the keys currently loaded in ModifierHooks.LOADER.

    Examples of valid inputs:

    • tconstruct:tool_stats
    • tconstruct:tooltip
  11. Use MaterialVariantArgument in commands

    1.20.1
    The MaterialVariantArgument is a command argument type used to select specific material variants within Tinkers' Construct commands. It expects a resource identifier formatted as a MaterialVariantId. When used in a command, it provides auto-completion suggestions for all registered materials in the MaterialRegistry and displays their colored display names via the MaterialTooltipCache.