use of ic2.api.energy.tile.IEnergySource in project Galacticraft by micdoodle8.
the class TileBaseUniversalConductor method injectEnergy.
@RuntimeInterface(clazz = "ic2.api.energy.tile.IEnergySink", modID = "IC2")
public double injectEnergy(EnumFacing directionFrom, double amount, double voltage) {
TileEntity tile = new BlockVec3(this).getTileEntityOnSide(this.worldObj, directionFrom);
int tier = ((int) voltage > 120) ? 2 : 1;
if (tile instanceof IEnergySource && ((IEnergySource) tile).getOfferedEnergy() >= 128) {
tier = 2;
}
float convertedEnergy = (float) amount * EnergyConfigHandler.IC2_RATIO;
float surplus = this.getNetwork().produce(convertedEnergy, true, tier, this, tile);
if (surplus >= 0.001F) {
this.IC2surplusJoules = surplus;
} else {
this.IC2surplusJoules = 0F;
}
return 0D;
}
Aggregations