Exemple #1
0
  /** gets the world info */
  public WorldInfo getWorldInfo(String par1Str) {
    File var2 = new File(this.savesDirectory, par1Str);

    if (!var2.exists()) {
      return null;
    } else {
      File var3 = new File(var2, "level.dat");
      NBTTagCompound var4;
      NBTTagCompound var5;

      if (var3.exists()) {
        try {
          var4 = CompressedStreamTools.readCompressed(new FileInputStream(var3));
          var5 = var4.getCompoundTag("Data");
          return new WorldInfo(var5);
        } catch (Exception var7) {
          var7.printStackTrace();
        }
      }

      var3 = new File(var2, "level.dat_old");

      if (var3.exists()) {
        try {
          var4 = CompressedStreamTools.readCompressed(new FileInputStream(var3));
          var5 = var4.getCompoundTag("Data");
          return new WorldInfo(var5);
        } catch (Exception var6) {
          var6.printStackTrace();
        }
      }

      return null;
    }
  }
Exemple #2
0
  /** Loads and returns the world info */
  public WorldInfo loadWorldInfo() {
    File var1 = new File(this.worldDirectory, "level.dat");
    NBTTagCompound var2;
    NBTTagCompound var3;
    WorldInfo worldInfo = null;
    if (var1.exists()) {
      try {
        var2 = CompressedStreamTools.readCompressed(new FileInputStream(var1));
        var3 = var2.getCompoundTag("Data");
        worldInfo = new WorldInfo(var3);
        FMLCommonHandler.instance().handleWorldDataLoad(this, worldInfo, var2);
        return worldInfo;
      } catch (Exception var5) {
        var5.printStackTrace();
      }
    }

    var1 = new File(this.worldDirectory, "level.dat_old");

    if (var1.exists()) {
      try {
        var2 = CompressedStreamTools.readCompressed(new FileInputStream(var1));
        var3 = var2.getCompoundTag("Data");
        worldInfo = new WorldInfo(var3);
        FMLCommonHandler.instance().handleWorldDataLoad(this, worldInfo, var2);
        return worldInfo;
      } catch (Exception var4) {
        var4.printStackTrace();
      }
    }

    return null;
  }
 public WorldInfo func_22173_b(String s) {
   File file = new File(field_22180_a, s);
   if (!file.exists()) {
     return null;
   }
   File file1 = new File(file, "level.dat");
   if (file1.exists()) {
     try {
       NBTTagCompound nbttagcompound =
           CompressedStreamTools.func_1138_a(new FileInputStream(file1));
       NBTTagCompound nbttagcompound2 = nbttagcompound.getCompoundTag("Data");
       return new WorldInfo(nbttagcompound2);
     } catch (Exception exception) {
       exception.printStackTrace();
     }
   }
   file1 = new File(file, "level.dat_old");
   if (file1.exists()) {
     try {
       NBTTagCompound nbttagcompound1 =
           CompressedStreamTools.func_1138_a(new FileInputStream(file1));
       NBTTagCompound nbttagcompound3 = nbttagcompound1.getCompoundTag("Data");
       return new WorldInfo(nbttagcompound3);
     } catch (Exception exception1) {
       exception1.printStackTrace();
     }
   }
   return null;
 }
Exemple #4
0
  public void importOldChunkTileEntities() {
    File file = wc.downloadSaveHandler.getSaveDirectory();
    if (wc.worldProvider instanceof WorldProviderHell) {
      file = new File(file, "DIM-1");
      file.mkdirs();
    }

    java.io.DataInputStream datainputstream =
        RegionFileCache.getChunkInputStream(file, xPosition, zPosition);
    NBTTagCompound nbttagcompound;
    if (datainputstream != null) {
      try {
        nbttagcompound = CompressedStreamTools.func_1141_a(datainputstream);
      } catch (IOException e) {
        return;
      }
    } else return;

    if (!nbttagcompound.hasKey("Level")) return;

    NBTTagList nbttaglist1 = nbttagcompound.getCompoundTag("Level").getTagList("TileEntities");
    if (nbttaglist1 != null) {
      for (int l = 0; l < nbttaglist1.tagCount(); l++) {
        NBTTagCompound nbttagcompound2 = (NBTTagCompound) nbttaglist1.tagAt(l);
        TileEntity te = TileEntity.createAndLoadEntity(nbttagcompound2);
        if (te != null) {
          ChunkPosition cp = new ChunkPosition(te.xCoord & 0xf, te.yCoord, te.zCoord & 0xf);
          newChunkTileEntityMap.put(cp, te);
        }
      }
    }
  }
