aboutsummaryrefslogtreecommitdiff
path: root/src/Java/miscutil/enderio/conduit/gas/GasUtil.java
diff options
context:
space:
mode:
authorDraknyte1 <Draknyte1@hotmail.com>2016-02-27 21:24:45 +1000
committerDraknyte1 <Draknyte1@hotmail.com>2016-02-27 21:24:45 +1000
commit7711c80664fdfa703b5e60e62af437655da783ae (patch)
tree1a251a5919b7c6d4f32de7efca6a36d97cef0233 /src/Java/miscutil/enderio/conduit/gas/GasUtil.java
parent707621bc6afd36856feafb052c2e65c52fe79986 (diff)
downloadGT5-Unofficial-7711c80664fdfa703b5e60e62af437655da783ae.tar.gz
GT5-Unofficial-7711c80664fdfa703b5e60e62af437655da783ae.tar.bz2
GT5-Unofficial-7711c80664fdfa703b5e60e62af437655da783ae.zip
Added Custom GT Cables/Wire & also added a copy of EnderIO's Gas Conduit classes.
Time to combine the two, yeah? Also stripped out a heap of constants and refactored them together.
Diffstat (limited to 'src/Java/miscutil/enderio/conduit/gas/GasUtil.java')
-rw-r--r--src/Java/miscutil/enderio/conduit/gas/GasUtil.java75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/Java/miscutil/enderio/conduit/gas/GasUtil.java b/src/Java/miscutil/enderio/conduit/gas/GasUtil.java
new file mode 100644
index 0000000000..1ccadc9485
--- /dev/null
+++ b/src/Java/miscutil/enderio/conduit/gas/GasUtil.java
@@ -0,0 +1,75 @@
+package crazypants.enderio.conduit.gas;
+
+import com.enderio.core.common.util.BlockCoord;
+import cpw.mods.fml.common.ModAPIManager;
+import cpw.mods.fml.common.Optional.Method;
+import crazypants.enderio.conduit.IConduitBundle;
+import crazypants.enderio.config.Config;
+import mekanism.api.gas.Gas;
+import mekanism.api.gas.GasStack;
+import mekanism.api.gas.IGasHandler;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.world.IBlockAccess;
+
+public final class GasUtil
+{
+ private static boolean useCheckPerformed = false;
+ private static boolean isGasConduitEnabled = false;
+ public static final String API_NAME = "MekanismAPI|gas";
+
+ public static boolean isGasConduitEnabled()
+ {
+ if (!useCheckPerformed)
+ {
+ if (Config.isGasConduitEnabled) {
+ isGasConduitEnabled = ModAPIManager.INSTANCE.hasAPI("MekanismAPI|gas");
+ } else {
+ isGasConduitEnabled = false;
+ }
+ useCheckPerformed = true;
+ }
+ return isGasConduitEnabled;
+ }
+
+ @Optional.Method(modid="MekanismAPI|gas")
+ public static IGasHandler getExternalGasHandler(IBlockAccess world, BlockCoord bc)
+ {
+ IGasHandler con = getGasHandler(world, bc);
+ return (con != null) && (!(con instanceof IConduitBundle)) ? con : null;
+ }
+
+ @Optional.Method(modid="MekanismAPI|gas")
+ public static IGasHandler getGasHandler(IBlockAccess world, BlockCoord bc)
+ {
+ return getGasHandler(world, bc.x, bc.y, bc.z);
+ }
+
+ @Optional.Method(modid="MekanismAPI|gas")
+ public static IGasHandler getGasHandler(IBlockAccess world, int x, int y, int z)
+ {
+ TileEntity te = world.getTileEntity(x, y, z);
+ return getGasHandler(te);
+ }
+
+ @Optional.Method(modid="MekanismAPI|gas")
+ public static IGasHandler getGasHandler(TileEntity te)
+ {
+ if ((te instanceof IGasHandler)) {
+ return (IGasHandler)te;
+ }
+ return null;
+ }
+
+ @Optional.Method(modid="MekanismAPI|gas")
+ public static boolean isGasValid(GasStack gas)
+ {
+ if (gas != null)
+ {
+ String name = gas.getGas().getLocalizedName();
+ if ((name != null) && (!name.trim().isEmpty())) {
+ return true;
+ }
+ }
+ return false;
+ }
+}