diff options
author | Draknyte1 <Draknyte1@hotmail.com> | 2016-09-07 16:36:25 +1000 |
---|---|---|
committer | Draknyte1 <Draknyte1@hotmail.com> | 2016-09-07 16:36:25 +1000 |
commit | 221c2f0fe81430e7dd4087e5f5845bd7c62ec56d (patch) | |
tree | d6e0faaef01b9d517828557e1be82500d476f95e /src/Java/gtPlusPlus/core/util/gregtech | |
parent | 5872c0947ce7bc788b03fa2fb690b8815d3d0a04 (diff) | |
download | GT5-Unofficial-221c2f0fe81430e7dd4087e5f5845bd7c62ec56d.tar.gz GT5-Unofficial-221c2f0fe81430e7dd4087e5f5845bd7c62ec56d.tar.bz2 GT5-Unofficial-221c2f0fe81430e7dd4087e5f5845bd7c62ec56d.zip |
% Refactored the entire project to stop using MiscUtils everywhere possible, now it's gtPlusPlus.
Diffstat (limited to 'src/Java/gtPlusPlus/core/util/gregtech')
-rw-r--r-- | src/Java/gtPlusPlus/core/util/gregtech/recipehandlers/GregtechRecipe.java | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/src/Java/gtPlusPlus/core/util/gregtech/recipehandlers/GregtechRecipe.java b/src/Java/gtPlusPlus/core/util/gregtech/recipehandlers/GregtechRecipe.java new file mode 100644 index 0000000000..d1857ffefc --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/gregtech/recipehandlers/GregtechRecipe.java @@ -0,0 +1,87 @@ +package gtPlusPlus.core.util.gregtech.recipehandlers; + +import gregtech.api.util.GT_ModHandler; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; + +import java.lang.reflect.Method; + +import net.minecraft.item.ItemStack; + +public final class GregtechRecipe { + + public LibraryProxy ourProxy; + public GregtechRecipe(){ + Utils.LOG_INFO("Initializing a recipe handler for different versions of Gregtech 5."); + try { + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ + this.ourProxy = new LibProxy1(); + Utils.LOG_INFO("Selecting GT 5.7/5.8 Recipe Set"); + } + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ + this.ourProxy = new LibProxy2(); + Utils.LOG_INFO("Selecting GT 5.9 Recipe Set"); + } + } catch (NoSuchMethodException e) { + this.ourProxy = null; + } + } + + public boolean addSmeltingAndAlloySmeltingRecipe(ItemStack aInput, ItemStack aOutput) { + Utils.LOG_INFO("Adding a GT Furnace/Alloy Smelter Recipe"); + return ourProxy.addSmeltingAndAlloySmeltingRecipe(aInput, aOutput); + } + +} + +abstract class LibraryProxy { // can also be interface unless you want to have common code here + abstract public boolean addSmeltingAndAlloySmeltingRecipe(ItemStack aInput, ItemStack aOutput); +} + +class LibProxy1 extends LibraryProxy { + final Method m1; + + public LibProxy1() throws NoSuchMethodException { + m1 = GT_ModHandler.class.getDeclaredMethod("addSmeltingAndAlloySmeltingRecipe", ItemStack.class, ItemStack.class); + } + + @Override + public boolean addSmeltingAndAlloySmeltingRecipe(ItemStack aInput, ItemStack aOutput) { + try { + Utils.LOG_INFO("Trying with Gt 5.7/5.8 Method."); + return (boolean) m1.invoke(null, aInput, aOutput); + } catch (Exception e) { + throw new RuntimeException(e); + } + } +} + +class LibProxy2 extends LibraryProxy { + final Method m2; + + public LibProxy2() throws NoSuchMethodException { + m2 = GT_ModHandler.class.getDeclaredMethod("addSmeltingAndAlloySmeltingRecipe", ItemStack.class, ItemStack.class, boolean.class); + } + + @Override + public boolean addSmeltingAndAlloySmeltingRecipe(ItemStack aInput, ItemStack aOutput) { + try { + Utils.LOG_INFO("Trying with Gt 5.9 Method."); + return (boolean) m2.invoke(null, aInput, aOutput, true); + } catch (Exception e) { + throw new RuntimeException(e); + } + } +} + +/*class Lib { // v1 + public static void addRecipe(ItemStack aInput, ItemStack aOutput) { + System.out.println("shit totally happened v1"); + } +} + +class Lib2 { // v2 + public static void addRecipe(ItemStack aInput, ItemStack aOutput, boolean hidden) { + System.out.println("shit totally happened v2"); + } +}*/
\ No newline at end of file |