ContentTweaker

ContentTweaker

27M Downloads

[1.12.2]How to use PartDataPiece

ztblat opened this issue ยท 2 comments

commented

https://mclo.gs/wBl5lF9
There is no error, but there is also no successful effect.

commented

The process is as follows:

  1. You create or retrieve a PartType (you created one but missed one step, see below)
  2. You register the new PartDataPiece to the Part Type (you already did; you named it "frame").
  3. You create a new Part using that Part Type (you already did; you named it"cool_part").
  4. You create or retrieve a Material (you already did; you created one named "Lawrencium").
  5. You create a new MaterialPart using the Part from 2. and the Material from 3. (you already did).
  6. On that new MaterialPart you can now set the data values (you already did, you set the "stackSize" to "8").

Now I mentioned that in part 1 you missed a step:
Inside your register callback for the materialPart you need to access the materialPartData of the materialPart that is registered.

val frame as PartType = MaterialSystem.createPartType("frame", function(materialPart){
 var materialName as string = materialPart.getMaterial().getName();
 // retrieve the materialPartData values for that materialPart here
 var materialPartData = materialPart.getData();

 val hardened_clay_pick as Item = VanillaFactory.createExpandItem( materialName.toLowerCase() ~ "_pick");
 //...
 // access the materialPartData here (or use a fallback value if it was not set)
 hardened_clay_pick.maxStackSize = materialPartData.getIntValue("maxStackSize", 1);
 // ... rest of your calls

 hardened_clay_pick.register();
});

// same code below to register the part, the material and the materialPart and set the materialPartData values

By the way, such questions can also be asked on our Discord Server where you may get faster feedback depending on who's online ๐Ÿ˜‰

commented

The process is as follows:

  1. You create or retrieve a PartType (you created one but missed one step, see below)
  2. You register the new PartDataPiece to the Part Type (you already did; you named it "frame").
  3. You create a new Part using that Part Type (you already did; you named it"cool_part").
  4. You create or retrieve a Material (you already did; you created one named "Lawrencium").
  5. You create a new MaterialPart using the Part from 2. and the Material from 3. (you already did).
  6. On that new MaterialPart you can now set the data values (you already did, you set the "stackSize" to "8").

Now I mentioned that in part 1 you missed a step: Inside your register callback for the materialPart you need to access the materialPartData of the materialPart that is registered.

val frame as PartType = MaterialSystem.createPartType("frame", function(materialPart){
 var materialName as string = materialPart.getMaterial().getName();
 // retrieve the materialPartData values for that materialPart here
 var materialPartData = materialPart.getData();

 val hardened_clay_pick as Item = VanillaFactory.createExpandItem( materialName.toLowerCase() ~ "_pick");
 //...
 // access the materialPartData here (or use a fallback value if it was not set)
 hardened_clay_pick.maxStackSize = materialPartData.getIntValue("maxStackSize", 1);
 // ... rest of your calls

 hardened_clay_pick.register();
});

// same code below to register the part, the material and the materialPart and set the materialPartData values

By the way, such questions can also be asked on our Discord Server where you may get faster feedback depending on who's online ๐Ÿ˜‰

thanks