MaterialSystem

The MaterialSystem is used to create new or retrieve existing Materials from within CT.

Importing the package

It might be required for you to import the package if you encounter any issues, so better be safe than sorry and add the import.
import mods.contenttweaker.MaterialSystem;

IPartType

Create

createPartType(String name, IRegisterMaterialPart registerMaterialPart)

Required Parameters:

Retrieve

getPartType(String name);

Required Parameters:

IMaterial

Create

Unlike the PartType, you cannot directly create a Material, instead you need to use a MaterialBuilder. Check the MaterialBuilder entry for info on what exactly to do with these.

val MB MaterialSystem.getMaterialBuilder();
MB.setName("Urubuntium");
MB.setColor(0);
MB.setHasEffect(false);
var builtMaterial = MB.build();

Retrieve

getMaterial(String name);

Required Parameters:

IPart

Create

Unlike the PartType, you cannot directly create a Part, instead you need to use a PartBuilder. Check the [Part entry](IPart](/Mods/ContentTweaker/Materials/Parts/Part/) for info on what exactly to do with these.

val PB = MaterialSystem.getPartBuilder();

Retrieve

getPart(String name);

Required Parameters:

IPartDataPiece

Create

createPartDataPiece(String name, boolean required)

Required Parameters:

Register multiple MaterialParts

Even though you can also do this using the Material’s own functionality, this Method allows you to register Parts for a given Material

registerPartsForMaterial(Material material, String[] partNames);

Required Parameters:

Retrieve already registered things:

You can use these methods to retrieve a map using strings as keys and the object as values:

Method Name Return Type
getMaterialParts() Map<String, IMaterialPart>
getMaterials() Map<String, IMaterial>
getParts() Map<String, IPart>
getPartType() Map<String, IPartType>
import mods.contenttweaker.MaterialPart;

val part = MaterialSystem.getMaterialPart("name"); //as MaterialPart

val partMap = MaterialSystem.getMaterialPartsByRegex(".*"); //as MaterialPart[string]