コード例 #1
0
 public boolean convertMapFormat(String s, IProgressUpdate iprogressupdate) {
   iprogressupdate.setLoadingProgress(0);
   ArrayList arraylist = new ArrayList();
   ArrayList arraylist1 = new ArrayList();
   ArrayList arraylist2 = new ArrayList();
   ArrayList arraylist3 = new ArrayList();
   File file = new File(field_22180_a, s);
   File file1 = new File(file, "DIM-1");
   System.out.println("Scanning folders...");
   func_22183_a(file, arraylist, arraylist1);
   if (file1.exists()) {
     func_22183_a(file1, arraylist2, arraylist3);
   }
   int i = arraylist.size() + arraylist2.size() + arraylist1.size() + arraylist3.size();
   System.out.println(
       (new StringBuilder()).append("Total conversion count is ").append(i).toString());
   func_22181_a(file, arraylist, 0, i, iprogressupdate);
   func_22181_a(file1, arraylist2, arraylist.size(), i, iprogressupdate);
   WorldInfo worldinfo = func_22173_b(s);
   worldinfo.setSaveVersion(19132);
   ISaveHandler isavehandler = getSaveLoader(s, false);
   isavehandler.saveWorldInfo(worldinfo);
   func_22182_a(arraylist1, arraylist.size() + arraylist2.size(), i, iprogressupdate);
   if (file1.exists()) {
     func_22182_a(
         arraylist3, arraylist.size() + arraylist2.size() + arraylist1.size(), i, iprogressupdate);
   }
   return true;
 }
コード例 #2
0
  private void func_22181_a(
      File file, ArrayList arraylist, int i, int j, IProgressUpdate iprogressupdate) {
    Collections.sort(arraylist);
    byte abyte0[] = new byte[4096];
    int i1;
    for (Iterator iterator = arraylist.iterator();
        iterator.hasNext();
        iprogressupdate.setLoadingProgress(i1)) {
      ChunkFile chunkfile = (ChunkFile) iterator.next();
      int k = chunkfile.func_22323_b();
      int l = chunkfile.func_22321_c();
      RegionFile regionfile = RegionFileCache.func_22193_a(file, k, l);
      if (!regionfile.func_22202_c(k & 0x1f, l & 0x1f)) {
        try {
          DataInputStream datainputstream =
              new DataInputStream(
                  new GZIPInputStream(new FileInputStream(chunkfile.func_22324_a())));
          DataOutputStream dataoutputstream =
              regionfile.getChunkDataOutputStream(k & 0x1f, l & 0x1f);
          for (int j1 = 0; (j1 = datainputstream.read(abyte0)) != -1; ) {
            dataoutputstream.write(abyte0, 0, j1);
          }

          dataoutputstream.close();
          datainputstream.close();
        } catch (IOException ioexception) {
          ioexception.printStackTrace();
        }
      }
      i++;
      i1 = (int) Math.round((100D * (double) i) / (double) j);
    }

    RegionFileCache.func_22192_a();
  }
コード例 #3
0
 private void func_22182_a(ArrayList arraylist, int i, int j, IProgressUpdate iprogressupdate) {
   int k;
   for (Iterator iterator = arraylist.iterator();
       iterator.hasNext();
       iprogressupdate.setLoadingProgress(k)) {
     File file = (File) iterator.next();
     File afile[] = file.listFiles();
     func_22179_a(afile);
     file.delete();
     i++;
     k = (int) Math.round((100D * (double) i) / (double) j);
   }
 }
コード例 #4
0
  private void convertFile(
      File par1File,
      Iterable par2Iterable,
      WorldChunkManager par3WorldChunkManager,
      int par4,
      int par5,
      IProgressUpdate par6IProgressUpdate) {
    int i;

    for (Iterator iterator = par2Iterable.iterator();
        iterator.hasNext();
        par6IProgressUpdate.setLoadingProgress(i)) {
      File file = (File) iterator.next();
      convertChunks(par1File, file, par3WorldChunkManager, par4, par5, par6IProgressUpdate);
      par4++;
      i = (int) Math.round((100D * (double) par4) / (double) par5);
    }
  }