Exemple #5
0
  /** Saves the passed in world info. */
  public void saveWorldInfo(WorldInfo par1WorldInfo) {
    NBTTagCompound var2 = par1WorldInfo.getNBTTagCompound();
    NBTTagCompound var3 = new NBTTagCompound();
    var3.setTag("Data", var2);
    FMLCommonHandler.instance().handleWorldDataSave(this, par1WorldInfo, var3);
    try {
      File var4 = new File(this.worldDirectory, "level.dat_new");
      File var5 = new File(this.worldDirectory, "level.dat_old");
      File var6 = new File(this.worldDirectory, "level.dat");
      CompressedStreamTools.writeCompressed(var3, new FileOutputStream(var4));

      if (var5.exists()) {
        var5.delete();
      }

      var6.renameTo(var5);

      if (var6.exists()) {
        var6.delete();
      }

      var4.renameTo(var6);

      if (var4.exists()) {
        var4.delete();
      }
    } catch (Exception var7) {
      var7.printStackTrace();
    }
  }
Exemple #6
0
  /** Saves the given World Info with the given NBTTagCompound as the Player. */
  public void saveWorldInfoWithPlayer(WorldInfo par1WorldInfo, NBTTagCompound par2NBTTagCompound) {
    NBTTagCompound var3 = par1WorldInfo.cloneNBTCompound(par2NBTTagCompound);
    NBTTagCompound var4 = new NBTTagCompound();
    var4.setTag("Data", var3);
    FMLCommonHandler.instance().handleWorldDataSave(this, par1WorldInfo, var4);
    try {
      File var5 = new File(this.worldDirectory, "level.dat_new");
      File var6 = new File(this.worldDirectory, "level.dat_old");
      File var7 = new File(this.worldDirectory, "level.dat");
      CompressedStreamTools.writeCompressed(var4, new FileOutputStream(var5));

      if (var6.exists()) {
        var6.delete();
      }

      var7.renameTo(var6);

      if (var7.exists()) {
        var7.delete();
      }

      var5.renameTo(var7);

      if (var5.exists()) {
        var5.delete();
      }
    } catch (Exception var8) {
      var8.printStackTrace();
    }
  }
 public void func_22170_a(String s, String s1) {
   File file = new File(field_22180_a, s);
   if (!file.exists()) {
     return;
   }
   File file1 = new File(file, "level.dat");
   if (file1.exists()) {
     try {
       NBTTagCompound nbttagcompound =
           CompressedStreamTools.func_1138_a(new FileInputStream(file1));
       NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("Data");
       nbttagcompound1.setString("LevelName", s1);
       CompressedStreamTools.writeGzippedCompoundToOutputStream(
           nbttagcompound, new FileOutputStream(file1));
     } catch (Exception exception) {
       exception.printStackTrace();
     }
   }
 }
  public static NBTTagCompound getNBTFromBase64(String elementString) {
    byte[] nbtBytes = DatatypeConverter.parseBase64Binary(elementString);

    try {
      return CompressedStreamTools.func_152457_a(nbtBytes, NBTSizeTracker.field_152451_a);
    } catch (IOException e) {
      e.printStackTrace();
    }

    return null;
  }
  public static String getBase64FromNBT(NBTTagCompound compound) {
    byte[] worldDataByteArray;

    try {
      worldDataByteArray = CompressedStreamTools.compress(compound);
      return DatatypeConverter.printBase64Binary(worldDataByteArray);
    } catch (IOException e) {
      e.printStackTrace();
    }

    return null;
  }
Exemple #10
0
  /** Gets the player data for the given playername as a NBTTagCompound. */
  public NBTTagCompound getPlayerData(String par1Str) {
    try {
      File var2 = new File(this.playersDirectory, par1Str + ".dat");

      if (var2.exists()) {
        return CompressedStreamTools.readCompressed(new FileInputStream(var2));
      }
    } catch (Exception var3) {
      logger.warning("Failed to load player data for " + par1Str);
    }

    return null;
  }
Exemple #11
0
  /** Writes the player data to disk from the specified PlayerEntityMP. */
  public void writePlayerData(EntityPlayer par1EntityPlayer) {
    try {
      NBTTagCompound var2 = new NBTTagCompound();
      par1EntityPlayer.writeToNBT(var2);
      File var3 = new File(this.playersDirectory, par1EntityPlayer.username + ".dat.tmp");
      File var4 = new File(this.playersDirectory, par1EntityPlayer.username + ".dat");
      CompressedStreamTools.writeCompressed(var2, new FileOutputStream(var3));

      if (var4.exists()) {
        var4.delete();
      }

      var3.renameTo(var4);
    } catch (Exception var5) {
      logger.warning("Failed to save player data for " + par1EntityPlayer.username);
    }
  }
  /** 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();
    }
  }