Trait Representation

A Trait representation represents a Tinkers’ Construct Trait.
You can get such an object either from the Trait Builder or from the Trait Bracket Handler.

Importing the class

It might be required for you to import the class if you encounter any issues (like casting an Array), so better be safe than sorry and add the import.
import mods.contenttweaker.tconstruct.Trait

ZenGetter

ZenGetter Type
identifier string
commandString string

Adding trait items

If you combine the given ingredient together with a tool in a tinker’s tool forge, you can apply the trait as modifier.

//myTrait.addModifierItem(IIngredient item, @Optional(1) int amountNeeded, @Optional(1) int amountMatched));
myTrait.addModifierItem(<item:minecraft:iron_pickaxe>);
myTrait.addModifierItem(<item:minecraft:iron_block>, 4, 2);

Accessing Trait Data

Trait data is the data that belongs to a trait and is itemBound. As such, you can provide the IItemStack and retrieve the TraitDataRepresentation object.

val myTraitData = myTrait.getData(itemWithTrait);