Search in sources :

Example 11 with IEnergyReceiver

use of cofh.api.energy.IEnergyReceiver in project PneumaticCraft by MineMaarten.

the class ProgWidgetRFCondition method getEvaluator.

@Override
protected DroneAIBlockCondition getEvaluator(IDroneBase drone, IProgWidget widget) {
    return new DroneAIBlockCondition(drone, (ProgWidgetAreaItemBase) widget) {

        @Override
        protected boolean evaluate(ChunkPosition pos) {
            TileEntity te = drone.getWorld().getTileEntity(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ);
            int energy = 0;
            if (te instanceof IEnergyReceiver) {
                for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
                    if (getSides()[d.ordinal()]) {
                        energy = Math.max(((IEnergyReceiver) te).getEnergyStored(d), energy);
                    }
                }
            }
            if (te instanceof IEnergyProvider) {
                for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
                    if (getSides()[d.ordinal()]) {
                        energy = Math.max(((IEnergyProvider) te).getEnergyStored(d), energy);
                    }
                }
            }
            return ((ICondition) widget).getOperator() == ICondition.Operator.EQUALS ? energy == ((ICondition) widget).getRequiredCount() : energy >= ((ICondition) widget).getRequiredCount();
        }
    };
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IEnergyProvider(cofh.api.energy.IEnergyProvider) DroneAIBlockCondition(pneumaticCraft.common.ai.DroneAIBlockCondition) ChunkPosition(net.minecraft.world.ChunkPosition) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) IEnergyReceiver(cofh.api.energy.IEnergyReceiver) ICondition(pneumaticCraft.common.progwidgets.ICondition)

Aggregations

IEnergyReceiver (cofh.api.energy.IEnergyReceiver)11 TileEntity (net.minecraft.tileentity.TileEntity)8 EnumFacing (net.minecraft.util.EnumFacing)6 IStrictEnergyAcceptor (mekanism.api.energy.IStrictEnergyAcceptor)4 IEnergyHandler (cofh.api.energy.IEnergyHandler)3 IElectrical (micdoodle8.mods.galacticraft.api.transmission.tile.IElectrical)3 IEngine (buildcraft.api.power.IEngine)2 IEnergyConnection (cofh.api.energy.IEnergyConnection)2 IEnergyProvider (cofh.api.energy.IEnergyProvider)2 IEnergySink (ic2.api.energy.tile.IEnergySink)2 IConductor (micdoodle8.mods.galacticraft.api.transmission.tile.IConductor)2 BlockVec3 (micdoodle8.mods.galacticraft.api.vector.BlockVec3)2 BlockPos (net.minecraft.util.BlockPos)2 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)2 IPipeTile (buildcraft.api.transport.IPipeTile)1 PacketPowerUpdate (buildcraft.transport.network.PacketPowerUpdate)1 IEnergyStorage (cofh.api.energy.IEnergyStorage)1 Field (java.lang.reflect.Field)1 ICableOutputter (mekanism.api.energy.ICableOutputter)1 IConnector (micdoodle8.mods.galacticraft.api.transmission.tile.IConnector)1