nus-yam/ex-repair huggingface dataset:
Program: 1279
Project: 1279
Buggy source:
/** 
 * @param c
 * @param x
 * @param y
 * @param z 
 */
protected void generateTree(Chunk c,int x,int y,int z){
  if (c.getParent().isBlockSurrounded(c.getBlockWorldPosX(x),c.getBlockWorldPosY(y + 1),c.getBlockWorldPosZ(z)) || !c.canBlockSeeTheSky(x,y + 1,z)) {
    return;
  }
  float forestDens=calcForestDensity(c.getBlockWorldPosX(x),c.getBlockWorldPosY(y),c.getBlockWorldPosZ(z));
  if (c.getBlock(x,y,z) == 0x1 && y > 32) {
    double r=_rand.standNormalDistrDouble();
    if (forestDens < 0.01) {
      r+=3f;
    }
    if (r > -0.05 && r < 0.05) {
      double r2=_rand.standNormalDistrDouble();
      if (r2 > -2 && r2 < -1) {
        c.setBlock(x,y + 1,z,(byte)0x0);
        c.getParent().getGeneratorPineTree().generate(c.getBlockWorldPosX(x),c.getBlockWorldPosY((int)y) + 1,c.getBlockWorldPosZ(z),false);
      }
 else       if (r2 > -3 && r2 < -2) {
        c.setBlock(x,y + 1,z,(byte)0x0);
        c.getParent().getGeneratorFirTree().generate(c.getBlockWorldPosX(x),c.getBlockWorldPosY((int)y) + 1,c.getBlockWorldPosZ(z),false);
      }
 else {
        c.setBlock(x,y + 1,z,(byte)0x0);
        c.getParent().getGeneratorTree().generate(c.getBlockWorldPosX(x),c.getBlockWorldPosY((int)y) + 1,c.getBlockWorldPosZ(z),false);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * @param c
 * @param x
 * @param y
 * @param z 
 */
protected void generateTree(Chunk c,int x,int y,int z){
  if (c.getParent().isBlockSurrounded(c.getBlockWorldPosX(x),c.getBlockWorldPosY(y + 1),c.getBlockWorldPosZ(z)) || !c.canBlockSeeTheSky(x,y + 1,z)) {
    return;
  }
  if (c.getBlock(x,y,z) == 0x1 && y > 32) {
    float forestDens=calcForestDensity(c.getBlockWorldPosX(x),c.getBlockWorldPosY(y),c.getBlockWorldPosZ(z));
    double r=_rand.standNormalDistrDouble();
    if (forestDens < 0.01) {
      r+=3f;
    }
    if (r > -0.05 && r < 0.05) {
      double r2=_rand.standNormalDistrDouble();
      if (r2 > -2 && r2 < -1) {
        c.setBlock(x,y + 1,z,(byte)0x0);
        c.getParent().getGeneratorPineTree().generate(c.getBlockWorldPosX(x),c.getBlockWorldPosY((int)y) + 1,c.getBlockWorldPosZ(z),false);
      }
 else       if (r2 > -3 && r2 < -2) {
        c.setBlock(x,y + 1,z,(byte)0x0);
        c.getParent().getGeneratorFirTree().generate(c.getBlockWorldPosX(x),c.getBlockWorldPosY((int)y) + 1,c.getBlockWorldPosZ(z),false);
      }
 else {
        c.setBlock(x,y + 1,z,(byte)0x0);
        c.getParent().getGeneratorTree().generate(c.getBlockWorldPosX(x),c.getBlockWorldPosY((int)y) + 1,c.getBlockWorldPosZ(z),false);
      }
    }
  }
}
Program: 1280
Project: 1280
Buggy source:
/** 
 * Returns true if the block side is ajdacent to a translucent block or an air block. NOTE: Air has to be handled separatly. Otherwise the water surface would not be displayed due to the tessellation process.
 */
private boolean isSideVisibleForBlockTypes(byte blockToCheck,byte currentBlock){
  return blockToCheck == 0x0 || blockToCheck == 0x6 || (Block.getBlockForType(blockToCheck).isBlockTypeTranslucent() && !Block.getBlockForType(currentBlock).isBlockTypeTranslucent());
}

Fixed version (ground truth):
/** 
 * Returns true if the block side is ajdacent to a translucent block or an air block. NOTE: Air and leafs have to be handled separatly. Otherwise the water surface would not be displayed due to the tessellation process.
 */
private boolean isSideVisibleForBlockTypes(byte blockToCheck,byte currentBlock){
  return blockToCheck == 0x0 || blockToCheck == 0x6 || Block.getBlockForType(blockToCheck).isBlockBillboard() || (Block.getBlockForType(blockToCheck).isBlockTypeTranslucent() && !Block.getBlockForType(currentBlock).isBlockTypeTranslucent());
}
Program: 1281
Project: 1281
Buggy source:
/** 
 */
public static void loadDefaults(){
  _settingsBoolean.put("String_Node_Str",true);
  _settingsBoolean.put("String_Node_Str",false);
  _settingsBoolean.put("String_Node_Str",true);
  _settingsBoolean.put("String_Node_Str",true);
  _settingsBoolean.put("String_Node_Str",false);
  _settingsBoolean.put("String_Node_Str",false);
  _settingsNumeric.put("String_Node_Str",10f);
  _settingsNumeric.put("String_Node_Str",64f);
  _settingsNumeric.put("String_Node_Str",1.5f);
  _settingsNumeric.put("String_Node_Str",1.2f);
  _settingsNumeric.put("String_Node_Str",0.8f);
  _settingsNumeric.put("String_Node_Str",0.05f);
  _settingsNumeric.put("String_Node_Str",0.05f);
}

Fixed version (ground truth):
/** 
 */
public static void loadDefaults(){
  _settingsBoolean.put("String_Node_Str",true);
  _settingsBoolean.put("String_Node_Str",false);
  _settingsBoolean.put("String_Node_Str",true);
  _settingsBoolean.put("String_Node_Str",true);
  _settingsBoolean.put("String_Node_Str",false);
  _settingsBoolean.put("String_Node_Str",false);
  _settingsNumeric.put("String_Node_Str",10f);
  _settingsNumeric.put("String_Node_Str",64f);
  _settingsNumeric.put("String_Node_Str",1.5f);
  _settingsNumeric.put("String_Node_Str",1.6f);
  _settingsNumeric.put("String_Node_Str",0.8f);
  _settingsNumeric.put("String_Node_Str",0.05f);
  _settingsNumeric.put("String_Node_Str",0.05f);
}
Program: 1282
Project: 1282
Buggy source:
/** 
 * Sets the light value at the given position.
 * @param x The X-coordinate
 * @param y The Y-coordinate
 * @param z The Z-coordinate
 * @param intens The light intensity value
 */
public void setSunlight(int x,int y,int z,byte intens){
  int chunkPosX=calcChunkPosX(x) % (int)Configuration.VIEWING_DISTANCE_IN_CHUNKS.x;
  int chunkPosY=calcChunkPosY(y) % (int)Configuration.VIEWING_DISTANCE_IN_CHUNKS.y;
  int chunkPosZ=calcChunkPosZ(z) % (int)Configuration.VIEWING_DISTANCE_IN_CHUNKS.z;
  int blockPosX=calcBlockPosX(x,chunkPosX);
  int blockPosY=calcBlockPosY(y,chunkPosY);
  int blockPosZ=calcBlockPosZ(z,chunkPosZ);
  try {
    Chunk c=loadOrCreateChunk(calcChunkPosX(x),calcChunkPosZ(z));
    c.setSunlight(blockPosX,blockPosY,blockPosZ,intens);
  }
 catch (  Exception e) {
  }
}

Fixed version (ground truth):
/** 
 * Sets the light value at the given position.
 * @param x The X-coordinate
 * @param y The Y-coordinate
 * @param z The Z-coordinate
 * @param intens The light intensity value
 */
public void setSunlight(int x,int y,int z,byte intens){
  int chunkPosX=calcChunkPosX(x) % (int)Configuration.VIEWING_DISTANCE_IN_CHUNKS.x;
  int chunkPosZ=calcChunkPosZ(z) % (int)Configuration.VIEWING_DISTANCE_IN_CHUNKS.y;
  int blockPosX=calcBlockPosX(x,chunkPosX);
  int blockPosZ=calcBlockPosZ(z,chunkPosZ);
  try {
    Chunk c=loadOrCreateChunk(calcChunkPosX(x),calcChunkPosZ(z));
    c.setSunlight(blockPosX,y,blockPosZ,intens);
  }
 catch (  Exception e) {
  }
}
Program: 1283
Project: 1283
Buggy source:
/** 
 * Places a block of a specific type at a given position.
 * @param x The X-coordinate
 * @param y The Y-coordinate
 * @param z The Z-coordinate
 * @param type The type of the block to set
 * @param update If set the affected chunk is queued for updating
 * @param overwrite  
 */
public final void setBlock(int x,int y,int z,byte type,boolean update,boolean overwrite){
  int chunkPosX=calcChunkPosX(x) % (int)Configuration.VIEWING_DISTANCE_IN_CHUNKS.x;
  int chunkPosY=calcChunkPosY(y) % (int)Configuration.VIEWING_DISTANCE_IN_CHUNKS.y;
  int chunkPosZ=calcChunkPosZ(z) % (int)Configuration.VIEWING_DISTANCE_IN_CHUNKS.z;
  int blockPosX=calcBlockPosX(x,chunkPosX);
  int blockPosY=calcBlockPosY(y,chunkPosY);
  int blockPosZ=calcBlockPosZ(z,chunkPosZ);
  try {
    Chunk c=loadOrCreateChunk(calcChunkPosX(x),calcChunkPosZ(z));
    if (overwrite || c.getBlock(blockPosX,blockPosY,blockPosZ) == 0) {
      c.setBlock(blockPosX,blockPosY,blockPosZ,type);
      if (update) {
        byte oldValue=getLight(x,y,z);
        c.calcSunlightAtLocalPos(blockPosX,blockPosZ,true);
        c.refreshLightAtLocalPos(blockPosX,blockPosY,blockPosZ);
        byte newValue=getLight(x,y,z);
        if (newValue > oldValue) {
          c.spreadLight(blockPosX,blockPosY,blockPosZ,newValue);
        }
 else         if (newValue < oldValue) {
        }
        queueChunkForUpdate(c);
      }
    }
  }
 catch (  Exception e) {
  }
}

Fixed version (ground truth):
/** 
 * Places a block of a specific type at a given position.
 * @param x The X-coordinate
 * @param y The Y-coordinate
 * @param z The Z-coordinate
 * @param type The type of the block to set
 * @param update If set the affected chunk is queued for updating
 * @param overwrite  
 */
public final void setBlock(int x,int y,int z,byte type,boolean update,boolean overwrite){
  int chunkPosX=calcChunkPosX(x) % (int)Configuration.VIEWING_DISTANCE_IN_CHUNKS.x;
  int chunkPosZ=calcChunkPosZ(z) % (int)Configuration.VIEWING_DISTANCE_IN_CHUNKS.y;
  int blockPosX=calcBlockPosX(x,chunkPosX);
  int blockPosZ=calcBlockPosZ(z,chunkPosZ);
  try {
    Chunk c=loadOrCreateChunk(calcChunkPosX(x),calcChunkPosZ(z));
    if (overwrite || c.getBlock(blockPosX,y,blockPosZ) == 0) {
      c.setBlock(blockPosX,y,blockPosZ,type);
      if (update) {
        byte oldValue=getLight(x,y,z);
        c.calcSunlightAtLocalPos(blockPosX,blockPosZ,true);
        c.refreshLightAtLocalPos(blockPosX,y,blockPosZ);
        byte newValue=getLight(x,y,z);
        if (newValue > oldValue) {
          c.spreadLight(blockPosX,y,blockPosZ,newValue);
        }
 else         if (newValue < oldValue) {
        }
        queueChunkForUpdate(c);
      }
    }
  }
 catch (  Exception e) {
  }
}
Program: 1285
Project: 1285
Buggy source:
/** 
 * Recursive light calculation. Too slow!
 * @param x
 * @param y
 * @param z
 * @param lightValue
 * @param depth  
 */
public void spreadLight(int x,int y,int z,byte lightValue,int depth){
  int chunkPosX=calcChunkPosX(x) % (int)Configuration.VIEWING_DISTANCE_IN_CHUNKS.x;
  int chunkPosY=calcChunkPosY(y) % (int)Configuration.VIEWING_DISTANCE_IN_CHUNKS.y;
  int chunkPosZ=calcChunkPosZ(z) % (int)Configuration.VIEWING_DISTANCE_IN_CHUNKS.z;
  int blockPosX=calcBlockPosX(x,chunkPosX);
  int blockPosY=calcBlockPosY(y,chunkPosY);
  int blockPosZ=calcBlockPosZ(z,chunkPosZ);
  try {
    Chunk c=loadOrCreateChunk(calcChunkPosX(x),calcChunkPosZ(z));
    c.spreadLight(blockPosX,blockPosY,blockPosZ,lightValue,depth);
  }
 catch (  Exception e) {
  }
}

Fixed version (ground truth):
/** 
 * Recursive light calculation. Too slow!
 * @param x
 * @param y
 * @param z
 * @param lightValue
 * @param depth  
 */
public void spreadLight(int x,int y,int z,byte lightValue,int depth){
  int chunkPosX=calcChunkPosX(x) % (int)Configuration.VIEWING_DISTANCE_IN_CHUNKS.x;
  int chunkPosZ=calcChunkPosZ(z) % (int)Configuration.VIEWING_DISTANCE_IN_CHUNKS.y;
  int blockPosX=calcBlockPosX(x,chunkPosX);
  int blockPosZ=calcBlockPosZ(z,chunkPosZ);
  try {
    Chunk c=loadOrCreateChunk(calcChunkPosX(x),calcChunkPosZ(z));
    c.spreadLight(blockPosX,y,blockPosZ,lightValue,depth);
  }
 catch (  Exception e) {
  }
}
Program: 1286
Project: 1286
Buggy source:
/** 
 * Recursive light calculation. Too weird.
 * @param x
 * @param y
 * @param z
 * @param oldValue
 * @param depth  
 */
public void unspreadLight(int x,int y,int z,byte oldValue,int depth){
  int chunkPosX=calcChunkPosX(x) % (int)Configuration.VIEWING_DISTANCE_IN_CHUNKS.x;
  int chunkPosY=calcChunkPosY(y) % (int)Configuration.VIEWING_DISTANCE_IN_CHUNKS.y;
  int chunkPosZ=calcChunkPosZ(z) % (int)Configuration.VIEWING_DISTANCE_IN_CHUNKS.z;
  int blockPosX=calcBlockPosX(x,chunkPosX);
  int blockPosY=calcBlockPosY(y,chunkPosY);
  int blockPosZ=calcBlockPosZ(z,chunkPosZ);
  try {
    Chunk c=loadOrCreateChunk(calcChunkPosX(x),calcChunkPosZ(z));
    c.unspreadLight(blockPosX,blockPosY,blockPosZ,oldValue,depth);
  }
 catch (  Exception e) {
  }
}

Fixed version (ground truth):
/** 
 * Recursive light calculation. Too weird.
 * @param x
 * @param y
 * @param z
 * @param oldValue
 * @param depth  
 */
public void unspreadLight(int x,int y,int z,byte oldValue,int depth){
  int chunkPosX=calcChunkPosX(x) % (int)Configuration.VIEWING_DISTANCE_IN_CHUNKS.x;
  int chunkPosZ=calcChunkPosZ(z) % (int)Configuration.VIEWING_DISTANCE_IN_CHUNKS.y;
  int blockPosX=calcBlockPosX(x,chunkPosX);
  int blockPosZ=calcBlockPosZ(z,chunkPosZ);
  try {
    Chunk c=loadOrCreateChunk(calcChunkPosX(x),calcChunkPosZ(z));
    c.unspreadLight(blockPosX,y,blockPosZ,oldValue,depth);
  }
 catch (  Exception e) {
  }
}
Program: 1287
Project: 1287
Buggy source:
/** 
 * Loads a specified chunk from the cache or queues a new chunk for generation. NOTE: This method ALWAYS returns a valid chunk since new chunks are generated if none of the present chunks fit.
 * @param x X-coordinate of the chunk
 * @param z Z-coordinate of the chunk
 * @return The chunk
 */
public Chunk loadOrCreateChunk(int x,int z){
  if (x < 0 || z < 0) {
    return null;
  }
  Chunk c=getChunk(x,0,z);
  if (c != null) {
    if (c.getPosition().x != x || c.getPosition().y != 0 || c.getPosition().z != z) {
      c=_chunkCache.get(Helper.getInstance().cantorize(x,z));
    }
  }
  if (c != null) {
    return c;
  }
 else {
  }
  if (_chunkCache.size() >= 1024) {
    ArrayList<Chunk> sortedChunks=null;
    sortedChunks=new ArrayList<Chunk>(_chunkCache.values());
    Collections.sort(sortedChunks);
    Logger.getLogger(this.getClass().getName()).log(Level.INFO,"String_Node_Str");
    for (int i=0; i < 32; i++) {
      int indexToDelete=sortedChunks.size() - i;
      if (indexToDelete >= 0 && indexToDelete < sortedChunks.size()) {
        Chunk cc=sortedChunks.get(indexToDelete);
        _chunkCache.remove(Helper.getInstance().cantorize((int)cc.getPosition().x,(int)cc.getPosition().z));
        _chunkUpdateNormal.remove(cc);
        cc.dispose();
      }
    }
    Logger.getLogger(this.getClass().getName()).log(Level.INFO,"String_Node_Str");
  }
  c=prepareNewChunk(x,z);
  _chunkCache.put(Helper.getInstance().cantorize(x,z),c);
  return c;
}

Fixed version (ground truth):
/** 
 * Loads a specified chunk from the cache or queues a new chunk for generation. NOTE: This method ALWAYS returns a valid chunk since new chunks are generated if none of the present chunks fit.
 * @param x X-coordinate of the chunk
 * @param z Z-coordinate of the chunk
 * @return The chunk
 */
public Chunk loadOrCreateChunk(int x,int z){
  if (x < 0 || z < 0) {
    return null;
  }
  Chunk c=getChunk(x,z);
  if (c != null) {
    if (c.getPosition().x != x || c.getPosition().y != 0 || c.getPosition().z != z) {
      c=_chunkCache.get(Helper.getInstance().cantorize(x,z));
    }
  }
  if (c != null) {
    return c;
  }
 else {
  }
  if (_chunkCache.size() >= 1024) {
    ArrayList<Chunk> sortedChunks=null;
    sortedChunks=new ArrayList<Chunk>(_chunkCache.values());
    Collections.sort(sortedChunks);
    Logger.getLogger(this.getClass().getName()).log(Level.INFO,"String_Node_Str");
    for (int i=0; i < 32; i++) {
      int indexToDelete=sortedChunks.size() - i;
      if (indexToDelete >= 0 && indexToDelete < sortedChunks.size()) {
        Chunk cc=sortedChunks.get(indexToDelete);
        _chunkCache.remove(Helper.getInstance().cantorize((int)cc.getPosition().x,(int)cc.getPosition().z));
        _chunkUpdateNormal.remove(cc);
        cc.dispose();
      }
    }
    Logger.getLogger(this.getClass().getName()).log(Level.INFO,"String_Node_Str");
  }
  c=prepareNewChunk(x,z);
  _chunkCache.put(Helper.getInstance().cantorize(x,z),c);
  return c;
}
Program: 1288
Project: 1288
Buggy source:
/** 
 * Returns the internal position of a block within a chunk.
 * @param x1 The Z-coordinate of the block within the world
 * @param x2 The Z-coordinate of the chunk within the world
 * @return The Z-coordinate of the block within the chunk
 */
private int calcBlockPosZ(int z1,int z2){
  z1=z1 % ((int)Configuration.VIEWING_DISTANCE_IN_CHUNKS.z * (int)Configuration.CHUNK_DIMENSIONS.z);
  return (z1 - (z2 * (int)Configuration.CHUNK_DIMENSIONS.z));
}

Fixed version (ground truth):
/** 
 * Returns the internal position of a block within a chunk.
 * @param x1 The Z-coordinate of the block within the world
 * @param x2 The Z-coordinate of the chunk within the world
 * @return The Z-coordinate of the block within the chunk
 */
private int calcBlockPosZ(int z1,int z2){
  z1=z1 % ((int)Configuration.VIEWING_DISTANCE_IN_CHUNKS.y * (int)Configuration.CHUNK_DIMENSIONS.z);
  return (z1 - (z2 * (int)Configuration.CHUNK_DIMENSIONS.z));
}
Program: 1289
Project: 1289
Buggy source:
/** 
 * Returns the light value at the given position.
 * @param x The X-coordinate
 * @param y The Y-coordinate
 * @param z The Z-coordinate
 * @return The light value
 */
public final byte getLight(int x,int y,int z){
  int chunkPosX=calcChunkPosX(x) % (int)Configuration.VIEWING_DISTANCE_IN_CHUNKS.x;
  int chunkPosY=calcChunkPosY(y) % (int)Configuration.VIEWING_DISTANCE_IN_CHUNKS.y;
  int chunkPosZ=calcChunkPosZ(z) % (int)Configuration.VIEWING_DISTANCE_IN_CHUNKS.z;
  int blockPosX=calcBlockPosX(x,chunkPosX);
  int blockPosY=calcBlockPosY(y,chunkPosY);
  int blockPosZ=calcBlockPosZ(z,chunkPosZ);
  try {
    Chunk c=loadOrCreateChunk(calcChunkPosX(x),calcChunkPosZ(z));
    return c.getLight(blockPosX,blockPosY,blockPosZ);
  }
 catch (  Exception e) {
  }
  return -1;
}

Fixed version (ground truth):
/** 
 * Returns the light value at the given position.
 * @param x The X-coordinate
 * @param y The Y-coordinate
 * @param z The Z-coordinate
 * @return The light value
 */
public final byte getLight(int x,int y,int z){
  int chunkPosX=calcChunkPosX(x) % (int)Configuration.VIEWING_DISTANCE_IN_CHUNKS.x;
  int chunkPosZ=calcChunkPosZ(z) % (int)Configuration.VIEWING_DISTANCE_IN_CHUNKS.y;
  int blockPosX=calcBlockPosX(x,chunkPosX);
  int blockPosZ=calcBlockPosZ(z,chunkPosZ);
  try {
    Chunk c=loadOrCreateChunk(calcChunkPosX(x),calcChunkPosZ(z));
    return c.getLight(blockPosX,y,blockPosZ);
  }
 catch (  Exception e) {
  }
  return -1;
}
Program: 1290
Project: 1290
Buggy source:
/** 
 * Updates the displayed chunks according to the players position and queues new chunks for updating.
 */
private void updateInfWorld(){
  for (int x=0; x < Configuration.VIEWING_DISTANCE_IN_CHUNKS.x; x++) {
    for (int z=0; z < Configuration.VIEWING_DISTANCE_IN_CHUNKS.z; z++) {
      Chunk c=getChunk(x,0,z);
      if (c != null) {
        Vector3f pos=new Vector3f(x,0,z);
        int multZ=(int)calcPlayerChunkOffsetZ() / (int)Configuration.VIEWING_DISTANCE_IN_CHUNKS.z + 1;
        if (z < calcPlayerChunkOffsetZ() % Configuration.VIEWING_DISTANCE_IN_CHUNKS.z) {
          pos.z+=Configuration.VIEWING_DISTANCE_IN_CHUNKS.z * multZ;
        }
 else {
          pos.z+=Configuration.VIEWING_DISTANCE_IN_CHUNKS.z * (multZ - 1);
        }
        int multX=(int)calcPlayerChunkOffsetX() / (int)Configuration.VIEWING_DISTANCE_IN_CHUNKS.x + 1;
        if (x < calcPlayerChunkOffsetX() % Configuration.VIEWING_DISTANCE_IN_CHUNKS.x) {
          pos.x+=Configuration.VIEWING_DISTANCE_IN_CHUNKS.x * multX;
        }
 else {
          pos.x+=Configuration.VIEWING_DISTANCE_IN_CHUNKS.x * (multX - 1);
        }
        if (c.getPosition().x != pos.x || c.getPosition().z != pos.z) {
          _chunkUpdateNormal.remove(c);
          c=loadOrCreateChunk((int)pos.x,(int)pos.z);
          _chunks[x][0][z]=c;
          queueChunkForUpdate(c);
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Updates the displayed chunks according to the players position and queues new chunks for updating.
 */
private void updateInfWorld(){
  for (int x=0; x < Configuration.VIEWING_DISTANCE_IN_CHUNKS.x; x++) {
    for (int z=0; z < Configuration.VIEWING_DISTANCE_IN_CHUNKS.y; z++) {
      Chunk c=getChunk(x,z);
      if (c != null) {
        Vector3f pos=new Vector3f(x,0,z);
        int multZ=(int)calcPlayerChunkOffsetZ() / (int)Configuration.VIEWING_DISTANCE_IN_CHUNKS.y + 1;
        if (z < calcPlayerChunkOffsetZ() % Configuration.VIEWING_DISTANCE_IN_CHUNKS.y) {
          pos.z+=Configuration.VIEWING_DISTANCE_IN_CHUNKS.y * multZ;
        }
 else {
          pos.z+=Configuration.VIEWING_DISTANCE_IN_CHUNKS.y * (multZ - 1);
        }
        int multX=(int)calcPlayerChunkOffsetX() / (int)Configuration.VIEWING_DISTANCE_IN_CHUNKS.x + 1;
        if (x < calcPlayerChunkOffsetX() % Configuration.VIEWING_DISTANCE_IN_CHUNKS.x) {
          pos.x+=Configuration.VIEWING_DISTANCE_IN_CHUNKS.x * multX;
        }
 else {
          pos.x+=Configuration.VIEWING_DISTANCE_IN_CHUNKS.x * (multX - 1);
        }
        if (c.getPosition().x != pos.x || c.getPosition().z != pos.z) {
          _chunkUpdateNormal.remove(c);
          c=loadOrCreateChunk((int)pos.x,(int)pos.z);
          _chunks[x][z]=c;
          queueChunkForUpdate(c);
        }
      }
    }
  }
}
Program: 1291
Project: 1291
Buggy source:
/** 
 * Calculates the intersection of a given ray originating from a specified point with a block. Returns a list of intersections ordered by the distance to the player.
 * @param x
 * @param y
 * @param z
 * @param origin
 * @param ray
 * @return Distance-ordered list of ray-face-intersections
 */
public ArrayList<RayFaceIntersection> rayBlockIntersection(int x,int y,int z,Vector3f origin,Vector3f ray){
  if (getBlock(x,y,z) == 0) {
    return null;
  }
  ArrayList<RayFaceIntersection> result=new ArrayList<RayFaceIntersection>();
  Vector3f[] vertices=verticesForBlockAt(x,y,z);
  Vector3f blockPos=new Vector3f(x,y,z);
  RayFaceIntersection is=rayFaceIntersection(blockPos,vertices[0],vertices[3],vertices[2],origin,ray);
  if (is != null) {
    result.add(is);
  }
  is=rayFaceIntersection(blockPos,vertices[4],vertices[5],vertices[6],origin,ray);
  if (is != null) {
    result.add(is);
  }
  is=rayFaceIntersection(blockPos,vertices[0],vertices[4],vertices[7],origin,ray);
  if (is != null) {
    result.add(is);
  }
  is=rayFaceIntersection(blockPos,vertices[1],vertices[2],vertices[6],origin,ray);
  if (is != null) {
    result.add(is);
  }
  is=rayFaceIntersection(blockPos,vertices[3],vertices[7],vertices[6],origin,ray);
  if (is != null) {
    result.add(is);
  }
  is=rayFaceIntersection(blockPos,vertices[0],vertices[1],vertices[5],origin,ray);
  if (is != null) {
    result.add(is);
  }
  Collections.sort(result);
  return result;
}

Fixed version (ground truth):
/** 
 * Calculates the intersection of a given ray originating from a specified point with a block. Returns a list of intersections ordered by the distance to the player.
 * @param x
 * @param y
 * @param z
 * @param origin
 * @param ray
 * @return Distance-ordered list of ray-face-intersections
 */
public ArrayList<RayFaceIntersection> rayBlockIntersection(int x,int y,int z,Vector3f origin,Vector3f ray){
  if (Block.getBlock(getBlock(x,y,z)).isBlockInvisible()) {
    return null;
  }
  ArrayList<RayFaceIntersection> result=new ArrayList<RayFaceIntersection>();
  Vector3f[] vertices=verticesForBlockAt(x,y,z);
  Vector3f blockPos=new Vector3f(x,y,z);
  RayFaceIntersection is=rayFaceIntersection(blockPos,vertices[0],vertices[3],vertices[2],origin,ray);
  if (is != null) {
    result.add(is);
  }
  is=rayFaceIntersection(blockPos,vertices[4],vertices[5],vertices[6],origin,ray);
  if (is != null) {
    result.add(is);
  }
  is=rayFaceIntersection(blockPos,vertices[0],vertices[4],vertices[7],origin,ray);
  if (is != null) {
    result.add(is);
  }
  is=rayFaceIntersection(blockPos,vertices[1],vertices[2],vertices[6],origin,ray);
  if (is != null) {
    result.add(is);
  }
  is=rayFaceIntersection(blockPos,vertices[3],vertices[7],vertices[6],origin,ray);
  if (is != null) {
    result.add(is);
  }
  is=rayFaceIntersection(blockPos,vertices[0],vertices[1],vertices[5],origin,ray);
  if (is != null) {
    result.add(is);
  }
  Collections.sort(result);
  return result;
}
Program: 1292
Project: 1292
Buggy source:
/** 
 * @param c
 * @return
 */
public boolean isChunkVisible(Chunk c){
  if (c.getPosition().x >= calcChunkPosX((int)_player.getPosition().x) - Configuration.VIEWING_DISTANCE_IN_CHUNKS.x / 2 && c.getPosition().x < Configuration.VIEWING_DISTANCE_IN_CHUNKS.x / 2 + calcChunkPosX((int)_player.getPosition().x)) {
    if (c.getPosition().z >= calcChunkPosZ((int)_player.getPosition().z) - Configuration.VIEWING_DISTANCE_IN_CHUNKS.z / 2 && c.getPosition().z < Configuration.VIEWING_DISTANCE_IN_CHUNKS.z / 2 + calcChunkPosZ((int)_player.getPosition().z)) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
/** 
 * @param c
 * @return
 */
public boolean isChunkVisible(Chunk c){
  if (c.getPosition().x >= calcChunkPosX((int)_player.getPosition().x) - Configuration.VIEWING_DISTANCE_IN_CHUNKS.x / 2 && c.getPosition().x < Configuration.VIEWING_DISTANCE_IN_CHUNKS.x / 2 + calcChunkPosX((int)_player.getPosition().x)) {
    if (c.getPosition().z >= calcChunkPosZ((int)_player.getPosition().z) - Configuration.VIEWING_DISTANCE_IN_CHUNKS.y / 2 && c.getPosition().z < Configuration.VIEWING_DISTANCE_IN_CHUNKS.y / 2 + calcChunkPosZ((int)_player.getPosition().z)) {
      return true;
    }
  }
  return false;
}
Program: 1294
Project: 1294
Buggy source:
/** 
 * Returns the block at the given position.
 * @param x The X-coordinate
 * @param y The Y-coordinate
 * @param z The Z-coordinate
 * @return The type of the block
 */
public final byte getBlock(int x,int y,int z){
  int chunkPosX=calcChunkPosX(x) % (int)Configuration.VIEWING_DISTANCE_IN_CHUNKS.x;
  int chunkPosY=calcChunkPosY(y) % (int)Configuration.VIEWING_DISTANCE_IN_CHUNKS.y;
  int chunkPosZ=calcChunkPosZ(z) % (int)Configuration.VIEWING_DISTANCE_IN_CHUNKS.z;
  int blockPosX=calcBlockPosX(x,chunkPosX);
  int blockPosY=calcBlockPosY(y,chunkPosY);
  int blockPosZ=calcBlockPosZ(z,chunkPosZ);
  try {
    Chunk c=loadOrCreateChunk(calcChunkPosX(x),calcChunkPosZ(z));
    return c.getBlock(blockPosX,blockPosY,blockPosZ);
  }
 catch (  Exception e) {
  }
  return -1;
}

Fixed version (ground truth):
/** 
 * Returns the block at the given position.
 * @param x The X-coordinate
 * @param y The Y-coordinate
 * @param z The Z-coordinate
 * @return The type of the block
 */
public final byte getBlock(int x,int y,int z){
  int chunkPosX=calcChunkPosX(x) % (int)Configuration.VIEWING_DISTANCE_IN_CHUNKS.x;
  int chunkPosZ=calcChunkPosZ(z) % (int)Configuration.VIEWING_DISTANCE_IN_CHUNKS.y;
  int blockPosX=calcBlockPosX(x,chunkPosX);
  int blockPosZ=calcBlockPosZ(z,chunkPosZ);
  try {
    Chunk c=loadOrCreateChunk(calcChunkPosX(x),calcChunkPosZ(z));
    return c.getBlock(blockPosX,y,blockPosZ);
  }
 catch (  Exception e) {
  }
  return -1;
}
Program: 1295
Project: 1295
Buggy source:
/** 
 * Queues all displayed chunks for updating.
 */
public void updateAllChunks(){
  for (int x=0; x < Configuration.VIEWING_DISTANCE_IN_CHUNKS.x; x++) {
    for (int y=0; y < Configuration.VIEWING_DISTANCE_IN_CHUNKS.y; y++) {
      for (int z=0; z < Configuration.VIEWING_DISTANCE_IN_CHUNKS.z; z++) {
        Chunk c=getChunk(x,y,z);
        queueChunkForUpdate(c);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Queues all displayed chunks for updating.
 */
public void updateAllChunks(){
  for (int x=0; x < Configuration.VIEWING_DISTANCE_IN_CHUNKS.x; x++) {
    for (int z=0; z < Configuration.VIEWING_DISTANCE_IN_CHUNKS.y; z++) {
      Chunk c=getChunk(x,z);
      queueChunkForUpdate(c);
    }
  }
}
Program: 1296
Project: 1296
Buggy source:
/** 
 * Returns the chunk at the given position.
 * @param x The X-coordinate
 * @param y The Y-coordinate
 * @param z The Z-coordinate
 * @return The chunk
 */
public final Chunk getChunk(int x,int y,int z){
  Chunk c=null;
  try {
    c=_chunks[x % (int)Configuration.VIEWING_DISTANCE_IN_CHUNKS.x][y % (int)Configuration.VIEWING_DISTANCE_IN_CHUNKS.y][z % (int)Configuration.VIEWING_DISTANCE_IN_CHUNKS.z];
  }
 catch (  Exception e) {
  }
  return c;
}

Fixed version (ground truth):
/** 
 * Returns the chunk at the given position.
 * @param x The X-coordinate
 * @param y The Y-coordinate
 * @param z The Z-coordinate
 * @return The chunk
 */
public final Chunk getChunk(int x,int z){
  Chunk c=null;
  try {
    c=_chunks[x % (int)Configuration.VIEWING_DISTANCE_IN_CHUNKS.x][z % (int)Configuration.VIEWING_DISTANCE_IN_CHUNKS.y];
  }
 catch (  Exception e) {
  }
  return c;
}
Program: 1297
Project: 1297
Buggy source:
/** 
 * Returns the cave density for the base terrain.
 * @param x
 * @param y
 * @param z
 * @return
 */
protected float calcForestDensity(float x,float y,float z){
  float result=0.0f;
  result+=_pGen1.noise(0.004f * x,0.004f * y,0.004f * z);
  return result;
}

Fixed version (ground truth):
/** 
 * Returns the cave density for the base terrain.
 * @param x
 * @param y
 * @param z
 * @return
 */
protected float calcForestDensity(float x,float y,float z){
  float result=0.0f;
  result+=_pGen3.noise(0.04f * x,0.04f * y,0.04f * z);
  return result;
}
Program: 1298
Project: 1298
Buggy source:
/** 
 * @param x
 * @param y
 * @param z
 * @return
 */
protected float calcGrassDensity(float x,float y,float z){
  float result=0.0f;
  result+=_pGen1.noise(0.8f * x,0.8f * y,0.8f * z);
  return result;
}

Fixed version (ground truth):
/** 
 * @param x
 * @param y
 * @param z
 * @return
 */
protected float calcGrassDensity(float x,float y,float z){
  float result=0.0f;
  result+=_pGen3.noise(0.8f * x,0.8f * y,0.8f * z);
  return result;
}
Program: 1299
Project: 1299
Buggy source:
/** 
 * Returns the spawning point of the player. TODO: Should not determine the spawning point randomly.
 * @return The coordinates of the spawning point
 */
public Vector3f calcPlayerOrigin(){
  return new Vector3f(Configuration.CHUNK_DIMENSIONS.x * Configuration.VIEWING_DISTANCE_IN_CHUNKS.x / 2,127,(Configuration.CHUNK_DIMENSIONS.z * Configuration.VIEWING_DISTANCE_IN_CHUNKS.z) / 2);
}

Fixed version (ground truth):
/** 
 * Returns the spawning point of the player. TODO: Should not determine the spawning point randomly.
 * @return The coordinates of the spawning point
 */
public Vector3f calcPlayerOrigin(){
  return new Vector3f(Configuration.CHUNK_DIMENSIONS.x * Configuration.VIEWING_DISTANCE_IN_CHUNKS.x / 2,127,(Configuration.CHUNK_DIMENSIONS.z * Configuration.VIEWING_DISTANCE_IN_CHUNKS.y) / 2);
}
Program: 1300
Project: 1300
Buggy source:
/** 
 * Saves this chunk to the disk.
 * @return 
 */
public boolean writeChunkToDisk(){
  if (_fresh) {
    return false;
  }
  ByteBuffer output=BufferUtils.createByteBuffer((int)Configuration.CHUNK_DIMENSIONS.x * (int)Configuration.CHUNK_DIMENSIONS.y * (int)Configuration.CHUNK_DIMENSIONS.z* 3);
  File dir1=new File(String.format("String_Node_Str",_parent.getTitle()));
  if (!dir1.exists()) {
    dir1.mkdir();
  }
  File dir2=new File(String.format("String_Node_Str",_parent.getTitle()));
  if (!dir2.exists()) {
    dir2.mkdir();
  }
  File f=new File(String.format("String_Node_Str",_parent.getTitle(),Helper.getInstance().cantorize((int)_position.x,(int)_position.z)));
  for (int x=0; x < Configuration.CHUNK_DIMENSIONS.x; x++) {
    for (int y=0; y < Configuration.CHUNK_DIMENSIONS.y; y++) {
      for (int z=0; z < Configuration.CHUNK_DIMENSIONS.z; z++) {
        output.put(_blocks[x][y][z]);
        output.put(_sunlight[x][y][z]);
      }
    }
  }
  output.rewind();
  try {
    FileOutputStream oS=new FileOutputStream(f);
    FileChannel c=oS.getChannel();
    c.write(output);
    oS.close();
    return true;
  }
 catch (  FileNotFoundException ex) {
    Logger.getLogger(Chunk.class.getName()).log(Level.SEVERE,null,ex);
  }
catch (  IOException ex) {
    Logger.getLogger(Chunk.class.getName()).log(Level.SEVERE,null,ex);
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Saves this chunk to the disk.
 * @return 
 */
public boolean writeChunkToDisk(){
  if (_fresh || _lightDirty) {
    return false;
  }
  ByteBuffer output=BufferUtils.createByteBuffer((int)Configuration.CHUNK_DIMENSIONS.x * (int)Configuration.CHUNK_DIMENSIONS.y * (int)Configuration.CHUNK_DIMENSIONS.z* 3);
  File dir1=new File(String.format("String_Node_Str",_parent.getTitle()));
  if (!dir1.exists()) {
    dir1.mkdir();
  }
  File dir2=new File(String.format("String_Node_Str",_parent.getTitle()));
  if (!dir2.exists()) {
    dir2.mkdir();
  }
  File f=new File(String.format("String_Node_Str",_parent.getTitle(),Helper.getInstance().cantorize((int)_position.x,(int)_position.z)));
  for (int x=0; x < Configuration.CHUNK_DIMENSIONS.x; x++) {
    for (int y=0; y < Configuration.CHUNK_DIMENSIONS.y; y++) {
      for (int z=0; z < Configuration.CHUNK_DIMENSIONS.z; z++) {
        output.put(_blocks[x][y][z]);
        output.put(_sunlight[x][y][z]);
      }
    }
  }
  output.rewind();
  try {
    FileOutputStream oS=new FileOutputStream(f);
    FileChannel c=oS.getChannel();
    c.write(output);
    oS.close();
    return true;
  }
 catch (  FileNotFoundException ex) {
    Logger.getLogger(Chunk.class.getName()).log(Level.SEVERE,null,ex);
  }
catch (  IOException ex) {
    Logger.getLogger(Chunk.class.getName()).log(Level.SEVERE,null,ex);
  }
  return false;
}
Program: 1301
Project: 1301
Buggy source:
/** 
 * Starts the render loop. The application can be terminated by pressing the ESCAPE key.
 */
private void start(){
  _logger.log(Level.INFO,"String_Node_Str");
  _lastLoopTime=Helper.getInstance().getTime();
  while (_runGame) {
    Display.sync(120);
    long delta=Helper.getInstance().getTime() - _lastLoopTime;
    _lastLoopTime=Helper.getInstance().getTime();
    _lastFpsTime+=delta;
    _fps++;
    if (_lastFpsTime >= 1000) {
      _lastFpsTime=0;
      _meanFps+=_fps;
      _meanFps/=2;
      _fps=0;
    }
    processKeyboardInput();
    processMouseInput();
    if (!_showDebugConsole) {
      update(delta);
    }
    render();
    Display.update();
  }
  Display.destroy();
}

Fixed version (ground truth):
/** 
 * Starts the render loop. The application can be terminated by pressing the ESCAPE key.
 */
private void start(){
  _logger.log(Level.INFO,"String_Node_Str");
  _lastLoopTime=Helper.getInstance().getTime();
  while (_runGame) {
    Display.sync(60);
    long delta=Helper.getInstance().getTime() - _lastLoopTime;
    _lastLoopTime=Helper.getInstance().getTime();
    _lastFpsTime+=delta;
    _fps++;
    if (_lastFpsTime >= 1000) {
      _lastFpsTime=0;
      _meanFps+=_fps;
      _meanFps/=2;
      _fps=0;
    }
    processKeyboardInput();
    processMouseInput();
    if (!_showDebugConsole) {
      update(delta);
    }
    render();
    Display.update();
  }
  Display.destroy();
}
Program: 1302
Project: 1302
Buggy source:
/** 
 * Populates the chunk (e.g. placement of trees etc.). TODO: Much to simple and boring
 */
public void populate(){
  for (int y=0; y < Configuration.CHUNK_DIMENSIONS.y; y++) {
    for (int x=0; x < Configuration.CHUNK_DIMENSIONS.x; x++) {
      for (int z=0; z < Configuration.CHUNK_DIMENSIONS.z; z++) {
        float dens=calcForestDensity(getBlockWorldPosX(x),getBlockWorldPosY(y),getBlockWorldPosZ(z));
        if (dens > 0.25 && dens < 0.6f && getBlock(x,y,z) == 0x1 && y > 32) {
          _parent.generateTree(getBlockWorldPosX(x),getBlockWorldPosY((int)y) + 1,getBlockWorldPosZ(z),false);
          return;
        }
 else         if (dens >= 0.6f && getBlock(x,y,z) == 0x1 && y > 32) {
          _parent.generatePineTree(getBlockWorldPosX(x),getBlockWorldPosY((int)y) + 1,getBlockWorldPosZ(z),false);
          return;
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Populates the chunk (e.g. placement of trees etc.). TODO: Much to simple and boring :-(
 */
public void populate(){
  for (int y=0; y < Configuration.CHUNK_DIMENSIONS.y; y++) {
    for (int x=0; x < Configuration.CHUNK_DIMENSIONS.x; x++) {
      for (int z=0; z < Configuration.CHUNK_DIMENSIONS.z; z++) {
        float dens=calcForestDensity(getBlockWorldPosX(x),getBlockWorldPosY(y),getBlockWorldPosZ(z));
        if (dens > 0.25 && dens < 0.6f && getBlock(x,y,z) == 0x1 && y > 32) {
          _parent.generateTree(getBlockWorldPosX(x),getBlockWorldPosY((int)y) + 1,getBlockWorldPosZ(z),false);
          return;
        }
 else         if (dens >= 0.6f && getBlock(x,y,z) == 0x1 && y > 32) {
          _parent.generatePineTree(getBlockWorldPosX(x),getBlockWorldPosY((int)y) + 1,getBlockWorldPosZ(z),false);
          return;
        }
      }
    }
  }
}
Program: 1303
Project: 1303
Buggy source:
/** 
 * Calculates a intersection with the face of a block defined by 3 points.
 * @param blockPos The position of the block to intersect with
 * @param v0 Point 1
 * @param v1 Point 2
 * @param v2 Point 3
 * @param origin Origin of the intersection ray
 * @param ray Direction of the intersection ray
 * @return Ray-face-intersection
 */
private RayFaceIntersection rayFaceIntersection(Vector3f blockPos,Vector3f v0,Vector3f v1,Vector3f v2,Vector3f origin,Vector3f ray){
  Vector3f a=Vector3f.sub(v1,v0,null);
  Vector3f b=Vector3f.sub(v2,v0,null);
  Vector3f norm=Vector3f.cross(a,b,null);
  float d=-(norm.x * v0.x + norm.y * v0.y + norm.z * v0.z);
  float t=-(norm.x * origin.x + norm.y * origin.y + norm.z * origin.z + d) / (Vector3f.dot(ray,norm));
  Vector3f intersectPoint=new Vector3f(ray.x * t,ray.y * t,ray.z * t);
  Vector3f.add(intersectPoint,origin,intersectPoint);
  if (intersectPoint.x >= v0.x && intersectPoint.x <= v2.x && intersectPoint.y >= v0.y && intersectPoint.y <= v2.y && intersectPoint.z >= v0.z && intersectPoint.z <= v2.z) {
    return new RayFaceIntersection(blockPos,v0,v1,v2,d,t,origin,ray,intersectPoint);
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Calculates a intersection with the face of a block defined by 3 points.
 * @param blockPos The position of the block to intersect with
 * @param v0 Point 1
 * @param v1 Point 2
 * @param v2 Point 3
 * @param origin Origin of the intersection ray
 * @param ray Direction of the intersection ray
 * @return Ray-face-intersection
 */
private RayFaceIntersection rayFaceIntersection(Vector3f blockPos,Vector3f v0,Vector3f v1,Vector3f v2,Vector3f origin,Vector3f ray){
  Vector3f a=Vector3f.sub(v1,v0,null);
  Vector3f b=Vector3f.sub(v2,v0,null);
  Vector3f norm=Vector3f.cross(a,b,null);
  float d=-(norm.x * v0.x + norm.y * v0.y + norm.z * v0.z);
  float t=-(norm.x * origin.x + norm.y * origin.y + norm.z * origin.z + d) / (Vector3f.dot(ray,norm));
  if (t < 0) {
    return null;
  }
  Vector3f intersectPoint=new Vector3f(ray.x * t,ray.y * t,ray.z * t);
  Vector3f.add(intersectPoint,origin,intersectPoint);
  if (intersectPoint.x >= v0.x && intersectPoint.x <= v2.x && intersectPoint.y >= v0.y && intersectPoint.y <= v2.y && intersectPoint.z >= v0.z && intersectPoint.z <= v2.z) {
    return new RayFaceIntersection(blockPos,v0,v1,v2,d,t,origin,ray,intersectPoint);
  }
  return null;
}
Program: 1304
Project: 1304
Buggy source:
/** 
 * Updates the daytime of the world. A day in Blockmania has 12 minutes.
 */
private void updateDaytime(){
  if (Helper.getInstance().getTime() - lastDaytimeMeasurement >= 30000) {
    _daytime=(short)((_daytime + 1) % 24);
    lastDaytimeMeasurement=Helper.getInstance().getTime();
    Logger.getLogger(World.class.getName()).log(Level.INFO,"String_Node_Str",_daytime);
    byte oldDaylight=_daylight;
switch (_daytime) {
case 18:
      _daylight=(byte)(0.8f * Configuration.MAX_LIGHT);
    break;
case 20:
  _daylight=(byte)(0.6f * Configuration.MAX_LIGHT);
break;
case 21:
_daylight=(byte)(0.4f * Configuration.MAX_LIGHT);
break;
case 22:
_daylight=(byte)(0.3f * Configuration.MAX_LIGHT);
break;
case 23:
_daylight=(byte)(0.2f * Configuration.MAX_LIGHT);
break;
case 5:
_daylight=(byte)(0.3f * Configuration.MAX_LIGHT);
break;
case 6:
_daylight=(byte)(0.6f * Configuration.MAX_LIGHT);
break;
case 7:
_daylight=(byte)(0.8f * Configuration.MAX_LIGHT);
break;
case 8:
_daylight=Configuration.MAX_LIGHT;
break;
}
if (_daylight != oldDaylight) {
synchronized (_chunkCache) {
for (int key : _chunkCache.keySet()) {
_chunkCache.get(key)._dirty=true;
}
}
for (int x=0; x < Configuration.VIEWING_DISTANCE_IN_CHUNKS.x; x++) {
for (int z=0; z < Configuration.VIEWING_DISTANCE_IN_CHUNKS.z; z++) {
Chunk c=_chunks[x][0][z];
queueChunkForUpdate(c,0);
}
}
}
}
}

Fixed version (ground truth):
/** 
 * Updates the daytime of the world. A day in Blockmania has 12 minutes.
 */
private void updateDaytime(){
  if (Helper.getInstance().getTime() - lastDaytimeMeasurement >= 30000) {
    _daytime=(short)((_daytime + 1) % 24);
    lastDaytimeMeasurement=Helper.getInstance().getTime();
    Logger.getLogger(World.class.getName()).log(Level.INFO,"String_Node_Str",_daytime);
    byte oldDaylight=_daylight;
switch (_daytime) {
case 18:
      _daylight=(byte)(0.8f * Configuration.MAX_LIGHT);
    break;
case 20:
  _daylight=(byte)(0.6f * Configuration.MAX_LIGHT);
break;
case 21:
_daylight=(byte)(0.4f * Configuration.MAX_LIGHT);
break;
case 22:
_daylight=(byte)(0.3f * Configuration.MAX_LIGHT);
break;
case 23:
_daylight=(byte)(0.2f * Configuration.MAX_LIGHT);
break;
case 5:
_daylight=(byte)(0.3f * Configuration.MAX_LIGHT);
break;
case 6:
_daylight=(byte)(0.6f * Configuration.MAX_LIGHT);
break;
case 7:
_daylight=(byte)(0.8f * Configuration.MAX_LIGHT);
break;
case 8:
_daylight=Configuration.MAX_LIGHT;
break;
}
if (_daylight != oldDaylight) {
for (int key : _chunkCache.keySet()) {
_chunkCache.get(key)._dirty=true;
}
for (int x=0; x < Configuration.VIEWING_DISTANCE_IN_CHUNKS.x; x++) {
for (int z=0; z < Configuration.VIEWING_DISTANCE_IN_CHUNKS.z; z++) {
Chunk c=_chunks[x][0][z];
queueChunkForUpdate(c,0);
}
}
}
}
}
Program: 1307
Project: 1307
Buggy source:
/** 
 * Tries to load a chunk from the cache. Returns null if no chunk is found.
 * @param x X-coordinate
 * @param z Z-coordinate
 * @return The loaded chunk
 */
private Chunk loadChunk(int x,int z){
synchronized (_chunkCache) {
    Chunk c=_chunkCache.get(Helper.getInstance().cantorize(x,z));
    return c;
  }
}

Fixed version (ground truth):
/** 
 * Tries to load a chunk from the cache. Returns null if no chunk is found.
 * @param x X-coordinate
 * @param z Z-coordinate
 * @return The loaded chunk
 */
private synchronized Chunk loadChunk(int x,int z){
  Chunk c=_chunkCache.get(Helper.getInstance().cantorize(x,z));
  return c;
}
Program: 1308
Project: 1308
Buggy source:
private void queueChunkForUpdate(Chunk c,int prio){
  ArrayBlockingQueue queue=null;
  if (prio > 0) {
    queue=_chunkUpdateImportant;
  }
 else {
    queue=_chunkUpdateNormal;
  }
  queue.add(c);
}

Fixed version (ground truth):
private void queueChunkForUpdate(Chunk c,int prio){
  LinkedBlockingQueue queue=null;
  if (prio > 0) {
    queue=_chunkUpdateImportant;
  }
 else {
    queue=_chunkUpdateNormal;
  }
  queue.add(c);
}
Program: 1309
Project: 1309
Buggy source:
/** 
 * Returns the detail level for the base terrain.
 */
protected float calcTerrainDetail(float x,float z){
  float result=0.0f;
  result+=_pGen2.noiseNoiseWithOctaves(0.02f * x,0.02f,0.02f * z,4);
  return result;
}

Fixed version (ground truth):
/** 
 * Returns the detail level for the base terrain.
 */
protected float calcTerrainDetail(float x,float z){
  float result=0.0f;
  result+=_pGen3.noiseNoiseWithOctaves(0.02f * x,0.02f,0.02f * z,12);
  return result;
}
Program: 1310
Project: 1310
Buggy source:
/** 
 * Returns the base elevation for the terrain.
 */
protected float calcTerrainElevation(float x,float z){
  float result=0.0f;
  result+=_pGen1.noiseNoiseWithOctaves(0.003f * x,0.003f,0.003f * z,4) * 128f;
  return Math.abs(result);
}

Fixed version (ground truth):
/** 
 * Returns the base elevation for the terrain.
 */
protected float calcTerrainElevation(float x,float z){
  float result=0.0f;
  result+=_pGen1.noiseNoiseWithOctaves(0.003f * x,0.003f,0.003f * z,16) * 128f;
  return result;
}
Program: 1312
Project: 1312
Buggy source:
/** 
 * Returns the roughness for the base terrain.
 */
protected float calcTerrainRoughness(float x,float z){
  float result=0.0f;
  result+=_pGen1.noiseNoiseWithOctaves(0.04f * x,0.04f,0.04f * z,8);
  return result;
}

Fixed version (ground truth):
/** 
 * Returns the roughness for the base terrain.
 */
protected float calcTerrainRoughness(float x,float z){
  float result=0.0f;
  result+=_pGen2.noiseNoiseWithOctaves(0.01f * x,0.01f,0.01f * z,16);
  return result;
}
Program: 1313
Project: 1313
Buggy source:
public boolean dimBlockAtLocalPos(int x,int y,int z){
  if (_parent.getBlock(getBlockWorldPosX(x + 1),getBlockWorldPosY(y),getBlockWorldPosZ(z)) > 0 || _parent.getBlock(getBlockWorldPosX(x - 1),getBlockWorldPosY(y),getBlockWorldPosZ(z)) > 0 || _parent.getBlock(getBlockWorldPosX(x),getBlockWorldPosY(y),getBlockWorldPosZ(z + 1)) > 0 || _parent.getBlock(getBlockWorldPosX(x),getBlockWorldPosY(y),getBlockWorldPosZ(z - 1)) > 0) {
    return true;
  }
  return false;
}

Fixed version (ground truth):
public boolean dimBlockAtLocalPos(int x,int y,int z){
  if (_parent.getBlock(getBlockWorldPosX(x + 1),getBlockWorldPosY(y),getBlockWorldPosZ(z)) > 0 || _parent.getBlock(getBlockWorldPosX(x - 1),getBlockWorldPosY(y),getBlockWorldPosZ(z)) > 0 || _parent.getBlock(getBlockWorldPosX(x),getBlockWorldPosY(y),getBlockWorldPosZ(z + 1)) > 0 || _parent.getBlock(getBlockWorldPosX(x),getBlockWorldPosY(y),getBlockWorldPosZ(z - 1)) > 0) {
    if (_parent.getBlock(getBlockWorldPosX(x + 1),getBlockWorldPosY(y),getBlockWorldPosZ(z + 1)) > 0 || _parent.getBlock(getBlockWorldPosX(x - 1),getBlockWorldPosY(y),getBlockWorldPosZ(z + 1)) > 0 || _parent.getBlock(getBlockWorldPosX(x + 1),getBlockWorldPosY(y),getBlockWorldPosZ(z - 1)) > 0 || _parent.getBlock(getBlockWorldPosX(x - 1),getBlockWorldPosY(y),getBlockWorldPosZ(z - 1)) > 0) {
      return true;
    }
  }
  return false;
}
Program: 1314
Project: 1314
Buggy source:
/** 
 * Draws the chunk.
 */
@Override public void render(){
  if (Configuration._showChunkOutlines) {
    glPushMatrix();
    glTranslatef(_position.x * (int)CHUNK_DIMENSIONS.x,_position.y * (int)CHUNK_DIMENSIONS.y,_position.z * (int)CHUNK_DIMENSIONS.z);
    glColor3f(255.0f,0.0f,0.0f);
    glBegin(GL_LINE_LOOP);
    glVertex3f(0.0f,0.0f,0.0f);
    glVertex3f(CHUNK_DIMENSIONS.x,0.0f,0.0f);
    glVertex3f(CHUNK_DIMENSIONS.x,CHUNK_DIMENSIONS.y,0.0f);
    glVertex3f(0.0f,CHUNK_DIMENSIONS.y,0.0f);
    glEnd();
    glBegin(GL_LINE_LOOP);
    glVertex3f(0.0f,0.0f,0.0f);
    glVertex3f(0.0f,0.0f,CHUNK_DIMENSIONS.z);
    glVertex3f(0.0f,CHUNK_DIMENSIONS.y,CHUNK_DIMENSIONS.z);
    glVertex3f(0.0f,CHUNK_DIMENSIONS.y,0.0f);
    glVertex3f(0.0f,0.0f,0.0f);
    glEnd();
    glBegin(GL_LINE_LOOP);
    glVertex3f(0.0f,0.0f,CHUNK_DIMENSIONS.z);
    glVertex3f(CHUNK_DIMENSIONS.x,0.0f,CHUNK_DIMENSIONS.z);
    glVertex3f(CHUNK_DIMENSIONS.x,CHUNK_DIMENSIONS.y,CHUNK_DIMENSIONS.z);
    glVertex3f(0.0f,CHUNK_DIMENSIONS.y,CHUNK_DIMENSIONS.z);
    glVertex3f(0.0f,0.0f,CHUNK_DIMENSIONS.z);
    glEnd();
    glBegin(GL_LINE_LOOP);
    glVertex3f(CHUNK_DIMENSIONS.x,0.0f,0.0f);
    glVertex3f(CHUNK_DIMENSIONS.x,0.0f,CHUNK_DIMENSIONS.z);
    glVertex3f(CHUNK_DIMENSIONS.x,CHUNK_DIMENSIONS.y,CHUNK_DIMENSIONS.z);
    glVertex3f(CHUNK_DIMENSIONS.x,CHUNK_DIMENSIONS.y,0.0f);
    glVertex3f(CHUNK_DIMENSIONS.x,0.0f,0.0f);
    glEnd();
    glPopMatrix();
  }
  glEnable(GL_TEXTURE_2D);
  glCallList(_displayList);
  glDisable(GL_TEXTURE_2D);
}

Fixed version (ground truth):
/** 
 * Draws the chunk.
 */
@Override public void render(){
  if (Configuration._showChunkOutlines) {
    glPushMatrix();
    glTranslatef(_position.x * (int)CHUNK_DIMENSIONS.x,_position.y * (int)CHUNK_DIMENSIONS.y,_position.z * (int)CHUNK_DIMENSIONS.z);
    glColor3f(255.0f,0.0f,0.0f);
    glBegin(GL_LINE_LOOP);
    glVertex3f(0.0f,0.0f,0.0f);
    glVertex3f(CHUNK_DIMENSIONS.x,0.0f,0.0f);
    glVertex3f(CHUNK_DIMENSIONS.x,CHUNK_DIMENSIONS.y,0.0f);
    glVertex3f(0.0f,CHUNK_DIMENSIONS.y,0.0f);
    glEnd();
    glBegin(GL_LINE_LOOP);
    glVertex3f(0.0f,0.0f,0.0f);
    glVertex3f(0.0f,0.0f,CHUNK_DIMENSIONS.z);
    glVertex3f(0.0f,CHUNK_DIMENSIONS.y,CHUNK_DIMENSIONS.z);
    glVertex3f(0.0f,CHUNK_DIMENSIONS.y,0.0f);
    glVertex3f(0.0f,0.0f,0.0f);
    glEnd();
    glBegin(GL_LINE_LOOP);
    glVertex3f(0.0f,0.0f,CHUNK_DIMENSIONS.z);
    glVertex3f(CHUNK_DIMENSIONS.x,0.0f,CHUNK_DIMENSIONS.z);
    glVertex3f(CHUNK_DIMENSIONS.x,CHUNK_DIMENSIONS.y,CHUNK_DIMENSIONS.z);
    glVertex3f(0.0f,CHUNK_DIMENSIONS.y,CHUNK_DIMENSIONS.z);
    glVertex3f(0.0f,0.0f,CHUNK_DIMENSIONS.z);
    glEnd();
    glBegin(GL_LINE_LOOP);
    glVertex3f(CHUNK_DIMENSIONS.x,0.0f,0.0f);
    glVertex3f(CHUNK_DIMENSIONS.x,0.0f,CHUNK_DIMENSIONS.z);
    glVertex3f(CHUNK_DIMENSIONS.x,CHUNK_DIMENSIONS.y,CHUNK_DIMENSIONS.z);
    glVertex3f(CHUNK_DIMENSIONS.x,CHUNK_DIMENSIONS.y,0.0f);
    glVertex3f(CHUNK_DIMENSIONS.x,0.0f,0.0f);
    glEnd();
    glPopMatrix();
  }
  _textureMap.bind();
  glEnable(GL_TEXTURE_2D);
  glCallList(_displayList);
  glDisable(GL_TEXTURE_2D);
}