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;
}
Aggregations