aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/tectech/loader/recipe/BaseRecipeLoader.java
blob: 445dd9c069009e0c45844c45a9de19afcf18eccb (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 tectech.loader.recipe;

import static gregtech.api.enums.Mods.NewHorizonsCoreMod;

import gregtech.api.enums.Materials;
import gregtech.api.interfaces.IItemContainer;
import tectech.TecTech;

/**
 * Created by danie_000 on 16.11.2016.
 */
public class BaseRecipeLoader {

    @SuppressWarnings("rawtypes")
    private static Class CUSTOM_ITEM_LIST;

    static {
        try {
            CUSTOM_ITEM_LIST = Class.forName("com.dreammaster.gthandler.CustomItemList");
        } catch (Exception e) {
            TecTech.LOGGER.error("NHCoreMod not present. Disabling all the recipes");
        }
    }

    @SuppressWarnings("unchecked")
    public static IItemContainer getItemContainer(String name) {
        // must never be called before the try catch block is ran
        return (IItemContainer) Enum.valueOf(CUSTOM_ITEM_LIST, name);
    }

    public static Materials getOrDefault(String name, Materials def) {
        Materials mat = Materials.get(name);
        return mat == Materials._NULL ? def : mat;
    }

    public void run() {
        // todo: Move those recipes in NHCore
        if (NewHorizonsCoreMod.isModLoaded()) {
            new Assembler().run();
            new AssemblyLine().run();
            new CircuitAssembler().run();
            new Crafting().run();
            new Extractor().run();
            new ResearchStationAssemblyLine().run();
            new Godforge().run();
        } else {
            Godforge.runDevEnvironmentRecipes();
        }
        Godforge.addFakeUpgradeCostRecipes();
    }
}