diff options
author | Johann Bernhardt <johann.bernhardt@tum.de> | 2021-12-12 19:38:06 +0100 |
---|---|---|
committer | Johann Bernhardt <johann.bernhardt@tum.de> | 2021-12-12 19:38:06 +0100 |
commit | 311ab89f93558233a40079f7cb16605b141b5346 (patch) | |
tree | c5f44ef47f441a57c5f57aa801f639c7879ed760 /src/main/java/gtPlusPlus/xmod/sol | |
parent | 896143b96132f5ac54aa8d8f7386f27487e5e530 (diff) | |
download | GT5-Unofficial-311ab89f93558233a40079f7cb16605b141b5346.tar.gz GT5-Unofficial-311ab89f93558233a40079f7cb16605b141b5346.tar.bz2 GT5-Unofficial-311ab89f93558233a40079f7cb16605b141b5346.zip |
Move sources and resources
Diffstat (limited to 'src/main/java/gtPlusPlus/xmod/sol')
-rw-r--r-- | src/main/java/gtPlusPlus/xmod/sol/HANDLER_SpiceOfLife.java | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/main/java/gtPlusPlus/xmod/sol/HANDLER_SpiceOfLife.java b/src/main/java/gtPlusPlus/xmod/sol/HANDLER_SpiceOfLife.java new file mode 100644 index 0000000000..11cc5da89c --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/sol/HANDLER_SpiceOfLife.java @@ -0,0 +1,61 @@ +package gtPlusPlus.xmod.sol; + +import java.lang.reflect.Constructor; + +import cpw.mods.fml.common.registry.GameRegistry; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.item.Item; + +public class HANDLER_SpiceOfLife { + + public static final void preInit() { + if (LoadedMods.SpiceOfLife) { + //Add a new Lunch Box with a reasonable amount of slots + tryRegisterNewLunchBox("foodcrate", 12); + } + } + + public static final void init() { + if (LoadedMods.SpiceOfLife) { + + } + } + + public static final void postInit() { + if (LoadedMods.SpiceOfLife) { + + } + } + + 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; + } + + + + + +} |