aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Java/miscutil/MiscUtils.java9
-rw-r--r--src/Java/miscutil/core/common/CommonProxy.java17
-rw-r--r--src/Java/miscutil/core/item/base/dusts/BaseItemDust.java3
-rw-r--r--src/Java/miscutil/core/lib/CORE.java2
-rw-r--r--src/Java/miscutil/core/util/ClassUtils.java23
-rw-r--r--src/Java/miscutil/core/util/LoggingUtils.java54
-rw-r--r--src/Java/miscutil/core/util/gregtech/five/GregtechVersionRecipeHandler.java23
-rw-r--r--src/Java/miscutil/core/util/gregtech/five/eight/AddSmeltingAndAlloySmeltingRecipe.java21
-rw-r--r--src/Java/miscutil/core/util/gregtech/five/nine/AddSmeltingAndAlloySmeltingRecipe.java21
-rw-r--r--src/Java/miscutil/core/util/gregtech/recipehandlers/GregtechRecipe.java87
-rw-r--r--src/Java/miscutil/xmod/gregtech/api/util/GregtechRecipeRegistrator.java4
11 files changed, 186 insertions, 78 deletions
diff --git a/src/Java/miscutil/MiscUtils.java b/src/Java/miscutil/MiscUtils.java
index 545e29a584..e02ad3233d 100644
--- a/src/Java/miscutil/MiscUtils.java
+++ b/src/Java/miscutil/MiscUtils.java
@@ -21,7 +21,10 @@ import miscutil.core.handler.events.LoginEventHandler;
import miscutil.core.item.general.RF2EU_Battery;
import miscutil.core.lib.CORE;
import miscutil.core.util.Utils;
+import miscutil.core.util.item.UtilsItems;
import miscutil.xmod.gregtech.HANDLER_GT;
+import net.minecraft.init.Items;
+import net.minecraft.item.ItemStack;
import net.minecraftforge.common.config.Configuration;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
@@ -111,6 +114,12 @@ implements ActionListener
public void serverStarting(FMLServerStartingEvent event)
{
event.registerServerCommand(new CommandMath());
+ ItemStack input = UtilsItems.getSimpleStack(Items.poisonous_potato);
+ ItemStack output = UtilsItems.getSimpleStack(Items.baked_potato);
+ CORE.GT_Recipe.addSmeltingAndAlloySmeltingRecipe(input, output);
+ input = UtilsItems.getSimpleStack(Items.slime_ball);
+ output = UtilsItems.getSimpleStack(Items.nether_star);
+ CORE.GT_Recipe.addSmeltingAndAlloySmeltingRecipe(input, output);
}
@Mod.EventHandler
diff --git a/src/Java/miscutil/core/common/CommonProxy.java b/src/Java/miscutil/core/common/CommonProxy.java
index eec65c0bb3..79c4a7b665 100644
--- a/src/Java/miscutil/core/common/CommonProxy.java
+++ b/src/Java/miscutil/core/common/CommonProxy.java
@@ -36,6 +36,14 @@ public class CommonProxy {
MinecraftForge.EVENT_BUS.register(this);
FMLCommonHandler.instance().bus().register(this);
if (LoadedMods.Gregtech){
+ if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){
+ Utils.LOG_INFO("We're using Gregtech 5.09 Experimental.");
+ }
+ else {
+ Utils.LOG_INFO("We're using Gregtech 5.08 or an equivalent fork.");
+ }
+ }
+ if (LoadedMods.Gregtech){
for (String tOreName : OreDictionary.getOreNames()) {
ItemStack tOreStack;
for (Iterator i$ = OreDictionary.getOres(tOreName).iterator(); i$.hasNext(); Meta_GT_Proxy.registerOre(new OreDictionary.OreRegisterEvent(tOreName, tOreStack))) {
@@ -52,15 +60,6 @@ public class CommonProxy {
LoadedMods.checkLoaded();
Utils.LOG_INFO("Making sure we're ready to party!");
- if (LoadedMods.Gregtech){
- if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){
- Utils.LOG_INFO("We're using Gregtech 5.09 Experimental.");
- }
- else {
- Utils.LOG_INFO("We're using Gregtech 5.08 or an equivalent fork.");
- }
- }
-
if (!DEBUG){
Utils.LOG_WARNING("Development mode not enabled.");
diff --git a/src/Java/miscutil/core/item/base/dusts/BaseItemDust.java b/src/Java/miscutil/core/item/base/dusts/BaseItemDust.java
index 5084e71018..2723debd7b 100644
--- a/src/Java/miscutil/core/item/base/dusts/BaseItemDust.java
+++ b/src/Java/miscutil/core/item/base/dusts/BaseItemDust.java
@@ -10,7 +10,6 @@ import java.util.List;
import miscutil.core.lib.CORE;
import miscutil.core.lib.MaterialInfo;
import miscutil.core.util.Utils;
-import miscutil.core.util.gregtech.five.GregtechVersionRecipeHandler;
import miscutil.core.util.item.UtilsItems;
import miscutil.core.util.math.MathUtils;
import miscutil.core.util.recipe.UtilsRecipe;
@@ -310,7 +309,7 @@ public class BaseItemDust extends Item{
Utils.LOG_WARNING("This will produce an ingot of "+tempOutputStack.getDisplayName() + " Debug: "+temp);
if (null != tempOutputStack){
if (mTier < 5){
- GregtechVersionRecipeHandler.addSmeltingAndAlloySmeltingRecipe(UtilsItems.getSimpleStack(this), tempOutputStack);
+ CORE.GT_Recipe.addSmeltingAndAlloySmeltingRecipe(UtilsItems.getSimpleStack(this), tempOutputStack);
}
else if (mTier >= 5){
Utils.LOG_WARNING("Adding recipe for "+materialName+" Ingots in a Blast furnace.");
diff --git a/src/Java/miscutil/core/lib/CORE.java b/src/Java/miscutil/core/lib/CORE.java
index 49b8d2a7b1..b2f29b8ad9 100644
--- a/src/Java/miscutil/core/lib/CORE.java
+++ b/src/Java/miscutil/core/lib/CORE.java
@@ -5,6 +5,7 @@ import java.util.List;
import java.util.Map;
import miscutil.core.creative.AddToCreativeTab;
+import miscutil.core.util.gregtech.recipehandlers.GregtechRecipe;
import miscutil.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials;
import miscutil.xmod.gregtech.api.interfaces.internal.IGregtech_RecipeAdder;
import miscutil.xmod.gregtech.common.Meta_GT_Proxy;
@@ -28,6 +29,7 @@ public class CORE {
public static IGregtech_RecipeAdder RA;
@Deprecated
public static IGregtech_RecipeAdder sRecipeAdder;
+ public static GregtechRecipe GT_Recipe = new GregtechRecipe();
@SideOnly(Side.CLIENT)
public static IIconRegister GT_BlockIcons, GT_ItemIcons;
diff --git a/src/Java/miscutil/core/util/ClassUtils.java b/src/Java/miscutil/core/util/ClassUtils.java
new file mode 100644
index 0000000000..6ea9336006
--- /dev/null
+++ b/src/Java/miscutil/core/util/ClassUtils.java
@@ -0,0 +1,23 @@
+package miscutil.core.util;
+
+public class ClassUtils {
+
+
+ /*@ if (isPresent("com.optionaldependency.DependencyClass")) {
+ // This block will never execute when the dependency is not present
+ // There is therefore no more risk of code throwing NoClassDefFoundException.
+ executeCodeLinkingToDependency();
+ }*/
+ public static boolean isPresent(String className) {
+ try {
+ Class.forName(className);
+ return true;
+ } catch (Throwable ex) {
+ // Class or one of its dependencies is not present...
+ return false;
+ }
+ }
+
+
+
+}
diff --git a/src/Java/miscutil/core/util/LoggingUtils.java b/src/Java/miscutil/core/util/LoggingUtils.java
new file mode 100644
index 0000000000..5942ead120
--- /dev/null
+++ b/src/Java/miscutil/core/util/LoggingUtils.java
@@ -0,0 +1,54 @@
+package miscutil.core.util;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.Date;
+
+public class LoggingUtils {
+
+ public static void profileLog(Object o){
+ try {
+ String content;
+ File file = new File("GregtechTimingsTC.txt");
+ // if file doesnt exists, then create it
+ if (!file.exists()) {
+ file.createNewFile();
+ FileWriter fw = new FileWriter(file.getAbsoluteFile(), true);
+ BufferedWriter bw = new BufferedWriter(fw);
+ bw.write("============================================================");
+ bw.write(System.lineSeparator());
+ bw.close();
+ }
+ if (o instanceof String){
+ content = (String) o;
+ }
+ else {
+ content = o.toString();
+ }
+ FileWriter fw = new FileWriter(file.getAbsoluteFile(), true);
+ BufferedWriter bw = new BufferedWriter(fw);
+ bw.write(content);
+ bw.write(System.lineSeparator());
+ bw.close();
+ System.out.println("Data Logged.");
+
+ } catch (IOException e) {
+ System.out.println("Data logging failed.");
+ }
+ }
+
+ public static boolean logCurrentSystemTime(String message){
+ Date date = new Date(System.currentTimeMillis());
+ try {
+ profileLog(message+" | "+date.toString());
+ return true;
+ }
+ catch (Throwable r) {
+ return false;
+ }
+
+ }
+
+}
diff --git a/src/Java/miscutil/core/util/gregtech/five/GregtechVersionRecipeHandler.java b/src/Java/miscutil/core/util/gregtech/five/GregtechVersionRecipeHandler.java
deleted file mode 100644
index 3025183204..0000000000
--- a/src/Java/miscutil/core/util/gregtech/five/GregtechVersionRecipeHandler.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package miscutil.core.util.gregtech.five;
-
-import miscutil.core.lib.CORE;
-import net.minecraft.item.ItemStack;
-
-public class GregtechVersionRecipeHandler {
-
- public static final boolean mainFork = isExperimentalVersion();
-
- public static boolean isExperimentalVersion(){
- return CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK;
- }
-
- public static void addSmeltingAndAlloySmeltingRecipe(ItemStack aInput, ItemStack aOutput){
- if (mainFork){
- miscutil.core.util.gregtech.five.nine.AddSmeltingAndAlloySmeltingRecipe.run(aInput, aOutput, false);
- }
- else {
- miscutil.core.util.gregtech.five.eight.AddSmeltingAndAlloySmeltingRecipe.run(aInput, aOutput);
- }
- }
-
-}
diff --git a/src/Java/miscutil/core/util/gregtech/five/eight/AddSmeltingAndAlloySmeltingRecipe.java b/src/Java/miscutil/core/util/gregtech/five/eight/AddSmeltingAndAlloySmeltingRecipe.java
deleted file mode 100644
index d990e70bae..0000000000
--- a/src/Java/miscutil/core/util/gregtech/five/eight/AddSmeltingAndAlloySmeltingRecipe.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package miscutil.core.util.gregtech.five.eight;
-
-import static gregtech.api.enums.GT_Values.RA;
-import gregtech.api.enums.ItemList;
-import gregtech.api.enums.OrePrefixes;
-import gregtech.api.util.GT_ModHandler;
-import net.minecraft.item.ItemStack;
-
-public class AddSmeltingAndAlloySmeltingRecipe {
-
- public static boolean run(ItemStack aInput, ItemStack aOutput) {
- if (aInput == null || aOutput == null) return false;
- boolean temp = false;
- if (aInput.stackSize == 1 && GT_ModHandler.addSmeltingRecipe(aInput, aOutput)) temp = true;
- if (RA.addAlloySmelterRecipe(aInput, OrePrefixes.ingot.contains(aOutput) ? ItemList.Shape_Mold_Ingot.get(0) : OrePrefixes.block.contains(aOutput) ? ItemList.Shape_Mold_Block.get(0) : OrePrefixes.nugget.contains(aOutput) ? ItemList.Shape_Mold_Nugget.get(0) : null, aOutput, 130, 3))
- temp = true;
- if (GT_ModHandler.addInductionSmelterRecipe(aInput, null, aOutput, null, aOutput.stackSize * 1600, 0)) temp = true;
- return temp;
- }
-
-}
diff --git a/src/Java/miscutil/core/util/gregtech/five/nine/AddSmeltingAndAlloySmeltingRecipe.java b/src/Java/miscutil/core/util/gregtech/five/nine/AddSmeltingAndAlloySmeltingRecipe.java
deleted file mode 100644
index 267a14b85e..0000000000
--- a/src/Java/miscutil/core/util/gregtech/five/nine/AddSmeltingAndAlloySmeltingRecipe.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package miscutil.core.util.gregtech.five.nine;
-
-import gregtech.api.enums.GT_Values;
-import gregtech.api.enums.ItemList;
-import gregtech.api.enums.OrePrefixes;
-import gregtech.api.util.GT_ModHandler;
-import net.minecraft.item.ItemStack;
-
-public class AddSmeltingAndAlloySmeltingRecipe {
-
- public static boolean run(ItemStack aInput, ItemStack aOutput, boolean hidden) {
- if (aInput == null || aOutput == null) return false;
- boolean temp = false;
- if (aInput.stackSize == 1 && GT_ModHandler.addSmeltingRecipe(aInput, aOutput)) temp = true;
- if (GT_Values.RA.addAlloySmelterRecipe(aInput, OrePrefixes.ingot.contains(aOutput) ? ItemList.Shape_Mold_Ingot.get(0) : OrePrefixes.block.contains(aOutput) ? ItemList.Shape_Mold_Block.get(0) : OrePrefixes.nugget.contains(aOutput) ? ItemList.Shape_Mold_Nugget.get(0) : null, aOutput, 130, 3))
- temp = true;
- if (GT_ModHandler.addInductionSmelterRecipe(aInput, null, aOutput, null, aOutput.stackSize * 1600, 0)) temp = true;
- return temp;
- }
-
-}
diff --git a/src/Java/miscutil/core/util/gregtech/recipehandlers/GregtechRecipe.java b/src/Java/miscutil/core/util/gregtech/recipehandlers/GregtechRecipe.java
new file mode 100644
index 0000000000..bab4c1ff0d
--- /dev/null
+++ b/src/Java/miscutil/core/util/gregtech/recipehandlers/GregtechRecipe.java
@@ -0,0 +1,87 @@
+package miscutil.core.util.gregtech.recipehandlers;
+
+import gregtech.api.util.GT_ModHandler;
+
+import java.lang.reflect.Method;
+
+import miscutil.core.lib.CORE;
+import miscutil.core.util.Utils;
+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
diff --git a/src/Java/miscutil/xmod/gregtech/api/util/GregtechRecipeRegistrator.java b/src/Java/miscutil/xmod/gregtech/api/util/GregtechRecipeRegistrator.java
index 6e035fdd80..0b2c04a193 100644
--- a/src/Java/miscutil/xmod/gregtech/api/util/GregtechRecipeRegistrator.java
+++ b/src/Java/miscutil/xmod/gregtech/api/util/GregtechRecipeRegistrator.java
@@ -17,7 +17,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import miscutil.core.util.gregtech.five.GregtechVersionRecipeHandler;
+import miscutil.core.lib.CORE;
import miscutil.xmod.gregtech.api.enums.GregtechOrePrefixes;
import miscutil.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials;
import miscutil.xmod.gregtech.api.objects.GregtechItemData;
@@ -172,7 +172,7 @@ public class GregtechRecipeRegistrator {
aMaterialAmount /= aStack.stackSize;
if (aAllowAlloySmelter)
- GregtechVersionRecipeHandler.addSmeltingAndAlloySmeltingRecipe(GT_Utility.copyAmount(1, aStack), GregtechOreDictUnificator.getIngot(aMaterial.mSmeltInto, aMaterialAmount));
+ CORE.GT_Recipe.addSmeltingAndAlloySmeltingRecipe(GT_Utility.copyAmount(1, aStack), GregtechOreDictUnificator.getIngot(aMaterial.mSmeltInto, aMaterialAmount));
else
GT_ModHandler.addSmeltingRecipe(GT_Utility.copyAmount(1, aStack), GregtechOreDictUnificator.getIngot(aMaterial.mSmeltInto, aMaterialAmount));
}