Tinkers Construct

Tinkers Construct

160M Downloads

How do I add custom materials?

Forixaim opened this issue ยท 4 comments

commented

I have been making a mod that allows for new materials to be added and I don't know where the code for adding materials is. I tried to use an official one and it didn't work as one said that it's outdated. Where is the code to the materials template?

Versions:

  • Minecraft: 1.12.2
  • Forge: 14.23.5.2847
  • Mantle: 1.3.3.55
  • Tinkers Construct: 2.12.0.157
commented

You add them using the TinkerRegistry. See the TinkerMaterials and TinkerIntegration class.

What official template were you trying to use?

commented

/* This first part adds Seared Stone as a material. Toolparts and tool graphics are created automatically by color */
NBTTagCompound tag = new NBTTagCompound();
tag.setInteger("Id", 50); // Unique material ID. Reseved IDs: 0-40 Tinker, 41-45 Iguana Tinker Tweaks, 100-200 ExtraTiC
tag.setString("Name", "Seared Stone"); // Unique material name
tag.setInteger("HarvestLevel", 3); // diamond level
tag.setInteger("Durability", 100);
tag.setInteger("MiningSpeed", 100);
tag.setInteger("Attack", 0); // optional
tag.setFloat("HandleModifier", 0.1f);
tag.setInteger("Reinforced", 0); // optional
tag.setFloat("Stonebound", 0); // optional, cannot be used if jagged
//tag.setFloat("Jagged", 0); // optional, cannot be used if stonebound
tag.setString("Style", EnumChatFormatting.RED.toString()); // optional, color of the material text
tag.setInteger("Color", 255 << 24 | 45 << 16 | 45 << 8 | 40); // argb

/* SINCE 1.8.2 - bow and arrow stats

  • for bow and arrow stats, best compare to other materials to find good values
    */
    // additional stats for bows
    tag.setInteger("Bow_DrawSpeed", 100); // the higher the longer it takes to draw the bow
    tag.setFloat("Bow_ProjectileSpeed", 1.0f); // the higher the faster the projectile goes

// additional stats for arrows
tag.setFloat("Projectile_Mass", 2.0f);
tag.setFloat("Projectile_Fragility", 0.9f); // This is a multiplier to the shafts break-chance

FMLInterModComms.sendMessage("TConstruct", "addMaterial", tag);

/* SINCE 1.8.3 - material mappings

  • This maps an item to a material so it can be used for repairing etc. */
    tag = new NBTTagCompound();
    tag.setInteger("MaterialId", 50);
    tag.setInteger("Value", 2); // 1 material ever 2 value. See PartMapping IMC
    item = new NBTTagCompound();
    (new ItemStack(TinkerTools.materials, 1, 2)).writeToNBT(item); // seared brick item
    tag.setTag("Item", item);

FMLInterModComms.sendMessage("TConstruct", "addMaterialItem", tag);

/* This part adds mappigs, so that you can convert items to toolparts in the Part Builder.
Stone Parts are used as the baseline for what exists */
tag = new NBTTagCompound();
tag.setInteger("MaterialId", 50); // output material id
NBTTagCompound item = new NBTTagCompound();
(new ItemStack(TinkerSmeltery.smeltery, 1, 2)).writeToNBT(item); // seared brick block
tag.setTag("Item", item);

item = new NBTTagCompound();
(new ItemStack(TinkerTools.materials, 1, 2)).writeToNBT(item); // seared brick item
tag.setTag("Shard", item);

// 1 value = 1 shard. So 1 blocks like stone usually have value 2.
// Seared Brick is the shard, the block consists of 4 bricks, therefore value 4
tag.setInteger("Value", 4);
FMLInterModComms.sendMessage("TConstruct", "addPartBuilderMaterial", tag);

/* This part adds Smeltery casting. Give it a liquid, and which material to output. BAM toolpart casting.
Iron parts are used as the baseline for what exists.
Note that the Liquid has to exist. */
tag = new NBTTagCompound();
// liquid to use
tag.setString("FluidName", TinkerSmeltery.moltenStoneFluid.getName());
// or this way, it's equal
(new FluidStack(TinkerSmeltery.moltenStoneFluid, 1)).writeToNBT(tag); // this also works, amount doesn't matter
tag.setInteger("MaterialId", 50); // output material id
FMLInterModComms.sendMessage("TConstruct", "addPartCastingMaterial", tag);

// Smeltery stuff since 1.7.1
/* This part adds Smeltery melting. Give it an item, a block to render in the smeltery, the temperature required and the liquid to produce.
For reference: Iron has temperature 600, Stone has 800, Water has 20.
Melting duration is directly related to temperature required. */
tag = new NBTTagCompound();
// the item
item = new NBTTagCompound();
(new ItemStack(TinkerTools.materials, 1, 2)).writeToNBT(item); // seared brick item
tag.setTag("Item", item);
// the block to render
item = new NBTTagCompound();
(new ItemStack(TinkerSmeltery.smeltery, 1, 4)).writeToNBT(item); // seared stone block
tag.setTag("Block", item);
// liquid to produce. This time the amount DOES matter!
(new FluidStack(TinkerSmeltery.moltenStoneFluid, TConstruct.ingotLiquidValue/4)).writeToNBT(tag); // this also works
// the temperature required
tag.setInteger("Temperature", 850);
FMLInterModComms.sendMessage("TConstruct", "addSmelteryMelting", tag);

/* This part adds Smeltery fuel. Give it a fuel, how hot it is and how long it lasts.
The temperature determines WHAT it can melt (e.g. stone needs at least temperature 800) and how FAST it melts
The duration depends on how long one "portion" of fuel lasts.

For reference: Lava has a temperature of 1300 and a duration of 80
The duration has to be divided through 20 to get the seconds.
One "portion" is 15mb. /
tag = new NBTTagCompound();
// fuel liquid. Amount doesn't matter if you use the fluidstack variant
tag.setString("FluidName", FluidRegistry.WATER.getName());
// water is totally OP
tag.setInteger("Temperature", 9001);
// but also used up very quickly
tag.setInteger("Duration", 1); // this means 15 mb last 1 tick. Therefore 1 second of use drains 15
20 = 300mb water
FMLInterModComms.sendMessage("TConstruct", "addSmelteryFuel", tag);

/* SINCE 1.8.3
This allows you to register your custom IEnergyContainerItems as a valid item for adding the Redstone Flux Modifier to your tool
you can add any item you like, just make sure that the item implements IEnergyContainerItem interface from the cofh/api/energy api */
ItemStack battery = new ItemStack(ModItems.battery);
FMLInterModComms.sendMessage("TConstruct", "addFluxBattery", battery);

This code was uploaded by you, and I couldn't find a newer one.
I'll see the TinkerRegistry and TinkerMaterials

commented

That looks like the old 1.7.10 IMC, where did you even find that? This wont work for anything past Minecraft 1.7.10.
Latest IMC infos can usually be found here: https://github.com/SlimeKnights/TinkersConstruct/wiki/IMC

The big question is if you even want IMCs. Those are usually only for standalone mods who want to add some sort of integration. If you're doing something more related to TiC you want to do it in code using the registry.

commented

I see, thank you