Program: 86829
Project: 86829
Buggy source:
/** 
 * @param playerId
 * @return returns only the entities within the viewport of the supplied player
 */
public NetGameUpdate getNetGameUpdateFor(int playerId){
  Player player=this.players.getPlayer(playerId);
  if (player == null) {
    return null;
  }
  NetGameUpdate netUpdate=this.playerUpdates[playerId];
  netUpdate.clear();
  if (player.isPureSpectator()) {
    NetEntity.toNetEntities(entities,netUpdate.entities);
    NetSound.toNetSounds(netUpdate.sounds,soundEvents);
    netUpdate.numberOfSounds=(byte)soundEvents.numberOfSounds();
    if (player.getSpectating() == null || player.getSpectating().isDead()) {
      Player otherPlayer=this.players.getRandomAlivePlayer();
      if (otherPlayer != null) {
        player.setSpectating(otherPlayer);
      }
    }
  }
 else {
    PlayerEntity playerEntity=player.isSpectating() ? player.getSpectatingEntity() : player.getEntity();
    if (playerEntity != null) {
      aSoundsHeard.clear();
      aSoundsHeard=playerEntity.getHeardSounds(soundEvents,aSoundsHeard);
      NetSound.toNetSounds(netUpdate.sounds,aSoundsHeard);
      netUpdate.numberOfSounds=(byte)aSoundsHeard.size();
      aEntitiesInView.clear();
      aEntitiesInView=playerEntity.getEntitiesInView(this);
      NetEntity.toNetEntities(aEntitiesInView,netUpdate.entities);
      if (playerEntity.isAlive()) {
        netUpdate.entities[playerEntity.getId()]=playerEntity.getNetPlayer();
      }
    }
  }
  for (int i=0; i < MAX_PERSISTANT_ENTITIES; i++) {
    if (deadFrames[i] > 0) {
      netUpdate.deadPersistantEntities.setBit(i);
    }
  }
  netUpdate.time=(int)time;
  netUpdate.spectatingPlayerId=player.getSpectatingPlayerId();
  return netUpdate;
}

Fixed version (ground truth):
/** 
 * @param playerId
 * @return returns only the entities within the viewport of the supplied player
 */
public NetGameUpdate getNetGameUpdateFor(int playerId){
  Player player=this.players.getPlayer(playerId);
  if (player == null) {
    return null;
  }
  NetGameUpdate netUpdate=new NetGameUpdate();
  netUpdate.clear();
  if (player.isPureSpectator()) {
    NetEntity.toNetEntities(entities,netUpdate.entities);
    NetSound.toNetSounds(netUpdate.sounds,soundEvents);
    netUpdate.numberOfSounds=(byte)soundEvents.numberOfSounds();
    if (player.getSpectating() == null || player.getSpectating().isDead()) {
      Player otherPlayer=this.players.getRandomAlivePlayer();
      if (otherPlayer != null) {
        player.setSpectating(otherPlayer);
      }
    }
  }
 else {
    PlayerEntity playerEntity=player.isSpectating() ? player.getSpectatingEntity() : player.getEntity();
    if (playerEntity != null) {
      aSoundsHeard.clear();
      aSoundsHeard=playerEntity.getHeardSounds(soundEvents,aSoundsHeard);
      NetSound.toNetSounds(netUpdate.sounds,aSoundsHeard);
      netUpdate.numberOfSounds=(byte)aSoundsHeard.size();
      aEntitiesInView.clear();
      aEntitiesInView=playerEntity.getEntitiesInView(this);
      NetEntity.toNetEntities(aEntitiesInView,netUpdate.entities);
      if (playerEntity.isAlive()) {
        netUpdate.entities[playerEntity.getId()]=playerEntity.getNetPlayer();
      }
    }
  }
  for (int i=0; i < MAX_PERSISTANT_ENTITIES; i++) {
    if (deadFrames[i] > 0) {
      netUpdate.deadPersistantEntities.setBit(i);
    }
  }
  netUpdate.time=(int)time;
  netUpdate.spectatingPlayerId=player.getSpectatingPlayerId();
  return netUpdate;
}