diff --git a/src/main/java/crazypants/enderio/TileEntityEio.java b/src/main/java/crazypants/enderio/TileEntityEio.java index 8eb9f973..922d0d04 100644 --- a/src/main/java/crazypants/enderio/TileEntityEio.java +++ b/src/main/java/crazypants/enderio/TileEntityEio.java @@ -1,17 +1,14 @@ package crazypants.enderio; -import crazypants.util.BlockCoord; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; +import crazypants.util.BlockCoord; -/** - * Created by CrazyPants on 27/02/14. - */ public abstract class TileEntityEio extends TileEntity { - + private final int checkOffset = (int) (Math.random() * 20); @Override @@ -19,7 +16,7 @@ public abstract class TileEntityEio extends TileEntity { super.readFromNBT(root); readCustomNBT(root); } - + @Override public final void writeToNBT(NBTTagCompound root) { super.writeToNBT(root); @@ -41,36 +38,47 @@ public abstract class TileEntityEio extends TileEntity { protected abstract void writeCustomNBT(NBTTagCompound root); protected abstract void readCustomNBT(NBTTagCompound root); - + protected void updateBlock() { if(worldObj != null) { worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); } } - + protected boolean isPoweredRedstone() { return worldObj.getStrongestIndirectPower(xCoord, yCoord, zCoord) > 0; } - /* - * init() is called directly after the TE is constructed. This is the place to call + /** + * Called directly after the TE is constructed. This is the place to call * non-final methods. */ - public void init() {} + public void init() { + } public BlockCoord getLocation() { return new BlockCoord(this); } - /* - * Call this with an interval (in ticks) to find out if the current tick is the one you want - * to do some work. This is staggered so the work of different TEs is stretched out over time. + + /** + * Call this with an interval (in ticks) to find out if the current tick is + * the one you want to do some work. This is staggered so the work of + * different TEs is stretched out over time. * - * If you have different work items in your TE, use the variant with the offset parameter to - * stagger your work. + * @see #shouldDoWorkThisTick(int, int) If you need to offset work ticks */ protected boolean shouldDoWorkThisTick(int interval) { - return (worldObj.getTotalWorldTime() + checkOffset) % interval == 0; + return shouldDoWorkThisTick(interval, 0); } + + /** + * Call this with an interval (in ticks) to find out if the current tick is + * the one you want to do some work. This is staggered so the work of + * different TEs is stretched out over time. + * + * If you have different work items in your TE, use this variant to stagger + * your work. + */ protected boolean shouldDoWorkThisTick(int interval, int offset) { return (worldObj.getTotalWorldTime() + checkOffset + offset) % interval == 0; } diff --git a/src/main/java/crazypants/enderio/conduit/gas/GasUtil.java b/src/main/java/crazypants/enderio/conduit/gas/GasUtil.java index c4a811bc..305eb37f 100644 --- a/src/main/java/crazypants/enderio/conduit/gas/GasUtil.java +++ b/src/main/java/crazypants/enderio/conduit/gas/GasUtil.java @@ -5,6 +5,7 @@ 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.ModContainer; import cpw.mods.fml.common.Optional.Method; import crazypants.enderio.conduit.IConduitBundle; import crazypants.enderio.config.Config; @@ -18,7 +19,12 @@ public final class GasUtil { public static boolean isGasConduitEnabled() { if(!useCheckPerformed) { if(Config.isGasConduitEnabled) { - isGasConduitEnabled = Loader.isModLoaded("MekanismAPI|gas"); + if(Loader.isModLoaded("MekanismAPI|gas")) { + isGasConduitEnabled = true; + } else { + ModContainer mc = Loader.instance().getIndexedModList().get("Mekanism"); + isGasConduitEnabled = mc != null && mc.getVersion().startsWith("7"); + } } else { isGasConduitEnabled = false; }