How to use the COT material system

Foreword

What is the material system?What do you do?If you have seen the tutorials of COT custom square blocks, items, etc., would you think that if you want to add items or blocks of various technology modules, such as tin ingot, tin ore, tin gear, tinboard plates, tin sticks, etc.A variety of content, do you plan to write one by one?This is the convenience brought by the material system.

introduce

The material system consists of materials and components, so what are they all?If you have seen the tutorial of COT custom artisan soul, then you may understand.According to the foreword, tin = material, ingot, mine, gear = component.

It will be explained in two parts next.

Cot script starts with #Loader ContentTweaker

Materials and parts

Custom material

Guide bag

Import Mods.ContentTTWEAKER.MATERIALSTEM;

Import Mods.ContentTWEAKER.MaterialBuilder;

Import Mods.ContentTTweaker.Material;

script

First writing

// Get the material builder

// VAR variable name as materialbuilder = materiaLSYSTEM.GetmaticBuilder ();

Var Builder As MaterialBuilder = MaterialSystem.getmater later ();

// Set ID

// Variable name .setName ("ID"); Builder.setName ("Urubuntu");

// Set color

// Variable name .setcolor (color code);

Builder.setcolor (0x000151);

// Set whether there is an enchanting light effect

// Variable name .sethaseffect (true/false);

Builder.sethaseffect (false);

// Construction

Val variable name 2 as material = variable name .build ();

Val Urubuntu As Material = Builder.build ();

The second way of writing (chain)

The same as above

Val Arakantara As Material = MaterialSystem.GetmaterBuilder (). SetName ("ARAKANTARA"). SetColor (15592941 .Sethaseffect (true) .build ();

Localization

base.material. Material ID = xxx

Custom part

Guide bag

Import Mods.ContentTTWEAKER.MATERIALSTEM;

Import Mods.ContentTTweaker.part;

Import Mods.ContentTWEAKER.PARTBUILDER;

Import Mods.ContentTweaker.parttype;

script

First writing

// Component builder

// var variable name = materialsystem.getpartbuilder ();

var pbuilder = materialSystem.getPartbuilder ();

// Set the ID of the component

// Variable name .setName ("ID");

pbuilder.setName ("DENSE_GEAR");

// What is the type of component type (item), block (block), ore (ore), FLUID (fluid), ARMOR (armor), Minecart (mining car)))

// Variable name .setPartType (MaterialSystem.getParttype ("What");

pbuilder.setPartType (materialsystem.getPartType ("item");

// Whether there is a part of the settings will not be colored (similar to the leather cover, prepare two pictures, a xx.png is a color map, and the xx_overlay.png

// Variable name .sethasoverlay (true/false);

pbuilder.Sethasoverlay (true); // Set mineral resignation

// Variable name .setOredictname ("Mine -Care");

pbuilder.setOredname ("superingot");

// Construction

// var variable name 2 = variable name.build ();

var densegearpart = pbuilder.build ();

The second way of writing (chain)

The same as above

var denseingotpart = MaterialSystem.getPartBuilder (). SetName ("Dense_INGOT"). Setparttype (mods.ContentTweaker. Materialsystem.getPartType ("item"))) .Sethasoverlay (true) .setOreDictName ("superingot"). Build ();

Of course, COT provides a lot of preset wiki

Localization

ContentTweaker.part. Component ID =%s xx (%s represents material, when you create the corresponding material parts, such as tin, it will automatically replace%s, such as tin gear)

Material

Like COT creation items, blocks, ites are placed in items, and blocks are placed in blocks.

Combining components with materials, registered materials parts

Although the above taught how the materials and components were created, they were all controlled. We need to combine them.

// Create a material and components here to demonstrate

Val Copper As Material = MaterialSystem.GetmaticBuilder (). SetName ("Copper"). Setcolor (0xff9933) .build ();

var denseingotpart = MaterialSystem.getPartBuilder (). SetName ("Dense_INGOT"). Setparttype (mods.ContentTweaker. Materialsystem.getPartType ("item"))) .Sethasoverlay (true) .setOreDictName ("superingot"). Build ();

// Register material and components

// Material variable name.registerpart (component ID SRING /Component variable name ipart);

Copper.registerpart ("Dense_INGOT");

Copper.registerpart (DENSEINGOTPART);

// Of course it can also be array

// Material variable name.registerparts

copper.registerparts (["Gear", "Casing", "DENSE_INGOT"] as String []);

copper.registerparts ([Denseingotpart] as iPart []);

// Of course they can actually reverse

// Component variable name.registertomaterial (material variable name);

DENSEINGOTPART.RegIStomater (Copper);

// array

// Component variable name.registertomaterials (material variable name Material []);

DENSEINGOTPART.RegisterTerials ([Copper] as material []);

Material component information

Perhaps you have higher requirements for the materials provided by the material system. For example, the excavation level of a certain material is 2, but the level of mining of a certain material is 3.

Guide bag

Import Mods.ContentTWEAKER.MaterialPartData;

script

// First of all, it is right to create a material part, not material and components but materials and components.

// Different from the material, no AS type is required, and then add registerpart behind build () .Getdata ()

value = materialsystem.getmaticBuilder (). SetName ("Lawrencium"). SetColor (15426660) .build ().

// After that, you can change according to the wiki provided

Oredata.adddataValue ("Drops", "Minecraft: Redstone, MINECRAFT: GOLD_INGOT");

Oredata.adddataValue ("variants", "Minecraft: Stone, MINECRAFT: END_STONE");

Oredata.adddataValue ("Hardness", "3,3");

Oredata.adddataValue ("Resistance", "15,15");

