Search in sources :

Example 1 with IConnection_BC8

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

the class BehaviourWood method selectNewDirection.

private void selectNewDirection() {
    if (pipe.getWorld().isRemote) {
        return;
    }
    EnumPipePart part = extractionFace;
    if (part == EnumPipePart.CENTER)
        part = part.next();
    int left = 6;
    while (left > 0) {
        part = part.next();
        left--;
        IConnection_BC8 connection = pipe.getConnections().get(part.face);
        if (isValidExtraction(connection)) {
            extractionFace = part;
            pipe.sendClientUpdate(this);
            pipe.sendRenderUpdate();
            return;
        }
    }
    extractionFace = EnumPipePart.CENTER;
    pipe.sendClientUpdate(this);
    pipe.sendRenderUpdate();
}
Also used : EnumPipePart(buildcraft.api.core.EnumPipePart) IConnection_BC8(buildcraft.api.transport.pipe_bc8.IConnection_BC8)

Example 2 with IConnection_BC8

use of buildcraft.api.transport.pipe_bc8.IConnection_BC8 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)

Example 3 with IConnection_BC8

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

the class TravellingItem_BC8 method tick.

@BCPipeEventHandler
public void tick(IPipeEvent_BC8.Tick tick) {
    if (item.getProperties().getValue(PipeAPI_BC8.ITEM_PAUSED)) {
        // Just so we render them properly, and so we need to stop this from ticking in the near future
        tickStarted++;
        tickFinished++;
        return;
    }
    if (tick instanceof IPipeEvent_BC8.Tick.Client)
        return;
    EnumContentsJourneyPart direction = item.getJourneyPart();
    if (direction == EnumContentsJourneyPart.JUST_ENTERED) {
        // Setup ourselves NOW, but tick the rest later
        double normalizedSpeed = item.getSpeed() * PipeTransportItem_BC8.SPEED_NORMALIZER;
        IPipeEventContents_BC8.ChangeSpeed changeSpeed = null;
        pipe.fireEvent(changeSpeed);
        // normalizedSpeed = changeSpeed.getNormalizedSpeed();
        item.setSpeed(normalizedSpeed / PipeTransportItem_BC8.SPEED_NORMALIZER);
        double distance = 0.25;
        IConnection_BC8 connection = pipe.getConnections().get(item.getDirection().getOpposite());
        if (connection != null)
            distance += connection.getLength();
        // generate our new timings (when we will next tick)
        genTimings(pipe.getWorld().getTotalWorldTime(), distance);
        // Update the client with our new timings
        pipe.sendClientUpdate(this);
        // Tick next tick not this tick
        return;
    }
    if (tick.getCurrentTick() < tickFinished)
        return;
    if (direction == EnumContentsJourneyPart.TO_CENTER) {
    // We need to find out where we are going, and the new speed of ourselves
    } else {
    /* We must be going to the end of the pipe, so we need to insert ourselves into the next pipe, or into an
             * inventory (if one exists) */
    }
}
Also used : IPipeEvent_BC8(buildcraft.api.transport.pipe_bc8.event_bc8.IPipeEvent_BC8) EnumContentsJourneyPart(buildcraft.api.transport.pipe_bc8.EnumContentsJourneyPart) IConnection_BC8(buildcraft.api.transport.pipe_bc8.IConnection_BC8) IPipeEventContents_BC8(buildcraft.api.transport.pipe_bc8.event_bc8.IPipeEventContents_BC8) BCPipeEventHandler(buildcraft.api.transport.pipe_bc8.BCPipeEventHandler)

Aggregations

IConnection_BC8 (buildcraft.api.transport.pipe_bc8.IConnection_BC8)3 EnumPipePart (buildcraft.api.core.EnumPipePart)1 BCPipeEventHandler (buildcraft.api.transport.pipe_bc8.BCPipeEventHandler)1 EnumContentsJourneyPart (buildcraft.api.transport.pipe_bc8.EnumContentsJourneyPart)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 IPipeEventContents_BC8 (buildcraft.api.transport.pipe_bc8.event_bc8.IPipeEventContents_BC8)1 IPipeEvent_BC8 (buildcraft.api.transport.pipe_bc8.event_bc8.IPipeEvent_BC8)1