aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/xmod/reliquary/util/AlkahestRecipeWrapper.java
blob: 6086b74ec421b16072ce6ba2415b4bc54dd437b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package gtPlusPlus.xmod.reliquary.util;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

import gtPlusPlus.core.util.reflect.ReflectionUtils;
import net.minecraft.item.ItemStack;

public class AlkahestRecipeWrapper {
	public ItemStack item = null;
	public int yield = 0;
	public int cost = 0;
	public String dictionaryName = null;

	public AlkahestRecipeWrapper(ItemStack par1, int par2, int par3) {
		this.item = par1;
		this.yield = par2;
		this.cost = par3;
	}

	public AlkahestRecipeWrapper(String par1, int par2, int par3) {
		this.dictionaryName = par1;
		this.yield = par2;
		this.cost = par3;
	}

	public Object getOriginalRecipe() {
		try {
			Constructor<?> o;
			if (dictionaryName == null) {
				 o = ReflectionUtils.getClass("xreliquary.util.alkahestry.AlkahestRecipe").getConstructor(ItemStack.class, int.class, int.class);
			}
			else {
				 o = ReflectionUtils.getClass("xreliquary.util.alkahestry.AlkahestRecipe").getConstructor(String.class, int.class, int.class);
			}
			
			Object r = o.newInstance(dictionaryName == null ? item : dictionaryName, yield, cost);
			if (r != null) {
				return r;
			}

		} catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
			// oops
		}
		return null;
	}
}