aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Java/gtPlusPlus/GTplusplus.java2
-rw-r--r--src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java4
-rw-r--r--src/Java/gtPlusPlus/core/lib/LoadedMods.java6
-rw-r--r--src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java50
-rw-r--r--src/Java/gtPlusPlus/xmod/ic2/recipe/RECIPE_IC2.java2
-rw-r--r--src/Java/gtPlusPlus/xmod/tinkers/HANDLER_Tinkers.java34
-rw-r--r--src/Java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java99
7 files changed, 195 insertions, 2 deletions
diff --git a/src/Java/gtPlusPlus/GTplusplus.java b/src/Java/gtPlusPlus/GTplusplus.java
index 250c8b57f5..235b314001 100644
--- a/src/Java/gtPlusPlus/GTplusplus.java
+++ b/src/Java/gtPlusPlus/GTplusplus.java
@@ -50,7 +50,7 @@ import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_Recycling;
import net.minecraftforge.oredict.OreDictionary;
@MCVersion(value = "1.7.10")
-@Mod(modid = CORE.MODID, name = CORE.name, version = CORE.VERSION, dependencies = "required-after:Forge; after:PlayerAPI; after:dreamcraft; after:IC2; after:ihl; after:psychedelicraft; after:gregtech; after:Forestry; after:MagicBees; after:CoFHCore; after:Growthcraft; after:Railcraft; after:CompactWindmills; after:ForbiddenMagic; after:MorePlanet; after:PneumaticCraft; after:ExtraUtilities; after:Thaumcraft; after:rftools; after:simplyjetpacks; after:BigReactors; after:EnderIO; after:tectech; after:GTRedtech; after:beyondrealitycore;")
+@Mod(modid = CORE.MODID, name = CORE.name, version = CORE.VERSION, dependencies = "required-after:Forge; before:TConstruct; after:PlayerAPI; after:dreamcraft; after:IC2; after:ihl; after:psychedelicraft; after:gregtech; after:Forestry; after:MagicBees; after:CoFHCore; after:Growthcraft; after:Railcraft; after:CompactWindmills; after:ForbiddenMagic; after:MorePlanet; after:PneumaticCraft; after:ExtraUtilities; after:Thaumcraft; after:rftools; after:simplyjetpacks; after:BigReactors; after:EnderIO; after:tectech; after:GTRedtech; after:beyondrealitycore;")
public class GTplusplus implements ActionListener {
//Mod Instance
diff --git a/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java b/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java
index 740f923c6f..f788e3b0e4 100644
--- a/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java
+++ b/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java
@@ -8,6 +8,7 @@ import gtPlusPlus.xmod.growthcraft.HANDLER_GC;
import gtPlusPlus.xmod.ic2.HANDLER_IC2;
import gtPlusPlus.xmod.thaumcraft.HANDLER_Thaumcraft;
import gtPlusPlus.xmod.thermalfoundation.HANDLER_TF;
+import gtPlusPlus.xmod.tinkers.HANDLER_Tinkers;
public class COMPAT_IntermodStaging {
@@ -21,6 +22,7 @@ public class COMPAT_IntermodStaging {
HANDLER_BiomesOPlenty.preInit();
//HANDLER_Mekanism.preInit();
HANDLER_Thaumcraft.preInit();
+ HANDLER_Tinkers.preInit();
}
public static void init(){
@@ -33,6 +35,7 @@ public class COMPAT_IntermodStaging {
HANDLER_BiomesOPlenty.init();
//HANDLER_Mekanism.init();
HANDLER_Thaumcraft.init();
+ HANDLER_Tinkers.init();
}
public static void postInit(){
@@ -45,6 +48,7 @@ public class COMPAT_IntermodStaging {
HANDLER_BiomesOPlenty.postInit();
//HANDLER_Mekanism.postInit();
HANDLER_Thaumcraft.postInit();
+ HANDLER_Tinkers.postInit();
}
diff --git a/src/Java/gtPlusPlus/core/lib/LoadedMods.java b/src/Java/gtPlusPlus/core/lib/LoadedMods.java
index 114219486e..81cae14a6b 100644
--- a/src/Java/gtPlusPlus/core/lib/LoadedMods.java
+++ b/src/Java/gtPlusPlus/core/lib/LoadedMods.java
@@ -49,6 +49,7 @@ public class LoadedMods {
public static boolean Mekanism = false;
public static boolean RedTech = false; //RedMage's Mod
public static boolean TecTech = false; //Technus' Mod
+ public static boolean TiCon = false;
@@ -91,6 +92,11 @@ public class LoadedMods {
Logger.INFO("Components enabled for: PlayerAPI");
totalMods++;
}
+ if (Loader.isModLoaded("TConstruct") == true){
+ TiCon = true;
+ Logger.INFO("Components enabled for: Tinkers Construct");
+ totalMods++;
+ }
if (Loader.isModLoaded("BuildCraft") == true){
BuildCraft = true;
Logger.INFO("Components enabled for: BuildCraft");
diff --git a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java
index d17c861b77..882d16c232 100644
--- a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java
+++ b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java
@@ -203,6 +203,56 @@ public class ReflectionUtils {
Logger.REFLECTION("Invoke failed or did something wrong.");
return false;
}
+
+ public static boolean invokeVoid(Object objectInstance, String methodName, Class[] parameters, Object[] values){
+ if (objectInstance == null || methodName == null || parameters == null || values == null){
+ return false;
+ }
+ Class<?> mLocalClass = (objectInstance instanceof Class ? (Class<?>) objectInstance : objectInstance.getClass());
+ Logger.REFLECTION("Trying to invoke "+methodName+" on an instance of "+mLocalClass.getCanonicalName()+".");
+ try {
+ Method mInvokingMethod = mLocalClass.getDeclaredMethod(methodName, parameters);
+ if (mInvokingMethod != null){
+ Logger.REFLECTION(methodName+" was not null.");
+ mInvokingMethod.invoke(objectInstance, values);
+ Logger.REFLECTION("Successfully invoked "+methodName+".");
+ return true;
+ }
+ else {
+ Logger.REFLECTION(methodName+" is null.");
+ }
+ }
+ catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
+ Logger.REFLECTION("Failed to Dynamically invoke "+methodName+" on an object of type: "+mLocalClass.getName());
+ }
+
+ Logger.REFLECTION("Invoke failed or did something wrong.");
+ return false;
+ }
+
+ public static Object invokeNonBool(Object objectInstance, String methodName, Class[] parameters, Object[] values){
+ if (objectInstance == null || methodName == null || parameters == null || values == null){
+ return false;
+ }
+ Class<?> mLocalClass = (objectInstance instanceof Class ? (Class<?>) objectInstance : objectInstance.getClass());
+ Logger.REFLECTION("Trying to invoke "+methodName+" on an instance of "+mLocalClass.getCanonicalName()+".");
+ try {
+ Method mInvokingMethod = mLocalClass.getDeclaredMethod(methodName, parameters);
+ if (mInvokingMethod != null){
+ Logger.REFLECTION(methodName+" was not null.");
+ return mInvokingMethod.invoke(objectInstance, values);
+ }
+ else {
+ Logger.REFLECTION(methodName+" is null.");
+ }
+ }
+ catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
+ Logger.REFLECTION("Failed to Dynamically invoke "+methodName+" on an object of type: "+mLocalClass.getName());
+ }
+
+ Logger.REFLECTION("Invoke failed or did something wrong.");
+ return null;
+ }
/*
* @ if (isPresent("com.optionaldependency.DependencyClass")) { // This
diff --git a/src/Java/gtPlusPlus/xmod/ic2/recipe/RECIPE_IC2.java b/src/Java/gtPlusPlus/xmod/ic2/recipe/RECIPE_IC2.java
index 0909b175c6..6c43e2b6e0 100644
--- a/src/Java/gtPlusPlus/xmod/ic2/recipe/RECIPE_IC2.java
+++ b/src/Java/gtPlusPlus/xmod/ic2/recipe/RECIPE_IC2.java
@@ -141,7 +141,7 @@ public class RECIPE_IC2 {
}
//Shaft Extruder Recipe
- GT_ModHandler.addCraftingRecipe(GregtechItemList.Shape_Extruder_WindmillShaft.get(1L, new Object[0]), GT_ModHandler.RecipeBits.BUFFERED | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"hXS", "XPX", "fXd", Character.valueOf('P'), ItemList.Shape_Extruder_Rod, Character.valueOf('X'), OrePrefixes.plate.get(Materials.DarkIron), Character.valueOf('S'), OrePrefixes.screw.get(Materials.DarkIron)});
+ GT_ModHandler.addCraftingRecipe(GregtechItemList.Shape_Extruder_WindmillShaft.get(1L, new Object[0]), GT_ModHandler.RecipeBits.BUFFERED | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"hXS", "XPX", "fXd", Character.valueOf('P'), ItemList.Shape_Extruder_Rod, Character.valueOf('X'), OrePrefixes.plate.get(Materials.DarkSteel), Character.valueOf('S'), OrePrefixes.screw.get(Materials.DarkSteel)});
GT_ModHandler.addCraftingRecipe(GregtechItemList.Shape_Extruder_WindmillShaft.get(1L, new Object[0]), GT_ModHandler.RecipeBits.BUFFERED | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"hXS", "XPX", "fXd", Character.valueOf('P'), ItemList.Shape_Extruder_Rod, Character.valueOf('X'), OrePrefixes.plate.get(Materials.TungstenSteel), Character.valueOf('S'), OrePrefixes.screw.get(Materials.TungstenSteel)});
GT_ModHandler.addCraftingRecipe(GregtechItemList.Shape_Extruder_WindmillShaft.get(1L, new Object[0]), GT_ModHandler.RecipeBits.BUFFERED | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"hXS", "XPX", "fXd", Character.valueOf('P'), ItemList.Shape_Extruder_Rod, Character.valueOf('X'), OrePrefixes.plate.get(Materials.Molybdenum), Character.valueOf('S'), OrePrefixes.screw.get(Materials.Molybdenum)});
Logger.INFO("Added recipe item for GT5 Extruder: Shaft Shape");
diff --git a/src/Java/gtPlusPlus/xmod/tinkers/HANDLER_Tinkers.java b/src/Java/gtPlusPlus/xmod/tinkers/HANDLER_Tinkers.java
new file mode 100644
index 0000000000..3ece2cc61d
--- /dev/null
+++ b/src/Java/gtPlusPlus/xmod/tinkers/HANDLER_Tinkers.java
@@ -0,0 +1,34 @@
+package gtPlusPlus.xmod.tinkers;
+
+import gtPlusPlus.core.lib.LoadedMods;
+import gtPlusPlus.xmod.tinkers.util.TinkersUtils;
+import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidRegistry;
+
+public class HANDLER_Tinkers {
+
+ public static final void preInit() {
+ if (LoadedMods.TiCon) {
+
+ }
+ }
+
+ public static final void init() {
+ if (LoadedMods.TiCon) {
+ //Migrate TiCon further back in the oreDict so that I never grab items from it.
+ //TinkersUtils.stopTiconLoadingFirst();
+ Fluid pyrotheumFluid = FluidRegistry.getFluid("pyrotheum");
+ if (pyrotheumFluid != null) {
+ //Enable Pyrotheum as Fuel for the Smeltery
+ TinkersUtils.addSmelteryFuel(pyrotheumFluid, 5000, 70); // pyrotheum lasts 3.5 seconds per 15 mb
+ }
+ }
+ }
+
+ public static final void postInit() {
+ if (LoadedMods.TiCon) {
+
+ }
+ }
+
+}
diff --git a/src/Java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java b/src/Java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java
new file mode 100644
index 0000000000..aed5b46e0a
--- /dev/null
+++ b/src/Java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java
@@ -0,0 +1,99 @@
+package gtPlusPlus.xmod.tinkers.util;
+
+import gtPlusPlus.core.lib.LoadedMods;
+import gtPlusPlus.core.util.minecraft.ItemUtils;
+import gtPlusPlus.core.util.reflect.ReflectionUtils;
+import net.minecraftforge.fluids.Fluid;
+
+public class TinkersUtils {
+
+ private static Object mSmelteryInstance;
+ private static Class mSmelteryClassInstance;
+
+ public static Object getSmelteryInstance() {
+ if (!LoadedMods.TiCon) {
+ return null;
+ }
+ else {
+ if (mSmelteryInstance == null || mSmelteryClassInstance == null) {
+ if (mSmelteryClassInstance == null) {
+ try {
+ mSmelteryClassInstance = Class.forName("tconstruct.library.crafting.Smeltery");
+ }
+ catch (ClassNotFoundException e) {}
+ }
+ if (mSmelteryClassInstance != null) {
+ try {
+ mSmelteryInstance = ReflectionUtils.getField(mSmelteryClassInstance, "instance").get(null);
+ }
+ catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) {
+ }
+ }
+ }
+ }
+ if (mSmelteryInstance != null) {
+ return mSmelteryInstance;
+ }
+ return null;
+ }
+
+ public static final boolean isTiConFirstInOD() {
+ if (LoadedMods.TiCon) {
+ try {
+ return (boolean) ReflectionUtils.getField(Class.forName("PHConstruct"), "tconComesFirst").get(null);
+ }
+ catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | ClassNotFoundException e) {
+ }
+ }
+ return false;
+ }
+
+ public static final boolean stopTiconLoadingFirst() {
+ if (isTiConFirstInOD()) {
+ try {
+ ReflectionUtils.setFieldValue(Class.forName("PHConstruct"), "tconComesFirst", false);
+ if ((boolean) ReflectionUtils.getField(Class.forName("PHConstruct"), "tconComesFirst").get(null) == false) {
+ return true;
+ }
+ //Did not work, let's see where TiCon uses this and prevent it.
+ else {
+ ItemUtils.getNonTinkersDust("", 1);
+ }
+ }
+ catch (Exception e) {}
+ }
+ return false;
+ }
+
+ /**
+ * Add a new fluid as a valid Smeltery fuel.
+ * @param fluid The fluid.
+ * @param power The temperature of the fluid. This also influences the melting speed. Lava is 1000.
+ * @param duration How long one "portion" of liquid fuels the smeltery. Lava is 10.
+ */
+ public static void addSmelteryFuel (Fluid fluid, int power, int duration){
+ ReflectionUtils.invokeVoid(getSmelteryInstance(), "addSmelteryFuel", new Class[] {Fluid.class, int.class, int.class}, new Object[] {fluid, power, duration});
+ }
+
+ /**
+ * Returns true if the liquid is a valid smeltery fuel.
+ */
+ public static boolean isSmelteryFuel (Fluid fluid){
+ return ReflectionUtils.invoke(getSmelteryInstance(), "isSmelteryFuel", new Class[] {Fluid.class}, new Object[] {fluid});
+ }
+
+ /**
+ * Returns the power of a smeltery fuel or 0 if it's not a fuel.
+ */
+ public static int getFuelPower (Fluid fluid){
+ return (int) ReflectionUtils.invokeNonBool(getSmelteryInstance(), "getFuelPower", new Class[] {Fluid.class}, new Object[] {fluid});
+ }
+
+ /**
+ * Returns the duration of a smeltery fuel or 0 if it's not a fuel.
+ */
+ public static int getFuelDuration (Fluid fluid){
+ return (int) ReflectionUtils.invokeNonBool(getSmelteryInstance(), "getFuelDuration", new Class[] {Fluid.class}, new Object[] {fluid});
+ }
+
+}