A PartType can be seen as a group that several parts fit in, e.g. items

Импорт пакета

Link to импорт-пакета

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

Retrieving such an object

Link to retrieving-such-an-object

You can use the MaterialSystem to either retrieve an existing PartType object or create an entirely new one.
Check out below entry to learn how to create a new PartType.

Following types are pre-registered:
  • item
  • block
  • ore
  • fluid
  • armor
  • minecart

You can retrieve the following information from a PartType:

ZenMethodВозвращаемый тип
ZenMethod
getName()
Возвращаемый тип
string

You can set the following information on a PartType:

ZenMethodParameter Type
ZenMethod
setData(IPartDataPiece[] data);
Parameter Type
IPartDataPiece[] data

Create a new PartType

Link to create-a-new-parttype

If you, for whatever reason would ever need to register a new PartType, you will need to know two things:

  • What name the new partType will have
  • How MaterialParts created from Parts that are of this type will be registered

The first is simple, it's a string.
The second is a bit trickier, it's a function that takes a MaterialPart as input:

ZenScript
Copy
#loader contenttweaker


import mods.contenttweaker.MaterialSystem;

val ourType = MaterialSystem.createPartType("cool_type", function(materialPart){

});

//Use the new type to create a Part
val ourPart = mods.contenttweaker.MaterialSystem.getPartBuilder().setName("cool_part").setPartType(ourType).build();

//Create a new Material and register the newly created part.
val ourMaterial = MaterialSystem.getMaterialBuilder().setName("Lawrencium").setColor(15426660).build();
ourMaterial.registerPart(ourPart);