blob: 26952bd657895846771e8e9f47d6c7ad50038e14 (
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
|
package gtPlusPlus.xmod.sol;
import static gregtech.api.enums.Mods.SpiceOfLife;
import java.lang.reflect.Constructor;
import net.minecraft.item.Item;
import cpw.mods.fml.common.registry.GameRegistry;
import gtPlusPlus.api.objects.Logger;
import gtPlusPlus.core.util.reflect.ReflectionUtils;
public class HANDLER_SpiceOfLife {
public static final void preInit() {
if (SpiceOfLife.isModLoaded()) {
// Add a new Lunch Box with a reasonable amount of slots
tryRegisterNewLunchBox("foodcrate", 12);
}
}
private static boolean tryRegisterNewLunchBox(String aItemName, int aSlots) {
Item aNewBox = getNewLunchBox(aItemName, aSlots);
if (aNewBox != null) {
GameRegistry.registerItem(aNewBox, aItemName);
Logger.INFO("[Spice of Life] Registered " + aItemName + " as a new food container.");
return true;
}
return false;
}
private static Item getNewLunchBox(String aItemName, int aSlots) {
Class aItemFoodContainer = ReflectionUtils.getClass("squeek.spiceoflife.items.ItemFoodContainer");
if (aItemFoodContainer != null) {
Constructor aItemFoodContainerConstructor = ReflectionUtils
.getConstructor(aItemFoodContainer, new Class[] { String.class, int.class });
if (aItemFoodContainerConstructor != null) {
Object aNewObject = ReflectionUtils.createNewInstanceFromConstructor(
aItemFoodContainerConstructor,
new Object[] { aItemName, aSlots });
if (aNewObject instanceof Item) {
Item aNewInstance = (Item) aNewObject;
return aNewInstance;
}
}
}
return null;
}
}
|