Search in sources :

Example 1 with IPipeContentsEditable

use of buildcraft.api.transport.pipe_bc8.IPipeContentsEditable in project BuildCraft by BuildCraft.

the class BehaviourWood method extract.

/**
 * @param items The number of items you can extract
 * @return The amount of power used
 */
private int extract(int availableEnergy) {
    IConnection_BC8 connection = pipe.getConnections().get(extractionFace.face);
    if (connection == null)
        return 0;
    IExtractable_BC8 extractable = pipe.getConnections().get(extractionFace).getExtractor();
    IInsertable_BC8 insertable = PipeAPI_BC8.INSERTION_MANAGER.getInsertableFor(pipe);
    IPipeContentsEditable contents = extractType(availableEnergy, insertable, extractable);
    if (contents == null)
        return 0;
    int energyRequired = getEnergyCost(contents);
    boolean inserted;
    if (contents instanceof IPipeContentsEditableItem) {
        inserted = insertable.tryInsertItems((IPipeContentsEditableItem) contents, pipe, extractionFace.face.getOpposite(), false);
    } else {
        inserted = insertable.tryInsertFluid((IPipeContentsEditableFluid) contents, pipe, extractionFace.face.getOpposite(), false);
    }
    if (!inserted)
        throw new IllegalStateException("Cannot NOT insert!");
    return energyRequired;
}
Also used : IInsertable_BC8(buildcraft.api.transport.pipe_bc8.IInsertionManager.IInsertable_BC8) IExtractable_BC8(buildcraft.api.transport.pipe_bc8.IExtractionManager.IExtractable_BC8) IPipeContentsEditableFluid(buildcraft.api.transport.pipe_bc8.IPipeContentsEditable.IPipeContentsEditableFluid) IPipeContentsEditable(buildcraft.api.transport.pipe_bc8.IPipeContentsEditable) IPipeContentsEditableItem(buildcraft.api.transport.pipe_bc8.IPipeContentsEditable.IPipeContentsEditableItem) IConnection_BC8(buildcraft.api.transport.pipe_bc8.IConnection_BC8)

Aggregations

IConnection_BC8 (buildcraft.api.transport.pipe_bc8.IConnection_BC8)1 IExtractable_BC8 (buildcraft.api.transport.pipe_bc8.IExtractionManager.IExtractable_BC8)1 IInsertable_BC8 (buildcraft.api.transport.pipe_bc8.IInsertionManager.IInsertable_BC8)1 IPipeContentsEditable (buildcraft.api.transport.pipe_bc8.IPipeContentsEditable)1 IPipeContentsEditableFluid (buildcraft.api.transport.pipe_bc8.IPipeContentsEditable.IPipeContentsEditableFluid)1 IPipeContentsEditableItem (buildcraft.api.transport.pipe_bc8.IPipeContentsEditable.IPipeContentsEditableItem)1