Oredata.adddataValue ("HarvestLevel", "1,1");

Oredata.adddataValue ("Harvesttool", "Pickaxe, SHOVEL");

Advance

If you want to make the added items have special effects, such as a magic scroll?Then the method provided by material component information is not feasible, so we need to create our own component type, that is, the ITEM, ORE, BLOCK, etc. used in the custom components above

Custom component type

Guide bag

Because it creates the original items and squares like COT, it needs to be imported

Import Mods.ContentTweaker.Vanillafactory;

script

// Create a custom component type object

// Val variable name as parttype = materialSystem.createPartType ("type ID", function (materialpart) {

Val Frame as parttype = MaterialSystem.createPartType ("Frame", Function (MaterialPart) {

// Get the name of the material

// var variable name 2 as string = materialpart.getmaterial (). Getname ();

Var matername as string = materialpart.getmatic (). GetName ();

// COT registered items/squares, modified micro -modification

// Register blocks and items, stitch the ID, similar to the %S component ID above

// var variable name as block = vanillaFactory.createBlock ("type ID_" ~ materialname.tolowercase (), );

Var frame as block = vanillaFactory.createBlock ("Frame_" ~ MaterialName.tolowerCase (), );

// The following is the normal square/item registration part, but here it is not more described

Frame.blocklayer = "Cutout";

Frame.blockhardness = 3.0;

Frame.blockResistance = 45.0; Frame.lightopaCity = 0;

Frame.fullBlock = false;

Frame.settoolClass ("Pickaxe");

Frame.translucent = true;

Frame.settoolLevel (1);

// Set the material path of custom component type

// Variable name.TextureLocation = MODS.CONTENTTTWEAKER.ResourceLocation.create ("ContentTweaker: (BLOCKS/Items)/Type ID");

Frame.TextureLocation = MODS.CONTENTTTWEAKER.ResourceLocation.create ("ContentTweaker: Blocks/Frame");

// Set the color of the item. Of course, it is recommended to use the colorPart.getCTCOLOR () to return the color of the material directly

// Variable name .Itemcolorsupplier = Function (item, tintIndex) {xxx};

Frame.ItemColorsupPlier = Function (item, tintIndex) {

Return materialpart.getCTCOLOR ();

};

// Set the color of the cub

// Variable name. BlockColorsupPlier = Function (state, accept, pos, tintindex) {xxx};

Frame.blockColorsupPlier = Function (state, accept, pos, tintindex) {

Return materialpart.getCTCOLOR ();

};

// End Construction

// Variable name.register ();

Frame.register ();

});

// Then give the custom component type in the custom component application, and then you use this part to create the material

// Customized parts

// Val variable name = mods.contenttweaker.MaterialSystem.getPartbuilder (). SetName ("Cool_part").

valpart = mods.contentTweaker.MateriaLSYSYSTEM.GetPartBuilder (). SetName ("Cool_part"). Setparttype (frame) .build ();

// Customized materials

VAL OURMATERIAL = MIATIALSYSTEM.GetMaterialBuilder (). SetName ("LAWRENCIUM"). Setcolor (15426660) .build ();

// Register material and components

OURMATERIAL.Registerpart (OURPART);

Custom material component information

We have registered a custom component type. What if there are different requirements for custom types like material components information?Write another one?Obviously unrealistic, so we can write a custom material component information like material component information

Guide bag

Import Mods.ContentTWEAKER.PARTDATAPIECE;

script

// First create a material component information (partDataPiece)

// Val variable name as partDataPiece = Materialsystem.createPartDataPiece ("material component information name", whether to fill in True/False);

Val mycustomdatapiece as partDataPiece = MaterialSystem.CreatePartDataPiece ("Blockhardness", FALSE);

// Register the custom material component information into the type of custom component type

// Custom component types of the above article as examples

Val Frame as parttype = MaterialSystem.createPartType ("Frame", Function (MaterialPart) {

Var matername as string = materialpart.getmatic (). GetName ();

// Insert the code of searching custom material component information

// varialPartdata = materialpart.getdata ();

VarialPartData = materialpart.getdata ();

// After calling this variable, just call it

Var frame as block = vanillaFactory.createBlock ("Frame_" ~ MaterialName.tolowerCase (), );

Frame.blocklayer = "Cutout";

// Such as Frame.blockhardness = 3.0;

Frame.blockhardness = MaterialPartdata.GetStringValue ("Blockhardness", "3.0F");

//

Frame.blockResistance = 45.0;

Frame.light!

Frame.fullBlock = false;

Frame.settoolClass ("Pickaxe");

Frame.translucent = true;

Frame.settoolLevel (1);

Frame.TextureLocation = MODS.CONTENTTTWEAKER.ResourceLocation.create ("ContentTweaker: Blocks/Frame");

Frame.ItemColorsupPlier = Function (item, tintIndex) {

Return materialpart.getCTCOLOR ();

};

Frame.blockColorsupPlier = Function (state, accept, pos, tintindex) {

Return materialpart.getCTCOLOR ();

};

Frame.register ();

});

// Register the custom material component information into the type of custom component type

// Variable .setdata ([[Customized material component information variable A, custom material component information variable B] as partDataPiece []);

Frame.setdata

// Normal registered materials and components later.

valpart = mods.contentTweaker.MateriaLSYSYSTEM.GetPartBuilder (). SetName ("Cool_part"). Setparttype (frame) .build ();

value = materialsystem.getmater laterbuilder (). SetName ("Lawrencium"). SetColor (15426660) .build () .getdata () ;Getdata ();

Oredata.adddataValue ("blockhardness", "114514.0F");