Only use the EnergyNet-related interfaces if IC2 itself is loaded.
Also add some extra safety to useIC2(). Conflicts: src/main/java/mekanism/common/util/MekanismUtils.java
This commit is contained in:
parent
26dadfe176
commit
b25d8f673b
4 changed files with 23 additions and 22 deletions
|
@ -16,7 +16,7 @@ import dan200.computercraft.api.peripheral.IPeripheral;
|
||||||
|
|
||||||
@InterfaceList({
|
@InterfaceList({
|
||||||
@Interface(iface = "buildcraft.api.power.IPowerReceptor", modid = "BuildCraftAPI|power"),
|
@Interface(iface = "buildcraft.api.power.IPowerReceptor", modid = "BuildCraftAPI|power"),
|
||||||
@Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2API", striprefs = true),
|
@Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2"),
|
||||||
@Interface(iface = "cofh.api.energy.IEnergyHandler", modid = "CoFHAPI|energy"),
|
@Interface(iface = "cofh.api.energy.IEnergyHandler", modid = "CoFHAPI|energy"),
|
||||||
@Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft")
|
@Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft")
|
||||||
})
|
})
|
||||||
|
|
|
@ -27,7 +27,7 @@ import dan200.computercraft.api.peripheral.IPeripheral;
|
||||||
|
|
||||||
@InterfaceList({
|
@InterfaceList({
|
||||||
@Interface(iface = "buildcraft.api.power.IPowerReceptor", modid = "BuildCraftAPI|power"),
|
@Interface(iface = "buildcraft.api.power.IPowerReceptor", modid = "BuildCraftAPI|power"),
|
||||||
@Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2API", striprefs = true),
|
@Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2"),
|
||||||
@Interface(iface = "cofh.api.energy.IEnergyHandler", modid = "CoFHAPI|energy"),
|
@Interface(iface = "cofh.api.energy.IEnergyHandler", modid = "CoFHAPI|energy"),
|
||||||
@Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft")
|
@Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft")
|
||||||
})
|
})
|
||||||
|
@ -194,7 +194,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Method(modid = "IC2API")
|
@Method(modid = "IC2")
|
||||||
public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction)
|
public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction)
|
||||||
{
|
{
|
||||||
if(getInv() == null)
|
if(getInv() == null)
|
||||||
|
@ -357,7 +357,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Method(modid = "IC2API")
|
@Method(modid = "IC2")
|
||||||
public double getDemandedEnergy()
|
public double getDemandedEnergy()
|
||||||
{
|
{
|
||||||
if(getInv() == null)
|
if(getInv() == null)
|
||||||
|
@ -369,7 +369,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Method(modid = "IC2API")
|
@Method(modid = "IC2")
|
||||||
public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage)
|
public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage)
|
||||||
{
|
{
|
||||||
if(getInv() == null)
|
if(getInv() == null)
|
||||||
|
@ -381,7 +381,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Method(modid = "IC2API")
|
@Method(modid = "IC2")
|
||||||
public int getSinkTier()
|
public int getSinkTier()
|
||||||
{
|
{
|
||||||
if(getInv() == null)
|
if(getInv() == null)
|
||||||
|
|
|
@ -33,8 +33,8 @@ import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||||
import cofh.api.energy.IEnergyHandler;
|
import cofh.api.energy.IEnergyHandler;
|
||||||
|
|
||||||
@InterfaceList({
|
@InterfaceList({
|
||||||
@Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2API", striprefs = true),
|
@Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2"),
|
||||||
@Interface(iface = "ic2.api.tile.IEnergyStorage", modid = "IC2API", striprefs = true),
|
@Interface(iface = "ic2.api.tile.IEnergyStorage", modid = "IC2"),
|
||||||
@Interface(iface = "cofh.api.energy.IEnergyHandler", modid = "CoFHAPI|energy"),
|
@Interface(iface = "cofh.api.energy.IEnergyHandler", modid = "CoFHAPI|energy"),
|
||||||
@Interface(iface = "buildcraft.api.power.IPowerReceptor", modid = "BuildCraftAPI|power"),
|
@Interface(iface = "buildcraft.api.power.IPowerReceptor", modid = "BuildCraftAPI|power"),
|
||||||
@Interface(iface = "buildcraft.api.power.IPowerEmitter", modid = "BuildCraftAPI|power")
|
@Interface(iface = "buildcraft.api.power.IPowerEmitter", modid = "BuildCraftAPI|power")
|
||||||
|
@ -74,7 +74,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Method(modid = "IC2API")
|
@Method(modid = "IC2")
|
||||||
public void register()
|
public void register()
|
||||||
{
|
{
|
||||||
if(!worldObj.isRemote)
|
if(!worldObj.isRemote)
|
||||||
|
@ -87,7 +87,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Method(modid = "IC2API")
|
@Method(modid = "IC2")
|
||||||
public void deregister()
|
public void deregister()
|
||||||
{
|
{
|
||||||
if(!worldObj.isRemote)
|
if(!worldObj.isRemote)
|
||||||
|
@ -307,21 +307,21 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Method(modid = "IC2API")
|
@Method(modid = "IC2")
|
||||||
public int getSinkTier()
|
public int getSinkTier()
|
||||||
{
|
{
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Method(modid = "IC2API")
|
@Method(modid = "IC2")
|
||||||
public void setStored(int energy)
|
public void setStored(int energy)
|
||||||
{
|
{
|
||||||
setEnergy(energy*Mekanism.FROM_IC2);
|
setEnergy(energy*Mekanism.FROM_IC2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Method(modid = "IC2API")
|
@Method(modid = "IC2")
|
||||||
public int addEnergy(int amount)
|
public int addEnergy(int amount)
|
||||||
{
|
{
|
||||||
setEnergy(getEnergy() + amount*Mekanism.FROM_IC2);
|
setEnergy(getEnergy() + amount*Mekanism.FROM_IC2);
|
||||||
|
@ -329,7 +329,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Method(modid = "IC2API")
|
@Method(modid = "IC2")
|
||||||
public boolean isTeleporterCompatible(ForgeDirection side)
|
public boolean isTeleporterCompatible(ForgeDirection side)
|
||||||
{
|
{
|
||||||
return getOutputtingSides().contains(side);
|
return getOutputtingSides().contains(side);
|
||||||
|
@ -342,35 +342,35 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Method(modid = "IC2API")
|
@Method(modid = "IC2")
|
||||||
public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction)
|
public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction)
|
||||||
{
|
{
|
||||||
return !getOutputtingSides().contains(direction);
|
return !getOutputtingSides().contains(direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Method(modid = "IC2API")
|
@Method(modid = "IC2")
|
||||||
public int getStored()
|
public int getStored()
|
||||||
{
|
{
|
||||||
return (int)Math.round(getEnergy()*Mekanism.TO_IC2);
|
return (int)Math.round(getEnergy()*Mekanism.TO_IC2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Method(modid = "IC2API")
|
@Method(modid = "IC2")
|
||||||
public int getCapacity()
|
public int getCapacity()
|
||||||
{
|
{
|
||||||
return (int)Math.round(getMaxEnergy()*Mekanism.TO_IC2);
|
return (int)Math.round(getMaxEnergy()*Mekanism.TO_IC2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Method(modid = "IC2API")
|
@Method(modid = "IC2")
|
||||||
public int getOutput()
|
public int getOutput()
|
||||||
{
|
{
|
||||||
return (int)Math.round(getMaxOutput()*Mekanism.TO_IC2);
|
return (int)Math.round(getMaxOutput()*Mekanism.TO_IC2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Method(modid = "IC2API")
|
@Method(modid = "IC2")
|
||||||
public double getDemandedEnergy()
|
public double getDemandedEnergy()
|
||||||
{
|
{
|
||||||
return (getMaxEnergy() - getEnergy())*Mekanism.TO_IC2;
|
return (getMaxEnergy() - getEnergy())*Mekanism.TO_IC2;
|
||||||
|
@ -383,14 +383,14 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Method(modid = "IC2API")
|
@Method(modid = "IC2")
|
||||||
public double getOutputEnergyUnitsPerTick()
|
public double getOutputEnergyUnitsPerTick()
|
||||||
{
|
{
|
||||||
return getMaxOutput()*Mekanism.TO_IC2;
|
return getMaxOutput()*Mekanism.TO_IC2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Method(modid = "IC2API")
|
@Method(modid = "IC2")
|
||||||
public double injectEnergy(ForgeDirection direction, double i, double v)
|
public double injectEnergy(ForgeDirection direction, double i, double v)
|
||||||
{
|
{
|
||||||
if(Coord4D.get(this).getFromSide(direction).getTileEntity(worldObj) instanceof IGridTransmitter)
|
if(Coord4D.get(this).getFromSide(direction).getTileEntity(worldObj) instanceof IGridTransmitter)
|
||||||
|
|
|
@ -76,6 +76,7 @@ import cpw.mods.fml.common.ModContainer;
|
||||||
import cpw.mods.fml.common.registry.GameData;
|
import cpw.mods.fml.common.registry.GameData;
|
||||||
|
|
||||||
import buildcraft.api.tools.IToolWrench;
|
import buildcraft.api.tools.IToolWrench;
|
||||||
|
import ic2.api.energy.EnergyNet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utilities used by Mekanism. All miscellaneous methods are located here.
|
* Utilities used by Mekanism. All miscellaneous methods are located here.
|
||||||
|
@ -1208,7 +1209,7 @@ public final class MekanismUtils
|
||||||
*/
|
*/
|
||||||
public static boolean useIC2()
|
public static boolean useIC2()
|
||||||
{
|
{
|
||||||
return Mekanism.hooks.IC2Loaded && !Mekanism.blacklistIC2;
|
return Mekanism.hooks.IC2Loaded && EnergyNet.instance != null && !Mekanism.blacklistIC2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue