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

Importing the package

Link to 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;

ZenScript
Copy
createPartType(String name, IRegisterMaterialPart registerMaterialPart)

Required Parameters:

  • String name: The part type's name → e.g. "dense_gear"
  • IRegisterMaterialPart registerMaterialPart → A function that handles how the Material parts will be created.
ZenScript
Copy
getPartType(String name);

Required Parameters:

  • String name: The part type's name → e.g. "gear" For a list of all available part types check the part type page.

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.

ZenScript
Copy
val MB MaterialSystem.getMaterialBuilder();
MB.setName("Urubuntium");
MB.setColor(0);
MB.setHasEffect(false);
var builtMaterial = MB.build();
ZenScript
Copy
getMaterial(String name);

Required Parameters:

  • String name: The Material's name → e.g. "Platinum"

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

ZenScript
Copy
val PB = MaterialSystem.getPartBuilder();
ZenScript
Copy
getPart(String name);

Required Parameters:

  • String name: The Part's name
Copy
createPartDataPiece(String name, boolean required)

Required Parameters:

  • String name: The Data Piece's name
  • boolean required: Is the data piece required?

Register multiple MaterialParts

Link to 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

ZenScript
Copy
registerPartsForMaterial(Material material, String[] partNames);

Required Parameters:

  • Material material: The material that the registered parts should be made of
  • String[] partNames: The names of the parts that should be registered → e.g. ["gear", "ingot"]

Retrieve already registered things:

Link to retrieve-already-registered-things

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

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

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

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