Trait Representation
Link to 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.
Импорт класса
Link to импорт-класса
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
Link to zengetter
ZenGetter | Тип |
---|---|
ZenGetter identifier | Тип string |
ZenGetter commandString | Тип string |
Adding trait items
Link to 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.
ZenScript Copy//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);
item
is the item that is matched against. You can use Item Conditions but no Transformers.amountNeeded
is the amount of items that is matched against. You can split them over all the slots the toolforge provides, which also allows you to go above 64. In the example above, you need 4 iron blocks per addition. Defaults to 1.amountMatched
is the amount of trait points added peramountNeeded
. In the example above four iron blocks give two trait points. Defaults to 1.
Accessing Trait Data
Link to 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.
Copyval myTraitData = myTrait.getData(itemWithTrait);