Jump to content

Adding ThermalExpansion recipes


Nauktis

Recommended Posts

Hi,

 

I know someone probably asked before but I really could not find the information.

I would like to add Thermal Expansion (pulverizer, induction smelter, etc.) recipes for my items.

 

I know the COFH team provides a class ThermalExpansionHelper to do that but I have no idea how to get access to it in my dev environment.

Also, I do not want to depend on any mod. If Thermal Expansion is available, I'll add my recipes but if it is not, my mod will just add classic recipes instead.

 

Could you help me a bit or point me to the right direction?

 

Thanks a lot.

 

N.

Link to comment
Share on other sites

You need to download the "dev" version of CofH and add it to your build path.

I'm away from my own code at the moment, but when I get back in front of it, I can give you a better idea of how our works, I added recipes for my own project. Or I'm pretty sure I did; I spent a good while on IRC asking around about how to do it x3

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

I found a quick and easy way to do it but I am very curious about the dev version of COFH.

They provide so little information on their website for devs...

 

Later I would also like to access the list of existing recipes (to implement my own pulverizer).

So if you have information about that as well please post :)

 

Here's my quick test code (working)

try {
    Class klass = Class.forName("cofh.api.modhelpers.ThermalExpansionHelper");
    Method method = klass.getMethod("addPulverizerRecipe", int.class, ItemStack.class, ItemStack.class);
    method.invoke(null, 150, new ItemStack(Items.apple), new ItemStack(Items.arrow));
} catch (ClassNotFoundException e) {
    e.printStackTrace();
} catch (NoSuchMethodException e) {
    e.printStackTrace();
} catch (InvocationTargetException e) {
    e.printStackTrace();
} catch (IllegalAccessException e) {
    e.printStackTrace();
}

You obviously want to handle the different catch clauses to account for the fact that the recipe was not added.

Link to comment
Share on other sites

Just got to where I can pull up my code (I was on my tablet, on a shitty 3G signal, waiting for my car to get its oil changed, so I couldn't remember how I'd done TE integration).

 

There's actually no reason that you need to reflect access to that class.

 

Because here's what that function you're invoking looks like:

 

public static void addPulverizerRecipe(int energy, ItemStack input, ItemStack primaryOutput, ItemStack secondaryOutput, int secondaryChance) {
	if (input == null || primaryOutput == null) {
		return;
	}
	NBTTagCompound toSend = new NBTTagCompound();
	toSend.setInteger("energy", energy);
	toSend.setTag("input", new NBTTagCompound());
	toSend.setTag("primaryOutput", new NBTTagCompound());
	if (secondaryOutput != null) {
		toSend.setTag("secondaryOutput", new NBTTagCompound());
	}
	input.writeToNBT(toSend.getCompoundTag("input"));
	primaryOutput.writeToNBT(toSend.getCompoundTag("primaryOutput"));
	if (secondaryOutput != null) {
		secondaryOutput.writeToNBT(toSend.getCompoundTag("secondaryOutput"));
		toSend.setInteger("secondaryChance", secondaryChance);
	}
	FMLInterModComms.sendMessage("ThermalExpansion", "PulverizerRecipe", toSend);
}

 

Notice the last line,

FMLInterModComms.sendMessage("ThermalExpansion", "PulverizerRecipe", toSend);

  FML inter-mod communications are an awesome piece of tech that gives a pretty substantial ability for mods to configure each other without the need for adding packages to build paths and what not.

 

So what you actually want to do is basically copy the source for that class (I believe it's on their github? If not I can toss my copy up somewhere, I've forgotten where I got it from) and just add it to your own class hierarchy.  It'll save you on the reflection calls.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.