Merge branch 'master' of https://github.com/aidancbrady/Mekanism
This commit is contained in:
commit
f9d845a36b
1 changed files with 59 additions and 8 deletions
|
@ -23,6 +23,7 @@ import buildcraft.api.power.IPowerReceptor;
|
||||||
import buildcraft.api.power.PowerHandler;
|
import buildcraft.api.power.PowerHandler;
|
||||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||||
import buildcraft.api.power.PowerHandler.Type;
|
import buildcraft.api.power.PowerHandler.Type;
|
||||||
|
import cofh.api.energy.IEnergyHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A universal conductor class.
|
* A universal conductor class.
|
||||||
|
@ -33,7 +34,7 @@ import buildcraft.api.power.PowerHandler.Type;
|
||||||
* @author Calclavia, micdoodle8
|
* @author Calclavia, micdoodle8
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public abstract class TileEntityUniversalConductor extends TileEntityConductor implements IEnergySink, IPowerReceptor
|
public abstract class TileEntityUniversalConductor extends TileEntityConductor implements IEnergySink, IPowerReceptor, IEnergyHandler
|
||||||
{
|
{
|
||||||
protected boolean isAddedToEnergyNet;
|
protected boolean isAddedToEnergyNet;
|
||||||
public PowerHandler powerHandler;
|
public PowerHandler powerHandler;
|
||||||
|
@ -65,7 +66,7 @@ public abstract class TileEntityUniversalConductor extends TileEntityConductor i
|
||||||
this.adjacentConnections[i] = tileEntity;
|
this.adjacentConnections[i] = tileEntity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (Compatibility.isIndustrialCraft2Loaded() && tileEntity instanceof IEnergyTile)
|
else if (tileEntity instanceof IEnergyTile)
|
||||||
{
|
{
|
||||||
if (tileEntity instanceof IEnergyAcceptor)
|
if (tileEntity instanceof IEnergyAcceptor)
|
||||||
{
|
{
|
||||||
|
@ -87,23 +88,26 @@ public abstract class TileEntityUniversalConductor extends TileEntityConductor i
|
||||||
|
|
||||||
this.adjacentConnections[i] = tileEntity;
|
this.adjacentConnections[i] = tileEntity;
|
||||||
}
|
}
|
||||||
else if (Compatibility.isBuildcraftLoaded() && tileEntity instanceof IPowerReceptor)
|
else if (tileEntity instanceof IPowerReceptor)
|
||||||
{
|
{
|
||||||
if (((IPowerReceptor) tileEntity).getPowerReceiver(side.getOpposite()) != null)
|
if (((IPowerReceptor) tileEntity).getPowerReceiver(side.getOpposite()) != null)
|
||||||
{
|
{
|
||||||
this.adjacentConnections[i] = tileEntity;
|
this.adjacentConnections[i] = tileEntity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (tileEntity instanceof IEnergyHandler)
|
||||||
|
{
|
||||||
|
if (((IEnergyHandler) tileEntity).canInterface(side.getOpposite()))
|
||||||
|
{
|
||||||
|
this.adjacentConnections[i] = tileEntity;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.adjacentConnections;
|
return this.adjacentConnections;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @Override public boolean canUpdate() { return !this.isAddedToEnergyNet; }
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateEntity()
|
public void updateEntity()
|
||||||
{
|
{
|
||||||
|
@ -185,7 +189,7 @@ public abstract class TileEntityUniversalConductor extends TileEntityConductor i
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BuildCraft functions
|
* BuildCraft Functions
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PowerReceiver getPowerReceiver(ForgeDirection side)
|
public PowerReceiver getPowerReceiver(ForgeDirection side)
|
||||||
|
@ -214,4 +218,51 @@ public abstract class TileEntityUniversalConductor extends TileEntityConductor i
|
||||||
{
|
{
|
||||||
return this.getWorldObj();
|
return this.getWorldObj();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thermal Expansion Functions
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate)
|
||||||
|
{
|
||||||
|
ElectricityPack pack = ElectricityPack.getFromWatts(maxReceive * Compatibility.TE_RATIO, 1);
|
||||||
|
float request = this.getMaxEnergyStored(from);
|
||||||
|
|
||||||
|
if (!simulate)
|
||||||
|
{
|
||||||
|
if (request > 0)
|
||||||
|
{
|
||||||
|
return (int) (maxReceive - (this.getNetwork().produce(pack, new Vector3(this).modifyPositionFromSide(from).getTileEntity(this.worldObj)) * Compatibility.TO_TE_RATIO));
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (int) Math.min(maxReceive, request * Compatibility.TO_TE_RATIO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canInterface(ForgeDirection from)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getEnergyStored(ForgeDirection from)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxEnergyStored(ForgeDirection from)
|
||||||
|
{
|
||||||
|
return (int) (this.getNetwork().getRequest(new Vector3(this).modifyPositionFromSide(from).getTileEntity(this.worldObj)).getWatts() * Compatibility.TO_TE_RATIO);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue