Search in sources :

Example 1 with IPipeEvent_BC8

use of buildcraft.api.transport.pipe_bc8.event_bc8.IPipeEvent_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

BCPipeEventHandler (buildcraft.api.transport.pipe_bc8.BCPipeEventHandler)1 EnumContentsJourneyPart (buildcraft.api.transport.pipe_bc8.EnumContentsJourneyPart)1 IConnection_BC8 (buildcraft.api.transport.pipe_bc8.IConnection_BC8)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