aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kubatech/api/utils/InfernalHelper.java
blob: 4bd48274f3347d0b2d368b4465ea08c9970e5224 (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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
/*
 * KubaTech - Gregtech Addon
 * Copyright (C) 2022  kuba6000
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library. If not, see <https://www.gnu.org/licenses/>.
 *
 */

package kubatech.api.utils;

import atomicstryker.infernalmobs.common.InfernalMobsCore;
import atomicstryker.infernalmobs.common.mods.api.ModifierLoader;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;

@SuppressWarnings("unchecked")
public class InfernalHelper {
    private static Method isClassAllowed = null;

    public static boolean isClassAllowed(EntityLivingBase e) {
        try {
            if (isClassAllowed == null) {
                isClassAllowed = InfernalMobsCore.class.getDeclaredMethod("isClassAllowed", EntityLivingBase.class);
                isClassAllowed.setAccessible(true);
            }
            return (boolean) isClassAllowed.invoke(InfernalMobsCore.instance(), e);
        } catch (Throwable exception) {
            exception.printStackTrace();
        }
        return false;
    }

    private static Method checkEntityClassForced = null;

    public static boolean checkEntityClassForced(EntityLivingBase e) {
        try {
            if (checkEntityClassForced == null) {
                checkEntityClassForced =
                        InfernalMobsCore.class.getDeclaredMethod("checkEntityClassForced", EntityLivingBase.class);
                checkEntityClassForced.setAccessible(true);
            }
            return (boolean) checkEntityClassForced.invoke(InfernalMobsCore.instance(), e);
        } catch (Throwable exception) {
            exception.printStackTrace();
        }
        return false;
    }

    private static Field modifierLoaders = null;

    public static ArrayList<ModifierLoader<?>> getModifierLoaders() {
        try {
            if (modifierLoaders == null) {
                modifierLoaders = InfernalMobsCore.class.getDeclaredField("modifierLoaders");
                modifierLoaders.setAccessible(true);
            }
            return (ArrayList<ModifierLoader<?>>) modifierLoaders.get(InfernalMobsCore.instance());
        } catch (Throwable exception) {
            exception.printStackTrace();
        }
        return new ArrayList<>();
    }

    private static Field eliteRarity;

    public static int getEliteRarity() {
        try {
            if (eliteRarity == null) {
                eliteRarity = InfernalMobsCore.class.getDeclaredField("eliteRarity");
                eliteRarity.setAccessible(true);
            }
            return eliteRarity.getInt(InfernalMobsCore.instance());
        } catch (Throwable exception) {
            exception.printStackTrace();
        }
        return 15;
    }

    private static Field ultraRarity;

    public static int getUltraRarity() {
        try {
            if (ultraRarity == null) {
                ultraRarity = InfernalMobsCore.class.getDeclaredField("ultraRarity");
                ultraRarity.setAccessible(true);
            }
            return ultraRarity.getInt(InfernalMobsCore.instance());
        } catch (Throwable exception) {
            exception.printStackTrace();
        }
        return 15;
    }

    private static Field infernoRarity;

    public static int getInfernoRarity() {
        try {
            if (infernoRarity == null) {
                infernoRarity = InfernalMobsCore.class.getDeclaredField("infernoRarity");
                infernoRarity.setAccessible(true);
            }
            return infernoRarity.getInt(InfernalMobsCore.instance());
        } catch (Throwable exception) {
            exception.printStackTrace();
        }
        return 15;
    }

    private static Field minEliteModifiers;

    public static int getMinEliteModifiers() {
        try {
            if (minEliteModifiers == null) {
                minEliteModifiers = InfernalMobsCore.class.getDeclaredField("minEliteModifiers");
                minEliteModifiers.setAccessible(true);
            }
            return minEliteModifiers.getInt(InfernalMobsCore.instance());
        } catch (Throwable exception) {
            exception.printStackTrace();
        }
        return 15;
    }

    private static Field minUltraModifiers;

    public static int getMinUltraModifiers() {
        try {
            if (minUltraModifiers == null) {
                minUltraModifiers = InfernalMobsCore.class.getDeclaredField("minUltraModifiers");
                minUltraModifiers.setAccessible(true);
            }
            return minUltraModifiers.getInt(InfernalMobsCore.instance());
        } catch (Throwable exception) {
            exception.printStackTrace();
        }
        return 15;
    }

    private static Field minInfernoModifiers;

    public static int getMinInfernoModifiers() {
        try {
            if (minInfernoModifiers == null) {
                minInfernoModifiers = InfernalMobsCore.class.getDeclaredField("minInfernoModifiers");
                minInfernoModifiers.setAccessible(true);
            }
            return minInfernoModifiers.getInt(InfernalMobsCore.instance());
        } catch (Throwable exception) {
            exception.printStackTrace();
        }
        return 15;
    }

    private static Field dimensionBlackList;

    public static ArrayList<Integer> getDimensionBlackList() {
        try {
            if (dimensionBlackList == null) {
                dimensionBlackList = InfernalMobsCore.class.getDeclaredField("dimensionBlackList");
                dimensionBlackList.setAccessible(true);
            }
            return (ArrayList<Integer>) dimensionBlackList.get(InfernalMobsCore.instance());
        } catch (Throwable exception) {
            exception.printStackTrace();
        }
        return new ArrayList<>();
    }

    private static Field dropIdListElite;

    public static ArrayList<ItemStack> getDropIdListElite() {
        try {
            if (dropIdListElite == null) {
                dropIdListElite = InfernalMobsCore.class.getDeclaredField("dropIdListElite");
                dropIdListElite.setAccessible(true);
            }
            return (ArrayList<ItemStack>) dropIdListElite.get(InfernalMobsCore.instance());
        } catch (Throwable exception) {
            exception.printStackTrace();
        }
        return new ArrayList<>();
    }

    private static Field dropIdListUltra;

    public static ArrayList<ItemStack> getDropIdListUltra() {
        try {
            if (dropIdListUltra == null) {
                dropIdListUltra = InfernalMobsCore.class.getDeclaredField("dropIdListUltra");
                dropIdListUltra.setAccessible(true);
            }
            return (ArrayList<ItemStack>) dropIdListUltra.get(InfernalMobsCore.instance());
        } catch (Throwable exception) {
            exception.printStackTrace();
        }
        return new ArrayList<>();
    }

    private static Field dropIdListInfernal;

    public static ArrayList<ItemStack> getDropIdListInfernal() {
        try {
            if (dropIdListInfernal == null) {
                dropIdListInfernal = InfernalMobsCore.class.getDeclaredField("dropIdListInfernal");
                dropIdListInfernal.setAccessible(true);
            }
            return (ArrayList<ItemStack>) dropIdListInfernal.get(InfernalMobsCore.instance());
        } catch (Throwable exception) {
            exception.printStackTrace();
        }
        return new ArrayList<>();
    }
}