Program: 156489
Project: 156489
Buggy source:
@Override public void updateEntity(){
  if (container.getWorld().isRemote) {
    return;
  }
  step();
  init();
  for (  EnumFacing side : EnumFacing.VALUES) {
    if (tiles[side.ordinal()] != null && tiles[side.ordinal()].isInvalid()) {
      updateTile(side);
    }
  }
  Arrays.fill(displayFlow,(short)0);
  for (int i=0; i < 6; ++i) {
    if (internalPower[i] > 0) {
      int totalPowerQuery=0;
      for (int j=0; j < 6; ++j) {
        if (j != i && powerQuery[j] > 0) {
          Object ep=providers[j];
          if (ep instanceof IPipeTile || ep instanceof IEnergyReceiver || ep instanceof IEnergyHandler) {
            totalPowerQuery+=powerQuery[j];
          }
        }
      }
      if (totalPowerQuery > 0) {
        int unusedPowerQuery=totalPowerQuery;
        for (int j=0; j < 6; ++j) {
          if (j != i && powerQuery[j] > 0) {
            Object ep=providers[j];
            double watts=Math.min(internalPower[i] * powerQuery[j] / unusedPowerQuery,internalPower[i]);
            unusedPowerQuery-=powerQuery[j];
            if (ep instanceof IPipeTile && ((IPipeTile)ep).getPipeType() == IPipeTile.PipeType.POWER) {
              Pipe<?> nearbyPipe=(Pipe<?>)((IPipeTile)ep).getPipe();
              PipeTransportPower nearbyTransport=(PipeTransportPower)nearbyPipe.transport;
              watts=nearbyTransport.receiveEnergy(EnumFacing.VALUES[j].getOpposite(),watts);
              internalPower[i]-=watts;
              dbgEnergyOutput[j]+=watts;
              powerAverage[j].push((int)Math.ceil(watts));
              powerAverage[i].push((int)Math.ceil(watts));
              displayFlow[i]=1;
              displayFlow[j]=-1;
            }
 else {
              int iWatts=(int)watts;
              if (ep instanceof IEnergyHandler) {
                IEnergyHandler handler=(IEnergyHandler)ep;
                if (handler.canConnectEnergy(EnumFacing.values()[j].getOpposite())) {
                  iWatts=handler.receiveEnergy(EnumFacing.values()[j].getOpposite(),iWatts,false);
                }
              }
 else               if (ep instanceof IEnergyReceiver) {
                IEnergyReceiver handler=(IEnergyReceiver)ep;
                if (handler.canConnectEnergy(EnumFacing.values()[j].getOpposite())) {
                  iWatts=handler.receiveEnergy(EnumFacing.values()[j].getOpposite(),iWatts,false);
                }
              }
              internalPower[i]-=iWatts;
              dbgEnergyOutput[j]+=iWatts;
              powerAverage[j].push(iWatts);
              powerAverage[i].push(iWatts);
              displayFlow[i]=1;
              displayFlow[j]=-1;
            }
          }
        }
      }
    }
  }
  short highestPower=0;
  for (int i=0; i < 6; i++) {
    powerAverage[i].tick();
    displayPower[i]=(short)Math.round(powerAverage[i].getAverage());
    if (displayPower[i] > highestPower) {
      highestPower=displayPower[i];
    }
  }
  overload+=highestPower > (maxPower * 0.95F) ? 1 : -1;
  if (overload < 0) {
    overload=0;
  }
  if (overload > OVERLOAD_TICKS) {
    overload=OVERLOAD_TICKS;
  }
  for (  EnumFacing dir : EnumFacing.VALUES) {
    if (!outputOpen(dir)) {
      continue;
    }
    Object tile=providers[dir.ordinal()];
    if (tile instanceof IPipeTile && ((IPipeTile)tile).getPipe() != null && ((Pipe<?>)((IPipeTile)tile).getPipe()).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);
        }
      }
    }
 else     if (tile instanceof IEnergyReceiver) {
      IEnergyReceiver handler=(IEnergyReceiver)tile;
      if (handler.canConnectEnergy(dir.getOpposite())) {
        int request=handler.receiveEnergy(dir.getOpposite(),this.maxPower,true);
        if (request > 0) {
          requestEnergy(dir,request);
        }
      }
    }
  }
  int[] transferQuery=new int[6];
  for (int i=0; i < 6; ++i) {
    transferQuery[i]=0;
    if (!inputOpen(EnumFacing.getFront(i))) {
      continue;
    }
    for (int j=0; j < 6; ++j) {
      if (j != i) {
        transferQuery[i]+=powerQuery[j];
      }
    }
    transferQuery[i]=Math.min(transferQuery[i],maxPower);
  }
  for (int i=0; i < 6; ++i) {
    if (transferQuery[i] != 0 && tiles[i] != null) {
      TileEntity entity=tiles[i];
      if (entity instanceof IPipeTile && ((IPipeTile)entity).getPipeType() == IPipeTile.PipeType.POWER) {
        IPipeTile nearbyTile=(IPipeTile)entity;
        if (nearbyTile.getPipe() == null || nearbyTile.getPipeType() != IPipeTile.PipeType.POWER) {
          continue;
        }
        PipeTransportPower nearbyTransport=(PipeTransportPower)((Pipe<?>)nearbyTile.getPipe()).transport;
        nearbyTransport.requestEnergy(EnumFacing.VALUES[i].getOpposite(),transferQuery[i]);
      }
    }
  }
  if (tracker.markTimeIfDelay(container.getWorld())) {
    PacketPowerUpdate packet=new PacketPowerUpdate(container);
    packet.displayPower=new short[6];
    for (int i=0; i < 6; i++) {
      double val=displayPower[i];
      val/=maxPower;
      val=Math.sqrt(val);
      val*=POWER_STAGES;
      packet.displayPower[i]=(short)val;
    }
    packet.displayFlow=displayFlow;
    packet.overload=isOverloaded();
    BuildCraftTransport.instance.sendToPlayersNear(packet,container);
  }
}