コード例 #5
0
  /** Converts the specified map to the new map format. Args: worldName, loadingScreen */
  public boolean convertMapFormat(String par1Str, IProgressUpdate par2IProgressUpdate) {
    par2IProgressUpdate.setLoadingProgress(0);
    ArrayList arraylist = new ArrayList();
    ArrayList arraylist1 = new ArrayList();
    ArrayList arraylist2 = new ArrayList();
    File file = new File(savesDirectory, par1Str);
    File file1 = new File(file, "DIM-1");
    File file2 = new File(file, "DIM1");
    System.out.println("Scanning folders...");
    addRegionFilesToCollection(file, arraylist);

    if (file1.exists()) {
      addRegionFilesToCollection(file1, arraylist1);
    }

    if (file2.exists()) {
      addRegionFilesToCollection(file2, arraylist2);
    }

    int i = arraylist.size() + arraylist1.size() + arraylist2.size();
    System.out.println(
        (new StringBuilder()).append("Total conversion count is ").append(i).toString());
    WorldInfo worldinfo = getWorldInfo(par1Str);
    Object obj = null;

    if (worldinfo.getTerrainType() == WorldType.FLAT) {
      obj = new WorldChunkManagerHell(BiomeGenBase.plains, 0.5F, 0.5F);
    } else {
      obj = new WorldChunkManager(worldinfo.getSeed(), worldinfo.getTerrainType());
    }

    convertFile(
        new File(file, "region"),
        arraylist,
        ((WorldChunkManager) (obj)),
        0,
        i,
        par2IProgressUpdate);
    convertFile(
        new File(file1, "region"),
        arraylist1,
        new WorldChunkManagerHell(BiomeGenBase.hell, 1.0F, 0.0F),
        arraylist.size(),
        i,
        par2IProgressUpdate);
    convertFile(
        new File(file2, "region"),
        arraylist2,
        new WorldChunkManagerHell(BiomeGenBase.sky, 0.5F, 0.0F),
        arraylist.size() + arraylist1.size(),
        i,
        par2IProgressUpdate);
    worldinfo.setSaveVersion(19133);

    if (worldinfo.getTerrainType() == WorldType.DEFAULT_1_1) {
      worldinfo.setTerrainType(WorldType.DEFAULT);
    }

    createFile(par1Str);
    ISaveHandler isavehandler = getSaveLoader(par1Str, false);
    isavehandler.saveWorldInfo(worldinfo);
    return true;
  }
コード例 #6
0
  /** copies a 32x32 chunk set from par2File to par1File, via AnvilConverterData */
  private void convertChunks(
      File par1File,
      File par2File,
      WorldChunkManager par3WorldChunkManager,
      int par4,
      int par5,
      IProgressUpdate par6IProgressUpdate) {
    try {
      String s = par2File.getName();
      RegionFile regionfile = new RegionFile(par2File);
      RegionFile regionfile1 =
          new RegionFile(
              new File(
                  par1File,
                  (new StringBuilder())
                      .append(s.substring(0, s.length() - ".mcr".length()))
                      .append(".mca")
                      .toString()));

      for (int i = 0; i < 32; i++) {
        for (int j = 0; j < 32; j++) {
          if (!regionfile.isChunkSaved(i, j) || regionfile1.isChunkSaved(i, j)) {
            continue;
          }

          DataInputStream datainputstream = regionfile.getChunkDataInputStream(i, j);

          if (datainputstream == null) {
            System.out.println("Failed to fetch input stream");
          } else {
            NBTTagCompound nbttagcompound = CompressedStreamTools.read(datainputstream);
            datainputstream.close();
            NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("Level");
            AnvilConverterData anvilconverterdata = ChunkLoader.load(nbttagcompound1);
            NBTTagCompound nbttagcompound2 = new NBTTagCompound();
            NBTTagCompound nbttagcompound3 = new NBTTagCompound();
            nbttagcompound2.setTag("Level", nbttagcompound3);
            ChunkLoader.convertToAnvilFormat(
                anvilconverterdata, nbttagcompound3, par3WorldChunkManager);
            DataOutputStream dataoutputstream = regionfile1.getChunkDataOutputStream(i, j);
            CompressedStreamTools.write(nbttagcompound2, dataoutputstream);
            dataoutputstream.close();
          }
        }

        int k = (int) Math.round((100D * (double) (par4 * 1024)) / (double) (par5 * 1024));
        int l =
            (int)
                Math.round((100D * (double) ((i + 1) * 32 + par4 * 1024)) / (double) (par5 * 1024));

        if (l > k) {
          par6IProgressUpdate.setLoadingProgress(l);
        }
      }

      regionfile.close();
      regionfile1.close();
    } catch (IOException ioexception) {
      ioexception.printStackTrace();
    }
  }