コード例 #1
0
ファイル: BlockDataGrid.java プロジェクト: Corosauce/CoroUtil
  public void writeToFile(boolean unloadInstances) {
    try {

      NBTTagCompound data = new NBTTagCompound();

      Collection playerDataCl = grid.values();
      Iterator it = playerDataCl.iterator();

      while (it.hasNext()) {
        BlockDataPoint bdp = (BlockDataPoint) it.next();
        data.setTag("" + bdp.hash, bdp.writeToNBT());
      }

      String saveFolder =
          CoroUtilFile.getWorldSaveFolderPath()
              + CoroUtilFile.getWorldFolderName()
              + "epoch"
              + File.separator;

      // Write out to file
      if (!(new File(saveFolder).exists())) (new File(saveFolder)).mkdirs();
      FileOutputStream fos =
          new FileOutputStream(
              saveFolder + "EpochBlockDataDim_" + world.provider.dimensionId + ".dat");
      CompressedStreamTools.writeCompressed(data, fos);
      fos.close();

    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
コード例 #2
0
  public static NBTTagCompound getCacheCompound() {
    File cache = null;

    try {
      cache = getCacheFile();
    } catch (IOException e) {
      e.printStackTrace();
    }

    if (cache == null) throw new RuntimeException("No cache file!");

    try {
      NBTTagCompound cmp = CompressedStreamTools.readCompressed(new FileInputStream(cache));
      return cmp;
    } catch (IOException e) {
      NBTTagCompound cmp = new NBTTagCompound();

      try {
        CompressedStreamTools.writeCompressed(cmp, new FileOutputStream(cache));
        return getCacheCompound();
      } catch (IOException e1) {
        e1.printStackTrace();
        return null;
      }
    }
  }
コード例 #3
0
ファイル: CacheHelper.java プロジェクト: pete404/MineTunes
 public static void injectNBTToFile(File file, NBTTagCompound cmp) {
   try {
     CompressedStreamTools.writeCompressed(cmp, new FileOutputStream(file));
   } catch (IOException e) {
     GuiDevTools.logThrowable(e);
   }
 }
コード例 #4
0
 public static void injectNBTToFile(NBTTagCompound cmp) {
   try {
     File f = getCacheFile();
     CompressedStreamTools.writeCompressed(cmp, new FileOutputStream(f));
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
コード例 #5
0
  // api
  public PacketNEIRecipe(NBTTagCompound recipe) throws IOException {
    ByteBuf data = Unpooled.buffer();

    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    DataOutputStream outputStream = new DataOutputStream(bytes);

    data.writeInt(this.getPacketID());

    CompressedStreamTools.writeCompressed(recipe, outputStream);
    data.writeBytes(bytes.toByteArray());

    this.configureWrite(data);
  }
コード例 #6
0
  private void writeNBTToFile(String fileName, NBTTagCompound nbttagcompound) {
    System.out.println("[ShipScanner] Filename: " + fileName);

    try {
      File file = new File(fileName);
      if (!file.exists()) {
        file.createNewFile();
      }

      FileOutputStream fileoutputstream = new FileOutputStream(file);

      CompressedStreamTools.writeCompressed(nbttagcompound, fileoutputstream);

      fileoutputstream.close();
    } catch (Exception exception) {
      exception.printStackTrace();
    }
  }
コード例 #7
0
  private void writeNBTToFile(String fileName, NBTTagCompound nbttagcompound) {
    WarpDrive.logger.info(this + " Filename: " + fileName);

    try {
      File file = new File(fileName);
      if (!file.exists()) {
        file.createNewFile();
      }

      FileOutputStream fileoutputstream = new FileOutputStream(file);

      CompressedStreamTools.writeCompressed(nbttagcompound, fileoutputstream);

      fileoutputstream.close();
    } catch (Exception exception) {
      exception.printStackTrace();
    }
  }
コード例 #8
0
ファイル: CacheHelper.java プロジェクト: pete404/MineTunes
  public static NBTTagCompound getCacheCompound(File file) {
    if (file == null) throw new RuntimeException("No cache file!");

    try {
      NBTTagCompound cmp = CompressedStreamTools.readCompressed(new FileInputStream(file));
      return cmp;
    } catch (IOException e) {
      NBTTagCompound cmp = new NBTTagCompound();

      try {
        CompressedStreamTools.writeCompressed(cmp, new FileOutputStream(file));
        return getCacheCompound(file);
      } catch (IOException e1) {
        GuiDevTools.logThrowable(e1);
        return null;
      }
    }
  }
コード例 #9
0
 public static void writeNBT(NBTTagCompound tag, File file) throws IOException {
   FileOutputStream out = new FileOutputStream(file);
   CompressedStreamTools.writeCompressed(tag, out);
   out.close();
 }