[1.12.2]How to use PartDataPiece
ztblat opened this issue ยท 2 comments
https://mclo.gs/wBl5lF9
There is no error, but there is also no successful effect.
The process is as follows:
- You create or retrieve a PartType (you created one but missed one step, see below)
- You register the new PartDataPiece to the Part Type (you already did; you named it "frame").
- You create a new Part using that Part Type (you already did; you named it"cool_part").
- You create or retrieve a Material (you already did; you created one named "Lawrencium").
- You create a new MaterialPart using the Part from 2. and the Material from 3. (you already did).
- 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 ๐
The process is as follows:
- You create or retrieve a PartType (you created one but missed one step, see below)
- You register the new PartDataPiece to the Part Type (you already did; you named it "frame").
- You create a new Part using that Part Type (you already did; you named it"cool_part").
- You create or retrieve a Material (you already did; you created one named "Lawrencium").
- You create a new MaterialPart using the Part from 2. and the Material from 3. (you already did).
- 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 valuesBy the way, such questions can also be asked on our Discord Server where you may get faster feedback depending on who's online ๐
thanks