package crazypants.enderio.conduit.gas;

import mekanism.api.gas.GasStack;
import mekanism.api.gas.IGasHandler;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Optional.Method;
import crazypants.enderio.conduit.IConduitBundle;
import crazypants.enderio.config.Config;
import crazypants.util.BlockCoord;

public final class GasUtil {

  private static boolean useCheckPerformed = false;
  private static boolean isGasConduitEnabled = false;

  public static boolean isGasConduitEnabled() {
    if(!useCheckPerformed) {
      if(Config.isGasConduitEnabled) {
        isGasConduitEnabled = Loader.isModLoaded("MekanismAPI|gas");
      } else {
        isGasConduitEnabled = false;
      }
      useCheckPerformed = true;
    }
    return isGasConduitEnabled;
  }

  @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;
  }

  @Method(modid = "MekanismAPI|gas")
  public static IGasHandler getGasHandler(IBlockAccess world, BlockCoord bc) {
    return getGasHandler(world, bc.x, bc.y, bc.z);
  }

  @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);
  }

  @Method(modid = "MekanismAPI|gas")
  public static IGasHandler getGasHandler(TileEntity te) {
    if(te instanceof IGasHandler) {
      return (IGasHandler) te;
    }
    return null;
  }

  @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;
  }

  private GasUtil() {
  }
}

@@ -217,20 +217,27 @@
 .common.
-Load
+ModAPIManag
 er;%0Aimpo
@@ -690,26 +690,37 @@
 d = 
-Loader.isModLoaded
+ModAPIManager.INSTANCE.hasAPI
 (%22Me

Fix gas conduits not being enabled when they should be