Fixed version (ground truth):
@Override public void updateEntity(){
  if (container.getWorld().isRemote) {
    return;
  }
  step();
  init();
  for (  EnumFacing side : EnumFacing.VALUES) {
    if (tiles[side.ordinal()] != null && tiles[side.ordinal()].isInvalid()) {
      updateTile(side);
    }
  }
  Arrays.fill(displayFlow,(short)0);
  for (int i=0; i < 6; ++i) {
    if (internalPower[i] > 0) {
      int totalPowerQuery=0;
      for (int j=0; j < 6; ++j) {
        if (j != i && powerQuery[j] > 0) {
          Object ep=providers[j];
          if (ep instanceof IPipeTile || ep instanceof IEnergyReceiver || ep instanceof IEnergyHandler) {
            totalPowerQuery+=powerQuery[j];
          }
        }
      }
      if (totalPowerQuery > 0) {
        int unusedPowerQuery=totalPowerQuery;
        for (int j=0; j < 6; ++j) {
          if (j != i && powerQuery[j] > 0) {
            Object ep=providers[j];
            double watts=Math.min(internalPower[i] * powerQuery[j] / unusedPowerQuery,internalPower[i]);
            unusedPowerQuery-=powerQuery[j];
            if (ep instanceof IPipeTile && ((IPipeTile)ep).getPipeType() == IPipeTile.PipeType.POWER) {
              Pipe<?> nearbyPipe=(Pipe<?>)((IPipeTile)ep).getPipe();
              PipeTransportPower nearbyTransport=(PipeTransportPower)nearbyPipe.transport;
              watts=nearbyTransport.receiveEnergy(EnumFacing.VALUES[j].getOpposite(),watts);
              internalPower[i]-=watts;
              dbgEnergyOutput[j]+=watts;
              powerAverage[j].push((int)Math.ceil(watts));
              powerAverage[i].push((int)Math.ceil(watts));
              displayFlow[i]=1;
              displayFlow[j]=-1;
            }
 else {
              int iWatts=(int)watts;
              if (ep instanceof IEnergyHandler) {
                IEnergyHandler handler=(IEnergyHandler)ep;
                if (handler.canConnectEnergy(EnumFacing.values()[j].getOpposite())) {
                  iWatts=handler.receiveEnergy(EnumFacing.values()[j].getOpposite(),iWatts,false);
                }
              }
 else               if (ep instanceof IEnergyReceiver) {
                IEnergyReceiver handler=(IEnergyReceiver)ep;
                if (handler.canConnectEnergy(EnumFacing.values()[j].getOpposite())) {
                  iWatts=handler.receiveEnergy(EnumFacing.values()[j].getOpposite(),iWatts,false);
                }
              }
              internalPower[i]-=iWatts;
              dbgEnergyOutput[j]+=iWatts;
              powerAverage[j].push(iWatts);
              powerAverage[i].push(iWatts);
              displayFlow[i]=1;
              displayFlow[j]=-1;
            }
          }
        }
      }
    }
  }
  short highestPower=0;
  for (int i=0; i < 6; i++) {
    powerAverage[i].tick();
    displayPower[i]=(short)Math.round(powerAverage[i].getAverage());
    if (displayPower[i] > highestPower) {
      highestPower=displayPower[i];
    }
  }
  overload+=highestPower > (maxPower * 0.95F) ? 1 : -1;
  if (overload < 0) {
    overload=0;
  }
  if (overload > OVERLOAD_TICKS) {
    overload=OVERLOAD_TICKS;
  }
  for (  EnumFacing dir : EnumFacing.VALUES) {
    if (!outputOpen(dir)) {
      continue;
    }
    Object tile=providers[dir.ordinal()];
    if (tile instanceof IPipeTile && ((IPipeTile)tile).getPipe() != null && ((Pipe<?>)((IPipeTile)tile).getPipe()).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);
        }
      }
    }
 else     if (tile instanceof IEnergyReceiver) {
      IEnergyReceiver handler=(IEnergyReceiver)tile;
      if (handler.canConnectEnergy(dir.getOpposite())) {
        int request=handler.receiveEnergy(dir.getOpposite(),this.maxPower,true);
        if (request > 0) {
          requestEnergy(dir,request);
        }
      }
    }
  }
  int[] transferQuery=new int[6];
  for (int i=0; i < 6; ++i) {
    transferQuery[i]=0;
    if (!inputOpen(EnumFacing.getFront(i))) {
      continue;
    }
    for (int j=0; j < 6; ++j) {
      if (j != i) {
        transferQuery[i]+=powerQuery[j];
      }
    }
    transferQuery[i]=Math.min(transferQuery[i],maxPower);
  }
  for (int i=0; i < 6; ++i) {
    if (transferQuery[i] != 0 && tiles[i] != null) {
      TileEntity entity=tiles[i];
      if (entity instanceof IPipeTile && ((IPipeTile)entity).getPipeType() == IPipeTile.PipeType.POWER) {
        IPipeTile nearbyTile=(IPipeTile)entity;
        if (nearbyTile.getPipe() == null || nearbyTile.getPipeType() != IPipeTile.PipeType.POWER) {
          continue;
        }
        PipeTransportPower nearbyTransport=(PipeTransportPower)((Pipe<?>)nearbyTile.getPipe()).transport;
        nearbyTransport.requestEnergy(EnumFacing.VALUES[i].getOpposite(),transferQuery[i]);
      }
    }
  }
  if (tracker.markTimeIfDelay(container.getWorld())) {
    PacketPowerUpdate packet=new PacketPowerUpdate(container);
    packet.displayPower=new short[6];
    for (int i=0; i < 6; i++) {
      double val=displayPower[i];
      val/=MAX_POWER;
      val=Math.sqrt(val);
      val*=POWER_STAGES;
      packet.displayPower[i]=(short)val;
    }
    packet.displayFlow=displayFlow;
    packet.overload=isOverloaded();
    BuildCraftTransport.instance.sendToPlayersNear(packet,container);
  }
}