powerConsumed = nearbyTransport.receiveEnergy(
ForgeDirection.VALID_DIRECTIONS[out].getOpposite(),
powerConsumed);
tilePowered = true;
} else if (tiles[out] instanceof IEnergyHandler) {
IEnergyHandler handler = (IEnergyHandler) tiles[out];
if (handler.canConnectEnergy(ForgeDirection.VALID_DIRECTIONS[out].getOpposite())) {
// Transmit power to an RF energy handler
powerConsumed = handler.receiveEnergy(ForgeDirection.VALID_DIRECTIONS[out].getOpposite(),
powerConsumed, false);
tilePowered = true;
}
} else {
PowerReceiver prov = getReceiverOnSide(ForgeDirection.VALID_DIRECTIONS[out]);
if (prov != null) {
// Transmit power to the legacy power framework
powerConsumed = (int) Math.ceil(prov.receiveEnergy(Type.PIPE, powerConsumed / 10.0,
ForgeDirection.VALID_DIRECTIONS[out].getOpposite()) * 10);
tilePowered = true;
}
}
if (!tilePowered) {
externalPower[out] = powerConsumed;
}
displayPower[out] += powerConsumed;
totalPowerConsumed += powerConsumed;
}
}
}
// STEP 3 - assume equal repartition of all consumed locations and
// compute display for each source of power
if (totalPowerConsumed > 0) {
for (int in = 0; in < 6; ++in) {
int powerConsumed = internalPower[in] * totalPowerConsumed / totalPowerContained;
displayPower[in] += powerConsumed;
}
}
// NEXT STEPS... other things to do...
highestPower = 0;
for (int i = 0; i < 6; i++) {
displayPower[i] = (short) ((prevDisplayPower[i] * (DISPLAY_SMOOTHING - 1.0F) + displayPower[i]) / DISPLAY_SMOOTHING);
if (displayPower[i] > highestPower) {
highestPower = displayPower[i];
}
if (displayPower[i] < 0) {
displayPower[i] = 0;
}
}
overload += highestPower > maxPower * 0.95 ? 1 : -1;
if (overload < 0) {
overload = 0;
}
if (overload > OVERLOAD_TICKS) {
overload = OVERLOAD_TICKS;
}
// Compute the tiles requesting energy that are not power pipes
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if (!outputOpen(dir)) {
continue;
}
TileEntity tile = tiles [dir.ordinal()];
if (tile instanceof TileGenericPipe && ((TileGenericPipe) tile).pipe.transport instanceof PipeTransportPower) {
continue;
}
if (tile instanceof IEnergyHandler) {
IEnergyHandler handler = (IEnergyHandler) tile;
if (handler.canConnectEnergy(dir.getOpposite())) {
int request = handler.receiveEnergy(dir.getOpposite(), this.maxPower, true);
if (request > 0) {
requestEnergy(dir, request);
}
}