Search in sources :

Example 1 with RuntimeInterface

use of micdoodle8.mods.miccore.Annotations.RuntimeInterface 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;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IEnergySource(ic2.api.energy.tile.IEnergySource) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3) RuntimeInterface(micdoodle8.mods.miccore.Annotations.RuntimeInterface)

Aggregations

IEnergySource (ic2.api.energy.tile.IEnergySource)1 BlockVec3 (micdoodle8.mods.galacticraft.api.vector.BlockVec3)1 RuntimeInterface (micdoodle8.mods.miccore.Annotations.RuntimeInterface)1 TileEntity (net.minecraft.tileentity.TileEntity)1