Program: 12709
Project: 12709
Buggy source:
/** 
 * Should be called for every biome. Generates and optimizes positions if they was not generated before. Also (pre) generates the castle stuff when the given chunk is within a position
 * @param world
 * @param chunkX
 * @param chunkZ
 * @param rnd
 * @param castleWorld Whether it is the castle dimension or the overworld
 */
public void checkBiome(World world,int chunkX,int chunkZ,Random rnd,boolean castleWorld){
  CastlePositionData data=CastlePositionData.get(world);
  if (!data.checked) {
    if (castleWorld) {
      CastlePositionData.Position p=new CastlePositionData.Position(0,0);
      p.setSize(6,6);
      p.setDraculasDim();
      p.setHeight(ChunkProviderCastle.MAX_Y_HEIGHT + 1);
      data.positions.add(p);
    }
 else {
      data.positions.addAll(this.findPositions(world,rnd));
      if (data.positions.size() > 0) {
        ListIterator<CastlePositionData.Position> iterator=data.positions.listIterator();
        while (iterator.hasNext()) {
          CastlePositionData.Position pos=iterator.next();
          CastlePositionData.Position pos2=this.optimizePosition(pos,world,rnd);
          if (pos2 == null) {
            Logger.d(TAG,"String_Node_Str",pos);
            iterator.remove();
          }
 else           if (!pos2.equals(pos)) {
            pos=pos2;
            iterator.set(pos2);
          }
        }
      }
      if (data.positions.size() == 0) {
        Logger.w(TAG,"String_Node_Str");
        if (world.provider.dimensionId == 0) {
          VampirismMod.vampireCastleFail=true;
        }
      }
    }
    data.checked=true;
    data.markDirty();
  }
  if (data.positions.size() == 0 && data.fullyGeneratedPositions.size() == 0) {
    if (world.getBiomeGenForCoords((chunkX << 4) + 8,(chunkZ << 4) + 8) instanceof BiomeVampireForest) {
      CastlePositionData.Position pos=new CastlePositionData.Position(chunkX,chunkZ);
      pos=this.optimizePosition(pos,world,rnd);
      if (pos != null) {
        data.positions.add(pos);
        data.markDirty();
        VampirismMod.vampireCastleFail=false;
        Logger.i(TAG,"String_Node_Str");
      }
    }
  }
  if (data.positions.size() > 0) {
    for (    CastlePositionData.Position p : data.positions) {
      if (p.isChunkInPosition(chunkX,chunkZ)) {
        if (!p.hasTiles()) {
          preGeneratePosition(p,world);
          data.markDirty();
        }
        String s=p.getTileAt(chunkX - p.chunkXPos,chunkZ - p.chunkZPos);
        String[] param=s.split("String_Node_Str");
        int height=p.getHeight();
        if (height == -1) {
          height=getAverageHeight(world.getChunkFromChunkCoords(chunkX,chunkZ));
          p.setHeight(height);
        }
        for (int i=(chunkX << 4); i < (chunkX << 4) + 16; i++) {
          for (int j=(chunkZ << 4); j < (chunkZ << 4) + 16; j++) {
            for (int k=height; k < height + 20; k++) {
              world.setBlockToAir(i,k,j);
            }
          }
        }
        for (int i=(chunkX << 4); i < (chunkX << 4) + 16; i++) {
          for (int j=(chunkZ << 4); j < (chunkZ << 4) + 16; j++) {
            for (int k=height - 1; k > height - 10; k--) {
              world.setBlock(i,k,j,ModBlocks.cursedEarth);
            }
          }
        }
        for (int i=0; i < param.length; i+=2) {
          int rotation=Integer.parseInt(param[i]);
          BuildingTile tile=tileMap.get(param[i + 1]);
          if (tile != null) {
            tile.build(chunkX,chunkZ,world,height,rotation);
          }
        }
        p.markGenerated(chunkX,chunkZ);
        data.markDirty();
        break;
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Should be called for every biome. Generates and optimizes positions if they was not generated before. Also (pre) generates the castle stuff when the given chunk is within a position
 * @param world
 * @param chunkX
 * @param chunkZ
 * @param rnd
 * @param castleWorld Whether it is the castle dimension or the overworld
 */
public void checkBiome(World world,int chunkX,int chunkZ,Random rnd,boolean castleWorld){
  CastlePositionData data=CastlePositionData.get(world);
  if (!data.checked) {
    if (castleWorld) {
      CastlePositionData.Position p=new CastlePositionData.Position(0,0);
      p.setSize(6,6);
      p.setDraculasDim();
      p.setHeight(ChunkProviderCastle.MAX_Y_HEIGHT + 1);
      data.positions.add(p);
    }
 else {
      data.positions.addAll(this.findPositions(world,rnd));
      if (data.positions.size() > 0) {
        ListIterator<CastlePositionData.Position> iterator=data.positions.listIterator();
        while (iterator.hasNext()) {
          CastlePositionData.Position pos=iterator.next();
          CastlePositionData.Position pos2=this.optimizePosition(pos,world,rnd);
          if (pos2 == null) {
            Logger.d(TAG,"String_Node_Str",pos);
            iterator.remove();
          }
 else           if (!pos2.equals(pos)) {
            pos=pos2;
            iterator.set(pos2);
          }
        }
      }
      if (data.positions.size() == 0) {
        Logger.w(TAG,"String_Node_Str");
        if (world.provider.dimensionId == 0) {
          VampirismMod.vampireCastleFail=true;
        }
      }
    }
    data.checked=true;
    data.markDirty();
  }
  if (data.positions.size() == 0 && data.fullyGeneratedPositions.size() == 0) {
    if (world.getBiomeGenForCoords((chunkX << 4) + 8,(chunkZ << 4) + 8) instanceof BiomeVampireForest) {
      CastlePositionData.Position pos=new CastlePositionData.Position(chunkX,chunkZ);
      pos=this.optimizePosition(pos,world,rnd);
      if (pos != null) {
        data.positions.add(pos);
        data.markDirty();
        VampirismMod.vampireCastleFail=false;
        Logger.i(TAG,"String_Node_Str");
      }
    }
  }
  if (data.positions.size() > 0) {
    for (    CastlePositionData.Position p : data.positions) {
      if (p.isChunkInPosition(chunkX,chunkZ)) {
        if (!p.hasTiles()) {
          preGeneratePosition(p,world);
          data.markDirty();
        }
        String s=p.getTileAt(chunkX - p.chunkXPos,chunkZ - p.chunkZPos);
        String[] param=s.split("String_Node_Str");
        int height=p.getHeight();
        if (height == -1) {
          height=getAverageHeight(world.getChunkFromChunkCoords(chunkX,chunkZ));
          p.setHeight(height);
        }
        for (int i=(chunkX << 4); i < (chunkX << 4) + 16; i++) {
          for (int j=(chunkZ << 4); j < (chunkZ << 4) + 16; j++) {
            for (int k=height; k < height + 20; k++) {
              world.setBlockToAir(i,k,j);
            }
          }
        }
        for (int i=(chunkX << 4); i < (chunkX << 4) + 16; i++) {
          for (int j=(chunkZ << 4); j < (chunkZ << 4) + 16; j++) {
            for (int k=height - 1; k > height - 10; k--) {
              world.setBlock(i,k,j,ModBlocks.cursedEarth);
            }
          }
        }
        for (int i=0; i < param.length; i+=2) {
          int rotation=Integer.parseInt(param[i]);
          BuildingTile tile=tileMap.get(param[i + 1]);
          if (tile != null) {
            tile.build(chunkX,chunkZ,world,height,rotation);
          }
 else {
            Logger.w(TAG,"String_Node_Str",param[i + 1]);
          }
        }
        p.markGenerated(chunkX,chunkZ);
        data.markDirty();
        break;
      }
    }
  }
}