diff options
author | Jordan Byrne <draknyte1@hotmail.com> | 2018-03-13 21:41:03 +1000 |
---|---|---|
committer | Jordan Byrne <draknyte1@hotmail.com> | 2018-03-13 21:41:03 +1000 |
commit | c1bbee9f5f71dd82ca0aef2669d52a34b65fcc2d (patch) | |
tree | adc018bc51e7c10094218dd86d53337c7eed7582 /src/Java/gtPlusPlus/xmod/tinkers/util | |
parent | f8cf6af92b23fb595c6f9410bf95e7c7d6be981d (diff) | |
download | GT5-Unofficial-c1bbee9f5f71dd82ca0aef2669d52a34b65fcc2d.tar.gz GT5-Unofficial-c1bbee9f5f71dd82ca0aef2669d52a34b65fcc2d.tar.bz2 GT5-Unofficial-c1bbee9f5f71dd82ca0aef2669d52a34b65fcc2d.zip |
$ Fixed TiCon not accepting GT++ Pyrotheum as a valid Smeltery Fuel.
$ Fixed Recipe for the Shaft Extruder shape, which now requires Dark Steel, instead of Dark Iron.
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/tinkers/util')
-rw-r--r-- | src/Java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java | 99 |
1 files changed, 99 insertions, 0 deletions
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}); + } + +} |