Material Builder

Link to material-builder

Using this package you can create materials that you can then create tools with!

Импорт класса

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.MaterialBuilder;

Creating a Material

Link to creating-a-material

First and foremost you will need to create a Material Builder.
This can be done using the static create method.

ZenScript
Copy
//mods.contenttweaker.tconstruct.MaterialBuilder.create(String identifier);
val myMat = mods.contenttweaker.tconstruct.MaterialBuilder.create("kindlich_mat");

Remember, that you will need to register the material after you've done your changes.
This can be done with the register method which will return a Material Representation of the new Material.

ZenScript
Copy
myMat.register();

Свойства

Link to свойства

You can set and get these properties using myMaterial.name.

PropertyТипAdditional notes
Property
identifier
Тип
string
Additional notes
Unique name
Property
color
Тип
int
Additional notes
Property
hidden
Тип
bool
Additional notes
Property
liquid
Тип
ILiquidStack
Additional notes
Smeltery output
Property
craftable
Тип
bool
Additional notes
Can be created in the part builder
Property
castable
Тип
bool
Additional notes
Can be created using casts. Requires liquid to be set!
Property
representativeItem
Тип
IItemStack
Additional notes
Shown item in the tinkers' manual
Property
representativeOre
Тип
IOreDictEntry
Additional notes
Shown if representativeItem is null
Property
shard
Тип
IItemStack
Additional notes
Used instead of the tinker's shard item in the part builder.
Property
localizedName
Тип
string
Additional notes
The shown name

Calculated Properties

Link to calculated-properties

You can use this function to calculate the material names if you need that to be the case.
Uses a Material Representation of this material and the name of the tool that's being renamed (e.g. "Mattock")

ZenScript
Copy
myMAt.itemLocalizer = function(thisMaterial, itemName){return "Cool " + itemName;};

Add Material Items

Link to add-material-items

If you use the given item in the part builder, you can set how many materialpoints that will give, or how much the item will repair.

ZenScript
Copy
//myMaterial.addItem(IIngredient item, @Optional(1) int amountNeeded, @Optional(144) int amountMatched));
myMaterial.addItem(<item:minecraft:iron_pickaxe>);
myMaterial.addItem(<item:minecraft:iron_block>, 4, 288);

//myMaterial.removeItem(IItemStack item);
myMaterial.removeItem(<minecraft:iron_block>);
  • 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 second example above, you need 4 iron blocks per addition. Defaults to 1.
  • amountMatched is the amount of material points added per amountNeeded. In the second example above four iron blocks give two material points. Defaults to 144 (one ingot/one Material value).
  • If you use the remove function, it will remove all trait ingredients that match for the item.

You can add a trait to the material.
All items made from this material will then have this trait.
Uses a String with the identifier of the trait, and an optional dependency string which will tell you which itemTypes should be affected by the trait.
Alternatively, you can use a Trait Representation, though that only works if the trait is already initialized by the time CoT runs (so most likely only for custom traits). Possible values for dependency are:

  • null (default) → All items, unless that dep already has other traits.
  • "head"
  • "handle"
  • "extra"
  • "bow"
  • "bowstring"
  • "projectile"
  • "shaft"
  • "fletching"
ZenScript
Copy
myMaterial.addMaterialTrait("fiery");
myMaterial.addMaterialTrait("fiery", "bowstring");

You can remove materialTraits as well (which is especially useful when doing batch materials).
You remove them using their identifier string and an optional dependency.
If you omit the dependency or use null all traits with that identifier will be removed.

ZenScript
Copy
//myMaterial.remove(String identifier, @Optional String dependency);
myMaterial.remove("cactus");
myMaterial.remove("cactus", "bowstring");

In order for TiCon to build your materials, it needs to know the material stats.
Only tooltypes whose stat has been added will be built!

ZenScript
Copy

myMat.addHeadMaterialStats(int durability, float miningSpeed, float attackDamage, int harvestLevel);
myMat.removeHeadMaterialStats();


myMat.addHandleMaterialStats(float modifier, int durability);
myMat.removeHandleMaterialStats();


myMat.addExtraMaterialStats(int extraDurability);
myMat.removeExtraMaterialStats();


myMat.addBowMaterialStats(float drawSpeed, float range, float bonusDamage);
myMat.removeBowMaterialStats();


myMat.addBowStringMaterialStats(float modifier);
myMat.removeBowStringMaterialStats();


myMat.addArrowShaftMaterialStats(float modifier, int bonusAmmo);
myMat.removeArrowShaftMaterialStats();


myMat.addFletchingMaterialStats(float accuracy, float modifier);
myMat.removeFletchingMaterialStats();


myMat.addProjectileMaterialStats();
myMat.removeProjectileMaterialStats();
ZenScript
Copy
#loader contenttweaker
#modloaded tconstruct

val testMat = mods.contenttweaker.tconstruct.MaterialBuilder.create("kindlich_mat");
testMat.color = 0x8e661b;
testMat.craftable = true;
testMat.liquid = <liquid:lava>;
testMat.castable = true;
testMat.addItem(<item:minecraft:comparator>);
testMat.addItem(<item:minecraft:repeater>, 1, 2);
testMat.addItem(<item:minecraft:red_flower:4>);
testMat.representativeItem = <item:minecraft:red_flower:4>;
testMat.addHeadMaterialStats(100, 1.5f, 5.5f, 5);
testMat.addHandleMaterialStats(0.3, 500);
testMat.addBowStringMaterialStats(0.5f);
testMat.addMaterialTrait(<ticontrait:kindlich_test>, "bowstring");
testMat.addMaterialTrait(<ticontrait:kindlich_test>, "head");
testMat.addMaterialTrait("blasting", "bowstring");
testMat.addMaterialTrait("blasting", "head");

//null (or not specifying that parameter at all) means that this is a default trait.
//Default traits are only queried when no other traits are added to that material type.
//In this case, the dense trait will only be on toolrods, because bowstrings and heads already have other traits.
testMat.addMaterialTrait("dense", null);

//Faulty, should error, though only during init, as then the strings will be checked.
testMat.addMaterialTrait("dance", null);

testMat.itemLocalizer = function(thisMaterial, itemName){return "Cool " + itemName;};
testMat.localizedName = "Wicked";
testMat.register();