aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gtPlusPlus/xmod/reliquary/util/AlkahestRecipeWrapper.java
blob: 2209afddc70e663ccb681858dbe7902c95bfe37a (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
48
49
50
51
package gtPlusPlus.xmod.reliquary.util;

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

import net.minecraft.item.ItemStack;

import gtPlusPlus.core.util.reflect.ReflectionUtils;

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;
    }
}