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();
}
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;
}
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) */
}
}
Aggregations