aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/detrav/utils/GTppHelper.java
blob: 985ca3386b90f28666f28ae418085acf26f49248 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package detrav.utils;

import java.util.HashMap;

import net.minecraft.block.Block;

import gtPlusPlus.core.block.base.BlockBaseOre;
import gtPlusPlus.core.material.Material;
import gtPlusPlus.core.material.MaterialMisc;
import gtPlusPlus.core.material.MaterialsAlloy;
import gtPlusPlus.core.material.MaterialsElements;
import gtPlusPlus.core.material.MaterialsOres;
import gtPlusPlus.core.material.nuclear.MaterialsFluorides;

/**
 * Created by bartimaeusnek on 19.04.2018.
 */
public class GTppHelper {

    public static final HashMap<Short, Material> decodeoresGTpp = new HashMap<>();
    public static final HashMap<Material, Short> encodeoresGTpp = new HashMap<>();

    public static void generate_OreIDs() {
        short n = 0;
        for (; n < MaterialsOres.class.getFields().length; ++n) {
            try {
                Short i = (short) (n + 1);
                Material m = ((Material) MaterialsOres.class.getFields()[n].get(MaterialsOres.class.getFields()[n]));
                decodeoresGTpp.put(i, m);
                encodeoresGTpp.put(m, i);
            } catch (Exception ignored) {}
        }
        // Manually add ores from other places than the ore class
        // Fluorite
        decodeoresGTpp.put((short) (++n + 1), MaterialsFluorides.FLUORITE);
        encodeoresGTpp.put(MaterialsFluorides.FLUORITE, (short) (n + 1));
        // Rare Earths
        decodeoresGTpp.put((short) (++n + 1), MaterialMisc.RARE_EARTH_LOW);
        encodeoresGTpp.put(MaterialMisc.RARE_EARTH_LOW, (short) (n + 1));
        decodeoresGTpp.put((short) (++n + 1), MaterialMisc.RARE_EARTH_MID);
        encodeoresGTpp.put(MaterialMisc.RARE_EARTH_MID, (short) (n + 1));
        decodeoresGTpp.put((short) (++n + 1), MaterialMisc.RARE_EARTH_HIGH);
        encodeoresGTpp.put(MaterialMisc.RARE_EARTH_HIGH, (short) (n + 1));
        // Koboldite
        decodeoresGTpp.put((short) (++n + 1), MaterialsAlloy.KOBOLDITE);
        encodeoresGTpp.put(MaterialsAlloy.KOBOLDITE, (short) (n + 1));
        // Runite
        decodeoresGTpp.put((short) (++n + 1), MaterialsElements.STANDALONE.RUNITE);
        encodeoresGTpp.put(MaterialsElements.STANDALONE.RUNITE, (short) (n + 1));
        // Ancient granite
        decodeoresGTpp.put((short) (++n + 1), MaterialsElements.STANDALONE.GRANITE);
        encodeoresGTpp.put(MaterialsElements.STANDALONE.GRANITE, (short) (n + 1));
    }

    public static boolean isGTppBlock(Block tBlock) {
        return tBlock instanceof BlockBaseOre;
    }

    public static short getGTppMeta(Block tBlock) {
        return (short) (GTppHelper.encodeoresGTpp.get(((BlockBaseOre) tBlock).getMaterialEx()) + 7000);
    }

    public static String getGTppVeinName(Block tBlock) {
        return tBlock.getLocalizedName();
    }

}