Jump to content

[1.10.2] Custom Tinker's Construct Materials


HenryRichard

Recommended Posts

I've been trying to integrate my mod with Tinker's Construct by adding some customized tool parts, but I've been trying for the past few days and have absolutely nothing working. I've googled this about thirty times, but nothing I found seems to work for me. Toolparts with my material aren't showing up in the Tinker's Toolparts creative tab, aren't craftable in the part maker, and if I try to use commands to give myself a tool part, it just says "Missing Material: Pinkite." Here's the code I'm trying to use:

package henryrichard.epicwasteoftime.init;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fluids.BlockFluidClassic;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.Optional;
import net.minecraftforge.fml.common.event.FMLInterModComms;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class EWOTTConstruct {

public static void preInitTConstruct() {
	if(Loader.isModLoaded("tconstruct")) {
		System.out.println("Tinker's Construct found! Doing some neat setup stuff...");
		addToolMaterial(50, "Pinkite", 1, 1200, 6, 1, 0.1f, TextFormatting.RED.toString(), 255 << 24 | 120 << 16 | 255 << 8 | 40, 1, 0.1f, 2.3f, 6, EWOTItems.pinkiteIngot);
		System.out.println("Done with neat setup stuff!");
	} else {
		System.out.println("Tinker's Construct not found. Skipped neat setup stuff.");
	}
}

private static void addToolMaterial(int id, String name, int harvestLevel, int durability, int miningSpeed, int attack,
		float handleModifier, String style, int color, int bowDrawSpeed, float bowProjectileSpeed, float projectileMass, int projectileFragility,
		Item material) {
	NBTTagCompound tag = new NBTTagCompound();
	tag.setInteger("Id", id); // Unique material ID. Reseved IDs: 0-40 Tinker, 41-45 Iguana Tinker Tweaks, 100-200 ExtraTiC
	tag.setString("Name", name); // Unique material name
	tag.setInteger("HarvestLevel", harvestLevel);
	tag.setInteger("Durability", durability);
	tag.setInteger("MiningSpeed", miningSpeed);
	tag.setInteger("Attack", attack); // optional
	tag.setFloat("HandleModifier", handleModifier);
	//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", style); // optional, color of the material text
	//tag.setInteger("Color", 255 << 24 | 45 << 16 | 45 << 8 | 40);
	tag.setInteger("Color", color); // 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", bowDrawSpeed); // the higher the longer it takes to draw the bow
	tag.setFloat("Bow_ProjectileSpeed", bowProjectileSpeed); // the higher the faster the projectile goes

	// additional stats for arrows
	tag.setFloat("Projectile_Mass", projectileMass);
	tag.setFloat("Projectile_Fragility", projectileFragility); // 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", id);
	//tag.setInteger("Value", 2); // 1 material ever 2 value. See PartMapping IMC
	NBTTagCompound item = new NBTTagCompound();
	(new ItemStack(material)).writeToNBT(item);
	tag.setTag("Item", item);

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

	/* This part adds mappings, 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", id); // output material id
	item = new NBTTagCompound();
	(new ItemStack(material)).writeToNBT(item);
	tag.setTag("Item", item);

	FMLInterModComms.sendMessage("tconstruct", "addPartBuilderMaterial", tag);
}

}

 

I'm calling preInitTConstruct() in my mod's CommonProxy's preInit method, after all my items have been declared and registered (so pinkiteIngot isn't null). I've also tried calling it in my init method, same result. Tinker's Construct is installed and my mod knows it, since Loader.isModLoaded("tconstruct") is true and stuff gets printed to the console. I just don't know what to do now. Any ideas?

I'll put something here when I have something of value I need to put at the end of every post. For now it's this mostly pointless text.

Link to comment
Share on other sites

I decided to look into the source for TConstruct and decided to just try and use the same code it used for registering materials - and lo and behold, it worked! I think the IMC for Tinker's Construct wasn't carried over past 1.7, so you now have to do something like this:

Material pinkite = new Material("pinkite", 0xffddff);
    TinkerMaterials.materials.add(pinkite);
    pinkite.setCraftable(true);
    pinkite.addItemIngot("ingotPinkite");
    pinkite.setRepresentativeItem(new ItemStack(EWOTItems.pinkiteIngot));
    pinkite.addTrait(TinkerTraits.dense, MaterialTypes.HEAD);
    pinkite.addTrait(TinkerTraits.duritos);
    TinkerRegistry.addMaterialStats(pinkite,
                new HeadMaterialStats(700, 6.00f, 3.00f, HarvestLevels.IRON),
                new HandleMaterialStats(0.50f, 350),
                new ExtraMaterialStats(150),
                new BowMaterialStats(0.5f, 1.5f, 7f));
    TinkerIntegration.integrationList.add(new MaterialIntegration(pinkite));

I'll put something here when I have something of value I need to put at the end of every post. For now it's this mostly pointless text.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.