aboutsummaryrefslogtreecommitdiff
path: root/gtpp/src/main/java/gtPlusPlus/xmod/bop/HANDLER_BiomesOPlenty.java
blob: 7727eaef383756c04f2a71322565f57fd3ff91e1 (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
package gtPlusPlus.xmod.bop;

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

import java.lang.reflect.Field;

import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;

import gtPlusPlus.core.util.minecraft.ItemUtils;
import gtPlusPlus.core.util.reflect.ReflectionUtils;
import gtPlusPlus.xmod.bop.blocks.BOP_Block_Registrator;

public class HANDLER_BiomesOPlenty {

    public static Item mPineCone;

    public static Block logs1;
    public static Block logs2;
    public static Block logs3;
    public static Block logs4;

    public static Block leaves1;
    public static Block leaves2;
    public static Block leaves3;
    public static Block leaves4;

    public static Block colorizedLeaves1;
    public static Block colorizedLeaves2;

    public static Block saplings;
    public static Block colorizedSaplings;

    public static void preInit() {
        BOP_Block_Registrator.run();
        if (BiomesOPlenty.isModLoaded()) {
            setFields();
            registerPineconeToOreDict();
        }
    }

    public static void postInit() {
        BOP_Block_Registrator.recipes();
    }

    private static void registerPineconeToOreDict() {
        if (mPineCone != null) {
            ItemStack aPinecone = ItemUtils.simpleMetaStack(mPineCone, 13, 1);
            if (aPinecone != null) {
                ItemUtils.addItemToOreDictionary(aPinecone, "pinecone");
            }
        }
    }

    public static ItemStack getStack(Block aBlock, int aMeta, int aSize) {
        return ItemUtils.simpleMetaStack(aBlock, aMeta, aSize);
    }

    // BOPCBlocks.logs4 - 0
    // BOPCBlocks.colorizedLeaves2 - 1

    private static void setFields() {
        Field aBopMiscItem = ReflectionUtils
            .getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCItems"), "misc");

        Field aBopBlock1 = ReflectionUtils
            .getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "logs1");
        Field aBopBlock2 = ReflectionUtils
            .getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "logs2");
        Field aBopBlock3 = ReflectionUtils
            .getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "logs3");
        Field aBopBlock4 = ReflectionUtils
            .getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "logs4");

        Field aBopLeaves1 = ReflectionUtils
            .getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "leaves1");
        Field aBopLeaves2 = ReflectionUtils
            .getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "leaves2");
        Field aBopLeaves3 = ReflectionUtils
            .getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "leaves3");
        Field aBopLeaves4 = ReflectionUtils
            .getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "leaves4");

        Field aBopColouredLeaves1 = ReflectionUtils
            .getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "colorizedLeaves1");
        Field aBopColouredLeaves2 = ReflectionUtils
            .getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "colorizedLeaves2");

        Field aBopSapling = ReflectionUtils
            .getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "saplings");
        Field aBopColouredSapling = ReflectionUtils
            .getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "colorizedSaplings");

        if (aBopMiscItem != null) {
            Item aMiscItem = ReflectionUtils.getFieldValue(aBopMiscItem);
            if (aMiscItem != null) {
                mPineCone = aMiscItem;
            }
        }

        if (aBopBlock1 != null) {
            Block aBlock = ReflectionUtils.getFieldValue(aBopBlock1);
            if (aBlock != null) {
                logs1 = aBlock;
            }
        }
        if (aBopBlock2 != null) {
            Block aBlock = ReflectionUtils.getFieldValue(aBopBlock2);
            if (aBlock != null) {
                logs2 = aBlock;
            }
        }
        if (aBopBlock3 != null) {
            Block aBlock = ReflectionUtils.getFieldValue(aBopBlock3);
            if (aBlock != null) {
                logs3 = aBlock;
            }
        }
        if (aBopBlock4 != null) {
            Block aBlock = ReflectionUtils.getFieldValue(aBopBlock4);
            if (aBlock != null) {
                logs4 = aBlock;
            }
        }

        if (aBopLeaves1 != null) {
            Block aBlock = ReflectionUtils.getFieldValue(aBopLeaves1);
            if (aBlock != null) {
                leaves1 = aBlock;
            }
        }
        if (aBopLeaves2 != null) {
            Block aBlock = ReflectionUtils.getFieldValue(aBopLeaves2);
            if (aBlock != null) {
                leaves2 = aBlock;
            }
        }
        if (aBopLeaves3 != null) {
            Block aBlock = ReflectionUtils.getFieldValue(aBopLeaves3);
            if (aBlock != null) {
                leaves3 = aBlock;
            }
        }
        if (aBopLeaves4 != null) {
            Block aBlock = ReflectionUtils.getFieldValue(aBopLeaves4);
            if (aBlock != null) {
                leaves4 = aBlock;
            }
        }

        if (aBopColouredLeaves1 != null) {
            Block aBlock = ReflectionUtils.getFieldValue(aBopColouredLeaves1);
            if (aBlock != null) {
                colorizedLeaves1 = aBlock;
            }
        }
        if (aBopColouredLeaves2 != null) {
            Block aBlock = ReflectionUtils.getFieldValue(aBopColouredLeaves2);
            if (aBlock != null) {
                colorizedLeaves2 = aBlock;
            }
        }

        if (aBopSapling != null) {
            Block aBlock = ReflectionUtils.getFieldValue(aBopSapling);
            if (aBlock != null) {
                saplings = aBlock;
            }
        }
        if (aBopColouredSapling != null) {
            Block aBlock = ReflectionUtils.getFieldValue(aBopColouredSapling);
            if (aBlock != null) {
                colorizedSaplings = aBlock;
            }
        }
    }
}